Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 3033)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 3034)
@@ -37,4 +37,10 @@
    * manalysis/MExtractSignal2.[h,cc]
      - removed uncommented code (arrival time)
+
+   * manalysis/MHPedestalPixel.[h,cc]
+     - is now filled with total pedestals (not per slice), but results are 
+       renormalized to values per slice (this is not to screw up with the 
+       pedestal RMS and the derived uncertainties)
+     - new function Renorm(nslices)
 
 
Index: /trunk/MagicSoft/Mars/manalysis/MExtractSignal2.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MExtractSignal2.cc	(revision 3033)
+++ /trunk/MagicSoft/Mars/manalysis/MExtractSignal2.cc	(revision 3034)
@@ -49,6 +49,4 @@
 #include "MExtractedSignalPix.h"
 
-//#include "MArrivalTime.h"
-
 ClassImp(MExtractSignal2);
 
@@ -128,9 +126,4 @@
         return kFALSE;
     }
-/*
-    fArrivalTime = (MArrivalTime*)pList->FindCreateObj(AddSerialNumber("MArrivalTime"));
-    if (!fArrivalTime)
-        return kFALSE;
- */
     return kTRUE;
 }
Index: /trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.cc	(revision 3033)
+++ /trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.cc	(revision 3034)
@@ -48,10 +48,10 @@
 const Float_t gkSq2Pi = 2.506628274631;
 const Float_t gkProbLimit = 0.01;
-const Int_t   MHPedestalPixel::gkChargeNbins    = 500 ;
+const Int_t   MHPedestalPixel::gkChargeNbins    = 250 ;
+const Axis_t  MHPedestalPixel::gkChargeFirst    = -0.5;
+const Axis_t  MHPedestalPixel::gkChargeLast     = 249.5;
 const Int_t   MHPedestalPixel::gkChargevsNbins  = 1000;
 const Axis_t  MHPedestalPixel::gkChargevsNFirst = -0.5;
 const Axis_t  MHPedestalPixel::gkChargevsNLast  = 999.5;
-const Axis_t  MHPedestalPixel::gkChargeFirst    = -0.5;
-const Axis_t  MHPedestalPixel::gkChargeLast     = 499.5;
 
 // --------------------------------------------------------------------------
