Index: /trunk/MagicSoft/Mars/manalysis/MHPedestalCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHPedestalCam.cc	(revision 4946)
+++ /trunk/MagicSoft/Mars/manalysis/MHPedestalCam.cc	(revision 4947)
@@ -169,8 +169,4 @@
 // - MHCalibrationCam::fAverageHiGainSectors
 // 
-// Sets number of bins to MHCalibrationCam::fAverageNbins for:
-// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
-// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
-//
 Bool_t MHPedestalCam::ReInitHists(MParList *pList)
 {
@@ -273,5 +269,4 @@
 
         GetAverageHiGainArea(j).GetHGausHist()->SetTitle("Pedestals average Area Idx ");
-        GetAverageHiGainArea(j).SetNbins(fAverageNbins);
 
         InitPedHists((MHPedestalPix&)GetAverageHiGainArea(j),j,fExtractHiGainSlices);
@@ -291,5 +286,4 @@
 
         GetAverageLoGainArea(j).GetHGausHist()->SetTitle("Pedestals average Area Idx ");
-        GetAverageLoGainArea(j).SetNbins(fAverageNbins);
 
         InitPedHists((MHPedestalPix&)GetAverageLoGainArea(j),j,fExtractLoGainSlices);
@@ -309,5 +303,4 @@
 
           GetAverageHiGainSector(j).GetHGausHist()->SetTitle("Pedestals average Sector ");
-          GetAverageHiGainSector(j).SetNbins(fAverageNbins);
 
           InitPedHists((MHPedestalPix&)GetAverageHiGainSector(j),j,fExtractHiGainSlices);
@@ -327,5 +320,4 @@
 
           GetAverageLoGainSector(j).GetHGausHist()->SetTitle("Pedestals average Sector ");
-          GetAverageLoGainSector(j).SetNbins(fAverageNbins);
 
           InitPedHists((MHPedestalPix&)GetAverageLoGainSector(j),j,fExtractLoGainSlices);
@@ -351,4 +343,5 @@
 void MHPedestalCam::InitPedHists(MHPedestalPix &hist, const Int_t i, const Float_t nslices)
 {
+
   hist.InitBins();
   hist.ChangeHistId(i);
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 4946)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 4947)
@@ -99,5 +99,6 @@
       kCheckExtractionWindow,
       kCheckHistOverflow,
-      kCheckDeviatingBehavior
+      kCheckDeviatingBehavior,
+      kCheckOscillations
     };                                         // Possible Checks
 
@@ -123,4 +124,11 @@
   void   PrintUncalibrated( MBadPixelsPix::UncalibratedType_t typ, const char *text) const;
 
+  // Query checks
+  Bool_t IsCheckDeadPixels       () const { return TESTBIT(fCheckFlags,kCheckDeadPixels);        }
+  Bool_t IsCheckDeviatingBehavior() const { return TESTBIT(fCheckFlags,kCheckDeviatingBehavior); }
+  Bool_t IsCheckExtractionWindow () const { return TESTBIT(fCheckFlags,kCheckExtractionWindow);  }
+  Bool_t IsCheckHistOverflow     () const { return TESTBIT(fCheckFlags,kCheckHistOverflow);      }
+  Bool_t IsCheckOscillations     () const { return TESTBIT(fCheckFlags,kCheckOscillations);      }  
+  
   // Global fit results
   void   SetPheFitOK          ( const Int_t aidx, const Bool_t b=kTRUE ) {
@@ -140,9 +148,4 @@
       : CLRBIT(fPINDiodeFlags[idx], kPINDiodeFitOK); }
 
-  Bool_t IsCheckDeadPixels       () const { return TESTBIT(fCheckFlags,kCheckDeadPixels);        }
-  Bool_t IsCheckExtractionWindow () const { return TESTBIT(fCheckFlags,kCheckExtractionWindow);  }
-  Bool_t IsCheckHistOverflow     () const { return TESTBIT(fCheckFlags,kCheckHistOverflow);      }
-  Bool_t IsCheckDeviatingBehavior() const { return TESTBIT(fCheckFlags,kCheckDeviatingBehavior); }
-  
   Int_t  PreProcess (MParList *pList);
   Bool_t ReInit     (MParList *pList); 
@@ -162,4 +165,22 @@
   void SetChargeErrLimit    ( const Float_t f=fgChargeErrLimit         ) { fChargeErrLimit    = f;     }
   void SetChargeRelErrLimit ( const Float_t f=fgChargeRelErrLimit      ) { fChargeRelErrLimit = f;     }
