Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 3454)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 3455)
@@ -18,4 +18,14 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2004/03/10: Markus Gaug
+
+   * mcalib/MCalibrationChargeCalc.cc
+   * mcalib/MCalibrationChargePix.[h,cc]
+   * mcalib/MCalibrationChargeCam.[h,cc]
+     - calculation of conversion factor with F-Factor method from 
+       same mean number of photons, derived from weighted mean number 
+       of photo-electrons from inner and outer pixels, respectively
+
+
  2004/03/10: Thomas Bretz
 
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 3454)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 3455)
@@ -522,4 +522,23 @@
       avouterpix->CalcFFactorMethod();
 
+  // 
+  // F-Factor calibration
+  //
+  if (fCam->CalcMeanFluxPhotonsFFactorMethod())
+  {
+    fCam->ApplyFFactorCalibration();
+    fCam->SetFFactorMethodValid(kTRUE);
+  }
+  else
+    {
+      *fLog << warn << "Could not calculate the flux of photo-electrons from the F-Factor method, " << endl;
+      fCam->SetFFactorMethodValid(kFALSE);
+    }
+  
+
+
+  // 
+  // Blind Pixel calibration
+  //
   if (!fBlindPixel->CheckChargeFitValidity())
   {
@@ -543,4 +562,7 @@
   }
 
+  // 
+  // PIN Diode calibration
+  //
   if (!fPINDiode->CheckChargeFitValidity() || !fPINDiode->CheckTimeFitValidity())
   {
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 3454)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 3455)
@@ -138,9 +138,11 @@
 #include "MCalibrationChargePINDiode.h"
 
-
 ClassImp(MCalibrationChargeCam);
 
 using namespace std;
 
+const Float_t MCalibrationChargeCam::gkAverageQE                = 0.18;     
+const Float_t MCalibrationChargeCam::gkAverageQEErr             = 0.02;  
+const Float_t MCalibrationChargeCam::fgConvFFactorRelErrLimit   = 0.25;
 // --------------------------------------------------------------------------
 //
@@ -171,4 +173,7 @@
 
     Clear();
+
+    SetAverageQE();
+    SetConvFFactorRelErrLimit();
 }
 
@@ -261,10 +266,20 @@
   fAverageOuterBadPix->Clear();
 
-  fNumExcludedPixels                 = 0;
+  fNumExcludedPixels            = 0;
+  fMeanFluxPhesInnerPixel       = 0.;
+  fMeanFluxPhesInnerPixelErr    = 0.;
+  fMeanFluxPhesOuterPixel       = 0.;
+  fMeanFluxPhesOuterPixelErr    = 0.;
 
   CLRBIT(fFlags,kBlindPixelMethodValid);
+  CLRBIT(fFlags,kFFactorMethodValid);
   CLRBIT(fFlags,kPINDiodeMethodValid);
 
   return;
+}
+
+void MCalibrationChargeCam::SetFFactorMethodValid(const Bool_t b)
+{
+    b ? SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid); 
 }
 
