Index: trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc	(revision 5977)
+++ trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.cc	(revision 6318)
@@ -30,9 +30,10 @@
 //  MMcFadcHeader and translates it to the pedestal mean and rms (in adc counts).
 //  If not already existing in the parameter list, an MCalibrationCam object
-//  is created, with the conversion factor between photons and ADC counts is 
-//  set to 1 to allow the analysis to proceed.
+//  is created, with the conversion factor between ADC counts and photons or 
+//  photoelectrons (depending on fSignalType) is set to 1 to allow the analysis 
+//  to proceed.
 //
 //  Then it creates and fills also the MPedPhotCam object containing the pedestal
-//  mean and rms in units of photons.
+//  mean and rms in units of photons or photoelectrons.
 //
 //  Input Containers:
@@ -71,4 +72,5 @@
 #include "MMcFadcHeader.hxx"
 #include "MMcConfigRunHeader.h"
+#include "MCalibrateData.h"
 
 ClassImp(MMcCalibrationUpdate);
@@ -85,4 +87,6 @@
     fAmplitudeOuter = -1.;
     fConversionHiLo = -1.;
+
+    fSignalType = MCalibrateData::kPhe;
 
     fFillCalibrationCam = kTRUE;
@@ -221,5 +225,5 @@
     // If MCalibrationChargeCam and MCalibrationQECam already existed 
     // in the parameter list before MMcCalibrationUpdate::PreProcess was 
-    // executed (from a previous calibration loop) we must not fill it, 
+    // executed (from a previous calibration loop) we must not fill them, 
     // hence nothing else has to be done in ReInit:
     //
@@ -233,5 +237,5 @@
     // perpendicular to the camera plane.
     //
-    // FIXME! We should look for AddSerialNumber("MMcConfigRunHeader") but
+    // FIXME! We look for AddSerialNumber("MMcConfigRunHeader") but
     // for the moment the stereo version of camera does not write one such
     // header per telescope (it should!)
@@ -254,13 +258,22 @@
     // (at angle = 90 deg)
 
-    // Set now the default conversion from ADC counts to "photoelectrons" 
+    // Set now the default conversion from ADC counts to photoelectrons 
     // (in case no previous calibration existed in the parameter list).
-    // As default we want 1 photon = 1 inner pixel ADC count
-    // (this will make Size to be in ADC counts, which is what we want for
-    // the MC calibration loop). To achieve this we set the ADC to 
-    // photoelectron conversion equal to the QE, which will later make the 
-    // ADC to photon conversion factor (= ADC2PhotEl/QE) to be = 1.
-    //
-    fADC2PhElInner = MCalibrationQEPix::gkDefaultAverageQE;
+    //
+    // As default we want to have SIZE in ADC counts, or rather, in "inner pixel
+    // equivalent ADC counts".
+    //
+    // To achieve this:
+    // - In the case fSignalType==kPhot: we set the ADC to photoelectron conversion 
+    // equal to the QE, which will later make the ADC to photon conversion factor 
+    // (= ADC2PhotEl/QE) to be = 1, 
+    //
+    // - In the case fSignalType==kPhe: we set the ADC to photoelectron conversion 
+    // equal to 1, since this will be applied directly to the signals...
+
+    if (fSignalType == MCalibrateData::kPhot)
+      fADC2PhElInner = MCalibrationQEPix::gkDefaultAverageQE;
+    else
+      fADC2PhElInner = 1.;
 
     //
@@ -281,5 +294,5 @@
 
     if (fOuterPixelsGainScaling)
-      fADC2PhElOuter =  MCalibrationQEPix::gkDefaultAverageQE 
+      fADC2PhElOuter = fADC2PhElInner
 	* (fAmplitude / fAmplitudeOuter);
     else
@@ -397,11 +410,16 @@
 
         Float_t qe       = qepix.GetAverageQE();
-	Float_t adc2phot = calpix.GetMeanConvFADC2Phe() / qe;
+
+
+	Float_t conv = (fSignalType == MCalibrateData::kPhot? 
+	  calpix.GetMeanConvFADC2Phe() / qe  :
+	  calpix.GetMeanConvFADC2Phe());
+
 	Float_t hi2lo    = calpix.GetConversionHiLo();
 
 	if (sigpix.IsLoGainUsed())
-            pedpix.Set(adc2phot*hi2lo*pedestmean, adc2phot*hi2lo*pedestrms);
+            pedpix.Set(conv*hi2lo*pedestmean, conv*hi2lo*pedestrms);
 	else
-            pedpix.Set(adc2phot*pedestmean, adc2phot*pedestrms);
+            pedpix.Set(conv*pedestmean, conv*pedestrms);
 
     }
@@ -409,2 +427,3 @@
     return kTRUE;
 }
+
