Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.cc	(revision 8446)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.cc	(revision 8452)
@@ -78,5 +78,4 @@
 #include "MLogManip.h"
 
-#include "MCalibrationIntensityCam.h"
 #include "MCalibrationCam.h"
 #include "MCalibrationPix.h"
@@ -144,5 +143,5 @@
     fHistXTitle(gsHistXTitle),fHistYTitle(gsHistYTitle),
     fCurrentNumEvts(0), fColor(MCalibrationCam::kNONE),
-    fBadPixels(NULL), fIntensCam(NULL), fCam(NULL), fGeom(NULL),
+    fBadPixels(NULL), fCam(NULL), fGeom(NULL),
     fRunHeader(NULL)
 {
@@ -606,9 +605,13 @@
   if (!fBadPixels)
   {
+      /*
       fBadPixels = (MBadPixelsCam*)pList->FindCreateObj(AddSerialNumber("MBadPixelsCam"));
       if (!fBadPixels)
           return kFALSE;
 
-      fBadPixels->InitSize(npixels);
+          fBadPixels->InitSize(npixels);
+          */
+      *fLog << err << "MBadPixelsCam not found... abort." << endl;
+      return kFALSE;
   }
 
@@ -762,5 +765,5 @@
           }
         else
-          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
+          InitHists(pix, fCam->GetAverageBadArea(j),j);
       }
   }
@@ -775,6 +778,6 @@
 
           pix.SetBinning(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nsectors), fFirst, fLast);
-          
-          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
+
+          InitHists(pix, fCam->GetAverageBadSector(j),j);
       }
   }
@@ -835,5 +838,5 @@
           }
         else
-          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
+          InitHists(pix, fCam->GetAverageBadArea(j),j);
       }
   }
@@ -849,5 +852,5 @@
           pix.SetBinning(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nsectors), fFirst, fLast);
           
-          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
+          InitHists(pix, fCam->GetAverageBadSector(j),j);
       }
   }
@@ -1034,7 +1037,5 @@
 // -------------------------------------------------------------
 //
-// - Searches for the CalibrationIntensity*Cam corresponding to 'name'. 
-// - In case, it does not exist in the parameter list, it searches
-//   for the corresponding MCalibration*Cam.
+// - Searches for the Calibration*Cam corresponding to 'name'.
 // - Initializes the MCalibration*Cam, if not yet done.
 // 
@@ -1042,27 +1043,18 @@
 {
 
-  TString intensname = "MCalibrationIntensity";
-  intensname += name;
-  intensname += "Cam";
-
-  TString ordname    = "MCalibration";
-  ordname    += name;
-  ordname    += "Cam";
-
-  fIntensCam = (MCalibrationIntensityCam*)plist->FindObject(AddSerialNumber(intensname));
-  if (fIntensCam)
-    *fLog << inf << "Found " << intensname << "... " << endl;
-  else
-    {
-      fCam = (MCalibrationCam*)plist->FindObject(AddSerialNumber(ordname));
+  TString ordname = "MCalibration";
+  ordname += name;
+  ordname += "Cam";
+
+  fCam = (MCalibrationCam*)plist->FindObject(AddSerialNumber(ordname));
+  if (!fCam)
+  {
+      fCam = (MCalibrationCam*)plist->FindCreateObj(AddSerialNumber(ordname));
       if (!fCam)
-        {
-          fCam = (MCalibrationCam*)plist->FindCreateObj(AddSerialNumber(ordname));
-          if (!fCam)
-              return kFALSE;
-
-          fCam->Init(*fGeom);
-        }
-    }
+          return kFALSE;
+
+      fCam->Init(*fGeom);
+  }
+
   return kTRUE;
 }
@@ -1182,12 +1174,12 @@
   if (!IsAverageing())
     return;
-  
-  MCalibrationCam *cam = fIntensCam ? fIntensCam->GetCam() : fCam;
+
+  MCalibrationCam *cam = fCam;
   if (!cam)
     return;
