Index: trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.h	(revision 2641)
+++ trunk/MagicSoft/Mars/mhist/MHCalibrationBlindPixel.h	(revision 2642)
@@ -39,4 +39,5 @@
   TF1 *fSinglePheFit;
   TF1 *fTimeGausFit;  
+  TF1 *fSinglePhePedFit;
 
   Axis_t  fBlindPixelChargefirst;
@@ -55,5 +56,5 @@
   
   BlindPixelFitFunc fgSinglePheFitFunc;     // In the beginning, 
-  Int_t     fgSinglePheFitNPar;     // we want to be flexible using different functions
+  Int_t     fgSinglePheFitNPar;             // we want to be flexible using different functions
 
   Double_t  fLambda; 
@@ -78,4 +79,7 @@
   Double_t  fSigmaTimeErr; 
   
+  Double_t fLambdaCheck;
+  Double_t fLambdaCheckErr;
+
 public:
 
@@ -88,19 +92,21 @@
   Bool_t FillBlindPixelChargevsN(Stat_t rq, Int_t t) { return fHBlindPixelChargevsN->Fill(t,rq) > -1;  }  
   
-  const Double_t GetLambda()   const { return fLambda; }
-  const Double_t GetMu0()     const { return fMu0; }
-  const Double_t GetMu1()     const { return fMu1; }
-  const Double_t GetSigma0()   const { return fSigma0; }
-  const Double_t GetSigma1()   const { return fSigma1; }
+  const Double_t GetLambda()         const { return fLambda; }
+  const Double_t GetLambdaCheck()    const { return fLambdaCheck; }
+  const Double_t GetMu0()            const { return fMu0; }
+  const Double_t GetMu1()            const { return fMu1; }
+  const Double_t GetSigma0()         const { return fSigma0; }
+  const Double_t GetSigma1()         const { return fSigma1; }
 
-  const Double_t GetLambdaErr() const { return fLambdaErr; }
-  const Double_t GetMu0Err()   const { return fMu0Err; }
-  const Double_t GetMu1Err()   const { return fMu1Err; }
-  const Double_t GetSigma0Err() const { return fSigma0Err; }
-  const Double_t GetSigma1Err() const { return fSigma1Err; }
+  const Double_t GetLambdaErr()      const { return fLambdaErr; }
+  const Double_t GetLambdaCheckErr() const { return fLambdaCheckErr; }
+  const Double_t GetMu0Err()         const { return fMu0Err; }
+  const Double_t GetMu1Err()         const { return fMu1Err; }
+  const Double_t GetSigma0Err()      const { return fSigma0Err; }
+  const Double_t GetSigma1Err()      const { return fSigma1Err; }
 
-  const Double_t GetChiSquare() const { return fChisquare; }
-  const Double_t GetProb()    const { return fProb;      }  
-  const Int_t    GetNdf()     const { return fNdf;       }   
+  const Double_t GetChiSquare()      const { return fChisquare; }
+  const Double_t GetProb()           const { return fProb;      }  
+  const Int_t    GetNdf()            const { return fNdf;       }   
 
   const Double_t GetMeanTime()      const { return fMeanTime; }
@@ -118,5 +124,5 @@
                            Double_t sigma1);
   
-  Bool_t FitSinglePhe(Axis_t rmin=0, Axis_t rmax=0, Option_t *opt="R0+");
+  Bool_t FitSinglePhe(Axis_t rmin=0, Axis_t rmax=0, Option_t *opt="RL0+");
   Bool_t FitTime(Axis_t rmin=0., Axis_t rmax=0.,Option_t *opt="R0+");
 
@@ -126,4 +132,6 @@
   void Draw(Option_t *option="");
 
+  Bool_t IsFitOK() { return fFitOK; }
+
   ClassDef(MHCalibrationBlindPixel, 1) 
 };
Index: trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc	(revision 2641)
+++ trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.cc	(revision 2642)
@@ -40,4 +40,6 @@
 
 #include <TFitter.h>
+#include <TGraph.h>
+#include <TAxis.h>
 
 #include <TF1.h>
@@ -62,4 +64,8 @@
 MHCalibrationPixel::MHCalibrationPixel(const char *name, const char *title)
       : fPixId(-1),
+	fHiGainvsLoGain(NULL),
+	fTotalEntries(0),
+	fHiGains(NULL),
+	fLoGains(NULL),
         fChargeGausFit(NULL), 
 	fTimeGausFit(NULL), 
@@ -141,4 +147,7 @@
     fHChargevsNLoGain->SetDirectory(NULL);
 
+    fHiGains = new TArrayF();
+    fLoGains = new TArrayF();
+
 }
 
@@ -153,4 +162,10 @@
   delete fHTimeLoGain;
   delete fHChargevsNLoGain;
+
+  if (fHiGainvsLoGain)
+    delete fHiGainvsLoGain;
+
+  delete fHiGains;
+  delete fLoGains;
 
   if (fChargeGausFit)
@@ -232,5 +247,5 @@
   fChargeLastHiGain     = 9999.5;
 
-  fHChargeLoGain->GetXaxis()->SetRangeUser(0.,fChargeLastLoGain);
+  fHChargeHiGain->GetXaxis()->SetRangeUser(0.,fChargeLastHiGain);
 
  for (Int_t i = fHChargeLoGain->FindBin(fChargeFirstLoGain); 
@@ -280,4 +295,15 @@
 }
 
+void MHCalibrationPixel::SetPointInGraph(Float_t qhi,Float_t qlo)
+{
+
+  fHiGains->Set(++fTotalEntries);
+  fLoGains->Set(fTotalEntries);
+
+  fHiGains->AddAt(qhi,fTotalEntries-1);
+  fLoGains->AddAt(qlo,fTotalEntries-1);
+
+}
+
 
 // -------------------------------------------------------------------------
