Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h	(revision 3496)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h	(revision 3510)
@@ -26,51 +26,55 @@
   static const Float_t fgTimeErrLimit;           // The limit (in units of FADC slices) for acceptance of the fitted time sigma
 
-  Float_t fChargeLimit;                     // The limit (in units of PedRMS) for acceptance of the fitted mean charge
-  Float_t fChargeErrLimit;                  // The limit (in units of PedRMS) for acceptance of the fitted charge sigma
-  Float_t fChargeRelErrLimit;               // The limit (in units of Error of fitted charge) for acceptance of the fitted mean  
-  
-  Float_t fTimeLimit;                       // The limit (in units of FADC slices) for acceptance of the fitted time
-  Float_t fTimeErrLimit;                    // The limit (in units of FADC slices) for acceptance of the fitted time sigma
-
-  Float_t fElectronicPedRms;                // The pure electronic component of the RMS
-  Float_t fElectronicPedRmsErr;             // The error of the pure electronic component of the RMS
-
-  Int_t   fPixId;                           // the pixel Id
-
-  UInt_t  fFlags;                           // Flag for the set bits
- 
-  Float_t fHiGainMeanCharge;                // The mean reduced charge after the fit
-  Float_t fHiGainMeanChargeErr;             // The error of reduced mean charge after the fit
-  Float_t fHiGainSigmaCharge;               // The sigma of the mean charge after the fit
-  Float_t fHiGainSigmaChargeErr;            // The error of the sigma of the mean charge after the fit
-  Float_t fHiGainChargeProb;                // The probability of the fit function 
-
-  Float_t fLoGainMeanCharge;                // The mean reduced charge after the fit
-  Float_t fLoGainMeanChargeErr;             // The error of reduced mean charge after the fit
-  Float_t fLoGainSigmaCharge;               // The sigma of the mean charge after the fit
-  Float_t fLoGainSigmaChargeErr;            // The error of the sigma of the mean charge after the fit
-  Float_t fLoGainChargeProb;                // The probability of the fit function 
-
-  Float_t fRSigmaCharge;                    // The reduced squares of sigmas after the fit
-  Float_t fRSigmaChargeErr;                 // The reduced squares of sigmas after the fit  
-
-  Float_t fPed;                             // The mean pedestal (from MPedestalPix) times number of FADC slices
-  Float_t fPedErr;                          // The error of the pedestal 
-  Float_t fPedRms;                          // The pedestal  RMS (from MPedestalPix) times sqrt of number of FADC slices
-
-  Float_t fLoGainPedRms;                    // The pedestal  RMS of the low gain
-  Float_t fLoGainPedRmsErr;                 // The pedestal  RMS Error of the low gain
-
-  Float_t fAbsTimeMean;                     // The mean absolute arrival time
-  Float_t fAbsTimeRms;                      // The rms of the mean absolute arrival time
-  
-  Byte_t  fTimeFirstHiGain;                 // The first used FADC slice
-  Byte_t  fTimeLastHiGain;                  // The last used FADC slice
-  
-  Byte_t  fTimeFirstLoGain;                 // The first used FADC slice
-  Byte_t  fTimeLastLoGain;                  // The last used FADC slice
-  
-  Float_t fPheFFactorMethod;                // The number of Phe's calculated (F-factor method)
-  Float_t fPheFFactorMethodErr;             // The error on the number of Phe's calculated (F-factor method)
+  static const Float_t fgPheFFactorMethodLimit;  // The default minimum number of Photo-electrons for a pixel to be accepted.
+  
+  Float_t fChargeLimit;             // The limit (in units of PedRMS) for acceptance of the fitted mean charge
+  Float_t fChargeVarLimit;          // The limit (in units of PedRMS) for acceptance of the fitted charge sigma square
+  Float_t fChargeRelVarLimit;       // The limit (in units of Variance of fitted charge) for acceptance of the fitted mean  
+  
+  Float_t fTimeLimit;               // The limit (in units of FADC slices) for acceptance of the fitted time
+  Float_t fTimeVarLimit;            // The limit (in units of FADC slices) for acceptance of the fitted time sigma
+
+  Float_t fElectronicPedRms;        // The pure electronic component of the RMS
+  Float_t fElectronicPedRmsVar;     // The error of the pure electronic component of the RMS
+
+  Float_t fPheFFactorMethodLimit;   // The minimum number of Photo-electrons for a pixel to be accepted.
+  
+  Int_t   fPixId;                   // the pixel Id
+
+  UInt_t  fFlags;                   // Flag for the set bits
+ 
+  Float_t fHiGainMeanCharge;        // The mean reduced charge after the fit
+  Float_t fHiGainMeanChargeVar;     // The error of reduced mean charge after the fit
+  Float_t fHiGainSigmaCharge;       // The sigma of the mean charge after the fit
+  Float_t fHiGainSigmaChargeVar;    // The error of the sigma of the mean charge after the fit
+  Float_t fHiGainChargeProb;        // The probability of the fit function 
+
+  Float_t fLoGainMeanCharge;        // The mean reduced charge after the fit
+  Float_t fLoGainMeanChargeVar;     // The error of reduced mean charge after the fit
+  Float_t fLoGainSigmaCharge;       // The sigma of the mean charge after the fit
+  Float_t fLoGainSigmaChargeVar;    // The error of the sigma of the mean charge after the fit
+  Float_t fLoGainChargeProb;        // The probability of the fit function 
+
+  Float_t fRSigmaCharge;            // The reduced squares of sigmas after the fit
+  Float_t fRSigmaChargeVar;         // The reduced squares of sigmas after the fit  
+
+  Float_t fPed;                     // The mean pedestal (from MPedestalPix) times number of FADC slices
+  Float_t fPedVar;                  // The error of the pedestal 
+  Float_t fPedRms;                  // The pedestal  RMS (from MPedestalPix) times sqrt of number of FADC slices
+
+  Float_t fLoGainPedRms;            // The pedestal  RMS of the low gain
+  Float_t fLoGainPedRmsVar;         // The pedestal  RMS Variance of the low gain
+
+  Float_t fAbsTimeMean;             // The mean absolute arrival time
+  Float_t fAbsTimeRms;              // The rms of the mean absolute arrival time
+  
+  Byte_t  fTimeFirstHiGain;         // The first used FADC slice
+  Byte_t  fTimeLastHiGain;          // The last used FADC slice
+  
+  Byte_t  fTimeFirstLoGain;         // The first used FADC slice
+  Byte_t  fTimeLastLoGain;          // The last used FADC slice
+  
+  Float_t fPheFFactorMethod;        // The number of Phe's calculated (F-factor method)
+  Float_t fPheFFactorMethodVar;     // The error on the number of Phe's calculated (F-factor method)
 
   Float_t fMeanConversionFFactorMethod;     // The conversion factor to Phe's (F-factor method)
