Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 4851)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 4852)
@@ -26,6 +26,12 @@
 
    * mcalib/MCalibrationChargeCam.[h,cc]
-     - two new functions GetAveragedConvFADC2PhotPerArea and 
-       GetAveragedConvFADC2PhotPerSector, to be used by the data check.
+     - new functions:
+       GetAveragedConvFADC2PhotPerArea,  
+       GetAveragedConvFADC2PhotPerSector, 
+       GetAveragedArrivalTimeMeanPerArea,  
+       GetAveragedArrivalTimeMeanPerSector, 
+       GetAveragedArrivalTimeRmsPerArea,  
+       GetAveragedArrivalTimeRmsPerSector, 
+       to be used by the data check.
 
    * mcalib/MCalibrationQEPix.[h,cc]
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 4851)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 4852)
@@ -675,2 +675,198 @@
   return arr;
 }  
+
+// --------------------------------------------------------------------------
+//
+// Calculates the average mean arrival times for pixel sizes. 
+// The geometry container is used to get the necessary
+// geometry information (area index). 
+// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
+// in the calculation of the size average.
+//
+// Returns a TArrayF of dimension 2: 
+// arr[0]: averaged mean arrival times (default: -1.)
+// arr[1]: Error (rms) of averaged mean arrival times (default: 0.)
+//
+// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
+//
+TArrayF *MCalibrationChargeCam::GetAveragedArrivalTimeMeanPerArea  ( const MGeomCam &geom, 
+                                           const UInt_t ai,  MBadPixelsCam *bad)
+{
+
+  const Int_t np = GetSize();
+
+  Double_t mean  = 0.;
+  Double_t mean2 = 0.;
+  Int_t    nr    = 0;
+
+  for (int i=0; i<np; i++)
+    {
+      if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        continue; 
+      
+      const UInt_t aidx = geom[i].GetAidx();
+      
+      if (ai != aidx)
+        continue;
+
+      const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
+      const Float_t time = pix.GetAbsTimeMean();
+
+      mean  += time   ;
+      mean2 += time*time;
+      nr    ++;
+      
+    }
+
+  TArrayF *arr = new TArrayF(2);
+  arr->AddAt(nr   ? mean/nr : -1.,0);
+  arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
+
+  return arr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculates the average mean arrival times for camera sectors. 
+// The geometry container is used to get the necessary
+// geometry information (area index).
+// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
+// in the calculation of the size average.
+//
+// Returns a TArrayF of dimension 2: 
+// arr[0]: averaged mean arrival times (default: -1.)
+// arr[1]: Error (rms) of averaged mean arrival times (default: 0.)
+//
+// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
+//
+TArrayF *MCalibrationChargeCam::GetAveragedArrivalTimeMeanPerSector( const MGeomCam &geom, 
+                                             const UInt_t sec, MBadPixelsCam *bad)
+{
+  const Int_t np = GetSize();
+
+  Double_t mean  = 0.;
+  Double_t mean2 = 0.;
+  Int_t    nr    = 0;
+
+  for (int i=0; i<np; i++)
+    {
+      if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        continue; 
+      
+      const UInt_t sector = geom[i].GetSector();
+      
+      if (sector != sec)
+        continue;
+
+      const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
+      const Float_t time = pix.GetAbsTimeMean();
+
+      mean  += time;
+      mean2 += time*time;
+      nr    ++;
+      
+    }
+
+  TArrayF *arr = new TArrayF(2);
+  arr->AddAt(nr   ? mean/nr : -1.,0);
+  arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
+
+  return arr;
+}  
+
+// --------------------------------------------------------------------------
+//
+// Calculates the average arrival time RMSs for pixel sizes. 
+// The geometry container is used to get the necessary
+// geometry information (area index). 
+// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
+// in the calculation of the size average.
+//
+// Returns a TArrayF of dimension 2: 
+// arr[0]: averaged arrival time RMSs (default: -1.)
+// arr[1]: Error (rms) of averaged arrival time RMSs (default: 0.)
+//
+// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
+//
+TArrayF *MCalibrationChargeCam::GetAveragedArrivalTimeRmsPerArea  ( const MGeomCam &geom, 
+                                           const UInt_t ai,  MBadPixelsCam *bad)
+{
+
+  const Int_t np = GetSize();
+
+  Double_t mean  = 0.;
+  Double_t mean2 = 0.;
+  Int_t    nr    = 0;
+
+  for (int i=0; i<np; i++)
+    {
+      if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        continue; 
+      
+      const UInt_t aidx = geom[i].GetAidx();
+      
+      if (ai != aidx)
+        continue;
+
+      const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
+      const Float_t rms = pix.GetAbsTimeRms();
+
+      mean  += rms;
+      mean2 += rms*rms;
+      nr    ++;
+      
+    }
+
+  TArrayF *arr = new TArrayF(2);
+  arr->AddAt(nr   ? mean/nr : -1.,0);
+  arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
+
+  return arr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculates the average arrival time RMSs for camera sectors. 
+// The geometry container is used to get the necessary
+// geometry information (area index).
+// If the bad pixel container is given all pixels which have the flag 'kUnsuitableRun' are ignored
+// in the calculation of the size average.
+//
+// Returns a TArrayF of dimension 2: 
+// arr[0]: averaged arrival time RMSs (default: -1.)
+// arr[1]: Error (rms) of averaged arrival time RMSs (default: 0.)
+//
+// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
+//
+TArrayF *MCalibrationChargeCam::GetAveragedArrivalTimeRmsPerSector( const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
+{
+  const Int_t np = GetSize();
+
+  Double_t mean  = 0.;
+  Double_t mean2 = 0.;
+  Int_t    nr    = 0;
+
+  for (int i=0; i<np; i++)
+    {
+      if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        continue; 
+      
+      const UInt_t sector = geom[i].GetSector();
+      
+      if (sector != sec)
+        continue;
+
+      const MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[i];
+      const Float_t rms = pix.GetAbsTimeRms();
+
+      mean  += rms;
+      mean2 += rms*rms;
+      nr    ++;
+    }
+
+  TArrayF *arr = new TArrayF(2);
+  arr->AddAt(nr   ? mean/nr : -1.,0);
+  arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
+
+  return arr;
+}  
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h	(revision 4851)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h	(revision 4852)
@@ -47,18 +47,26 @@
   Bool_t  IsFFactorMethodValid            () const;
 
-  TArrayF *GetAveragedConvFADC2PhotPerArea  ( const MGeomCam &geom, const MCalibrationQECam &qecam,
-                                             const UInt_t ai=0,  MBadPixelsCam *bad=NULL);
-  TArrayF *GetAveragedConvFADC2PhotPerSector( const MGeomCam &geom, const MCalibrationQECam &qecam,
-                                             const UInt_t sec=0, MBadPixelsCam *bad=NULL);  
+  TArrayF *GetAveragedConvFADC2PhotPerArea    ( const MGeomCam &geom, const MCalibrationQECam &qecam,
+                                                const UInt_t ai=0,  MBadPixelsCam *bad=NULL);
+  TArrayF *GetAveragedConvFADC2PhotPerSector  ( const MGeomCam &geom, const MCalibrationQECam &qecam,
+                                                const UInt_t sec=0, MBadPixelsCam *bad=NULL);  
+  TArrayF *GetAveragedArrivalTimeMeanPerArea  ( const MGeomCam &geom, 
+	                                        const UInt_t ai=0,  MBadPixelsCam *bad=NULL);
+  TArrayF *GetAveragedArrivalTimeMeanPerSector( const MGeomCam &geom, 
+                                                const UInt_t sec=0, MBadPixelsCam *bad=NULL);  
+  TArrayF *GetAveragedArrivalTimeRmsPerArea   ( const MGeomCam &geom, 
+                                                const UInt_t ai=0,  MBadPixelsCam *bad=NULL);
+  TArrayF *GetAveragedArrivalTimeRmsPerSector ( const MGeomCam &geom, 
+                                                const UInt_t sec=0, MBadPixelsCam *bad=NULL);  
   
   // Prints
-  void   Print(Option_t *o="")         const;
+  void   Print(Option_t *o="") const;
 
   // Setters   
-  void  SetFFactorMethodValid ( const Bool_t b=kTRUE );
-  void  SetNumPhotonsBlindPixelMethod ( const Float_t f )     { fNumPhotonsBlindPixelMethod    = f; } 
-  void  SetNumPhotonsFFactorMethod   ( const Float_t f )     { fNumPhotonsFFactorMethod       = f; }      
-  void  SetNumPhotonsPINDiodeMethod  ( const Float_t f )     { fNumPhotonsPINDiodeMethod      = f; }   
-  void  SetNumPhotonsBlindPixelMethodErr ( const Float_t f )  { fNumPhotonsBlindPixelMethodErr = f; } 
+  void  SetFFactorMethodValid           ( const Bool_t  b=kTRUE );
+  void  SetNumPhotonsBlindPixelMethod   ( const Float_t f )  { fNumPhotonsBlindPixelMethod    = f; } 
+  void  SetNumPhotonsFFactorMethod      ( const Float_t f )  { fNumPhotonsFFactorMethod       = f; }      
+  void  SetNumPhotonsPINDiodeMethod     ( const Float_t f )  { fNumPhotonsPINDiodeMethod      = f; }   
+  void  SetNumPhotonsBlindPixelMethodErr( const Float_t f )  { fNumPhotonsBlindPixelMethodErr = f; } 
   void  SetNumPhotonsFFactorMethodErr   ( const Float_t f )  { fNumPhotonsFFactorMethodErr    = f; }      
   void  SetNumPhotonsPINDiodeMethodErr  ( const Float_t f )  { fNumPhotonsPINDiodeMethodErr   = f; }   