@@ -567,90 +582,126 @@
       break;
     case 9:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsFFactorMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsFFactorMethodValid())
         return kFALSE;
       val = (*this)[idx].GetPheFFactorMethod();
       break;
     case 10:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsFFactorMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsFFactorMethodValid())
         return kFALSE;
       val = (*this)[idx].GetPheFFactorMethodErr();
       break;
     case 11:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsFFactorMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsFFactorMethodValid())
         return kFALSE;
       val = (*this)[idx].GetMeanConversionFFactorMethod();
       break;
     case 12:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsFFactorMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsFFactorMethodValid())
         return kFALSE;
       val = (*this)[idx].GetConversionFFactorMethodErr();
       break;
     case 13:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsFFactorMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsFFactorMethodValid())
         return kFALSE;
       val = (*this)[idx].GetTotalFFactorFFactorMethod();
       break;
     case 14:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsFFactorMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsFFactorMethodValid())
         return kFALSE;
       val = (*this)[idx].GetTotalFFactorErrFFactorMethod();
       break;
     case 15:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsBlindPixelMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsBlindPixelMethodValid())
         return kFALSE;
       val = fBlindPixel->GetMeanFluxInsidePlexiglass()*area;
       break;
     case 16:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsBlindPixelMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsBlindPixelMethodValid())
         return kFALSE;
       val = fBlindPixel->GetMeanFluxErrInsidePlexiglass()*area;
       break;
     case 17:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsBlindPixelMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsBlindPixelMethodValid())
         return kFALSE;
       val = (*this)[idx].GetMeanConversionBlindPixelMethod();
       break;
     case 18:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsBlindPixelMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsBlindPixelMethodValid())
         return kFALSE;
       val = (*this)[idx].GetConversionBlindPixelMethodErr();
       break;
     case 19:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsBlindPixelMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsBlindPixelMethodValid())
         return kFALSE;
       val = (*this)[idx].GetTotalFFactorBlindPixelMethod();
       break;
     case 20:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsBlindPixelMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsBlindPixelMethodValid())
         return kFALSE;
       val = (*this)[idx].GetTotalFFactorErrBlindPixelMethod();
       break;
     case 21:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsPINDiodeMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsPINDiodeMethodValid())
         return kFALSE;
       val = fPINDiode->GetMeanFluxOutsidePlexiglass()*area;
       break;
     case 22:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsPINDiodeMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsPINDiodeMethodValid())
         return kFALSE;
       val = fPINDiode->GetMeanFluxErrOutsidePlexiglass()*area;
       break;
     case 23:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsPINDiodeMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsPINDiodeMethodValid())
         return kFALSE;
       val = (*this)[idx].GetMeanConversionPINDiodeMethod();
       break;
     case 24:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsPINDiodeMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsPINDiodeMethodValid())
         return kFALSE;
       val = (*this)[idx].GetConversionPINDiodeMethodErr();
       break;
     case 25:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsPINDiodeMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsPINDiodeMethodValid())
         return kFALSE;
       val = (*this)[idx].GetTotalFFactorPINDiodeMethod();
       break;
     case 26:
-      if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsPINDiodeMethodValid())
+      if ((*this)[idx].IsExcluded() 
+          || !(*fBadPixels)[idx].IsCalibrationSignalOK() 
+          || !(*this)[idx].IsPINDiodeMethodValid())
         return kFALSE;
       val = (*this)[idx].GetTotalFFactorErrPINDiodeMethod();
@@ -782,4 +833,186 @@
     (*this)[idx].DrawClone();
 }
