Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 4564)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 4565)
@@ -19,4 +19,14 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+  2004/08/10: Florian Goebel
+
+   * mpedestal/MPedCalcFromLoGain.[h,cc]
+     - add SetPedContainerName() to change name
+       of output container
+     - fix bug affecting behaviour when running twice
+       over the same run
+     - change format of "Format"
+     - change default value for fgMaxHiGainVar to 40
 
   2004/08/10: Nadia Tonello
Index: /trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc
===================================================================
--- /trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 4564)
+++ /trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 4565)
@@ -153,5 +153,5 @@
 const Byte_t MPedCalcFromLoGain::fgHiGainWindowSize = 12;
 const Byte_t MPedCalcFromLoGain::fgLoGainWindowSize = 14;
-const Byte_t MPedCalcFromLoGain::fgMaxHiGainVar     = 20;
+const Byte_t MPedCalcFromLoGain::fgMaxHiGainVar     = 40;
 
 // --------------------------------------------------------------------------
@@ -173,5 +173,5 @@
     : fWindowSizeHiGain(fgHiGainWindowSize), 
       fWindowSizeLoGain(fgLoGainWindowSize), 
-      fGeom(NULL)
+      fGeom(NULL), fPedContainerName("MPedestalCam")
 {
   fName  = name  ? name  : "MPedCalcFromLoGain";
@@ -260,6 +260,6 @@
     {
       *fLog << warn << GetDescriptor() 
-            << Form("%s%2i%s%2i%s%2i%s",": Hi Gain window size: ",(int)fWindowSizeHiGain,
-                    " is bigger than available range: [",(int)fHiGainFirst,",",(int)fHiGainLast,"]") << endl;
+            << Form(": Hi Gain window size: %2i is bigger than available range: [%2i,%2i]",
+		    (int)fWindowSizeHiGain, (int)fHiGainFirst, (int)fHiGainLast) << endl;
       *fLog << warn << GetDescriptor() 
             << ": Will set window size to: " << (int)availhirange << endl;
@@ -270,6 +270,6 @@
     {
       *fLog << warn << GetDescriptor() 
-            << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",(int)fWindowSizeLoGain,
-                    " is bigger than available range: [",(int)fLoGainFirst,",",(int)fLoGainLast,"]") << endl;
+            << Form(": Lo Gain window size: %2i is bigger than available range: [%2i,%2i]",
+		    (int)fWindowSizeLoGain, (int)fLoGainFirst, (int)fLoGainLast) << endl;
       *fLog << warn << GetDescriptor() 
             << ": Will set window size to: " << (int)availlorange << endl;
@@ -322,7 +322,13 @@
     }
 
-  fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+  *fLog << " searching for the container " << fPedContainerName << endl;
+
+  fPedestals = (MPedestalCam*)pList->FindCreateObj( AddSerialNumber("MPedestalCam"),fPedContainerName);  
   if (!fPedestals)
+  {
+    *fLog << err << fPedContainerName << " can not be created" << endl;
     return kFALSE;
+  }
+
 
   return kTRUE;
@@ -356,7 +362,6 @@
       *fLog << endl; 
       *fLog << warn << GetDescriptor()
-            << Form("%s%2i%s%2i%s%2i%s",": Selected Lo Gain FADC Window [",
-                    (int)fLoGainFirst,",",lastdesired,
-                    "] ranges out of the available limits: [0,",lastavailable,"].") << endl;
+            << Form(": Selected Lo Gain FADC Window [%2i,%2i] ranges out of the available limits: [0,%2i].",
+		    (int)fLoGainFirst, lastdesired, lastavailable) << endl;
       *fLog << GetDescriptor() << ": Will reduce the upper edge to " << (int)(fLoGainLast - diff) << endl;
       SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff);
@@ -371,9 +376,8 @@
       *fLog << endl;
       *fLog << warn << GetDescriptor()
-            << Form("%s%2i%s%2i%s%2i%s",": Selected Hi Gain Range [",
-                    (int)fHiGainFirst,",",lastdesired,
-                    "] ranges out of the available limits: [0,",lastavailable,"].") << endl;
+            << Form(": Selected Hi Gain Range [%2i,%2i] ranges out of the available limits: [0,%2i].",
+                    (int)fHiGainFirst, lastdesired, lastavailable) << endl;
       *fLog << warn << GetDescriptor() 
-            << Form("%s%2i%s",": Will possibly use ",diff," samples from the Low-Gain for the High-Gain range")
+            << Form(": Will possibly use %2i samples from the Low-Gain for the High-Gain range", diff)
             << endl;
       fHiGainLast -= diff;
@@ -389,9 +393,8 @@
       *fLog << endl;
       *fLog << warn << GetDescriptor()
-            << Form("%s%2i%s%2i%s",": Selected Hi Gain FADC Window size ",
-                    (int)fWindowSizeHiGain,
-                    " ranges out of the available limits: [0,",lastavailable,"].") << endl;
+            << Form(": Selected Hi Gain FADC Window size %2i ranges out of the available limits: [0,%2i].",
+                    (int)fWindowSizeHiGain, lastavailable) << endl;
       *fLog << warn << GetDescriptor() 
-            << Form("%s%2i%s",": Will use ",diff," samples from the Low-Gain for the High-Gain extraction")
+            << Form(": Will use %2i samples from the Low-Gain for the High-Gain extraction", diff)
             << endl;
 
@@ -510,5 +513,5 @@
       }
 
-      if (fPedestalUpdate && (fNumEventsUsed[idx] == fNumEventsDump)) {
+      if (fPedestalUpdate && (fNumEventsUsed[idx] >= fNumEventsDump)) {
 
 	const ULong_t n = fNumEventsDump;
@@ -597,4 +600,11 @@
   }
 
+  fSumx.Reset();
+  fSumx2.Reset();
+  fSumAB0.Reset();
+  fSumAB1.Reset();
+  fNumEventsUsed.Reset();
+  fTotalCounter.Reset();
+
   return kTRUE;
 }
Index: /trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h
===================================================================
--- /trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h	(revision 4564)
+++ /trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h	(revision 4565)
@@ -35,7 +35,8 @@
 
   Bool_t  fPedestalUpdate;
-  
-  MGeomCam*fGeom;            // Camera geometry
-  
+
+  MGeomCam     *fGeom;       // Camera geometry
+  TString fPedContainerName; // name of the 'MPedestalCam' container
+ 
   TArrayI fNumEventsUsed;    // Number of events used for pedestal calc for each pixel
   TArrayI fTotalCounter;     // Counter for dumping values to Pedestal Container
@@ -44,4 +45,5 @@
   TArrayD fSumAB0;           // sum of ABFlag=0 slices
   TArrayD fSumAB1;           // sum of ABFlag=1 slices
+
   
   Int_t  PreProcess (MParList *pList);
@@ -60,4 +62,6 @@
   void SetPedestalUpdate(Bool_t pedupdate)  {fPedestalUpdate = pedupdate;}
   
+  void SetPedContainerName(const char *name)    { fPedContainerName = name; }
+
   TArrayI *GetNumEventsUsed() {return &fNumEventsUsed;};
   
