Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 2724)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 2725)
@@ -4,4 +4,18 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2003/12/19: Markus Gaug, Michele Doro
+
+   * manalysis/MExtractSignal.[h,cc]
+   * manalysis/MCalibrate.[h,cc]
+   * manalysis/MCalibrationCalc.[h,cc]
+   * manalysis/MCalibrationPix.[h,cc]
+
+     - Treatment of the conversion factors between HI Gain and Lo Gain
+       is now done in the MCalibrationPix. 
+
+       MExtractSignal does not convert anymore, but MCalibrate searches 
+       the conversion factor from MCalibrationPix.
+       This allows for different conversion factors for every pixel.
 
  2003/12/18: Abelardo Moralejo
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrate.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrate.cc	(revision 2724)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrate.cc	(revision 2725)
@@ -44,4 +44,5 @@
 
 #include "MCalibrate.h"
+#include "MCalibrationConfig.h"
 
 #include "MLog.h"
@@ -137,26 +138,34 @@
 	MCalibrationPix &pix = (*fCalibrations)[pixid];
 
+
 	if (pix.IsBlindPixelMethodValid())
 	{
 	    MExtractedSignalPix &sig =  (*fSignals)[pixid];
 
-	    Bool_t logain = sig.IsLoGainUsed();
-	
 	    Float_t signal;
-	    if (logain)
-		signal = sig.GetExtractedSignalLoGain();
+	    Float_t signalErr = 0.;
+
+	    if (sig.IsLoGainUsed())
+              {
+		signal    = sig.GetExtractedSignalLoGain()*pix.GetConversionHiLo();
+                signalErr = signal*pix.GetConversionHiLoError();
+              }
 	    else
-		signal = sig.GetExtractedSignalHiGain();
-	    
-	    
+              {
+                signal = sig.GetExtractedSignalHiGain();
+              }
+            
 	    //      Float_t calibrationConvertionFactor = pix.GetMeanConversionFFactorMethod();
-	    Float_t calibrationConversionFactor = pix.GetMeanConversionBlindPixelMethod();
+	    Float_t calibrationConversionFactor      = pix.GetMeanConversionBlindPixelMethod();
 	    Float_t calibrationConversionFactorError = pix.GetErrorConversionBlindPixelMethod();
 	    
 
-	    Float_t nphot = signal*calibrationConversionFactor;
-	    Float_t nphoterr = signal*calibrationConversionFactorError;;
-	    
-	    fCerPhotEvt->AddPixel(pixid, nphot, nphoterr);
+	    Float_t nphot    = signal*calibrationConversionFactor;
+
+	    Float_t nphotErr = signal*calibrationConversionFactorError*signal*calibrationConversionFactorError;
+	    nphotErr += signalErr*signalErr*calibrationConversionFactor*calibrationConversionFactor;
+            nphotErr  = TMath::Sqrt(nphotErr);
+
+	    fCerPhotEvt->AddPixel(pixid, nphot, nphotErr);
 	}
 	else
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrate.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrate.h	(revision 2724)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrate.h	(revision 2725)
@@ -30,7 +30,9 @@
     MExtractedSignalCam *fSignals;      // Integrated charge in FADCs counts
     MCerPhotEvt         *fCerPhotEvt; // Cerenkov Photon Event used for calculation
- 
-  Int_t PreProcess(MParList *pList);
-  Int_t Process();
+
+    Float_t fConversionHiLo;
+    
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
 
 public:
@@ -38,4 +40,6 @@
     MCalibrate(const char *name=NULL, const char *title=NULL);
 
+    void SetConversionHiLo(Float_t conv)         { fConversionHiLo = conv; }
+    
     ClassDef(MCalibrate, 0)   // Task to calculate cerenkov photons using calibration constants
 };
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.cc	(revision 2724)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.cc	(revision 2725)
@@ -124,4 +124,5 @@
     SETBIT(fFlags, kUseBlindPixelFit);
     SETBIT(fFlags, kUsePinDiodeFit);
