Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeBlindPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeBlindPix.cc	(revision 3661)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeBlindPix.cc	(revision 3662)
@@ -24,10 +24,31 @@
 
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MCalibrationChargeBlindPix                                              //
-//                                                                         //
-// This is the storage container to hold informations about the calibration//
-// blind pixel                                                             //
-//                                                                         //
+//                               
+// MCalibrationChargeBlindPix    
+//
+// Storage container of the fit results of the Blind Pixel signal 
+// (from MHCalibrationChargeBlindPix). 
+//
+// The Flux is calculated in photons per mm^2 in the camera plane. 
+//
+// Currently, the following numbers are implemented:
+// - gkBlindPixelArea: 100 mm^2
+// - Average QE of Blind Pixel: 
+//    gkBlindPixelQEGreen: 0.154
+//    gkBlindPixelQEBlue : 0.226
+//    gkBlindPixelQEUV   : 0.247
+//    gkBlindPixelQECT1  : 0.247
+// - Average QE Error of Blind Pixel: 
+//    gkBlindPixelQEGreenErr: 0.015;
+//    gkBlindPixelQEBlueErr : 0.02;
+//    gkBlindPixelQEUVErr   : 0.02;
+//    gkBlindPixelQECT1Err  : 0.02;
+// - Attenuation factor Blind Pixel:
+//    gkBlindPixelAttGreen :  1.97;
+//    gkBlindPixelAttBlue  :  1.96;
+//    gkBlindPixelAttUV    :  1.95;
+//    gkBlindPixelAttCT1   :  1.95;
+//
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MCalibrationChargeBlindPix.h"
@@ -41,26 +62,23 @@
 
 using namespace std;
-const Float_t MCalibrationChargeBlindPix::gkBlindPixelArea = 100;
-// Average QE of Blind Pixel (three colours)
-const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEGreen = 0.154;
-const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEBlue  = 0.226;
-const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUV    = 0.247;
-const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECT1   = 0.247;
-// Average QE Error of Blind Pixel (three colours)
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelArea       = 100;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttGreen   = 1.97;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttBlue    = 1.96;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttUV      = 1.95;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttCT1     = 1.95;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEGreen    = 0.154;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEBlue     = 0.226;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUV       = 0.247;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECT1      = 0.247;
 const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEGreenErr = 0.015;
 const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEBlueErr  = 0.02;
 const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUVErr    = 0.02;
 const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECT1Err   = 0.02;
-// Attenuation factor Blind Pixel (three colours)
-const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttGreen = 1.97;
-const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttBlue  = 1.96;
-const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttUV    = 1.95;
-const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttCT1   = 1.95;
-
-const Float_t MCalibrationChargeBlindPix::fgLambdaCheckLimit   = 0.2;
-const Float_t MCalibrationChargeBlindPix::fgLambdaErrLimit     = 0.2;
 // --------------------------------------------------------------------------
 //
 // Default Constructor. 
+//
+// Calls:
+// - Clear()
 //
 MCalibrationChargeBlindPix::MCalibrationChargeBlindPix(const char *name, const char *title)
@@ -70,7 +88,4 @@
   fTitle = title ? title : "Container of the fit results of the blind pixel";
 
-  SetLambdaCheckLimit();
-  SetLambdaErrLimit();
-
   Clear();
 }
@@ -79,23 +94,27 @@
 // ------------------------------------------------------------------------
 //
-// Invalidate values
+// Sets:
+// - all flags to kFALSE
+// - all variables to -1.
+//
+// Calls: 
+// - MCalibrationChargePix::Clear()
 //
 void MCalibrationChargeBlindPix::Clear(Option_t *o)
 {
 
-  fLambda      = -1.;
-  fLambdaCheck = -1.;
-  fMu0         = -1.;
-  fMu1         = -1.;
-  fSigma0      = -1.;
-  fSigma1      = -1.;
-  fLambdaErr   = -1.;
-  fMu0Err      = -1.;
-  fMu1Err      = -1.;
-  fSigma0Err   = -1.;
-  fSigma1Err   = -1.;
-
-  fMeanFluxInsidePlexiglass          = -1.;
-  fMeanFluxErrInsidePlexiglass       = -1.;
+  fFluxInsidePlexiglass    = -1.;
+  fFluxInsidePlexiglassVar = -1.;
+  fLambda                  = -1.;
+  fLambdaCheck             = -1.;
+  fLambdaVar               = -1.;
+  fMu0                     = -1.;
+  fMu0Err                  = -1.;
+  fMu1                     = -1.;
+  fMu1Err                  = -1.;
+  fSigma0                  = -1.;
+  fSigma0Err               = -1.;
+  fSigma1                  = -1.;
+  fSigma1Err               = -1.;
 
   SetOscillating                   ( kFALSE );
@@ -105,5 +124,6 @@
   SetSinglePheFitOK                ( kFALSE );
   SetFluxInsidePlexiglassAvailable ( kFALSE );
-
+  
+  MCalibrationChargePix::Clear();
 }
 