-  
+
   for (UInt_t j=0; j<fGeom->GetNumAreas(); j++)
     {
-  
+
       MCalibrationPix &pix    = cam->GetAverageArea(j);
 
@@ -1241,17 +1233,17 @@
   if (hist.IsEmpty())
   {
-      *fLog << warn << "Pixel  " << setw(4) << pix.GetPixId() << ": Hi-Gain histogram empty." << endl;
+      //*fLog << warn << "Pixel  " << setw(4) << pix.GetPixId() << ": Hi-Gain histogram empty." << endl;
+      //bad.SetUncalibrated( fittyp );
+      return;
+  }
+  if (hist.IsOnlyOverflow())
+  {
+      *fLog << warn << "Pixel  " << setw(4) << pix.GetPixId() << ": Hi-Gain histogram contains only overflows (Check Binning!)." << endl;
       bad.SetUncalibrated( fittyp );
       return;
   }
-  if (hist.IsOnlyOverflow())
-  {
-      *fLog << warn << "Pixel  " << setw(4) << pix.GetPixId() << ": Hi-Gain histogram contains only overflows." << endl;
-      bad.SetUncalibrated( fittyp );
-      return;
-  }
   if (hist.IsOnlyUnderflow())
   {
-      *fLog << warn << "Pixel  " << setw(4) << pix.GetPixId() << ": Hi-Gain histogram contains only underflows." << endl;
+      *fLog << warn << "Pixel  " << setw(4) << pix.GetPixId() << ": Hi-Gain histogram contains only underflows (Check Binning!)." << endl;
       bad.SetUncalibrated( fittyp );
       return;
@@ -1346,17 +1338,17 @@
   if (hist.IsEmpty())
   {
-      // *fLog << warn << "Pixel   " << setw(4) << pix.GetPixId() << ": Lo-Gain histogram empty." << endl;
+      //*fLog << warn << "Pixel   " << setw(4) << pix.GetPixId() << ": Lo-Gain histogram empty." << endl;
+      //bad.SetUncalibrated( fittyp ); // FIXME: Combine with HiGain!
+      return;
+  }
+  if (hist.IsOnlyOverflow())
+  {
+      *fLog << warn << "Pixel  " << setw(4) << pix.GetPixId() << ": Lo-Gain histogram contains only overflows (Check Binning!)." << endl;
       bad.SetUncalibrated( fittyp );
       return;
   }
-  if (hist.IsOnlyOverflow())
-  {
-      *fLog << warn << "Pixel  " << setw(4) << pix.GetPixId() << ": Lo-Gain histogram contains only overflows." << endl;
-      bad.SetUncalibrated( fittyp );
-      return;
-  }
   if (hist.IsOnlyUnderflow())
   {
-      *fLog << warn << "Pixel  " << setw(4) << pix.GetPixId() << ": Lo-Gain histogram contains only underflows." << endl;
+      *fLog << warn << "Pixel  " << setw(4) << pix.GetPixId() << ": Lo-Gain histogram contains only underflows (Check Binning!)." << endl;
       bad.SetUncalibrated( fittyp );
       return;
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.h
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.h	(revision 8446)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.h	(revision 8452)
@@ -29,5 +29,4 @@
 class MGeomCam;
 class MRawRunHeader;
-class MCalibrationIntensityCam;
 class MCalibrationCam;
 class MCalibrationPix;
@@ -100,5 +99,4 @@
 
   MBadPixelsCam    *fBadPixels;           //! Bad Pixels storage container
-  MCalibrationIntensityCam *fIntensCam;   //! Intensity Calibration Cam with the results
   MCalibrationCam  *fCam;                 //! Calibration Cam with the results
   MGeomCam         *fGeom;                //! Camera geometry
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc	(revision 8446)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc	(revision 8452)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MHCalibrationChargeCam.cc,v 1.57 2007-04-25 14:39:43 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MHCalibrationChargeCam.cc,v 1.58 2007-04-27 10:04:47 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -143,5 +143,4 @@
 #include "MHCalibrationPix.h"
 
-#include "MCalibrationIntensityCam.h"
 #include "MCalibrationChargeCam.h"
 #include "MCalibrationChargePix.h"
@@ -339,5 +338,5 @@
 // Gets or creates the pointers to:
 // - MExtractedSignalCam
-// - MCalibrationChargeCam or MCalibrationIntensityChargeCam
+// - MCalibrationChargeCam
 // - MBadPixelsCam
 //
@@ -472,5 +471,5 @@
         pix.SetBinningAbsTime(higainsamples, -0.5, higainsamples-0.5);
 
-        InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
+        InitHists(pix, fCam->GetAverageBadArea(j),j);
 
         h =  pix.GetHAbsTime();
@@ -498,5 +497,5 @@
           pix.SetBinningAbsTime(higainsamples, -0.5, higainsamples-0.5);
 
-          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
+          InitHists(pix, fCam->GetAverageBadSector(j),j);
 
           h =  pix.GetHAbsTime();
@@ -582,5 +581,5 @@
           pix.SetBinningAbsTime(logainsamples, -0.5, logainsamples-0.5);
           
-          InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
+          InitHists(pix, fCam->GetAverageBadArea(j),j);
 
           h =  pix.GetHAbsTime();
@@ -609,5 +608,5 @@
         pix.SetBinningAbsTime(logainsamples, -0.5, logainsamples-0.5);
         
-        InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
+        InitHists(pix, fCam->GetAverageBadSector(j),j);
 
         h =  pix.GetHAbsTime();
@@ -862,6 +861,4 @@
   TH1F *h = NULL;
 
-  MCalibrationCam *chargecam = fIntensCam ? fIntensCam->GetCam() : fCam;
-
   const Int_t hifirst = fSignal->GetFirstUsedSliceHiGain();
   const Int_t hilast  = fSignal->GetLastUsedSliceHiGain();
@@ -871,11 +868,10 @@
   for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
     {
-      
+
       MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
-      
       if (histhi.IsExcluded())
 	continue;
 
-      MCalibrationChargePix  &pix = (MCalibrationChargePix&)(*chargecam)[i] ;
+      MCalibrationChargePix  &pix = (MCalibrationChargePix&)(*fCam)[i];
 
       const Int_t numsat = histhi.GetSaturated();
@@ -935,5 +931,5 @@
           }
 
-        MCalibrationChargePix &pix = (MCalibrationChargePix&)(*chargecam)[i] ;
+        MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i] ;
         if (!pix.IsHiGainSaturation())
             continue;
@@ -966,5 +962,5 @@
       
       MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainArea(j);      
-      MCalibrationChargePix  &pix    = (MCalibrationChargePix&)chargecam->GetAverageArea(j);
+      MCalibrationChargePix  &pix    = (MCalibrationChargePix&)fCam->GetAverageArea(j);
 
       if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
@@ -976,5 +972,5 @@
         }
 
-      MBadPixelsPix &bad = chargecam->GetAverageBadArea(j);
+      MBadPixelsPix &bad = fCam->GetAverageBadArea(j);
       FinalizeAbsTimes(histhi, pix, bad, hifirst, hilast);
    }
