Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2748)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2749)
@@ -4,4 +4,29 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2003/12/23: Abelardo Moralejo
+
+   * manalysis/MExtractedSignalPix.cc
+     - in Clear(), initialized fExtractedSignalHiGain to 0 instead 
+       of -1. In MC files run without noise, the ADC info of pixels 
+       with no C-photons is missing. Later noise will be added to all 
+       pixels in the padding, and "empty" ones must have a 0 before 
+       the addition of this noise.
+
+   * manalysis/MGeomApply.cc
+     - initialized size of MPedPhotCam.
+
+   * manalysis/MMcCalibrationCalc.[cc,h]
+     - Removed setter function SetConversionHiLo: the ratio from high 
+       to low gain is now read from MMcFadcHeader, and set in ReInit.
+     - Fixed bug: fADC2PhOuter was initialized before the MMcFadcHeader
+       was available. Now it is done in ReInit.
+     - fPedPhotCam is now initialized in PreProcess and not in ReInit.
+     - fGeom is now set in ReInit (there should be one MGeomCam per
+       run header in the camera file).
+
+   * mmc/MMcFadcHeader.hxx
+     - added getter function GetLow2HighGain()
+
 
  2003/12/23: Thomas Bretz
Index: trunk/MagicSoft/Mars/manalysis/MExtractedSignalPix.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MExtractedSignalPix.cc	(revision 2748)
+++ trunk/MagicSoft/Mars/manalysis/MExtractedSignalPix.cc	(revision 2749)
@@ -64,6 +64,8 @@
 {
 
-  fExtractedSignalHiGain = -1.;
+  fExtractedSignalHiGain = 0.;
+  //  fExtractedSignalHiGain = -1.;
   fExtractedSignalHiGainError = -1.;
+
   fIsLoGainUsed = kFALSE;
   fNumHiGainSaturated = 0;
Index: trunk/MagicSoft/Mars/manalysis/MGeomApply.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MGeomApply.cc	(revision 2748)
+++ trunk/MagicSoft/Mars/manalysis/MGeomApply.cc	(revision 2749)
@@ -58,4 +58,5 @@
 #include "MPedestalCam.h"
 #include "MCalibrationCam.h"
+#include "MPedPhotCam.h"
 #include "MBlindPixels.h"
 
@@ -122,4 +123,9 @@
 
 
+    MPedPhotCam *pedphot = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
+    if (pedphot)
+        pedphot->InitSize(cam->GetNumPixels());
+
+
     MBlindPixels *bnd = (MBlindPixels*)pList->FindObject(AddSerialNumber("MBlindPixels"));
     if (bnd)
Index: trunk/MagicSoft/Mars/manalysis/MMcCalibrationCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcCalibrationCalc.cc	(revision 2748)
+++ trunk/MagicSoft/Mars/manalysis/MMcCalibrationCalc.cc	(revision 2749)
@@ -101,6 +101,4 @@
 {
   fADC2PhInner = x;
-  fADC2PhOuter = x * 
-    fHeaderFadc->GetAmplitud() / fHeaderFadc->GetAmplitudOuter();
 
   return;
@@ -125,5 +123,6 @@
     }
 
-  if ( ! pList->FindCreateObj(AddSerialNumber("MPedPhotCam")))
+  fPedPhotCam = (MPedPhotCam*) pList->FindCreateObj(AddSerialNumber("MPedPhotCam"));
+  if ( ! fPedPhotCam)
     {
       *fLog << err << dbginf << "Cannot create MPedPhotCam... aborting." << endl;
@@ -131,11 +130,4 @@
     }
 
-  fGeom = (MGeomCam*) pList->FindObject(AddSerialNumber("MGeomCam"));
-  if ( ! fGeom )
-    {
-      *fLog << err << dbginf << "Cannot find MGeomCam... aborting." << endl;
-      return kFALSE;
-    }
-
   fSignalCam = (MExtractedSignalCam*) pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
   if ( ! fSignalCam)
@@ -145,4 +137,12 @@
     }
 
