Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 3018)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 3019)
@@ -21,5 +21,5 @@
 
 
- 2004/02/03: Abelardo Moralejo
+ 2004/02/04: Abelardo Moralejo
 
   * macros/starmc2.C
@@ -28,5 +28,5 @@
 
 
- 2004/02/03: Markus Gaug
+ 2004/02/04: Markus Gaug
 
   * manalysis/MPedestalCam.[h,cc], manalysis/MPedestalPix.[h,cc],
@@ -41,4 +41,8 @@
   * manalysis/MExtractSignal.cc
     - remove uncommented code
+
+  * mcalib/MCalibrationCalc.[h,cc]
+    - modified way to handle histogram overflow: Now flags are set and 
+      ChargevsN histogram is not tried to be filled subsequently
 
 
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc	(revision 3018)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc	(revision 3019)
@@ -145,9 +145,16 @@
     SETBIT(fFlags, kUseQualityChecks);
 
+    CLRBIT(fFlags, kBlindPixelOverFlow);
+    CLRBIT(fFlags, kPINDiodeOverFlow);
+    CLRBIT(fFlags, kHiGainOverFlow);
+    CLRBIT(fFlags, kLoGainOverFlow);
     // As long as we don't have the PIN Diode:
     CLRBIT(fFlags, kUsePinDiodeFit);
 
+
+
     fEvents            = 0;
     fCosmics           = 0;
+
     fNumHiGainSamples  = 0;
     fNumLoGainSamples  = 0;
@@ -430,5 +437,4 @@
   fEvents++;
 
-  Int_t   overflow      = 0;
   Float_t referencetime = 0.;
   
@@ -508,7 +514,12 @@
             }
           
-          if (!blindpixel.FillRChargevsTime(sumhi,fEvents))
-            *fLog << warn << 
-              "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl;
+          if (!TESTBIT(fFlags,kBlindPixelOverFlow))
+            if (!blindpixel.FillRChargevsTime(sumhi,fEvents))
+              {
+                *fLog << warn << 
+                  "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl;
+                SETBIT(fFlags,kBlindPixelOverFlow);
+              }
+          
           break;
           
@@ -529,7 +540,12 @@
             }
           
-          if (!pindiode.FillRChargevsTime(sumhi,fEvents))
-            *fLog << warn << 
-              "Overflow or Underflow occurred filling PINDiode: eventnr = " << fEvents << endl;
+          if (!TESTBIT(fFlags,kPINDiodeOverFlow))
+            if (!pindiode.FillRChargevsTime(sumhi,fEvents))
+              {
+                *fLog << warn 
+                      << "Overflow or Underflow occurred filling PINDiode: eventnr = " 
+                      << fEvents << endl;
+                SETBIT(fFlags,kPINDiodeOverFlow);
+              }
           break;
           
@@ -538,9 +554,22 @@
           pix.FillChargesInGraph(sumhi,sumlo);
 
-          if (!pix.FillRChargevsTimeLoGain(sumlo,fEvents))
-            overflow++;
-          
-          if (!pix.FillRChargevsTimeHiGain(sumhi,fEvents))
-            overflow++;
+          if (!TESTBIT(fFlags,kLoGainOverFlow))
+            if (!pix.FillRChargevsTimeLoGain(sumlo,fEvents))
+              {
+                *fLog << warn 
+                      << "Overflow filling Histogram ChargevsNLoGain eventnr = " 
+                      << fEvents << endl;
+                SETBIT(fFlags,kLoGainOverFlow);
+              }
+          
+          if (!TESTBIT(fFlags,kHiGainOverFlow))
+            if (!pix.FillRChargevsTimeHiGain(sumhi,fEvents))
+              {
+                *fLog << warn 
+                      << "Overflow filling Histogram ChargevsNHiGain eventnr = " 
+                      << fEvents << endl;
+                SETBIT(fFlags,kHiGainOverFlow);
+              }
+
           
           if (sig.IsLoGainUsed())
@@ -583,7 +612,4 @@
     } /* while (pixel.Next()) */
 
-  if (overflow)
-    *fLog << warn << "Overflow occurred filling Charges vs. EvtNr " << overflow << " times" << endl;
-  
   return kTRUE;
 }
@@ -655,6 +681,12 @@
           pederr          = TMath::Sqrt(pederr)*sqrslice;
           
-          const Float_t pedsigma    = pedhist.GetChargeSigma()*sqrslice;
-          const Float_t pedsigmaerr = pedhist.GetChargeSigmaErr()*sqrslice;
+          //
+          // Fitted sigma: 1. one sqrt(Nr. slices) for the division which is not 
+          //                  not appropriate: sigma(real)/slice = GetSigma*sqrt(nslices)
+          //               2. another sqrt(Nr. slices) to calculate back to number 
+          //                  of slices
+          // 
+          const Float_t pedsigma    = pedhist.GetChargeSigma()*nslices;
+          const Float_t pedsigmaerr = pedhist.GetChargeSigmaErr()*nslices;
           
           hist->SetMeanPedestal(peddiff);
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.h	(revision 3018)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.h	(revision 3019)
@@ -55,5 +55,5 @@
   Int_t fEvents;                           // Number of events  
   Int_t fCosmics;                          // Number of events due to supposed cosmics
-
+  
   Byte_t fNumHiGainSamples; 
   Byte_t fNumLoGainSamples; 
@@ -61,5 +61,5 @@
   
   Float_t fConversionHiLo;
-  Byte_t fFlags;                           // Flag for the fits used
+  Int_t   fFlags;                           // Flag for the fits used
 
   TString fExcludedPixelsFile;
@@ -67,5 +67,7 @@
 
   enum  { kUseTimes, kUseBlindPixelFit, kUsePinDiodeFit,
-          kUseCosmicsRejection, kUseQualityChecks };
+          kUseCosmicsRejection, kUseQualityChecks,
+          kBlindPixelOverFlow, kPINDiodeOverFlow,
+          kHiGainOverFlow, kLoGainOverFlow  };
 
 public:
