Index: trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.cc	(revision 2612)
+++ trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.cc	(revision 2627)
@@ -69,9 +69,10 @@
 
     // Create a large number of bins, later we will rebin
-    fBlindPixelChargefirst = 0;
+    fBlindPixelChargefirst = -1000.;
     fBlindPixelChargelast  = gkStartBlindPixelBinNr;
-    fBlindPixelChargenbins = gkStartBlindPixelBinNr;
-
-    fHBlindPixelCharge = new TH1I("HBlindPixelCharge","Distribution of Summed FADC Slices",fBlindPixelChargenbins,fBlindPixelChargefirst,fBlindPixelChargelast);
+    fBlindPixelChargenbins = gkStartBlindPixelBinNr+(int)fBlindPixelChargefirst;
+
+    fHBlindPixelCharge = new TH1F("HBlindPixelCharge","Distribution of Summed FADC Slices",
+				  fBlindPixelChargenbins,fBlindPixelChargefirst,fBlindPixelChargelast);
     fHBlindPixelCharge->SetXTitle("Sum FADC Slices");
     fHBlindPixelCharge->SetYTitle("Nr. of events");
@@ -313,5 +314,5 @@
   const Double_t lambda_guess = 0.2;
   const Double_t mu_0_guess = fHBlindPixelCharge->GetBinCenter(fHBlindPixelCharge->GetMaximumBin());
-  const Double_t si_0_guess = mu_0_guess/10.;
+  const Double_t si_0_guess = mu_0_guess/5.;
   const Double_t mu_1_guess = mu_0_guess + 50.;
   const Double_t si_1_guess = si_0_guess + si_0_guess;
Index: trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.h	(revision 2612)
+++ trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.h	(revision 2627)
@@ -32,5 +32,5 @@
 private:
 
-  TH1I* fHBlindPixelCharge;        //-> Histogram with the single Phe spectrum
+  TH1F* fHBlindPixelCharge;        //-> Histogram with the single Phe spectrum
   TH1F* fHBlindPixelErrCharge;     //-> Variance of summed FADC slices
   TH1I* fHBlindPixelTime;        //-> Variance of summed FADC slices
@@ -83,7 +83,7 @@
   ~MHCalibrationBlindPixel();
 
-  Bool_t FillBlindPixelCharge(Int_t q)         { return fHBlindPixelCharge->Fill(q) > -1;  }  
-  Bool_t FillErrBlindPixelCharge(Float_t errq) { return fHBlindPixelErrCharge->Fill(errq) > -1; }
-  Bool_t FillBlindPixelTime(Int_t t)         { return fHBlindPixelTime->Fill(t) > -1;  }
+  Bool_t FillBlindPixelCharge(Float_t q)             { return fHBlindPixelCharge->Fill(q) > -1;  }  
+  Bool_t FillErrBlindPixelCharge(Float_t errq)       { return fHBlindPixelErrCharge->Fill(errq) > -1; }
+  Bool_t FillBlindPixelTime(Int_t t)                 { return fHBlindPixelTime->Fill(t) > -1;  }
   Bool_t FillBlindPixelChargevsN(Stat_t rq, Int_t t) { return fHBlindPixelChargevsN->Fill(t,rq) > -1;  }  
   
@@ -123,9 +123,8 @@
   void ChangeFitFunc(BlindPixelFitFunc fitfunc, Int_t par=5);
 
-
   void CutAllEdges();
   void Draw(Option_t *option="");
 
-  ClassDef(MHCalibrationBlindPixel, 0) 
+  ClassDef(MHCalibrationBlindPixel, 1) 
 };
 
Index: trunk/MagicSoft/Mars/mhist/MHCalibrationConfig.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCalibrationConfig.h	(revision 2612)
+++ trunk/MagicSoft/Mars/mhist/MHCalibrationConfig.h	(revision 2627)
@@ -7,5 +7,5 @@
 //                                                                         //
 // Contains all configuration data of the Calibration                      //
-//                                                                         //
+//                       i                                                  //
 /////////////////////////////////////////////////////////////////////////////
 
Index: trunk/MagicSoft/Mars/mhist/MHCalibrationPINDiode.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCalibrationPINDiode.cc	(revision 2612)
+++ trunk/MagicSoft/Mars/mhist/MHCalibrationPINDiode.cc	(revision 2627)
@@ -67,9 +67,10 @@
 
     // Create a large number of bins, later we will rebin
-    fChargeFirst = 0;
-    fChargeLast  = gkStartPINDiodeBinNr;
-    fChargeNbins = gkStartPINDiodeBinNr;
+    fChargeFirstHiGain = -1000.;
+    fChargeLastHiGain  = gkStartPINDiodeBinNr;
+    fChargeNbinsHiGain = gkStartPINDiodeBinNr;
 