@@ -338,4 +364,17 @@
 void MHCalibrationPixel::Draw(Option_t *opt) 
 {
+
+  if (!fHiGainvsLoGain)
+    {
+
+    // Create TGraph, we set the points later, get hold of the number of points with fTotalEntries
+    fHiGainvsLoGain = new TGraph(fTotalEntries,fHiGains->GetArray(),fLoGains->GetArray());
+    fHiGainvsLoGain->SetName("HiGainvsLoGain");
+    fHiGainvsLoGain->SetTitle("Plot the High Gain vs. Low Gain");
+    fHiGainvsLoGain->GetXaxis()->Set(300,0.,1500.);
+    fHiGainvsLoGain->GetYaxis()->Set(400,0.,2000.);
+    fHiGainvsLoGain->SetMarkerStyle(7);
+
+    }
 
     gStyle->SetOptFit(0);
@@ -374,4 +413,12 @@
 	    fChargeGausFit->DrawCopy("same");
 	  }
+	c->Modified();
+	c->Update();
+
+	c->cd(3);
+	gROOT->SetSelectedPad(NULL);
+	fHiGainvsLoGain->DrawClone("Apq")->SetBit(kCanDelete);
+	gPad->Modified();
+	gPad->Update();
 
 	c->cd(4);
@@ -393,7 +440,20 @@
 	gPad->SetLogy(1);
 	gPad->SetTicks();
+
 	fHChargeLoGain->DrawCopy(opt);
+	c->Modified();
+	c->Update();
+    
 	c->cd(3);
 	DrawLegend();
+
+	c->cd(4);
+	
+	gROOT->SetSelectedPad(NULL);
+	fHiGainvsLoGain->DrawClone("Apq")->SetBit(kCanDelete);
+	gPad->Modified();
+	gPad->Update();
+
+
       }	
 
@@ -426,4 +486,6 @@
 	    
 	    fTimeGausFit->DrawCopy("same");
+	    c->Modified();
+	    c->Update();
 	  }
       }
@@ -445,4 +507,7 @@
 	gPad->SetLogy(1);
 	fHTimeLoGain->DrawCopy(opt);	
+	c->Modified();
+	c->Update();
+    
       }
     c->Modified();
@@ -459,4 +524,5 @@
     c->Update();
 
+
 }
 
@@ -616,17 +682,11 @@
   fHChargeHiGain->Fit(fChargeGausFit,option);
   
-  Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
+  Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.0*fChargeGausFit->GetParameter(2);
   
   rmin = (rtry < rmin ? rmin : rtry);
-  rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
+  rmax = fChargeGausFit->GetParameter(1) + 3.5*fChargeGausFit->GetParameter(2);
   fChargeGausFit->SetRange(rmin,rmax);  
 
   fHChargeHiGain->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);  
-
-  // fHChargeHiGain->Fit(fChargeGausFit,option);
 
   fChargeChisquare = fChargeGausFit->GetChisquare();
@@ -697,8 +757,8 @@
   fHChargeLoGain->Fit(fChargeGausFit,option);
   
-  Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);
+  Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.*fChargeGausFit->GetParameter(2);
   
   rmin = (rtry < rmin ? rmin : rtry);
-  rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);
+  rmax = fChargeGausFit->GetParameter(1) + 3.5*fChargeGausFit->GetParameter(2);
   fChargeGausFit->SetRange(rmin,rmax);  
 
Index: trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h	(revision 2641)
+++ trunk/MagicSoft/Mars/mhist/MHCalibrationPixel.h	(revision 2642)
@@ -18,4 +18,12 @@
 #endif
 
+#ifndef ROOT_TGraph
+#include "TGraph.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include "TArrayF.h"
+#endif
+
 class TPaveText;
 class TMath;
@@ -27,16 +35,21 @@
 private:
 
-  Int_t fPixId;           //-> Pixel Nr
-  
+  Int_t fPixId;                  // Pixel Nr
+  TGraph *fHiGainvsLoGain;       // Plot the HiGain vs. the LoGain
+  Int_t fTotalEntries;           // Number of entries
+
+  TArrayF *fHiGains;
+  TArrayF *fLoGains;
+
 protected:
 
-  TH1F* fHChargeHiGain;              //-> Summed FADC slices
-  TH1I* fHTimeHiGain;                //-> Mean arrival time in number of FADC sice
-  TH1I* fHChargevsNHiGain;           //-> Summed Charge vs. Event Nr. 
+  TH1F* fHChargeHiGain;          // Summed FADC slices High Gain
+  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. 
-  
+  TH1F* fHChargeLoGain;          // Summed FADC slices Low Gain
+  TH1I* fHTimeLoGain;            // Mean arrival time in number of FADC sice
+  TH1I* fHChargevsNLoGain;       // Summed Charge vs. Event Nr. 
+
   TF1* fChargeGausFit;
   TF1* fTimeGausFit;
@@ -85,11 +98,13 @@
   Bool_t Fill(const MParContainer *, const Stat_t w=1) { return kTRUE; }
 
-  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; }
+  void   SetPointInGraph(Float_t qhi, Float_t qlo);
 
-  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; }
+  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); }
+
+  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; }
Index: trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2641)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 2642)
@@ -125,5 +125,5 @@
     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     SetCamError(const MCamEvent &evt, Int_t type=0);
 
     virtual void     CntCamContent(const MCamEvent &evt, Double_t threshold, Int_t type=0);