+
+//
+// Calculate the weighted mean of the phe's of all inner and outer pixels, respectively.
+// Bad pixels are excluded from the calculation.
+//
+Bool_t MCalibrationChargeCam::CalcMeanFluxPhotonsFFactorMethod()
+{
+
+  const Float_t avQERelErrSquare             = fAverageQEErr * fAverageQEErr
+                                            / (fAverageQE    * fAverageQE ); 
+
+  Float_t sumweightsinner = 0.;
+  Float_t sumphesinner    = 0.;
+  Float_t sumweightsouter = 0.;
+  Float_t sumphesouter    = 0.;
+      
+  TIter Next(fPixels);
+  MCalibrationChargePix *pix;
+  while ((pix=(MCalibrationChargePix*)Next()))
+    {
+
+      if (!pix->IsFFactorMethodValid())
+        continue;
+
+      const Int_t idx = pix->GetPixId();
+
+      if(!(*fBadPixels)[idx].IsCalibrationResultOK())
+        continue;
+      
+      const Float_t nphe    = pix->GetPheFFactorMethod();
+      const Float_t npheerr = pix->GetPheFFactorMethodErr();
+      const Float_t ratio   = fGeomCam->GetPixRatio(idx);
+
+      if (npheerr > 0.)
+        {
+          // 
+          // first the inner pixels:
+          //
+          if (ratio == 1.)
+            {
+              const Float_t weight = 1./npheerr/npheerr;
+              sumweightsinner += weight;
+              sumphesinner    += weight*nphe;
+            }
+          else
+            {
+              // 
+              // now the outers
+              //
+              const Float_t weight = 1./npheerr/npheerr;
+              sumweightsouter += weight;
+              sumphesouter    += weight*nphe;
+            }
+        } /* if npheerr != 0 */
+    } /* while ((pix=(MCalibrationChargePix*)Next())) */
+  
+  if (sumweightsinner <= 0. || sumphesinner <= 0.)
+    {
+      *fLog << warn << " Mean number of phe's from inner pixels cannot be calculated: "
+            << " Sum of weights: " << sumweightsinner 
+            << " Sum of weighted phes: " << sumphesinner << endl;
+      return kFALSE;
+    }
+  else
+    {
+      fMeanFluxPhesInnerPixel    = sumphesinner/sumweightsinner;
+      fMeanFluxPhesInnerPixelErr = TMath::Sqrt(1./sumweightsinner);
+
+    }
+
+  if (sumweightsouter <= 0. || sumphesouter <= 0.)
+    {
+      *fLog << warn << " Mean number of phe's from outer pixels cannot be calculated: "
+            << " Sum of weights or sum of weighted phes is 0. " << endl;
+    }
+  else
+    {
+      fMeanFluxPhesOuterPixel    = sumphesouter/sumweightsouter;
+      fMeanFluxPhesOuterPixelErr = TMath::Sqrt(1./sumweightsouter);
+    }
+
+
+  const Float_t meanFluxPhotonsRelErrSquare = fMeanFluxPhesInnerPixelErr * fMeanFluxPhesInnerPixelErr 
+                                           / (fMeanFluxPhesInnerPixel    * fMeanFluxPhesInnerPixel);
+
+  fMeanFluxPhotonsInnerPixel    =  fMeanFluxPhesInnerPixel/fAverageQE;
+  fMeanFluxPhotonsInnerPixelErr =  TMath::Sqrt(meanFluxPhotonsRelErrSquare + avQERelErrSquare)
+                                 * fMeanFluxPhotonsInnerPixel;
+
+  fMeanFluxPhotonsOuterPixel    = 4.*fMeanFluxPhotonsInnerPixel;
+  fMeanFluxPhotonsOuterPixelErr = 4.*fMeanFluxPhotonsInnerPixelErr;  
+
+  *fLog << inf << " Mean number of photo-electrons from inner pixels (F-Factor Method): "
+        << fMeanFluxPhesInnerPixel << " +- " << fMeanFluxPhesInnerPixelErr << endl;
+
+  *fLog << inf << " Mean number of photons from inner pixels (F-Factor Method): "
+        << fMeanFluxPhotonsInnerPixel << " +- " << fMeanFluxPhotonsInnerPixelErr << endl;
+
+  
+
+  return kTRUE;
+}
+
+void MCalibrationChargeCam::ApplyFFactorCalibration()
+{
+
+  const Float_t meanphotRelErrSquare        = fMeanFluxPhotonsInnerPixelErr * fMeanFluxPhotonsInnerPixelErr
+                                           /( fMeanFluxPhotonsInnerPixel    * fMeanFluxPhotonsInnerPixel );
+
+  TIter Next(fPixels);
+  MCalibrationChargePix *pix;
+  while ((pix=(MCalibrationChargePix*)Next()))
+    {
+
+      if (!pix->IsFFactorMethodValid())
+        continue;
+
+      const Int_t idx = pix->GetPixId();
+
+      if(!(*fBadPixels)[idx].IsCalibrationResultOK())
+        continue;
+
+      const Float_t ratio   = fGeomCam->GetPixRatio(idx);
+      //
+      // Calculate the conversion factor between PHOTONS and FADC counts
+      //
+      // Nphot = Nphe / avQE
+      // conv  = Nphot / FADC counts
+      //
+      Float_t conv;
+      
+      if (ratio == 1.)
+        conv               = fMeanFluxPhotonsInnerPixel / pix->GetMeanCharge(); 
+      else
+        conv               = fMeanFluxPhotonsOuterPixel / pix->GetMeanCharge(); 
+
+      if (conv <= 0.)
+        {
+          pix->SetFFactorMethodValid(kFALSE);
+          continue;
+        }
+      
+      const Float_t chargeRelErrSquare       =   pix->GetMeanChargeErr() * pix->GetMeanChargeErr()
+                                             / ( pix->GetMeanCharge()    * pix->GetMeanCharge());
+      const Float_t rsigmaChargeRelErrSquare =   pix->GetRSigmaChargeErr() *  pix->GetRSigmaChargeErr()
+  	                                      / (pix->GetRSigmaCharge()    * pix->GetRSigmaCharge()) ;
+
+      const Float_t convrelerr = TMath::Sqrt(meanphotRelErrSquare + chargeRelErrSquare);
+
+      if (convrelerr > fConvFFactorRelErrLimit)
+        {
+          *fLog << warn << GetDescriptor() << ": Conversion Factor F-Factor Method Rel. Error: " 
+                << convrelerr << " above limit of: " << fConvFFactorRelErrLimit 
+                << " in pixel: " << idx << endl;
+          pix->SetFFactorMethodValid(kFALSE);
+          continue;
+        }
+      
+      //
+      // Calculate the Total F-Factor of the camera (in photons)
+      //
+      const Float_t totalFFactor  =  (pix->GetRSigmaCharge()/pix->GetMeanCharge())
+                                    *TMath::Sqrt(fMeanFluxPhotonsInnerPixel);
+      
+      //
+      // Calculate the error of the Total F-Factor of the camera ( in photons )
+      //
+      const Float_t totalFFactorErr = TMath::Sqrt(  rsigmaChargeRelErrSquare
+                                    + chargeRelErrSquare
+                                    + meanphotRelErrSquare );
+
+      pix->SetConversionFFactorMethod(conv,
+                                      convrelerr*conv,
+                                      totalFFactor*TMath::Sqrt(conv));
+
+      pix->SetTotalFFactorFFactorMethod(   totalFFactor   );
+      pix->SetTotalFFactorErrFFactorMethod(totalFFactorErr);      
+      pix->SetFFactorMethodValid();
+    }
+}
+
+
 
 void MCalibrationChargeCam::ApplyBlindPixelCalibration()
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h	(revision 3454)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.h	(revision 3455)
@@ -22,4 +22,14 @@
 private:
   