@@ -79,8 +83,8 @@
   Float_t fMeanConversionCombinedMethod;    // The conversion factor to Ph's (all methods combined)
 
-  Float_t fConversionFFactorMethodErr;      // The error of the conversion factor to Phe's (F-factor method)
-  Float_t fConversionBlindPixelMethodErr;   // The error of the conversion factor to Ph's (Blind Pixel method)
-  Float_t fConversionPINDiodeMethodErr;     // The error of the conversion factor to Ph's (PIN Diode method)
-  Float_t fConversionCombinedMethodErr;     // The error of the conversion factor to Ph's (all methods combined)
+  Float_t fConversionFFactorMethodVar;      // The error of the conversion factor to Phe's (F-factor method)
+  Float_t fConversionBlindPixelMethodVar;   // The error of the conversion factor to Ph's (Blind Pixel method)
+  Float_t fConversionPINDiodeMethodVar;     // The error of the conversion factor to Ph's (PIN Diode method)
+  Float_t fConversionCombinedMethodVar;     // The error of the conversion factor to Ph's (all methods combined)
 
   Float_t fSigmaConversionFFactorMethod;    // The sigma of conversion factor to Phe's (F-factor method)
@@ -94,14 +98,14 @@
   Float_t fTotalFFactorCombinedMethod;      // The total F-Factor to Ph's (all methods combined)
  
