Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 3026)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 3027)
@@ -9,4 +9,8 @@
      - removed all TStrings and replace them by Form(..)
      - Check for nan's of all returned fit values
+
+   * mcalib/MCalibrationPix.[h,cc]
+     - reshuffled HiLoGainConversion, calculation of F-Factor method, 
+     - calculation of total F-Factor of the readout.
 
 
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h	(revision 3026)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h	(revision 3027)
@@ -14,6 +14,6 @@
   static const Float_t gkElectronicPedRms;    // The pure electronic component of the RMS
   static const Float_t gkErrElectronicPedRms; // The error of the pure electronic component of the RMS
-  static const Float_t gkFFactor;             // The laboratory F-factor
-  static const Float_t gkFFactorError;        // The laboratory F-factor Error
+  static const Float_t gkFFactor;             // The laboratory F-factor of the PMTs
+  static const Float_t gkFFactorError;        // The laboratory F-factor Error of the PMTs
   static const Float_t gkChargeLimit;         // The limit (in units of PedRMS) for acceptance of the fitted mean charge
   static const Float_t gkChargeErrLimit;      // The limit (in units of PedRMS) for acceptance of the fitted charge sigma
@@ -21,5 +21,7 @@
   static const Float_t gkTimeLimit;           // The limit (in units of FADC slices) for acceptance of the fitted time
   static const Float_t gkTimeErrLimit;        // The limit (in units of FADC slices) for acceptance of the fitted time sigma
-   
+  static const Float_t gkConvFFactorRelErrorLimit; // The limit (in units of [1]) for acceptance of the rel. error of the conversion factor with the FFactor method
+  
+  
   Int_t   fPixId;                     // the pixel Id
 
@@ -30,5 +32,6 @@
   Float_t fSigmaCharge;         // The sigma of the mean charge after the fit
   Float_t fErrSigmaCharge;      // The error of the sigma of the mean charge after the fit
-  Float_t fRSigmaSquare;        // The reduced squares of sigmas after the fit
+  Float_t fRSigmaCharge;        // The reduced squares of sigmas after the fit
+  Float_t fErrRSigmaCharge;     // The reduced squares of sigmas after the fit  
   Float_t fChargeProb;          // The probability of the fit function 
 
@@ -37,7 +40,7 @@
   Float_t fErrPedRms;           // The error of the pedestal  RMS (from MPedestalPix)  
 
-  Float_t fTime;                // The mean arrival time after the fit
-  Float_t fErrTime;             // The mean arrival time error after the fit    
-  Float_t fSigmaTime;           // The error of the mean arrival time after the fit
+  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 
 
@@ -55,18 +58,26 @@
   Float_t fPheFFactorMethodError;           // The error on the number of Phe's calculated (F-factor method)
 
-  Float_t fConversionFFactorMethod;         // The conversion factor to Phe's (F-factor method)
-  Float_t fConversionBlindPixelMethod;      // The conversion factor to Ph's (Blind Pixel method)
-  Float_t fConversionPINDiodeMethod;        // The conversion factor to Ph's (PIN Diode method)
-
-  Float_t fConversionErrorFFactorMethod;    // The error of the conversion factor to Phe's (F-factor method)
-  Float_t fConversionErrorBlindPixelMethod; // The error of the conversion factor to Ph's (Blind Pixel method)
-  Float_t fConversionErrorPINDiodeMethod;   // The error of the conversion factor to Ph's (PIN Diode method)
-
-  Float_t fConversionSigmaFFactorMethod;    // The sigma of conversion factor to Ph's (F-factor method)
-  Float_t fConversionSigmaBlindPixelMethod; // The conversion factor to Ph's (Blind Pixel method)
-  Float_t fConversionSigmaPINDiodeMethod;   // The conversion factor to Phd's (PIN Diode method)
-
+  Float_t fMeanConversionFFactorMethod;     // The conversion factor to Phe's (F-factor method)
+  Float_t fMeanConversionBlindPixelMethod;  // The conversion factor to Ph's (Blind Pixel method)
+  Float_t fMeanConversionPINDiodeMethod;    // The conversion factor to Ph's (PIN Diode method)
+
+  Float_t fErrorConversionFFactorMethod;    // The error of the conversion factor to Phe's (F-factor method)
+  Float_t fErrorConversionBlindPixelMethod; // The error of the conversion factor to Ph's (Blind Pixel method)
+  Float_t fErrorConversionPINDiodeMethod;   // The error of the conversion factor to Ph's (PIN Diode method)
+
+  Float_t fSigmaConversionFFactorMethod;    // The sigma of conversion factor to Phe's (F-factor method)
+  Float_t fSigmaConversionBlindPixelMethod; // The conversion factor to Ph's (Blind Pixel method)
+  Float_t fSigmaConversionPINDiodeMethod;   // The conversion factor to Ph's (PIN Diode method)
+
+  Float_t fTotalFFactor;                    // The F-Factor of the total readout system (Sigma(out)/mean(out)*Mean(in)/sigma(in)
+  Float_t fTotalFFactorError;               // 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 fConversionHiLoError;             // The error of the conversion factor between Hi Gain and Lo Gain  
+
+  Float_t fNumHiGainSamples;
+  Float_t fNumLoGainSamples;
+  
+  Bool_t fFactorCalculated;
   
   enum  { kHiGainSaturation,
@@ -81,4 +92,6 @@
   Bool_t CheckTimeFitValidity();
   Bool_t CheckOscillations();  
+
+  Bool_t CalcFFactorMethod();
   
 public:
@@ -93,16 +106,18 @@
 
   // Charges
-  Float_t GetCharge()              const { return fCharge;         }
-  Float_t GetErrCharge()           const { return fErrCharge;      }
-  Float_t GetChargeProb()          const { return fChargeProb;     }    
-  Float_t GetSigmaCharge()         const { return fSigmaCharge;    }
-  Float_t GetErrSigmaCharge()      const { return fErrSigmaCharge; }
-  Float_t GetRSigmaSquare()        const { return fRSigmaSquare;   }
+  Float_t GetCharge()              const { return fCharge;          }
+  Float_t GetErrCharge()           const { return fErrCharge;       }
+  Float_t GetChargeProb()          const { return fChargeProb;      }    
+  Float_t GetSigmaCharge()         const { return fSigmaCharge;     }
+  Float_t GetErrSigmaCharge()      const { return fErrSigmaCharge;  }
+  Float_t GetRSigmaCharge()        const { return fRSigmaCharge;    }
+  Float_t GetErrRSigmaCharge()     const { return fErrRSigmaCharge; }  
 
   // Times  
-  Float_t GetTime()                const { return fTime;           }
-  Float_t GetErrTime()             const { return fErrTime;        }  
-  Float_t GetSigmaTime()           const { return fSigmaTime;      }
-  Float_t GetTimeProb()            const { return fTimeProb;       }      
+  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;    }
@@ -114,18 +129,18 @@
   Float_t GetConversionHiLoError()            const  { return fConversionHiLoError;   }
 