-    fHPCharge = new TH1I("HPCharge","Distribution of Summed FADC Slices",fChargeNbins,fChargeFirst,fChargeLast);
+    fHPCharge = new TH1I("HPCharge","Distribution of Summed FADC Slices",
+			 fChargeNbinsHiGain,fChargeFirstHiGain,fChargeLastHiGain);
     fHPCharge->SetXTitle("Sum FADC Slices");
     fHPCharge->SetYTitle("Nr. of events");
Index: trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc	(revision 2612)
+++ trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc	(revision 2627)
@@ -65,5 +65,11 @@
 	fTimeGausFit(NULL), 
 	fFitLegend(NULL),
-	fLowerFitRange(0.),
+	fLowerFitRange(-2000.),
+	fChargeFirstHiGain(-2000.5),
+	fChargeLastHiGain(9999.5),
+	fChargeNbinsHiGain(12000),
+	fChargeFirstLoGain(-2000.5),
+	fChargeLastLoGain(9999.5),
+	fChargeNbinsLoGain(1200),
         fFitOK(kFALSE),
         fChargeChisquare(-1.),
@@ -72,5 +78,6 @@
         fTimeChisquare(-1.),
         fTimeProb(-1.),
-        fTimeNdf(-1)
+        fTimeNdf(-1),
+	fUseLoGain(kFALSE)
 { 
 
@@ -79,15 +86,19 @@
 
     // Create a large number of bins, later we will rebin
-    fChargeFirst = -0.5;
-    fChargeLast  = 10000. - 0.5;
-    fChargeNbins = 20000;
-
-    fHCharge = new TH1I("HCharge","Distribution of Summed FADC Slices Pixel ",
-                   fChargeNbins,fChargeFirst,fChargeLast);
-    fHCharge->SetXTitle("Sum FADC Slices");
-    fHCharge->SetYTitle("Nr. of events");
-    fHCharge->Sumw2();
-
-    fHCharge->SetDirectory(NULL);
+    fHChargeHiGain = new TH1F("HChargeHiGain","Distribution of Summed FADC Hi Gain Slices Pixel ",
+			      fChargeNbinsHiGain,fChargeFirstHiGain,fChargeLastHiGain);
+    fHChargeHiGain->SetXTitle("Sum FADC Slices (Hi Gain)");
+    fHChargeHiGain->SetYTitle("Nr. of events");
+    fHChargeHiGain->Sumw2();
+
+    fHChargeHiGain->SetDirectory(NULL);
+
+    fHChargeLoGain = new TH1F("HChargeLoGain","Distribution of Summed FADC Lo Gain Slices Pixel ",
+			      fChargeNbinsLoGain,fChargeFirstLoGain,fChargeLastLoGain);
+    fHChargeLoGain->SetXTitle("Sum FADC Slices (Lo Gain)");
+    fHChargeLoGain->SetYTitle("Nr. of events");
+    fHChargeLoGain->Sumw2();
+
+    fHChargeLoGain->SetDirectory(NULL);
 
     Axis_t tfirst = -0.5;
@@ -95,13 +106,19 @@
     Int_t  ntbins = 16;
 
-    fHTime = new TH1I("HTime","Distribution of Mean Arrival Times Pixel ",
-                  ntbins,tfirst,tlast);
-    fHTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
-    fHTime->SetYTitle("Nr. of events");
-    fHTime->Sumw2();
-
-    fHTime->SetDirectory(NULL);
-
-    TString qvsntitle = "Sum of Charges vs. Event Number Pixel ";
+    fHTimeHiGain = new TH1I("HTimeHiGain","Distribution of Mean Arrival Hi Gain Times Pixel ",
+			    ntbins,tfirst,tlast);
+    fHTimeHiGain->SetXTitle("Mean Arrival Times [Hi Gain FADC slice nr]");
+    fHTimeHiGain->SetYTitle("Nr. of events");
+    fHTimeHiGain->Sumw2();
+
+    fHTimeHiGain->SetDirectory(NULL);
+
+    fHTimeLoGain = new TH1I("HTimeLoGain","Distribution of Mean Arrival Lo Gain Times Pixel ",
+			    ntbins,tfirst,tlast);
+    fHTimeLoGain->SetXTitle("Mean Arrival Times [Lo Gain FADC slice nr]");
+    fHTimeLoGain->SetYTitle("Nr. of events");
+    fHTimeLoGain->Sumw2();
+
+    fHTimeLoGain->SetDirectory(NULL);
 
     // We define a reasonable number and later enlarge it if necessary
@@ -110,10 +127,17 @@
     Axis_t nlast  = (Axis_t)nqbins - 0.5;
 
-    fHChargevsN = new TH1I("HChargevsN",qvsntitle.Data(),
-                     nqbins,nfirst,nlast);
-    fHChargevsN->SetXTitle("Event Nr.");
-    fHChargevsN->SetYTitle("Sum of FADC slices");
-
-    fHChargevsN->SetDirectory(NULL);
+    fHChargevsNHiGain = new TH1I("HChargevsNHiGain","Sum of Hi Gain Charges vs. Event Number Pixel ",
+				 nqbins,nfirst,nlast);
+    fHChargevsNHiGain->SetXTitle("Event Nr.");
+    fHChargevsNHiGain->SetYTitle("Sum of Hi Gain FADC slices");
+
+    fHChargevsNHiGain->SetDirectory(NULL);
+
+    fHChargevsNLoGain = new TH1I("HChargevsNLoGain","Sum of Lo Gain Charges vs. Event Number Pixel ",
+				 nqbins,nfirst,nlast);
+    fHChargevsNLoGain->SetXTitle("Event Nr.");
+    fHChargevsNLoGain->SetYTitle("Sum of Lo Gain FADC slices");
+
+    fHChargevsNLoGain->SetDirectory(NULL);
 
 }
