Index: trunk/FACT++/src/fscctrl.cc
===================================================================
--- trunk/FACT++/src/fscctrl.cc	(revision 19583)
+++ trunk/FACT++/src/fscctrl.cc	(revision 19584)
@@ -32,4 +32,7 @@
     bool fIsVerbose;
     bool fIsAutoReconnect;
+
+    uint16_t fTempMin;
+    uint16_t fTempMax;
 
     size_t fNumConsecutiveErrors;   // Number of consecutive messages with errors
@@ -253,8 +256,7 @@
         //970=-7.6
         //1300=76
+        //DD 2019/09/01: changed from 970 to 980 as sensor 19 had values slighly larger than -7.6
         for (int *pt=mapt; *pt>=0; pt++)
-            //temperatures.push_back(resist[*pt]>800&&resist[*pt]<2000 ? GetTempPT1000(resist[*pt]) : 0);
-            temperatures.push_back(resist[*pt]>970&&resist[*pt]<1300 ? GetTempPT1000(resist[*pt]) : 0);
-            //temperatures.push_back(resist[*pt]>1019&&resist[*pt]<1300 ? GetTempPT1000(resist[*pt]) : 0);
+            temperatures.push_back(resist[*pt]>=fTempMin && resist[*pt]<=fTempMax ? GetTempPT1000(resist[*pt]) : 0);
 
         // 0 = 3-(3+0)%4
@@ -440,7 +442,5 @@
         {
             for (size_t i=0; i<resist.size(); i++)
-                //if (resist[i]>800 && resist[i]<2000)
-                if (resist[i]>970 && resist[i]<1300)
-                //if (resist[i]>1019 && resist[i]<1300)
+                if (resist[i]>=fTempMin && resist[i]<=fTempMax)
                     Out() << setw(2) << i << " - " << setw(4) << (int)resist[i] << ": " << setprecision(1) << fixed << GetTempPT1000(resist[i]) << endl;
                 else
@@ -562,5 +562,5 @@
 public:
     ConnectionFSC(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()),
-        fIsVerbose(false), fIsAutoReconnect(false), fReconnectTimeout(ioservice)
+        fIsVerbose(false), fIsAutoReconnect(false), fTempMin(0), fTempMax(65535), fReconnectTimeout(ioservice)
     {
         SetLogStream(&imp);
@@ -580,4 +580,14 @@
     {
         fPositionsBias = vec;
+    }
+
+    void SetTempMin(const uint16_t &min)
+    {
+        fTempMin = min;
+    }
+
+    void SetTempMax(const uint16_t &max)
+    {
+        fTempMax = max;
     }
 
@@ -627,4 +637,7 @@
             if (temp[i]!=0)
             {
+                if (temp[i]<0)
+                    Warn(Tools::Form("Temperature sensor %2d has negative temperature (%7.2f deg C)", i, temp[i]));
+
                 T.emplace_back(temp[i]);
                 xy.emplace_back(fPositionsSensors[i]);
@@ -636,5 +649,5 @@
         if (T.size()==0)
         {
-            Warn("No valid sensor temperatures.");
+            Warn("No valid temperatures from compartment sensors.");
             return;
         }
@@ -649,12 +662,12 @@
         const bool reject = rms>4 || (fabs(fLastRms[0]-fLastRms[1])<=cut_val && fabs(rms-fLastRms[0])>cut_val);
 
+        if (reject)
+            Warn(Tools::Form("RMS of compartment temperature suspicous: T[0]:%6.2f (n=%2d) T[1]:%6.2f T[2]:%6.2f... rejected.", rms, T.size(), fLastRms[0], fLastRms[1]));
+
         fLastRms[1] = fLastRms[0];
         fLastRms[0] = rms;
 
         if (reject)
-        {
-            Warn("Suspicious temperature values rejecte for BIAS_TEMP.");
             return;
-        }
 
         // Create interpolator for the corresponding sensor positions
@@ -664,5 +677,5 @@
         if (!inter.SetOutputGrid(fPositionsBias))
         {
-            Warn("Temperature values rejecte for BIAS_TEMP (calculation of weights failed).");
+            Warn("Interpolation for n="+to_string(xy.size())+" grid positions failed... rejected.");
             return;
         }
@@ -859,4 +872,7 @@
         fFSC.SetVerbose(!conf.Get<bool>("quiet"));
 
+        fFSC.SetTempMin(conf.Get<uint16_t>("temp-adc-min"));
+        fFSC.SetTempMax(conf.Get<uint16_t>("temp-adc-max"));
+
         const string fname1 = conf.GetPrefixedString("sensor-pos-file");
         const auto v1 = Interpolator2D::ReadGrid(fname1);
@@ -903,4 +919,6 @@
         ("patch-pos-file",  var<string>()->required(),  "File with the positions of the 320 bias patches")
         ("quiet,q",       po_bool(true),  "Disable printing contents of all received messages (except dynamic data) in clear text.")
+        ("temp-adc-min",  var<uint16_t>(uint16_t(980)),  "Minimum ADC value for allowed range of temperature ADCs (default ~ -7.4 deg C)")
+        ("temp-adc-max",  var<uint16_t>(uint16_t(1300)), "Maximum ADC value for allowed range of temperature ADCs (default ~ 76 deg C)")
         ;
 
