Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 6928)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 7013)
@@ -231,5 +231,5 @@
 using namespace std;
 
-const Float_t MCalibrationChargeCalc::fgChargeLimit            = 2.5;
+const Float_t MCalibrationChargeCalc::fgChargeLimit            = 4.5;
 const Float_t MCalibrationChargeCalc::fgChargeErrLimit         = 0.;
 const Float_t MCalibrationChargeCalc::fgChargeRelErrLimit      = 1.;
@@ -238,5 +238,7 @@
 const Float_t MCalibrationChargeCalc::fgPheErrLimit            = 4.5;
 const Float_t MCalibrationChargeCalc::fgFFactorErrLimit        = 4.5;
+const Float_t MCalibrationChargeCalc::fgArrTimeRmsLimit        = 3.5;
 const TString MCalibrationChargeCalc::fgNamePedestalCam = "MPedestalCam";
+
 // --------------------------------------------------------------------------
 //
@@ -252,4 +254,5 @@
 //
 // Initializes:
+// - fArrTimeRmsLimit   to fgArrTimeRmsLimit
 // - fChargeLimit       to fgChargeLimit 
 // - fChargeErrLimit    to fgChargeErrLimit   
@@ -282,4 +285,5 @@
   AddToBranchList("MRawEvtData.fLoGainFadcSamples");
   
+  SetArrTimeRmsLimit   ();
   SetChargeLimit       ();
   SetChargeErrLimit    ();  
@@ -294,4 +298,5 @@
   SetDebug       ( kFALSE );
 
+  SetCheckArrivalTimes     ();
   SetCheckDeadPixels       ();
   SetCheckDeviatingBehavior();
@@ -732,4 +737,6 @@
       if (FinalizeCharges(pix,bad,"pixel  "))
         nvalid++;
+
+      FinalizeArrivalTimes(pix,bad,"pixel  ");
     }
 
@@ -760,4 +767,5 @@
       FinalizePedestals(ped,pix,aidx);
       FinalizeCharges(pix, chargecam->GetAverageBadArea(aidx),"area id");
+      FinalizeArrivalTimes(pix, chargecam->GetAverageBadArea(aidx), "area id");
     }
   
@@ -855,4 +863,10 @@
   PrintUncalibrated(MBadPixelsPix::kLoGainOverFlow,    
                     "Pixels with Low Gain Overflow :                   ");
+  PrintUncalibrated(MBadPixelsPix::kFluctuatingArrivalTimes,
+                    "Fluctuating Pulse Arrival Times:                  ");
+  PrintUncalibrated(MBadPixelsPix::kDeadPedestalRms,
+                    "Presumably dead from Pedestal Rms:                ");
+  PrintUncalibrated(MBadPixelsPix::kPreviouslyExcluded,
+                    "Previously excluded:                              ");
 
   *fLog << inf << endl;
@@ -1018,5 +1032,23 @@
 }
 
-
+// -----------------------------------------------------------------------------------
+//
+// Test the arrival Times RMS of the pixel and set the bit
+// - MBadPixelsPix::kFluctuatingArrivalTimes
+//
+void MCalibrationChargeCalc::FinalizeArrivalTimes(MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what)
+{
+    if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        return;
+
+    if (cal.GetAbsTimeRms() > fArrTimeRmsLimit)
+    {
+        *fLog << warn;
+        *fLog << "RMS of pulse arrival times: " << Form("%2.1f", cal.GetAbsTimeRms());
+        *fLog << " FADC sl. < " << Form("%2.1", fArrTimeRmsLimit);
+        *fLog << "   in " << what << Form("%3i", cal.GetPixId()) << endl;
+        bad.SetUncalibrated( MBadPixelsPix::kFluctuatingArrivalTimes);
+    }
+}
 
 // -----------------------------------------------------------------------------------
@@ -1039,14 +1071,10 @@
 {
   
-  MBadPixelsCam         *badcam    = fIntensBad 
-    ? (MBadPixelsCam*)        fIntensBad->GetCam()  : fBadPixels;
-  MCalibrationChargeCam *chargecam = fIntensCam 
-    ? (MCalibrationChargeCam*)fIntensCam->GetCam()  : fCam;
+  MBadPixelsCam *badcam = fIntensBad ? (MBadPixelsCam*)fIntensBad->GetCam() : fBadPixels;
 
   for (Int_t i=0; i<badcam->GetSize(); i++)
     {
       
-      MBadPixelsPix    &bad    = (*badcam)   [i];
-      MCalibrationPix  &pix    = (*chargecam)[i];
+      MBadPixelsPix &bad = (*badcam)[i];
 
       if (IsCheckDeadPixels())
@@ -1086,6 +1114,9 @@
         }
       
-      if (bad.IsUnsuitable(   MBadPixelsPix::kUnsuitableRun    ))
-        pix.SetExcluded();
+      if (IsCheckArrivalTimes())
+        {
+          if (bad.IsUncalibrated( MBadPixelsPix::kFluctuatingArrivalTimes ))
+            bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
+        }
 
       if (bad.IsUncalibrated( MBadPixelsPix::kChargeSigmaNotValid ))
@@ -1812,5 +1843,4 @@
           qepix.SetFFactorMethodValid(kFALSE,fPulserColor);
           pix.SetFFactorMethodValid(kFALSE);
-          pix.SetExcluded();
           continue;
         }
@@ -2200,4 +2230,9 @@
       rc = kTRUE;
     }
+  if (IsEnvDefined(env, prefix, "ArrTimeRmsLimit", print))
+    {
+      SetArrTimeRmsLimit(GetEnvValue(env, prefix, "ArrTimeRmsLimit", fArrTimeRmsLimit));
+      rc = kTRUE;
+    }
   if (IsEnvDefined(env, prefix, "FFactorErrLimit", print))
     {
@@ -2245,5 +2280,10 @@
       rc = kTRUE;
     }
-  
+  if (IsEnvDefined(env, prefix, "CheckArrivalTimes", print))
+    {
+      SetCheckArrivalTimes(GetEnvValue(env, prefix, "CheckArrivalTimes", IsCheckArrivalTimes()));
+      rc = kTRUE;
+    }
+
   return rc;
 }