@@ -122,7 +146,11 @@
 {
 
-  delete fHCharge;
-  delete fHTime;
-  delete fHChargevsN;
+  delete fHChargeHiGain;
+  delete fHTimeHiGain;
+  delete fHChargevsNHiGain;
+
+  delete fHChargeLoGain;
+  delete fHTimeLoGain;
+  delete fHChargevsNLoGain;
 
   if (fChargeGausFit)
@@ -141,27 +169,52 @@
   fPixId = id;
   
-  TString nameQ = TString(fHCharge->GetName());
-  nameQ += id;
-  fHCharge->SetName(nameQ.Data());
-
-  TString nameT = TString(fHTime->GetName());
-  nameT += id;
-  fHTime->SetName(nameT.Data());
-
-  TString nameQvsN  = TString(fHChargevsN->GetName());
-  nameQvsN += id;
-  fHChargevsN->SetName(nameQvsN.Data());
-
-  TString titleQ = TString(fHCharge->GetTitle());
-  titleQ += id;
-  fHCharge->SetTitle(titleQ.Data());
-
-  TString titleT = TString(fHTime->GetTitle());
-  titleT += id;
-  fHTime->SetTitle(titleT.Data());
-
-  TString titleQvsN  = TString(fHChargevsN->GetTitle());
-  titleQvsN += id;
-  fHChargevsN->SetTitle(titleQvsN.Data());
+  TString nameQHiGain = TString(fHChargeHiGain->GetName());
+  nameQHiGain += id;
+  fHChargeHiGain->SetName(nameQHiGain.Data());
+
+  TString nameTHiGain = TString(fHTimeHiGain->GetName());
+  nameTHiGain += id;
+  fHTimeHiGain->SetName(nameTHiGain.Data());
+
+  TString nameQvsNHiGain  = TString(fHChargevsNHiGain->GetName());
+  nameQvsNHiGain += id;
+  fHChargevsNHiGain->SetName(nameQvsNHiGain.Data());
+
+  TString titleQHiGain = TString(fHChargeHiGain->GetTitle());
+  titleQHiGain += id;
+  fHChargeHiGain->SetTitle(titleQHiGain.Data());
+
+  TString titleTHiGain = TString(fHTimeHiGain->GetTitle());
+  titleTHiGain += id;
+  fHTimeHiGain->SetTitle(titleTHiGain.Data());
+
+  TString titleQvsNHiGain  = TString(fHChargevsNHiGain->GetTitle());
+  titleQvsNHiGain += id;
+  fHChargevsNHiGain->SetTitle(titleQvsNHiGain.Data());
+
+
+  TString nameQLoGain = TString(fHChargeLoGain->GetName());
+  nameQLoGain += id;
+  fHChargeLoGain->SetName(nameQLoGain.Data());
+
+  TString nameTLoGain = TString(fHTimeLoGain->GetName());
+  nameTLoGain += id;
+  fHTimeLoGain->SetName(nameTLoGain.Data());
+
+  TString nameQvsNLoGain  = TString(fHChargevsNLoGain->GetName());
+  nameQvsNLoGain += id;
+  fHChargevsNLoGain->SetName(nameQvsNLoGain.Data());
+
+  TString titleQLoGain = TString(fHChargeLoGain->GetTitle());
+  titleQLoGain += id;
+  fHChargeLoGain->SetTitle(titleQLoGain.Data());
+
+  TString titleTLoGain = TString(fHTimeLoGain->GetTitle());
+  titleTLoGain += id;
+  fHTimeLoGain->SetTitle(titleTLoGain.Data());
+
+  TString titleQvsNLoGain  = TString(fHChargevsNLoGain->GetTitle());
+  titleQvsNLoGain += id;
+  fHChargevsNLoGain->SetTitle(titleQvsNLoGain.Data());
 }
 