+    fCalCam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationCam"));
+
+    if (!fCalCam)
+    {
+        *fLog << err << dbginf << "Could not create MCalibrationCam... aborting. " << endl;
+        return kFALSE;
+    }
+
   return kTRUE;
 
@@ -163,7 +163,13 @@
 
     //
-    // Now check the existence of all necessary containers. This has
-    // to be done only if this is a MC file.
-    //
+    // Now check the existence of all necessary containers.
+    //
+
+    fGeom = (MGeomCam*) pList->FindObject(AddSerialNumber("MGeomCam"));
+    if ( ! fGeom )
+      {
+	*fLog << err << dbginf << "Cannot find MGeomCam... aborting." << endl;
+	return kFALSE;
+      }
 
     fHeaderFadc = (MMcFadcHeader*)pList->FindObject(AddSerialNumber("MMcFadcHeader"));
@@ -174,21 +180,14 @@
     }
 
-    fCalCam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationCam"));
-
-    if (!fCalCam)
-    {
-        *fLog << err << dbginf << "Could not create MCalibrationCam... aborting. " << endl;
-        return kFALSE;
-    }
-
-    fPedPhotCam = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
-
-    if (!fPedPhotCam)
-    {
-        *fLog << err << dbginf << "Could not create MPedPhotCam... aborting. " << endl;
-        return kFALSE;
-    }
-
-    fPedPhotCam->InitSize(fGeom->GetNumPixels());
+    //
+    // Set the ADC to photons conversion factor for outer pixels:
+    //
+    fADC2PhOuter = fADC2PhInner *
+      (fHeaderFadc->GetAmplitud() / fHeaderFadc->GetAmplitudOuter());
+
+    //
+    // Set the conversion factor between high and low gain:
+    //
+    fConversionHiLo = fHeaderFadc->GetLow2HighGain();
 
     return kTRUE;
@@ -231,5 +230,5 @@
 	//
 
-	Float_t adc2phot = (fGeom->GetPixRatio(i) > fGeom->GetPixRatio(0))?
+	Float_t adc2phot = (fGeom->GetPixRatio(i) < fGeom->GetPixRatio(0))?
 	  fADC2PhOuter : fADC2PhInner;
 
Index: trunk/MagicSoft/Mars/manalysis/MMcCalibrationCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcCalibrationCalc.h	(revision 2748)
+++ trunk/MagicSoft/Mars/manalysis/MMcCalibrationCalc.h	(revision 2749)
@@ -28,5 +28,4 @@
     Float_t fADC2PhInner; // Conversion factor from ADC counts to photons
     Float_t fADC2PhOuter; // for inner and outer pixels.
-
     Float_t fConversionHiLo;
 
@@ -35,5 +34,4 @@
 
     void SetADC2PhInner(Float_t x);
-    void SetConversionHiLo(Float_t x) { fConversionHiLo = x; }
 
     ClassDef(MMcCalibrationCalc, 0)   // Task which obtains, for MC files, the pedestal mean and rms, and the calibration factor from ADC counts to photons. 
Index: trunk/MagicSoft/include-Classes/MMcFormat/MMcFadcHeader.hxx
===================================================================
--- trunk/MagicSoft/include-Classes/MMcFormat/MMcFadcHeader.hxx	(revision 2748)
+++ trunk/MagicSoft/include-Classes/MMcFormat/MMcFadcHeader.hxx	(revision 2749)
@@ -83,4 +83,5 @@
   Float_t GetAmplitud() const { return fAmplFadc; }
   Float_t GetAmplitudOuter() const { return fAmplFadcOuter; }
+  Float_t GetLow2HighGain() const { return fLow2HighGain; }
 
   UInt_t GetNumPixel() const { return MFADC_CHANNELS; }
