Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 3173)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 3174)
@@ -9,4 +9,10 @@
    * mcalib/Makefile
    * mcalib/CalibLinkDef.h
+
+   * mcalib/MHCalibrationChargePix.[h,cc]
+     - new base class for the calibration charges histogram pixel. 
+       Derives from MH and can be filled with the MH with the MH 
+       functions. 
+
    * mcalib/MExtractPINDiode.[h,cc]
      - new signal extractor for the PIN Diode
Index: /trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h	(revision 3173)
+++ /trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h	(revision 3174)
@@ -17,4 +17,5 @@
 #pragma link C++ class MHCalibrationBlindPixel+;
 #pragma link C++ class MHCalibrationPixel+;
+#pragma link C++ class MHCalibrationChargePix+;
 
 #pragma link C++ class MMcCalibrationCalc++;
Index: /trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc	(revision 3173)
+++ /trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc	(revision 3174)
@@ -60,6 +60,4 @@
 //                MalibrationCam::SkipBlindPixelFits()  (skip all blind
 //                pixel fits)
-//                MalibrationCam::SkipPinDiodeFits()  (skip all PIN Diode
-//                fits)
 //
 //                Hi-Gain vs. Lo-Gain Calibration (very memory-intensive)
@@ -106,5 +104,4 @@
 
 #include "MCalibrationBlindPix.h"
-#include "MCalibrationPINDiode.h"
 
 ClassImp(MCalibrationCalc);
@@ -112,6 +109,6 @@
 using namespace std;
 
-const UInt_t MCalibrationCalc::fBlindPixelId = 559;
-const UInt_t MCalibrationCalc::fPINDiodeId   = 9999;
+const UInt_t MCalibrationCalc::fgBlindPixelId    = 559;
+const UInt_t MCalibrationCalc::fgPINDiodeId      = 9999;
 const Byte_t MCalibrationCalc::fgSaturationLimit = 254;
 const Int_t  MCalibrationCalc::fgBlindPixelFirst = 3;
@@ -149,6 +146,4 @@
     CLRBIT(fFlags, kHiGainOverFlow);
     CLRBIT(fFlags, kLoGainOverFlow);
-    // As long as we don't have the PIN Diode:
-    CLRBIT(fFlags, kUsePinDiodeFit);
 
     fBlindPixelFirst   = 0;
@@ -178,9 +173,4 @@
 {
     return fCalibrations->GetBlindPixel();
-}
-
-MCalibrationPINDiode *MCalibrationCalc::GetPINDiode() const
-{
-    return fCalibrations->GetPINDiode();
 }
 
@@ -313,8 +303,8 @@
 
         // Exclude the blind pixel and the PIN Diode from normal pixel calibration:
-        if (i == fBlindPixelId)
+        if (i == fgBlindPixelId)
           pix.SetExcluded();
 
-        if (i == fPINDiodeId)
+        if (i == fgPINDiodeId)
           pix.SetExcluded();
 
@@ -395,5 +385,4 @@
   //
   MCalibrationBlindPix &blindpixel = *(fCalibrations->GetBlindPixel());
-  MCalibrationPINDiode &pindiode   = *(fCalibrations->GetPINDiode());
   
   MRawEvtPixelIter pixel(fRawEvt);
