Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationCam.cc	(revision 3694)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationCam.cc	(revision 3696)
@@ -393,12 +393,20 @@
 {
 
-  fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
-  if (!fBadPixels)
-      return kFALSE;
-
-
   const Int_t npixels  = fGeom->GetNumPixels();
   const Int_t nsectors = fGeom->GetNumSectors();
   const Int_t nareas   = fGeom->GetNumAreas();
+
+  fBadPixels = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
+  if (!fBadPixels)
+    {
+      fBadPixels = (MBadPixelsCam*)pList->FindCreateObj(AddSerialNumber("MBadPixelsCam"));
+      if (!fBadPixels)
+        {
+          gLog << err << "Cannot find nor create MBadPixelsCam ... abort." << endl;
+          return kFALSE;
+        }
+      else 
+        fBadPixels->InitSize(npixels);
+    }
 
   //
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h	(revision 3694)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.h	(revision 3696)
@@ -7,6 +7,5 @@
 
 class MRawEvtData;
-class MBadPixelsPix;
-class MCalibrationChargeCam;
+class MExtractedSignalCam;
 class MCalibrationChargePix;
 class MHCalibrationChargePix;
@@ -15,20 +14,26 @@
 private:
 
-  static const Float_t fgNumHiGainSaturationLimit;   // The default for fNumHiGainSaturationLimit
-  static const Float_t fgNumLoGainSaturationLimit;   // The default for fNumLoGainSaturationLimit
+  static const Float_t fgNumHiGainSaturationLimit;   //! The default for fNumHiGainSaturationLimit (now at: 0.01)
+  static const Float_t fgNumLoGainSaturationLimit;   //! The default for fNumLoGainSaturationLimit (now at: 0.005)
+  static const Float_t fgTimeLowerLimit;             //! Default for fTimeLowerLimit    (now set to: 1.) 
+  static const Float_t fgTimeUpperLimit;             //! Default for fTimeUpperLimit    (now set to: 2.)
   
   Float_t fNumHiGainSaturationLimit;  // Rel. amount sat. higain FADC slices until pixel is called saturated
   Float_t fNumLoGainSaturationLimit;  // Rel. amount sat. logain FADC slices until pixel is called saturated
-  
-  MRawEvtData *fRawEvt;               //!  Raw event data 
+  Float_t fTimeLowerLimit;            // Limit dist. to first signal slice (in units of FADC slices) 
+  Float_t fTimeUpperLimit;            // Limit dist. to last signal slice  (in units of FADC slices) 
+
+  MRawEvtData         *fRawEvt;       //!  Raw event data 
+  MExtractedSignalCam *fSig;          //!  Signal Extractor
 
   Bool_t SetupHists(const MParList *pList);
   Bool_t ReInitHists(MParList *pList);
   Bool_t FillHists(const MParContainer *par, const Stat_t w=1);
+
+  void   FinalizeAbsTimes (MHCalibrationChargePix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad,
+                           Byte_t first, Byte_t last);  
   Bool_t FinalizeHists();
   void   FinalizeBadPixels();
 
-  void FinalizeHiGainHists(MHCalibrationChargePix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad);
-  void FinalizeLoGainHists(MHCalibrationChargePix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad);
 
  public:
@@ -39,4 +44,6 @@
   void SetNumLoGainSaturationLimit( const Float_t lim=fgNumLoGainSaturationLimit) { fNumLoGainSaturationLimit = lim; }
   void SetNumHiGainSaturationLimit( const Float_t lim=fgNumHiGainSaturationLimit) { fNumHiGainSaturationLimit = lim; }
+  void SetTimeLowerLimit    ( const Float_t f=fgTimeLowerLimit         ) { fTimeLowerLimit    = f;   }
+  void SetTimeUpperLimit    ( const Float_t f=fgTimeUpperLimit         ) { fTimeUpperLimit    = f;   }
   
   Float_t GetNumHiGainSaturationLimit()      const  { return fNumHiGainSaturationLimit; }
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.cc	(revision 3694)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.cc	(revision 3696)
@@ -52,13 +52,15 @@
 using namespace std;
 
-const Int_t   MHCalibrationChargePINDiode::fgChargeNbins     = 200;
+const Axis_t  MHCalibrationChargePINDiode::fgAbsTimeFirst    = -0.5;
+const Axis_t  MHCalibrationChargePINDiode::fgAbsTimeLast     = 29.5;
+const Int_t   MHCalibrationChargePINDiode::fgAbsTimeNbins    = 30;
 const Axis_t  MHCalibrationChargePINDiode::fgChargeFirst     = -0.5;
 const Axis_t  MHCalibrationChargePINDiode::fgChargeLast      = 199.5;
+const Int_t   MHCalibrationChargePINDiode::fgChargeNbins     = 200;
 const Int_t   MHCalibrationChargePINDiode::fgRmsChargeNbins  = 100;
 const Axis_t  MHCalibrationChargePINDiode::fgRmsChargeFirst  = 0.;
 const Axis_t  MHCalibrationChargePINDiode::fgRmsChargeLast   = 100.;  
-const Int_t   MHCalibrationChargePINDiode::fgAbsTimeNbins    = 30;
-const Axis_t  MHCalibrationChargePINDiode::fgAbsTimeFirst    = -0.5;
-const Axis_t  MHCalibrationChargePINDiode::fgAbsTimeLast     = 29.5;
+const Float_t MHCalibrationChargePINDiode::fgTimeLowerLimit  = 3.;
+const Float_t MHCalibrationChargePINDiode::fgTimeUpperLimit  = 4.;
 // --------------------------------------------------------------------------
 //
@@ -66,4 +68,7 @@
 //
 // Sets: 
+// - the default number for fAbsTimeFirst        (fgAbsTimeFirst)
+// - the default number for fAbsTimeLast         (fgAbsTimeLast)
+// - the default number for fAbsTimeNbins        (fgAbsTimeNbins)
 // - the default number for MHGausEvents::fNbins (fgChargeNbins)
 // - the default number for MHGausEvents::fFirst (fgChargeFirst)
@@ -72,7 +77,6 @@
 // - the default number for fRmsChargeFirst      (fgRmsChargeFirst)
 // - the default number for fRmsChargeLast       (fgRmsChargeLast)
-// - the default number for fAbsTimeNbins        (fgAbsTimeNbins)
-// - the default number for fAbsTimeFirst        (fgAbsTimeFirst)
-// - the default number for fAbsTimeLast         (fgAbsTimeLast)
+// - the default number for fTimeLowerLimit      (fgTimeLowerLimit)
+// - the default number for fTimeUpperLimit      (fgTimeUpperLimit)
 //
 // - the default name of the  fHGausHist      ("HCalibrationChargePINDiode")
@@ -99,5 +103,5 @@
 //
 MHCalibrationChargePINDiode::MHCalibrationChargePINDiode(const char *name, const char *title)
-    : fPINDiode(NULL), fHRmsCharge()
+    : fPINDiode(NULL), fSigPIN(NULL), fHRmsCharge()
 {
 
@@ -105,4 +109,8 @@
   fTitle = title ? title : "Fill the FADC sums of the PINDiode events and perform the fits";
   
+  SetAbsTimeFirst();
+  SetAbsTimeLast();
+  SetAbsTimeNbins();
+
   SetNbins( fgChargeNbins );
   SetFirst( fgChargeFirst );
@@ -113,7 +121,6 @@
   SetRmsChargeLast();
   
-  SetAbsTimeNbins();
-  SetAbsTimeFirst();
-  SetAbsTimeLast();
+  SetTimeLowerLimit();
+  SetTimeUpperLimit();
 
   fHGausHist.SetName("HCalibrationChargePINDiode");
@@ -159,4 +166,5 @@
 //
 // Gets or creates the pointers to:
+// - MExtractedSignalPINDiode
 // - MCalibrationChargePINDiode
 //
@@ -164,4 +172,11 @@
 {
   
+  fSigPIN = (MExtractedSignalPINDiode*)pList->FindCreateObj("MExtractedSignalPINDiode");
+  if (!fSigPIN)
+  {
+      *fLog << err << "MExtractedSignalPINDiode not found... aborting " << endl;
+      return kFALSE;
+  }
+
   fPINDiode = (MCalibrationChargePINDiode*)pList->FindCreateObj("MCalibrationChargePINDiode");
   if (!fPINDiode)
@@ -237,4 +252,10 @@
 // - Rms Charge Sigma and Error
 // 
+// Performs one consistency check on the arrival time: 
+// The check returns kFALSE if:
+//
+// -The mean arrival time is in fTimeLowerLimit slices from the lower edge 
+//  and fUpperLimit slices from the upper edge
+//
 Bool_t MHCalibrationChargePINDiode::Finalize() 
 {
@@ -262,4 +283,25 @@
   fPINDiode->SetRmsChargeSigma(    GetRmsChargeSigma()       );
   fPINDiode->SetRmsChargeSigmaErr( GetRmsChargeSigmaErr()    );
+
+  const Byte_t  loweredge  = fSigPIN->GetFirstUsedSlice();
+  const Byte_t  upperedge  = fSigPIN->GetLastUsedSlice();
+  const Float_t lowerlimit = (Float_t)loweredge + fTimeLowerLimit;
+  const Float_t upperlimit = (Float_t)upperedge + fTimeUpperLimit;  
+
+  if (GetAbsTimeMean() < lowerlimit)
+    {
+      *fLog << warn << GetDescriptor() << ": Mean ArrivalTime in first " << fTimeLowerLimit 
+            << " extraction bin in PIN Diode " << endl;
+      *fLog << GetAbsTimeMean() << "   " << lowerlimit << endl;
+      return kFALSE;
+    }
+  
+  if ( GetAbsTimeMean() > upperlimit )
+    {
+      *fLog << warn << GetDescriptor() << ": Mean ArrivalTime in last " << fTimeUpperLimit 
+            << " two extraction bins in PIN Diode " << endl;
+      *fLog << GetAbsTimeMean() << "   " << upperlimit << endl;
+      return kFALSE;
+    }
 
   return kTRUE;
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.h	(revision 3694)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.h	(revision 3696)
@@ -8,4 +8,5 @@
 
 class TH1F;
+class MExtractedSignalPINDiode;
 class MCalibrationChargePINDiode;
 class MHCalibrationChargePINDiode : public MHCalibrationChargePix
@@ -13,4 +14,7 @@
 private:
 
+  static const Axis_t  fgAbsTimeFirst;    //! Default for fAbsTimeFirst    (now set to: -0.5  )
+  static const Axis_t  fgAbsTimeLast;     //! Default for fAbsTimeLast     (now set to: 29.5  )
+  static const Int_t   fgAbsTimeNbins;    //! Default for fAbsTimeNBins    (now set to: 30    )
   static const Int_t   fgChargeNbins;     //! Default for fNBins           (now set to: 200   )
   static const Axis_t  fgChargeFirst;     //! Default for fFirst           (now set to: -0.5  )
@@ -19,21 +23,22 @@
   static const Axis_t  fgRmsChargeFirst;  //! Default for fRmsChargeFirst  (now set to: 0.    )
   static const Axis_t  fgRmsChargeLast;   //! Default for fRmsChargeLast   (now set to: 100.  )
-  static const Int_t   fgAbsTimeNbins;    //! Default for fAbsTimeNBins    (now set to: 30    )
-  static const Axis_t  fgAbsTimeFirst;    //! Default for fAbsTimeFirst    (now set to: -0.5  )
-  static const Axis_t  fgAbsTimeLast;     //! Default for fAbsTimeLast     (now set to: 29.5  )
+  static const Float_t fgTimeLowerLimit;  //! Default for fTimeLowerLimit    (now set to: 1.) 
+  static const Float_t fgTimeUpperLimit;  //! Default for fTimeUpperLimit    (now set to: 2.)
+  
+  MCalibrationChargePINDiode *fPINDiode;  //! Storage container of the results
+  MExtractedSignalPINDiode   *fSigPIN;    //! Storage container of extracted signal
 
-  MCalibrationChargePINDiode *fPINDiode; //! Storage container of the results
+  TH1F fHRmsCharge;                       //  Histogram containing Variance of summed FADC slices
 
-  TH1F fHRmsCharge;                      // Histogram containing Variance of summed FADC slices
-
-  Int_t   fRmsChargeNbins;               // Number of  bins used for the fHRmsCharge
-  Axis_t  fRmsChargeFirst;               // Lower bound bin used for the fHRmsCharge
-  Axis_t  fRmsChargeLast;                // Upper bound bin used for the fHRmsCharge
-
-  Float_t fRmsChargeMean;                //  Mean of the Gauss fit               
-  Float_t fRmsChargeSigma;               //  Sigma of the Gauss fit             
-  Float_t fRmsChargeMeanErr;             //  Error of the mean of the Gauss fit 
-  Float_t fRmsChargeSigmaErr;            //  Error of the sigma of the Gauss fit
-
+  Axis_t  fRmsChargeFirst;                //  Lower bound bin used for the fHRmsCharge
+  Axis_t  fRmsChargeLast;                 //  Upper bound bin used for the fHRmsCharge
+  Int_t   fRmsChargeNbins;                //  Number of  bins used for the fHRmsCharge
+  Float_t fRmsChargeMean;                 //  Mean of the Gauss fit               
+  Float_t fRmsChargeMeanErr;              //  Error of the mean of the Gauss fit 
+  Float_t fRmsChargeSigma;                //  Sigma of the Gauss fit             
+  Float_t fRmsChargeSigmaErr;             //  Error of the sigma of the Gauss fit
+  Float_t fTimeLowerLimit;                //  Limit dist. to first signal slice (units: FADC slices) 
+  Float_t fTimeUpperLimit;                //  Limit dist. to last signal slice  (units: FADC slices) 
+  
 public:
 
@@ -44,23 +49,16 @@
   Bool_t ReInit   (      MParList *pList);
   Bool_t Fill     (const MParContainer *par, const Stat_t w=1);
-  Bool_t Finalize();
-
-  // Setters
-  void SetAbsTimeNbins(const Int_t  bins =fgAbsTimeNbins)        { fAbsTimeNbins = bins;    }
-  void SetAbsTimeFirst(const Axis_t first=fgAbsTimeFirst)        { fAbsTimeFirst = first;   }
-  void SetAbsTimeLast( const Axis_t last =fgAbsTimeLast)         { fAbsTimeLast  = last;    }
-
-  void SetRmsChargeNbins(const Int_t  bins =fgRmsChargeNbins)    { fRmsChargeNbins = bins;  }
-  void SetRmsChargeFirst(const Axis_t first=fgRmsChargeFirst)    { fRmsChargeFirst = first; }
-  void SetRmsChargeLast( const Axis_t last =fgRmsChargeLast)     { fRmsChargeLast  = last;  }
-
+  Bool_t Finalize ();
+  
+  // Draw
+  void Draw(Option_t *opt="");
+  
   // Getters
-  TH1F *GetHRmsCharge()                        { return &fHRmsCharge;  }
-  const TH1F *GetHRmsCharge()            const { return &fHRmsCharge;  }
-
-  Float_t  GetRmsChargeMean()            const { return fRmsChargeMean; }
-  Float_t  GetRmsChargeMeanErr()         const { return fRmsChargeMeanErr; }
-  Float_t  GetRmsChargeSigma()           const { return fRmsChargeSigma; }
-  Float_t  GetRmsChargeSigmaErr()        const { return fRmsChargeSigmaErr; }
+        TH1F *GetHRmsCharge()                  { return &fHRmsCharge;       }
+  const TH1F *GetHRmsCharge()            const { return &fHRmsCharge;       }
+  Float_t     GetRmsChargeMean()         const { return fRmsChargeMean;     }
+  Float_t     GetRmsChargeMeanErr()      const { return fRmsChargeMeanErr;  }
+  Float_t     GetRmsChargeSigma()        const { return fRmsChargeSigma;    }
+  Float_t     GetRmsChargeSigmaErr()     const { return fRmsChargeSigmaErr; }
 
   // Fill histos
@@ -70,7 +68,14 @@
   Bool_t FitRmsCharge(Option_t *option="RQ0");
 
-  // Draw
-  void Draw(Option_t *opt="");
-  
+  // Setters
+  void SetAbsTimeNbins   ( const Int_t   bins =fgAbsTimeNbins   ) { fAbsTimeNbins   = bins;  }
+  void SetAbsTimeFirst   ( const Axis_t  first=fgAbsTimeFirst   ) { fAbsTimeFirst   = first; }
+  void SetAbsTimeLast    ( const Axis_t  last =fgAbsTimeLast    ) { fAbsTimeLast    = last;  }
+  void SetRmsChargeNbins ( const Int_t   bins =fgRmsChargeNbins ) { fRmsChargeNbins = bins;  }
+  void SetRmsChargeFirst ( const Axis_t  first=fgRmsChargeFirst ) { fRmsChargeFirst = first; }
+  void SetRmsChargeLast  ( const Axis_t  last =fgRmsChargeLast  ) { fRmsChargeLast  = last;  }
+  void SetTimeLowerLimit ( const Float_t f=fgTimeLowerLimit     ) { fTimeLowerLimit = f;     }
+  void SetTimeUpperLimit ( const Float_t f=fgTimeUpperLimit     ) { fTimeUpperLimit = f;     }
+
   ClassDef(MHCalibrationChargePINDiode, 1)  // Histogram class for Charge PIN Diode Calibration 
 };