@@ -994,12 +990,11 @@
           }
         
-        MCalibrationChargePix  &pix    = (MCalibrationChargePix&)chargecam->GetAverageArea(j);
-
+        MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j);
         if (pix.IsHiGainSaturation())
           {
-            MBadPixelsPix &bad = chargecam->GetAverageBadArea(j);
+            MBadPixelsPix &bad = fCam->GetAverageBadArea(j);
             FinalizeAbsTimes(histlo, pix, bad, lofirst, lolast);
           }
-        
+
       }
   
@@ -1008,5 +1003,5 @@
       
       MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainSector(j);      
-      MCalibrationChargePix  &pix    = (MCalibrationChargePix&)chargecam->GetAverageSector(j);
+      MCalibrationChargePix  &pix    = (MCalibrationChargePix&)fCam->GetAverageSector(j);
 
       if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
@@ -1018,5 +1013,5 @@
         }
 
-      MBadPixelsPix &bad = chargecam->GetAverageBadSector(j);
+      MBadPixelsPix &bad = fCam->GetAverageBadSector(j);
       FinalizeAbsTimes(histhi, pix, bad, hifirst, hilast);
     }
@@ -1025,8 +1020,8 @@
     for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
       {
-        
+
         MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j);      
-        MBadPixelsPix          &bad    = chargecam->GetAverageBadSector(j);
-        
+        MBadPixelsPix          &bad    = fCam->GetAverageBadSector(j);
+
         if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
           {
@@ -1037,7 +1032,6 @@
             continue;
           }
-        
-        MCalibrationChargePix  &pix    = (MCalibrationChargePix&)chargecam->GetAverageSector(j);
-
+
+        MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j);
         if (pix.IsHiGainSaturation())
           FinalizeAbsTimes(histlo, pix, bad, lofirst, lolast);