+
+  // Checks
+  void SetCheckDeadPixels( const Bool_t b=kTRUE ) {
+    b ? SETBIT(fCheckFlags,kCheckDeadPixels)
+      : CLRBIT(fCheckFlags,kCheckDeadPixels); }
+  void SetCheckDeviatingBehavior( const Bool_t b=kTRUE ) {
+    b ? SETBIT(fCheckFlags,kCheckDeviatingBehavior)
+      : CLRBIT(fCheckFlags,kCheckDeviatingBehavior); }
+  void SetCheckExtractionWindow( const Bool_t b=kTRUE ) {
+    b ? SETBIT(fCheckFlags,kCheckExtractionWindow)
+      : CLRBIT(fCheckFlags,kCheckExtractionWindow); }
+  void SetCheckHistOverflow( const Bool_t b=kTRUE ) {
+    b ? SETBIT(fCheckFlags,kCheckHistOverflow)
+      : CLRBIT(fCheckFlags,kCheckHistOverflow); }
+  void SetCheckOscillations( const Bool_t b=kTRUE ) {
+    b ? SETBIT(fCheckFlags,kCheckOscillations)
+      : CLRBIT(fCheckFlags,kCheckOscillations); }
+
   void SetDebug             ( const Bool_t  b=kTRUE                    ) { b ? SETBIT(fFlags, kDebug) 
 									     : CLRBIT(fFlags, kDebug); }
@@ -172,18 +193,4 @@
   void SetPulserColor       ( const MCalibrationCam::PulserColor_t col ) { fPulserColor       = col;   }
 
-  // Checks
-  void SetCheckDeadPixels( const Bool_t b=kTRUE ) {
-    b ? SETBIT(fCheckFlags,kCheckDeadPixels)
-      : CLRBIT(fCheckFlags,kCheckDeadPixels); }
-  void SetCheckExtractionWindow( const Bool_t b=kTRUE ) {
-    b ? SETBIT(fCheckFlags,kCheckExtractionWindow)
-      : CLRBIT(fCheckFlags,kCheckExtractionWindow); }
-  void SetCheckHistOverflow( const Bool_t b=kTRUE ) {
-    b ? SETBIT(fCheckFlags,kCheckHistOverflow)
-      : CLRBIT(fCheckFlags,kCheckHistOverflow); }
-  void SetCheckDeviatingBehavior( const Bool_t b=kTRUE ) {
-    b ? SETBIT(fCheckFlags,kCheckDeviatingBehavior)
-      : CLRBIT(fCheckFlags,kCheckDeviatingBehavior); }
-
   ClassDef(MCalibrationChargeCalc, 1)   // Task calculating Calibration Containers and Quantum Efficiencies
 };
Index: /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc	(revision 4946)
+++ /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.cc	(revision 4947)
@@ -180,4 +180,7 @@
 // - fTimeLowerLimit           to fgTimeLowerLimit 
 // - fTimeUpperLimit           to fgTimeUpperLimit 
+// - fNbins to fgChargeHiGainLast-fgChargeHiGainFirst
+// - fFirst to fgChargeHiGainFirst
+// - fLast  to fgChargeHiGainLast 
 //
 MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
@@ -193,4 +196,11 @@
   SetTimeUpperLimit();
 
+  SetNbins((Int_t)(fgChargeHiGainLast-fgChargeHiGainFirst)/2);
+  SetFirst(fgChargeHiGainFirst);
+  SetLast (fgChargeHiGainLast );
+
+  SetLoGainNbins((Int_t)(fgChargeLoGainLast-fgChargeLoGainFirst)/2);
+  SetLoGainFirst(fgChargeLoGainFirst);
+  SetLoGainLast (fgChargeLoGainLast );
 }
 
@@ -323,7 +333,7 @@
         pix.SetAbsTimeLast(higainsamples-0.5);
 
-        pix.SetNbins((Int_t)(fgChargeHiGainLast-fgChargeHiGainFirst));
-        pix.SetFirst(fgChargeHiGainFirst);
-        pix.SetLast (fgChargeHiGainLast);
+        pix.SetNbins(fNbins);
+        pix.SetFirst(fFirst);
+        pix.SetLast (fLast);
 
         TH1F *h =  pix.GetHGausHist();
@@ -354,7 +364,7 @@
           pix.SetAbsTimeLast(logainsamples-0.5);
           
-          pix.SetNbins((Int_t)(fgChargeLoGainLast-fgChargeLoGainFirst));
-          pix.SetFirst(fgChargeLoGainFirst);
-          pix.SetLast (fgChargeLoGainLast);
+          pix.SetNbins(fLoGainNbins);
+          pix.SetFirst(fLoGainFirst);
+          pix.SetLast (fLoGainLast);
           
           TH1F *h =  pix.GetHGausHist();
@@ -400,7 +410,7 @@
         pix.SetAbsTimeLast(higainsamples-0.5);
 
-        pix.SetNbins((Int_t)(fgChargeHiGainLast-fgChargeHiGainFirst)*3);
-        pix.SetFirst(fgChargeHiGainFirst);
-        pix.SetLast (fgChargeHiGainLast);
+        pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
+        pix.SetFirst(fFirst);
+        pix.SetLast (fLast);
         
         TH1F *h =  pix.GetHGausHist();
