Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 3634)
+++ trunk/MagicSoft/Mars/Changelog	(revision 3635)
@@ -42,4 +42,9 @@
      - two new base classes for general calibration storage containers,
        contain average pixel storage functionality
+
+   * mcalib/MCalibrationRelTimeCam.[h,cc]
+   * mcalib/MCalibrationRelTimePix.[h,cc]
+     - new storage container for the rel. time calibration results, derive
+       from MCalibrationPix, MCalibrationCam
 
 
Index: trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h	(revision 3634)
+++ trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h	(revision 3635)
@@ -8,7 +8,10 @@
 #pragma link C++ class MCalibrateData+;
 
+#pragma link C++ class MCalibrationCam+;
+#pragma link C++ class MCalibrationPix+;
+#pragma link C++ class MCalibrationRelTimeCam+;
+#pragma link C++ class MCalibrationRelTimePix+;
 #pragma link C++ class MCalibrationQECam+;
 #pragma link C++ class MCalibrationQEPix+;
-
 #pragma link C++ class MCalibrationChargeCalc+;
 #pragma link C++ class MCalibrationChargeCam+;
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc	(revision 3635)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc	(revision 3635)
@@ -0,0 +1,281 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   11/2003 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationCam                                               
+//                                                               
+// Base class for camera Calibration results:
+//                                                               
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationCam.h"
+
+#include <TH2.h>
+#include <TCanvas.h>
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+#include "MCalibrationPix.h"
+
+ClassImp(MCalibrationCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Creates a TClonesArray of MCalibrationPix containers, initialized to 1 entry
+// Later, a call to MCalibrationCam::InitSize(Int_t size) has to be performed
+//
+// Creates an MCalibrationBlindPix container 
+//
+MCalibrationCam::MCalibrationCam(const char *name, const char *title)
+    : fPixels(NULL), fAverageAreas(NULL), fAverageSectors(NULL)
+{
+    fName  = name  ? name  : "MCalibrationCam";
+    fTitle = title ? title : "Base class Storage container for Camera Calibration";
+
+    fAverageBadAreas    = new TClonesArray("MBadPixelsPix",1);
+    fAverageBadSectors  = new TClonesArray("MBadPixelsPix",1);
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the TClonesArray of MCalibrationPix containers
+// Delete the MCalibrationPINDiode and the MCalibrationBlindPix
+//
+// Delete the histograms if they exist
+//
+MCalibrationCam::~MCalibrationCam()
+{
+
+  //
+  // delete fPixels should delete all Objects stored inside
+  // 
+  if (fPixels)
+    delete fPixels;
+
+  if (fAverageAreas)
+    delete fAverageAreas;
+
+  if (fAverageSectors)
+    delete fAverageSectors;
+
+  delete fAverageBadAreas;
+  delete fAverageBadSectors;
+  
+}
+
+// -------------------------------------------------------------------
+//
+//
+void MCalibrationCam::InitSize(const UInt_t i)
+{
+  fPixels->ExpandCreate(i);
+}
+
+void MCalibrationCam::InitAverageAreas(const UInt_t i)
+{
+  fAverageAreas->ExpandCreate(i);
+  fAverageBadAreas->ExpandCreate(i);
+}
+
+void MCalibrationCam::InitAverageSectors(const UInt_t i)
+{
+  fAverageSectors->ExpandCreate(i);
+  fAverageBadSectors->ExpandCreate(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// This function returns the current size of the TClonesArray 
+// independently if the MCalibrationPix is filled with values or not.
+//
+// It is the size of the array fPixels.
+//
+Int_t MCalibrationCam::GetSize() const
+{
+  return fPixels->GetEntriesFast();
+}
+
+Int_t MCalibrationCam::GetAverageAreas() const
+{
+  return fAverageAreas->GetEntriesFast();
+}
+
+Int_t MCalibrationCam::GetAverageSectors() const
+{
+  return fAverageSectors->GetEntriesFast();
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+MCalibrationPix &MCalibrationCam::operator[](UInt_t i)
+{
+  return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+const MCalibrationPix &MCalibrationCam::operator[](UInt_t i) const
+{
+  return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (area number)
+//
+MCalibrationPix &MCalibrationCam::GetAverageArea(UInt_t i)
+{
+  return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (area number)
+//
+const MCalibrationPix &MCalibrationCam::GetAverageArea(UInt_t i) const 
+{
+  return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (sector number)
+//
+MCalibrationPix &MCalibrationCam::GetAverageSector(UInt_t i)
+{
+  return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (sector number)
+//
+const MCalibrationPix &MCalibrationCam::GetAverageSector(UInt_t i) const 
+{
+  return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (area number)
+//
+MBadPixelsPix &MCalibrationCam::GetAverageBadArea(UInt_t i)
+{
+  return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (area number)
+//
+const MBadPixelsPix &MCalibrationCam::GetAverageBadArea(UInt_t i) const 
+{
+  return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (sector number)
+//
+MBadPixelsPix &MCalibrationCam::GetAverageBadSector(UInt_t i)
+{
+  return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (sector number)
+//
+const MBadPixelsPix &MCalibrationCam::GetAverageBadSector(UInt_t i) const 
+{
+  return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
+}
+
+
+// --------------------------------------
+//
+void MCalibrationCam::Clear(Option_t *o)
+{
+
+  fPixels->ForEach(TObject, Clear)();
+
+  //
+  // another ForEach does not compile, thus have to do the loop ourselves:
+  //
+  for (Int_t i=0;i<GetAverageAreas();i++)
+    {
+      fAverageAreas[i].Clear();
+      fAverageBadAreas[i].Clear();
+    }
+
+  //
+  // another ForEach does not compile, thus have to do the loop ourselves:
+  //
+  for (Int_t i=0;i<GetAverageSectors();i++)
+    {
+      fAverageSectors[i].Clear();
+      fAverageBadSectors[i].Clear();
+    }
+  
+  return;
+}
+
+// --------------------------------------------------------------------------
+//
+// Dummy needed for compilation with MCamEvent
+//
+Bool_t MCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+  return kTRUE;
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// What MHCamera needs in order to draw an individual pixel in the camera
+//
+void MCalibrationCam::DrawPixelContent(Int_t idx) const
+{
+  (*this)[idx].DrawClone();
+}
+
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc	(revision 3635)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc	(revision 3635)
@@ -0,0 +1,130 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCalibrationPix                                                         //
+//                                                                         //
+// Base Storage container to for a calibration pixel                       //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationPix.h"
+
+ClassImp(MCalibrationPix);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor: 
+//
+MCalibrationPix::MCalibrationPix(const char *name, const char *title)
+    : fPixId(-1),
+      fFlags(0)
+{
+
+  fName  = name  ? name  : "MCalibrationPix";
+  fTitle = title ? title : "Container of the fit results of MHCalibrationPixs ";
+
+  Clear();
+
+}
+
+// ------------------------------------------------------------------------
+//
+// Invalidate values
+//
+void MCalibrationPix::Clear(Option_t *o)
+{
+
+  fHiGainNumPickup     =  -1 ;
+  fHiGainMean          =  -1.;
+  fHiGainMeanVar       =  -1.;
+  fHiGainProb          =  -1.;
+  fHiGainSigma         =  -1.;
+  fHiGainSigmaVar      =  -1.;
+
+  fLoGainNumPickup     =  -1 ;
+  fLoGainMean          =  -1.;
+  fLoGainMeanVar       =  -1.;
+  fLoGainProb          =  -1.;
+  fLoGainSigma         =  -1.;
+  fLoGainSigmaVar      =  -1.;
+
+  SetHiGainSaturation  ( kFALSE );
+  SetExcluded          ( kFALSE );
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the Hi Gain Saturation Bit from outside
+//
+void MCalibrationPix::SetHiGainSaturation(Bool_t b)
+{
+    b ?  SETBIT(fFlags, kHiGainSaturation) : CLRBIT(fFlags, kHiGainSaturation); 
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set the Excluded Bit from outside 
+//
+void MCalibrationPix::SetExcluded(Bool_t b )
+{ 
+    b ?  SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded); 
+}
+
+
+Float_t MCalibrationPix::GetHiGainMeanErr()  const
+{
+  return TMath::Sqrt(fHiGainMeanVar);
+}
+
+
+Float_t MCalibrationPix::GetHiGainSigmaErr()  const
+{
+  return TMath::Sqrt(fHiGainSigmaVar);
+}
+
+Float_t MCalibrationPix::GetLoGainMeanErr()  const
+{
+  return TMath::Sqrt(fLoGainMeanVar);
+}
+
+
+Float_t MCalibrationPix::GetLoGainSigmaErr()  const
+{
+  return TMath::Sqrt(fLoGainSigmaVar);
+}
+
+
+Bool_t MCalibrationPix::IsExcluded()     const
+{ 
+   return TESTBIT(fFlags,kExcluded);  
+}
+
+Bool_t MCalibrationPix::IsHiGainSaturation()    const
+{ 
+   return TESTBIT(fFlags,kHiGainSaturation);  
+}
+
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h	(revision 3635)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h	(revision 3635)
@@ -0,0 +1,98 @@
+#ifndef MARS_MCalibrationPix
+#define MARS_MCalibrationPix
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MBadPixelsPix;
+class MCalibrationPix : public MParContainer
+{
+protected:
+
+  Int_t   fPixId;       // the pixel Id
+
+  UInt_t  fFlags;       // Flag for the set bits
+ 
+  Float_t fHiGainMean;        // The mean reduced charge after the fit
+  Float_t fHiGainMeanVar;     // The error of reduced mean charge after the fit
+  Float_t fHiGainSigma;       // The sigma of the mean charge after the fit
+  Float_t fHiGainSigmaVar;    // The error of the sigma of the mean charge after the fit
+  Float_t fHiGainProb;        // The probability of the fit function 
+  Float_t fHiGainNumPickup;   // The number of pickup events in the high-gain
+  
+  Float_t fLoGainMean;        // The mean reduced charge after the fit
+  Float_t fLoGainMeanVar;     // The error of reduced mean charge after the fit
+  Float_t fLoGainSigma;       // The sigma of the mean charge after the fit
+  Float_t fLoGainSigmaVar;    // The error of the sigma of the mean charge after the fit
+  Float_t fLoGainProb;        // The probability of the fit function 
+  Float_t fLoGainNumPickup;   // The number of pickup events in the low-gain
+
+  enum  { kHiGainSaturation, kExcluded };
+  
+public:
+
+  MCalibrationPix(const char *name=NULL, const char *title=NULL);
+  ~MCalibrationPix() {}
+  
+  virtual void Clear(Option_t *o="");
+
+  // Setter
+  void SetPixId( const Int_t i )   { fPixId = i; }
+
+  void SetHiGainMean      ( const Float_t f ) { fHiGainMean      = f;   }
+  void SetHiGainMeanErr   ( const Float_t f ) { fHiGainMeanVar   = f*f; }
+  void SetHiGainProb      ( const Float_t f ) { fHiGainProb      = f;   }
+  void SetHiGainSigma     ( const Float_t f ) { fHiGainSigma     = f;   }
+  void SetHiGainSigmaErr  ( const Float_t f ) { fHiGainSigmaVar  = f*f; }
+  void SetHiGainNumPickup ( const Float_t f ) { fHiGainNumPickup = f;   }
+
+  void SetLoGainMean      ( const Float_t f ) { fLoGainMean      = f;   }
+  void SetLoGainMeanErr   ( const Float_t f ) { fLoGainMeanVar   = f*f; }
+  void SetLoGainProb      ( const Float_t f ) { fLoGainProb      = f;   }
+  void SetLoGainSigma     ( const Float_t f ) { fLoGainSigma     = f;   }
+  void SetLoGainSigmaErr  ( const Float_t f ) { fLoGainSigmaVar  = f*f; }
+  void SetLoGainNumPickup ( const Float_t f ) { fLoGainNumPickup = f;   }
+
+  void SetMean       ( const Float_t f ) { IsHiGainSaturation() ? fLoGainMean = f       : fHiGainMean = f      ; }
+  void SetMeanErr    ( const Float_t f ) { IsHiGainSaturation() ? fLoGainMeanVar = f*f  : fHiGainMeanVar = f*f ; }
+  void SetProb       ( const Float_t f ) { IsHiGainSaturation() ? fLoGainProb = f       : fHiGainProb = f      ; }
+  void SetSigma      ( const Float_t f ) { IsHiGainSaturation() ? fLoGainSigma = f      : fHiGainSigma = f     ; }
+  void SetSigmaErr   ( const Float_t f ) { IsHiGainSaturation() ? fLoGainSigmaVar = f*f : fHiGainSigmaVar = f*f; }
+  void SetNumPickup  ( const Float_t f ) { IsHiGainSaturation() ? fLoGainNumPickup = f  : fHiGainNumPickup = f ; }
+  
+  void SetHiGainSaturation( const Bool_t  b = kTRUE );
+  void SetExcluded        ( const Bool_t  b = kTRUE );
+
+  // Getters
+  Float_t GetHiGainMean     () const { return fHiGainMean   ;   }
+  Float_t GetHiGainMeanErr  () const;
+  Float_t GetHiGainProb     () const { return fHiGainProb   ;   }
+  Float_t GetHiGainSigma    () const { return fHiGainSigma  ;   }
+  Float_t GetHiGainSigmaErr () const;
+  Float_t GetHiGainNumPickup() const { return fHiGainNumPickup; }
+
+  virtual Float_t GetLoGainMean     () const { return fLoGainMean   ;   }
+  virtual Float_t GetLoGainMeanErr  () const;
+  virtual Float_t GetLoGainProb     () const { return fLoGainProb   ;   }
+  virtual Float_t GetLoGainSigma    () const { return fLoGainSigma  ;   }
+  virtual Float_t GetLoGainSigmaErr () const;
+  virtual Float_t GetLoGainNumPickup() const { return fLoGainNumPickup; }
+
+  Float_t GetMean       () const { return IsHiGainSaturation() ? GetLoGainMean()      : GetHiGainMean()     ; }
+  Float_t GetMeanErr    () const { return IsHiGainSaturation() ? GetLoGainMeanErr()   : GetHiGainMeanErr()  ; }
+  Float_t GetProb       () const { return IsHiGainSaturation() ? GetLoGainProb()      : GetHiGainProb()     ; }
+  Float_t GetSigma      () const { return IsHiGainSaturation() ? GetLoGainSigma()     : GetHiGainSigma()    ; }
+  Float_t GetSigmaErr   () const { return IsHiGainSaturation() ? GetLoGainSigmaErr()  : GetHiGainSigmaErr() ; }
+  Float_t GetNumPickup  () const { return IsHiGainSaturation() ? GetLoGainNumPickup() : GetHiGainNumPickup(); }
+
+  Int_t   GetPixId      () const { return fPixId ;  }
+
+  Bool_t  IsExcluded()         const;
+  Bool_t  IsHiGainSaturation() const;
+
+  ClassDef(MCalibrationPix, 1)	// Container for Calibration of one pixel
+};
+
+#endif
+
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.cc	(revision 3635)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.cc	(revision 3635)
@@ -0,0 +1,277 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   11/2003 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationRelTimeCam                                               
+//                                                               
+// Hold the whole Calibration results of the camera:
+//                                                               
+// 1) MCalibrationRelTimeCam initializes a TClonesArray whose elements are 
+//    pointers to MCalibrationRelTimePix Containers
+//
+// The calculated values (types of GetPixelContent) are:
+// 
+// Fitted values:
+// ============== 
+//
+// 0: Fitted RelTime
+// 1: Error of fitted RelTime
+// 2: Sigma of fitted RelTime
+// 3: Error of Sigma of fitted RelTime
+//
+// Useful variables derived from the fit results:
+// =============================================
+//
+// 4: Returned probability of Gauss fit to RelTime distribution
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationRelTimeCam.h"
+#include "MCalibrationCam.h"
+
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MCalibrationRelTimePix.h"
+
+ClassImp(MCalibrationRelTimeCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Creates a TClonesArray of MCalibrationPix containers, initialized to 1 entry
+// Later, a call to MCalibrationRelTimeCam::InitSize(Int_t size) has to be performed
+//
+// Creates an MCalibrationBlindPix container 
+//
+MCalibrationRelTimeCam::MCalibrationRelTimeCam(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MCalibrationRelTimeCam";
+    fTitle = title ? title : "Storage container for the Calibration Information in the camera";
+
+    fPixels           = new TClonesArray("MCalibrationRelTimePix",1);
+    fAverageAreas     = new TClonesArray("MCalibrationRelTimePix",1);
+    fAverageSectors   = new TClonesArray("MCalibrationRelTimePix",1);
+
+    Clear();
+
+}
+
+
+
+// --------------------------------------
+//
+void MCalibrationRelTimeCam::Clear(Option_t *o)
+{
+
+  MCalibrationCam::Clear();
+
+  CLRBIT(fFlags,kValid);
+
+  return;
+}
+
+void MCalibrationRelTimeCam::SetValid(const Bool_t b)
+{
+    b ? SETBIT(fFlags, kValid) : CLRBIT(fFlags, kValid); 
+}
+
+
+Bool_t  MCalibrationRelTimeCam::IsValid()   const
+{
+  return TESTBIT(fFlags,kValid);
+}
+
+// --------------------------------------------------------------------------
+//
+// Print first the well fitted pixels 
+// and then the ones which are not FitValid
+//
+void MCalibrationRelTimeCam::Print(Option_t *o) const
+{
+
+  *fLog << all << GetDescriptor() << ":" << endl;
+  int id = 0;
+  
+  *fLog << all << "Calibrated pixels:" << endl;
+  *fLog << all << endl;
+
+  TIter Next(fPixels);
+  MCalibrationRelTimePix *pix;
+  while ((pix=(MCalibrationRelTimePix*)Next()))
+    {
+      
+      if (!pix->IsExcluded()) 
+	{                            
+
+          *fLog << all 
+                << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Pix  ",pix->GetPixId(),
+                        ":            Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
+                        "   Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
+		<< endl;
+          id++;
+	}
+    }
+  
+  *fLog << all << id << " pixels" << endl;
+  id = 0;
+  
+   
+  *fLog << all << endl;
+  *fLog << all << "Excluded pixels:" << endl;
+  *fLog << all << endl;
+  
+  id = 0;
+
+  TIter Next4(fPixels);
+  while ((pix=(MCalibrationRelTimePix*)Next4()))
+  {
+      if (pix->IsExcluded())
+      {
+	  *fLog << all << pix->GetPixId() << endl;
+	  id++;
+      }
+  }
+  *fLog << all << id << " Excluded pixels " << endl;
+  *fLog << endl;
+
+  TIter Next5(fAverageAreas);
+  while ((pix=(MCalibrationRelTimePix*)Next5()))
+  {
+    *fLog << all 
+          << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Area   ",pix->GetPixId(),
+                  ":  Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
+                  "   Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
+          << endl;
+  }
+
+  TIter Next6(fAverageSectors);
+  while ((pix=(MCalibrationRelTimePix*)Next5()))
+  {
+    *fLog << all 
+          << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Sector ",pix->GetPixId(),
+                  ":  Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
+                  "   Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
+          << endl;
+  }
+}
+
+
+// --------------------------------------------------------------------------
+//
+// The types are as follows:
+// 
+// Fitted values:
+// ============== 
+//
+// 0: Fitted RelTime
+// 1: Error of fitted RelTime
+// 2: Sigma of fitted RelTime
+// 3: Error of Sigma of fitted RelTime
+//
+// Useful variables derived from the fit results:
+// =============================================
+//
+// 4: Returned probability of Gauss fit to RelTime distribution
+//
+Bool_t MCalibrationRelTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+
+  if (idx > GetSize())
+    return kFALSE;
+
+  Float_t area = cam[idx].GetA();
+
+ if (area == 0)
+    return kFALSE;
+
+ MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*this)[idx];
+
+  switch (type)
+    {
+    case 0:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetMean();
+      break;
+    case 1:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetMeanErr();
+      break;
+    case 2:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetSigma();
+      break;
+    case 3:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetSigmaErr();
+      break;
+    case 4:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetProb();
+      break;
+    default:
+      return kFALSE;
+    }
+
+  return val!=-1.;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// What MHCamera needs in order to draw an individual pixel in the camera
+//
+void MCalibrationRelTimeCam::DrawPixelContent(Int_t idx) const
+{
+  (*this)[idx].DrawClone();
+}
+
+
+
+Bool_t MCalibrationRelTimeCam::GetConversion(Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma)
+{
+
+  MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*this)[ipx];
+
+  mean  = pix.GetMeanConversion();
+  err   = pix.GetConversionErr();
+  sigma = pix.GetSigmaConversion();
+
+  return kTRUE;
+}
+
+
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.h	(revision 3635)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.h	(revision 3635)
@@ -0,0 +1,44 @@
+#ifndef MARS_MCalibrationRelTimeCam
+#define MARS_MCalibrationRelTimeCam
+
+#ifndef MARS_MCalibrationCam
+#include "MCalibrationCam.h"
+#endif
+
+class MCalibrationRelTimePix;
+class MBadPixelsPix;
+class MBadPixelsCam;
+class MCalibrationRelTimeCam : public MCalibrationCam
+{
+private:
+  
+  enum  { kValid };
+
+public:
+
+  MCalibrationRelTimeCam(const char *name=NULL, const char *title=NULL);
+  ~MCalibrationRelTimeCam() {}
+  
+  
+  void Clear(    Option_t *o="" );
+
+  // Setters   
+  void SetValid(    const Bool_t b = kTRUE );
+
+  Bool_t  GetConversion(    Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
+
+  Bool_t IsValid()   const;
+
+  // Prints
+  void Print(Option_t *o="") const;
+  
+  // Draws
+  void DrawPixelContent(Int_t num) const;    
+  
+  // Others
+  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+
+  ClassDef(MCalibrationRelTimeCam, 1)	// Container for calibration of the camera
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimePix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimePix.cc	(revision 3635)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimePix.cc	(revision 3635)
@@ -0,0 +1,116 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCalibrationRelTimePix                                                  //
+//                                                                         //
+// Storage container to hold informations about the calibrated arrival time// 
+// value of one Pixel (PMT).                                               //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationRelTimePix.h"
+
+ClassImp(MCalibrationRelTimePix);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default Constructor: 
+//
+MCalibrationRelTimePix::MCalibrationRelTimePix(const char *name, const char *title)
+{
+
+  fName  = name  ? name  : "MCalibrationRelTimePix";
+  fTitle = title ? title : "Container of the fit results of MHCalibrationRelTimePixs ";
+
+  Clear();
+
+}
+
+// ------------------------------------------------------------------------
+//
+// Invalidate values
+//
+void MCalibrationRelTimePix::Clear(Option_t *o)
+{
+
+  SetExcluded  ( kFALSE );
+  SetValid     ( kFALSE );
+
+  fMeanConversion   =  -1.;
+  fConversionVar    =  -1.;
+  fSigmaConversion  =  -1.;
+
+  MCalibrationPix::Clear();
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set the conversion factors from outside (only for MC)
+//
+void MCalibrationRelTimePix::SetConversion(Float_t c, Float_t err, Float_t sig)
+{
+  fMeanConversion  = c;
+  fConversionVar   = err*err;
+  fSigmaConversion = sig;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set the Excluded Bit from outside 
+//
+void MCalibrationRelTimePix::SetExcluded(Bool_t b )
+{ 
+    b ?  SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded); 
+}
+
+    
+// --------------------------------------------------------------------------
+//
+// Set the Excluded Bit from outside 
+//
+void MCalibrationRelTimePix::SetValid(const Bool_t b )
+{ 
+  b ?  SETBIT(fFlags, kValid) : CLRBIT(fFlags, kValid); 
+}    
+
+
+Float_t MCalibrationRelTimePix::GetConversionErr()  const
+{
+  if (fConversionVar < 0.)
+    return -1.;
+  return TMath::Sqrt(fConversionVar);
+}
+
+
+Bool_t MCalibrationRelTimePix::IsExcluded()     const
+{ 
+   return TESTBIT(fFlags,kExcluded);  
+}
+
+Bool_t MCalibrationRelTimePix::IsValid() const 
+{ 
+  return TESTBIT(fFlags, kValid); 
+}
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimePix.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimePix.h	(revision 3635)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimePix.h	(revision 3635)
@@ -0,0 +1,48 @@
+#ifndef MARS_MCalibrationRelTimePix
+#define MARS_MCalibrationRelTimePix
+
+#ifndef MARS_MCalibrationPix
+#include "MCalibrationPix.h"
+#endif
+
+class MCalibrationRelTimePix : public MCalibrationPix
+{
+private:
+
+  Float_t fMeanConversion;     // The conversion factor to Phe's (F-factor method)
+  Float_t fConversionVar;      // The error of the conversion factor to Phe's (F-factor method)
+  Float_t fSigmaConversion;    // The sigma of conversion factor to Phe's (F-factor method)
+
+  enum  { kExcluded, kValid };
+
+public:
+
+  MCalibrationRelTimePix(const char *name=NULL, const char *title=NULL);
+  ~MCalibrationRelTimePix() {}
+  
+  void Clear(Option_t *o="");
+
+  // Conversion Factors
+  void SetConversion   ( Float_t c, Float_t err, Float_t sig );
+  
+  // Setters
+  void SetExcluded (  const Bool_t b = kTRUE );
+  void SetValid( const Bool_t b = kTRUE );
+
+  Float_t GetMeanConversion()  const  { return fMeanConversion;  }
+  Float_t GetConversionErr()   const;
+  Float_t GetSigmaConversion() const  { return fSigmaConversion; }
+
+  Float_t GetTimeOffset()       const { return GetMean();        }
+  Float_t GetTimeOffsetErr()    const { return GetMeanErr();     }
+  Float_t GetTimePrecision()    const { return GetSigma();       }
+  Float_t GetTimePrecisionErr() const { return GetSigmaErr();    }
+
+  Bool_t IsExcluded()           const;
+  Bool_t IsValid()              const;
+
+  ClassDef(MCalibrationRelTimePix, 1)	// Container for Calibration of one pixel
+};
+
+#endif
+
Index: trunk/MagicSoft/Mars/mcalib/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mcalib/Makefile	(revision 3634)
+++ trunk/MagicSoft/Mars/mcalib/Makefile	(revision 3635)
@@ -39,4 +39,8 @@
 SRCFILES = MCalibrate.cc \
 	   MCalibrateData.cc \
+           MCalibrationCam.cc \
+           MCalibrationPix.cc  \
+           MCalibrationRelTimeCam.cc \
+           MCalibrationRelTimePix.cc  \
            MCalibrationQECam.cc \
            MCalibrationQEPix.cc  \