@@ -170,14 +223,25 @@
 {
   
-  for (Int_t i = fHCharge->FindBin(fChargeFirst); 
-       i <= fHCharge->FindBin(fChargeLast); i++)
-    fHCharge->SetBinContent(i, 1.e-20);
+  for (Int_t i = fHChargeHiGain->FindBin(fChargeFirstHiGain); 
+       i <= fHChargeHiGain->FindBin(fChargeLastHiGain); i++)
+    fHChargeHiGain->SetBinContent(i, 1.e-20);
 
   for (Int_t i = 0; i < 16; i++)
-      fHTime->SetBinContent(i, 1.e-20);
-  
-  fChargeLast     = 9999.5;
-
-  fHCharge->GetXaxis()->SetRangeUser(0.,fChargeLast);
+      fHTimeHiGain->SetBinContent(i, 1.e-20);
+  
+  fChargeLastHiGain     = 9999.5;
+
+  fHChargeLoGain->GetXaxis()->SetRangeUser(0.,fChargeLastLoGain);
+
+ for (Int_t i = fHChargeLoGain->FindBin(fChargeFirstLoGain); 
+       i <= fHChargeLoGain->FindBin(fChargeLastLoGain); i++)
+    fHChargeLoGain->SetBinContent(i, 1.e-20);
+
+  for (Int_t i = 0; i < 16; i++)
+      fHTimeLoGain->SetBinContent(i, 1.e-20);
+  
+  fChargeLastLoGain     = 9999.5;
+
+  fHChargeLoGain->GetXaxis()->SetRangeUser(0.,fChargeLastLoGain);
 
   return;
@@ -192,6 +256,8 @@
 {
 
-  fHCharge->Reset();
-  fHTime->Reset();
+  fHChargeHiGain->Reset();
+  fHTimeHiGain->Reset();
+  fHChargeLoGain->Reset();
+  fHTimeLoGain->Reset();
 
   return kTRUE;
@@ -240,5 +306,4 @@
   fFitLegend->AddText(line8);
 
-
   if (fFitOK)
     fFitLegend->AddText("Result of the Fit: OK");
@@ -266,5 +331,5 @@
     gROOT->SetSelectedPad(NULL);
 
-    c->Divide(2,2);
+    c->Divide(2,4);
 
     c->cd(1);
@@ -273,51 +338,115 @@
     gPad->SetTicks();
 
-    fHCharge->Draw(opt);
-    
-    if (fChargeGausFit)
-      {
-        if (fFitOK)
-          fChargeGausFit->SetLineColor(kGreen);          
-        else
-          fChargeGausFit->SetLineColor(kRed);
-
-        fChargeGausFit->Draw("same");
-        c->Modified();
-        c->Update();
-      }
-
-    
-    c->cd(2);
-    DrawLegend();
-    c->Update();
-
-    c->cd(3);
-    gStyle->SetOptStat(1111111);
-
-    gPad->SetLogy(1);
-    fHTime->Draw(opt);
-
-    if (fTimeGausFit)
-      {
-        if (fTimeChisquare > 1.)
-          fTimeGausFit->SetLineColor(kRed);
-        else
-          fTimeGausFit->SetLineColor(kGreen);
-
-        fTimeGausFit->Draw("same");
-        c->Modified();
-        c->Update();
-      }
-    
+    fHChargeHiGain->DrawCopy(opt);
+
     c->Modified();
     c->Update();
 
-    c->cd(4);
-    fHChargevsN->Draw(opt);
-}
-
-
-
-Bool_t MHCalibrationPixel::FitTime(Axis_t rmin, Axis_t rmax, Option_t *option)
+    if (fUseLoGain)
+      {
+	c->cd(2);
+	gPad->SetLogy(1);
+	gPad->SetTicks();
+	fHChargeLoGain->DrawCopy(opt);
+    
+ 	if (fChargeGausFit)
+	  {
+	    if (fFitOK)
+	      fChargeGausFit->SetLineColor(kGreen);          
+	    else
+	      fChargeGausFit->SetLineColor(kRed);
+	    
+	    fChargeGausFit->DrawCopy("same");
+	  }
+
+	c->cd(4);
+	DrawLegend();
+
+      }
+    else
+      {
+ 	if (fChargeGausFit)
+	  {
+	    if (fFitOK)
+	      fChargeGausFit->SetLineColor(kGreen);          
+	    else
+	      fChargeGausFit->SetLineColor(kRed);
+	    
+	    fChargeGausFit->DrawCopy("same");
+	  }
+	c->cd(2);
+	gPad->SetLogy(1);
+	gPad->SetTicks();
+	fHChargeLoGain->DrawCopy(opt);
+	c->cd(3);
+	DrawLegend();
+      }	
+
+    c->Modified();
+    c->Update();
+    
+    c->cd(5);
+    gStyle->SetOptStat(1111111);
+
+    gPad->SetLogy(1);
+    fHTimeHiGain->DrawCopy(opt);
+    c->Modified();
+    c->Update();
+
+    if (fUseLoGain)
+      {
+
+	c->cd(6);
+	gPad->SetLogy(1);
+	fHTimeLoGain->DrawCopy(opt);
+	c->Modified();
+	c->Update();
+	
+	if (fTimeGausFit)
+	  {
+	    if (fTimeChisquare > 1.)
+	      fTimeGausFit->SetLineColor(kRed);
+	    else
+	      fTimeGausFit->SetLineColor(kGreen);
+	    
+	    fTimeGausFit->DrawCopy("same");
+	  }
+      }
+    else
+      {  
+	if (fTimeGausFit)
+	  {
+	    if (fTimeChisquare > 1.)
+	      fTimeGausFit->SetLineColor(kRed);
+	    else
+	      fTimeGausFit->SetLineColor(kGreen);
+	    
+	    fTimeGausFit->DrawCopy("same");
+	    c->Modified();
+	    c->Update();
+	  }
+
+	c->cd(6);
+	gPad->SetLogy(1);
+	fHTimeLoGain->DrawCopy(opt);	
+      }
+    c->Modified();
+    c->Update();
+    
+    c->cd(7);
+    fHChargevsNHiGain->DrawCopy(opt);
+    c->Modified();
+    c->Update();
+
+    c->cd(8);
+    fHChargevsNLoGain->DrawCopy(opt);
+    c->Modified();
+    c->Update();
+
+}
+
+
+
+Bool_t MHCalibrationPixel::FitTimeHiGain(Axis_t rmin, Axis_t rmax, Option_t *option)
 {
 
@@ -328,6 +457,6 @@
   rmax = (rmax != 0.) ? rmax : 9.;
 
-  const Stat_t   entries     = fHTime->GetEntries();
-  const Double_t mu_guess    = fHTime->GetBinCenter(fHTime->GetMaximumBin());
+  const Stat_t   entries     = fHTimeHiGain->GetEntries();
+  const Double_t mu_guess    = fHTimeHiGain->GetBinCenter(fHTimeHiGain->GetMaximumBin());
   const Double_t sigma_guess = (rmax - rmin)/2.;
   const Double_t area_guess  = entries/gkSq2Pi;
@@ -350,5 +479,5 @@
   fTimeGausFit->SetRange(rmin,rmax);
 
-  fHTime->Fit(fTimeGausFit,option);
+  fHTimeHiGain->Fit(fTimeGausFit,option);
 
   rmin = fTimeGausFit->GetParameter(1) - 3.*fTimeGausFit->GetParameter(2);
@@ -356,5 +485,5 @@
   fTimeGausFit->SetRange(rmin,rmax);  
 
-  fHTime->Fit(fTimeGausFit,option);
+  fHTimeHiGain->Fit(fTimeGausFit,option);
 
   fTimeChisquare = fTimeGausFit->GetChisquare();
@@ -375,5 +504,61 @@
 }
 
