Index: trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc	(revision 3028)
+++ 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;
-}
-
