Index: trunk/FACT++/src/smartfact.cc
===================================================================
--- trunk/FACT++/src/smartfact.cc	(revision 17191)
+++ trunk/FACT++/src/smartfact.cc	(revision 17192)
@@ -18,5 +18,4 @@
 #include "DimWriteStatistics.h"
 #include "externals/PixelMap.h"
-#include "externals/Interpolator2D.h"
 
 #include "tools.h"
@@ -601,5 +600,5 @@
         if (!col.empty())
             out << col;
-        for (auto it=vec.begin(); it!=vec.end(); it++)
+        for (auto it=vec.cbegin(); it!=vec.cend(); it++)
         {
             // The valid range is from 1 to 127
@@ -684,6 +683,6 @@
             avg = accumulate (t.begin(), t.end(), 0.)/t.size();
 
-            const size_t p = t.size()/2;
-            med = p%2 ? copy[p] : (copy[p-1]+copy[p])/2.;
+            const size_t p = copy.size()/2;
+            med = copy.size()%2 ? copy[p] : (copy[p-1]+copy[p])/2.;
         }
     };
@@ -1751,19 +1750,19 @@
     int HandleFscBiasTemp(const EventImp &d)
     {
-        if (!CheckDataSize(d, "FscControl:BiasTemp", 321*4))
+        if (!CheckDataSize(d, "FscControl:BiasTemp", 323*4))
             return GetCurrentState();
 
         const float *ptr = d.Ptr<float>(4);
+        const float avg = d.Get<float>(321*4);
+        //const float rms = d.Get<float>(322*4);
 
         vector<double> tout(320);
-        double pavg = 0;
         for (int i=0; i<320; i++)
         {
             const int idx = (fPixelMap.hv(i).hw()/9)*2+fPixelMap.hv(i).group();
             tout[idx] = ptr[i];
-            pavg += ptr[i];
-        }
-
-        WriteCam(d, "cam-fsccontrol-temperature", tout, 3, pavg/320-1.75);
+        }
+
+        WriteCam(d, "cam-fsccontrol-temperature", tout, 3, avg-1.75);
 
         return GetCurrentState();