-Bool_t MHCalibrationPixel::FitCharge(Option_t *option)
+Bool_t MHCalibrationPixel::FitTimeLoGain(Axis_t rmin, Axis_t rmax, Option_t *option)
+{
+
+  if (fTimeGausFit)
+    return kFALSE;
+
+  rmin = (rmin != 0.) ? rmin : 4.;
+  rmax = (rmax != 0.) ? rmax : 9.;
+
+  const Stat_t   entries     = fHTimeLoGain->GetEntries();
+  const Double_t mu_guess    = fHTimeLoGain->GetBinCenter(fHTimeLoGain->GetMaximumBin());
+  const Double_t sigma_guess = (rmax - rmin)/2.;
+  const Double_t area_guess  = entries/gkSq2Pi;
+
+  TString name = TString("GausTime");
+  name += fPixId;
+  fTimeGausFit = new TF1(name.Data(),"gaus",rmin,rmax);  
+
+  if (!fTimeGausFit) 
+    {
+    *fLog << err << dbginf << "Could not create fit function for Gauss fit" << endl;
+    return kFALSE;
+    }
+
+  fTimeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
+  fTimeGausFit->SetParNames("Area","#mu","#sigma");
+  fTimeGausFit->SetParLimits(0,0.,entries);
+  fTimeGausFit->SetParLimits(1,rmin,rmax);
+  fTimeGausFit->SetParLimits(2,0.,(rmax-rmin));
+  fTimeGausFit->SetRange(rmin,rmax);
+
+  fHTimeLoGain->Fit(fTimeGausFit,option);
+
+  rmin = fTimeGausFit->GetParameter(1) - 3.*fTimeGausFit->GetParameter(2);
+  rmax = fTimeGausFit->GetParameter(1) + 3.*fTimeGausFit->GetParameter(2);
+  fTimeGausFit->SetRange(rmin,rmax);  
+
+  fHTimeLoGain->Fit(fTimeGausFit,option);
+
+  fTimeChisquare = fTimeGausFit->GetChisquare();
+  fTimeNdf       = fTimeGausFit->GetNDF();
+  fTimeProb      = fTimeGausFit->GetProb();
+
+  fTimeMean      = fTimeGausFit->GetParameter(1);
+  fTimeSigma     = fTimeGausFit->GetParameter(2);
+
+  if (fTimeChisquare > 1.) 
+    {
+      *fLog << warn << "Fit of the Arrival times failed ! " << endl;
+      return kFALSE;
+    }
+  
+  return kTRUE;
+
+}
+
+Bool_t MHCalibrationPixel::FitChargeHiGain(Option_t *option)
 {
 
@@ -384,5 +569,5 @@
   // Get the fitting ranges
   //
-  Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirst;
+  Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirstHiGain;
   Axis_t rmax = 0.;
 
@@ -391,7 +576,7 @@
   // otherwise the fit goes gaga because of high number of dimensions ...
   //
-  const Stat_t   entries    = fHCharge->GetEntries();
+  const Stat_t   entries    = fHChargeHiGain->GetEntries();
   const Double_t area_guess = entries/gkSq2Pi;
-  const Double_t mu_guess   = fHCharge->GetBinCenter(fHCharge->GetMaximumBin());
+  const Double_t mu_guess   = fHChargeHiGain->GetBinCenter(fHChargeHiGain->GetMaximumBin());
   const Double_t sigma_guess = mu_guess/15.;
 
@@ -399,5 +584,5 @@
   name += fPixId;
 
-  fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLast);
+  fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLastHiGain);
 
   if (!fChargeGausFit) 