@@ -113,4 +133,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Set the Oscillating Bit from outside 
+//
 void  MCalibrationChargeBlindPix::SetOscillating( const Bool_t b)
 {
@@ -118,8 +142,17 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Set the ChargeFitValid Bit from outside 
+//
 void  MCalibrationChargeBlindPix::SetChargeFitValid( const Bool_t b)
 {
     b ? SETBIT(fFlags,kChargeFitValid) : CLRBIT(fFlags,kChargeFitValid);
 }
+
+// --------------------------------------------------------------------------
+//
+// Set the PedestalFitValid Bit from outside 
+//
 void  MCalibrationChargeBlindPix::SetPedestalFitOK( const Bool_t b)
 {
@@ -127,4 +160,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Set the SinglePheFitValid Bit from outside 
+//
 void  MCalibrationChargeBlindPix::SetSinglePheFitOK( const Bool_t b)
 {
@@ -132,14 +169,43 @@
 }
 
-void  MCalibrationChargeBlindPix::SetExcluded( const Bool_t b)
-{
-    b ? SETBIT(fFlags,kExcluded) : CLRBIT(fFlags,kExcluded);
-}
-
-Bool_t MCalibrationChargeBlindPix::IsExcluded()       const
-{ 
-   return TESTBIT(fFlags,kExcluded);  
-}
-
+// --------------------------------------------------------------------------
+//
+// Return -1 if fFluxInsidePlexiglassVar is smaller than 0.
+// Return square root of fFluxInsidePlexiglassVar
+// 
+Float_t MCalibrationChargeBlindPix::GetFluxInsidePlexiglassErr() const
+{
+  if (fFluxInsidePlexiglassVar < 0.)
+    return -1.;
+  
+  return TMath::Sqrt(fFluxInsidePlexiglassVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fLambdaVar is smaller than 0.
+// Return square root of fLambdaVar
+// 
+Float_t MCalibrationChargeBlindPix::GetLambdaErr() const
+{
+  if (fLambdaVar < 0.)
+    return -1.;
+  
+  return TMath::Sqrt(fLambdaVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kChargeFitValid
+//
+Bool_t MCalibrationChargeBlindPix::IsChargeFitValid()  const 
+{
+    return TESTBIT(fFlags,kChargeFitValid);
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kOscillating
+//
 Bool_t MCalibrationChargeBlindPix::IsOscillating()  const 
 {
@@ -147,9 +213,8 @@
 }
 
-Bool_t MCalibrationChargeBlindPix::IsChargeFitValid()  const 
-{
-    return TESTBIT(fFlags,kChargeFitValid);
-}
-
+// --------------------------------------------------------------------------
+//
+// Test bit kPedestalFitValid
+//
 Bool_t MCalibrationChargeBlindPix::IsPedestalFitOK()  const 
 {
@@ -157,4 +222,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Test bit kSinglePheFitValid
+//
 Bool_t MCalibrationChargeBlindPix::IsSinglePheFitOK()  const 
 {
@@ -162,4 +231,8 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Test bit kFluxInsidePlexiglassAvailable
+//
 Bool_t  MCalibrationChargeBlindPix::IsFluxInsidePlexiglassAvailable()   const
 {
@@ -168,33 +241,18 @@
 
 
-//
-// The check return kTRUE if:
-//
-// 1) fLambda and fLambdaCheck are separated relatively by fLambdaCheckLimit
-// 2) BlindPixel has an fLambdaErr smaller than  fLambdaErrLimit
-// 
-Bool_t MCalibrationChargeBlindPix::CheckChargeFitValidity()
-{
-
-  if (2.*(fLambdaCheck-fLambda)/(fLambdaCheck+fLambda) < fLambdaCheckLimit)
-    {
-      *fLog << warn << "WARNING: Lambda and Lambda-Check differ by more than "
-            << fLambdaCheckLimit << " in the Blind Pixel " << endl;
-      return kFALSE;
-    }
-  
-  if (fLambdaErr < fLambdaErrLimit) 
-    {
-      *fLog << warn << "WARNING: Error of Fitted Lambda is greater than "
-            << fLambdaErrLimit << " in Blind Pixel " << endl;
-      return kFALSE;
-    }
-      
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-//
+// --------------------------------------------------------------------------
+//
+// Return kFALSE if IsChargeFitValid() is kFALSE
+//
+// Calculate fFluxInsidePlexiglass with the formula:
+// - fFluxInsidePlexiglass    = fLambda * gkBlindPixelArea / gkBlindPixelQE * 10**gkBlindPixelAtt
+// - fFluxInsidePlexiglassVar = sqrt( fLambdaVar / ( fLambda * fLambda ) 
+//                             + ( gkBlindPixelQEErr * gkBlindPixelQEErr / gkBlindPixelQE / gkBlindPixelQE )
+//                               ) * fFluxInsidePlexiglass * * fFluxInsidePlexiglass
+//
+// If the fFluxInsidePlexiglass is smaller than 0., return kFALSE
+// If the Variance is smaller than 0., return kFALSE
+//
+// SetFluxInsidePlexiglassAvailable() and return kTRUE
 //
 Bool_t MCalibrationChargeBlindPix::CalcFluxInsidePlexiglass()
@@ -207,45 +265,47 @@
   //
   // Start calculation of number of photons 
-  //
   // The blind pixel has exactly 100 mm^2 area (with negligible error), 
   //
-  fMeanFluxInsidePlexiglass    = fLambda*gkBlindPixelArea;
-
+  fFluxInsidePlexiglass      = fLambda*gkBlindPixelArea;
+
+  //
   // Start calculation of number of photons relative Variance 
-  fMeanFluxErrInsidePlexiglass  = fLambdaErr*fLambdaErr/fLambda/fLambda;
-  
+  //
+  const Float_t lambdaRelVar = fLambdaVar / ( fLambda * fLambda );
+  fFluxInsidePlexiglassVar   = lambdaRelVar;
+
   switch (fColor)
     {
     case kGREEN:
-      fMeanFluxInsidePlexiglass    /= gkBlindPixelQEGreen;   
-      fMeanFluxErrInsidePlexiglass += gkBlindPixelQEGreenErr*gkBlindPixelQEGreenErr
-                                    / gkBlindPixelQEGreen  /   gkBlindPixelQEGreen;   
-
-      fMeanFluxInsidePlexiglass  *= TMath::Power(10,gkBlindPixelAttGreen); // correct for absorption 
+      fFluxInsidePlexiglass    /=  gkBlindPixelQEGreen;   
+      fFluxInsidePlexiglassVar +=  gkBlindPixelQEGreenErr * gkBlindPixelQEGreenErr
+                               / ( gkBlindPixelQEGreen    * gkBlindPixelQEGreen   );   
+
+      fFluxInsidePlexiglass  *= TMath::Power(10,gkBlindPixelAttGreen); // correct for absorption 
       // attenuation has negligible error
       break;
     case kBLUE:
-      fMeanFluxInsidePlexiglass    /= gkBlindPixelQEBlue;   
-      fMeanFluxErrInsidePlexiglass += gkBlindPixelQEBlueErr*gkBlindPixelQEBlueErr
-                                    / gkBlindPixelQEBlue  /   gkBlindPixelQEBlue;   
-
-      fMeanFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttBlue); // correct for absorption 
+      fFluxInsidePlexiglass    /=  gkBlindPixelQEBlue;   
+      fFluxInsidePlexiglassVar +=  gkBlindPixelQEBlueErr * gkBlindPixelQEBlueErr
+                               / ( gkBlindPixelQEBlue    * gkBlindPixelQEBlue    );   
+
+      fFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttBlue); // correct for absorption 
       // attenuation has negligible error
       break;
     case kUV:
-      fMeanFluxInsidePlexiglass    /= gkBlindPixelQEUV;   
-      fMeanFluxErrInsidePlexiglass += gkBlindPixelQEUVErr*gkBlindPixelQEUVErr
-                                    / gkBlindPixelQEUV  /   gkBlindPixelQEUV;   
-
-      fMeanFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttUV); // correct for absorption 
+      fFluxInsidePlexiglass    /=  gkBlindPixelQEUV;   
+      fFluxInsidePlexiglassVar +=  gkBlindPixelQEUVErr* gkBlindPixelQEUVErr
+                               / ( gkBlindPixelQEUV   * gkBlindPixelQEUV    );   
+
+      fFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttUV); // correct for absorption 
       // attenuation has negligible error
       break;
     case kCT1:
     default:
-      fMeanFluxInsidePlexiglass    /= gkBlindPixelQECT1;   
-      fMeanFluxErrInsidePlexiglass += gkBlindPixelQECT1Err*gkBlindPixelQECT1Err
-                                    / gkBlindPixelQECT1  /   gkBlindPixelQECT1;   
-
-      fMeanFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttCT1); // correct for absorption 
+      fFluxInsidePlexiglass    /=  gkBlindPixelQECT1;   
+      fFluxInsidePlexiglassVar +=  gkBlindPixelQECT1Err * gkBlindPixelQECT1Err
+                               / ( gkBlindPixelQECT1    * gkBlindPixelQECT1    );   
+
+      fFluxInsidePlexiglass *= TMath::Power(10,gkBlindPixelAttCT1); // correct for absorption 
       // attenuation has negligible error
       break;
@@ -254,20 +314,21 @@
   *fLog << inf << endl;
   *fLog << inf << " Photon flux [ph/mm^2] inside Plexiglass: " 
-        << fMeanFluxInsidePlexiglass << endl;
-
-  if (fMeanFluxInsidePlexiglass < 0.)
+        << fFluxInsidePlexiglass << endl;
+
+  if (fFluxInsidePlexiglass < 0.)
       return kFALSE;
 
-  if (fMeanFluxErrInsidePlexiglass < 0.)
+  if (fFluxInsidePlexiglassVar < 0.)
       return kFALSE;
 
   SetFluxInsidePlexiglassAvailable(kTRUE);  
 
-  // Finish calculation of errors -> convert from relative variance to absolute error
-  fMeanFluxErrInsidePlexiglass = TMath::Sqrt(fMeanFluxErrInsidePlexiglass);
-  fMeanFluxErrInsidePlexiglass *= fMeanFluxInsidePlexiglass;
+  //
+  // Finish calculation of errors -> convert from relative variance to absolute variance
+  //
+  fFluxInsidePlexiglassVar *= fFluxInsidePlexiglass * fFluxInsidePlexiglass;
 
   *fLog << inf << " Error on photon flux [ph/mm^2] inside Plexiglass: " 
-        << fMeanFluxErrInsidePlexiglass << endl;
+        << GetFluxInsidePlexiglass() << endl;
   *fLog << inf << endl;
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeBlindPix.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeBlindPix.h	(revision 3661)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeBlindPix.h	(revision 3662)
@@ -10,49 +10,34 @@
 private:
 
-  static const Float_t fgLambdaCheckLimit;  // The default limit (in units of PedRMS) for acceptance of the fitted mean charge
-  static const Float_t fgLambdaErrLimit;    // The default limit (in units of PedRMS) for acceptance of the fitted charge sigma
+  static const Float_t gkBlindPixelArea;        //! The Blind Pixel area in mm^2
+  static const Float_t gkBlindPixelAttGreen;    //! Attenuation Filter at 520 nm 
+  static const Float_t gkBlindPixelAttBlue ;    //! Attenuation Filter at 460 nm 
+  static const Float_t gkBlindPixelAttUV   ;    //! Attenuation Filter at 370 nm 
+  static const Float_t gkBlindPixelAttCT1  ;    //! Attenuation Filter at 370 nm
+  static const Float_t gkBlindPixelQEGreen;     //! Quantum Efficiency at 520 nm
+  static const Float_t gkBlindPixelQEBlue ;     //! Quantum Efficiency at 460 nm
+  static const Float_t gkBlindPixelQEUV   ;     //! Quantum Efficiency at 370 nm
+  static const Float_t gkBlindPixelQECT1  ;     //! Quantum Efficiency at 370 nm
+  static const Float_t gkBlindPixelQEGreenErr;  //! Uncertainty QE at 520 nm 
+  static const Float_t gkBlindPixelQEBlueErr ;  //! Uncertainty QE at 460 nm 
+  static const Float_t gkBlindPixelQEUVErr   ;  //! Uncertainty QE at 370 nm 
+  static const Float_t gkBlindPixelQECT1Err  ;  //! Uncertainty QE at 370 nmu
 
-  static const Float_t gkBlindPixelArea;       // The Blind Pixel area in mm^2
+  Float_t fLambda;                  // Mean Poisson fit
+  Float_t fLambdaCheck;             // Mean Pedestal Check (Gauss) fit
+  Float_t fLambdaCheckErr;          // Error mean pedestal Check fit
+  Float_t fLambdaVar;               // Variance lambda Poisson fit
+  Float_t fFluxInsidePlexiglass;    // Number photons in INNER PIXEL inside the plexiglass
+  Float_t fFluxInsidePlexiglassVar; // Variance number of photons in INNER PIXEL 
+  Float_t fMu0;                     // Position pedestal peak
+  Float_t fMu0Err;                  // Error pos. pedestal-peak
+  Float_t fMu1;                     // Position first photo-electron peak
+  Float_t fMu1Err;                  // Error pos. first photo-electon peak
+  Float_t fSigma0;                  // Width pedestal peak
+  Float_t fSigma0Err;               // Error width pedestal peak
+  Float_t fSigma1;                  // Width first photo-electron peak  
+  Float_t fSigma1Err;               // Error width first photo-electron peak  
 
-  static const Float_t gkBlindPixelQEGreen;
-  static const Float_t gkBlindPixelQEBlue ;
-  static const Float_t gkBlindPixelQEUV   ;
-  static const Float_t gkBlindPixelQECT1  ;
-
-  static const Float_t gkBlindPixelQEGreenErr;
-  static const Float_t gkBlindPixelQEBlueErr ;
-  static const Float_t gkBlindPixelQEUVErr   ;
-  static const Float_t gkBlindPixelQECT1Err  ;
- 
-  static const Float_t gkBlindPixelAttGreen;
-  static const Float_t gkBlindPixelAttBlue ;
-  static const Float_t gkBlindPixelAttUV   ;
-  static const Float_t gkBlindPixelAttCT1  ;
-
-  Float_t fLambdaCheckLimit; // The rel. limit for the rel difference between lambda and lambda check
-  Float_t fLambdaErrLimit;   // The limit for acceptance of the fitted lambda
-
-  Float_t fLambda;           // The mean of the Poisson fit
-  Float_t fLambdaCheck;      // The mean of the pedestal Check fit
-  Float_t fMu0;              // The position of the pedestal-peak
-  Float_t fMu1;              // The position of the first phe-peak
-  Float_t fSigma0;           // The width of the pedestal-peak
-  Float_t fSigma1;           // The width of the first phe-peak  
-
-  Float_t fLambdaErr;        // The error of the mean charge after the fit
-  Float_t fLambdaCheckErr;   // The error of the mean of the pedestal Check fit
-  Float_t fMu0Err;           // The error of the position of the pedestal-peak
-  Float_t fMu1Err;           // The error of the position of the first phe-peak
-  Float_t fSigma0Err;        // The error of the width of the pedestal-peak
-  Float_t fSigma1Err;        // The error of the width of the first phe-peak  
-
-  Float_t fProb;             // The probability of the fit
-  
-  Float_t fMeanFluxInsidePlexiglass;          //  The mean number of photons in an INNER PIXEL inside the plexiglass
-  Float_t fMeanFluxErrInsidePlexiglass;       //  The uncertainty about the number of photons in an INNER PIXEL  
-
-  Byte_t fFlags;
-
-  enum { kOscillating, kPedestalFitOK, kSinglePheFitOK, kChargeFitValid, kExcluded, 
+  enum { kOscillating, kPedestalFitOK, kSinglePheFitOK, kChargeFitValid, 
          kFluxInsidePlexiglassAvailable };
 
@@ -67,49 +52,39 @@
 
   // Setters
-  void SetColor       ( const PulserColor_t color )  {  fColor = color;  }
+  void SetColor            ( const PulserColor_t color )          { fColor        = color; }
+  void SetLambda           ( const Float_t f )                    { fLambda           = f; }
+  void SetLambdaErr        ( const Float_t f )                    { fLambdaVar        = f*f; }
+  void SetLambdaCheck      ( const Float_t f )                    { fLambdaCheck      = f; }
+  void SetLambdaCheckErr   ( const Float_t f )                    { fLambdaCheckErr   = f; }
+  void SetMu0              ( const Float_t f )                    { fMu0              = f; }
+  void SetMu0Err           ( const Float_t f )                    { fMu0Err           = f; }
+  void SetMu1              ( const Float_t f )                    { fMu1              = f; }
+  void SetMu1Err           ( const Float_t f )                    { fMu1Err           = f; }
+  void SetSigma0           ( const Float_t f )                    { fSigma0           = f; }
+  void SetSigma0Err        ( const Float_t f )                    { fSigma0Err        = f; }
+  void SetSigma1           ( const Float_t f )                    { fSigma1           = f; }
+  void SetSigma1Err        ( const Float_t f )                    { fSigma1Err        = f; }
 
-  void SetLambda      ( const Float_t f ) { fLambda      = f;  }
-  void SetLambdaCheck ( const Float_t f ) { fLambdaCheck = f;  }
-  void SetMu0         ( const Float_t f ) { fMu0         = f;  }
-  void SetMu1         ( const Float_t f ) { fMu1         = f;  }
-  void SetSigma0      ( const Float_t f ) { fSigma0      = f;  }
-  void SetSigma1      ( const Float_t f ) { fSigma1      = f;  }
-
-  void SetLambdaErr       ( const Float_t f ) { fLambdaErr    = f;  }
-  void SetLambdaCheckErr  ( const Float_t f ) { fLambdaCheck = f;   }
-  void SetMu0Err          ( const Float_t f ) { fMu0Err       = f;  }
-  void SetMu1Err          ( const Float_t f ) { fMu1Err       = f;  }
-  void SetSigma0Err       ( const Float_t f ) { fSigma0Err    = f;  }
-  void SetSigma1Err       ( const Float_t f ) { fSigma1Err    = f;  }
-
-  void SetProb            ( const Float_t f ) { fProb         = f;  }
-
-  void SetLambdaCheckLimit ( const Float_t f=fgLambdaCheckLimit  ) { fLambdaCheckLimit  = f; }
-  void SetLambdaErrLimit   ( const Float_t f=fgLambdaErrLimit    ) { fLambdaErrLimit    = f; }
-
-  void SetOscillating     ( const Bool_t b=kTRUE);
-  void SetChargeFitValid  ( const Bool_t b=kTRUE);
-  void SetPedestalFitOK   ( const Bool_t b=kTRUE);
-  void SetSinglePheFitOK ( const Bool_t b=kTRUE);
-  void SetFluxInsidePlexiglassAvailable  ( const Bool_t b=kTRUE);
-  void SetExcluded        ( const Bool_t b=kTRUE);
+  void SetOscillating      ( const Bool_t  b=kTRUE);
+  void SetChargeFitValid   ( const Bool_t  b=kTRUE);
+  void SetPedestalFitOK    ( const Bool_t  b=kTRUE);
+  void SetSinglePheFitOK   ( const Bool_t  b=kTRUE);
+  void SetFluxInsidePlexiglassAvailable( const Bool_t b=kTRUE);
   
   // Getters
-  Float_t GetLambda()      const    { return fLambda;      }
-  Float_t GetLambdaCheck() const    { return fLambdaCheck; }
-  Float_t GetMu0()         const    { return fMu0;         }
-  Float_t GetMu1()         const    { return fMu1;         }
-  Float_t GetSigma0()      const    { return fSigma0;      }
-  Float_t GetSigma1()      const    { return fSigma1;      }
-
-  Float_t GetLambdaErr()      const    { return fLambdaErr;      }
-  Float_t GetLambdaCheckErr() const    { return fLambdaCheckErr; }
-  Float_t GetMu0Err()         const    { return fMu0Err;         }
-  Float_t GetMu1Err()         const    { return fMu1Err;         }
-  Float_t GetSigma0Err()      const    { return fSigma0Err;      } 
-  Float_t GetSigma1Err()      const    { return fSigma1Err;      }
-
-  Float_t GetMeanFluxInsidePlexiglass()     const { return fMeanFluxInsidePlexiglass;     }
-  Float_t GetMeanFluxErrInsidePlexiglass()  const { return fMeanFluxErrInsidePlexiglass;  }
+  Float_t GetLambda()                  const { return fLambda;               }
+  Float_t GetLambdaErr()               const;
+  Float_t GetLambdaCheck()             const { return fLambdaCheck;          }
+  Float_t GetLambdaCheckErr()          const { return fLambdaCheckErr;       }
+  Float_t GetFluxInsidePlexiglass()    const { return fFluxInsidePlexiglass; }
+  Float_t GetFluxInsidePlexiglassErr() const;
+  Float_t GetMu0()                     const { return fMu0;                  }
+  Float_t GetMu0Err()                  const { return fMu0Err;               }
+  Float_t GetMu1()                     const { return fMu1;                  }
+  Float_t GetMu1Err()                  const { return fMu1Err;               }
+  Float_t GetSigma0()                  const { return fSigma0;               }
+  Float_t GetSigma0Err()               const { return fSigma0Err;            } 
+  Float_t GetSigma1()                  const { return fSigma1;               }
+  Float_t GetSigma1Err()               const { return fSigma1Err;            }
 
   Bool_t  IsOscillating()                    const;
@@ -117,11 +92,9 @@
   Bool_t  IsPedestalFitOK()                  const;
   Bool_t  IsSinglePheFitOK()                 const;
-  Bool_t  IsExcluded()                       const;
   Bool_t  IsFluxInsidePlexiglassAvailable()  const;
   
   Bool_t CalcFluxInsidePlexiglass();
-  Bool_t CheckChargeFitValidity();
 
-  ClassDef(MCalibrationChargeBlindPix, 1)	// Container for Calibration ChargeBlind Pixel
+  ClassDef(MCalibrationChargeBlindPix, 1)	// Container Charge Calibration Results Blind Pixel
 };
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 3661)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 3662)
@@ -213,12 +213,34 @@
 using namespace std;
 
-const Float_t MCalibrationChargeCalc::fgChargeLimit              = 3.;
-const Float_t MCalibrationChargeCalc::fgChargeErrLimit           = 0.;
-const Float_t MCalibrationChargeCalc::fgChargeRelErrLimit        = 1.;
-const Float_t MCalibrationChargeCalc::fgTimeLowerLimit           = 1.;
-const Float_t MCalibrationChargeCalc::fgTimeUpperLimit           = 2.;
+const Float_t MCalibrationChargeCalc::fgChargeLimit        = 3.;
+const Float_t MCalibrationChargeCalc::fgChargeErrLimit     = 0.;
+const Float_t MCalibrationChargeCalc::fgChargeRelErrLimit  = 1.;
+const Float_t MCalibrationChargeCalc::fgLambdaCheckLimit   = 0.2;
+const Float_t MCalibrationChargeCalc::fgLambdaErrLimit     = 0.2;
+const Float_t MCalibrationChargeCalc::fgTimeLowerLimit     = 1.;
+const Float_t MCalibrationChargeCalc::fgTimeUpperLimit     = 2.;
 // --------------------------------------------------------------------------
 //
 // Default constructor. 
+//
+// Sets all pointers to NULL
+// 
+// Calls AddToBranchList for: 
+// - MRawEvtData.fHiGainPixId   
+// - MRawEvtData.fLoGainPixId   
+// - MRawEvtData.fHiGainFadcSamples
+// - MRawEvtData.fLoGainFadcSamples
+//
+// Initializes:
+// - fChargeLimit       to fgChargeLimit 
+// - fChargeErrLimit    to fgChargeErrLimit   
+// - fChargeRelErrLimit to fgChargeRelErrLimit
+// - fLambdaCheckLimit  to fgLambdaCheckLimit 
+// - fLambdaErrLimit    to fgLambdaErrLimit 
+// - fTimeLowerLimit    to fgTimeLowerLimit 
+// - fTimeUpperLimit    to fgTimeUpperLimit 
+// 
+// Calls:
+// - Clear()
 //
 MCalibrationChargeCalc::MCalibrationChargeCalc(const char *name, const char *title)
@@ -230,20 +252,22 @@
 {
 
-    fName  = name  ? name  : "MCalibrationChargeCalc";
-    fTitle = title ? title : "Task to calculate the calibration constants and MCalibrationCam ";
-
-    AddToBranchList("MRawEvtData.fHiGainPixId");
-    AddToBranchList("MRawEvtData.fLoGainPixId");
-    AddToBranchList("MRawEvtData.fHiGainFadcSamples");
-    AddToBranchList("MRawEvtData.fLoGainFadcSamples");
-
-    Clear();
-
-    SetChargeLimit();
-    SetChargeErrLimit();  
-    
-    SetChargeRelErrLimit();
-    SetTimeLowerLimit();
-    SetTimeUpperLimit();
+  fName  = name  ? name  : "MCalibrationChargeCalc";
+  fTitle = title ? title : "Task to calculate the calibration constants and MCalibrationCam ";
+  
+  AddToBranchList("MRawEvtData.fHiGainPixId");
+  AddToBranchList("MRawEvtData.fLoGainPixId");
+  AddToBranchList("MRawEvtData.fHiGainFadcSamples");
+  AddToBranchList("MRawEvtData.fLoGainFadcSamples");
+  
+  SetChargeLimit();
+  SetChargeErrLimit();  
+  SetChargeRelErrLimit();
+  SetLambdaCheckLimit();
+  SetLambdaErrLimit();
+  SetTimeLowerLimit();
+  SetTimeUpperLimit();
+
+  Clear();
+  
 }
 
@@ -254,12 +278,11 @@
     SETBIT(fFlags, kHiLoGainCalibration);
 
-    fNumHiGainSamples  = 0.;
-    fNumLoGainSamples  = 0.;
-    fSqrtHiGainSamples = 0.;
-    fSqrtLoGainSamples = 0.;
-    fConversionHiLo    = 0;
+    fNumHiGainSamples        = 0.;
+    fNumLoGainSamples        = 0.;
+    fSqrtHiGainSamples       = 0.;
+    fSqrtLoGainSamples       = 0.;
+    fConversionHiLo          = 0 ;
     SkipQualityChecks      ( kFALSE );
     SkipHiLoGainCalibration( kFALSE );    
-
 }
 
@@ -611,13 +634,16 @@
 // Returns kFALSE if pointer to MCalibrationChargePINDiode is NULL
 //
-// The check return kTRUE if:
-//
-// 1) PINDiode has a fitted charge greater than fChargeLimit*PedRMS
-// 2) PINDiode has a fit error greater than fChargeErrLimit
-// 3) PINDiode has a fitted charge greater its fChargeRelErrLimit times its charge error
-// 4) PINDiode has a charge sigma bigger than its Pedestal RMS
-// 5) The mean arrival time is at least fTimeLowerLimit slices from the lower edge 
+// The check returns kFALSE if:
+//
+// 1) PINDiode has a fitted charge smaller than fChargeLimit*PedRMS
+// 2) PINDiode has a fit error smaller than fChargeErrLimit
+// 3) PINDiode has a fitted charge smaller its fChargeRelErrLimit times its charge error
+// 4) PINDiode has a charge sigma smaller than its Pedestal RMS
+// 5) The mean arrival time is in fTimeLowerLimit slices from the lower edge 
 //    and fUpperLimit slices from the upper edge
 // 
+// Calls:
+// - MCalibrationChargePINDiode::CalcFluxOutsidePlexiglass()
+//
 Bool_t MCalibrationChargeCalc::FinalizePINDiode()
 {
@@ -686,4 +712,55 @@
   return kTRUE;
 }
+
+// ------------------------------------------------------------------------
+//
+// Returns kFALSE if pointer to MExtractedSignalBlindPixel is NULL
+// Returns kFALSE if pointer to MCalibrationChargeBlindPix is NULL
+//
+// The check returns kFALSE if:
+//
+// 1) fLambda and fLambdaCheck are separated relatively to each other by more than fLambdaCheckLimit
+// 2) BlindPixel has an fLambdaErr greater than fLambdaErrLimit
+// 
+// Calls:
+// - MCalibrationChargeBlindPix::CalcFluxInsidePlexiglass()
+//
+Bool_t MCalibrationChargeCalc::FinalizeBlindPixel()
+{
+
+  if (!fSigBlind)
+    return kFALSE;
+  
+  if (!fBlindPixel)
+    return kFALSE;  
+
+  const Float_t lambda      = fBlindPixel->GetLambda();
+  const Float_t lambdaerr   = fBlindPixel->GetLambdaErr();
+  const Float_t lambdacheck = fBlindPixel->GetLambdaCheck();
+
+  if (2.*(lambdacheck-lambda)/(lambdacheck+lambda) < fLambdaCheckLimit)
+    {
+      *fLog << warn << "WARNING: Lambda and Lambda-Check differ by more than "
+            << fLambdaCheckLimit << " in the Blind Pixel " << endl;
+      return kFALSE;
+    }
+  
+  if (lambdaerr < fLambdaErrLimit) 
+    {
+      *fLog << warn << "WARNING: Error of Fitted Lambda is greater than "
+            << fLambdaErrLimit << " in Blind Pixel " << endl;
+      return kFALSE;
+    }
+      
+  if (!fBlindPixel->CalcFluxInsidePlexiglass())
+    {
+      *fLog << warn << "Could not calculate the flux of photons from the Blind Pixel, "
+            << "will skip Blind Pixel Calibration " << endl;
+      return kFALSE;
+    }
+  
+  return kTRUE;
+}
+
 
 
@@ -788,24 +865,11 @@
   // Blind Pixel calibration
   //
-  if (!fBlindPixel->CheckChargeFitValidity())
-  {
-      *fLog << warn << "Could not calculate the flux of photons from the Blind Pixel, "
-            << "charge fit not valid " << endl;
-      fCam->SetBlindPixelMethodValid(kFALSE);
-  }
+  if (!FinalizeBlindPixel())
+    fCam->SetBlindPixelMethodValid(kFALSE); 
   else
-  { 
-      if (!fBlindPixel->CalcFluxInsidePlexiglass())
-      {
-	  *fLog << warn << "Could not calculate the flux of photons from the Blind Pixel, "
-                << "will skip PIN Diode Calibration " << endl;
-	  fCam->SetBlindPixelMethodValid(kFALSE);
-      }
-      else
-      {
-	  fCam->SetBlindPixelMethodValid(kTRUE);
-	  fCam->ApplyBlindPixelCalibration(*fGeom,*fBadPixels, *fBlindPixel);
-      }
-  }
+    {
+      fCam->SetBlindPixelMethodValid(kTRUE);
+      fCam->ApplyBlindPixelCalibration(*fGeom,*fBadPixels, *fBlindPixel);
+    }
 
   // 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 3661)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 3662)
@@ -39,13 +39,17 @@
 private:
 
-  static const Float_t fgChargeLimit;       // Default for fChargeLimit        (now set to: 3.)
-  static const Float_t fgChargeErrLimit;    // Default for fChargeErrLimit     (now set to: 0.)
-  static const Float_t fgChargeRelErrLimit; // Default for fChargeRelErrLimit  (now set to: 1.)
-  static const Float_t fgTimeLowerLimit;    // Default for fTimeLowerLimit     (now set to: 1.) 
-  static const Float_t fgTimeUpperLimit;    // Default for fTimeUpperLimit     (now set to: 2.)
+  static const Float_t fgChargeLimit;       //! Default for fChargeLimit       (now set to: 3.)
+  static const Float_t fgChargeErrLimit;    //! Default for fChargeErrLimit    (now set to: 0.)
+  static const Float_t fgChargeRelErrLimit; //! Default for fChargeRelErrLimit (now set to: 1.)
+  static const Float_t fgLambdaCheckLimit;  //! Default for fLambdaCheckLimit  (now set to: 0.2)
+  static const Float_t fgLambdaErrLimit;    //! Default for fLabmdaErrLimit    (now set to: 0.2)
+  static const Float_t fgTimeLowerLimit;    //! Default for fTimeLowerLimit    (now set to: 1.) 
+  static const Float_t fgTimeUpperLimit;    //! Default for fTimeUpperLimit    (now set to: 2.)
   
   Float_t fChargeLimit;          // Limit (in units of PedRMS) for acceptance of mean charge
   Float_t fChargeErrLimit;       // Limit (in units of PedRMS) for acceptance of charge sigma square
   Float_t fChargeRelErrLimit;    // Limit (in units of Sigma of fitted charge) for acceptance of mean  
+  Float_t fLambdaCheckLimit;     // Limit for rel. diff. lambda and lambdacheck blind pixel
+  Float_t fLambdaErrLimit;       // Limit for acceptance of lambda error blind pixel
   Float_t fTimeLowerLimit;       // Limit (in units of FADC slices) for dist. to first signal slice
   Float_t fTimeUpperLimit;       // Limit (in units of FADC slices) for dist. to last signal slice
@@ -89,4 +93,5 @@
   Bool_t FinalizeCharges(MCalibrationChargePix &cal, MBadPixelsPix &bad);
   Bool_t FinalizePINDiode();
+  Bool_t FinalizeBlindPixel();
   
   void PrintUnsuitable(MBadPixelsPix::UnsuitableType_t typ, const char *text) const;   
@@ -102,4 +107,6 @@
   void SetChargeErrLimit (   const Float_t f=fgChargeErrLimit    ) { fChargeErrLimit    = f; }
   void SetChargeRelErrLimit( const Float_t f=fgChargeRelErrLimit ) { fChargeRelErrLimit = f; }
+  void SetLambdaErrLimit   ( const Float_t f=fgLambdaErrLimit   ) { fLambdaErrLimit   = f; }
+  void SetLambdaCheckLimit ( const Float_t f=fgLambdaCheckLimit ) { fLambdaCheckLimit = f; }
 
   void SetTimeLowerLimit (   const Float_t f=fgTimeLowerLimit    ) { fTimeLowerLimit  = f;   }
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 3661)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 3662)
@@ -994,6 +994,6 @@
 {
 
-  Float_t flux    = blindpix.GetMeanFluxInsidePlexiglass();
-  Float_t fluxerr = blindpix.GetMeanFluxErrInsidePlexiglass();
+  Float_t flux    = blindpix.GetFluxInsidePlexiglass();
+  Float_t fluxerr = blindpix.GetFluxInsidePlexiglassErr();
 
   TIter Next(fPixels);
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.cc	(revision 3661)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.cc	(revision 3662)
@@ -31,7 +31,8 @@
 // is the documentation for the moment.
 //
+// The Flux is calculated in photons per mm^2 in the camera plane. 
+//
 // Currently, the following numbers are implemented:
 //
-// Area of Inner Pixel Ai: 779.423 +- 0  mm^2 
 // Area of PIN Diode   Ap: 100.000 +- 10 mm^2 
 //
@@ -41,11 +42,10 @@
 // Distance of Inner Pixel to pulser D2: 18.0 +- 0.5 m
 //
-//                         Ai*D1*D1
-// gkSolidAngleRatio   =   -------- = 0.054
+//                          D1*D1
+// gkSolidAngleRatio   =   -------- = 0.00007
 //                         Ap*D2*D2
 //
-// gkSolidAngleRatioErr = 0.01
-//
-// 
+// gkSolidAngleRatioErr = 0.00002
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MCalibrationChargePINDiode.h"
@@ -61,16 +61,10 @@
 const Float_t MCalibrationChargePINDiode::fgChargeToPhotons    = -1.; 
 const Float_t MCalibrationChargePINDiode::fgChargeToPhotonsErr = -1.; 
-const Float_t MCalibrationChargePINDiode::gkSolidAngleRatio      = 0.055;
-const Float_t MCalibrationChargePINDiode::gkSolidAngleRatioErr   = 0.01;
-//
-// Average QE of the PIN Diode
-//
+const Float_t MCalibrationChargePINDiode::gkSolidAngleRatio      = 0.00007;
+const Float_t MCalibrationChargePINDiode::gkSolidAngleRatioErr   = 0.00002;
 const Float_t MCalibrationChargePINDiode::gkPINDiodeQEGreen    = -1.0;
 const Float_t MCalibrationChargePINDiode::gkPINDiodeQEBlue     = -1.0;
 const Float_t MCalibrationChargePINDiode::gkPINDiodeQEUV       = -1.0;
 const Float_t MCalibrationChargePINDiode::gkPINDiodeQECT1      = -1.0;
-//
-// Average QE of the PIN Diode
-//
 const Float_t MCalibrationChargePINDiode::gkPINDiodeQEGreenErr = -1.0;
 const Float_t MCalibrationChargePINDiode::gkPINDiodeQEBlueErr  = -1.0;
@@ -211,4 +205,14 @@
 // --------------------------------------------------------------------------
 //
+// Test bit kFluxOutsidePlexiglassAvailable
+//
+Bool_t  MCalibrationChargePINDiode::IsFluxOutsidePlexiglassAvailable()   const
+{
+  return TESTBIT(fFlags,kFluxOutsidePlexiglassAvailable);
+}
+
+
+// --------------------------------------------------------------------------
+//
 // Test bit kTimeFitValid
 //
@@ -216,4 +220,13 @@
 {
   return TESTBIT(fCalibFlags, kTimeFitValid);  
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kOscillating
+//
+Bool_t MCalibrationChargePINDiode::IsOscillating()   const 
+{
+  return TESTBIT(fCalibFlags, kOscillating);  
 }
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.h	(revision 3661)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargePINDiode.h	(revision 3662)
@@ -82,5 +82,7 @@
   Bool_t  IsChargeFitValid()    const;
   Bool_t  IsTimeFitValid()      const;
-
+  Bool_t  IsOscillating()       const;
+  Bool_t  IsFluxOutsidePlexiglassAvailable() const;
+  
   Bool_t  CalcFluxOutsidePlexiglass();
 
