Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc	(revision 8300)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc	(revision 8304)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MHCalibrationChargeCam.cc,v 1.49 2007-01-30 14:16:45 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MHCalibrationChargeCam.cc,v 1.50 2007-02-04 15:29:09 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -114,4 +114,10 @@
 //  + Float_t fNumLoGainBlackoutLimit; // Rel. amount blackout logain events until pixel is declared unsuitable
 //
+// Class Version 3:
+//  - Byte_t  fFirstHiGain;                              // First used slice High Gain
+//  - Byte_t  fLastHiGain;                               // Last used slice High Gain
+//  - Byte_t  fFirstLoGain;                              // First used slice Low Gain
+//  - Byte_t  fLastLoGain;                               // Last used slice Low Gain
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MHCalibrationChargeCam.h"
@@ -219,5 +225,5 @@
 //
 MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
-    : fRawEvt(NULL)
+    : fRawEvt(NULL), fSignal(NULL)
 {
 
@@ -367,7 +373,6 @@
 {
 
-  MExtractedSignalCam *signal = 
-    (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
-  if (!signal)
+  fSignal = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
+  if (!fSignal)
   {
       *fLog << err << "MExtractedSignalCam not found... abort." << endl;
@@ -377,9 +382,4 @@
   if (!InitCams(pList,"Charge"))
     return kFALSE;
-
-  fFirstHiGain = signal->GetFirstUsedSliceHiGain();
-  fLastHiGain  = signal->GetLastUsedSliceHiGain();
-  fFirstLoGain = signal->GetFirstUsedSliceLoGain();
-  fLastLoGain  = signal->GetLastUsedSliceLoGain();
 
   const Int_t npixels  = fGeom->GetNumPixels();
@@ -900,4 +900,9 @@
   MBadPixelsCam   *badcam    = fIntensBad ? fIntensBad->GetCam() : fBadPixels;
 
+  const Int_t hifirst = fSignal->GetFirstUsedSliceHiGain();
+  const Int_t hilast  = fSignal->GetLastUsedSliceHiGain();
+  const Int_t lofirst = fSignal->GetFirstUsedSliceLoGain();
+  const Int_t lolast  = fSignal->GetLastUsedSliceLoGain();
+
 
   for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
@@ -944,6 +949,6 @@
           bad.SetUncalibrated( MBadPixelsPix::kHiGainOverFlow ); 
         }
-      
-      FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
+
+      FinalizeAbsTimes(histhi, pix, bad, hifirst, hilast);
     }
 
@@ -991,5 +996,5 @@
           }
         
-        FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
+        FinalizeAbsTimes(histlo, pix, bad, lofirst, lolast);
       }
 
@@ -1009,5 +1014,5 @@
 
       MBadPixelsPix &bad = chargecam->GetAverageBadArea(j);
-      FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
+      FinalizeAbsTimes(histhi, pix, bad, hifirst, hilast);
    }
 
@@ -1031,5 +1036,5 @@
           {
             MBadPixelsPix &bad = chargecam->GetAverageBadArea(j);
-            FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
+            FinalizeAbsTimes(histlo, pix, bad, lofirst, lolast);
           }
         
@@ -1051,5 +1056,5 @@
 
       MBadPixelsPix &bad = chargecam->GetAverageBadSector(j);
-      FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
+      FinalizeAbsTimes(histhi, pix, bad, hifirst, hilast);
     }
   
@@ -1073,5 +1078,5 @@
 
         if (pix.IsHiGainSaturation())
-          FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
+          FinalizeAbsTimes(histlo, pix, bad, lofirst, lolast);
       }
   
@@ -1131,5 +1136,5 @@
 //
 void MHCalibrationChargeCam::FinalizeAbsTimes(MHCalibrationChargePix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad, 
-                                              Byte_t first, Byte_t last)
+                                              Int_t first, Int_t last)
 {
     const Float_t mean = hist.GetAbsTimeMean();
@@ -1139,6 +1144,6 @@
     pix.SetAbsTimeRms(rms);
 
-    const Float_t lowerlimit = (Float_t)first;// + fTimeLowerLimit;
-    const Float_t upperlimit = (Float_t)last ;// - fTimeUpperLimit;
+    const Float_t lowerlimit = (Float_t)first+1;// + fTimeLowerLimit;
+    const Float_t upperlimit = (Float_t)last -1;// - fTimeUpperLimit;
 
     // FIXME: instead of checking whether the maximum is in the first or
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h	(revision 8300)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h	(revision 8304)
@@ -86,10 +86,7 @@
   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) 
-  Byte_t  fFirstHiGain;                              // First used slice High Gain 
-  Byte_t  fLastHiGain;                               // Last used slice High Gain
-  Byte_t  fFirstLoGain;                              // First used slice Low Gain
-  Byte_t  fLastLoGain;                               // Last used slice Low Gain
   
   MRawEvtData         *fRawEvt;                      //!  Raw event data 
+  MExtractedSignalCam *fSignal;                      //!
 
   Bool_t SetupHists(const MParList *pList);
@@ -101,5 +98,5 @@
 
   void   FinalizeAbsTimes (MHCalibrationChargePix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad,
-                           Byte_t first, Byte_t last);  
+                           Int_t first, Int_t last);
   Bool_t FinalizeHists();
   void   FinalizeBadPixels();
@@ -141,5 +138,5 @@
   void   DrawPixelContent( Int_t num )  const;    
 
-  ClassDef(MHCalibrationChargeCam, 2)	// Histogram class for Charge Camera Calibration
+  ClassDef(MHCalibrationChargeCam, 3)	// Histogram class for Charge Camera Calibration
 };
 