@@ -410,9 +595,9 @@
   fChargeGausFit->SetParNames("Area","#mu","#sigma");
   fChargeGausFit->SetParLimits(0,0.,entries);
-  fChargeGausFit->SetParLimits(1,rmin,fChargeLast);
-  fChargeGausFit->SetParLimits(2,0.,fChargeLast-rmin);
-  fChargeGausFit->SetRange(rmin,fChargeLast);
-
-  fHCharge->Fit(fChargeGausFit,option);
+  fChargeGausFit->SetParLimits(1,rmin,fChargeLastHiGain);
+  fChargeGausFit->SetParLimits(2,0.,fChargeLastHiGain-rmin);
+  fChargeGausFit->SetRange(rmin,fChargeLastHiGain);
+
+  fHChargeHiGain->Fit(fChargeGausFit,option);
   
   Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
@@ -422,5 +607,5 @@
   fChargeGausFit->SetRange(rmin,rmax);  
 
-  fHCharge->Fit(fChargeGausFit,option);
+  fHChargeHiGain->Fit(fChargeGausFit,option);
 
   //  rmin = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
@@ -428,5 +613,5 @@
   //  fChargeGausFit->SetRange(rmin,rmax);  
 
-  // fHCharge->Fit(fChargeGausFit,option);
+  // fHChargeHiGain->Fit(fChargeGausFit,option);
 
   fChargeChisquare = fChargeGausFit->GetChisquare();
@@ -455,17 +640,107 @@
 }
 
