Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.cc	(revision 2718)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationCam.cc	(revision 2719)
@@ -206,24 +206,4 @@
 }
 
-// --------------------------------------------------------------------------
-//
-// Return TRUE if:
-//
-// 1) Pixel is inside the range of the TClonesArray
-// 2) Pixel has a fitted charge greater than 3*PedRMS
-// 3) Pixel has a charge sigma bigger than its Pedestal RMS
-// 4) Pixel has a fit error greater than 0.
-// 5) Pixel has a fit Probability greater than 0.0001
-// 6) If FitTimes is used, 
-//    the mean arrival time is at least 1.5 slices from the edge
-// 
-Bool_t MCalibrationCam::IsPixelFitValid(Int_t idx) const 
-{
-
-  if (!CheckBounds(idx))
-    return kFALSE;
-
-  return (*this)[idx].IsFitValid();
-}
 
 // --------------------------------------
@@ -397,4 +377,6 @@
 }
 
+
+
 Bool_t MCalibrationCam::CalcNumPhotInsidePlexiglass()
 {
@@ -442,5 +424,14 @@
     {
       if((pix->GetCharge() > 0.) && (fMeanPhotInsidePlexiglass > 0.))
-	pix->SetConversionBlindPixelMethod(fMeanPhotInsidePlexiglass/pix->GetCharge(), 0., 0.);
+        {
+
+          Float_t conversion      = fMeanPhotInsidePlexiglass/pix->GetCharge();
+          Float_t conversionerr   = 0.;
+          Float_t conversionsigma = 0.;
+          pix->SetConversionBlindPixelMethod(conversion, conversionerr, conversionsigma);
+
+          if (conversionerr/conversion < 0.1) 
+            pix->SetBlindPixelMethodValid();
+        }
     }
   return kTRUE;
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc	(revision 2718)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc	(revision 2719)
@@ -72,5 +72,10 @@
       fConversionSigmaBlindPixelMethod(-1.),
       fConversionSigmaPINDiodeMethod(-1.),
-      fHiGainSaturation(kFALSE)
+      fHiGainSaturation(kFALSE),
+      fFitValid(kFALSE),        
+      fFitted(kFALSE), 
+      fBlindPixelMethodValid(kFALSE),
+      fFFactorMethodValid(kFALSE),
+      fPINDiodeMethodValid(kFALSE)
 {
 
@@ -106,114 +111,4 @@
 }
 
-
-Bool_t MCalibrationPix::IsFitted()
-{
-  return (fCharge > 0.) && (fErrCharge > 0.) ;
-}
-
-// --------------------------------------------------------------------------
-//
-// Return TRUE if:
-//
-// 1) Pixel has a fitted charge greater than 3*PedRMS
-// 2) Pixel has a fit error greater than 0.
-// 3) Pixel has a fit Probability greater than 0.0001 
-// 4) Pixel has a charge sigma bigger than its Pedestal RMS
-// 5) If FitTimes is used, 
-//    the mean arrival time is at least 1.5 slices from the edge
-// 
-Bool_t MCalibrationPix::IsFitValid()
-{
-   
-  if (fCharge < 3.*GetPedRms())
-    return kFALSE;
-  
-  if (fErrCharge <= 0.)
-    return kFALSE;
-  
-  if (!fHist->IsFitOK()) 
-    return kFALSE;
-  
-  if (fSigmaCharge <= fPedRms)
-    return kFALSE;
-
-  if (fHist->GetTimeLowerFitRange() < fTime < fHist->GetTimeLowerFitRange()+1.)
-    return kFALSE;
-
-  if (fHist->GetTimeUpperFitRange()-1. < fTime < fHist->GetTimeUpperFitRange())
-    return kFALSE;
-
-  return kTRUE;
-  
-}
-
-// --------------------------------------------------------------------------
-//
-// Return TRUE if:
-//
-// 1) Pixel is FitValid
-// 2) Conversion Factor is bigger than 0.
-// 3) The error of the conversion factor is smaller than 10%
-//
-Bool_t MCalibrationPix::IsBlindPixelMethodValid()
-{
-  
-  if (!IsFitValid())
-    return kFALSE;
-
-  if (fConversionBlindPixelMethod <= 0.)
-    return kFALSE;
-  
-  if (fConversionErrorBlindPixelMethod/fConversionBlindPixelMethod > 0.1)
-    return kFALSE;
-  
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Return TRUE if:
-//
-// 1) Pixel is FitValid
-// 2) Conversion Factor is bigger than 0.
-// 3) The error of the conversion factor is smaller than 10%
-//
-Bool_t MCalibrationPix::IsFFactorMethodValid()
-{
-  
-  if (!IsFitValid())
-    return kFALSE;
-
-  if (fConversionFFactorMethod <= 0.)
-    return kFALSE;
-  
-  if (fConversionErrorFFactorMethod/fConversionFFactorMethod > 0.1)
-    return kFALSE;
-
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Return TRUE if:
-//
-// 1) Pixel is FitValid
-// 2) Conversion Factor is bigger than 0.
-// 3) The error of the conversion factor is smaller than 10%
-//
-Bool_t MCalibrationPix::IsPINDiodeMethodValid()
-{
-  
-  if (!IsFitValid())
-    return kFALSE;
-
-  if (fConversionPINDiodeMethod <= 0.)
-    return kFALSE;
-  
-  if (fConversionErrorPINDiodeMethod/fConversionPINDiodeMethod > 0.1)
-    return kFALSE;
-
-  return kTRUE;
-}
 
 // --------------------------------------------------------------------------
@@ -229,4 +124,19 @@
 // 8) Calculate the errors of the F-Factor method
 //
+// The fit is declared as valid, if:
+//
+// 1) Pixel has a fitted charge greater than 3*PedRMS
+// 2) Pixel has a fit error greater than 0.
+// 3) Pixel has a fit Probability greater than 0.0001 
+// 4) Pixel has a charge sigma bigger than its Pedestal RMS
+// 5) If FitTimes is used, 
+//    the mean arrival time is at least 1.5 slices from the edge
+// 
+// The F-Factor method is declared as valid, if:
+//
+// 1) Pixel is FitValid
+// 2) Conversion Factor is bigger than 0.
+// 3) The error of the conversion factor is smaller than 10%
+//
 Bool_t MCalibrationPix::FitCharge() 
 {
@@ -273,5 +183,15 @@
       return kFALSE;
     }
-  
+
+  if (fErrCharge > 0.) 
+    fFitted = kTRUE;
+
+  if ( (fCharge > 3.*GetPedRms()) &&
+       (fErrCharge  > 0.)        &&
+       (fHist->IsFitOK())        &&
+       (fSigmaCharge > fPedRms)  &&
+       (fTime > fHist->GetTimeLowerFitRange()+1.) &&
+       (fTime < fHist->GetTimeUpperFitRange()-1.) )
+    fFitValid =  kTRUE;
 
   //
@@ -326,5 +246,8 @@
           Float_t logainrmssquare          = nsbsquare/conversionsquare + elecrmssquare;
           Float_t logainrmssquareerrsquare = nsbsquareerrsquare/conversionsquare/conversionsquare 
-                                           + elecrmssquareerr * elecrmssquareerr ;
+                                           + elecrmssquareerr * elecrmssquareerr 
+                                           + conversionsquareerr*conversionsquareerr
+                                             / (conversionsquare*conversionsquare)
+                                             / (conversionsquare*conversionsquare);
           //
           // Calculate the reduced sigma with the new "Pedestal RMS"
@@ -377,4 +300,10 @@
       fPheFFactorMethodError        =  TMath::Sqrt(pheffactorrelerrsquare) * fPheFFactorMethod;
 
+      if ( IsFitValid()                    &&
+          (fConversionFFactorMethod > 0.) &&
+           (fConversionErrorFFactorMethod/fConversionFFactorMethod < 0.1) )
+        fFFactorMethodValid = kTRUE;
+      
+
     } /*   if ((fPed > 0.)  && (fPedRms > 0.)) */
 
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h	(revision 2718)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h	(revision 2719)
@@ -48,6 +48,12 @@
   Float_t fConversionSigmaPINDiodeMethod;   // The conversion factor to Phd's calculated after the PIN Diode method
 
-  Bool_t fHiGainSaturation;     // Is Lo-Gain used at all?
+  Bool_t  fHiGainSaturation;     // Is Lo-Gain used at all?
 
+  Bool_t  fFitValid;        
+  Bool_t  fFitted; 
+  Bool_t  fBlindPixelMethodValid;
+  Bool_t  fFFactorMethodValid;
+  Bool_t  fPINDiodeMethodValid;
+  
   MHCalibrationPixel *fHist;    //! Pointer to the histograms performing the fits, etc.  
   
@@ -122,9 +128,15 @@
   Bool_t FillRChargevsTimeLoGain(Float_t rq, Int_t t)  { return fHist->FillChargevsNLoGain(rq,t); }    
   
-  Bool_t IsFitValid();        
-  Bool_t IsFitted(); 
-  Bool_t IsBlindPixelMethodValid();
-  Bool_t IsFFactorMethodValid();
-  Bool_t IsPINDiodeMethodValid();
+  Bool_t IsFitValid()                                  { return fFitValid;  }
+  Bool_t IsFitted()                                    { return fFitted;  }
+  Bool_t IsBlindPixelMethodValid()                     { return fBlindPixelMethodValid;  }
+  Bool_t IsFFactorMethodValid()                        { return fFFactorMethodValid;  }
+  Bool_t IsPINDiodeMethodValid()                       { return fPINDiodeMethodValid;  }
+  
+  void   SetFitValid()                                     { fFitValid = kTRUE;  }
+  void   SetFitted()                                      { fFitted = kTRUE;  }
+  void   SetBlindPixelMethodValid()                             { fBlindPixelMethodValid = kTRUE;  }
+  void   SetFFactorMethodValid()                               { fFFactorMethodValid = kTRUE;  }
+  void   SetPINDiodeMethodValid()                              { fPINDiodeMethodValid = kTRUE;  }
   
   Int_t  GetPixId()                              const  { return fPixId;   }