-  Float_t fTotalFFactorErrFFactorMethod;         // The error of the total F-Factor to Ph's (F-factor method)
-  Float_t fTotalFFactorErrBlindPixelMethod;      // The error of the total F-Factor to Ph's (Blind Pixel method)
-  Float_t fTotalFFactorErrPINDiodeMethod;        // The error of the total F-Factor to Ph's (PIN Diode method)
-  Float_t fTotalFFactorErrCombinedMethod;        // The error of the total F-Factor to Ph's (all methods combined)
- 
-  Float_t fTotalFFactor;                         // The F-Factor of the total readout system (Sigma(out)/mean(out)*Mean(in)/sigma(in)
-  Float_t fTotalFFactorErr;                      // The error on the F-Factor of the total readout system
-  
-  Float_t fConversionHiLo;                       // The conversion factor between Hi Gain and Lo Gain  
-  Float_t fConversionHiLoErr;                    // The error of the conversion factor between Hi Gain and Lo Gain  
+  Float_t fTotalFFactorFFactorMethodVar;    // The variance of the total F-Factor to Ph's (F-factor method)
+  Float_t fTotalFFactorBlindPixelMethodVar; // The variance of the total F-Factor to Ph's (Blind Pixel method)
+  Float_t fTotalFFactorPINDiodeMethodVar;   // The variance of the total F-Factor to Ph's (PIN Diode method)
+  Float_t fTotalFFactorCombinedMethodVar;   // The variance of the total F-Factor to Ph's (all methods combined)
+ 
+  Float_t fTotalFFactor;                    // The F-Factor of the total readout system (Sigma(out)/mean(out)*Mean(in)/sigma(in)
+  Float_t fTotalFFactorVar;                 // The variance on the F-Factor of the total readout system
+  
+  Float_t fConversionHiLo;                  // The conversion factor between Hi Gain and Lo Gain  
+  Float_t fConversionHiLoVar;               // The error of the conversion factor between Hi Gain and Lo Gain  
 
   Float_t fNumLoGainSamples;
@@ -130,24 +134,26 @@
 
   void SetConversionHiLo(     const Float_t c = gkConversionHiLo)       { fConversionHiLo      = c;    }
-  void SetConversionHiLoErr(  const Float_t e = gkConversionHiLoErr)    { fConversionHiLoErr   = e;    }
+  void SetConversionHiLoErr(  const Float_t e = gkConversionHiLoErr)    { fConversionHiLoVar   = e*e;    }
   void SetChargeLimit    (   const Float_t f=fgChargeLimit       ) { fChargeLimit       = f; }
-  void SetChargeErrLimit (   const Float_t f=fgChargeErrLimit    ) { fChargeErrLimit    = f; }
-  void SetChargeRelErrLimit( const Float_t f=fgChargeRelErrLimit ) { fChargeRelErrLimit = f; }
+  void SetChargeErrLimit (   const Float_t f=fgChargeErrLimit    ) { fChargeVarLimit    = f*f; }
+  void SetChargeRelErrLimit( const Float_t f=fgChargeRelErrLimit ) { fChargeRelVarLimit = f*f; }
 
   void SetTimeLimit      (   const Float_t f=fgTimeLimit         ) { fTimeLimit       = f;   }
-  void SetTimeErrLimit   (   const Float_t f=fgTimeErrLimit      ) { fTimeErrLimit    = f;   }
-
+  void SetTimeErrLimit   (   const Float_t f=fgTimeErrLimit      ) { fTimeVarLimit    = f*f;   }
+
+  void SetPheFFactorMethodLimit ( const Float_t f=fgPheFFactorMethodLimit  ) { fPheFFactorMethodLimit  = f;   }
+  
   // Charges
   void SetHiGainMeanCharge      ( const Float_t f ) { fHiGainMeanCharge      = f; }
-  void SetHiGainMeanChargeErr   ( const Float_t f ) { fHiGainMeanChargeErr   = f; }
+  void SetHiGainMeanChargeErr   ( const Float_t f ) { fHiGainMeanChargeVar   = f*f; }
   void SetHiGainChargeProb      ( const Float_t f ) { fHiGainChargeProb      = f; }
   void SetHiGainSigmaCharge     ( const Float_t f ) { fHiGainSigmaCharge     = f; }
