Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2996)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2997)
@@ -87,4 +87,5 @@
 
    * mcalib/MCalibrationCalc.[h,cc]
+   * mcalib/MHCalibrationBlindPixel.[h,cc]
      - fBlindPixelId and fPINDiodeId now like in PedestalCam
      - fill Blind Pixel with information about its fitted pedestal if 
Index: trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.h	(revision 2996)
+++ trunk/MagicSoft/Mars/manalysis/MHPedestalPixel.h	(revision 2997)
@@ -53,14 +53,16 @@
   void ChangeHistId(Int_t i);
   
-  // Setters
-  const TH1F *GetHPedestalCharge()    const { return fHPedestalCharge;    }
+  // Getters
+  const TH1F *GetHPedestalCharge() const { return fHPedestalCharge; }
 
-  Double_t GetChargeMean()     const { return fChargeMean;    }
-  Double_t GetChargeMeanErr()  const { return fChargeMeanErr; }
-  Double_t GetChargeSigma()    const { return fChargeSigma;   }
-  Double_t GetChargeSigmaErr() const { return fChargeSigmaErr; }
-  Double_t GetChargeChiSquare() const { return fChargeChisquare; }
-  Double_t GetChargeProb()      const { return fChargeProb;      }  
-  Int_t    GetChargeNdf()       const { return fChargeNdf;       }   
+  Double_t GetChargeMean()         const { return fChargeMean;      }
+  Double_t GetChargeMeanErr()      const { return fChargeMeanErr;   }
+  Double_t GetChargeSigma()        const { return fChargeSigma;     }
+  Double_t GetChargeSigmaErr()     const { return fChargeSigmaErr;  }
+  Double_t GetChargeChiSquare()    const { return fChargeChisquare; }
+  Double_t GetChargeProb()         const { return fChargeProb;      }  
+  Int_t    GetChargeNdf()          const { return fChargeNdf;       }
+
+  Int_t    GetTotalEntries()       const { return fTotalEntries;    }     
 
   Bool_t IsFitOK()     const;    
Index: trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc	(revision 2996)
+++ trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc	(revision 2997)
@@ -39,5 +39,5 @@
 // Actually, MPedCalcPedRun applies the following formula (1):
 // 
-// PedRMS = Sqrt(  (sum(x_i2) - sum(x_i)/n) / n-1 / 14 )
+// PedRMS = Sqrt(  (sum(x_i^2) - sum(x_i)/n) / n-1 / 14 )
 // 
 // where x_i is the sum of 14 FADC slices and sum means the sum over all
Index: trunk/MagicSoft/Mars/manalysis/MPedestalPix.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalPix.h	(revision 2996)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalPix.h	(revision 2997)
@@ -47,4 +47,6 @@
   
   // Getters
+  MHPedestalPixel *GetHist() const { return fHist; } 
+
   Float_t GetPedestal()    const { return fPedestal; }
   Float_t GetPedestalRms() const { return fPedestalRms; }
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.cc	(revision 2996)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.cc	(revision 2997)
@@ -34,4 +34,29 @@
 // 2) at least 100 events are in the single Photo-electron peak
 //
+// Used numbers are the following:
+//
+// Electronic conversion factor:
+//   Assume, we have N_e electrons at the anode, 
+//   thus a charge of N_e*e (e = electron charge) Coulomb.
+//
+//   This charge is AC coupled and runs into a R_pre = 50 Ohm resistency. 
+//   The corresponding current is amplified by a gain factor G_pre = 400 
+//   (the precision of this value still has to be checked !!!) and again AC coupled to 
+//   the output. 
+//   The corresponding signal goes through the whole transmission and 
+//   amplification chain and is digitized in the FADCs. 
+//   The conversion Signal Area to FADC counts (Conv_trans) has been measured 
+//   by David and Oscar to be approx. 3.9 pVs^-1
+//
+//   Thus: Conversion FADC counts to Number of Electrons at Anode: 
+//         FADC counts = (1/Conv_tran) * G_pre * R_pre *  e * N_e = 8 * 10^-4 N_e. 
+//
+//   Also: FADC counts = 8*10^-4 * GAIN * N_phe
+//
+//   In the blind pixel, there is an additional pre-amplifier with an amplification of 
+//   about 10. Therefore, we have for the blind pixel:
+//
+//   FADC counts (Blind Pixel) = 8*10^-3 * GAIN * N_phe
+//
 //////////////////////////////////////////////////////////////////////////////
 #include "MHCalibrationBlindPixel.h"
@@ -53,4 +78,12 @@
 using namespace std;
 
+const Int_t    MHCalibrationBlindPixel::fgBlindPixelChargeNbins        = 1000;
+const Int_t    MHCalibrationBlindPixel::fgBlindPixelTimeNbins          = 32;
+const Int_t    MHCalibrationBlindPixel::fgBlindPixelChargevsNbins      = 10000;
+const Axis_t   MHCalibrationBlindPixel::fgBlindPixelTimeFirst          = -0.25;
+const Axis_t   MHCalibrationBlindPixel::fgBlindPixelTimeLast           = 15.75;
+const Double_t MHCalibrationBlindPixel::fgBlindPixelElectronicAmp      = 0.008;
+const Double_t MHCalibrationBlindPixel::fgBlindPixelElectronicAmpError = 0.002;
+  
 // --------------------------------------------------------------------------
 //
@@ -58,10 +91,5 @@
 //
 MHCalibrationBlindPixel::MHCalibrationBlindPixel(const char *name, const char *title)