@@ -457,5 +446,5 @@
         {
           
-        case fBlindPixelId:
+        case fgBlindPixelId:
 
           if (TESTBIT(fFlags,kUseBlindPixelFit))
@@ -556,27 +545,4 @@
           
           break;
-        case fPINDiodeId:
-
-          if (TESTBIT(fFlags,kUsePinDiodeFit))
-            {
-          
-              if (!pindiode.FillCharge(sumhi)) 
-                *fLog << warn 
-                      << "Overflow or Underflow occurred filling PINDiode: sum = " 
-                      << sumhi << endl;
-              
-              if (!pindiode.FillAbsTime(abstime))
-                 *fLog << warn 
-                       << "Overflow or Underflow occurred filling PINDiode abs. time = " 
-                       << abstime << endl;
-
-              if (!pindiode.FillGraphs(sumhi,sumlo))
-                *fLog << warn 
-                      << "Overflow or Underflow occurred filling PINDiode: eventnr = " << endl;
-              
-            } /* if use PIN Diode */
-          
-          //          break;
-              
         default:
               
@@ -662,29 +628,10 @@
       const Int_t   nslices     = fBlindPixelLast-fBlindPixelFirst+1;
       const Float_t sqrslice    = TMath::Sqrt((Float_t)nslices);
-      //
-      // retrieve the pedestal pix of the blind pixel
-      //
-      if (fPedestals->GetHistSize() > fBlindPixelId)
-        {
-          MHPedestalPixel &pedhist = (*fPedestals)(fBlindPixelId);
-          pedestal    = pedhist.GetChargeMean()*nslices;
-          pederr      = pedhist.GetChargeMeanErr()*nslices;
-          //
-          // 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
-          // 
-          pedsigma    = pedhist.GetChargeSigma()*nslices;
-          pedsigmaerr = pedhist.GetChargeSigmaErr()*nslices;
-        }
-      else
-        {
-          MPedestalPix    &pedpix  = (*fPedestals)[fBlindPixelId];
-          pedestal    = pedpix.GetPedestal()*nslices;
-          pederr      = pedpix.GetPedestalRms()*nslices/nentries;
-          pedsigma    = pedpix.GetPedestalRms()*sqrslice;
-          pedsigmaerr = pederr/2.;
-        }
+
+      MPedestalPix    &pedpix  = (*fPedestals)[fgBlindPixelId];
+      pedestal    = pedpix.GetPedestal()*nslices;
+      pederr      = pedpix.GetPedestalRms()*nslices/nentries;
+      pedsigma    = pedpix.GetPedestalRms()*sqrslice;
+      pedsigmaerr = pederr/2.;
       //
       // retrieve the histogram containers
@@ -779,12 +726,10 @@
 
 
-  if (TESTBIT(fFlags,kUsePinDiodeFit) && fCalibrations->IsPINDiodeMethodValid())
+  if (fCalibrations->IsPINDiodeMethodValid())
     {
       if (!fCalibrations->CalcFluxOutsidePlexiglass())
         {
           *fLog << err 
-                << "Could not calculate the number of photons from the blind pixel " << endl;
-          *fLog << err 
-                << "You can try to calibrate using the MCalibrationCalc::SkipPINDiodeFit()" << endl;
+                << "Could not calculate the number of photons from the PIN Diode " << endl;
           fCalibrations->SetPINDiodeMethodValid(kFALSE);
         }
Index: /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.cc	(revision 3174)
+++ /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePINDiode.cc	(revision 3174)
@@ -0,0 +1,233 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 11/2003 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHCalibrationChargePINDiode
+//
+//  Performs all the necessary fits to extract the mean number of photons
+//              out of the derived light flux
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationChargePINDiode.h"
+
+#include <TH1.h>
+#include <TPad.h>
+#include <TVirtualPad.h>
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MExtractedSignalPINDiode.h"
+
+ClassImp(MHCalibrationChargePINDiode);
+
+using namespace std;
+
+const Int_t   MHCalibrationChargePINDiode::fgChargeNbins     = 200;
+const Axis_t  MHCalibrationChargePINDiode::fgChargeFirst     = -0.5;
+const Axis_t  MHCalibrationChargePINDiode::fgChargeLast      = 199.5;
+const Int_t   MHCalibrationChargePINDiode::fgRmsChargeNbins  = 100;
+const Axis_t  MHCalibrationChargePINDiode::fgRmsChargeFirst  = 0.;
+const Axis_t  MHCalibrationChargePINDiode::fgRmsChargeLast   = 100.;  
+const Int_t   MHCalibrationChargePINDiode::fgAbsTimeNbins    = 30;
+const Axis_t  MHCalibrationChargePINDiode::fgAbsTimeFirst    = -0.5;
+const Axis_t  MHCalibrationChargePINDiode::fgAbsTimeLast     = 29.5;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+MHCalibrationChargePINDiode::MHCalibrationChargePINDiode(const char *name, const char *title)
+    : fHRmsCharge()
+{
+
+  fName  = name  ? name  : "MHCalibrationChargePINDiode";
+  fTitle = title ? title : "Fill the FADC sums of the PINDiode events and perform the fits";
+  
+  SetChargeNbins();
+  SetChargeFirst();
+  SetChargeLast();
+  
+  SetRmsChargeNbins();
+  SetRmsChargeFirst();
+  SetRmsChargeLast();
+  
+  SetAbsTimeNbins();
+  SetAbsTimeFirst();
+  SetAbsTimeLast();
+
+  fHRmsCharge.SetName("HRmsCharge");
+  fHRmsCharge.SetTitle("Distribution of Variances of summed FADC slices");  
+  fHRmsCharge.SetXTitle("RMS (sum) [FADC slices]");
+  fHRmsCharge.SetYTitle("Nr. of events");
+  fHRmsCharge.UseCurrentStyle();
+  fHRmsCharge.SetDirectory(NULL); 
+
+  fExtractSlices = 0;
+}
+
+
+void MHCalibrationChargePINDiode::Init()
+{
+
+  fHGausHist.SetName("HCalibrationChargePINDiode");
+  fHGausHist.SetTitle("Distribution of Summed FADC slices PIN Diode");  
+  fHGausHist.SetXTitle("Sum FADC Slices");
+  fHGausHist.SetYTitle("Nr. of events");
+  fHGausHist.SetBins(fChargeNbins,fChargeFirst,fChargeLast);
+  //  fHGausHist.Sumw2();
+
+  fHAbsTime.SetName("HAbsTimePINDiode");
+  fHAbsTime.SetTitle("Distribution of Absolute Arrival Times PIN Diode ");  
+  fHAbsTime.SetXTitle("Absolute Arrival Time [FADC slice nr]");
+  fHAbsTime.SetYTitle("Nr. of events");
+  fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
+
+  fHRmsCharge.SetBins(fRmsChargeNbins,fRmsChargeFirst,fRmsChargeLast);
+}
+
+
+void MHCalibrationChargePINDiode::Clear(Option_t *o)
+{
+  
+  fExtractSlices = 0;
+
+  MHCalibrationChargePix::Clear();
+  return;
+}
+
+Bool_t MHCalibrationChargePINDiode::SetupFill(const MParList *pList) 
+{
+
+  Init();
+  return kTRUE;
+}
+
+Bool_t MHCalibrationChargePINDiode::Fill(const MParContainer *par, const Stat_t w)
+{
+
+  MExtractedSignalPINDiode *extractor = (MExtractedSignalPINDiode*)par;
+  
+  if (!extractor)
+    {
+      *fLog << err << "No argument in MExtractedSignalPINDiode::Fill... abort." << endl;
+      return kFALSE;
+    }
+  
+  Float_t slices = (Float_t)extractor->GetNumFADCSamples();
+  
+  if (slices == 0.)
+    {
+      *fLog << err << "Number of used signal slices in MExtractedSignalPINDiode is zero  ... abort." 
+            << endl;
+      return kFALSE;
+    }
+  
+  if (fExtractSlices != 0. && slices != fExtractSlices )
+    {
+      gLog << err << "Number of used signal slices changed in MExtractedSignalCam  ... abort." 
+           << endl;
+      return kFALSE;
+    }
+  
+  fExtractSlices = slices;
+  
+  const Float_t signal = (float)extractor->GetExtractedSignal();
+  const Float_t time   = extractor->GetExtractedTime();
+  const Float_t rms    = extractor->GetExtractedRms();
+
+  *fLog << "signal " << signal << endl;
+  *fLog << "time " << time << endl;
+  *fLog << "rms  " << rms  << endl;
+
+
+  FillHistAndArray(signal);
+  FillAbsTime(time);
+  FillRmsCharge(rms);
+
+  return kTRUE;
+}
+
+Bool_t MHCalibrationChargePINDiode::Finalize() 
+{
+  
+  if (IsGausFitOK() || IsEmpty())
+    return kTRUE;
+    
+  FitGaus();
+  FitRmsCharge();
+  CreateFourierSpectrum();
+
+
+  return kTRUE;
+}
+
+Bool_t MHCalibrationChargePINDiode::FillRmsCharge(Float_t q)
+{
+  return fHRmsCharge.Fill(q) > -1;
+}
+
+// -----------------------------------------------------------
+//
+// Fits -- not yet implemented
+//
+Bool_t MHCalibrationChargePINDiode::FitRmsCharge(Option_t *option)
+{
+  return 1;
+}
+
+
+void MHCalibrationChargePINDiode::Draw(const Option_t *opt)
+{
+
+  TString option(opt);
+  option.ToLower();
+  
+  Int_t win = 1;
+
+  TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this,600, 600);
+
+  pad->SetTicks();
+  pad->SetBorderMode(0);
+    
+  if (option.Contains("RmsCharge"))
+    win++;
+
+  pad->Divide(1,win);
+  pad->cd(1);
+
+  *fLog << err << "HERE" << endl;
+
+  if (!IsEmpty())
+    pad->SetLogy();
+
+  MHGausEvents::Draw(opt);
+
+  if (win > 1)
+    {
+      pad->cd(2);
+      fHRmsCharge.Draw(opt);
+    }
+}
Index: /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc	(revision 3174)
+++ /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.cc	(revision 3174)
@@ -0,0 +1,230 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHCalibrationChargePix
+//
+//  Histogram class for charge calibration analysis. Holds the histogrammed
+//  summed FADC slices and some rough absolute timing. Calculates the mean 
+//  sum of FADC slices and its sigma
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationChargePix.h"
+
+#include <TH1.h>
+#include <TF1.h>
+
+#include <TVirtualPad.h>
+#include <TCanvas.h>
+#include <TPad.h>
+#include <TGraph.h>
+
+#include "MH.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHCalibrationChargePix);
+
+using namespace std;
+
+const Int_t   MHCalibrationChargePix::fgChargeNbins     = 2000;
+const Axis_t  MHCalibrationChargePix::fgChargeFirst     = -0.5;
+const Axis_t  MHCalibrationChargePix::fgChargeLast      = 1999.5;
+const Int_t   MHCalibrationChargePix::fgAbsTimeNbins    = 15;
+const Axis_t  MHCalibrationChargePix::fgAbsTimeFirst    = -0.5;
+const Axis_t  MHCalibrationChargePix::fgAbsTimeLast     = 14.5;
+
+const Int_t   MHCalibrationChargePix::fgPulserFrequency = 200;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+MHCalibrationChargePix::MHCalibrationChargePix(const char *name, const char *title)
+    : fHAbsTime()
+{ 
+  
+  fName  = name  ? name  : "MHCalibrationChargePix";
+  fTitle = title ? title : "Fill the FADC sums of calibration events and perform the fits";
+
+  SetChargeNbins();
+  SetChargeFirst();
+  SetChargeLast();
+
+  SetAbsTimeNbins();
+  SetAbsTimeFirst();
+  SetAbsTimeLast();
+
+  fHAbsTime.UseCurrentStyle();
+  fHAbsTime.SetDirectory(NULL); 
+
+  Clear();
+  
+  SetPulserFrequency();
+}
+
+void MHCalibrationChargePix::Init()
+{
+
+  fHGausHist.SetName("HCalibrationCharge");
+  fHGausHist.SetTitle("Distribution of Summed FADC slices Pixel");  
+  fHGausHist.SetXTitle("Sum FADC Slices");
+  fHGausHist.SetYTitle("Nr. of events");
+  fHGausHist.SetBins(fChargeNbins,fChargeFirst,fChargeLast);
+  fHGausHist.Sumw2();
+
+  fHAbsTime.SetName("HAbsTimePixel");
+  fHAbsTime.SetTitle("Distribution of Absolute Arrival Times Pixel ");  
+  fHAbsTime.SetXTitle("Absolute Arrival Time [FADC slice nr]");
+  fHAbsTime.SetYTitle("Nr. of events");
+  fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
+
+}
+
+    
+
+void MHCalibrationChargePix::Clear(Option_t *o)
+{
+
+  fPixId = -1;
+  
+  SetMeanTimeInFirstBin( kFALSE );
+  SetMeanTimeInLastBin(  kFALSE );  
+
+  MHGausEvents::Clear();
+  return;
+}
+
+
+void MHCalibrationChargePix::Reset()
+{
+}
+
+
+void MHCalibrationChargePix::ChangeHistId(Int_t id)
+{
+
+  fPixId = id;
+
+  fHGausHist.SetName(Form("%s%d", fHGausHist.GetName(), id));
+  fHGausHist.SetTitle(Form("%s%d", fHGausHist.GetTitle(), id));
+
+  fHAbsTime.SetName(Form("%s%d", fHAbsTime.GetName(), id));
+  fHAbsTime.SetTitle(Form("%s%d", fHAbsTime.GetTitle(), id));
+}
+
+void MHCalibrationChargePix::SetMeanTimeInFirstBin(const Bool_t b)
+{
+  b ? SETBIT(fFlags,kMeanTimeInFirstBin) : CLRBIT(fFlags,kMeanTimeInFirstBin);
+}
+
+void MHCalibrationChargePix::SetMeanTimeInLastBin(const Bool_t b)
+{
+  b ? SETBIT(fFlags,kMeanTimeInLastBin) : CLRBIT(fFlags,kMeanTimeInLastBin);
+}
+
+const Bool_t MHCalibrationChargePix::IsMeanTimeInFirstBin() const
+{
+  return TESTBIT(fFlags,kMeanTimeInFirstBin);
+}
+
+const Bool_t MHCalibrationChargePix::IsMeanTimeInLastBin() const
+{
+  return TESTBIT(fFlags,kMeanTimeInLastBin);
+}
+
+
+const Float_t MHCalibrationChargePix::GetIntegral() const 
+{ 
+   return fHGausHist.Integral("width");  
+}
+
+const Float_t MHCalibrationChargePix::GetAbsTimeMean() const 
+{
+  return fHAbsTime.GetMean();
+}
+
+const Float_t MHCalibrationChargePix::GetAbsTimeRms()  const 
+{
+  return fHAbsTime.GetRMS();
+}
+
+void  MHCalibrationChargePix::SetPulserFrequency(Float_t f)
+{
+  SetEventFrequency(f);
+}
+
+Bool_t MHCalibrationChargePix::FillAbsTime(Float_t t)
+{
+  return fHAbsTime.Fill(t) > -1;
+}
+
+
+void MHCalibrationChargePix::Draw(const Option_t *opt)
+{
+
+  TString option(opt);
+  option.ToLower();
+  
+  Int_t win = 1;
+  
+  TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this,600, 600);
+
+  pad->SetTicks();
+  pad->SetBorderMode(0);
+    
+  if (option.Contains("time"))
+    win++;
+
+  pad->SetTicks();
+  pad->SetBorderMode(0);
+  pad->Divide(1,win);
+  pad->cd(1);
+
+  if (!IsEmpty())
+    pad->SetLogy();
+
+  MHGausEvents::Draw(opt);
+
+  if (win > 1)
+    {
+      pad->cd(2);
+      fHAbsTime.Draw(opt);
+    }
+}
+
+void MHCalibrationChargePix::BypassFit()
+{
+
+  //
+  // In case, we do not obtain reasonable values 
+  // with the fit, we take the histogram values
+  //
+  SetMean(fHGausHist.GetMean());
+  SetMeanErr(fHGausHist.GetRMS()/fHGausHist.GetEntries());
+  SetSigma(fHGausHist.GetRMS());
+  SetSigmaErr(fHGausHist.GetRMS()/fHGausHist.GetEntries()/2.);
+}
+
Index: /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.h
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.h	(revision 3174)
+++ /trunk/MagicSoft/Mars/mcalib/MHCalibrationChargePix.h	(revision 3174)
@@ -0,0 +1,92 @@
+#ifndef MARS_MHCalibrationChargePix
+#define MARS_MHCalibrationChargePix
+
+#ifndef MARS_MHGausEvents
+#include "MHGausEvents.h"
+#endif
+
+class TH1F;
+class MHCalibrationChargePix : public MHGausEvents
+{
+
+private:
+
+  static const Int_t   fgChargeNbins;
+  static const Axis_t  fgChargeFirst;
+  static const Axis_t  fgChargeLast;  
+
+  static const Int_t   fgAbsTimeNbins;
+  static const Axis_t  fgAbsTimeFirst;
+  static const Axis_t  fgAbsTimeLast;
+
+protected:
+
+  static const Int_t   fgPulserFrequency;
+
+  Int_t    fPixId;
+
+  TH1F     fHAbsTime;          // Histogram to hold the absolute arrival times in number of FADC slices
+                          
+  Int_t    fChargeNbins;
+  Axis_t   fChargeFirst;
+  Axis_t   fChargeLast;
+
+  Int_t    fAbsTimeNbins;
+  Axis_t   fAbsTimeFirst;
+  Axis_t   fAbsTimeLast;
+
+  enum { kMeanTimeInFirstBin, kMeanTimeInLastBin }; // Bits to hold information about arrival time results
+  
+  Byte_t fFlags;                    //  Byte to hold the arrival time results
+  
+public:
+
+  MHCalibrationChargePix(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationChargePix() {}
+
+  virtual void Clear(Option_t *o="");
+  virtual void Reset();  
+  virtual void Init();
+  
+  // Setters
+  virtual void SetChargeNbins(const Int_t  bins =fgChargeNbins)    { fChargeNbins = bins; }
+  virtual void SetChargeFirst(const Axis_t first=fgChargeFirst)    { fChargeFirst = first; }
+  virtual void SetChargeLast( const Axis_t last =fgChargeLast)     { fChargeLast  = last; }
+  
+  virtual void SetAbsTimeNbins(const Int_t  bins =fgAbsTimeNbins)    { fAbsTimeNbins = bins; }
+  virtual void SetAbsTimeFirst(const Axis_t first=fgAbsTimeFirst)    { fAbsTimeFirst = first; }
+  virtual void SetAbsTimeLast( const Axis_t last =fgAbsTimeLast)     { fAbsTimeLast  = last; }
+
+  void SetPulserFrequency(Float_t f=fgPulserFrequency);
+
+  // Setters ONLY for MC:
+  void  SetMeanTimeInFirstBin(const Bool_t b);
+  void  SetMeanTimeInLastBin( const Bool_t b);
+
+  // Getters
+  TH1F *GetHAbsTime()                  { return &fHAbsTime;  }
+  const TH1F *GetHAbsTime()            const { return &fHAbsTime;  }
+
+  const Float_t  GetIntegral() const;
+  
+  const Float_t  GetAbsTimeMean() const;
+  const Float_t  GetAbsTimeRms() const;
+
+  const Bool_t IsMeanTimeInFirstBin() const;
+  const Bool_t IsMeanTimeInLastBin() const;
+  
+  void ChangeHistId(Int_t i);
+  
+  // Fill histos
+  Bool_t FillAbsTime(const Float_t t);
+
+  // Fits
+  void BypassFit();
+  
+  // Draws
+  virtual void Draw(Option_t *opt="");
+  
+  ClassDef(MHCalibrationChargePix, 1)     // Base class for charge calibrated pixel
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/mcalib/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mcalib/Makefile	(revision 3173)
+++ /trunk/MagicSoft/Mars/mcalib/Makefile	(revision 3174)
@@ -47,4 +47,5 @@
            MHCalibrationPINDiode.cc \
            MHCalibrationPixel.cc \
+           MHCalibrationChargePix.cc \
 	   MMcCalibrationCalc.cc \
 	   MExtractPINDiode.cc \