-  void SetHiGainSigmaChargeErr  ( const Float_t f ) { fHiGainSigmaChargeErr  = f; }
+  void SetHiGainSigmaChargeErr  ( const Float_t f ) { fHiGainSigmaChargeVar  = f*f; }
 
   void SetLoGainMeanCharge      ( const Float_t f ) { fLoGainMeanCharge      = f; }
-  void SetLoGainMeanChargeErr   ( const Float_t f ) { fLoGainMeanChargeErr   = f; }
+  void SetLoGainMeanChargeErr   ( const Float_t f ) { fLoGainMeanChargeVar   = f*f; }
   void SetLoGainChargeProb      ( const Float_t f ) { fLoGainChargeProb      = f; }
   void SetLoGainSigmaCharge     ( const Float_t f ) { fLoGainSigmaCharge     = f; }
-  void SetLoGainSigmaChargeErr  ( const Float_t f ) { fLoGainSigmaChargeErr  = f; }
+  void SetLoGainSigmaChargeErr  ( const Float_t f ) { fLoGainSigmaChargeVar  = f*f; }
 
   void SetMeanCharge            ( const Float_t f );                
@@ -175,7 +181,7 @@
   void SetTotalFFactorPINDiodeMethod   ( const Float_t f)  { fTotalFFactorPINDiodeMethod = f; }
   
-  void SetTotalFFactorErrFFactorMethod   ( const Float_t f)  { fTotalFFactorErrFFactorMethod = f; }
-  void SetTotalFFactorErrBlindPixelMethod ( const Float_t f)  { fTotalFFactorErrBlindPixelMethod = f; }
-  void SetTotalFFactorErrPINDiodeMethod   ( const Float_t f)  { fTotalFFactorErrPINDiodeMethod = f; }
+  void SetTotalFFactorFFactorMethodErr   ( const Float_t f)  { fTotalFFactorFFactorMethodVar = f*f; }
+  void SetTotalFFactorBlindPixelMethodErr ( const Float_t f)  { fTotalFFactorBlindPixelMethodVar = f*f; }
+  void SetTotalFFactorPINDiodeMethodErr   ( const Float_t f)  { fTotalFFactorPINDiodeMethodVar = f*f; }
   
   // Bit Setters
@@ -195,14 +201,14 @@
   // Charges
   Float_t GetHiGainMeanCharge()          const { return fHiGainMeanCharge;      }
-  Float_t GetHiGainMeanChargeErr()       const { return fHiGainMeanChargeErr;   }
+  Float_t GetHiGainMeanChargeErr()       const;
   Float_t GetHiGainChargeProb()          const { return fHiGainChargeProb;      }    
   Float_t GetHiGainSigmaCharge()         const { return fHiGainSigmaCharge;     }
-  Float_t GetHiGainSigmaChargeErr()      const { return fHiGainSigmaChargeErr;  }
-
-  Float_t GetLoGainMeanCharge()          const { return fLoGainMeanCharge;      }
-  Float_t GetLoGainMeanChargeErr()       const { return fLoGainMeanChargeErr;   }
+  Float_t GetHiGainSigmaChargeErr()      const;
+
+  Float_t GetLoGainMeanCharge()          const;
+  Float_t GetLoGainMeanChargeErr()       const;
   Float_t GetLoGainChargeProb()          const { return fLoGainChargeProb;      }    
-  Float_t GetLoGainSigmaCharge()         const { return fLoGainSigmaCharge;     }
-  Float_t GetLoGainSigmaChargeErr()      const { return fLoGainSigmaChargeErr;  }
+  Float_t GetLoGainSigmaCharge()         const;
+  Float_t GetLoGainSigmaChargeErr()      const;
 
   Float_t GetMeanCharge()                const;
@@ -212,6 +218,6 @@
   Float_t GetSigmaChargeErr()            const;
 
-  Float_t GetRSigmaCharge()              const { return fRSigmaCharge;    }
-  Float_t GetRSigmaChargeErr()           const { return fRSigmaChargeErr; }  
+  Float_t GetRSigmaCharge()              const;
+  Float_t GetRSigmaChargeErr()           const;
 
   Float_t GetHiGainNumPickup()           const { return fHiGainNumPickup; }