@@ -97,5 +97,5 @@
 {
   
-  fTotalEntries    = 0;
+  fTotalEntries    =  0;
 
   fChargeMean      = -1.;
@@ -196,6 +196,6 @@
 {
 
-  gStyle->SetOptFit(1);
   gStyle->SetOptStat(111111);
+  gStyle->SetOptFit();
   
   gROOT->SetSelectedPad(NULL);
@@ -203,5 +203,5 @@
   TCanvas *c = MH::MakeDefCanvas(this,600,900); 
   
-  c->Divide(1,2);
+  //  c->Divide(1,2);
   
   c->cd(1);
@@ -210,5 +210,5 @@
 
   if (fHPedestalCharge->Integral() > 0)
-    gPad->SetLogy(1);
+    gPad->SetLogy();
 
   fHPedestalCharge->Draw(opt);
@@ -226,8 +226,11 @@
   c->Update();
 
+  /*
   c->cd(2);
   gPad->SetTicks();
 
   fHPedestalChargevsN->Draw(opt);
+  */
+
   c->Modified();
   c->Update();
@@ -285,16 +288,14 @@
   
   // 
-  // If we are not able to fit, try once again
-  //
-  if (fGausFit->GetProb() < gkProbLimit)
-    {
-
-      Axis_t rtry = fGausFit->GetParameter(1) - 2.0*fGausFit->GetParameter(2);
-      rmin        = (rtry < rmin ? rmin : rtry);
-      rmax        = fGausFit->GetParameter(1) + 2.0*fGausFit->GetParameter(2);
-      fGausFit->SetRange(rmin,rmax);  
-
-      fHPedestalCharge->Fit(fGausFit,option);
-    }
+  // In order not to be affected by outliers, 
+  // try once again with stricter borders
+  //
+  Axis_t rtry = fGausFit->GetParameter(1) - 2.5*fGausFit->GetParameter(2);
+  rmin        = (rtry < rmin ? rmin : rtry);
+  rtry        = fGausFit->GetParameter(1) + 2.5*fGausFit->GetParameter(2);
+  rmax        = (rtry > rmax ? rmax : rtry);
+  fGausFit->SetRange(rmin,rmax);  
+  
+  fHPedestalCharge->Fit(fGausFit,option);
   
   fChargeChisquare = fGausFit->GetChisquare();
@@ -312,5 +313,15 @@
   // The Probability is greater than gkProbLimit (default 0.001 == 99.9%)
   //
-  if (TMath::IsNaN(fChargeMean) || TMath::IsNaN(fChargeMeanErr))
+  if (TMath::IsNaN(fChargeMean)    || 
+     TMath::IsNaN(fChargeMeanErr) ||
+     TMath::IsNaN(fChargeSigma) || 
+     TMath::IsNaN(fChargeSigmaErr))
+    {
+      Clear();
+      //      CLRBIT(fFlags,kFitOK);
+      return kFALSE;
+    }
+  
+  if ((fChargeProb < gkProbLimit) || (TMath::IsNaN(fChargeProb)))
     {
       CLRBIT(fFlags,kFitOK);
@@ -318,18 +329,36 @@
     }
   
-  if ((fChargeProb < gkProbLimit) || (TMath::IsNaN(fChargeProb)))
-    {
-      CLRBIT(fFlags,kFitOK);
-      return kFALSE;
-    }
-  
   SETBIT(fFlags,kFitOK);
   return kTRUE;
 }
 
+void MHPedestalPixel::Renorm(const Float_t nslices)
+{
+
+  if (!TESTBIT(fFlags,kFitOK))
+    return;
+
+  Float_t sqslices = TMath::Sqrt(nslices);
+
+  fChargeMean      /= nslices;
+  //
+  // Mean error goes with PedestalRMS/Sqrt(entries) -> scale with slices
+  // 
+  fChargeMeanErr   /= nslices;
+  //
+  // Sigma goes like PedestalRMS -> scale with sqrt(slices)    
+  //
+  fChargeSigma     /= sqslices;
+  //
+  // Sigma error goes like PedestalRMS/2.(entries) -> scale with slices
+  //
+  fChargeSigmaErr  /= nslices;
+  
+}
+
 void MHPedestalPixel::CutAllEdges()
 {
 
-  Int_t nbins = 30;
+  Int_t nbins = 15;
 
   MH::CutEdges(fHPedestalCharge,nbins);
Index: /trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.h	(revision 3033)
+++ /trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.h	(revision 3034)
@@ -80,5 +80,6 @@
 
   // Fits
-  Bool_t FitCharge(Option_t *option="RQ0");  
+  Bool_t FitCharge(Option_t *option="RQ0");
+  void Renorm(const Float_t nslices);  
 
   // Draws
Index: /trunk/MagicSoft/Mars/manalysis/MPedestalCam.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 3033)
+++ /trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 3034)
@@ -47,6 +47,6 @@
   MPedestalPix &operator[](Int_t i) const;
   
-  MHPedestalPixel      &operator()(UInt_t i);
-  const MHPedestalPixel &operator()(UInt_t i) const;
+  MHPedestalPixel &operator()(UInt_t i);
+  MHPedestalPixel &operator()(UInt_t i) const;
   
   Bool_t SetupFill(const MParList *pList);
@@ -54,5 +54,5 @@
   Bool_t Finalize();
   
-  //  TObject *Clone(const char *) const;
+  TObject *Clone(const char *) const;
   
   // Setters
Index: /trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc	(revision 3033)
+++ /trunk/MagicSoft/Mars/manalysis/MPedestalPix.cc	(revision 3034)
@@ -59,4 +59,5 @@
 void MPedestalPix::InitUseHists()
 {
+
   fPedestal = 0.;
   fPedestalRms = 0.;
