Index: trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc	(revision 7005)
+++ trunk/MagicSoft/Mars/mcalib/MCalibCalcFromPast.cc	(revision 7013)
@@ -334,4 +334,5 @@
 // Read the setup from a TEnv, eg:
 //   MCalibCalcFromPast.UpdateWithFFactorMethod: Off, On
+//   MCalibCalcFromPast.NumEventsDump: 500
 //
 Int_t MCalibCalcFromPast::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
@@ -344,4 +345,10 @@
     }
 
+    if (IsEnvDefined(env, prefix, "NumEventsDump", print))
+    {
+        SetNumEventsDump(GetEnvValue(env, prefix, "NumEventsDump", (Int_t)fNumEventsDump));
+        rc = kTRUE;
+    }
+
     return rc;
 }
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 7005)
+++ 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;
 }
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 7005)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 7013)
@@ -56,4 +56,5 @@
   static const Float_t fgPheErrLimit;          //! Default for fPheErrLimit        (now set to: 4.5)
   static const Float_t fgFFactorErrLimit;      //! Default for fFFactorErrLimit    (now set to: 4.5)
+  static const Float_t fgArrTimeRmsLimit;      //! Default for fArrTimeRmsLimit    (now set to: 3.5)
  
   static const TString fgNamePedestalCam;      //! "MPedestalCam"
@@ -69,4 +70,5 @@
   Float_t fPheErrLimit;                        // Limit acceptance nr. phe's w.r.t. area idx mean (in sigmas)
   Float_t fFFactorErrLimit;                    // Limit acceptance F-Factor w.r.t. area idx mean 
+  Float_t fArrTimeRmsLimit;                    // Limit acceptance RMS of absolute arrival times
   Float_t fSqrtHiGainSamples;                  // Square root nr. High-Gain FADC slices used by extractor
   Float_t fSqrtLoGainSamples;                  // Square root nr. Low -Gain FADC slices used by extractor 
@@ -112,5 +114,6 @@
       kCheckHistOverflow,
       kCheckDeviatingBehavior,
-      kCheckOscillations
+      kCheckOscillations,
+      kCheckArrivalTimes
     };                                         // Possible Checks
 
@@ -122,4 +125,5 @@
   // functions
   void   FinalizePedestals       ( const MPedestalPix    &ped, MCalibrationChargePix &cal, const Int_t aidx );
+  void   FinalizeArrivalTimes    ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
   Bool_t FinalizeCharges         ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
   Bool_t FinalizePINDiode        ();
@@ -141,4 +145,5 @@
   Bool_t IsCheckHistOverflow     () const { return TESTBIT(fCheckFlags,kCheckHistOverflow);      }
   Bool_t IsCheckOscillations     () const { return TESTBIT(fCheckFlags,kCheckOscillations);      }
+  Bool_t IsCheckArrivalTimes     () const { return TESTBIT(fCheckFlags,kCheckArrivalTimes);      }
 
   void   PrintUncalibrated( MBadPixelsPix::UncalibratedType_t typ, const char *text) const;
@@ -182,4 +187,7 @@
 
   // Checks
+  void SetCheckArrivalTimes( const Bool_t b=kTRUE ) {
+    b ? SETBIT(fCheckFlags,kCheckArrivalTimes)
+      : CLRBIT(fCheckFlags,kCheckArrivalTimes); }
   void SetCheckDeadPixels( const Bool_t b=kTRUE ) {
     b ? SETBIT(fCheckFlags,kCheckDeadPixels)
@@ -203,4 +211,5 @@
   void SetPedestals(MPedestalCam *cam) { fPedestals=cam; }
 									 
+  void SetArrTimeRmsLimit   ( const Float_t f=fgArrTimeRmsLimit        ) { fArrTimeRmsLimit   = f;     }
   void SetFFactorErrLimit   ( const Float_t f=fgFFactorErrLimit        ) { fFFactorErrLimit   = f;     }
   void SetLambdaErrLimit    ( const Float_t f=fgLambdaErrLimit         ) { fLambdaErrLimit    = f;     }
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 7005)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 7013)
@@ -289,5 +289,5 @@
     {
       
-      if (!pix->IsExcluded()) 
+      if (pix->IsFFactorMethodValid()) 
 	{                            
 
@@ -311,5 +311,5 @@
    
   *fLog << all << endl;
-  *fLog << all << "Excluded pixels:" << endl;
+  *fLog << all << "Previously Excluded pixels:" << endl;
   *fLog << all << endl;
   
@@ -329,4 +329,21 @@
   }
   
+  *fLog << all << endl;
+  *fLog << all << "New Excluded pixels:" << endl;
+  *fLog << all << endl;
+  
+  TIter Next5(fPixels);
+  while ((pix=(MCalibrationChargePix*)Next5()))
+  {
+      if (!pix->IsFFactorMethodValid() && !pix->IsExcluded())
+      {
+        *fLog << all << pix->GetPixId() << " ";
+        id++;
+
+        if (!(id % 25))
+          *fLog << endl;
+      }
+  }
+  
   *fLog << endl;
   *fLog << all << id << " Excluded pixels " << endl;
@@ -337,6 +354,6 @@
   *fLog << all << endl;
 
-  TIter Next5(fAverageAreas);
-  while ((pix=(MCalibrationChargePix*)Next5()))
+  TIter Next6(fAverageAreas);
+  while ((pix=(MCalibrationChargePix*)Next6()))
   {
     *fLog << all << Form("%s%3i","Area Idx: ",pix->GetPixId())
@@ -353,6 +370,6 @@
   *fLog << all << endl;
 
-  TIter Next6(fAverageSectors);
-  while ((pix=(MCalibrationChargePix*)Next6()))
+  TIter Next7(fAverageSectors);
+  while ((pix=(MCalibrationChargePix*)Next7()))
   {
     *fLog << all << Form("%s%3i","Sector: ",pix->GetPixId())
@@ -482,5 +499,5 @@
       break;
     case 5:
-      if (pix.IsExcluded())
+      if (!pix.IsFFactorMethodValid())
         return kFALSE;
       if (pix.GetRSigma() == -1.)
@@ -489,5 +506,5 @@
       break;
     case 6:
-      if (pix.IsExcluded())
+      if (!pix.IsFFactorMethodValid())
         return kFALSE;    
       if (pix.GetRSigma() == -1.)
@@ -496,40 +513,40 @@
       break;
     case 7:
-      if (pix.IsExcluded())
+      if (!pix.IsFFactorMethodValid())
         return kFALSE;
       val = pix.GetRSigmaPerCharge();
       break;
     case 8:
-      if (pix.IsExcluded())
+      if (!pix.IsFFactorMethodValid())
         return kFALSE;
       val =  pix.GetRSigmaPerChargeErr();
       break;
     case 9:
-      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
+      if (!pix.IsFFactorMethodValid())
         return kFALSE;
       val = pix.GetPheFFactorMethod();
       break;
     case 10:
-      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
+      if (!pix.IsFFactorMethodValid())
         return kFALSE;
       val = pix.GetPheFFactorMethodErr();
       break;
     case 11:
-      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
+      if (!pix.IsFFactorMethodValid())
         return kFALSE;
       val = pix.GetMeanConvFADC2Phe();
       break;
     case 12:
-      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
+      if (!pix.IsFFactorMethodValid())
         return kFALSE;
       val = pix.GetMeanConvFADC2PheErr();
       break;
     case 13:
-      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
+      if (!pix.IsFFactorMethodValid())
         return kFALSE;
       val = pix.GetMeanFFactorFADC2Phot();
       break;
     case 14:
-      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
+      if (!pix.IsFFactorMethodValid())
         return kFALSE;
       val = pix.GetMeanFFactorFADC2PhotErr();
@@ -625,5 +642,15 @@
       break;
     case 32:
+      if (pix.IsExcluded())
+        return kFALSE;
       val = pix.GetMean() == 0. ? 0. : pix.GetRms()/pix.GetMean();
+      break;
+    case 33:
+      if (pix.IsExcluded())
+        return kFALSE;
+      if (pix.GetMean() == 0.)
+        val = 0.;
+      else
+        val = pix.GetSigmaErr()/pix.GetMean() + pix.GetRms()/pix.GetMean()/pix.GetMean()*pix.GetMeanErr();
       break;
     default:
@@ -633,5 +660,4 @@
   return val!=-1.;
 }
-
 
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc	(revision 7005)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc	(revision 7013)
@@ -69,4 +69,8 @@
 //           MHCalibrationChargeCam, MHCalibrationChargePix
 //
+//
+// ClassVersion 3:
+//  + fNumSaturated
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MCalibrationChargePix.h"
@@ -90,4 +94,5 @@
 const Float_t MCalibrationChargePix::fgPheFFactorMethodLimit    = 1.;
 const Float_t MCalibrationChargePix::fgConvFFactorRelErrLimit   = 0.85;
+
 // --------------------------------------------------------------------------
 //
@@ -105,5 +110,5 @@
 //
 MCalibrationChargePix::MCalibrationChargePix(const char *name, const char *title)
-    : fCalibFlags(0)
+    : fCalibFlags(0), fNumSaturated(0)
 {
 
@@ -158,4 +163,6 @@
   fMeanFFactorFADC2Phot             =  -1.;
   fMeanFFactorFADC2PhotVar          =  -1.;  
+
+  fNumSaturated                     =   0;
 
   MCalibrationPix::Clear();
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h	(revision 7005)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h	(revision 7013)
@@ -41,4 +41,6 @@
   Float_t fRSigmaSquare;                    // Square of Reduced sigma
   Float_t fRSigmaSquareVar;                 // Variance Reduced sigma
+
+  Int_t   fNumSaturated;                    // Number of (high-gain) saturated events
   
   enum  { kFFactorMethodValid   };          // Possible bits to be set
@@ -71,4 +73,5 @@
   void SetPheFFactorMethodVar   ( const Float_t f)                          { fPheFFactorMethodVar    = f; }  
   void SetPheFFactorMethodLimit ( const Float_t f=fgPheFFactorMethodLimit ) { fPheFFactorMethodLimit  = f; }
+  void SetNumSaturated          ( const Int_t   i)                          { fNumSaturated           = i; }
   
   // Getters
@@ -90,4 +93,5 @@
   Float_t GetMeanFFactorFADC2PhotErr () const;
   Float_t GetMeanFFactorFADC2PhotVar () const { return fMeanFFactorFADC2PhotVar; }    
+  Int_t   GetNumSaturated            () const { return fNumSaturated;            }
   Float_t GetPed                     () const { return fPed;                     }
   Float_t GetPedErr                  () const { return TMath::Sqrt(fPedVar);     }
@@ -113,5 +117,5 @@
   Bool_t CalcMeanFFactor   ( const Float_t nphotons, const Float_t nphotonsrelvar );
   
-  ClassDef(MCalibrationChargePix, 2)	// Container Charge Calibration Results Pixel
+  ClassDef(MCalibrationChargePix, 3)	// Container Charge Calibration Results Pixel
 };
 