@@ -222,44 +228,44 @@
   
   // Conversion Factors
-  Float_t GetConversionHiLo()      const  { return fConversionHiLo;    }
-  Float_t GetConversionHiLoErr()   const  { return fConversionHiLoErr; }
+  Float_t GetConversionHiLo()            const  { return fConversionHiLo;    }
+  Float_t GetConversionHiLoErr()         const;
 
   Float_t GetMeanConversionBlindPixelMethod()  const { return fMeanConversionBlindPixelMethod  ; }
-  Float_t GetConversionBlindPixelMethodErr()   const { return fConversionBlindPixelMethodErr ;   }
+  Float_t GetConversionBlindPixelMethodErr()   const;
   Float_t GetSigmaConversionBlindPixelMethod() const { return fSigmaConversionBlindPixelMethod ; }
 
   Float_t GetMeanConversionFFactorMethod()     const { return fMeanConversionFFactorMethod;      }
-  Float_t GetConversionFFactorMethodErr()      const { return fConversionFFactorMethodErr;       } 
+  Float_t GetConversionFFactorMethodErr()      const;
   Float_t GetSigmaConversionFFactorMethod()    const { return fSigmaConversionFFactorMethod;     }
 
   Float_t GetMeanConversionPINDiodeMethod()    const { return fMeanConversionPINDiodeMethod ;    }
-  Float_t GetConversionPINDiodeMethodErr()     const { return fConversionPINDiodeMethodErr ;     }
+  Float_t GetConversionPINDiodeMethodErr()     const;
   Float_t GetSigmaConversionPINDiodeMethod()   const { return fSigmaConversionPINDiodeMethod ;   }
 
   Float_t GetMeanConversionCombinedMethod()    const { return fMeanConversionCombinedMethod ;    }
-  Float_t GetConversionCombinedMethodErr()     const { return fConversionCombinedMethodErr ;     }
+  Float_t GetConversionCombinedMethodErr()     const;
   Float_t GetSigmaConversionCombinedMethod()   const { return fSigmaConversionCombinedMethod ;   }
 
   Float_t GetPheFFactorMethod()                const { return fPheFFactorMethod;                 }    
-  Float_t GetPheFFactorMethodErr()             const { return fPheFFactorMethodErr;              }
+  Float_t GetPheFFactorMethodErr()             const;
 
   Int_t   GetPixId()                           const { return fPixId;                            }
 
   Float_t GetPed()                             const { return fPed;                              }
-  Float_t GetPedErr()                          const { return fPedErr;                           }
+  Float_t GetPedErr()                          const;
   Float_t GetPedRms()                          const;
   Float_t GetPedRmsErr()                       const;
 
   Float_t GetTotalFFactorFFactorMethod()       const { return fTotalFFactorFFactorMethod;        }
-  Float_t GetTotalFFactorErrFFactorMethod()    const { return fTotalFFactorErrFFactorMethod;     }
+  Float_t GetTotalFFactorFFactorMethodErr()    const;
   
   Float_t GetTotalFFactorBlindPixelMethod()    const { return fTotalFFactorBlindPixelMethod;     }
-  Float_t GetTotalFFactorErrBlindPixelMethod() const { return fTotalFFactorErrBlindPixelMethod;  }
+  Float_t GetTotalFFactorBlindPixelMethodErr() const;
   
   Float_t GetTotalFFactorPINDiodeMethod()      const { return fTotalFFactorPINDiodeMethod;       }
-  Float_t GetTotalFFactorErrPINDiodeMethod()   const { return fTotalFFactorErrPINDiodeMethod;    } 
+  Float_t GetTotalFFactorPINDiodeMethodErr()   const;
 
   Float_t GetTotalFFactorCombinedMethod()      const { return fTotalFFactorCombinedMethod;       }
-  Float_t GetTotalFFactorErrCombinedMethod()   const { return fTotalFFactorErrCombinedMethod;    }
+  Float_t GetTotalFFactorCombinedMethodErr()   const;
   
   Bool_t IsExcluded()                          const;