+
+Bool_t MHCalibrationPixel::FitChargeLoGain(Option_t *option)
+{
+
+  if (fChargeGausFit)
+    return kFALSE;
+
+  //
+  // Get the fitting ranges
+  //
+  Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirstLoGain;
+  Axis_t rmax = 0.;
+
+  //
+  // First guesses for the fit (should be as close to reality as possible, 
+  // otherwise the fit goes gaga because of high number of dimensions ...
+  //
+  const Stat_t   entries    = fHChargeLoGain->GetEntries();
+  const Double_t area_guess = entries/gkSq2Pi;
+  const Double_t mu_guess   = fHChargeLoGain->GetBinCenter(fHChargeLoGain->GetMaximumBin());
+  const Double_t sigma_guess = mu_guess/15.;
+
+  TString name = TString("ChargeGausFit");
+  name += fPixId;
+
+  fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLastLoGain);
+
+  if (!fChargeGausFit) 
+    {
+    *fLog << err << dbginf << "Could not create fit function for Gauss fit" << endl;
+    return kFALSE;
+    }
+  
+  fChargeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
+  fChargeGausFit->SetParNames("Area","#mu","#sigma");
+  fChargeGausFit->SetParLimits(0,0.,entries);
+  fChargeGausFit->SetParLimits(1,rmin,fChargeLastLoGain);
+  fChargeGausFit->SetParLimits(2,0.,fChargeLastLoGain-rmin);
+  fChargeGausFit->SetRange(rmin,fChargeLastLoGain);
+
+  fHChargeLoGain->Fit(fChargeGausFit,option);
+  
+  Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
+  
+  rmin = (rtry < rmin ? rmin : rtry);
+  rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
+  fChargeGausFit->SetRange(rmin,rmax);  
+
+  fHChargeLoGain->Fit(fChargeGausFit,option);
+
+  //  rmin = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
+  //  rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
+  //  fChargeGausFit->SetRange(rmin,rmax);  
+
+  // fHChargeLoGain->Fit(fChargeGausFit,option);
+
+  fChargeChisquare = fChargeGausFit->GetChisquare();
+  fChargeNdf       = fChargeGausFit->GetNDF();
+  fChargeProb      = fChargeGausFit->GetProb();
+  fChargeMean      = fChargeGausFit->GetParameter(1);
+  fChargeMeanErr   = fChargeGausFit->GetParError(1);
+  fChargeSigma     = fChargeGausFit->GetParameter(2);
+  fChargeSigmaErr  = fChargeGausFit->GetParError(2);
+
+  //
+  // The fit result is accepted under condition
+  // The Probability is greater than gkProbLimit (default 0.01 == 99%)
+  //
+  if (fChargeProb < gkProbLimit) 
+    {
+      *fLog << warn << "Prob: " << fChargeProb << " is smaller than the allowed value: " << gkProbLimit << endl;
+      fFitOK = kFALSE;
+      return kFALSE;
+    }
+  
+  
+  fFitOK = kTRUE;
+    
+  return kTRUE;
+}
+
  
 void MHCalibrationPixel::CutAllEdges()
 {
 
-  Int_t nbins = 50;
-
-  CutEdges(fHCharge,nbins);
-
-  fChargeFirst = fHCharge->GetBinLowEdge(fHCharge->GetXaxis()->GetFirst());
-  fChargeLast  = fHCharge->GetBinLowEdge(fHCharge->GetXaxis()->GetLast())+fHCharge->GetBinWidth(0);
-  fChargeNbins = nbins;
-
-  CutEdges(fHChargevsN,0);
+  Int_t nbins = 30;
+
+  CutEdges(fHChargeHiGain,nbins);
+
+  fChargeFirstHiGain = fHChargeHiGain->GetBinLowEdge(fHChargeHiGain->GetXaxis()->GetFirst());
+  fChargeLastHiGain  = fHChargeHiGain->GetBinLowEdge(fHChargeHiGain->GetXaxis()->GetLast())
+                      +fHChargeHiGain->GetBinWidth(0);
+  fChargeNbinsHiGain = nbins;
+
+  CutEdges(fHChargeLoGain,nbins);
+
+  fChargeFirstLoGain = fHChargeLoGain->GetBinLowEdge(fHChargeLoGain->GetXaxis()->GetFirst());
+  fChargeLastLoGain  = fHChargeLoGain->GetBinLowEdge(fHChargeLoGain->GetXaxis()->GetLast())
+                      +fHChargeLoGain->GetBinWidth(0);
+  fChargeNbinsLoGain = nbins;
+
+  CutEdges(fHChargevsNHiGain,0);
+  CutEdges(fHChargevsNLoGain,0);
 
 }
Index: trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h	(revision 2612)
+++ trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h	(revision 2627)
@@ -31,7 +31,11 @@
 protected:
 
-  TH1I* fHCharge;              //-> Summed FADC slices
-  TH1I* fHTime;                //-> Mean arrival time in number of FADC sice
-  TH1I* fHChargevsN;           //-> Summed Charge vs. Event Nr. 
+  TH1F* fHChargeHiGain;              //-> Summed FADC slices
+  TH1I* fHTimeHiGain;                //-> Mean arrival time in number of FADC sice
+  TH1I* fHChargevsNHiGain;           //-> Summed Charge vs. Event Nr. 
+  
+  TH1F* fHChargeLoGain;              //-> Summed FADC slices
+  TH1I* fHTimeLoGain;                //-> Mean arrival time in number of FADC sice
+  TH1I* fHChargevsNLoGain;           //-> Summed Charge vs. Event Nr. 
   
   TF1* fChargeGausFit;
@@ -41,7 +45,11 @@
   
   Axis_t  fLowerFitRange;