+  static const Float_t gkAverageQE;          // The average quantum efficieny agreed on for the first analysis
+  static const Float_t gkAverageQEErr;       // The error of average quantum efficieny 
+  
+  static const Float_t fgConvFFactorRelErrLimit; // The limit for acceptance of the rel. error of the conversion factor with the FFactor method
+
+  Float_t fAverageQE;                       // The average quantum efficieny (see Class description)
+  Float_t fAverageQEErr;                    // The error of the average quantum efficieny (see Class description)
+  
+  Float_t fConvFFactorRelErrLimit;          // The limit for acceptance of the rel. error of the conversion factor with the FFactor method
+
   Int_t fNumPixels;
   TClonesArray *fPixels;                         //-> Array of MCalibrationPix with fit results
@@ -45,5 +55,15 @@
   Byte_t  fFlags;
 
-  enum  { kBlindPixelMethodValid, kPINDiodeMethodValid, kCombinedMethodValid };
+  enum  { kFFactorMethodValid, kBlindPixelMethodValid, kPINDiodeMethodValid, kCombinedMethodValid };
+
+  Float_t fMeanFluxPhesInnerPixel;        //  The mean number of photo-electrons in an INNER PIXEL
+  Float_t fMeanFluxPhesInnerPixelErr;     //  The uncertainty about the number of photo-electrons INNER PIXEL  
+  Float_t fMeanFluxPhesOuterPixel;        //  The mean number of photo-electrons in an INNER PIXEL
+  Float_t fMeanFluxPhesOuterPixelErr;     //  The uncertainty about the number of photo-electrons INNER PIXEL  
+
+  Float_t fMeanFluxPhotonsInnerPixel;        //  The mean number of photo-electrons in an INNER PIXEL
+  Float_t fMeanFluxPhotonsInnerPixelErr;     //  The uncertainty about the number of photo-electrons INNER PIXEL  
+  Float_t fMeanFluxPhotonsOuterPixel;        //  The mean number of photo-electrons in an INNER PIXEL
+  Float_t fMeanFluxPhotonsOuterPixelErr;     //  The uncertainty about the number of photo-electrons INNER PIXEL  
   
 public:
@@ -56,4 +76,8 @@
 
   // Setters   
