Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 3055)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 3056)
@@ -33,4 +33,10 @@
      - check for oscillations for all pixels (and you will not trust 
        your eyes when you look at the results :-((((
+
+   * mcalib/MCalibrationCalc.[h,cc]
+     - remove ArrivalTime -> go to separate class
+     - remove BlidnPixel and PI Didoe overflow, now handled directly 
+       inside the corr. classes. 
+     - remove SkipTimeFits -> go the arrival time class
 
 
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.h	(revision 3055)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.h	(revision 3056)
@@ -31,5 +31,4 @@
 class MCalibrationCam;
 class MExtractedSignalCam;
-class MArrivalTime;
 
 class MTime;
@@ -39,6 +38,6 @@
 private:
 
-  static const Int_t fBlindPixelId;         // ID of the blind pixel
-  static const Int_t fPINDiodeId;           // ID of the PIN Diode
+  static const UInt_t fBlindPixelId;        // ID of the blind pixel
+  static const UInt_t fPINDiodeId;          // ID of the PIN Diode
   static const Byte_t fgSaturationLimit;    // Saturation of Hi Gain
   static const Byte_t fgBlindPixelFirst;    // First FADC slice blind pixel
@@ -52,6 +51,4 @@
   MRawRunHeader            *fRunHeader;    // RunHeader information
 
-  MArrivalTime             *fArrivalTime;  // Calculated Arrival Times
-  
   MTime                    *fEvtTime;      // Time of the event
 
@@ -69,8 +66,7 @@
   UInt_t  fNumExcludedPixels;
 
-  enum  { kUseTimes, kUseBlindPixelFit, kUsePinDiodeFit,
+  enum  { kUseBlindPixelFit, kUsePinDiodeFit,
           kUseCosmicsRejection, kUseQualityChecks,
           kHiLoGainCalibration,
-          kBlindPixelOverFlow, kPINDiodeOverFlow,
           kHiGainOverFlow, kLoGainOverFlow  };
 
@@ -96,7 +92,4 @@
   void Clear(const Option_t *o="");
   
-  // Skipping parts of the work
-  void SkipTime(Bool_t b=kTRUE)
-      {b ? CLRBIT(fFlags, kUseTimes) : SETBIT(fFlags, kUseTimes);}
   void SkipBlindPixelFit(Bool_t b=kTRUE)
       {b ? CLRBIT(fFlags, kUseBlindPixelFit) : SETBIT(fFlags, kUseBlindPixelFit);}
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.cc	(revision 3055)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.cc	(revision 3056)
@@ -88,8 +88,4 @@
   fPed                              =  -1.;
   fPedRms                           =  -1.;
-  fTime                             =  -1.;
-  fSigmaTime                        =  -1.;
-  fTimeChiSquare                    =  -1.;
-
 }
 
@@ -271,34 +267,4 @@
 }
 
-
-// --------------------------------------------------------------------------
-//
-// 1) Fit the arrival times
-// 2) Retrieve the results
-// 3) Note that because of the low number of bins, the NDf is sometimes 0, so 
-//    Root does not give a reasonable Probability, the Chisquare is more significant
-//
-Bool_t MCalibrationPINDiode::FitTime() 
-{
-
-  if(!fHist->FitTime())
-    {
-      *fLog << warn << "WARNING: Could not fit Hi Gain times of PIN Diode" << endl;
-      fHist->PrintTimeFitResult();
-      return kFALSE;
-    }
-  
-  fTime          = fHist->GetRelTimeMean();
-  fSigmaTime     = fHist->GetRelTimeSigma();
-  fTimeProb      = fHist->GetRelTimeProb();
-  
-  if (CheckTimeFitValidity())
-    SETBIT(fFlags,kTimeFitValid);
-  else
-    CLRBIT(fFlags,kTimeFitValid);
-
-  return kTRUE;
-}
-
 //
 // The check returns kTRUE if:
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.h	(revision 3055)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.h	(revision 3056)
@@ -26,9 +26,4 @@
   Float_t fChargeProb;            // The probability of the fit function 
 
-  Float_t fTime;                  // The mean arrival time after the fit  
-  Float_t fSigmaTime;             // The error of the mean arrival time after the fit
-  Float_t fTimeChiSquare;         // The Chi Square of the fit function 
-  Float_t fTimeProb;              // The probability of the fit function 
-  
   Byte_t  fFlags;                 // Flag for the set Bits
 
@@ -58,9 +53,4 @@
   Float_t GetRSigmaSquare()        const { return fRSigmaSquare;   }
 
-  // Times  
-  Float_t GetTime()                const { return fTime;           }
-  Float_t GetSigmaTime()           const { return fSigmaTime;      }
-  Float_t GetTimeChiSquare()       const { return fTimeChiSquare;  }
-  Float_t GetTimeProb()            const { return fTimeProb;  }      
 
   // Pedestals
@@ -84,10 +74,9 @@
   Bool_t FillCharge(Float_t q)      { return fHist->FillChargeHiGain(q); }
   Bool_t FillAbsTime(Float_t t)     { return fHist->FillAbsTimeHiGain(t); }
-  Bool_t FillRelTime(Float_t t)     { return fHist->FillRelTimeHiGain(t); }
-  Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillChargevsNHiGain(rq,t); }    
 
+  Bool_t FillGraphs(Float_t qhi,Float_t qlo) const { return fHist->FillGraphs(qhi,qlo); }  
+  
   // Fits
   Bool_t FitCharge();
-  Bool_t FitTime();
 
   // Draws
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc	(revision 3055)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc	(revision 3056)
@@ -106,7 +106,8 @@
   CLRBIT(fFlags, kHiGainSaturation);
   CLRBIT(fFlags, kExcluded);
+  CLRBIT(fFlags, kExcludeQualityCheck);
   CLRBIT(fFlags, kChargeFitValid);
-  CLRBIT(fFlags, kTimeFitValid);
   CLRBIT(fFlags, kFitted);
+  CLRBIT(fFlags, kOscillating);
   CLRBIT(fFlags, kBlindPixelMethodValid);
   CLRBIT(fFlags, kFFactorMethodValid);
@@ -128,8 +129,4 @@
   fNumLoGainSamples                 =  -1.;
 
-  fMeanTimeOffset                   =  -1.;
-  fMeanTimeOffsetError              =  -1.;
-  fTimingPrecision                  =  -1.;
-  fTimeProb                         =  -1.;
   fTimeFirstHiGain                  =   0 ;
   fTimeLastHiGain                   =   0 ;
@@ -270,16 +267,16 @@
 // Set the Excluded Bit from outside 
 //
-void MCalibrationPix::SetTimeFitValid(Bool_t b )    
-{ 
-  b ?  SETBIT(fFlags, kTimeFitValid) : CLRBIT(fFlags, kTimeFitValid); 
-}
-
+void MCalibrationPix::SetFitted(Bool_t b )
+{ 
+  b ?  SETBIT(fFlags, kFitted) : CLRBIT(fFlags, kFitted); 
+}
+    
 // --------------------------------------------------------------------------
 //
 // Set the Excluded Bit from outside 
 //
-void MCalibrationPix::SetFitted(Bool_t b )
-{ 
-  b ?  SETBIT(fFlags, kFitted) : CLRBIT(fFlags, kFitted); 
+void MCalibrationPix::SetOscillating(Bool_t b )
+{ 
+  b ?  SETBIT(fFlags, kOscillating) : CLRBIT(fFlags, kOscillating); 
 }
     
@@ -348,5 +345,5 @@
 
 
-Float_t MCalibrationPix::GetTotalFFactor() 
+Float_t MCalibrationPix::GetTotalFFactorFFactorMethod() 
 {
   if (!fFactorCalculated)
@@ -356,5 +353,5 @@
 }
 
-Float_t MCalibrationPix::GetTotalFFactorError() 
+Float_t MCalibrationPix::GetTotalFFactorErrorFFactorMethod() 
 {
 
@@ -373,4 +370,28 @@
 
 
+Float_t MCalibrationPix::GetTotalFFactorBlindPixelMethod() 
+{
+  return 1.;
+}
+
+Float_t MCalibrationPix::GetTotalFFactorErrorBlindPixelMethod() 
+{
+
+  return 1.;
+}
+
+Float_t MCalibrationPix::GetTotalFFactorPINDiodeMethod() 
+{
+  return 1.;
+}
+
+Float_t MCalibrationPix::GetTotalFFactorErrorPINDiodeMethod() 
+{
+
+  return 1.;
+}
+
+
+
 Float_t MCalibrationPix::GetMeanConversionFFactorMethod()
 {
@@ -401,10 +422,4 @@
   return fSigmaConversionFFactorMethod;
   
-}
-
-
-Float_t MCalibrationPix::GetTimingPrecisionError() const 
-{
-  return fMeanTimeOffsetError/2.;
 }
 
@@ -415,4 +430,14 @@
  }
 
+Bool_t MCalibrationPix::IsExcludeQualityCheck() const
+ { 
+   return TESTBIT(fFlags,kExcludeQualityCheck);  
+ }
+
+Bool_t MCalibrationPix::IsHiGainSaturation() const
+ { 
+   return TESTBIT(fFlags,kHiGainSaturation);  
+ }
+
 Bool_t MCalibrationPix::IsChargeFitValid() const 
 {
@@ -420,12 +445,22 @@
 }
 
-Bool_t MCalibrationPix::IsTimeFitValid() const 
-{
-  return TESTBIT(fFlags, kTimeFitValid);  
-}
-
 Bool_t MCalibrationPix::IsFitted() const 
 { 
   return TESTBIT(fFlags, kFitted);    
+}
+
+Bool_t MCalibrationPix::IsOscillating()
+{ 
+
+  if (TESTBIT(fFlags, kOscillating))
+    return kTRUE;
+
+  if (fHist->CheckOscillations())
+    {
+      SETBIT(fFlags,kOscillating);
+      return kTRUE;
+    }
+  
+  return kFALSE;
 }
 
@@ -530,8 +565,18 @@
   fChargeProb     = fHist->GetChargeProb();
 
+
+  fAbsTimeMean    = fHist->GetAbsTimeMean();
+  fAbsTimeMeanErr = fHist->GetAbsTimeMeanErr();
+  fAbsTimeRms     = fHist->GetAbsTimeRms();  
+
+  if (CheckTimeFitValidity())
+    SETBIT(fFlags,kTimeFitValid);
+  else
+    CLRBIT(fFlags,kTimeFitValid);
+
   //
   // Calculate the conversion factors 
   //
-  if (TESTBIT(fFlags,kHiGainSaturation))
+  if (IsHiGainSaturation())
     ApplyLoGainConversion();
 
@@ -585,5 +630,5 @@
   Float_t pedRmsSquareErrSquare           = 4.*fErrPedRms*fErrPedRms * pedRmsSquare;
   
-  if (!TESTBIT(fFlags,kHiGainSaturation))
+  if (!IsHiGainSaturation())
     {  /* HiGain */
 
@@ -683,5 +728,5 @@
   fFactorCalculated = kTRUE;
 
-  fSigmaConversionFFactorMethod = GetTotalFFactor()*TMath::Sqrt(fMeanConversionFFactorMethod);
+  fSigmaConversionFFactorMethod = GetTotalFFactorFFactorMethod()*TMath::Sqrt(fMeanConversionFFactorMethod);
 
   return kTRUE;
@@ -706,15 +751,15 @@
 {
 
-  if (!TESTBIT(fFlags,kFitted))
+  if (!IsFitted())
     return kFALSE;
 
-  if (TESTBIT(fFlags,kExcludeQualityCheck))
+  if (IsExcludeQualityCheck())
     return kTRUE;
 
   Float_t pedestal;
 
-  if (!TESTBIT(fFlags,kHiGainSaturation))  /* higain */
+  if (!IsHiGainSaturation())  /* higain */
     pedestal = GetPedRms()*TMath::Sqrt(fNumHiGainSamples);
-  else                                     /*  logain */
+  else                         /*  logain */
     pedestal = GetPedRms()*TMath::Sqrt(fNumLoGainSamples);
       
@@ -769,39 +814,9 @@
 {
 
-  if (TMath::IsNaN(fMeanTimeOffset)
-      || TMath::IsNaN(fMeanTimeOffsetError)
-      || TMath::IsNaN(fTimingPrecision)
-      || TMath::IsNaN(fTimeProb))
-    {
-      *fLog << warn << "WARNING: Some of the time fit values are NAN in Pixel " 
-            << fPixId << endl;
-      return kFALSE;
-    }
-  
-  if (TESTBIT(fFlags,kExcludeQualityCheck))
+  
+  if (IsExcludeQualityCheck())
     return kTRUE;
 
-  if (TMath::Abs(fMeanTimeOffset) > gkTimeLimit) 
-    {
-      *fLog << warn << "WARNING: Abs(Fitted Rel. Time) " << TMath::Abs(fMeanTimeOffset) 
-            << " is greater than " << gkTimeLimit << " in Pixel " << fPixId << endl;
-      return kFALSE;
-    }
-
-  if (fMeanTimeOffsetError > gkTimeErrLimit) 
-    {
-      *fLog << warn << "WARNING: Error of Fitted Time " << fMeanTimeOffsetError 
-            << " is smaller than " << gkTimeErrLimit << " in Pixel " << fPixId << endl;
-      return kFALSE;
-    }
-
-  if (!fHist->IsTimeFitOK()) 
-    {
-      *fLog << warn << "WARNING: Probability of Fitted Time too low in Pixel " 
-            << fPixId << endl;
-      return kFALSE;
-    }
-
-  if (TESTBIT(fFlags,kHiGainSaturation))
+  if (IsHiGainSaturation())
     {
 
@@ -854,12 +869,7 @@
 
 
-//
-// The check returns kTRUE if:
-//
-// 
-//
-Bool_t MCalibrationPix::CheckOscillations()
-{
-  return kTRUE;
+void MCalibrationPix::CheckOscillations()
+{
+  fHist->CheckOscillations();
 }
 
@@ -882,40 +892,2 @@
 }
 
-
-
-// --------------------------------------------------------------------------
-//
-// 1) Fit the arrival times
-// 2) Retrieve the results
-//
-// This fit has to be done AFTER the Charges fit, 
-// otherwise only the Hi Gain will be fitted, even if there are no entries
-//
-// 
-Bool_t MCalibrationPix::FitTime() 
-{
-
-
-  if(!fHist->FitTime())
-    {
-      *fLog << warn << "WARNING: Could not fit relative times of pixel " << fPixId << endl;
-      return kFALSE;
-    }
-  
-  fMeanTimeOffset      = fHist->GetRelTimeMean();
-  fMeanTimeOffsetError = fHist->GetRelTimeMeanErr();
-  fTimingPrecision     = fHist->GetRelTimeSigma();
-  fTimeProb            = fHist->GetRelTimeProb();
-
-  fAbsTimeMean    = fHist->GetAbsTimeMean();
-  fAbsTimeMeanErr = fHist->GetAbsTimeMeanErr();
-  fAbsTimeRms     = fHist->GetAbsTimeRms();  
-
-  if (CheckTimeFitValidity())
-    SETBIT(fFlags,kTimeFitValid);
-  else
-    CLRBIT(fFlags,kTimeFitValid);
-
-  return kTRUE;
-}
-
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h	(revision 3055)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h	(revision 3056)
@@ -40,9 +40,4 @@
   Float_t fErrPedRms;           // The error of the pedestal  RMS (from MPedestalPix)  
 
-  Float_t fMeanTimeOffset;      // The mean relative arrival time offset after the fit
-  Float_t fMeanTimeOffsetError; // The mean relative arrival time offset error after the fit    
-  Float_t fTimingPrecision;     // The error of the mean arrival time after the fit
-  Float_t fTimeProb;            // The probability of the fit function 
-
   Float_t fAbsTimeMean;
   Float_t fAbsTimeMeanErr;  
@@ -84,5 +79,5 @@
           kExcluded, kExcludeQualityCheck,
           kChargeFitValid, kTimeFitValid,
-          kFitted,
+          kFitted, kOscillating, 
           kBlindPixelMethodValid, kFFactorMethodValid, kPINDiodeMethodValid };
   
@@ -91,6 +86,4 @@
   Bool_t CheckChargeFitValidity();
   Bool_t CheckTimeFitValidity();
-  Bool_t CheckOscillations();  
-
   Bool_t CalcFFactorMethod();
   
@@ -114,10 +107,4 @@
   Float_t GetErrRSigmaCharge()     const { return fErrRSigmaCharge; }  
 
-  // Times  
-  Float_t GetMeanTimeOffset()       const { return fMeanTimeOffset;      } 
-  Float_t GetMeanTimeOffsetError()  const { return fMeanTimeOffsetError; }  
-  Float_t GetTimingPrecision()      const { return fTimingPrecision;     }
-  Float_t GetTimingPrecisionError() const;
-  Float_t GetTimeProb()             const { return fTimeProb;            }      
 
   Float_t GetAbsTimeMean()         const { return fAbsTimeMean;    }
@@ -149,11 +136,19 @@
   Float_t GetPedRms()                          const { return fPedRms; }
 
-  Float_t GetTotalFFactor();
-  Float_t GetTotalFFactorError();
+  Float_t GetTotalFFactorFFactorMethod();
+  Float_t GetTotalFFactorErrorFFactorMethod();
+  
+  Float_t GetTotalFFactorBlindPixelMethod();
+  Float_t GetTotalFFactorErrorBlindPixelMethod();
+  
+  Float_t GetTotalFFactorPINDiodeMethod();
+  Float_t GetTotalFFactorErrorPINDiodeMethod();
   
   Bool_t IsExcluded()              const;
+  Bool_t IsExcludeQualityCheck()   const;
+  Bool_t IsHiGainSaturation()      const;
   Bool_t IsChargeFitValid()        const;
-  Bool_t IsTimeFitValid()          const;
   Bool_t IsFitted()                const;
+  Bool_t IsOscillating();
   Bool_t IsBlindPixelMethodValid() const;
   Bool_t IsPINDiodeMethodValid()   const;
@@ -175,6 +170,6 @@
   void SetExcludeQualityCheck(Bool_t b = kTRUE);
   void SetChargeFitValid(Bool_t b = kTRUE);
-  void SetTimeFitValid(Bool_t b = kTRUE);
   void SetFitted(Bool_t b = kTRUE);
+  void SetOscillating(Bool_t b = kTRUE);
   void SetBlindPixelMethodValid(Bool_t b = kTRUE);
   void SetFFactorMethodValid(Bool_t b = kTRUE);
@@ -184,15 +179,11 @@
   
   // Fill histos
-  Bool_t FillChargeHiGain(Float_t q)                  const { return fHist->FillChargeHiGain(q); }
-  Bool_t FillAbsTimeHiGain(Float_t t)                 const { return fHist->FillAbsTimeHiGain(t); }
-  Bool_t FillRelTimeHiGain(Float_t t)                 const { return fHist->FillRelTimeHiGain(t); }  
-  Bool_t FillRChargevsTimeHiGain(Float_t rq, Int_t t) const { return fHist->FillChargevsNHiGain(rq,t); }    
-
-  Bool_t FillChargeLoGain(Float_t q)                  const { return fHist->FillChargeLoGain(q); }
-  Bool_t FillAbsTimeLoGain(Float_t t)                 const { return fHist->FillAbsTimeLoGain(t); }
-  Bool_t FillRelTimeLoGain(Float_t t)                 const { return fHist->FillRelTimeLoGain(t); }    
-  Bool_t FillRChargevsTimeLoGain(Float_t rq, Int_t t) const { return fHist->FillChargevsNLoGain(rq,t); }    
-  
-  Bool_t FillChargesInGraph(Float_t qhi,Float_t qlo) const  { return fHist->FillPointInGraph(qhi,qlo); }
+  Bool_t FillChargeHiGain(Float_t q)         const { return fHist->FillChargeHiGain(q); }
+  Bool_t FillAbsTimeHiGain(Float_t t)        const { return fHist->FillAbsTimeHiGain(t); }
+
+  Bool_t FillChargeLoGain(Float_t q)         const { return fHist->FillChargeLoGain(q); }
+  Bool_t FillAbsTimeLoGain(Float_t t)        const { return fHist->FillAbsTimeLoGain(t); }
+
+  Bool_t FillGraphs(Float_t qhi,Float_t qlo) const { return fHist->FillGraphs(qhi,qlo); }
 
   void   DefinePixId(Int_t i);
@@ -200,5 +191,4 @@
   // Fits
   Bool_t FitCharge();
-  Bool_t FitTime();
   
   // Draws
@@ -207,5 +197,6 @@
   
   // Miscellaneous
-  void   ApplyLoGainConversion();
+  void  ApplyLoGainConversion();
+  void  CheckOscillations();  
 
   ClassDef(MCalibrationPix, 1)	// Storage Container for Calibration information of one pixel
Index: /trunk/MagicSoft/Mars/mcalib/MHCalibrationPINDiode.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHCalibrationPINDiode.cc	(revision 3055)
+++ /trunk/MagicSoft/Mars/mcalib/MHCalibrationPINDiode.cc	(revision 3056)
@@ -48,8 +48,5 @@
 MHCalibrationPINDiode::MHCalibrationPINDiode(const char *name, const char *title)
     : fChargeNbins(1000),
-      fTimeNbins(64),
-      fChargevsNbins(10000),
-      fTimeFirst(-0.25),
-      fTimeLast(31.75)
+      fChargevsNbins(10000)
 {
 
@@ -68,11 +65,4 @@
     fHPINDiodeCharge->SetDirectory(NULL);
 
-    fHPINDiodeTime = new TH1F("HPINDiodeTime","Distribution of Mean Arrival Times PINDiode",
-                              fTimeNbins,fTimeFirst,fTimeLast);
-    fHPINDiodeTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
-    fHPINDiodeTime->SetYTitle("Nr. of events");
-    fHPINDiodeTime->Sumw2();
-    fHPINDiodeTime->SetDirectory(NULL);
-
     fHPINDiodeChargevsN = new TH1I("HPINDiodeChargevsN","Sum of Hi Gain Charges vs. Event Number Pixel ",
 				 fChargevsNbins,-0.5,(Axis_t)fChargevsNbins - 0.5);
@@ -88,11 +78,8 @@
 
   delete fHPINDiodeCharge;
-  delete fHPINDiodeTime;
   delete fHPINDiodeChargevsN;
 
   if (fChargeGausFit)
     delete fChargeGausFit;
-  if (fRelTimeGausFit)
-    delete fRelTimeGausFit;
   if (fFitLegend)
     delete fFitLegend;
@@ -110,18 +97,7 @@
   fChargeProb              = -1.;
   fChargeNdf               = -1;
-  fRelTimeProb             = -1.;
-  fRelTimeNdf              = -1;
-  fRelTimeMean             = -1.;
-  fRelTimeSigma            = -1.;
-
-  fRelTimeLowerFitRangeHiGain = -99.;
-  fRelTimeUpperFitRangeHiGain = -99.;
-  fRelTimeLowerFitRangeLoGain = -99.;
-  fRelTimeUpperFitRangeLoGain = -99.;
 
   if (fChargeGausFit)
     delete fChargeGausFit;
-  if (fRelTimeGausFit)
-    delete fRelTimeGausFit;
   if (fFitLegend)
     delete fFitLegend;
@@ -137,5 +113,4 @@
 
   fHPINDiodeCharge->Reset();
-  fHPINDiodeTime->Reset();
   fHPINDiodeChargevsN->Reset();
 }
@@ -145,9 +120,4 @@
 {
     return (fHPINDiodeCharge->Fill(q) > -1);
-}
-
-Bool_t MHCalibrationPINDiode::FillTime(Float_t t)
-{
-    return (fHPINDiodeTime->Fill(t)   > -1);
 }
 
@@ -160,5 +130,5 @@
 {
 
-  Int_t nbins = 30;
+  Int_t nbins = 20;
 
   CutEdges(fHPINDiodeCharge,nbins);
Index: /trunk/MagicSoft/Mars/mcalib/MHCalibrationPINDiode.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHCalibrationPINDiode.h	(revision 3055)
+++ /trunk/MagicSoft/Mars/mcalib/MHCalibrationPINDiode.h	(revision 3056)
@@ -17,10 +17,8 @@
   TH1F* fHPINDiodeCharge;    // Histogram containing the summed 32 PINDiode slices
   TH1F* fHPINDiodeErrCharge; // Variance of summed FADC slices
-  TH1F* fHPINDiodeTime;      // Histogram with time evolution of summed charges
   
   TH1I* fHPINDiodeChargevsN; // Summed Charge vs. Event Nr.
   
   const Int_t   fChargeNbins;
-  const Int_t   fTimeNbins;
   const Int_t   fChargevsNbins;
 
@@ -38,10 +36,8 @@
   // Fill histos
   Bool_t FillCharge(Float_t q);
-  Bool_t FillTime(Float_t t);
   Bool_t FillChargevsN(Float_t q, Int_t n);
 
   // Fits -- not yet implemented
   Bool_t FitCharge(Option_t *option="RQ0") { return kTRUE; }
-  Bool_t FitTime(Option_t *option="RQ0")   { return kTRUE; }
 
   // Others
Index: /trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc	(revision 3055)
+++ /trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc	(revision 3056)
@@ -42,4 +42,7 @@
 #include <TPaveText.h>
 #include <TText.h>
+#include <TGraph.h>
+
+#include "MFFT.h"
 
 #include "MLog.h"
@@ -52,14 +55,14 @@
 const Int_t   MHCalibrationPixel::fChargeNbinsHiGain = 2100;
 const Int_t   MHCalibrationPixel::fChargeNbinsLoGain = 1010;
-const Int_t   MHCalibrationPixel::fChargevsNbins     = 5000;
-const Int_t   MHCalibrationPixel::fAbsTimeNbins      = 32;
+const Int_t   MHCalibrationPixel::fAbsTimeNbins      = 16;
 const Axis_t  MHCalibrationPixel::fAbsTimeFirst      = - 0.25;
 const Axis_t  MHCalibrationPixel::fAbsTimeLast       =  15.75;
-const Int_t   MHCalibrationPixel::fRelTimeNbins      = 900;
-const Axis_t  MHCalibrationPixel::fRelTimeFirst      = -13.;
-const Axis_t  MHCalibrationPixel::fRelTimeLast       =  13.;
 const Float_t MHCalibrationPixel::fProbLimit         = 0.001;
 const Int_t   MHCalibrationPixel::fNDFLimit          = 5;
 
+const Axis_t  MHCalibrationPixel::fNyquistFreq       = 1.0;
+const Axis_t  MHCalibrationPixel::fMinFreq           = 0.;
+const Int_t   MHCalibrationPixel::fPSDNbins          = 30;
+  
 // --------------------------------------------------------------------------
 //
@@ -69,12 +72,17 @@
       : fPixId(-1),
 	fHivsLoGain(NULL),
+        fPSDHiGain(NULL),
+        fPSDLoGain(NULL),
+        fChargeGausFit(NULL),
         fHPSD(NULL),
-        fChargeGausFit(NULL),
-	fRelTimeGausFit(NULL), 
-	fFitLegend(NULL)
+        fPSDExpFit(NULL),
+        fChargeXaxis(NULL),
+        fPSDXaxis(NULL),
+	fFitLegend(NULL),
+        fCurrentSize(1024)
 { 
 
     fName  = name  ? name  : "MHCalibrationPixel";
-    fTitle = title ? title : "Fill the accumulated charges and times of all events and perform fits";
+    fTitle = title ? title : "Fill the accumulated charges of all events and perform fits";
 
     fChargeFirstHiGain = -100.5;
@@ -110,27 +118,4 @@
     fHAbsTimeLoGain->SetYTitle("Nr. of events");
 
-    // Relative Times
-    fHRelTimeHiGain = new TH1F("HRelTimeHiGain","Distribution of Relative Arrival Times High Gain Pixel ",
-                               fRelTimeNbins,fRelTimeFirst,fRelTimeLast);
-    fHRelTimeLoGain = new TH1F("HRelTimeLoGain","Distribution of Relative Arrival Time Low Gain Pixel ",
-                               fRelTimeNbins,fRelTimeFirst,fRelTimeLast);
-
-    fHRelTimeHiGain->SetXTitle("Relative Arrival Times [Hi Gain FADC slice nr]");
-    fHRelTimeLoGain->SetXTitle("Relative Arrival Times [Lo Gain FADC slice nr]");
-
-    fHRelTimeHiGain->SetYTitle("Nr. of events");
-    fHRelTimeLoGain->SetYTitle("Nr. of events");
-
-    // We define a reasonable number and later enlarge it if necessary
-    fHChargevsNHiGain = new TH1I("HChargevsNHiGain","Sum of Hi Gain Charges vs. Event Number Pixel ",
-				 fChargevsNbins,-0.5,(Axis_t)fChargevsNbins - 0.5);
-    fHChargevsNLoGain = new TH1I("HChargevsNLoGain","Sum of Lo Gain Charges vs. Event Number Pixel ",
-				 fChargevsNbins,-0.5,(Axis_t)fChargevsNbins - 0.5);
-
-    fHChargevsNHiGain->SetXTitle("Event Nr.");
-    fHChargevsNLoGain->SetXTitle("Event Nr.");
-
-    fHChargevsNHiGain->SetYTitle("Sum of Hi Gain FADC slices");
-    fHChargevsNLoGain->SetYTitle("Sum of Lo Gain FADC slices");
 
     fHChargeHiGain->SetDirectory(NULL);
@@ -138,11 +123,7 @@
     fHAbsTimeHiGain->SetDirectory(NULL);
     fHAbsTimeLoGain->SetDirectory(NULL);
-    fHRelTimeHiGain->SetDirectory(NULL);
-    fHRelTimeLoGain->SetDirectory(NULL);
-    fHChargevsNHiGain->SetDirectory(NULL);
-    fHChargevsNLoGain->SetDirectory(NULL);
-
-    fHiGains = new TArrayF();
-    fLoGains = new TArrayF();
+
+    fHiGains = new TArrayF(fCurrentSize);
+    fLoGains = new TArrayF(fCurrentSize);
 
     Clear();
@@ -155,11 +136,7 @@
   delete fHChargeHiGain;
   delete fHAbsTimeHiGain;
-  delete fHRelTimeHiGain;
-  delete fHChargevsNHiGain;
 
   delete fHChargeLoGain;
   delete fHAbsTimeLoGain;
-  delete fHRelTimeLoGain;
-  delete fHChargevsNLoGain;
 
   delete fHiGains;
@@ -168,10 +145,16 @@
   if (fChargeGausFit)
     delete fChargeGausFit;
-  if (fRelTimeGausFit)
-    delete fRelTimeGausFit;
+  if (fPSDExpFit)
+    delete fPSDExpFit;
+  if (fHPSD)
+    delete fHPSD;
   if (fFitLegend)
     delete fFitLegend;
   if (fHivsLoGain)
     delete fHivsLoGain;
+  if (fChargeXaxis)
+    delete fChargeXaxis;
+  if (fPSDXaxis)
+    delete fPSDXaxis;
 }
 
@@ -181,4 +164,5 @@
   
   fTotalEntries            = 0;
+  fCurrentSize             = 1024;
 
   fChargeFirstHiGain       = -100.5;
@@ -191,15 +175,4 @@
   fChargeNdf               = -1;
 
-  fRelTimeChisquare        = -1.;
-  fRelTimeProb             = -1.;
-  fRelTimeNdf              = -1;
-  fRelTimeMean             = -1.;
-  fRelTimeSigma            = -1.;
-
-  fRelTimeLowerFitRangeHiGain = -99.;
-  fRelTimeUpperFitRangeHiGain = -99.;
-  fRelTimeLowerFitRangeLoGain = -99.;
-  fRelTimeUpperFitRangeLoGain = -99.;
-
   fAbsTimeFirstHiGain     = -1.;
   fAbsTimeFirstLoGain     = -1.;
@@ -216,16 +189,24 @@
   if (fChargeGausFit)
     delete fChargeGausFit;
-  if (fRelTimeGausFit)
-    delete fRelTimeGausFit;
+  if (fPSDExpFit)
+    delete fPSDExpFit;
+  if (fHPSD)
+    delete fHPSD;
   if (fFitLegend)
     delete fFitLegend;
   if (fHivsLoGain)
     delete fHivsLoGain;
-  if (fHPSD)
-    delete fHPSD;
+  if (fChargeXaxis)
+    delete fChargeXaxis;
+  if (fPSDXaxis)
+    delete fPSDXaxis;
+  if (fPSDHiGain)
+    delete fPSDHiGain;
+  if (fPSDLoGain)
+    delete fPSDLoGain;
 
   CLRBIT(fFlags,kUseLoGain);
   CLRBIT(fFlags,kChargeFitOK);
-  CLRBIT(fFlags,kTimeFitOK);
+  CLRBIT(fFlags,kOscillating);
 
   return;
@@ -240,13 +221,13 @@
   fHChargeHiGain->Reset();
   fHChargeLoGain->Reset();
+
   fHAbsTimeHiGain->Reset();
   fHAbsTimeLoGain->Reset();
-  fHRelTimeHiGain->Reset();
-  fHRelTimeLoGain->Reset();
-  fHChargevsNHiGain->Reset();
-  fHChargevsNLoGain->Reset();
-
-  fHiGains->Reset();
-  fLoGains->Reset();
+
+  fHiGains->Set(1024);
+  fLoGains->Set(1024);
+
+  fHiGains->Reset(0.);
+  fLoGains->Reset(0.);
 
 }
@@ -261,4 +242,117 @@
 
 
+Bool_t MHCalibrationPixel::CheckOscillations()
+{
+
+  if (fPSDExpFit)
+    return IsOscillating();
+
+  MFFT fourier;
+
+  fPSDLoGain = fourier.PowerSpectrumDensity(fLoGains);
+  fPSDHiGain = fourier.PowerSpectrumDensity(fHiGains);
+
+  Int_t entries;
+  TArrayF *array;
+  
+  if (IsUseLoGain())
+    {
+      fHPSD = new TH1F(Form("%s%d","HPSD",fPixId),
+                       Form("%s%s","Power Spectrum Density Projection ","LoGain"),
+                       fPSDNbins,fMinFreq,fNyquistFreq);
+      
+      array = fPSDLoGain;
+    }
+  else
+    {
+
+      fHPSD = new TH1F(Form("%s%d","HPSD",fPixId),
+                       Form("%s%s","Power Spectrum Density Projection ","HiGain"),
+                       fPSDNbins,fMinFreq,fNyquistFreq);
+      
+      array = fPSDLoGain;
+    }
+  
+  entries = array->GetSize();
+  
+  for (Int_t i=0;i<entries;i++)
+    fHPSD->Fill(array->At(i));
+
+  //
+  // First guesses for the fit (should be as close to reality as possible, 
+  //
+  const Double_t area_guess  = entries*10.;
+
+  fPSDExpFit = new TF1(Form("%s%d","PSDExpFit",fPixId),"[0]*exp(-[1]*x)",0.,1.);
+
+  fPSDExpFit->SetParameters(entries,10.);
+  fPSDExpFit->SetParNames("Area","slope");
+  fPSDExpFit->SetParLimits(0,0.,3.*area_guess);
+  fPSDExpFit->SetParLimits(1,5.,20.);
+  fPSDExpFit->SetRange(fMinFreq,fNyquistFreq);
+
+  fHPSD->Fit(fPSDExpFit,"RQL0");
+  
+  fPSDProb  = fPSDExpFit->GetProb();
+
+  if (fPSDProb < gkProbLimit)
+    {
+      SETBIT(fFlags,kOscillating);
+      return kTRUE;
+    }
+  
+  CLRBIT(fFlags,kOscillating);
+
+  return kFALSE;
+}
+
+void MHCalibrationPixel::CreatePSDXaxis(Int_t n)
+{
+  
+  if (fPSDXaxis)
+    return;
+
+  fPSDXaxis = new TArrayF(n);
+
+  for (Int_t i=0;i<n;i++)
+    fPSDXaxis->AddAt((Float_t)i,i);
+}
+
+void MHCalibrationPixel::CreateChargeXaxis(Int_t n)
+{
+  
+  if (!fChargeXaxis)
+    {
+      fChargeXaxis = new TArrayF(n);
+      for (Int_t i=0;i<n;i++)
+        fChargeXaxis->AddAt((Float_t)i,i);
+      return;
+    }
+
+  if (fChargeXaxis->GetSize() == n)
+    return;
+
+  const Int_t diff = fChargeXaxis->GetSize()-n;
+  fChargeXaxis->Set(n);
+  if (diff < 0)
+    for (Int_t i=n;i<n+diff;i++)
+      fChargeXaxis->AddAt((Float_t)i,i);
+}
+
+void MHCalibrationPixel::CutArrayBorder(TArrayF *array)
+{
+  
+  Int_t i;
+
+  for (i=array->GetSize()-1;i>=0;i--)
+    if (array->At(i) != 0)
+      {
+        array->Set(i+1);
+        break;
+      }
+}
+
+
+
 Bool_t MHCalibrationPixel::IsEmpty() const
 {
@@ -276,7 +370,12 @@
 }
 
-Bool_t MHCalibrationPixel::IsTimeFitOK() const 
-{
-    return TESTBIT(fFlags,kTimeFitOK);
+Bool_t MHCalibrationPixel::IsOscillating()
+{
+
+  if (fPSDExpFit)
+    return TESTBIT(fFlags,kOscillating);
+
+  return CheckOscillations();
+
 }
 
@@ -291,14 +390,4 @@
 }
 
-Bool_t MHCalibrationPixel::FillRelTimeLoGain(Float_t t)
-{
-    return (fHRelTimeLoGain->Fill(t) > -1);
-}
-
-Bool_t MHCalibrationPixel::FillChargevsNLoGain(Float_t q, Int_t n)
-{
-    return (fHChargevsNLoGain->Fill(n,q) > -1);
-}
-
 Bool_t MHCalibrationPixel::FillChargeHiGain(Float_t q)
 {
@@ -309,14 +398,4 @@
 {
     return (fHAbsTimeHiGain->Fill(t) > -1);
-}
-
-Bool_t MHCalibrationPixel::FillRelTimeHiGain(Float_t t)
-{
-    return (fHRelTimeHiGain->Fill(t) > -1);
-}
-
-Bool_t MHCalibrationPixel::FillChargevsNHiGain(Float_t q, Int_t n)
-{
-    return (fHChargevsNHiGain->Fill(n,q) > -1);
 }
 
@@ -333,6 +412,4 @@
       fHChargeHiGain->SetName(   Form("%s%d",fHChargeHiGain->GetName(),   id));
       fHAbsTimeHiGain->SetName(  Form("%s%d",fHAbsTimeHiGain->GetName(),  id));
-      fHRelTimeHiGain->SetName(  Form("%s%d",fHRelTimeHiGain->GetName(),  id));
-      fHChargevsNHiGain->SetName(Form("%s%d",fHChargevsNHiGain->GetName(),id));
       
       //
@@ -341,6 +418,4 @@
       fHChargeHiGain->SetTitle(    Form("%s%d",fHChargeHiGain->GetTitle(),   id));
       fHAbsTimeHiGain->SetTitle(   Form("%s%d",fHAbsTimeHiGain->GetTitle(),  id));
-      fHRelTimeHiGain->SetTitle(   Form("%s%d",fHRelTimeHiGain->GetTitle(),  id));
-      fHChargevsNHiGain->SetTitle( Form("%s%d",fHChargevsNHiGain->GetTitle(),id));
   
       //
@@ -349,6 +424,4 @@
       fHChargeLoGain->SetName( Form("%s%d",fHChargeLoGain->GetName(),id));
       fHAbsTimeLoGain->SetName( Form("%s%d",fHAbsTimeLoGain->GetName(),id));
-      fHRelTimeLoGain->SetName( Form("%s%d",fHRelTimeLoGain->GetName(),id));
-      fHChargevsNLoGain->SetName( Form("%s%d",fHChargevsNLoGain->GetName(),id));
 
       //
@@ -357,19 +430,8 @@
       fHChargeLoGain->SetTitle( Form("%s%d",fHChargeLoGain->GetTitle(),id));
       fHAbsTimeLoGain->SetTitle( Form("%s%d",fHAbsTimeLoGain->GetTitle(),id));
-      fHRelTimeLoGain->SetTitle( Form("%s%d",fHRelTimeLoGain->GetTitle(),id));
-      fHChargevsNLoGain->SetTitle( Form("%s%d",fHChargevsNLoGain->GetTitle(),id));
       
       fPixId = id;
     }
   
-}
-
-
-Bool_t MHCalibrationPixel::SetupFill(const MParList *plist)
-{
- 
-  Reset();
-  
-  return kTRUE;
 }
 
@@ -390,12 +452,19 @@
 }
 
-Bool_t MHCalibrationPixel::FillPointInGraph(Float_t qhi,Float_t qlo)
-{
-
-  fHiGains->Set(++fTotalEntries);
-  fLoGains->Set(fTotalEntries);
-
-  fHiGains->AddAt(qhi,fTotalEntries-1);
-  fLoGains->AddAt(qlo,fTotalEntries-1);
+Bool_t MHCalibrationPixel::FillGraphs(Float_t qhi,Float_t qlo)
+{
+
+  if (fTotalEntries >= fCurrentSize)
+    {
+      fCurrentSize *= 2;
+
+      fHiGains->Set(fCurrentSize);
+      fLoGains->Set(fCurrentSize);
+    }
+  
+  fHiGains->AddAt(qhi,fTotalEntries);
+  fLoGains->AddAt(qlo,fTotalEntries);
+
+  fTotalEntries++;
 
   return kTRUE;
@@ -508,7 +577,4 @@
   fHChargeHiGain->Draw(opt);
   
-  c->Modified();
-  c->Update();
-  
   if (IsUseLoGain())
     {
@@ -528,7 +594,4 @@
         }
 
-      c->Modified();
-      c->Update();
-      
       c->cd(3);
       gROOT->SetSelectedPad(NULL);
@@ -536,10 +599,7 @@
       if (fHivsLoGain)
         fHivsLoGain->Draw("prof");
-      gPad->Modified();
-      gPad->Update();
-      
+
       c->cd(4);
       DrawLegend();
-      
     }
   else
@@ -558,7 +618,5 @@
       
       fHChargeLoGain->Draw(opt);
-      c->Modified();
-      c->Update();
-      
+
       c->cd(3);
       DrawLegend();
@@ -570,87 +628,89 @@
       if (fHivsLoGain)
         fHivsLoGain->Draw("prof");
-      gPad->Modified();
-      gPad->Update();
     }	
+  
+  c->cd(5);
+  gPad->SetTicks();
+  fHAbsTimeHiGain->Draw(opt);
+
+  c->cd(6);
+  gPad->SetTicks();
+  fHAbsTimeLoGain->Draw(opt);
+
+  CutArrayBorder(fHiGains);
+  CreateChargeXaxis(fHiGains->GetSize());
+
+  c->cd(7);
+  gPad->SetTicks();
+  TGraph *gr1 = new TGraph(fChargeXaxis->GetSize(),
+                           fChargeXaxis->GetArray(),
+                           fHiGains->GetArray());  
+  gr1->SetTitle("Evolution of HiGain charges with event number");
+  gr1->SetBit(kCanDelete);
+  gr1->Draw("AL");
+  
+  CutArrayBorder(fLoGains);  
+  CreateChargeXaxis(fHiGains->GetSize());
+
+  c->cd(8);
+  gPad->SetTicks();
+  TGraph *gr2 = new TGraph(fChargeXaxis->GetSize(),
+                           fChargeXaxis->GetArray(),
+                           fLoGains->GetArray());  
+  gr2->SetTitle("Evolution of HiGain charges with event number");
+  gr2->SetBit(kCanDelete);
+  gr2->Draw("AL");
   
   c->Modified();
   c->Update();
   
-  c->cd(5);
-  gStyle->SetOptStat(1111111);
-
-  gPad->SetTicks();  
-  gPad->SetLogy(0);
-  fHRelTimeHiGain->Draw(opt);
+  c->cd(9);
+  
+  TArrayF *array;
+
+  if(IsUseLoGain())
+    {
+      if (!fPSDLoGain)
+        return;
+      array = fPSDLoGain;
+    }
+  else
+    {
+      if (!fPSDHiGain)
+        return;
+      array = fPSDHiGain;
+    }
+  
+  if (!fPSDXaxis)
+    CreatePSDXaxis(array->GetSize());
+
+  TGraph *gr3 = new TGraph(fPSDXaxis->GetSize(),fPSDXaxis->GetArray(),array->GetArray());
+  gr3->SetTitle("Power Spectrum Density");
+  gr3->SetBit(kCanDelete);
+  gr3->Draw("AL");
+
   c->Modified();
   c->Update();
   
-  if (IsUseLoGain())
-      {
-        
-	c->cd(6);
-        gPad->SetTicks();
-	gPad->SetLogy(0);
-	fHRelTimeLoGain->Draw(opt);
-	c->Modified();
-	c->Update();
-	
-	if (fRelTimeGausFit)
-	  {
-            fRelTimeGausFit->SetLineColor(IsTimeFitOK() ? kGreen : kRed);
-	    fRelTimeGausFit->Draw("same");
-	  }
-
-        c->Modified();
-        c->Update();
-      }
-    else
-      {  
-	if (fRelTimeGausFit)
-	  {
-            fRelTimeGausFit->SetLineColor(IsTimeFitOK() ? kGreen : kRed);
-	    fRelTimeGausFit->Draw("same");
-	  }
-        
-        c->Modified();
-        c->Update();
-	
-        c->cd(6);
-        gPad->SetTicks();
-	gPad->SetLogy(0);
-	fHRelTimeLoGain->Draw(opt);	
-	c->Modified();
-	c->Update();
-    
-      }
-    c->Modified();
-    c->Update();
-    
-    c->cd(7);
-    gPad->SetTicks();
-    fHAbsTimeHiGain->Draw(opt);
-    c->Modified();
-    c->Update();
-
-    c->cd(8);
-    gPad->SetTicks();
-    fHAbsTimeLoGain->Draw(opt);
-    c->Modified();
-    c->Update();
-
-
-    c->cd(9);
-    gPad->SetTicks();
-    fHChargevsNHiGain->Draw(opt);
-    c->Modified();
-    c->Update();
-
-    c->cd(10);
-    gPad->SetTicks();
-    fHChargevsNLoGain->Draw(opt);
-    c->Modified();
-    c->Update();
-
-    return;
+  c->cd(10);
+  
+  gStyle->SetOptStat(111111);
+  gPad->SetTicks();  
+
+  if (fHPSD->Integral() > 0)
+    gPad->SetLogy();
+
+  fHPSD->Draw(opt);
+
+  if (fPSDExpFit)
+    {
+      fPSDExpFit->SetLineColor(IsOscillating() ? kRed : kGreen);          
+      fPSDExpFit->Draw("same");
+    }
+
+  c->Modified();
+  c->Update();
+  
+  return;
 }
 
@@ -684,100 +744,4 @@
 }
 
-
-Bool_t MHCalibrationPixel::FitTime(Option_t *option)
-{
-
-  if (fRelTimeGausFit)
-    return kFALSE;
-
-  //
-  // From the absolute time, we only take the mean and RMS
-  //
-  fAbsTimeMean    = (Float_t)fHAbsTimeHiGain->GetMean();
-  fAbsTimeRms     = (Float_t)fHAbsTimeHiGain->GetRMS();
-  fAbsTimeMeanErr = (Float_t)fAbsTimeRms / TMath::Sqrt(fHAbsTimeHiGain->GetEntries());
-  
-  if (TESTBIT(fFlags,kUseLoGain))
-    {
-      fAbsTimeMean    = fHAbsTimeLoGain->GetMean();
-      fAbsTimeRms     = fHAbsTimeLoGain->GetRMS();
-      fAbsTimeMeanErr = fAbsTimeRms / TMath::Sqrt(fHAbsTimeLoGain->GetEntries());
-    }
-  
-  //
-  // Get the fitting ranges
-  //
-  Axis_t rmin = fRelTimeLowerFitRangeHiGain;
-  Axis_t rmax = fRelTimeUpperFitRangeHiGain;
-  TH1F *hist = fHRelTimeHiGain;
-
-  if (TESTBIT(fFlags,kUseLoGain))
-    {
-      rmin = fRelTimeLowerFitRangeLoGain;
-      rmax = fRelTimeUpperFitRangeLoGain;
-      hist = fHRelTimeLoGain;
-    }
-  
-  const Stat_t   entries     = hist->Integral("width");
-  const Double_t mu_guess    = hist->GetBinCenter(hist->GetMaximumBin());
-  const Double_t sigma_guess = (rmax - rmin)/2.;
-  const Double_t area_guess  = 2.*entries/gkSq2Pi/sigma_guess;
-
-  TString name = TString("GausRelTime");
-  name += fPixId;
-  fRelTimeGausFit = new TF1(name.Data(),"gaus",rmin,rmax);  
-
-  if (!fRelTimeGausFit) 
-    {
-    *fLog << warn << dbginf << "WARNING: Could not create fit function for RelTime fit" << endl;
-    return kFALSE;
-    }
-
-  fRelTimeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
-  fRelTimeGausFit->SetParNames("Area","#mu","#sigma");
-  fRelTimeGausFit->SetParLimits(0,0.,5.*area_guess);
-  fRelTimeGausFit->SetParLimits(1,rmin,rmax);
-  fRelTimeGausFit->SetParLimits(2,0.,(rmax-rmin));
-  fRelTimeGausFit->SetRange(rmin,rmax);
-
-  hist->Fit(fRelTimeGausFit,option);
-
-  //
-  // If the fit does not converge, try another one with smaller bounderies
-  //
-  if (fRelTimeGausFit->GetProb() < 0.001)
-    {
-      rmin = fRelTimeGausFit->GetParameter(1) - 1.5*fRelTimeGausFit->GetParameter(2);
-      rmax = fRelTimeGausFit->GetParameter(1) + 1.5*fRelTimeGausFit->GetParameter(2);
-      fRelTimeGausFit->SetRange(rmin,rmax);  
-      hist->Fit(fRelTimeGausFit,option);
-    }
-  
-  fRelTimeChisquare = fRelTimeGausFit->GetChisquare();
-  fRelTimeNdf       = fRelTimeGausFit->GetNDF();
-  fRelTimeProb      = fRelTimeGausFit->GetProb();
-
-  fRelTimeMean      = fRelTimeGausFit->GetParameter(1);
-  fRelTimeSigma     = fRelTimeGausFit->GetParameter(2);
-
-  fRelTimeMeanErr   = fRelTimeGausFit->GetParError(1);
-
-  if (TMath::IsNaN(fRelTimeMean) || TMath::IsNaN(fRelTimeSigma))
-    {
-      CLRBIT(fFlags,kTimeFitOK);
-      return kFALSE;
-    }
-  
-  if (TMath::IsNaN(fRelTimeChisquare) || (fRelTimeProb < fProbLimit))
-    {
-      CLRBIT(fFlags,kTimeFitOK);
-      return kFALSE;
-    }
-  
-  SETBIT(fFlags,kTimeFitOK);
-
-  return kTRUE;
-
-}
 
 
@@ -850,4 +814,18 @@
 
   //
+  // From the absolute time, we only take the mean and RMS
+  //
+  fAbsTimeMean    = (Float_t)fHAbsTimeHiGain->GetMean();
+  fAbsTimeRms     = (Float_t)fHAbsTimeHiGain->GetRMS();
+  fAbsTimeMeanErr = (Float_t)fAbsTimeRms / TMath::Sqrt(fHAbsTimeHiGain->GetEntries());
+  
+  if (TESTBIT(fFlags,kUseLoGain))
+    {
+      fAbsTimeMean    = fHAbsTimeLoGain->GetMean();
+      fAbsTimeRms     = fHAbsTimeLoGain->GetRMS();
+      fAbsTimeMeanErr = fAbsTimeRms / TMath::Sqrt(fHAbsTimeLoGain->GetEntries());
+    }
+
+  //
   // The fit result is accepted under condition:
   // 1) The results are not nan's
@@ -880,10 +858,8 @@
 
 
-
- 
 void MHCalibrationPixel::CutAllEdges()
 {
 
-  Int_t nbins = 50;
+  Int_t nbins = 30;
 
   CutEdges(fHChargeHiGain,nbins);
@@ -899,15 +875,4 @@
                       +fHChargeLoGain->GetBinWidth(0);
 
-  CutEdges(fHRelTimeHiGain,0);
-
-  fRelTimeLowerFitRangeHiGain = fHRelTimeHiGain->GetBinLowEdge(fHRelTimeHiGain->GetXaxis()->GetFirst());
-  fRelTimeUpperFitRangeHiGain = fHRelTimeHiGain->GetBinLowEdge(fHRelTimeHiGain->GetXaxis()->GetLast())
-                               +fHRelTimeHiGain->GetBinWidth(0);
-
-  CutEdges(fHRelTimeLoGain,0);
-
-  fRelTimeLowerFitRangeLoGain = fHRelTimeLoGain->GetBinLowEdge(fHRelTimeLoGain->GetXaxis()->GetFirst());
-  fRelTimeUpperFitRangeLoGain = fHRelTimeLoGain->GetBinLowEdge(fHRelTimeLoGain->GetXaxis()->GetLast())
-                               +fHRelTimeLoGain->GetBinWidth(0);
 
   CutEdges(fHAbsTimeHiGain,0);
@@ -923,6 +888,4 @@
                        +fHAbsTimeLoGain->GetBinWidth(0);
 
-  CutEdges(fHChargevsNHiGain,0);
-  CutEdges(fHChargevsNLoGain,0);
 
 }
@@ -939,12 +902,2 @@
 }
 
-void MHCalibrationPixel::PrintTimeFitResult()
-{
-
-  *fLog << all << "Results of the Time Slices Fit: "                        << endl;
-  *fLog << all << "Chisquare: "   << fRelTimeChisquare                      << endl;
-  *fLog << all << "Ndf: "         << fRelTimeNdf                            << endl;
-  *fLog << all << "Probability: " << fRelTimeProb                           << endl;
-  *fLog << all                                                              << endl;
-
-}