-  Axis_t  fChargeFirst;
-  Axis_t  fChargeLast;
-  Int_t   fChargeNbins;
+  Axis_t  fChargeFirstHiGain;
+  Axis_t  fChargeLastHiGain;
+  Int_t   fChargeNbinsHiGain;
+
+  Axis_t  fChargeFirstLoGain;
+  Axis_t  fChargeLastLoGain;
+  Int_t   fChargeNbinsLoGain;
 
   Bool_t fFitOK;
@@ -62,4 +70,6 @@
   Double_t fTimeMean;
   Double_t fTimeSigma;
+
+  Bool_t fUseLoGain;
   
   virtual void DrawLegend();
@@ -75,10 +85,16 @@
   Bool_t Fill(const MParContainer *, const Stat_t w=1) { return kTRUE; }
 
-  Bool_t FillCharge(Int_t q)               { return fHCharge->Fill(q)      > -1; }
-  Bool_t FillTime(Int_t t)                 { return fHTime->Fill(t)        > -1; }
-  Bool_t FillChargevsN(Float_t q, Int_t n) { return fHChargevsN->Fill(n,q) > -1; }
+  Bool_t FillChargeLoGain(Float_t q)             { return fHChargeLoGain->Fill(q)      > -1; }
+  Bool_t FillTimeLoGain(Int_t t)                 { return fHTimeLoGain->Fill(t)        > -1; }
+  Bool_t FillChargevsNLoGain(Float_t q, Int_t n) { return fHChargevsNLoGain->Fill(n,q) > -1; }
 
-  const TH1I *GetHCharge()                 { return fHCharge;    }
-  const TH1I *GetHCharge() const           { return fHCharge;    }
+  Bool_t FillChargeHiGain(Float_t q)             { return fHChargeHiGain->Fill(q)      > -1; }
+  Bool_t FillTimeHiGain(Int_t t)                 { return fHTimeHiGain->Fill(t)        > -1; }
+  Bool_t FillChargevsNHiGain(Float_t q, Int_t n) { return fHChargevsNHiGain->Fill(n,q) > -1; }
+
+  void SetUseLoGain()                      { fUseLoGain = kTRUE; }
+
+  const TH1F *GetHCharge()                 { return fHChargeHiGain;    }
+  const TH1F *GetHCharge() const           { return fHChargeHiGain;    }
 
   const Double_t GetChargeMean()     const { return fChargeMean;    }
@@ -100,12 +116,15 @@
   const Int_t    GetTimeNdf()         const { return fTimeNdf;       }   
   
-  const TH1I *GetHTime()                    { return fHTime; }
-  const TH1I *GetHTime()              const { return fHTime; }
+  const TH1I *GetHTime()                    { return fHTimeHiGain; }
+  const TH1I *GetHTime()              const { return fHTimeHiGain; }
   
-  const TH1I *GetHChargevsN()               { return fHChargevsN; }
-  const TH1I *GetHChargevsN()         const { return fHChargevsN; }
+  const TH1I *GetHChargevsN()               { return fHChargevsNHiGain; }
+  const TH1I *GetHChargevsN()         const { return fHChargevsNHiGain; }
   
-  Bool_t FitCharge(Option_t *option="RQ0");  
-  Bool_t FitTime(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");    
+  Bool_t FitChargeHiGain(Option_t *option="RQ0");  
+  Bool_t FitTimeHiGain(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");    
+
+  Bool_t FitChargeLoGain(Option_t *option="RQ0");  
+  Bool_t FitTimeLoGain(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0");    
 
   virtual void Draw(Option_t *option="");
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2612)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 2627)
@@ -739,4 +739,27 @@
 // ------------------------------------------------------------------------
 //
+// Call this function to add a MCamEvent on top of the present contents.
+//
+void MHCamera::SetCamError(const MCamEvent &evt, Int_t type)
+{
+
+    if (fNcells<=1 || IsFreezed())
+        return;
+
+    // FIXME: Security check missing!
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+    {
+        Double_t val=0;
+        if (evt.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/)
+            SetUsed(idx);
+
+        SetBinError(idx+1, val); // FIXME: Slow!
+    }
+}
+
+
+
+// ------------------------------------------------------------------------
+//
 // Call this function to add a MHCamera on top of the present contents.
 // Type:
Index: trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2612)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2627)
@@ -124,4 +124,7 @@
     virtual void     SetCamContent(const TArrayD &evt, const TArrayC *used=NULL) { Reset(); AddCamContent(evt, used); }
     virtual void     SetCamContent(const MHCamera &d, Int_t type=0) { Reset(); AddCamContent(d, type); fEntries=d.fEntries; }
+
+    virtual void     SetCamError(const MCamEvent &event, Int_t type=0);
+
     virtual void     CntCamContent(const MCamEvent &evt, Double_t threshold, Int_t type=0);
     virtual void     CntCamContent(const TArrayD &evt, Double_t threshold, Bool_t ispos=kTRUE);