+  void SetAverageQE(          const Float_t qe= gkAverageQE, 
+			      const Float_t err=gkAverageQEErr)         { fAverageQE    = qe;           
+			                                                  fAverageQEErr = err;         }
+  void SetConvFFactorRelErrLimit( const Float_t f=fgConvFFactorRelErrLimit ) { fConvFFactorRelErrLimit = f; }
   void SetNumPixelsExcluded(  const UInt_t n )            {  fNumExcludedPixels = n; }
   void SetGeomCam(  const MGeomCam *geom)                 {  fGeomCam = geom;        }
@@ -63,16 +87,26 @@
   void SetBlindPixel( const MCalibrationChargeBlindPix *b ) {  fBlindPixel = b;      }
 
-  // Setters only for MC!!
+  void SetFFactorMethodValid(    const Bool_t b = kTRUE );
   void SetBlindPixelMethodValid( const Bool_t b = kTRUE );
   void SetPINDiodeMethodValid(   const Bool_t b = kTRUE );  
 
   // Getters
-  Int_t  GetSize()               const;
-  UInt_t GetNumPixels()          const { return fNumPixels; }
+  Int_t   GetSize()               const;
+  UInt_t  GetNumPixels()          const { return fNumPixels; }
 
-  Bool_t GetConversionFactorFFactor(    Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
-  Bool_t GetConversionFactorBlindPixel( Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
-  Bool_t GetConversionFactorPINDiode(   Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
-  Bool_t GetConversionFactorCombined(   Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
+  Bool_t  GetConversionFactorFFactor(    Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
+  Bool_t  GetConversionFactorBlindPixel( Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
+  Bool_t  GetConversionFactorPINDiode(   Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
+  Bool_t  GetConversionFactorCombined(   Int_t ipx, Float_t &mean, Float_t &err, Float_t &sigma );
+
+  Float_t GetMeanFluxPhesInnerPixel()     const { return fMeanFluxPhesInnerPixel;     }
+  Float_t GetMeanFluxPhesInnerPixelErr()  const { return fMeanFluxPhesInnerPixelErr;  }
+  Float_t GetMeanFluxPhesOuterPixel()     const { return fMeanFluxPhesOuterPixel;     }
+  Float_t GetMeanFluxPhesOuterPixelErr()  const { return fMeanFluxPhesOuterPixelErr;  }
+
+  Float_t GetMeanFluxPhotonsInnerPixel()     const { return fMeanFluxPhotonsInnerPixel;     }
+  Float_t GetMeanFluxPhotonsInnerPixelErr()  const { return fMeanFluxPhotonsInnerPixelErr;  }
+  Float_t GetMeanFluxPhotonsOuterPixel()     const { return fMeanFluxPhotonsOuterPixel;     }
+  Float_t GetMeanFluxPhotonsOuterPixelErr()  const { return fMeanFluxPhotonsOuterPixelErr;  }
 
   Bool_t IsBlindPixelMethodValid()   const;
@@ -105,6 +139,9 @@
   Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
 
+  Bool_t CalcMeanFluxPhotonsFFactorMethod();  
+
   void   ApplyPINDiodeCalibration();
   void   ApplyBlindPixelCalibration();
+  void   ApplyFFactorCalibration();
 
   ClassDef(MCalibrationChargeCam, 1)	// Container for calibration information of the camera
@@ -112,7 +149,2 @@
 
 #endif
-
-
-
-
-
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc	(revision 3454)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc	(revision 3455)
@@ -101,6 +101,4 @@
 const Float_t MCalibrationChargePix::gkFFactorErr               = 0.02;
 
-const Float_t MCalibrationChargePix::gkAverageQE                = 0.18;     
-const Float_t MCalibrationChargePix::gkAverageQEErr             = 0.02;  
 const Float_t MCalibrationChargePix::gkConversionHiLo           = 10.;
 const Float_t MCalibrationChargePix::gkConversionHiLoErr        = 2.5;
@@ -111,5 +109,4 @@
 const Float_t MCalibrationChargePix::fgTimeLimit                = 1.5;
 const Float_t MCalibrationChargePix::fgTimeErrLimit             = 3.;
-const Float_t MCalibrationChargePix::fgConvFFactorRelErrLimit   = 0.25;
 // --------------------------------------------------------------------------
 //
@@ -133,5 +130,4 @@
   SetConversionHiLoErr();
 
-  SetAverageQE();
   SetChargeLimit();
   SetChargeErrLimit();  
@@ -140,5 +136,4 @@
   SetTimeLimit();
   SetTimeErrLimit();
-  SetConvFFactorRelErrLimit();
 }
 
@@ -565,5 +560,4 @@
       bad->SetUnsuitableRun();
     }
-  
 }
 
@@ -661,6 +655,9 @@
 
   if (fRSigmaCharge < 0.)
+    {
+      SetFFactorMethodValid(kFALSE);
       return kFALSE;
-
+    }
+  
   //
   // Square all variables in order to avoid applications of square root
@@ -677,12 +674,4 @@
   const Float_t ffactorsquareRelErrSquare = 4.*gkFFactorErr * gkFFactorErr / ffactorsquare;
 
-  const Float_t avQERelErrSquare          =    fAverageQEErr * fAverageQEErr / fAverageQE / fAverageQE; 
-
-  const Float_t avQEFFactor               = TMath::Sqrt( ( 1. - fAverageQE ) / fAverageQE  );
-  const Float_t avQEFFactorErr            = 1./ ( 2. * avQEFFactor ) * fAverageQEErr 
-                                            / ( fAverageQE * fAverageQE );
-
-  const Float_t avQEFFactorRelErrSquare  = avQEFFactorErr  * avQEFFactorErr 
-                                           / ( avQEFFactor * avQEFFactor) ;
 
   const Float_t rsigmaSquare              =     fRSigmaCharge    * fRSigmaCharge;
@@ -697,6 +686,9 @@
 
   if (fPheFFactorMethod < 0.)
+    {
+      SetFFactorMethodValid(kFALSE);
       return kFALSE;
-
+    }
+  
   //
   // Calculate the Error of Nphe
@@ -707,53 +699,10 @@
   fPheFFactorMethodErr                 =  TMath::Sqrt(pheFFactorRelErrSquare) * fPheFFactorMethod;
 
-  //
-  // Calculate the conversion factor between PHOTONS and FADC counts
-  //
-  // Nphot = Nphe / avQE
-  // conv  = Nphot / FADC counts
-  //
-  fMeanConversionFFactorMethod         =  fPheFFactorMethod / fAverageQE / GetMeanCharge();
-
-
-  //
-  // Calculate the error of the mean conversion factor between PHOTONS and FADC counts
-  //
-  const Float_t convRelErrSquare     =  ( pheFFactorRelErrSquare + chargeRelErrSquare + avQERelErrSquare);
-
-  if (convRelErrSquare < 0.)
-      return kFALSE;
-
-
-  const Float_t convRelErr           =  TMath::Sqrt(convRelErrSquare);
-  fConversionFFactorMethodErr        = convRelErr * fMeanConversionFFactorMethod;
-  
-  if (convRelErr < fConvFFactorRelErrLimit)
-    SetFFactorMethodValid();
-
-  //
-  // Calculate the Total F-Factor of the camera (in photons)
-  //
-  fTotalFFactorFFactorMethod =  (fRSigmaCharge/GetMeanCharge())*TMath::Sqrt(fPheFFactorMethod);
-  fTotalFFactorFFactorMethod *=  avQEFFactor;
-      
-  //
-  // Calculate the error of the Total F-Factor of the camera ( in photons )
-  //
-  const Float_t rsigmaChargeRelErrSquare =    fRSigmaChargeErr * fRSigmaChargeErr 
-	                                   / (fRSigmaCharge    * fRSigmaCharge) ;
-      
-  fTotalFFactorErrFFactorMethod = TMath::Sqrt(  rsigmaChargeRelErrSquare
-						+ chargeRelErrSquare
-						+ pheFFactorRelErrSquare
-						+ avQEFFactorRelErrSquare  );
-  fTotalFFactorErrFFactorMethod *= fTotalFFactorFFactorMethod;
-
-  //
-  // Calculate the sigma of the conversion from FADC counts to photons
-  //
-  fSigmaConversionFFactorMethod = GetTotalFFactorFFactorMethod()*TMath::Sqrt(fMeanConversionFFactorMethod);
+  SetFFactorMethodValid(kTRUE);
 
   return kTRUE;
 }
+
+
 
 void MCalibrationChargePix::ApplyLoGainConversion()
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h	(revision 3454)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h	(revision 3455)
@@ -11,7 +11,4 @@
 private:
 
-  static const Float_t gkAverageQE;              // The average quantum efficieny agreed on for the first analysis
-  static const Float_t gkAverageQEErr;           // The error of average quantum efficieny 
-  
   static const Float_t gkConversionHiLo;         // The default conversion factor HI gain - Lo Gain
   static const Float_t gkConversionHiLoErr;      // The error of the default conversion factor
@@ -28,5 +25,4 @@
   static const Float_t fgTimeLimit;              // The limit (in units of FADC slices) for acceptance of the fitted time
   static const Float_t fgTimeErrLimit;           // The limit (in units of FADC slices) for acceptance of the fitted time sigma
-  static const Float_t fgConvFFactorRelErrLimit; // The limit for acceptance of the rel. error of the conversion factor with the FFactor method
 
   Float_t fChargeLimit;                     // The limit (in units of PedRMS) for acceptance of the fitted mean charge
@@ -36,5 +32,4 @@
   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 fConvFFactorRelErrLimit;          // The limit for acceptance of the rel. error of the conversion factor with the FFactor method
 
   Float_t fElectronicPedRms;                // The pure electronic component of the RMS
@@ -45,7 +40,4 @@
   UInt_t  fFlags;                           // Flag for the set bits
  
-  Float_t fAverageQE;                       // The average quantum efficieny (see Class description)
-  Float_t fAverageQEErr;                    // The error of the average quantum efficieny (see Class description)
-  
   Float_t fHiGainMeanCharge;                // The mean reduced charge after the fit
   Float_t fHiGainMeanChargeErr;             // The error of reduced mean charge after the fit
@@ -139,7 +131,4 @@
   void SetConversionHiLo(     const Float_t c = gkConversionHiLo)       { fConversionHiLo      = c;    }
   void SetConversionHiLoErr(  const Float_t e = gkConversionHiLoErr)    { fConversionHiLoErr   = e;    }
-  void SetAverageQE(          const Float_t qe= gkAverageQE, 
-			      const Float_t err=gkAverageQEErr)         { fAverageQE    = qe;           
-			                                                  fAverageQEErr = err;         }
   void SetChargeLimit    (   const Float_t f=fgChargeLimit       ) { fChargeLimit       = f; }
   void SetChargeErrLimit (   const Float_t f=fgChargeErrLimit    ) { fChargeErrLimit    = f; }
@@ -148,5 +137,4 @@
   void SetTimeLimit      (   const Float_t f=fgTimeLimit         ) { fTimeLimit       = f;   }
   void SetTimeErrLimit   (   const Float_t f=fgTimeErrLimit      ) { fTimeErrLimit    = f;   }
-  void SetConvFFactorRelErrLimit( const Float_t f=fgConvFFactorRelErrLimit ) { fConvFFactorRelErrLimit = f; }
 
   // Charges
@@ -177,5 +165,5 @@
   void SetNumLoGainSamples      ( const Float_t f ) { fNumLoGainSamples      = f; }
 
-  // Setters for MC
+  // Conversion Factors
   void SetConversionFFactorMethod   ( Float_t c, Float_t err, Float_t sig );
   void SetConversionBlindPixelMethod( Float_t c, Float_t err, Float_t sig );
@@ -183,4 +171,12 @@
   void SetConversionCombinedMethod  ( Float_t c, Float_t err, Float_t sig );
 
+  void SetTotalFFactorFFactorMethod   ( const Float_t f)  { fTotalFFactorFFactorMethod = f; }
+  void SetTotalFFactorBlindPixelMethod ( const Float_t f)  { fTotalFFactorBlindPixelMethod = f; }
+  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; }
+  
   // Bit Setters
   void SetHiGainSaturation    (  const Bool_t b = kTRUE );
