Index: trunk/MagicSoft/Mars/mpedestal/MHPedestalPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MHPedestalPix.cc	(revision 5000)
+++ trunk/MagicSoft/Mars/mpedestal/MHPedestalPix.cc	(revision 5000)
@@ -0,0 +1,134 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHPedestalPix
+//
+//  Histogram class for pedestal analysis. 
+//  Stores and fits the pedestals taken from MPedestalPix on an event-by-event
+//  basis. The results are re-normalized to a value per slice with the formulae:
+//
+// - Mean Pedestal        / slice = Mean Pedestal        / Number slices
+// - Mean Pedestal Error  / slice = Mean Pedestal Error  / Number slices
+// - Sigma Pedestal       / slice = Sigma Pedestal       / Sqrt (Number slices)
+// - Sigma Pedestal Error / slice = Sigma Pedestal Error / Sqrt (Number slices)
+// 
+//  Derives from MHCalibrationPix, fits the pedestals to a Gaussian and performs
+//  a Fourier analysis.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHPedestalPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include <TH1.h>
+
+ClassImp(MHPedestalPix);
+
+using namespace std;
+//
+const Int_t   MHPedestalPix::fgChargeNbins    = 500;
+const Axis_t  MHPedestalPix::fgChargeFirst    = -49.5;
+const Axis_t  MHPedestalPix::fgChargeLast     = 449.5;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets: 
+// - the default number for fNbins        (fgChargeNbins)
+// - the default number for fFirst        (fgChargeFirst)
+// - the default number for fLast         (fgChargeLast)
+//
+// - the default name of the  fHGausHist ("HPedestalCharge")
+// - the default title of the fHGausHist ("Distribution of Summed FADC Pedestal slices Pixel ")
+// - the default x-axis title for fHGausHist ("Sum FADC Slices")
+// - the default y-axis title for fHGausHist ("Nr. of events")
+// - TH1::Sumw2() for fHGausHist
+//
+// Initializes:
+// - fNSlices to 1
+// - fProbLimit to 0.01
+//
+MHPedestalPix::MHPedestalPix(const char *name, const char *title) 
+    : fNSlices(1.)
+{ 
+
+  fName  = name  ? name  : "MHPedestalPix";
+  fTitle = title ? title : "Histogrammed Pedestal events";
+
+  SetNbins( fgChargeNbins );
+  SetFirst( fgChargeFirst );
+  SetLast(  fgChargeLast  );
+
+  SetProbLimit(0.01);
+
+  // Create a large number of bins, later we will rebin
+  fHGausHist.SetName("HPedestalCharge");
+  fHGausHist.SetTitle("Distribution of Summed FADC Pedestal Slices Pixel ");
+  fHGausHist.SetXTitle("Sum FADC Slices");
+  fHGausHist.SetYTitle("Nr. of events");
+  fHGausHist.Sumw2();
+
+}
+
+// --------------------------------------------------------------------------
+// 
+// If mean and sigma have not yet been set, returns.
+//
+// Renormalizes the pedestal fit results by the following formulae:
+//
+// - Mean Pedestal        / slice = Mean Pedestal        / Number slices
+// - Mean Pedestal Error  / slice = Mean Pedestal Error  / Number slices
+// - Sigma Pedestal       / slice = Sigma Pedestal       / Sqrt (Number slices)
+// - Sigma Pedestal Error / slice = Sigma Pedestal Error / Sqrt (Number slices)
+// 
+void MHPedestalPix::Renorm()
+{
+
+  //
+  // One never knows...
+  //
+  if (fNSlices <= 0)
+    return;
+
+  const Float_t sqslices = TMath::Sqrt(fNSlices);
+
+  SetMean     ( GetMean()    / fNSlices  );
+  //
+  // Mean error goes with PedestalRMS/Sqrt(entries) -> scale with slices
+  // 
+  SetMeanErr  ( GetMeanErr() / fNSlices  );
+  //
+  // Sigma goes like PedestalRMS -> scale with sqrt(slices)    
+  //
+  SetSigma    ( GetSigma()   / sqslices  );
+  //
+  // Sigma error goes like PedestalRMS/2.(entries) -> scale with sqrt(slices)
+  //
+  SetSigmaErr ( GetSigmaErr() / sqslices );
+  
+}
+
Index: trunk/MagicSoft/Mars/mpedestal/MHPedestalPix.h
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MHPedestalPix.h	(revision 5000)
+++ trunk/MagicSoft/Mars/mpedestal/MHPedestalPix.h	(revision 5000)
@@ -0,0 +1,36 @@
+#ifndef MARS_MHPedestalPix
+#define MARS_MHPedestalPix
+
+#ifndef MARS_MHCalibrationPix
+#include "MHCalibrationPix.h"
+#endif
+
+class MHPedestalPix : public MHCalibrationPix
+{
+
+private:
+
+  static const Int_t   fgChargeNbins;        // Default for fNbins   (now set to: 450  )
+  static const Axis_t  fgChargeFirst;        // Default for fFirst   (now set to: -0.5 )
+  static const Axis_t  fgChargeLast;         // Default for fLast    (now set to: 449.5)
+
+  Float_t fNSlices;                         // Number of FADC slices summed in extraction
+  
+public:
+
+  MHPedestalPix(const char *name=NULL, const char *title=NULL);
+  ~MHPedestalPix() {}
+
+  // Setters
+  void SetNSlices( const Float_t n)    { fNSlices = n ; }
+  
+  // Getters
+  Float_t GetNSlices() const       { return fNSlices; }
+  
+  // Others
+  void Renorm();  
+
+  ClassDef(MHPedestalPix, 1)     // Histogram class for Charge Pedestal Pixel
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mpedestal/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/Makefile	(revision 4996)
+++ trunk/MagicSoft/Mars/mpedestal/Makefile	(revision 5000)
@@ -20,5 +20,5 @@
 #
 INCLUDES = -I. -I../mbase -I../mgui -I../mraw -I../mmc -I../mgeom \
-           -I../msignal -I../manalysis -I../mbadpixels
+           -I../msignal -I../manalysis -I../mbadpixels -I../mhcalib
 # MCamEvent
 # MMcPedestalCopy   (MRawRunHeader)
@@ -38,4 +38,6 @@
            MPedestalCam.cc \
 	   MPedestalPix.cc \
+           MHPedestalCam.cc \
+	   MHPedestalPix.cc \
 	   MPedCalcFromData.cc
 
Index: trunk/MagicSoft/Mars/mpedestal/PedestalLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/PedestalLinkDef.h	(revision 4996)
+++ trunk/MagicSoft/Mars/mpedestal/PedestalLinkDef.h	(revision 5000)
@@ -5,16 +5,18 @@
 #pragma link off all functions;
 
-#pragma link C++ class MMcPedestalCopy++;
-#pragma link C++ class MMcPedestalNSBAdd++;
+#pragma link C++ class MMcPedestalCopy+;
+#pragma link C++ class MMcPedestalNSBAdd+;
 
-#pragma link C++ class MPedPhotCalc++;
-#pragma link C++ class MPedPhotCam++;
-#pragma link C++ class MPedPhotPix++;
+#pragma link C++ class MPedPhotCalc+;
+#pragma link C++ class MPedPhotCam+;
+#pragma link C++ class MPedPhotPix+;
 
-#pragma link C++ class MPedCalcPedRun++;
-#pragma link C++ class MPedCalcFromLoGain++;
-#pragma link C++ class MPedestalCam++;
-#pragma link C++ class MPedestalPix++;
-#pragma link C++ class MPedCalcFromData++;
+#pragma link C++ class MPedCalcPedRun+;
+#pragma link C++ class MPedCalcFromLoGain+;
+#pragma link C++ class MPedestalCam+;
+#pragma link C++ class MPedestalPix+;
+#pragma link C++ class MHPedestalCam+;
+#pragma link C++ class MHPedestalPix+;
+#pragma link C++ class MPedCalcFromData+;
 
 #endif