+
 }
 
@@ -271,5 +272,5 @@
     // FIXME: In the future need a much more sophisticated one!!!
     //
-    
+
     while (pixel.Next())
       {
@@ -308,6 +309,4 @@
 	Float_t sumhi  = sig.GetExtractedSignalHiGain();
 	Float_t sumlo  = sig.GetExtractedSignalLoGain();
-	Bool_t  logain = sig.IsLoGainUsed();
-
 	Float_t mtime  = sig.GetMeanArrivalTime();
 
@@ -356,5 +355,5 @@
 		    << pixid << " signal = " << sumhi  << " event Nr: " << fEvents << endl;
 
-	    if (logain)
+	    if (sig.IsLoGainUsed())
 	      {
 		
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.h	(revision 2724)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationCalc.h	(revision 2725)
@@ -46,5 +46,6 @@
   Byte_t fFlags;                           // Flag for the fits used
    
-
+  Float_t fConversionHiLo;
+  
   enum  { kUseTimeFits, kUseBlindPixelFit, kUsePinDiodeFit };
 
@@ -74,4 +75,6 @@
 
   void SetPulserColor(PulserColor_t color)    { fColor = color; }
+
+  void SetConversionHiLo(Float_t conv)         { fConversionHiLo = conv; }
   
   ClassDef(MCalibrationCalc, 1)   // Task to fill the Calibration Containers from raw data
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc	(revision 2724)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.cc	(revision 2725)
@@ -83,4 +83,11 @@
   fTitle = title ? title : "Container of the MHCalibrationPixels and the fit results";
 
+  //
+  // At the moment, we don't have a database, yet, 
+  // so we get it from the configuration file
+  //
+  fConversionHiLo      = gkConversionHiLo;
+  fConversionHiLoError = gkConversionHiLoError;  
+
   fHist = new MHCalibrationPixel("MHCalibrationPixel","Calibration Histograms Pixel ");
 
@@ -124,5 +131,5 @@
 // 8) Calculate the errors of the F-Factor method
 //
-// The fit is declared as valid, if:
+// The fit is declared valid (fFitValid = kTRUE), if:
 //
 // 1) Pixel has a fitted charge greater than 3*PedRMS
@@ -131,9 +138,9 @@
 // 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 mean arrival time is at least 1.0 slices from the used edge slices 
 // 
-// The F-Factor method is declared as valid, if:
-//
-// 1) Pixel is FitValid
+// The conversion factor after the F-Factor method is declared valid, if:
+//
+// 1) fFitValid is kTRUE
 // 2) Conversion Factor is bigger than 0.
 // 3) The error of the conversion factor is smaller than 10%
@@ -142,7 +149,14 @@
 {
 
+  //
+  // 1) Return if the charge distribution is already succesfully fitted  
+  //
   if (fHist->IsFitOK())
     return kTRUE;
 
+  //
+  // 2) Set a lower Fit range according to 1.5 Pedestal RMS in order to avoid 
+  //    possible remaining cosmics to spoil the fit.
+  //
   if (fPed && fPedRms)
     fHist->SetLowerFitRange(1.5*fPedRms);
@@ -150,12 +164,21 @@
     *fLog << warn << "Cannot set lower fit range: Pedestals not available" << endl;
 
+  //
+  // 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
+  //
   if (fHist->UseLoGain())
     {
 
       SetHiGainSaturation();
-
+      
+      //
+      // 4) Fit the Lo Gain histograms with a Gaussian
+      //
       if(!fHist->FitChargeLoGain())
 	{
 	  *fLog << warn << "Could not fit Lo Gain charges of pixel " << fPixId << endl;
+          //          
+          // 5) In case of failure print out the fit results
+          //
 	  fHist->PrintChargeFitResult();
 	}
@@ -163,7 +186,13 @@
   else 
     {
+      //
+      // 4) Fit the Hi Gain histograms with a Gaussian
+      //
       if(!fHist->FitChargeHiGain())
 	{
 	  *fLog << warn << "Could not fit Hi Gain charges of pixel " << fPixId << endl;
+          //          
+          // 5) In case of failure print out the fit results
+          //
 	  fHist->PrintChargeFitResult();
 	}
@@ -171,4 +200,7 @@
   
 
+  //
+  // 6) Retrieve the results and store them in this class
+  //
   fCharge         = fHist->GetChargeMean();
   fErrCharge      = fHist->GetChargeMeanErr(); 
@@ -187,14 +219,29 @@
     fFitted = kTRUE;
 
-  if ( (fCharge > 3.*GetPedRms()) &&
-       (fErrCharge  > 0.)        &&
-       (fHist->IsFitOK())        &&
-       (fSigmaCharge > fPedRms)  &&
-       (fTime > fHist->GetTimeLowerFitRange()+1.) &&
-       (fTime < fHist->GetTimeUpperFitRange()-1.) )
-    fFitValid =  kTRUE;
-
-  //
-  // Apply the F-Factor Method
+
+  if (fHiGainSaturation)
+    {
+      if ( (fCharge     > 0.3*GetPedRms()) &&
+          (fErrCharge  > 0.)              &&
+          (fHist->IsFitOK())              &&
+          (fSigmaCharge > fPedRms/fConversionHiLo)   &&
+          (fTime > fHist->GetTimeLowerFitRange()+1.) &&
+          (fTime < fHist->GetTimeUpperFitRange()-1.) )
+        fFitValid =  kTRUE;
+    }
+  else
+    {
+      if ( (fCharge > 3.*GetPedRms()) &&
+           (fErrCharge  > 0.)        &&
+           (fHist->IsFitOK())        &&
+           (fSigmaCharge > fPedRms)  &&
+           (fTime > fHist->GetTimeLowerFitRange()+1.) &&
+           (fTime < fHist->GetTimeUpperFitRange()-1.) )
+        fFitValid =  kTRUE;
+    }
+  
+  //
+  // 7) Calculate the number of photo-electrons after the F-Factor method
+  // 8) Calculate the errors of the F-Factor method
   //
   if ((fPed > 0.)  && (fPedRms > 0.))
@@ -204,27 +251,25 @@
       // Square all variables in order to avoid applications of square root
       //
-      const Float_t chargesquare              =       fCharge*fCharge;
-      const Float_t chargessquarerelerrsquare = 4.*fErrCharge*fErrCharge/chargesquare;
-
-      const Float_t sigmasquare         =       fSigmaCharge*fSigmaCharge;
-      const Float_t sigmasquareerr      = 2.*fErrSigmaCharge*fSigmaCharge;
-
-      const Float_t pedrmssquare        =       fPedRms*fPedRms;
-      const Float_t pedrmssquareerr     = 2.*fErrPedRms*fPedRms;
-
-      const Float_t elecrmssquare       =       fElectronicPedRms*fElectronicPedRms;
-      const Float_t elecrmssquareerr    = 2.*fErrElectronicPedRms*fElectronicPedRms;
-
-      const Float_t conversionsquare    =    gkConversionHiLo     *gkConversionHiLo;
-      const Float_t conversionsquareerr = 2.*gkConversionHiLoError*gkConversionHiLo;
-
-      const Float_t ffactorrelerrsquare = fFactorError * fFactorError / fFactor / fFactor;
-
-      Float_t rsigmasquarerelerrsquare  = 0.;
-      Float_t   pheffactorrelerrsquare  = 0.;
+      // First the relative error squares
+      //
+      const Float_t chargeSquare              =       fCharge*   fCharge;
+      const Float_t chargeSquareRelErrSquare  = 4.*fErrCharge*fErrCharge / chargeSquare;
+
+      const Float_t fFactorRelErrSquare       = fFactorError * fFactorError / (fFactor * fFactor);
+      //
+      // Now the absolute error squares
+      //
+      const Float_t sigmaSquare               =       fSigmaCharge*   fSigmaCharge;
+      const Float_t sigmaSquareErrSquare      = 4.*fErrSigmaCharge*fErrSigmaCharge * sigmaSquare;
+
+      const Float_t elecRmsSquare             =       fElectronicPedRms*   fElectronicPedRms;
+      const Float_t elecRmsSquareErrSquare    = 4.*fErrElectronicPedRms*fErrElectronicPedRms * elecRmsSquare;
+
+      Float_t pedRmsSquare                    =       fPedRms*   fPedRms;
+      Float_t pedRmsSquareErrSquare           = 4.*fErrPedRms*fErrPedRms * pedRmsSquare;
 
       if (fHiGainSaturation)
 	{
-
+          
           //
           // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it 
@@ -233,10 +278,10 @@
           // We extract the pure NSB contribution:
           //
-          Float_t nsbsquare            = pedrmssquare - elecrmssquare;
-          Float_t nsbsquareerrsquare   = pedrmssquareerr  * pedrmssquareerr +
-                                         elecrmssquareerr * elecrmssquareerr;
-
-	  if (nsbsquare < 0.)
-            nsbsquare = 0.;
+          Float_t nsbSquare             =  pedRmsSquare          - elecRmsSquare;
+          Float_t nsbSquareRelErrSquare = (pedRmsSquareErrSquare + elecRmsSquareErrSquare)
+                                          / (nsbSquare * nsbSquare) ;
+
+	  if (nsbSquare < 0.)
+            nsbSquare = 0.;
           
           //
@@ -244,69 +289,87 @@
           // add it quadratically to the electronic noise
           //
-          Float_t logainrmssquare          = nsbsquare/conversionsquare + elecrmssquare;
-          Float_t logainrmssquareerrsquare = nsbsquareerrsquare/conversionsquare/conversionsquare 
-                                           + elecrmssquareerr * elecrmssquareerr 
-                                           + conversionsquareerr*conversionsquareerr
-                                             / (conversionsquare*conversionsquare)
-                                             / (conversionsquare*conversionsquare);
-          //
-          // Calculate the reduced sigma with the new "Pedestal RMS"
-          //
-          fRSigmaSquare            = sigmasquare - logainrmssquare;
-          rsigmasquarerelerrsquare = (sigmasquareerr * sigmasquareerr + logainrmssquareerrsquare)
-                                     / (fRSigmaSquare * fRSigmaSquare);
-
-          if (fRSigmaSquare > 0.)
-            {
-              fPheFFactorMethod      = fFactor * chargesquare / fRSigmaSquare;
-              pheffactorrelerrsquare =        ffactorrelerrsquare
-                                      + chargessquarerelerrsquare
-                                      +  rsigmasquarerelerrsquare ;
-            }
+          const Float_t conversionSquare             =    fConversionHiLo     *fConversionHiLo;
+          const Float_t conversionSquareRelErrSquare = 4.*fConversionHiLoError*fConversionHiLoError/conversionSquare;
+
+          //
+          // Calculate the new "Pedestal RMS"
+          //
+          const Float_t convertedNsbSquare          =  nsbSquare             / conversionSquare;
+          const Float_t convertedNsbSquareErrSquare = (nsbSquareRelErrSquare + conversionSquareRelErrSquare)
+                                                      * convertedNsbSquare * convertedNsbSquare;
+
+          pedRmsSquare           = convertedNsbSquare           + elecRmsSquare;
+          pedRmsSquareErrSquare  = convertedNsbSquareErrSquare  + elecRmsSquareErrSquare;
           
 	}    /* if (fHiGainSaturation) */
-      else   
+      
+      //
+      // Calculate the reduced sigmas
+      //
+      fRSigmaSquare = sigmaSquare - pedRmsSquare;
+      if (fRSigmaSquare <= 0.)
         {
-          fRSigmaSquare            = sigmasquare - pedrmssquare;
-          rsigmasquarerelerrsquare = (  sigmasquareerr *  sigmasquareerr 
-                                     + pedrmssquareerr * pedrmssquareerr) 
-                                   / (fRSigmaSquare * fRSigmaSquare);
-
-          fPheFFactorMethod      = fFactor * chargesquare / fRSigmaSquare;
-          //
-          // We first calculate the squared relative error in order to save the 
-          // TMath::Sqrt
-          //
-          pheffactorrelerrsquare = (       ffactorrelerrsquare
-                                   + chargessquarerelerrsquare
-                                   +  rsigmasquarerelerrsquare );
-          
-
-        }   /* if (fHiGainSaturation) */
-      
-
-      if (fPheFFactorMethod <= 0.)
-        {
-          *fLog << warn << "Cannot apply F-Factor calibration: Number of PhE smaller than 0 in pixel " 
+          *fLog << warn << "Cannot apply F-Factor calibration: Reduced Sigma smaller than 0 in pixel " 
                 << fPixId << endl;
+          if (fHiGainSaturation)
+            ApplyLoGainConversion();
           return kFALSE;
         }
-      
-      fConversionFFactorMethod      =  fPheFFactorMethod /  fCharge ;
-      fConversionErrorFFactorMethod =  fConversionFFactorMethod  *
-                                       ( pheffactorrelerrsquare +
-                                       (fErrCharge * fErrCharge / chargesquare ) );
-
-      fPheFFactorMethodError        =  TMath::Sqrt(pheffactorrelerrsquare) * fPheFFactorMethod;
-
-      if ( IsFitValid()                    &&
-          (fConversionFFactorMethod > 0.) &&
+
+      const Float_t rSigmaSquareRelErrSquare = (sigmaSquareErrSquare + pedRmsSquareErrSquare)
+        / (fRSigmaSquare * fRSigmaSquare) ;
+  
+      //
+      // Calculate the number of phe's from the F-Factor method
+      // (independent on Hi Gain or Lo Gain)
+      //
+      fPheFFactorMethod = fFactor * chargeSquare / fRSigmaSquare;
+
+      const Float_t pheFFactorRelErrSquare =  fFactorRelErrSquare
+                                            + chargeSquareRelErrSquare
+                                            + rSigmaSquareRelErrSquare ;
+          
+      fPheFFactorMethodError        =  TMath::Sqrt(pheFFactorRelErrSquare) * fPheFFactorMethod;
+
+      //
+      // Calculate the conversion factors 
+      //
+      if (fHiGainSaturation)
+        ApplyLoGainConversion();
+      
+      const Float_t chargeRelErrSquare = fErrCharge*fErrCharge / (fCharge * fCharge);
+      
+      fConversionFFactorMethod        =  fPheFFactorMethod / fCharge ;
+      fConversionErrorFFactorMethod   =  ( pheFFactorRelErrSquare + chargeRelErrSquare )
+                                         * fConversionFFactorMethod * fConversionFFactorMethod;
+      
+      if ( IsFitValid()                     &&
+           (fConversionFFactorMethod > 0.) &&
            (fConversionErrorFFactorMethod/fConversionFFactorMethod < 0.1) )
         fFFactorMethodValid = kTRUE;
       
-
+      
     } /*   if ((fPed > 0.)  && (fPedRms > 0.)) */
 
   return kTRUE;
+  
+}
+
+
+void MCalibrationPix::ApplyLoGainConversion()
+{
+  
+  const Float_t chargeRelErrSquare     =   fErrCharge*fErrCharge
+                                         /(   fCharge *  fCharge);
+  const Float_t sigmaRelErrSquare      =   fErrSigmaCharge*fErrSigmaCharge
+                                         /(   fSigmaCharge *  fSigmaCharge);
+  const Float_t conversionRelErrSquare =   fConversionHiLoError*fConversionHiLoError 
+                                         /(fConversionHiLo    * fConversionHiLo);
+  
+  fCharge         *= fConversionHiLo;
+  fErrCharge       = TMath::Sqrt(chargeRelErrSquare + conversionRelErrSquare) * fCharge;
+  
+  fSigmaCharge    *= fConversionHiLo;
+  fErrSigmaCharge =  TMath::Sqrt(sigmaRelErrSquare + conversionRelErrSquare) * fSigmaCharge;
   
 }
Index: /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h	(revision 2724)
+++ /trunk/MagicSoft/Mars/manalysis/MCalibrationPix.h	(revision 2725)
@@ -12,41 +12,44 @@
 private:
 
-  Int_t   fPixId;           // the pixel Id
+  Int_t   fPixId;                        // the pixel Id
   
-  Float_t fCharge;              // The mean reduced charge after the fit
-  Float_t fErrCharge;           // The error of reduced mean charge after the fit
-  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 fChargeProb;          // The probability of the fit function 
+  Float_t fCharge;                       // The mean reduced charge after the fit
+  Float_t fErrCharge;                    // The error of reduced mean charge after the fit
+  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 fChargeProb;                   // The probability of the fit function 
 
-  Float_t fPed;                 // The mean pedestal (from MPedestalPix)
-  Float_t fPedRms;              // The pedestal  RMS (from MPedestalPix)
-  Float_t fErrPedRms;           // The error of the pedestal  RMS (from MPedestalPix)  
-  Float_t fElectronicPedRms;    // The pure electronic component of the RMS
-  Float_t fErrElectronicPedRms; // The error of the pure electronic component of the RMS
+  Float_t fPed;                          // The mean pedestal (from MPedestalPix)
+  Float_t fPedRms;                       // The pedestal  RMS (from MPedestalPix)
+  Float_t fErrPedRms;                    // The error of the pedestal  RMS (from MPedestalPix)  
+  Float_t fElectronicPedRms;             // The pure electronic component of the RMS
+  Float_t fErrElectronicPedRms;          // The error of the pure electronic component of the RMS
 
-  Float_t fTime;                // The mean arrival time after the fit  
-  Float_t fSigmaTime;           // The error of the mean arrival time after the fit
-  Float_t fTimeChiSquare;       // The probability of the fit function 
+  Float_t fTime;                         // The mean arrival time after the fit  
+  Float_t fSigmaTime;                    // The error of the mean arrival time after the fit
+  Float_t fTimeChiSquare;                // The probability of the fit function 
   
-  Float_t fFactor;                  // The laboratory F-factor
-  Float_t fFactorError;             // The laboratory F-factor Error
-  Float_t fPheFFactorMethod;        // The number of Phe's calculated after the F-factor method
-  Float_t fPheFFactorMethodError;   // The error on the number of Phe's calculated after the F-factor method  
+  Float_t fFactor;                       // The laboratory F-factor
+  Float_t fFactorError;                  // The laboratory F-factor Error
+  Float_t fPheFFactorMethod;             // The number of Phe's calculated (F-factor method)
+  Float_t fPheFFactorMethodError;        // The error on the number of Phe's calculated (F-factor method)
 
-  Float_t fConversionFFactorMethod;    // The conversion factor to Ph's calculated after the F-factor method
-  Float_t fConversionBlindPixelMethod; // The conversion factor to Ph's calculated after the Blind Pixel method
-  Float_t fConversionPINDiodeMethod;   // The conversion factor to Ph's calculated after the PIN Diode 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 conversion factor to Phe's calculated after the F-factor method
-  Float_t fConversionErrorBlindPixelMethod; // The conversion factor to Phe's calculated after the Blind Pixel method
-  Float_t fConversionErrorPINDiodeMethod;   // The conversion factor to Phe's calculated after the 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 conversion factor to Ph's calculated after the F-factor method
-  Float_t fConversionSigmaBlindPixelMethod; // The conversion factor to Ph's calculated after the Blind Pixel method
-  Float_t fConversionSigmaPINDiodeMethod;   // The conversion factor to Phd's calculated after the 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)
 
-  Bool_t  fHiGainSaturation;     // Is Lo-Gain used at all?
+  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  
+  
+  Bool_t  fHiGainSaturation;                // Is Lo-Gain used at all?
 
   Bool_t  fFitValid;        
@@ -81,6 +84,14 @@
 
   void SetPedestal(Float_t ped, Float_t pedrms);
-  void SetHiGainSaturation()                        { fHiGainSaturation = kTRUE; fHist->SetUseLoGain(); } 
+  void SetHiGainSaturation()                               { fHiGainSaturation = kTRUE; fHist->SetUseLoGain(); } 
 
+  void ApplyLoGainConversion();
+
+  void SetConversionHiLo(Float_t c)                       { fConversionHiLo      = c;    }
+  void SetConversionHiLoError(Float_t e)                    { fConversionHiLoError = e;    }
+
+  Float_t GetConversionHiLo()                       { return fConversionHiLo;        }
+  Float_t GetConversionHiLoError()                  { return fConversionHiLoError;   }
+  
   void SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig)      
                                                     { 
@@ -136,7 +147,7 @@
   void   SetFitValid()                                     { fFitValid = kTRUE;  }
   void   SetFitted()                                      { fFitted = kTRUE;  }
-  void   SetBlindPixelMethodValid()                             { fBlindPixelMethodValid = kTRUE;  }
-  void   SetFFactorMethodValid()                               { fFFactorMethodValid = kTRUE;  }
-  void   SetPINDiodeMethodValid()                              { fPINDiodeMethodValid = kTRUE;  }
+  void   SetBlindPixelMethodValid(Bool_t b=kTRUE)               { fBlindPixelMethodValid = b;  }
+  void   SetFFactorMethodValid(Bool_t b=kTRUE)                 { fFFactorMethodValid = b;  }
+  void   SetPINDiodeMethodValid(Bool_t b=kTRUE)                { fPINDiodeMethodValid = b;  }
   
   Int_t  GetPixId()                              const  { return fPixId;   }
Index: /trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc	(revision 2724)
+++ /trunk/MagicSoft/Mars/manalysis/MExtractSignal.cc	(revision 2725)
@@ -59,5 +59,5 @@
                     const char *name, const char *title)
   : fNumHiGainSamples(last-first+1), fNumLoGainSamples(last-first+1),
-    fSaturationLimit(254), fConversionHiLo(10.)
+    fSaturationLimit(254)
 {
 
@@ -215,5 +215,5 @@
 	pix.SetExtractedSignal((Float_t)sumHi - pedes*(Float_t)fNumHiGainSamples,
 			       pedrms*fSqrtHiGainSamples,
-			       ((Float_t)sumLo - pedes*(Float_t)fNumLoGainSamples)*fConversionHiLo,
+			       ((Float_t)sumLo - pedes*(Float_t)fNumLoGainSamples),
 			       pedrms*fSqrtLoGainSamples
 			       );
Index: /trunk/MagicSoft/Mars/manalysis/MExtractSignal.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MExtractSignal.h	(revision 2724)
+++ /trunk/MagicSoft/Mars/manalysis/MExtractSignal.h	(revision 2725)
@@ -41,5 +41,4 @@
 
   Byte_t  fSaturationLimit;
-  Float_t fConversionHiLo;
 
   Bool_t ReInit(MParList *pList); 
@@ -50,8 +49,9 @@
 public:
 
-  MExtractSignal(const Byte_t first=4, const Byte_t last=9, const Byte_t logainshift=1, const char *name=NULL, const char *title=NULL);
+  MExtractSignal(const Byte_t first=4, const Byte_t last=9,
+                 const Byte_t logainshift=1,
+                 const char *name=NULL, const char *title=NULL);
   
   void SetSaturationLimit(Byte_t lim)      { fSaturationLimit = lim; }
-  void SetConversionHiLo(Float_t con)      { fConversionHiLo = con; }
 
   ClassDef(MExtractSignal, 0)   // Task to fill the Extracted Signal Containers from raw data