-  Float_t GetMeanConversionBlindPixelMethod()  const { return fConversionBlindPixelMethod ; }
-  Float_t GetErrorConversionBlindPixelMethod() const { return fConversionErrorBlindPixelMethod ; }
-  Float_t GetSigmaConversionBlindPixelMethod() const { return fConversionSigmaBlindPixelMethod ; }
-
-  Float_t GetMeanConversionFFactorMethod()     const { return fConversionFFactorMethod ;       }
-  Float_t GetErrorConversionFFactorMethod()    const { return fConversionErrorFFactorMethod ;  }
-  Float_t GetSigmaConversionFFactorMethod()    const { return fConversionSigmaFFactorMethod ;  }
-
-  Float_t GetPheFFactorMethod()                const { return fPheFFactorMethod;               }
-  Float_t GetPheFFactorMethodError()           const { return fPheFFactorMethodError;          }
-
-  Float_t GetMeanConversionPINDiodeMethod()    const { return fConversionPINDiodeMethod ;      }
-  Float_t GetErrorConversionPINDiodeMethod()   const { return fConversionErrorPINDiodeMethod ; }
-  Float_t GetSigmaConversionPINDiodeMethod()   const { return fConversionSigmaPINDiodeMethod ; }
+  Float_t GetMeanConversionBlindPixelMethod()  const { return fMeanConversionBlindPixelMethod  ; }
+  Float_t GetErrorConversionBlindPixelMethod() const { return fErrorConversionBlindPixelMethod ; }
+  Float_t GetSigmaConversionBlindPixelMethod() const { return fSigmaConversionBlindPixelMethod ; }
+
+  Float_t GetMeanConversionFFactorMethod();
+  Float_t GetErrorConversionFFactorMethod();
+  Float_t GetSigmaConversionFFactorMethod();
+
+  Float_t GetMeanConversionPINDiodeMethod()    const { return fMeanConversionPINDiodeMethod ;  }
+  Float_t GetErrorConversionPINDiodeMethod()   const { return fErrorConversionPINDiodeMethod ; }
+  Float_t GetSigmaConversionPINDiodeMethod()   const { return fSigmaConversionPINDiodeMethod ; }
+
+  Float_t GetPheFFactorMethod();    
+  Float_t GetPheFFactorMethodError();
 
   Int_t   GetPixId()                           const  { return fPixId;   }
@@ -134,4 +149,7 @@
   Float_t GetPedRms()                          const { return fPedRms; }
 
+  Float_t GetTotalFFactor();
+  Float_t GetTotalFFactorError();
+  
   Bool_t IsExcluded()              const;
   Bool_t IsChargeFitValid()        const;
@@ -139,9 +157,9 @@
   Bool_t IsFitted()                const;
   Bool_t IsBlindPixelMethodValid() const;
-  Bool_t IsFFactorMethodValid()    const;
   Bool_t IsPINDiodeMethodValid()   const;
+  Bool_t IsFFactorMethodValid();
 
   // Setter
-  void SetPedestal(Float_t ped, Float_t pedrms);
+  void SetPedestal(Float_t ped, Float_t pedrms, Float_t higainsamp, Float_t logainsamp);
   void SetConversionHiLo(Float_t c)      { fConversionHiLo      = c;    }
   void SetConversionHiLoError(Float_t e)  { fConversionHiLoError = e;    }