-    :   fBlindPixelChargeNbins(1000),
-        fBlindPixelTimeNbins(32),
-        fBlindPixelChargevsNbins(10000),
-        fBlindPixelTimeFirst(-0.25),
-        fBlindPixelTimeLast(15.75),
-        fHBlindPixelPSD(NULL), 
+    :   fHBlindPixelPSD(NULL), 
         fSinglePheFit(NULL),  
         fTimeGausFit(NULL),
@@ -78,5 +106,5 @@
 
     fHBlindPixelCharge = new TH1F("HBlindPixelCharge","Distribution of Summed FADC Slices",
-				  fBlindPixelChargeNbins,fBlindPixelChargefirst,fBlindPixelChargelast);
+				  fgBlindPixelChargeNbins,fBlindPixelChargefirst,fBlindPixelChargelast);
     fHBlindPixelCharge->SetXTitle("Sum FADC Slices");
     fHBlindPixelCharge->SetYTitle("Nr. of events");
@@ -85,5 +113,5 @@
 
     fHBlindPixelTime = new TH1F("HBlindPixelTime","Distribution of Mean Arrival Times",
-                                fBlindPixelTimeNbins,fBlindPixelTimeFirst,fBlindPixelTimeLast);
+                                fgBlindPixelTimeNbins,fgBlindPixelTimeFirst,fgBlindPixelTimeLast);
     fHBlindPixelTime->SetXTitle("Mean Arrival Times [FADC slice nr]");
     fHBlindPixelTime->SetYTitle("Nr. of events");
@@ -92,5 +120,5 @@
 
     fHBlindPixelChargevsN = new TH1I("HBlindPixelChargevsN","Sum of Charges vs. Event Number",
-                                     fBlindPixelChargevsNbins,-0.5,(Axis_t)fBlindPixelChargevsNbins-0.5);
+                                     fgBlindPixelChargevsNbins,-0.5,(Axis_t)fgBlindPixelChargevsNbins-0.5);
     fHBlindPixelChargevsN->SetXTitle("Event Nr.");
     fHBlindPixelChargevsN->SetYTitle("Sum of FADC slices");
@@ -431,5 +459,6 @@
   const Double_t delta1_guess     = 8.;
   const Double_t delta2_guess     = 5.;
-  const Double_t electronicAmp_guess  = 0.0025;
+  const Double_t electronicAmp_guess  = fgBlindPixelElectronicAmp;
+  const Double_t electronicAmp_limit  = fgBlindPixelElectronicAmpError;
 
   //
@@ -481,9 +510,17 @@
 
     case kEPolya:
-      fSinglePheFit->SetParameters(lambda_guess, excessPoisson_guess,
-                                   delta1_guess,delta2_guess,
-                                   electronicAmp_guess,
-                                   si_0_guess,
-                                   norm, mu_0_guess);
+      if ((fMeanPedestal) && (fSigmaPedestal))
+        fSinglePheFit->SetParameters(lambda_guess, excessPoisson_guess,
+                                     delta1_guess,delta2_guess,
+                                     electronicAmp_guess,
+                                     fSigmaPedestal,
+                                     norm, 
+                                     fMeanPedestal);
+      else
+        fSinglePheFit->SetParameters(lambda_guess, excessPoisson_guess,
+                                     delta1_guess,delta2_guess,
+                                     electronicAmp_guess,
+                                     si_0_guess,
+                                     norm, mu_0_guess);
       fSinglePheFit->SetParNames("#lambda","b_{tot}",
                                  "#delta_{1}","#delta_{2}",
@@ -494,8 +531,20 @@
       fSinglePheFit->SetParLimits(2,6.,12.);    
       fSinglePheFit->SetParLimits(3,3.,8.);    
-      fSinglePheFit->SetParLimits(4,0.,0.005);    
-      fSinglePheFit->SetParLimits(5,min,(max-min)/1.5);
+      fSinglePheFit->SetParLimits(4,electronicAmp_guess-electronicAmp_limit,
+                                    electronicAmp_guess+electronicAmp_limit);    
+      if ((fMeanPedestal) && (fSigmaPedestal))
+        fSinglePheFit->SetParLimits(5,
+                                    fSigmaPedestal-3.*fSigmaPedestalErr,
+                                    fSigmaPedestal+3.*fSigmaPedestalErr);
+      else
+        fSinglePheFit->SetParLimits(5,min,(max-min)/1.5);
+
       fSinglePheFit->SetParLimits(6,norm-0.1,norm+0.1);
-      fSinglePheFit->SetParLimits(7,-35.,15.);
+      if ((fMeanPedestal) && (fSigmaPedestal))
+        fSinglePheFit->SetParLimits(7,
+                                    fMeanPedestal-3.*fMeanPedestalErr,
+                                    fMeanPedestal+3.*fMeanPedestalErr);
+      else
+        fSinglePheFit->SetParLimits(7,-35.,15.);
       break;
 
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.h	(revision 2996)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.h	(revision 2997)
@@ -17,9 +17,11 @@
 private:
 
-  const Int_t fBlindPixelChargeNbins;
-  const Int_t fBlindPixelTimeNbins;
-  const Int_t fBlindPixelChargevsNbins;
-  const Axis_t fBlindPixelTimeFirst;
-  const Axis_t fBlindPixelTimeLast;
+  static const Int_t    fgBlindPixelChargeNbins;
+  static const Int_t    fgBlindPixelTimeNbins;
+  static const Int_t    fgBlindPixelChargevsNbins;
+  static const Axis_t   fgBlindPixelTimeFirst;
+  static const Axis_t   fgBlindPixelTimeLast;
+  static const Double_t fgBlindPixelElectronicAmp;
+  static const Double_t fgBlindPixelElectronicAmpError;
   
   TH1F* fHBlindPixelCharge;        // Histogram with the single Phe spectrum
