Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 6791)
+++ trunk/MagicSoft/Mars/Changelog	(revision 6792)
@@ -21,4 +21,11 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2005/03/08 Markus Gaug
+
+   * mhcalib/MHPedestalCam.[h,cc]
+     - introduce new parameter "fFitStart" to decide from outside where
+       to start fitting the pedestals.
+
+
  2005/03/07 Markus Gaug
 
Index: trunk/MagicSoft/Mars/mhcalib/MHPedestalCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHPedestalCam.cc	(revision 6791)
+++ trunk/MagicSoft/Mars/mhcalib/MHPedestalCam.cc	(revision 6792)
@@ -119,7 +119,7 @@
 using namespace std;
 
-const Int_t   MHPedestalCam::fgNbins      = 200;
-const Axis_t  MHPedestalCam::fgFirst      = -49.5;
-const Axis_t  MHPedestalCam::fgLast       = 150.5;
+const Int_t   MHPedestalCam::fgNbins      =  50;
+const Axis_t  MHPedestalCam::fgFirst      = -57.5;
+const Axis_t  MHPedestalCam::fgLast       = 192.5;
 const TString MHPedestalCam::gsHistName   = "Pedestal";
 const TString MHPedestalCam::gsHistTitle  = "Pedestal";
@@ -166,4 +166,5 @@
   SetHistYTitle(gsHistYTitle.Data());
 
+  SetFitStart();
 }
 
@@ -280,5 +281,6 @@
   
 
-  fPedestalsOut = (MPedestalCam*)pList->FindObject(AddSerialNumber(fNamePedestalCamOut),"MPedestalCam");
+  if (!fPedestalsOut)
+    fPedestalsOut = (MPedestalCam*)pList->FindObject(AddSerialNumber(fNamePedestalCamOut),"MPedestalCam");
 
   if (!fPedestalsOut)
@@ -558,9 +560,5 @@
       //      else
       TH1F *gaush = hist.GetHGausHist();
-      hist.FitGaus("RQ0",-0.5,gaush->GetBinCenter(gaush->GetXaxis()->GetLast()));
-      //
-      // 3) Take histogram means and RMS
-      //
-      hist.BypassFit();
+      hist.FitGaus("RQ0",fFitStart,gaush->GetBinCenter(gaush->GetXaxis()->GetLast()));
       //
       // 4) Check for oscillations
@@ -596,9 +594,6 @@
       // 2) Fit the Hi Gain histograms with a Gaussian
       //
-      hist.FitGaus();
-      //
-      // 3) Take histogram means and RMS
-      //
-      hist.BypassFit();
+      TH1F *gaush = hist.GetHGausHist();
+      hist.FitGaus("RQ0",fFitStart,gaush->GetBinCenter(gaush->GetXaxis()->GetLast()));
       //
       // 4) Check for oscillations
@@ -640,9 +635,6 @@
       // 2) Fit the Hi Gain histograms with a Gaussian
       //
-      hist.FitGaus();
-      //
-      // 3) Take histogram means and RMS
-      //
-      hist.BypassFit();
+      TH1F *gaush = hist.GetHGausHist();
+      hist.FitGaus("RQ0",fFitStart,gaush->GetBinCenter(gaush->GetXaxis()->GetLast()));
       //
       // 4) Check for oscillations
@@ -698,6 +690,9 @@
       
       MCalibrationPix &pix = (*fCam)[i];
+      MPedestalPix    &ped = (*fPedestalsOut)[i];
       pix.SetHiGainMean     ( pix.GetHiGainMean()     / fExtractHiGainSlices  );
       pix.SetLoGainMean     ( pix.GetLoGainMean()     / fExtractHiGainSlices  );
+
+      ped.SetPedestal(pix.GetHiGainMean());
       //
       // Mean error goes with PedestalRMS/Sqrt(entries) -> scale with sqrt(slices)
@@ -705,4 +700,5 @@
       pix.SetHiGainMeanVar  ( pix.GetHiGainMeanVar()  / fExtractHiGainSlices );
       pix.SetLoGainMeanVar  ( pix.GetHiGainMeanVar()  / fExtractHiGainSlices );
+
       //
       // Sigma goes like PedestalRMS -> scale with sqrt(slices)    
@@ -710,4 +706,6 @@
       pix.SetHiGainSigma    ( pix.GetHiGainSigma()    / sqslices  );
       pix.SetLoGainSigma    ( pix.GetLoGainSigma()    / sqslices  );
+
+      ped.SetPedestalRms(pix.GetHiGainSigma());
       //
       // Sigma error goes like PedestalRMS/2.(entries) -> scale with sqrt(slices)
Index: trunk/MagicSoft/Mars/mhcalib/MHPedestalCam.h
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHPedestalCam.h	(revision 6791)
+++ trunk/MagicSoft/Mars/mhcalib/MHPedestalCam.h	(revision 6792)
@@ -39,4 +39,6 @@
   Bool_t  fRenorm;                        // Flag if the results will be re-normalized
 
+  Axis_t  fFitStart;                      // Charge value to start the fitting procedure
+  
   MArrayD fSum;                           //! sum of values  
   MArrayD fSumSquare;                     //! sum of squared values
@@ -69,7 +71,8 @@
   void ResetHists();
 
-  void SetNamePedestalCamOut(const char *name) { fNamePedestalCamOut = name; }
-  void SetPedestalsOut ( MPedestalCam *cam) { fPedestalsOut = cam; }
-  void SetRenorm         (const Bool_t b=kTRUE )  {  fRenorm = b; }
+  void SetFitStart          ( const Axis_t a=-0.5  ) { fFitStart = a;  }
+  void SetNamePedestalCamOut( const char *name     ) { fNamePedestalCamOut = name; }
+  void SetPedestalsOut      ( MPedestalCam *cam    ) { fPedestalsOut = cam; }
+  void SetRenorm            ( const Bool_t b=kTRUE ) { fRenorm = b; }
   
   ClassDef(MHPedestalCam, 1)	// Histogram class for Charge Camera Pedestals 