@@ -1047,5 +1041,5 @@
   // Perform the fitting for the High Gain (done in MHCalibrationCam)
   //
-  FitHiGainArrays(*chargecam, *fBadPixels,
+  FitHiGainArrays(*fCam, *fBadPixels,
                   MBadPixelsPix::kHiGainNotFitted,
                   MBadPixelsPix::kHiGainOscillating);
@@ -1055,5 +1049,5 @@
   //
   if (IsLoGain())
-    FitLoGainArrays(*chargecam, *fBadPixels,
+    FitLoGainArrays(*fCam, *fBadPixels,
                     MBadPixelsPix::kLoGainNotFitted,
                     MBadPixelsPix::kLoGainOscillating);
@@ -1071,5 +1065,5 @@
           continue;
 
-      MCalibrationChargePix  &pix = (MCalibrationChargePix&)(*chargecam)[i] ;
+      MCalibrationChargePix  &pix = (MCalibrationChargePix&)(*fCam)[i];
       if (!pix.IsHiGainSaturation())
           continue;
@@ -1143,11 +1137,9 @@
 {
 
-  MCalibrationCam *chargecam = fIntensCam ? fIntensCam->GetCam() : fCam;
-      
   for (Int_t i=0; i<fBadPixels->GetSize(); i++)
     {
-      
-      MBadPixelsPix    &bad    = (*fBadPixels)[i];
-      MCalibrationPix  &pix    = (*chargecam)[i];
+
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      MCalibrationPix &pix = (*fCam)[i];
 
       if (bad.IsUncalibrated(MBadPixelsPix::kHiGainNotFitted))
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationRelTimeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationRelTimeCam.cc	(revision 8446)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationRelTimeCam.cc	(revision 8452)
@@ -125,5 +125,5 @@
 
 const Float_t MHCalibrationRelTimeCam::fgNumHiGainSaturationLimit = 0.25;
-const UInt_t  MHCalibrationRelTimeCam::fgReferencePixel = 1;
+//const UInt_t  MHCalibrationRelTimeCam::fgReferencePixel = 1;
 const Int_t   MHCalibrationRelTimeCam::fgNbins      = 400;
 const Axis_t  MHCalibrationRelTimeCam::fgFirst      = -9.975;
@@ -141,5 +141,4 @@
 //
 // Sets: 
-// - fReferencePixel to fgReferencePixel
 // - fNbins to fgNbins
 // - fFirst to fgFirst
@@ -159,5 +158,5 @@
   SetNumHiGainSaturationLimit(fgNumHiGainSaturationLimit);
 
-  SetReferencePixel();
+//  SetReferencePixel();
 
   SetBinning(fgNbins, fgFirst, fgLast);
@@ -263,11 +262,4 @@
     return kFALSE;
 
-  MArrivalTimeCam *signal = (MArrivalTimeCam*)pList->FindObject("MArrivalTimeCam");
-  if (!signal)
-  {
-      *fLog << err << "MArrivalTimeCam not found... abort." << endl;
-      return kFALSE;
-  }
-
   const Int_t npixels  = fGeom->GetNumPixels();
   const Int_t nsectors = fGeom->GetNumSectors();
@@ -313,5 +305,5 @@
       return kFALSE;
     }
-  
+
   const Int_t npixels  = fGeom->GetNumPixels();
   const Int_t nareas   = fGeom->GetNumAreas();
@@ -327,15 +319,17 @@
   fNumsectorlo.Reset();
 
-  const MArrivalTimePix &refpix = (*arrtime)[fReferencePixel];
-  // FIXME: What do we do if pixel is invalid?
-  if (!refpix.IsArrivalTimeValid())
+  TArrayF arr(npixels);
+  Int_t n = 0;
+  for (Int_t i=0; i<npixels; i++)
   {
-      gLog << warn << "WARNING - Arrival time in refrence pixel " << fReferencePixel << " invalid." << endl;
-      return kTRUE;
+      if ((*fGeom)[i].GetAidx()>0)
+          continue;
+
+      const MArrivalTimePix &pix = (*arrtime)[i];
+      if (pix.IsHiGainValid() && !pix.IsHiGainSaturated())
+          arr[n++] = pix.GetArrivalTimeHiGain();
   }
 
-  const Float_t reftime = refpix.GetArrivalTime();
-//      refpix.IsHiGainSaturated()
-//     ? refpix.GetArrivalTimeLoGain() : refpix.GetArrivalTimeHiGain();
+  const Float_t reftime = TMath::Median(n, arr.GetArray());
 
   for (Int_t i=0; i<npixels; i++)
@@ -345,7 +339,4 @@
           continue;
 
-      const Int_t aidx   = (*fGeom)[i].GetAidx();
-      const Int_t sector = (*fGeom)[i].GetSector();
-
       const MArrivalTimePix &pix = (*arrtime)[i];
 
@@ -361,4 +352,7 @@
               histhi.FillHist(time-reftime);
 
+          const Int_t aidx   = (*fGeom)[i].GetAidx();
+          const Int_t sector = (*fGeom)[i].GetSector();
+
           fSumareahi  [aidx]   += time;
           fNumareahi  [aidx]   ++;
@@ -373,9 +367,11 @@
 /*
       // If lo-gain arrival time has been extracted successfully,
-      // the hi-gain has saturateed and the lo-gain is switched on
+      // the hi-gain has saturated and the lo-gain is switched on
       // fill hi-gain histograms and arrays
       if (pix.IsLoGainValid() && IsLoGain())
       {
           const Float_t time = pix.GetArrivalTimeLoGain();
+
+          // FIXME: We need the reference time of the lo-gains!
 
           MHCalibrationPix &histlo = (*this)(i);
@@ -393,38 +389,44 @@
 
   for (Int_t j=0; j<nareas; j++)
-    {
-      MHCalibrationPix &histhi = GetAverageHiGainArea(j);
-      if (IsOscillations())
-          histhi.FillHistAndArray(fNumareahi[j] == 0 ? 0. : fSumareahi[j]/fNumareahi[j]);
-      else
-          histhi.FillHist(fNumareahi[j] == 0 ? 0. : fSumareahi[j]/fNumareahi[j]);
-
-      if (IsLoGain())
-        {
+  {
+      if (fNumareahi[j]>0)
+      {
+          MHCalibrationPix &histhi = GetAverageHiGainArea(j);
+          if (IsOscillations())
+              histhi.FillHistAndArray(fSumareahi[j]/fNumareahi[j]);
+          else
+              histhi.FillHist(fSumareahi[j]/fNumareahi[j]);
+      }
+
+      if (IsLoGain() && fNumarealo[j]>0)
+      {
           MHCalibrationPix &histlo = GetAverageLoGainArea(j);
-	  if (IsOscillations())
-              histlo.FillHistAndArray(fNumarealo[j] == 0 ? 0. : fSumarealo[j]/fNumarealo[j]);
+          if (IsOscillations())
+              histlo.FillHistAndArray(fSumarealo[j]/fNumarealo[j]);
           else
-              histlo.FillHist(fNumarealo[j] == 0 ? 0. : fSumarealo[j]/fNumarealo[j]);
-        }
-    }
-  
+              histlo.FillHist(fSumarealo[j]/fNumarealo[j]);
+      }
+  }
+
   for (Int_t j=0; j<nsectors; j++)
-    {
-      MHCalibrationPix &histhi = GetAverageHiGainSector(j);
-      if (IsOscillations())
-          histhi.FillHistAndArray(fNumsectorhi[j] == 0 ? 0. : fSumsectorhi[j]/fNumsectorhi[j]);
-      else
-          histhi.FillHist(fNumsectorhi[j] == 0 ? 0. : fSumsectorhi[j]/fNumsectorhi[j]);
-
-      if (IsLoGain())
-        {
+  {
+      if (fNumsectorhi[j]>0)
+      {
+          MHCalibrationPix &histhi = GetAverageHiGainSector(j);
+          if (IsOscillations())
+              histhi.FillHistAndArray(fSumsectorhi[j]/fNumsectorhi[j]);
+          else
+              histhi.FillHist(fSumsectorhi[j]/fNumsectorhi[j]);
+      }
+
+      if (IsLoGain() && fNumsectorlo[j]>0)
+      {
           MHCalibrationPix &histlo = GetAverageLoGainSector(j);
-	  if (IsOscillations())
-              histlo.FillHistAndArray(fNumsectorlo[j] == 0 ? 0. : fSumsectorlo[j]/fNumsectorlo[j]);
+          if (IsOscillations())
+              histlo.FillHistAndArray(fSumsectorlo[j]/fNumsectorlo[j]);
           else
-              histlo.FillHist(fNumsectorlo[j] == 0 ? 0. : fSumsectorlo[j]/fNumsectorlo[j]);
-        }
-    }
+              histlo.FillHist(fSumsectorlo[j]/fNumsectorlo[j]);
+      }
+  }
 
   return kTRUE;
@@ -459,5 +461,5 @@
       if (histhi.IsExcluded())
         continue;
-      
+
       const Int_t aidx   = (*fGeom)[i].GetAidx();
       const Int_t sector = (*fGeom)[i].GetSector();
@@ -562,9 +564,9 @@
 
       if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeNotFitted ))
-        bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
+          bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
 
       if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeOscillating))
-        bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
-      
+          bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
+
     }
 }
@@ -577,19 +579,19 @@
 // ============== 
 //
-// 0: Fitted Mean Relative Arrival Time in FADC slices  (MHGausEvents::GetMean()
-// 1: Error Mean Relative Arrival Time in FADC slices   (MHGausEvents::GetMeanErr()
+// 0: Fitted Mean  Relative Arrival Time in FADC slices (MHGausEvents::GetMean()
+// 1: Error  Mean  Relative Arrival Time in FADC slices (MHGausEvents::GetMeanErr()
 // 2: Sigma fitted Relative Arrival Time in FADC slices (MHGausEvents::GetSigma()
-// 3: Error Sigma Relative Arrival Time in FADC slices  (MHGausEvents::GetSigmaErr()
+// 3: Error Sigma  Relative Arrival Time in FADC slices (MHGausEvents::GetSigmaErr()
 //
 // Useful variables derived from the fit results:
 // =============================================
 //
-// 4: Returned probability of Gauss fit              (calls: MHGausEvents::GetProb())
+// 4: Returned probability of Gauss fit  (MHGausEvents::GetProb())
 //
 // Localized defects:
 // ==================
 //
-// 5: Gaus fit not OK                               (calls: MHGausEvents::IsGausFitOK())
-// 6: Fourier spectrum not OK                       (calls: MHGausEvents::IsFourierSpectrumOK())
+// 5: Gaus fit not OK                    (MHGausEvents::IsGausFitOK())
+// 6: Fourier spectrum not OK            (MHGausEvents::IsFourierSpectrumOK())
 //
 Bool_t MHCalibrationRelTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
@@ -849,10 +851,4 @@
     }
 
-    if (IsEnvDefined(env, prefix, "ReferencePixel", print))
-    {
-        SetReferencePixel(GetEnvValue(env, prefix, "ReferencePixel", (Int_t)fReferencePixel));
-        rc = kTRUE;
-    }
-
     TEnv refenv(fReferenceFile);
 
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationRelTimeCam.h
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationRelTimeCam.h	(revision 8446)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationRelTimeCam.h	(revision 8452)
@@ -22,5 +22,4 @@
 
   static const Float_t fgNumHiGainSaturationLimit;   //! The default for fNumHiGainSaturationLimit (now at: 0.25)
-  static const UInt_t  fgReferencePixel;             //! Default for fReferencePixel   (now set to: 1)
   static const Int_t   fgNbins;                      //! Default number of bins        (now set to: 900   )
   static const Axis_t  fgFirst;                      //! Default lower histogram limit (now set to: -13.5 )
@@ -35,5 +34,4 @@
   static const TString fgReferenceFile;              //! default for fReferenceFile ("mjobs/calibrationref.rc")
 
-  UInt_t  fReferencePixel;                           // The reference pixel for rel. times
   Float_t fInnerRefTime;                             // The reference mean arrival time inner pixels
   Float_t fOuterRefTime;                             // The reference mean arrival time outer pixels
@@ -66,11 +64,8 @@
   ~MHCalibrationRelTimeCam() {}
 
-  UInt_t GetReferencePixel() const { return fReferencePixel; }
-
   // Clone
   TObject *Clone(const char *name="") const;
 
   // Setters
-  void  SetReferencePixel( const UInt_t i=fgReferencePixel   ) { fReferencePixel = i;   }
   void  SetReferenceFile ( const TString ref=fgReferenceFile ) { fReferenceFile  = ref; }
 