@@ -444,7 +454,7 @@
         pix.SetAbsTimeLast(logainsamples-0.5);
 
-        pix.SetNbins((Int_t)(fgChargeLoGainLast-fgChargeLoGainFirst)*3);
-        pix.SetFirst(fgChargeLoGainFirst);
-        pix.SetLast(fgChargeLoGainLast);
+        pix.SetNbins(fLoGainNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
+        pix.SetFirst(fLoGainFirst);
+        pix.SetLast (fLoGainLast);
 
         TH1F *h =  pix.GetHGausHist();
@@ -501,7 +511,7 @@
           pix.SetAbsTimeLast(higainsamples-0.5);
           
-          pix.SetNbins((Int_t)(fgChargeHiGainLast-fgChargeHiGainFirst)*3);
-          pix.SetFirst(fgChargeHiGainFirst);
-          pix.SetLast (fgChargeHiGainLast);
+          pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
+          pix.SetFirst(fFirst);
+          pix.SetLast (fLast);
 
           TH1F *h =  pix.GetHGausHist();
@@ -534,7 +544,7 @@
           pix.SetAbsTimeLast(logainsamples-0.5);
           
-          pix.SetNbins((Int_t)(fgChargeLoGainLast-fgChargeLoGainFirst)*3);
-          pix.SetFirst(fgChargeLoGainFirst);
-          pix.SetLast (fgChargeLoGainLast);
+          pix.SetNbins(fLoGainNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
+          pix.SetFirst(fLoGainFirst);
+          pix.SetLast (fLoGainLast);
 
           TH1F *h =  pix.GetHGausHist();
Index: /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h
===================================================================
--- /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h	(revision 4946)
+++ /trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeCam.h	(revision 4947)
@@ -39,17 +39,21 @@
   static const Float_t gkLoGainOuterRefLines[7];     //!
 
-  MArrayD fSumhiarea  ;                             //!
-  MArrayD fSumloarea  ;                             //!
-  MArrayD fTimehiarea ;                             //!
-  MArrayD fTimeloarea ;                             //!
-  MArrayD fSumhisector;                             //!
-  MArrayD fSumlosector;                             //!
-  MArrayD fTimehisector;                            //!
-  MArrayD fTimelosector;                            //!
+  Int_t   fLoGainNbins;                              // Number of LoGain bins        
+  Axis_t  fLoGainFirst;                              // Lower histogram limit low gain
+  Axis_t  fLoGainLast;                               // Upper histogram limit low gain  
 
-  MArrayI fSathiarea  ;                             //!
-  MArrayI fSatloarea  ;                             //!
-  MArrayI fSathisector;                             //!
-  MArrayI fSatlosector;                             //!
+  MArrayD fSumhiarea  ;                              //!
+  MArrayD fSumloarea  ;                              //!
+  MArrayD fTimehiarea ;                              //!
+  MArrayD fTimeloarea ;                              //!
+  MArrayD fSumhisector;                              //!
+  MArrayD fSumlosector;                              //!
+  MArrayD fTimehisector;                             //!
+  MArrayD fTimelosector;                             //!
+
+  MArrayI fSathiarea  ;                              //!
+  MArrayI fSatloarea  ;                              //!
+  MArrayI fSathisector;                              //!
+  MArrayI fSatlosector;                              //!
 
   Float_t fTimeLowerLimit;            // Limit dist. to first signal slice (in units of FADC slices) 
@@ -72,5 +76,5 @@
 
   void   DrawDataCheckPixel(MHCalibrationChargePix &pix, const Float_t refline[]);
-  void   DisplayRefLines(const TH2D *hist, const Float_t refline[]) const;
+  void   DisplayRefLines   ( const TH2D *hist,           const Float_t refline[]) const;
   
 public:
@@ -81,6 +85,10 @@
   TObject *Clone(const char *name="") const;
 
-  void SetTimeLowerLimit    ( const Float_t f=fgTimeLowerLimit         ) { fTimeLowerLimit    = f;   }
-  void SetTimeUpperLimit    ( const Float_t f=fgTimeUpperLimit         ) { fTimeUpperLimit    = f;   }
+  void SetLoGainNbins       ( const Int_t  i )       { fLoGainNbins   = i; }
+  void SetLoGainFirst       ( const Axis_t f )       { fLoGainFirst   = f; }
+  void SetLoGainLast        ( const Axis_t f )       { fLoGainLast    = f; }  
+
+  void SetTimeLowerLimit    ( const Float_t f=fgTimeLowerLimit ) { fTimeLowerLimit = f; }
+  void SetTimeUpperLimit    ( const Float_t f=fgTimeUpperLimit ) { fTimeUpperLimit = f; }
   
   Bool_t GetPixelContent ( Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
@@ -94,11 +102,2 @@
 
 #endif
-
-
-
-
-
-
-
-
-
