Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 4985)
+++ trunk/MagicSoft/Mars/Changelog	(revision 4986)
@@ -32,5 +32,42 @@
 
  2004/09/13: Markus Gaug 
- 
+  
+   * mjobs/MJCalibration.[h,cc]
+     - added MCalibrationIntensityBlindCam
+     - replaced MCalibrationChargeBlindCam by MCalibrationBlindCam
+
+   * mcalib/MCalibrationPix.[h,cc]
+     - added Copy function
+
+   * mcalib/MCalibrationIntensityBlindCam.[h,cc]
+     - new class for Intensity calibration
+
+   * mcalib/MCalibrationBlindCam.[h,cc]
+   * mcalib/MCalibrationBlindPix.[h,cc]
+     - new containers based on MCalibrationCam and MCalibrationPix. 
+     - similiar to MCalibrationChargePix and MCalibrationChargeCam, but 
+       slightly different data members. In order not to get confused with
+       already stored data, this is for the moment a second, equivalent 
+       class. 
+  
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+     - added Intenisty Calibration for blind pixel
+     - take new MCalibrationBlindCam instead of MCalibrationChargeBlindCam
+
+   * mcalib/MCalibrationCam.cc
+   * mcalib/MCalibrationChargeCam.cc
+   * mcalib/MCalibrationQECam.cc
+   * mcalib/MCalibrationRelTimeCam.cc
+     - initialize fAverageBadPixels in derived classes
+
+   * mhcalib/MHCalibrationChargeBlindCam.[h,cc]
+   * mhcalib/MHCalibrationChargeBlindPix.[h,cc]
+     - derive class from MHCalibrationCam now and treat pointers 
+       like done in MHCalibrationChargeCam
+     - implement Intensity Calibration
+     - write results to MCalibrationBlindCam instead of 
+       MCalibrationChargeBlindCam 
+
+
    * mhcalib/MHCalibrationCam.h
      - took out the "->" for all pointers
@@ -38,7 +75,4 @@
        kLoGain, kOscillations, kAverageing, kSizeCheck
 
-   * mhcalib/MHCalibrationBlindCam.h
-     - took out the "->" for all pointers
-	     
    * mhcalib/MHCalibrationChargeCam.[h,cc]
      - wrote a ReadEnv function
Index: trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h	(revision 4985)
+++ trunk/MagicSoft/Mars/mcalib/CalibLinkDef.h	(revision 4986)
@@ -14,4 +14,5 @@
 #pragma link C++ class MCalibrationIntensityCam+;
 #pragma link C++ class MCalibrationIntensityChargeCam+;
+#pragma link C++ class MCalibrationIntensityBlindCam+;
 #pragma link C++ class MCalibrationIntensityQECam+;
 #pragma link C++ class MCalibrationIntensityRelTimeCam+;
@@ -31,4 +32,8 @@
 #pragma link C++ class MCalibrationChargeCam+;
 #pragma link C++ class MCalibrationChargePix+;
+#pragma link C++ class MCalibrationBlindCam+;
+#pragma link C++ class MCalibrationBlindPix+;
+#pragma link C++ class MCalibrationBlindCamOneOldStyle+;
+#pragma link C++ class MCalibrationBlindCamTwoNewStyle+;
 #pragma link C++ class MCalibrationChargeBlindCamOneOldStyle+;
 #pragma link C++ class MCalibrationChargeBlindCamTwoNewStyle+;
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCam.cc	(revision 4986)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCam.cc	(revision 4986)
@@ -0,0 +1,109 @@
+/* ======================================================================== *\
+!
+! *
+! * 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   07/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationBlindCam                                               
+//                                                               
+// Base class for Blind Pixels Calibration results. Derived classes intialize
+// the actual values of the MCalibrationBlindPix's. 
+//
+// Contains TClonesArrays for the following objects:
+// - fBlindPixels:    Array of classes derived from MCalibrationBlindPix, one entry 
+//                    per blind pixel. 
+//
+// All TClonesArrays have to enlarged by the corresponding calls to (e.g. in MGeomApply): 
+// - InitSize()
+//
+// See also: MCalibrationBlindCamOneOldStyle
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationBlindCam.h"
+#include "MCalibrationBlindPix.h"
+
+#include "MLogManip.h"
+
+#include <TClonesArray.h>
+
+ClassImp(MCalibrationBlindCam);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Creates a TClonesArray of MCalibrationBlindPix containers for the TClonesArray's: 
+// - fPixels
+//
+MCalibrationBlindCam::MCalibrationBlindCam(Int_t nblind,const char *name, const char *title)
+{
+
+  fName  = name  ? name  : "MCalibrationBlindCam";
+  fTitle = title ? title : "Calibration Information of blinded pixels in camera";
+
+  fPixels = new TClonesArray("MCalibrationBlindPix",nblind);
+
+  InitSize(nblind);
+}
+
+// --------------------------------------------------------------------------
+//
+// Copy 'constructor'
+//
+void MCalibrationBlindCam::Copy(TObject& object) const
+{
+  
+  MCalibrationBlindCam &calib = (MCalibrationBlindCam&)object;
+  
+  //  MParContainer::Copy(calib);
+  
+  *fLog << err << calib.GetSize() << endl;
+
+  const UInt_t n = GetSize();
+  if (n != 0)
+    {
+      calib.InitSize(n);
+      for (UInt_t i=0; i<n; i++)
+        (*this)[i].Copy(calib[i]);
+    }
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Expands and creates new MCalibrationPix's. Cannot use ExpandCreate(), because
+// for some reason, the constructor of MCalibrationPix does not initialize the 
+// Arrays correctly, then.
+//
+void MCalibrationBlindCam::InitSize( const UInt_t n) 
+{
+  const UInt_t size = GetSize();
+  fPixels->Expand(n);
+
+  for (UInt_t i=size; i<n; i++)
+    (*fPixels)[i] = new MCalibrationBlindPix;
+
+}
+
+
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCam.h	(revision 4986)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCam.h	(revision 4986)
@@ -0,0 +1,23 @@
+#ifndef MARS_MCalibrationBlindCam
+#define MARS_MCalibrationBlindCam
+
+#ifndef MARS_MCalibrationCam
+#include "MCalibrationCam.h"
+#endif
+
+class MCalibrationBlindCam : public MCalibrationCam
+{
+public:
+
+  MCalibrationBlindCam(Int_t nblind=1,const char *name=NULL, const char *title=NULL);
+  
+  void Copy(TObject& object) const;
+
+  // Inits
+  void  Init ( const MGeomCam &geom ) {}
+  void  InitSize ( const UInt_t n );
+  
+  ClassDef(MCalibrationBlindCam, 1) // Container Blind Pixels Calibration Results Camera
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCamOneOldStyle.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCamOneOldStyle.cc	(revision 4986)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCamOneOldStyle.cc	(revision 4986)
@@ -0,0 +1,176 @@
+/* ======================================================================== *\
+!
+! *
+! * 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   07/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationBlindCamOneOldStyle                                               
+//                                                               
+// Blind Pixels Calibration camera until run 31693. The blind pixel camera 
+// consisted then only of one non-coated blind pixel with poorly known 
+// quantum efficiency read out in hardware ID 560.
+//
+// See also: MCalibrationBlindCam
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationBlindCamOneOldStyle.h"
+#include "MCalibrationBlindPix.h"
+
+ClassImp(MCalibrationBlindCamOneOldStyle);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// - CreatePixs();
+// - CreateAreas();   
+// - CreateAtts();   
+// - CreateQEs();     
+// - CreateCollEffs();
+//
+MCalibrationBlindCamOneOldStyle::MCalibrationBlindCamOneOldStyle(const char *name)
+    : MCalibrationBlindCam(1,name,"One Blind Pixel in camera - old style")
+{
+
+  CreatePixs    ();    
+  CreateAreas   ();   
+  CreateAtts    ();   
+  CreateQEs     ();     
+  CreateCollEffs();
+
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Only one blind pixel with ID 559
+//
+void MCalibrationBlindCamOneOldStyle::CreatePixs() 
+{
+
+  (*this)[0].SetPixId(559);
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Only one blind pixel with exactly 100 mm^2 area
+//
+void MCalibrationBlindCamOneOldStyle::CreateAreas() 
+{
+  
+  MCalibrationBlindPix &pix = (MCalibrationBlindPix&)(*this)[0];
+  pix.SetArea(100.);
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// One blind pixel with poorly known qe's: average of David measurments with 
+// 4% error.
+//
+void MCalibrationBlindCamOneOldStyle::CreateQEs() 
+{
+  
+  MCalibrationBlindPix &pix = (MCalibrationBlindPix&)(*this)[0];
+
+  Float_t qe[4];
+
+  qe[    MCalibrationCam::kGREEN ] = 0.154;
+  qe[    MCalibrationCam::kBLUE  ] = 0.226;
+  qe[    MCalibrationCam::kUV    ] = 0.247;
+  qe[    MCalibrationCam::kCT1   ] = 0.247;
+
+  pix.SetQE(4,qe);  
+
+  Float_t qeerr[4];
+
+  qeerr[ MCalibrationCam::kGREEN ] = 0.005;
+  qeerr[ MCalibrationCam::kBLUE  ] = 0.007;
+  qeerr[ MCalibrationCam::kUV    ] = 0.01;
+  qeerr[ MCalibrationCam::kCT1   ] = 0.01;
+
+  pix.SetQEErr(4,qeerr);  
+}
+
+// --------------------------------------------------------------------------
+//
+// One blind pixel with poorly known coll.eff's: email from Eckart with 
+// estimates depending on colour, but 5% error (maybe more??)
+//
+void MCalibrationBlindCamOneOldStyle::CreateCollEffs() 
+{
+
+  MCalibrationBlindPix &pix = (MCalibrationBlindPix&)(*this)[0];
+
+  Float_t colleff[4];
+
+  colleff[MCalibrationCam::kGREEN ] = 0.99;
+  colleff[MCalibrationCam::kBLUE  ] = 0.93;
+  colleff[MCalibrationCam::kUV    ] = 0.90;
+  colleff[MCalibrationCam::kCT1   ] = 0.90;
+
+  pix.SetCollEff(4,colleff);  
+
+  Float_t collefferr[4];
+
+  collefferr[MCalibrationCam::kGREEN ] = 0.05;
+  collefferr[MCalibrationCam::kBLUE  ] = 0.05;
+  collefferr[MCalibrationCam::kUV    ] = 0.05;
+  collefferr[MCalibrationCam::kCT1   ] = 0.05;
+  
+  pix.SetCollEffErr(4,collefferr);  
+}
+
+// --------------------------------------------------------------------------
+//
+// One blind pixel with very well known attenuation 0.01 (datasheet delivered 
+// with filter, precision better than 1%
+//
+void MCalibrationBlindCamOneOldStyle::CreateAtts() 
+{
+
+  MCalibrationBlindPix &pix = (MCalibrationBlindPix&)(*this)[0];
+
+  Float_t att[4];
+
+  att[MCalibrationCam::kGREEN ] = 1.97;
+  att[MCalibrationCam::kBLUE  ] = 1.96;
+  att[MCalibrationCam::kUV    ] = 1.95;
+  att[MCalibrationCam::kCT1   ] = 1.95;
+
+  pix.SetAtt(4,att);
+
+  Float_t atterr[4];
+
+  atterr[MCalibrationCam::kGREEN ] = 0.01;
+  atterr[MCalibrationCam::kBLUE  ] = 0.01;
+  atterr[MCalibrationCam::kUV    ] = 0.01;
+  atterr[MCalibrationCam::kCT1   ] = 0.01;
+  
+  pix.SetAttErr(4,atterr);
+
+}
+
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCamOneOldStyle.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCamOneOldStyle.h	(revision 4986)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCamOneOldStyle.h	(revision 4986)
@@ -0,0 +1,25 @@
+#ifndef MARS_MCalibrationBlindCamOneOldStyle
+#define MARS_MCalibrationBlindCamOneOldStyle
+
+#ifndef MARS_MCalibrationBlindCam
+#include "MCalibrationBlindCam.h"
+#endif
+
+class MCalibrationBlindCamOneOldStyle : public MCalibrationBlindCam
+{
+private:
+
+  void CreatePixs();
+  void CreateAreas();
+  void CreateAtts();
+  void CreateQEs();
+  void CreateCollEffs();
+  
+public:
+
+  MCalibrationBlindCamOneOldStyle(const char *name=NULL);
+  
+  ClassDef(MCalibrationBlindCamOneOldStyle, 1) // Container Blind Pixel Calibration Results - until run 31693
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCamTwoNewStyle.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCamTwoNewStyle.cc	(revision 4986)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCamTwoNewStyle.cc	(revision 4986)
@@ -0,0 +1,232 @@
+/* ======================================================================== *\
+!
+! *
+! * 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   07/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationBlindCamTwoNewStyle                                               
+//                                                               
+// Blind Pixels Calibration camera after run 31693. The blind pixel camera 
+// consisted then of two non-coated blind pixel with very well known 
+// quantum efficiency read out in hardware ID 560 and 561.
+//
+// See also: MCalibrationBlindCam
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationBlindCamTwoNewStyle.h"
+#include "MCalibrationBlindPix.h"
+
+ClassImp(MCalibrationBlindCamTwoNewStyle);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// - CreatePixs();
+// - CreateAreas();   
+// - CreateAtts();   
+// - CreateQEs();     
+// - CreateCollEffs();
+//
+MCalibrationBlindCamTwoNewStyle::MCalibrationBlindCamTwoNewStyle(const char *name)
+    : MCalibrationBlindCam(2,name,"Two Blind Pixels in camera - new style")
+{
+
+  CreatePixs    ();    
+  CreateAreas   ();   
+  CreateAtts    ();   
+  CreateQEs     ();     
+  CreateCollEffs();
+
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Two blind pixels with ID 559 and 560 (software)
+//
+void MCalibrationBlindCamTwoNewStyle::CreatePixs() 
+{
+
+  (*this)[0].SetPixId(559);
+  (*this)[1].SetPixId(560);
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Two blind pixels with exactly 100 mm^2 area
+//
+void MCalibrationBlindCamTwoNewStyle::CreateAreas() 
+{
+
+  MCalibrationBlindPix &pix = (MCalibrationBlindPix&)(*this)[0];
+  pix.SetArea(100.);
+
+  pix = (MCalibrationBlindPix&)(*this)[1];
+  pix.SetArea(100.);
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Two blind pixels with very well known qe's: David's measurments with 
+// 1% error.
+//
+void MCalibrationBlindCamTwoNewStyle::CreateQEs() 
+{
+
+  MCalibrationBlindPix &pix = (MCalibrationBlindPix&)(*this)[0];  
+
+  Float_t qe[4];
+
+  qe[    MCalibrationCam::kGREEN ] = 0.166;
+  qe[    MCalibrationCam::kBLUE  ] = 0.240;
+  qe[    MCalibrationCam::kUV    ] = 0.273;
+  qe[    MCalibrationCam::kCT1   ] = 0.273;
+
+  pix.SetQE(4,qe);  
+
+  Float_t qeerr[4];
+
+  qeerr[    MCalibrationCam::kGREEN ] = 0.004;
+  qeerr[    MCalibrationCam::kBLUE  ] = 0.005;
+  qeerr[    MCalibrationCam::kUV    ] = 0.006;
+  qeerr[    MCalibrationCam::kCT1   ] = 0.006;
+
+  pix.SetQEErr(4,qeerr);  
+
+  pix = (MCalibrationBlindPix&)(*this)[1];
+
+  qe[    MCalibrationCam::kGREEN ] = 0.155;
+  qe[    MCalibrationCam::kBLUE  ] = 0.228;
+  qe[    MCalibrationCam::kUV    ] = 0.261;
+  qe[    MCalibrationCam::kCT1   ] = 0.261;
+
+  pix.SetQE(4,qe);  
+
+  qeerr[    MCalibrationCam::kGREEN ] = 0.004;
+  qeerr[    MCalibrationCam::kBLUE  ] = 0.005;
+  qeerr[    MCalibrationCam::kUV    ] = 0.006;
+  qeerr[    MCalibrationCam::kCT1   ] = 0.006;
+
+  pix.SetQEErr(4,qeerr);  
+
+}
+
+// --------------------------------------------------------------------------
+//
+// One blind pixel with poorly known coll.eff's: email from Eckart with 
+// estimates depending on colour, but 5% error (maybe more??)
+//
+void MCalibrationBlindCamTwoNewStyle::CreateCollEffs() 
+{
+
+  MCalibrationBlindPix &pix = (MCalibrationBlindPix&)(*this)[0];  
+
+  Float_t colleff[4];
+
+  colleff[    MCalibrationCam::kGREEN ] = 0.99;
+  colleff[    MCalibrationCam::kBLUE  ] = 0.93;
+  colleff[    MCalibrationCam::kUV    ] = 0.90;
+  colleff[    MCalibrationCam::kCT1   ] = 0.90;
+
+  pix.SetCollEff(4,colleff);  
+
+  Float_t collefferr[4];
+
+  collefferr[    MCalibrationCam::kGREEN ] = 0.05;
+  collefferr[    MCalibrationCam::kBLUE  ] = 0.05;
+  collefferr[    MCalibrationCam::kUV    ] = 0.05;
+  collefferr[    MCalibrationCam::kCT1   ] = 0.05;
+
+  pix.SetCollEffErr(4,collefferr);  
+
+  pix = (MCalibrationBlindPix&)(*this)[1];
+  
+  colleff[    MCalibrationCam::kGREEN ] = 0.99;
+  colleff[    MCalibrationCam::kBLUE  ] = 0.93;
+  colleff[    MCalibrationCam::kUV    ] = 0.90;
+  colleff[    MCalibrationCam::kCT1   ] = 0.90;
+
+  pix.SetCollEff(4,colleff);  
+
+  collefferr[    MCalibrationCam::kGREEN ] = 0.05;
+  collefferr[    MCalibrationCam::kBLUE  ] = 0.05;
+  collefferr[    MCalibrationCam::kUV    ] = 0.05;
+  collefferr[    MCalibrationCam::kCT1   ] = 0.05;
+  
+  pix.SetCollEffErr(4,collefferr);    
+}
+
+// --------------------------------------------------------------------------
+//
+// One blind pixel has a very well known attenuation 0.01 (datasheet delivered 
+// with filter, precision better than 1%
+//
+// The second blind pixel is not yet so well known, the company does not reply.
+// Attenuation: 0.001 (datasheet not delivered with filter, precision guaranteed to 5%)
+//
+void MCalibrationBlindCamTwoNewStyle::CreateAtts() 
+{
+
+  MCalibrationBlindPix &pix = (MCalibrationBlindPix&)(*this)[0];  
+
+  Float_t att[4];
+
+  att[MCalibrationCam::kGREEN ] = 1.97;
+  att[MCalibrationCam::kBLUE  ] = 1.96;
+  att[MCalibrationCam::kUV    ] = 1.95;
+  att[MCalibrationCam::kCT1   ] = 1.95;
+
+  pix.SetAtt(4,att);
+
+  Float_t atterr[4];
+
+  atterr[    MCalibrationCam::kGREEN ] = 0.01;
+  atterr[    MCalibrationCam::kBLUE  ] = 0.01;
+  atterr[    MCalibrationCam::kUV    ] = 0.01;
+  atterr[    MCalibrationCam::kCT1   ] = 0.01;
+
+  pix.SetAttErr(4,atterr);
+
+  pix = (MCalibrationBlindPix&)(*this)[1];  
+
+  att[MCalibrationCam::kGREEN ] = 3.00;
+  att[MCalibrationCam::kBLUE  ] = 3.00;
+  att[MCalibrationCam::kUV    ] = 3.00;
+  att[MCalibrationCam::kCT1   ] = 3.00;
+
+  pix.SetAtt(4,att);
+
+  atterr[    MCalibrationCam::kGREEN ] = 0.15;
+  atterr[    MCalibrationCam::kBLUE  ] = 0.15;
+  atterr[    MCalibrationCam::kUV    ] = 0.15;
+  atterr[    MCalibrationCam::kCT1   ] = 0.15;
+
+  pix.SetAttErr(4,atterr);
+  
+}
+
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCamTwoNewStyle.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCamTwoNewStyle.h	(revision 4986)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationBlindCamTwoNewStyle.h	(revision 4986)
@@ -0,0 +1,25 @@
+#ifndef MARS_MCalibrationBlindCamTwoNewStyle
+#define MARS_MCalibrationBlindCamTwoNewStyle
+
+#ifndef MARS_MCalibrationBlindCam
+#include "MCalibrationBlindCam.h"
+#endif
+
+class MCalibrationBlindCamTwoNewStyle : public MCalibrationBlindCam
+{
+private:
+
+  void CreatePixs();
+  void CreateAreas();
+  void CreateAtts();
+  void CreateQEs();
+  void CreateCollEffs();
+  
+public:
+
+  MCalibrationBlindCamTwoNewStyle(const char *name=NULL);
+  
+  ClassDef(MCalibrationBlindCamTwoNewStyle, 1) // Container Blind Pixel Calibration Results - after run 31693
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationBlindPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationBlindPix.cc	(revision 4986)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationBlindPix.cc	(revision 4986)
@@ -0,0 +1,549 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                               
+// MCalibrationBlindPix    
+//
+// 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:
+// - fArea: 100 mm^2
+// - Average QE of Blind Pixel: 
+//    fQEGreen: 0.154
+//    fQEBlue : 0.226
+//    fQEUV   : 0.247
+//    fQECT1  : 0.247
+// - Average QE Error of Blind Pixel: 
+//    fQEGreenErr: 0.015;
+//    fQEBlueErr : 0.02;
+//    fQEUVErr   : 0.02;
+//    fQECT1Err  : 0.02;
+// - Attenuation factor Blind Pixel:
+//    fAttGreen :  1.97;
+//    fAttBlue  :  1.96;
+//    fAttUV    :  1.95;
+//    fAttCT1   :  1.95;
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationBlindPix.h"
+
+#include <TH1.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MCalibrationBlindPix);
+
+using namespace std;
+const Float_t MCalibrationBlindPix::fgArea       = 100;
+const Float_t MCalibrationBlindPix::fgAttGreen   = 1.97;
+const Float_t MCalibrationBlindPix::fgAttBlue    = 1.96;
+const Float_t MCalibrationBlindPix::fgAttUV      = 1.95;
+const Float_t MCalibrationBlindPix::fgAttCT1     = 1.95;
+const Float_t MCalibrationBlindPix::fgAttErr     = 0.01;
+const Float_t MCalibrationBlindPix::fgQEGreen    = 0.154;
+const Float_t MCalibrationBlindPix::fgQEBlue     = 0.226;
+const Float_t MCalibrationBlindPix::fgQEUV       = 0.247;
+const Float_t MCalibrationBlindPix::fgQECT1      = 0.247;
+const Float_t MCalibrationBlindPix::fgQEErrGreen = 0.005;
+const Float_t MCalibrationBlindPix::fgQEErrBlue  = 0.007;
+const Float_t MCalibrationBlindPix::fgQEErrUV    = 0.01;
+const Float_t MCalibrationBlindPix::fgQEErrCT1   = 0.01;
+const Float_t MCalibrationBlindPix::fgCollEffGreen = 0.99; 
+const Float_t MCalibrationBlindPix::fgCollEffBlue  = 0.93; 
+const Float_t MCalibrationBlindPix::fgCollEffUV    = 0.90; 
+const Float_t MCalibrationBlindPix::fgCollEffCT1   = 0.90; 
+const Float_t MCalibrationBlindPix::fgCollEffErr   = 0.05; 
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Calls:
+// - Clear()
+//
+// For backward-compatibility reasons, quantum eff., coll. eff. and att. 
+// are intialized from the static members. This should, however, be 
+// overwritten by a class deriving from MCalibrationBlindCam. 
+//
+MCalibrationBlindPix::MCalibrationBlindPix(const char *name, const char *title)
+{
+
+  fName  = name  ? name  : "MCalibrationBlindPix";
+  fTitle = title ? title : "Container of the fit results of the blind pixel";
+
+  Clear();
+
+  *fLog << err << "SIZE: " << fAtt.GetSize() << endl;
+
+  fArea = fgArea;
+
+  Float_t att[MCalibrationCam::gkNumPulserColors];
+
+  att [ MCalibrationCam::kGREEN ] = fgAttGreen; 
+  att [ MCalibrationCam::kBLUE  ] = fgAttBlue; 
+  att [ MCalibrationCam::kUV    ] = fgAttUV; 
+  att [ MCalibrationCam::kCT1   ] = fgAttCT1; 
+
+  SetAtt(MCalibrationCam::gkNumPulserColors,att);
+
+  Float_t atterr[MCalibrationCam::gkNumPulserColors];
+
+  atterr [ MCalibrationCam::kGREEN ] = fgAttErr; 
+  atterr [ MCalibrationCam::kBLUE  ] = fgAttErr; 
+  atterr [ MCalibrationCam::kUV    ] = fgAttErr; 
+  atterr [ MCalibrationCam::kCT1   ] = fgAttErr; 
+  
+  SetAttErr(MCalibrationCam::gkNumPulserColors,atterr);
+
+  Float_t qe[MCalibrationCam::gkNumPulserColors];
+
+  qe [ MCalibrationCam::kGREEN ] = fgQEGreen; 
+  qe [ MCalibrationCam::kBLUE  ] = fgQEBlue; 
+  qe [ MCalibrationCam::kUV    ] = fgQEUV; 
+  qe [ MCalibrationCam::kCT1   ] = fgQECT1; 
+
+  SetQE(MCalibrationCam::gkNumPulserColors,qe);  
+
+  Float_t qeerr[MCalibrationCam::gkNumPulserColors];
+
+  qeerr [ MCalibrationCam::kGREEN ] = fgQEErrGreen; 
+  qeerr [ MCalibrationCam::kBLUE  ] = fgQEErrBlue; 
+  qeerr [ MCalibrationCam::kUV    ] = fgQEErrUV; 
+  qeerr [ MCalibrationCam::kCT1   ] = fgQEErrCT1; 
+
+  SetQEErr(MCalibrationCam::gkNumPulserColors,qeerr);  
+
+  Float_t colleff[MCalibrationCam::gkNumPulserColors];
+
+  colleff [ MCalibrationCam::kGREEN ] = fgCollEffGreen; 
+  colleff [ MCalibrationCam::kBLUE  ] = fgCollEffBlue; 
+  colleff [ MCalibrationCam::kUV    ] = fgCollEffUV; 
+  colleff [ MCalibrationCam::kCT1   ] = fgCollEffCT1; 
+
+  SetCollEff(MCalibrationCam::gkNumPulserColors,colleff);  
+
+  Float_t collefferr[MCalibrationCam::gkNumPulserColors];
+
+  collefferr [ MCalibrationCam::kGREEN ] = fgCollEffErr; 
+  collefferr [ MCalibrationCam::kBLUE  ] = fgCollEffErr; 
+  collefferr [ MCalibrationCam::kUV    ] = fgCollEffErr; 
+  collefferr [ MCalibrationCam::kCT1   ] = fgCollEffErr; 
+
+  SetCollEffErr(MCalibrationCam::gkNumPulserColors,collefferr);  
+}
+
+// ------------------------------------------------------------------------
+//
+// Sets:
+// - all flags to kFALSE
+// - all variables to -1.
+// - the fColor to MCalibrationCam::kNONE
+//
+// Calls: 
+// - MCalibrationPix::Clear()
+//
+void MCalibrationBlindPix::Clear(Option_t *o)
+{
+
+  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 );
+  SetExcluded                      ( kFALSE );
+  SetChargeFitValid                ( kFALSE );
+  SetPedestalFitOK                 ( kFALSE );
+  SetSinglePheFitOK                ( kFALSE );
+  SetFluxInsidePlexiglassAvailable ( kFALSE );
+  
+  SetColor(MCalibrationCam::kNONE);
+
+  MCalibrationPix::Clear();
+}
+
+void  MCalibrationBlindPix::SetFluxInsidePlexiglassAvailable( const Bool_t b)
+{
+    b ? SETBIT(fFlags,kFluxInsidePlexiglassAvailable) : CLRBIT(fFlags,kFluxInsidePlexiglassAvailable);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set the Oscillating Bit from outside 
+//
+void  MCalibrationBlindPix::SetOscillating( const Bool_t b)
+{
+    b ? SETBIT(fFlags,kOscillating) : CLRBIT(fFlags,kOscillating);
+}
+
+// -----------------------------------------------------
+//
+// copy 'constructor'
+//
+void MCalibrationBlindPix::Copy(TObject& object) const
+{
+
+  MCalibrationBlindPix &pix = (MCalibrationBlindPix&)object;
+
+  //
+  // Copy the data members
+  //
+  pix.fPixId      = fPixId;
+  pix.fFlags      = fFlags;
+  pix.fArea       = fArea;                     
+  pix.fColor      = fColor;
+
+  //
+  // Copy arrays
+  //
+  pix.fAtt        = fAtt;   
+  pix.fAttErr     = fAttErr;            
+  pix.fQE         = fQE;                       
+  pix.fQEErr      = fQEErr;                    
+  pix.fCollEff    = fCollEff;                  
+  pix.fCollEffErr = fCollEffErr;               
+ 
+  pix.fLambda                  = fLambda;                   
+  pix.fLambdaCheck             = fLambdaCheck;              
+  pix.fLambdaCheckErr          = fLambdaCheckErr;           
+  pix.fLambdaVar               = fLambdaVar;                
+  pix.fFluxInsidePlexiglass    = fFluxInsidePlexiglass;     
+  pix.fFluxInsidePlexiglassVar = fFluxInsidePlexiglassVar;  
+  pix.fMu0       = fMu0;                      
+  pix.fMu0Err    = fMu0Err;                   
+  pix.fMu1       = fMu1;                      
+  pix.fMu1Err    = fMu1Err;                   
+  pix.fSigma0    = fSigma0;                   
+  pix.fSigma0Err = fSigma0Err;                
+  pix.fSigma1    = fSigma1;                   
+  pix.fSigma1Err = fSigma1Err;                
+ 
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set the ChargeFitValid Bit from outside 
+//
+void  MCalibrationBlindPix::SetChargeFitValid( const Bool_t b)
+{
+    b ? SETBIT(fFlags,kChargeFitValid) : CLRBIT(fFlags,kChargeFitValid);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the PedestalFitValid Bit from outside 
+//
+void  MCalibrationBlindPix::SetPedestalFitOK( const Bool_t b)
+{
+    b ? SETBIT(fFlags,kPedestalFitOK) : CLRBIT(fFlags,kPedestalFitOK);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the SinglePheFitValid Bit from outside 
+//
+void  MCalibrationBlindPix::SetSinglePheFitOK( const Bool_t b)
+{
+    b ? SETBIT(fFlags,kSinglePheFitOK) : CLRBIT(fFlags,kSinglePheFitOK);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fFluxInsidePlexiglassVar is smaller than 0.
+// Return square root of fFluxInsidePlexiglassVar
+// 
+const Float_t MCalibrationBlindPix::GetFluxInsidePlexiglassErr() const
+{
+  if (fFluxInsidePlexiglassVar < 0.)
+    return -1.;
+  
+  return TMath::Sqrt(fFluxInsidePlexiglassVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fFluxInsidePlexiglassVar is smaller than 0.
+// Return -1 if fFluxInsidePlexiglass    is 0.
+// Return fFluxInsidePlexiglassVar / fFluxInsidePlexiglass^2
+// 
+const Float_t MCalibrationBlindPix::GetFluxInsidePlexiglassRelVar() const
+{
+  if (fFluxInsidePlexiglassVar < 0.)
+    return -1.;
+
+  if (fFluxInsidePlexiglass == 0.)
+    return -1.;
+  
+  return fFluxInsidePlexiglassVar / (fFluxInsidePlexiglass * fFluxInsidePlexiglass) ;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fLambdaVar is smaller than 0.
+// Return square root of fLambdaVar
+// 
+const Float_t MCalibrationBlindPix::GetLambdaErr() const
+{
+  if (fLambdaVar < 0.)
+    return -1.;
+  
+  return TMath::Sqrt(fLambdaVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fLambdaVar is smaller than 0.
+// Return -1 if fLambda    is 0.
+// Return fLambdaVar / (fLambda * fLambda )
+// 
+const Float_t  MCalibrationBlindPix::GetLambdaRelVar() const
+{
+  if (fLambdaVar < 0.)
+    return -1.;
+  
+  if (fLambda  == 0.)
+    return -1.;
+  
+  return fLambdaVar / fLambda / fLambda ;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return TMath::Power(10,fAtt[fColor])
+//
+const Float_t MCalibrationBlindPix::GetAtt() const
+{
+  return TMath::Power(10,fAtt[fColor]);   
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fAttErr[fColor] is smaller than 0.
+// Error of TMath::Power(10,fAtt[fColor]) = TMath::Power(10,fAtt[fColor])*ln(10.)*fAttErr[fColor]
+// Return fAttErr^2 / (fAtt^2 )
+// 
+const Float_t MCalibrationBlindPix::GetAttRelVar() const
+{
+
+  const Float_t err = fAttErr[fColor];
+
+  if (err < 0.)
+    return -1.;
+  
+  return err*err*2.3;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return fQE[fColor]
+//
+const Float_t MCalibrationBlindPix::GetQE() const
+{
+  return fQE[fColor];
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fQEErr[fColor] is smaller than 0.
+// Return fQEErr^2 / (fQE^2 )
+// 
+const Float_t MCalibrationBlindPix::GetQERelVar() const
+{
+
+  if (fQEErr[fColor] < 0.)
+    return -1.;
+  
+  return fQEErr[fColor]* fQEErr[fColor] / GetQE() / GetQE();
+}
+
+// --------------------------------------------------------------------------
+//
+// Return fCollEff[fColor]
+//
+const Float_t MCalibrationBlindPix::GetCollEff() const
+{
+  return fCollEff[fColor];
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fCollEffErr[fColor] is smaller than 0.
+// Return fCollEffErr^2 / (fCollEff^2 )
+// 
+const Float_t MCalibrationBlindPix::GetCollEffRelVar() const
+{
+
+  if (fCollEffErr[fColor] < 0.)
+    return -1.;
+  
+  return fCollEffErr[fColor]* fCollEffErr[fColor] / GetCollEff() / GetCollEff();
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kChargeFitValid
+//
+const Bool_t MCalibrationBlindPix::IsChargeFitValid()  const 
+{
+    return TESTBIT(fFlags,kChargeFitValid);
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kOscillating
+//
+const Bool_t MCalibrationBlindPix::IsOscillating()  const 
+{
+    return TESTBIT(fFlags,kOscillating);
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kPedestalFitValid
+//
+const Bool_t MCalibrationBlindPix::IsPedestalFitOK()  const 
+{
+    return TESTBIT(fFlags,kPedestalFitOK);
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kSinglePheFitValid
+//
+const Bool_t MCalibrationBlindPix::IsSinglePheFitOK()  const 
+{
+    return TESTBIT(fFlags,kSinglePheFitOK);
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kFluxInsidePlexiglassAvailable
+//
+const Bool_t  MCalibrationBlindPix::IsFluxInsidePlexiglassAvailable()   const
+{
+  return TESTBIT(fFlags,kFluxInsidePlexiglassAvailable);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Return kFALSE if IsChargeFitValid() is kFALSE
+//
+// Calculate fFluxInsidePlexiglass with the formula:
+// - fFluxInsidePlexiglass    = fLambda 
+//                            / GetCollEff()
+//                            / GetQE() 
+//                            * GetAtt()
+//                            / fArea 
+// - fFluxInsidePlexiglassVar = sqrt( fLambdaVar / ( fLambda * fLambda ) 
+//                             + GetQERelVar() 
+//                             + GetCollEffRelVar()
+//                             + GetAttRelVar()
+//                               ) * 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 MCalibrationBlindPix::CalcFluxInsidePlexiglass()
+{
+
+  if (IsChargeFitValid())
+    return kFALSE;
+  
+
+  //
+  // Start calculation of number of photons 
+  // The blind pixel has exactly 100 mm^2 area (with negligible error), 
+  //
+  fFluxInsidePlexiglass    = fLambda / GetQE() * GetAtt() / GetCollEff() / fArea;   
+
+  if (fFluxInsidePlexiglass < 0.)
+      return kFALSE;
+
+  fFluxInsidePlexiglassVar = GetLambdaRelVar() + GetQERelVar() + GetAttRelVar() + GetCollEffRelVar();
+
+  //
+  // Finish calculation of errors -> convert from relative variance to absolute variance
+  //
+  fFluxInsidePlexiglassVar *= fFluxInsidePlexiglass * fFluxInsidePlexiglass;
+
+  if (fFluxInsidePlexiglassVar < 0.)
+      return kFALSE;
+
+  SetFluxInsidePlexiglassAvailable(kTRUE);  
+
+  *fLog << inf << GetDescriptor() 
+        << ": Blind Pixel Nr. " << fPixId << ": Photon flux [ph/mm^2] inside Plexiglass: " 
+        << Form("%5.3f%s%5.3f",fFluxInsidePlexiglass," +- ",GetFluxInsidePlexiglassErr()) << endl;
+
+  return kTRUE;
+}
+
+void MCalibrationBlindPix::Print(Option_t *opt) const
+{
+  
+  *fLog << all << GetDescriptor() 
+        << Form("%s%3i","BlindPixel: "       ,GetPixId())
+        << Form("%s%4.2f%s%4.2f","  Lambda: ",GetLambda(),"+-",GetLambdaErr())
+        << Form("%s%4.2f%s%4.2f","  Mu0: "   ,GetMu0(),   "+-",GetMu0Err())
+        << Form("%s%4.2f%s%4.2f","  Mu1: "   ,GetMu1(),   "+-",GetMu1Err()) 
+        << Form("%s%4.2f%s%4.2f","  Sigma0: ",GetSigma0(),"+-",GetSigma0Err())
+        << Form("%s%4.2f%s%4.2f","  Sigma1: ",GetSigma1(),"+-",GetSigma1Err())
+        << endl;
+  *fLog << all
+        << " Pedestal Fit OK? :" << IsPedestalFitOK() 
+        << Form("%s%4.2f%s%4.2f","  Lambda (Check): " ,GetLambdaCheck(),"+-",GetLambdaCheckErr()) 
+        << endl;
+  *fLog << all
+        << " Flux available? :" << IsFluxInsidePlexiglassAvailable() 
+        << Form("%s%4.2f%s%4.2f","  Flux: " ,GetFluxInsidePlexiglass(),"+-",GetFluxInsidePlexiglassErr())
+        << endl;
+}
+
+
+
+
+
+
+
+
+
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationBlindPix.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationBlindPix.h	(revision 4986)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationBlindPix.h	(revision 4986)
@@ -0,0 +1,143 @@
+#ifndef MARS_MCalibrationBlindPix
+#define MARS_MCalibrationBlindPix
+
+#ifndef ROOT_MArrayF
+#include <MArrayF.h>
+#endif
+
+#ifndef MARS_MCalibrationCam
+#include "MCalibrationCam.h"
+#endif
+
+#ifndef MARS_MCalibrationPix
+#include "MCalibrationPix.h"
+#endif
+
+class MCalibrationBlindPix : public MCalibrationPix
+{
+private:
+
+  static const Float_t fgArea;         //! The Blind Pixel area in mm^2
+  static const Float_t fgAttGreen;     //! Attenuation Filter at 520 nm 
+  static const Float_t fgAttBlue ;     //! Attenuation Filter at 460 nm 
+  static const Float_t fgAttUV   ;     //! Attenuation Filter at 370 nm 
+  static const Float_t fgAttCT1  ;     //! Attenuation Filter at 370 nm
+  static const Float_t fgAttErr;       //! Error Att. Filter at all w.l.
+  static const Float_t fgQEGreen;      //! Quantum Efficiency at 520 nm
+  static const Float_t fgQEBlue ;      //! Quantum Efficiency at 460 nm
+  static const Float_t fgQEUV   ;      //! Quantum Efficiency at 370 nm
+  static const Float_t fgQECT1  ;      //! Quantum Efficiency at 370 nm
+  static const Float_t fgQEErrGreen;   //! Uncertainty QEUnCoated at 520 nm 
+  static const Float_t fgQEErrBlue;    //! Uncertainty QEUnCoated at 460 nm 
+  static const Float_t fgQEErrUV   ;   //! Uncertainty QEUnCoated at 370 nm 
+  static const Float_t fgQEErrCT1  ;   //! Uncertainty QEUnCoated at 370 nmu
+  static const Float_t fgCollEffGreen; //! Collecttion Efficiency
+  static const Float_t fgCollEffBlue;  //! Collecttion Efficiency
+  static const Float_t fgCollEffUV;    //! Collecttion Efficiency
+  static const Float_t fgCollEffCT1;   //! Collecttion Efficiency
+  static const Float_t fgCollEffErr;   //! Uncertainty Collection Efficiency
+
+  Float_t fArea;                       // Blind Pixel Area 
+  MArrayF fAtt;                        // Attenuation filter (per color)
+  MArrayF fAttErr;                     // Error attnuation filter (per color)
+  MArrayF fQE;                         // Quantum eff. (per color)
+  MArrayF fQEErr;                      // Error Quantum eff. (per color)
+  MArrayF fCollEff;                    // Coll eff. (per color)
+  MArrayF fCollEffErr;                 // Error coll. eff. (per color)
+                                        
+  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  
+
+  enum { kOscillating, kPedestalFitOK, kSinglePheFitOK, kChargeFitValid, 
+         kFluxInsidePlexiglassAvailable };   // Possible validity flags 
+
+  MCalibrationCam::PulserColor_t fColor;     // Colour of the used pulser light
+
+public:
+
+  MCalibrationBlindPix(const char *name=NULL, const char *title=NULL);
+  
+  Bool_t CalcFluxInsidePlexiglass();
+  void   Clear(Option_t *o="");
+  void   Copy(TObject& object) const;
+  
+  // Getters
+  const Float_t GetAtt          () const; 
+  const Float_t GetAttRelVar    () const; 
+  const Float_t GetQE           () const; 
+  const Float_t GetQERelVar     () const; 
+  const Float_t GetCollEff      () const;
+  const Float_t GetCollEffRelVar() const;   
+
+  const MCalibrationCam::PulserColor_t GetColor () const { return fColor;                }
+  const Float_t GetLambda                       () const { return fLambda;               }
+  const Float_t GetLambdaErr                    () const;
+  const Float_t GetLambdaRelVar                 () const;  
+  const Float_t GetLambdaCheck                  () const { return fLambdaCheck;          }
+  const Float_t GetLambdaCheckErr               () const { return fLambdaCheckErr;       }
+  const Float_t GetFluxInsidePlexiglass         () const { return fFluxInsidePlexiglass; }
+  const Float_t GetFluxInsidePlexiglassErr      () const;
+  const Float_t GetFluxInsidePlexiglassRelVar   () const;  
+  const Float_t GetMu0                          () const { return fMu0;                  }
+  const Float_t GetMu0Err                       () const { return fMu0Err;               }
+  const Float_t GetMu1                          () const { return fMu1;                  }
+  const Float_t GetMu1Err                       () const { return fMu1Err;               }
+  const Float_t GetSigma0                       () const { return fSigma0;               }
+  const Float_t GetSigma0Err                    () const { return fSigma0Err;            } 
+  const Float_t GetSigma1                       () const { return fSigma1;               }
+  const Float_t GetSigma1Err                    () const { return fSigma1Err;            }
+
+  const Bool_t  IsOscillating                   () const;
+  const Bool_t  IsChargeFitValid                () const;
+  const Bool_t  IsPedestalFitOK                 () const;
+  const Bool_t  IsSinglePheFitOK                () const;
+  const Bool_t  IsFluxInsidePlexiglassAvailable () const;
+
+  void Print(Option_t *opt=NULL) const;
+  
+  // Setters
+  void SetArea      ( Float_t f )               { fArea = f; }
+  
+  void SetAtt       ( Int_t n, Float_t *array ) { fAtt       .Set(n,array); }
+  void SetAttErr    ( Int_t n, Float_t *array ) { fAttErr    .Set(n,array); }
+  void SetQE        ( Int_t n, Float_t *array ) { fQE        .Set(n,array); }
+  void SetQEErr     ( Int_t n, Float_t *array ) { fQEErr     .Set(n,array); }
+  void SetCollEff   ( Int_t n, Float_t *array ) { fCollEff   .Set(n,array); }
+  void SetCollEffErr( Int_t n, Float_t *array ) { fCollEffErr.Set(n,array); }
+  
+  void SetColor          ( const MCalibrationCam::PulserColor_t color ) { fColor      = color; }
+  void SetLambda         ( const Float_t f )                            { fLambda         = f; }
+  void SetLambdaVar      ( const Float_t f )                            { fLambdaVar      = 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 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);
+
+  ClassDef(MCalibrationBlindPix, 1)	// Container Calibration Results Blind Pixel
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc	(revision 4985)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc	(revision 4986)
@@ -89,9 +89,7 @@
 MCalibrationCam::MCalibrationCam(const char *name, const char *title)
     : fPulserColor(kNONE), 
-      fPixels(NULL), fAverageAreas(NULL), fAverageSectors(NULL)
-{
-
-  fAverageBadAreas    = new TClonesArray("MBadPixelsPix",1);
-  fAverageBadSectors  = new TClonesArray("MBadPixelsPix",1);
+      fPixels(NULL), fAverageAreas(NULL), fAverageSectors(NULL),
+      fAverageBadAreas(NULL), fAverageBadSectors(NULL)
+{
 
   fNumHiGainFADCSlices.Set(1);
@@ -125,6 +123,9 @@
     delete fAverageSectors;
 
-  delete fAverageBadAreas;
-  delete fAverageBadSectors;
+  if (fAverageBadAreas)
+    delete fAverageBadAreas;
+
+  if (fAverageBadSectors)
+    delete fAverageBadSectors;
   
 }
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 4985)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 4986)
@@ -1,3 +1,3 @@
-/* ======================================================================== *\
+ /* ======================================================================== *\
 !
 ! *
@@ -208,6 +208,6 @@
 #include "MCalibrationChargePix.h"
 #include "MCalibrationChargePINDiode.h"
-#include "MCalibrationChargeBlindPix.h"
-#include "MCalibrationChargeBlindCam.h"
+#include "MCalibrationBlindPix.h"
+#include "MCalibrationBlindCam.h"
 
 #include "MExtractedSignalCam.h"
@@ -317,5 +317,4 @@
     fCam        = NULL;
     fIntensCam  = NULL;
-    fBlindPixel = NULL;
     fBlindCam   = NULL;
     fPINDiode   = NULL;
@@ -404,5 +403,5 @@
 // 
 // Search for the following input containers and give a warning if not existing:
-//  - MCalibrationChargeBlindPix
+//  - MCalibrationBlindPix
 //  - MCalibrationChargePINDiode
 //
@@ -426,5 +425,5 @@
 //
 // - MCalibrationChargeCam
-// - MCalibrationChargeBlindPix (if existing)
+// - MCalibrationBlindPix (if existing)
 // - MCalibrationChargePINDiode (if existing)
 //
@@ -456,17 +455,13 @@
   // Optional Containers 
   //
-  fBlindPixel = (MCalibrationChargeBlindPix*)pList->FindObject("MCalibrationChargeBlindPix");
-  if (!fBlindPixel)
-    {
-      fBlindCam = (MCalibrationChargeBlindCam*)pList->FindObject("MCalibrationChargeBlindCam");
-      if (!fBlindCam)
-	{
+  fBlindCam = (MCalibrationBlindCam*)pList->FindObject("MCalibrationBlindCam");
+  if (!fBlindCam)
+    {
       *fLog << endl;
       *fLog << warn << GetDescriptor() 
-            << ": MCalibrationChargeBlindPix nor MCalibrationChargeBlindCam "
+            << ": MCalibrationBlindPix nor MCalibrationBlindCam "
 	    << " found... no Blind Pixel method! " << endl;
-	}
-    }
-  
+    }
+
   fPINDiode = (MCalibrationChargePINDiode*)pList->FindObject("MCalibrationChargePINDiode");
   if (!fPINDiode)
@@ -603,9 +598,6 @@
     fCam->SetPulserColor( fPulserColor );
   
-  if (fBlindPixel)
-    fBlindPixel->SetColor( fPulserColor );
-  
   if (fBlindCam)
-    fBlindCam->SetColor( fPulserColor );
+    fBlindCam->SetPulserColor( fPulserColor );
   
   if (fPINDiode)
@@ -640,5 +632,5 @@
 //  
 // Call MParContainer::SetReadyToSave() for fIntensCam, fCam, fQECam, fBadPixels and 
-//                                          fBlindPixel and fPINDiode if they exist
+//                                          fBlindCam and fPINDiode if they exist
 //
 // Print out some statistics
@@ -658,12 +650,4 @@
               << ": MCalibrationChargePINDiode is declared not valid... no PIN Diode method! " << endl;
         fPINDiode = NULL;
-      }
-
-  if (fBlindPixel)
-    if (!fBlindPixel->IsValid())
-      {
-        *fLog << warn << GetDescriptor() 
-              << ": MCalibrationChargeBlindPix is declared not valid... no Blind Pixel method! " << endl;
-        fBlindPixel = NULL;
       }
 
@@ -766,14 +750,8 @@
   // Finalize Blind Pixel
   //
-  if (fBlindPixel)
-    if (FinalizeBlindPixel())
-      fQECam->SetBlindPixelMethodValid(kTRUE);
-    else
-      fQECam->SetBlindPixelMethodValid(kFALSE); 
-  else 
-    if (FinalizeBlindCam())
-      fQECam->SetBlindPixelMethodValid(kTRUE);
-    else
-      fQECam->SetBlindPixelMethodValid(kFALSE); 
+  if (FinalizeBlindCam())
+    fQECam->SetBlindPixelMethodValid(kTRUE);
+  else
+    fQECam->SetBlindPixelMethodValid(kFALSE); 
 
   // 
@@ -812,6 +790,4 @@
   fBadPixels->SetReadyToSave();
 
-  if (fBlindPixel)
-    fBlindPixel->SetReadyToSave();
   if (fBlindCam)
     fBlindCam->SetReadyToSave();
@@ -1407,7 +1383,8 @@
 
 
+
 // ------------------------------------------------------------------------
 //
-// Returns kFALSE if pointer to MCalibrationChargeBlindPix is NULL
+// Returns kFALSE if pointer to MCalibrationBlindCam is NULL
 //
 // The check returns kFALSE if:
@@ -1417,54 +1394,5 @@
 // 
 // Calls:
-// - MCalibrationChargeBlindPix::CalcFluxInsidePlexiglass()
-//
-Bool_t MCalibrationChargeCalc::FinalizeBlindPixel()
-{
-
-  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 << GetDescriptor() 
-            << Form("%s%4.2f%s%4.2f%s%4.2f%s",": Lambda: ",lambda," and Lambda-Check: ",
-                    lambdacheck," differ by more than ",fLambdaCheckLimit," in the Blind Pixel ")
-            << endl;
-      return kFALSE;
-    }
-  
-  if (lambdaerr > fLambdaErrLimit) 
-    {
-      *fLog << warn << GetDescriptor() 
-            << Form("%s%4.2f%s%4.2f%s",": Error of Fitted Lambda: ",lambdaerr," 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;
-}
-
-// ------------------------------------------------------------------------
-//
-// Returns kFALSE if pointer to MCalibrationChargeBlindCam 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()
+// - MCalibrationBlindPix::CalcFluxInsidePlexiglass()
 //
 Bool_t MCalibrationChargeCalc::FinalizeBlindCam()
@@ -1478,8 +1406,8 @@
   Int_t   nvalid  = 0;
 
-  for (UInt_t i=0; i<fBlindCam->GetNumBlindPixels(); i++)
-    {
-      
-      MCalibrationChargeBlindPix &blindpix = (*fBlindCam)[i];
+  for (Int_t i=0; i<fBlindCam->GetSize(); i++)
+    {
+      
+      MCalibrationBlindPix &blindpix = (MCalibrationBlindPix&)(*fBlindCam)[i];
 
       if (!blindpix.IsValid())
@@ -1858,10 +1786,10 @@
 // Loop over pixels: 
 //
-// - Continue, if not MCalibrationChargeBlindPix::IsFluxInsidePlexiglassAvailable() and set:
+// - Continue, if not MCalibrationBlindPix::IsFluxInsidePlexiglassAvailable() and set:
 //                    MCalibrationQEPix::SetBlindPixelMethodValid(kFALSE,fPulserColor)
 //
 // - Calculate the quantum efficiency with the formula:
 // 
-//   QE =  Num.Phes / MCalibrationChargeBlindPix::GetFluxInsidePlexiglass() 
+//   QE =  Num.Phes / MCalibrationBlindPix::GetFluxInsidePlexiglass() 
 //        / MGeomPix::GetA() * MCalibrationQECam::GetPlexiglassQE()
 //
@@ -1880,4 +1808,5 @@
   // Set the results in the MCalibrationChargeCam
   //
+  /*
   if (fBlindPixel)
     {
@@ -1901,4 +1830,5 @@
         }
     }
+  */
   //
   //  With the knowledge of the overall photon flux, calculate the 
@@ -1910,5 +1840,5 @@
       MCalibrationQEPix   &qepix = (MCalibrationQEPix&)  (*fQECam)[i];
 
-      if (!fBlindPixel)
+      if (!fBlindCam)
         {
           qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
@@ -1916,4 +1846,5 @@
         }
 
+      /*
       if (!fBlindPixel->IsFluxInsidePlexiglassAvailable())
         {
@@ -1921,5 +1852,6 @@
           continue;
         }
-      
+      */      
+
       MBadPixelsPix &bad = (*fBadPixels)[i];
       if (bad.IsUnsuitable (MBadPixelsPix::kUnsuitableRun))
@@ -1935,10 +1867,10 @@
       
       const Float_t qe        = pix.GetPheFFactorMethod() 
-                             / fBlindPixel->GetFluxInsidePlexiglass() 
+        //                             / fBlindPixel->GetFluxInsidePlexiglass() 
                              / geo.GetA() 
                              * fQECam->GetPlexiglassQE();
 
-      const Float_t qerelvar = fBlindPixel->GetFluxInsidePlexiglassRelVar() 
-                               + fQECam->GetPlexiglassQERelVar()
+      const Float_t qerelvar = /* fBlindPixel->GetFluxInsidePlexiglassRelVar() 
+                                  + */ fQECam->GetPlexiglassQERelVar()
                                + pix.GetPheFFactorMethodRelVar();
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 4985)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h	(revision 4986)
@@ -31,6 +31,5 @@
 class MPedestalPix;
 class MCalibrationChargePINDiode;
-class MCalibrationChargeBlindCam;
-class MCalibrationChargeBlindPix;
+class MCalibrationBlindCam;
 class MCalibrationChargePix;
 class MCalibrationChargeCam;
@@ -84,6 +83,5 @@
   MCalibrationIntensityChargeCam *fIntensCam;  //  Calibrated Charges of all pixels   
   MCalibrationChargeCam      *fCam;            //  Calibrated Charges of all pixels 
-  MCalibrationChargeBlindPix *fBlindPixel;     //  Calibrated Charges of the Blind Pixel 
-  MCalibrationChargeBlindCam *fBlindCam;       //  Calibrated Charges of the Blind Pixels
+  MCalibrationBlindCam       *fBlindCam;       //  Calibrated Charges of the Blind Pixels
   MCalibrationChargePINDiode *fPINDiode;       //  Calibrated Charges of the PIN Diode
   MCalibrationQECam          *fQECam;          //  Calibrated Quantum Efficiencies of all pixels 
@@ -112,5 +110,4 @@
   Bool_t FinalizeCharges         ( MCalibrationChargePix &cal, MBadPixelsPix &bad, const char* what);
   Bool_t FinalizePINDiode        ();
-  Bool_t FinalizeBlindPixel      ();
   Bool_t FinalizeBlindCam        ();  
   Bool_t FinalizeFFactorMethod   ();
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 4985)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc	(revision 4986)
@@ -129,7 +129,9 @@
   fTitle = title ? title : "Storage container for the Calibration Information in the camera";
   
-  fPixels           = new TClonesArray("MCalibrationChargePix",1);
-  fAverageAreas     = new TClonesArray("MCalibrationChargePix",1);
-  fAverageSectors   = new TClonesArray("MCalibrationChargePix",1);
+  fPixels            = new TClonesArray("MCalibrationChargePix",1);
+  fAverageAreas      = new TClonesArray("MCalibrationChargePix",1);
+  fAverageSectors    = new TClonesArray("MCalibrationChargePix",1);
+  fAverageBadAreas   = new TClonesArray("MBadPixelsPix",1);
+  fAverageBadSectors = new TClonesArray("MBadPixelsPix",1);
 
   Clear();
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityBlindCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityBlindCam.cc	(revision 4986)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityBlindCam.cc	(revision 4986)
@@ -0,0 +1,65 @@
+/* ======================================================================== *\
+!
+! *
+! * 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-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationIntensityBlindCam                                               
+//                                                               
+// Storage container for intensity charge calibration results. 
+// 
+// Individual MCalibrationBlindCam's can be retrieved with: 
+// - GetCam() yielding the current cam.
+// - GetCam("name") yielding the current camera with name "name".
+// - GetCam(i) yielding the i-th camera.
+//
+// See also: MCalibrationIntensityCam, MCalibrationBlindCam,
+//           MCalibrationBlindPix, MCalibrationChargeCalc, MCalibrationQECam
+//           MHCalibrationChargeBlindPix, MHCalibrationChargeBlindCam              
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationIntensityBlindCam.h"
+
+#include <TClonesArray.h>
+
+ClassImp(MCalibrationIntensityBlindCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Sets all pointers to 0
+// 
+// Creates a TClonesArray of MCalibrationBlindCam containers, initialized to 1 entry, destinated 
+// to hold one container per camera. 
+//
+MCalibrationIntensityBlindCam::MCalibrationIntensityBlindCam(const char *name, const char *title)
+{
+
+  fName  = name  ? name  : "MCalibrationIntensityBlindCam";
+  fTitle = title ? title : "Results of the Intensity Calibration";
+  
+  fCams = new TClonesArray("MCalibrationBlindCam",1);
+  
+}
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityBlindCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityBlindCam.h	(revision 4986)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityBlindCam.h	(revision 4986)
@@ -0,0 +1,21 @@
+#ifndef MARS_MCalibrationIntensityBlindCam
+#define MARS_MCalibrationIntensityBlindCam
+
+#ifndef MARS_MCalibrationIntensityCam
+#include "MCalibrationIntensityCam.h"
+#endif
+
+#ifndef MARS_MCalibrationBlindCam
+#include "MCalibrationBlindCam.h"
+#endif
+
+class MCalibrationIntensityBlindCam : public MCalibrationIntensityCam
+{
+public:
+
+  MCalibrationIntensityBlindCam(const char *name=NULL, const char *title=NULL);
+
+  ClassDef(MCalibrationIntensityBlindCam, 1) // Container Intensity Blind Calibration Results Camera
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc	(revision 4985)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc	(revision 4986)
@@ -102,4 +102,37 @@
 }
 
+
+// -----------------------------------------------------
+//
+// copy 'constructor'
+//
+void MCalibrationPix::Copy(TObject& object) const
+{
+
+  MCalibrationPix &pix = (MCalibrationPix&)object;
+
+  //
+  // Copy the data members
+  //
+  pix.fPixId             = fPixId;
+  pix.fFlags             = fFlags;
+  pix.fHiGainMean        = fHiGainMean;
+  pix.fHiGainMeanVar     = fHiGainMeanVar;
+  pix.fHiGainNumBlackout = fHiGainNumBlackout;
+  pix.fHiGainNumPickup   = fHiGainNumPickup;
+  pix.fHiGainSigma       = fHiGainSigma;
+  pix.fHiGainSigmaVar    = fHiGainSigmaVar;
+  pix.fHiGainProb        = fHiGainProb;
+  pix.fLoGainMean        = fLoGainMean;
+  pix.fLoGainMeanVar     = fLoGainMeanVar;
+  pix.fLoGainNumBlackout = fLoGainNumBlackout;
+  pix.fLoGainNumPickup   = fLoGainNumPickup;
+  pix.fLoGainSigma       = fLoGainSigma;
+  pix.fLoGainSigmaVar    = fLoGainSigmaVar;
+  pix.fLoGainProb        = fLoGainProb;
+  
+}
+
+
 // --------------------------------------------------------------------------
 //
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h	(revision 4985)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h	(revision 4986)
@@ -34,6 +34,7 @@
   ~MCalibrationPix() {}
   
-  virtual void Clear(Option_t *o="");
-
+  void Clear(Option_t *o="");
+  void Copy(TObject& object) const;
+  
   // Setter
   void SetPixId( const Int_t i )   { fPixId = i; }
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationQECam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationQECam.cc	(revision 4985)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationQECam.cc	(revision 4986)
@@ -110,7 +110,9 @@
     fTitle = title ? title : "Storage container for the calibrated Quantum Efficiency of the camera";
 
-    fPixels           = new TClonesArray("MCalibrationQEPix",1);
-    fAverageAreas     = new TClonesArray("MCalibrationQEPix",1);
-    fAverageSectors   = new TClonesArray("MCalibrationQEPix",1);
+    fPixels             = new TClonesArray("MCalibrationQEPix",1);
+    fAverageAreas       = new TClonesArray("MCalibrationQEPix",1);
+    fAverageSectors     = new TClonesArray("MCalibrationQEPix",1);
+    fAverageBadAreas    = new TClonesArray("MBadPixelsPix",1);
+    fAverageBadSectors  = new TClonesArray("MBadPixelsPix",1);
 
     fFlags.Set(MCalibrationCam::gkNumPulserColors);
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.cc	(revision 4985)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationRelTimeCam.cc	(revision 4986)
@@ -112,7 +112,9 @@
   fTitle = title ? title : "Container for Relative Time Calibration Information";
   
-  fPixels           = new TClonesArray("MCalibrationRelTimePix",1);
-  fAverageAreas     = new TClonesArray("MCalibrationRelTimePix",1);
-  fAverageSectors   = new TClonesArray("MCalibrationRelTimePix",1);
+  fPixels             = new TClonesArray("MCalibrationRelTimePix",1);
+  fAverageAreas       = new TClonesArray("MCalibrationRelTimePix",1);
+  fAverageSectors     = new TClonesArray("MCalibrationRelTimePix",1);
+  fAverageBadAreas    = new TClonesArray("MBadPixelsPix",1);
+  fAverageBadSectors  = new TClonesArray("MBadPixelsPix",1);
   
 }
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationTestCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationTestCam.cc	(revision 4985)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationTestCam.cc	(revision 4986)
@@ -89,7 +89,7 @@
   fTitle = title ? title : "Storage container for the Calibration Test Information in the camera";
   
-  fPixels           = new TClonesArray("MCalibrationTestPix",1);
-  fAverageAreas     = new TClonesArray("MCalibrationTestPix",1);
-  fAverageSectors   = new TClonesArray("MCalibrationTestPix",1);
+  fPixels            = new TClonesArray("MCalibrationTestPix",1);
+  fAverageAreas      = new TClonesArray("MCalibrationTestPix",1);
+  fAverageSectors    = new TClonesArray("MCalibrationTestPix",1);
 
   Clear();
Index: trunk/MagicSoft/Mars/mcalib/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mcalib/Makefile	(revision 4985)
+++ trunk/MagicSoft/Mars/mcalib/Makefile	(revision 4986)
@@ -38,4 +38,5 @@
            MCalibrationIntensityCam.cc \
            MCalibrationIntensityChargeCam.cc \
+           MCalibrationIntensityBlindCam.cc \
            MCalibrationIntensityQECam.cc \
            MCalibrationIntensityRelTimeCam.cc \
@@ -55,4 +56,8 @@
            MCalibrationChargeCam.cc \
            MCalibrationChargePix.cc  \
+           MCalibrationBlindCam.cc  \
+           MCalibrationBlindPix.cc  \
+           MCalibrationBlindCamOneOldStyle.cc  \
+           MCalibrationBlindCamTwoNewStyle.cc  \
            MCalibrationChargeBlindCamOneOldStyle.cc  \
            MCalibrationChargeBlindCamTwoNewStyle.cc  \
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindCam.cc	(revision 4985)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindCam.cc	(revision 4986)
@@ -40,9 +40,12 @@
 #include "MLogManip.h"
 
-#include "MCalibrationChargeBlindPix.h"
-#include "MCalibrationChargeBlindCam.h"
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
 
 #include "MExtractedSignalBlindPixel.h"
 
+#include "MCalibrationBlindPix.h"
+#include "MCalibrationIntensityBlindCam.h"
+
 #include "MParList.h"
 
@@ -52,5 +55,12 @@
 
 using namespace std;
-
+const Int_t     MHCalibrationChargeBlindCam::fgNbins    =  128;
+const Axis_t    MHCalibrationChargeBlindCam::fgFirst    = -0.5;
+const Axis_t    MHCalibrationChargeBlindCam::fgLast     =  511.5;
+const Axis_t    MHCalibrationChargeBlindCam::fgSPheCut  =  20.;
+const TString   MHCalibrationChargeBlindCam::gsHistName   = "ChargeBlind";
+const TString   MHCalibrationChargeBlindCam::gsHistTitle  = "Signals Blind ";
+const TString   MHCalibrationChargeBlindCam::gsHistXTitle = "Signal [FADC counts]";
+const TString   MHCalibrationChargeBlindCam::gsHistYTitle = "Nr. events";
 // --------------------------------------------------------------------------
 //
@@ -60,11 +70,22 @@
 // - all pointers to NULL
 //
-// Initializes and sets owner of:
-// - fBlindPixelsArray
+// - fFitFunc to kEPoisson4
+// - fNbins   to fgNbins
+// - fFirst   to fgFirst
+// - fLast    to fgLast 
+// - fSPheCut to fgSPheCut
 // 
-// Sets fFitFunc to kEPoisson4
+// - fHistName   to gsHistName  
+// - fHistTitle  to gsHistTitle 
+// - fHistXTitle to gsHistXTitle
+// - fHistYTitle to gsHistYTitle
+//
+// - SetAverageing  (kFALSE);
+// - SetLoGain      (kFALSE);
+// - SetOscillations(kFALSE);
+// - SetSizeCheck   (kFALSE);
 //
 MHCalibrationChargeBlindCam::MHCalibrationChargeBlindCam(const char *name, const char *title)
-    :  fCam(NULL), fRunHeader(NULL)
+    : fRawEvt(NULL)
 {
 
@@ -72,38 +93,316 @@
   fTitle = title ? title : "Class to fille the blind pixel histograms";
 
-  fBlindPixelsArray = new TObjArray;
-  fBlindPixelsArray->SetOwner();
-
-  fFitFunc = MHCalibrationChargeBlindPix::kEPoisson4;
-
-}
-
-// --------------------------------------------------------------------------
-//
-// Deletes the TClonesArray of:
-// - fBlindPixelsArray
-//
-MHCalibrationChargeBlindCam::~MHCalibrationChargeBlindCam()
-{
-  delete fBlindPixelsArray;
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th High Gain pixel (pixel number)
-//
-MHCalibrationChargeBlindPix &MHCalibrationChargeBlindCam::operator[](UInt_t i)
-{
-  return *static_cast<MHCalibrationChargeBlindPix*>(fBlindPixelsArray->UncheckedAt(i));
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th High Gain pixel (pixel number)
-//
-const MHCalibrationChargeBlindPix &MHCalibrationChargeBlindCam::operator[](UInt_t i) const
-{
-  return *static_cast<MHCalibrationChargeBlindPix*>(fBlindPixelsArray->UncheckedAt(i));
-}
+  SetFitFunc();
+  SetSPheCut();
+
+  SetNbins(fgNbins);
+  SetFirst(fgFirst);
+  SetLast (fgLast );
+
+  SetHistName  (gsHistName  .Data());
+  SetHistTitle (gsHistTitle .Data());
+  SetHistXTitle(gsHistXTitle.Data());
+  SetHistYTitle(gsHistYTitle.Data());
+
+  SetAverageing  (kFALSE);
+  SetLoGain      (kFALSE);
+  SetOscillations(kFALSE);
+  SetSizeCheck   (kFALSE);
+}
+
+// --------------------------------------------------------------------------
+//
+// Gets the pointers to:
+// - MRawEvtData
+//
+Bool_t MHCalibrationChargeBlindCam::SetupHists(const MParList *pList)
+{
+
+  fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+  if (!fRawEvt)
+  {
+      *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
+      return kFALSE;
+  }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Gets or creates the pointers to:
+// - MExtractedSignalBlindPixel
+// - MCalibrationChargeCam or MCalibrationIntensityBlindCam
+//
+// Initializes the number of used FADC slices from MExtractedSignalCam 
+// into MCalibrationChargeCam and test for changes in that variable
+//
+// Retrieve:
+// - fRunHeader->GetNumSamplesHiGain();
+//
+// Initializes the High Gain Arrays:
+//
+// - Expand fHiGainArrays to nblindpixels
+// 
+// - For every entry in the expanded arrays: 
+//   * Initialize an MHCalibrationPix
+//   * Set Binning from  fNbins, fFirst and fLast
+//   * Set Histgram names and titles from fHistName and fHistTitle
+//   * Set X-axis and Y-axis titles from fHistXTitle and fHistYTitle
+//   * Call InitHists
+//
+Bool_t MHCalibrationChargeBlindCam::ReInitHists(MParList *pList)
+{
+
+  MExtractedSignalBlindPixel *signal = 
+    (MExtractedSignalBlindPixel*)pList->FindObject(AddSerialNumber("MExtractedSignalBlindPixel"));
+  if (!signal)
+  {
+      *fLog << err << "MExtractedSignalBlindPixel not found... abort." << endl;
+      return kFALSE;
+  }
+
+  fIntensCam = (MCalibrationIntensityCam*)pList->FindObject(AddSerialNumber("MCalibrationIntensityBlindCam"));
+  if (fIntensCam)
+    *fLog << inf << "Found MCalibrationIntensityBlindCam ... " << endl;
+  else
+    {
+      fCam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationBlindCam"));
+      if (!fCam)
+        {
+          fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationBlindCam"));
+          if (!fCam)
+            {
+              *fLog << err << "Cannot find nor create MCalibrationBlindCam ... abort." << endl;
+              return kFALSE;
+            }
+        }
+    }
+
+  const Int_t nblindpixels = signal->GetNumBlindPixels();
+  const Int_t samples      = signal->GetNumFADCSamples();
+  const Int_t integ        = signal->IsExtractionType( MExtractBlindPixel::kIntegral );
+  
+  TH1F *h;
+
+  if (fHiGainArray->GetEntries()==0)
+  {
+      fHiGainArray->Expand(nblindpixels);
+      for (Int_t i=0; i<nblindpixels; i++)
+      {
+        (*fHiGainArray)[i] = new MHCalibrationChargeBlindPix(Form("%s%s",fHistName.Data(),"Pix"),
+                                                  Form("%s%s",fHistTitle.Data()," Pixel "));
+
+        MHCalibrationChargeBlindPix &pix = (MHCalibrationChargeBlindPix&)(*this)[i];
+
+        pix.SetNbins        ( fNbins );
+        pix.SetFirst        ( fFirst );
+        pix.SetLast         ( integ ? ((fLast+0.5)*samples)-0.5 : fLast    );
+        pix.SetSinglePheCut ( integ ? fSPheCut * samples        : fSPheCut );
+        pix.SetFitFunc      ( integ ? kEPoisson5                : fFitFunc );
+
+        h = pix.GetHGausHist();
+
+        h->SetName (Form("%s%s%s","H",fHistName.Data(),"Pix"));
+        h->SetTitle(Form("%s%s",fHistTitle.Data()," Pixel "));  
+        h->SetXTitle(fHistXTitle.Data());
+        h->SetYTitle(fHistYTitle.Data());
+
+        pix.ChangeHistId(i);
+        pix.InitBins();
+
+        h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
+      }
+  }
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Retrieves from MExtractedSignalBlindPixel:
+// - number of blind pixels
+//
+// Retrieves from MExtractedSignalBlindPixel:
+// - number of FADC samples
+// - extracted signal 
+// - blind Pixel ID
+//
+// Resizes (if necessary):
+// - fASinglePheFADCSlices to sum of HiGain and LoGain samples
+// - fAPedestalFADCSlices to sum of HiGain and LoGain samples
+//
+// Fills the following histograms:
+// - MHGausEvents::FillHistAndArray(signal)
+//
+// Creates MRawEvtPixelIter, jumps to blind pixel ID, 
+// fills the vectors fASinglePheFADCSlices and fAPedestalFADCSlices 
+// with the full FADC slices, depending on the size of the signal w.r.t. fSinglePheCut
+//
+Bool_t MHCalibrationChargeBlindCam::FillHists(const MParContainer *par, const Stat_t w)
+{
+
+  MExtractedSignalBlindPixel *signal = (MExtractedSignalBlindPixel*)par;
+  if (!signal)
+    {
+      *fLog << err << "No argument in MExtractedSignalBlindCam::Fill... abort." << endl;
+      return kFALSE;
+    }
+  
+  const Int_t nblindpixels  = signal->GetNumBlindPixels();
+  
+  if (GetSize() != nblindpixels)
+    {
+      gLog << err << "ERROR - Size mismatch... abort." << endl;
+      return kFALSE;
+    }
+
+  Float_t slices = (Float_t)signal->GetNumFADCSamples();
+  
+  if (slices == 0.)
+    {
+      *fLog << err << dbginf
+	    << "Number of used signal slices in MExtractedSignalBlindPix "
+	    << "is zero  ... abort." 
+            << endl;
+      return kFALSE;
+    }
+  
+  for (Int_t i=0; i<nblindpixels; i++)
+    {
+
+      //
+      // Signal extraction and histogram filling
+      // If filter has been applied, sig has been set to -1.
+      //
+      const Float_t sig = signal->GetExtractedSignal(i);
+      
+      if (sig < -0.5)
+        continue;
+
+      MHCalibrationChargeBlindPix &hist = (MHCalibrationChargeBlindPix&)(*this)[i];
+
+      hist.FillHist(sig);
+      //
+      // In order to study the single-phe posistion, we extract the slices
+      //
+      const Int_t blindpixIdx = signal->GetBlindPixelIdx(i);
+      
+      MRawEvtPixelIter pixel(fRawEvt);
+      pixel.Jump(blindpixIdx);
+      
+      if (sig > fSPheCut)
+        hist.FillSinglePheFADCSlices(pixel);
+      else
+        hist.FillPedestalFADCSlices(pixel);
+
+    }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// For all TObjArray's (including the averaged ones), the following steps are performed: 
+//
+// 1) Returns if the pixel is excluded.
+// 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation()
+//    or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated )
+// 3) Store the absolute arrival times in the MCalibrationChargePix's. If flag 
+//    MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored, 
+//    otherwise the Hi-Gain ones.
+// 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays() 
+//    with the flags:
+//    - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
+//    - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
+//    - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
+//    - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
+//
+Bool_t MHCalibrationChargeBlindCam::FinalizeHists()
+{
+
+  *fLog << endl;
+
+  for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
+    {
+      
+      MHCalibrationChargeBlindPix &hist = (MHCalibrationChargeBlindPix&)(*this)[i];
+      
+      TH1F *h = hist.GetHGausHist();
+
+      Stat_t overflow = h->GetBinContent(h->GetNbinsX()+1);
+      if (overflow > 0.1)
+        {
+          *fLog << warn << GetDescriptor()
+                << ": Histogram Overflow occurred " << overflow 
+                << " times in blind pixel: " << i << endl;
+        }
+
+      overflow = h->GetBinContent(0);
+      if (overflow > 0.1)
+        {
+          *fLog << warn << GetDescriptor()
+                << ": Histogram Underflow occurred " << overflow
+                << " times in blind pixel: " << i << endl;
+        }
+
+      MCalibrationBlindPix  &pix    = fIntensCam 
+        ? (MCalibrationBlindPix&)(*fIntensCam)[i] 
+        : (MCalibrationBlindPix&)(*fCam)[i];
+
+      FitBlindPixel(hist,pix);
+    }
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Returns kFALSE, if empty
+//
+// - Creates the fourier spectrum and sets bit MHGausEvents::IsFourierSpectrumOK()
+// - Retrieves the pedestals from MExtractedSignalBlindPixel
+// - Normalizes fASinglePheFADCSlices and fAPedestalFADCSlices
+// - Executes FitPedestal()
+// - Executes FitSinglePhe()
+// - Retrieves fit results and stores them in MCalibrationBlindPix
+// 
+void MHCalibrationChargeBlindCam::FitBlindPixel(MHCalibrationChargeBlindPix &hist, MCalibrationBlindPix &pix)
+{
+
+  if (hist.IsEmpty())
+  {
+    *fLog << err << GetDescriptor() << " ID: " << hist.GetPixId()
+	  << " My histogram has not been filled !! " << endl;
+      return;
+  }
+
+  hist.FinalizeSinglePheSpectrum();
+  
+  hist.FitPedestal();
+
+  pix.SetValid(kTRUE);
+
+  if (hist.FitSinglePhe())
+    pix.SetSinglePheFitOK();
+  else
+    pix.SetValid(hist.IsPedestalFitOK());
+
+  pix.SetLambda      ( hist.GetLambda   () );
+  pix.SetLambdaVar   ( hist.GetLambdaErr()*hist.GetLambdaErr() );
+  pix.SetMu0         ( hist.GetMu0      () );
+  pix.SetMu0Err      ( hist.GetMu0Err   () );
+  pix.SetMu1         ( hist.GetMu1      () );
+  pix.SetMu1Err      ( hist.GetMu1Err   () );
+  pix.SetSigma0      ( hist.GetSigma0   () );
+  pix.SetSigma0Err   ( hist.GetSigma0Err() );
+  pix.SetSigma1      ( hist.GetSigma1   () );
+  pix.SetSigma1Err   ( hist.GetSigma1Err() );
+  pix.SetProb        ( hist.GetProb     () );
+
+  pix.SetLambdaCheck    ( hist.GetLambdaCheck()    );
+  pix.SetLambdaCheckErr ( hist.GetLambdaCheckErr() );
+}
+
 
 // --------------------------------------------------------------------------
@@ -118,6 +417,4 @@
 {
 
-  const Int_t nhi   = fBlindPixelsArray->GetEntries();
-  
   //
   // FIXME, this might be done faster and more elegant, by direct copy.
@@ -125,160 +422,24 @@
   MHCalibrationChargeBlindCam *cam = new MHCalibrationChargeBlindCam();
 
-  cam->fBlindPixelsArray->Expand(nhi);
+  //
+  // Copy the data members
+  //
+  cam->fRunNumbers             = fRunNumbers;
+  cam->fPulserFrequency        = fPulserFrequency;
+  cam->fFlags                  = fFlags;
+  cam->fNbins                  = fNbins;
+  cam->fFirst                  = fFirst;
+  cam->fLast                   = fLast;
+  cam->fFitFunc                = fFitFunc;
+
+  const Int_t nhi = fHiGainArray->GetEntries();
+  
+  cam->fHiGainArray->Expand(nhi);
 
   for (int i=0; i<nhi; i++)
-    (*cam->fBlindPixelsArray)[i] = (*fBlindPixelsArray)[i]->Clone();
+    (*cam->fHiGainArray)[i] = (*fHiGainArray)[i]->Clone();
 
   return cam;
 }
-
-// --------------------------------------------------------------------------
-//
-// Gets the pointers to:
-// - MRunHeader
-// - MExtractedSignalBlindPix
-//
-// Calls Delete-Function of:
-// - MHCalibrationChargeBlindCam::fBlindPixelsArray
-//
-Bool_t MHCalibrationChargeBlindCam::SetupFill(const MParList *pList)
-{
-  
-  fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
-  if (!fRunHeader)
-  {
-    *fLog << warn << GetDescriptor() 
-          << ": MRawRunHeader not found... will not store run numbers." << endl;
-    return kFALSE;
-  }
-
-  fSignal  = (MExtractedSignalBlindPixel*)pList->FindObject("MExtractedSignalBlindPixel");
-  if (!fSignal)
-    {
-      *fLog << err << "MExtractedSignalBlindPixel not found... aborting " << endl;
-      return kFALSE;
-    }
-
-  return kTRUE;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Initializes, if empty to MExtractedSignalCam::GetSize() for:
-// - MHCalibrationChargeBlindCam::fBlindPixelsArray
-//
-// Calls InitializeHists() for every entry in:
-// - MHCalibrationChargeBlindCam::fBlindPixelsArray
-//
-// Retrieves the run numbers from MRawRunHeader and stores them in fRunNumbers
-//
-Bool_t MHCalibrationChargeBlindCam::ReInit(MParList *pList)
-{
-
-  const UInt_t nblindpixels  = fSignal->GetNumBlindPixels();
-
-  Int_t runnr = 0;
-
-  if (fRunHeader)
-    runnr = fRunHeader->GetRunNumber();
-
-  fCam = (MCalibrationChargeBlindCam*)pList->FindCreateObj("MCalibrationChargeBlindCam");
-  if (!fCam)
-    {
-      *fLog << err << "Cannot find nor create MCalibrationChargeBlindCam ... abort." << endl;
-      return kFALSE;
-    }
-
-  if (fCam->GetNumBlindPixels() != nblindpixels)
-    {
-        *fLog << err;
-        *fLog << "Size mismatch in MCalibrationChargeBlindCam ... abort." << endl;
-        *fLog << "  Size of MCalibrationChargeBlindCam: " << fCam->GetNumBlindPixels() << endl;
-        *fLog << "  Size of MExtractedSignalBlindPixel: " << nblindpixels << endl;
-      return kFALSE;
-    }
-  
-
-  const Int_t samples = fSignal->GetNumFADCSamples();
-  const Int_t integ   = fSignal->IsExtractionType( MExtractBlindPixel::kIntegral );
-
-  if (fBlindPixelsArray->GetEntries()==0)
-  {
-
-      fBlindPixelsArray->Expand(nblindpixels);
-
-      for (UInt_t i=0; i<nblindpixels; i++)
-	{
-	  (*fBlindPixelsArray)[i] = new MHCalibrationChargeBlindPix;
-	  (*this)[i].ChangeHistId(i);
-	  if (integ)
-	    {
-	      (*this)[i].SetLast( samples * integ * 
-				  ((*this)[i].GetLast()+0.5) - 0.5 );
-	      (*this)[i].SetSinglePheCut( samples * integ *
-					  (*this)[i].GetSinglePheCut() );
-	    }
-	  (*this)[i].InitBins();
-	  TH1F *h = (*this)[i].GetHGausHist();
-	  h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
-          (*this)[i].ChangeFitFunc(fFitFunc);
-	  (*this)[i].SetupFill(pList);
-	  (*this)[i].SetCalibrationChargeBlindPix(&(*fCam)[i]);
-      }
-  }
-
-  for (UInt_t i=0; i<nblindpixels; i++)
-    {
-      TH1F *h = (*this)[i].GetHGausHist();
-      h->SetTitle( Form("%s%i%s", h->GetTitle(),runnr," "));
-    }
-
-  return kTRUE;
-}
-
-
-//--------------------------------------------------------------------------------
-//
-// Retrieves from MExtractedSignalBlindPixel:
-// - number of blind pixels
-//
-// For all TObjArray's, the following steps are performed: 
-//
-// 1) Test size and return kFALSE if not matching
-// 2) 
-//
-Bool_t MHCalibrationChargeBlindCam::Fill(const MParContainer *par, const Stat_t w)
-{
-
-  const Int_t nblindpixels  = fSignal->GetNumBlindPixels();
-  
-  if (GetSize() != nblindpixels)
-    {
-      gLog << err << "ERROR - Size mismatch... abort." << endl;
-      return kFALSE;
-    }
-  
-  for (Int_t i=0; i<nblindpixels; i++)
-    (*this)[i].Fill(par,w);
-
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Calls the Finalize() function of the blind pixels
-//
-Bool_t MHCalibrationChargeBlindCam::Finalize()
-{
-
-  for (Int_t i=0; i<GetSize(); i++)
-    if (!(*this)[i].Finalize())
-      return kFALSE;
-
-  return kTRUE;
-}
-
-
 
 // -----------------------------------------------------------------------------
@@ -293,5 +454,5 @@
 {
 
-  const Int_t size = fBlindPixelsArray->GetEntries();
+  const Int_t size = fHiGainArray->GetEntries();
 
   if (size == 0)
@@ -330,2 +491,27 @@
 
 }
+
+Int_t MHCalibrationChargeBlindCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+
+  Bool_t rc = kFALSE;
+
+  if (MHCalibrationCam::ReadEnv(env,prefix,print))
+    rc = kTRUE;
+  
+  if (IsEnvDefined(env, prefix, "SPheCut", print))
+    {
+      SetSPheCut(GetEnvValue(env, prefix, "SPheCut", fSPheCut));
+      rc = kTRUE;
+    }
+  
+  // FIXME: GetEnvValue does not work with enums yet
+  /*
+  if (IsEnvDefined(env, prefix, "FitFunc", print))
+    {
+      SetFitFunc((Int_t)GetEnvValue(env, prefix, "FitFunc", fFitFunc));
+      rc = kTRUE;
+  }
+  */
+  return rc;
+}
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindCam.h
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindCam.h	(revision 4985)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindCam.h	(revision 4986)
@@ -2,37 +2,54 @@
 #define MARS_MHCalibrationChargeBlindCam
 
-#ifndef MARS_MH
-#include "MH.h"
-#endif
-#ifndef MARS_MHCalibrationChargeBlindPix
-#include "MHCalibrationChargeBlindPix.h"
+#ifndef MARS_MHCalibrationCam
+#include "MHCalibrationCam.h"
 #endif
 
-class TObjArray;
-class MRawRunHeader;
-class MExtractedSignalBlindPixel;
-class MCalibrationChargeBlindCam;
+class MRawEvtData;
+class MCalibrationBlindPix;
 class MHCalibrationChargeBlindPix;
-class MHCalibrationChargeBlindCam : public MH
+class MHCalibrationChargeBlindCam : public MHCalibrationCam
 {
 private:
 
-  MExtractedSignalBlindPixel *fSignal;     //!  Extracted Signal class
-  MCalibrationChargeBlindCam *fCam;        //!  Calibration Cam with the results
-  MRawRunHeader              *fRunHeader;  //!  Run Header
+  static const Int_t   fgNbins;        //! Default for fNBins new style blind pixel (now set to:  128   )
+  static const Axis_t  fgFirst;        //! Default for fFirst new style blind pixel (now set to: - 0.5 )
+  static const Axis_t  fgLast;         //! Default for fLast  new style blind pixel (now set to: 511.5 )
+
+  static const Axis_t  fgSPheCut;      //! Default for fSinglePheCut new style blind pixel (now set to: 20)
   
-  TObjArray *fBlindPixelsArray;            // Array of calibration pixels, one per pixel
+  static const TString gsHistName;     //! Default Histogram names
+  static const TString gsHistTitle;    //! Default Histogram titles
+  static const TString gsHistXTitle;   //! Default Histogram x-axis titles
+  static const TString gsHistYTitle;   //! Default Histogram y-axis titles
+  
+  Axis_t fSPheCut;                    // Signal value upon which event considered as single-phe
+  
+  MRawEvtData *fRawEvt;                 //!  Raw event data
 
-  MHCalibrationChargeBlindPix::FitFunc_t fFitFunc;
+public:
+
+  enum FitFunc_t { kEPoisson4, kEPoisson5,
+                   kEPoisson6, kEPoisson7,
+                   kEPolya, kEMichele }; // Possible fit functions types (see MHCalibrationChargeBlindPix)
+  
+  static const FitFunc_t fgFitFunc = kEPoisson4;    //! Default for fFitFunc
+
+private:
+
+  FitFunc_t fFitFunc;                 // The actual fit function type
+  
+  Bool_t SetupHists   (const MParList *pList );
+  Bool_t ReInitHists  (      MParList *pList );
+  Bool_t FillHists    (const MParContainer *par, const Stat_t w=1 );
+  Bool_t FinalizeHists();
+
+  void   FitBlindPixel( MHCalibrationChargeBlindPix &hist, MCalibrationBlindPix &pix);
+
+  Int_t ReadEnv        ( const TEnv &env, TString prefix, Bool_t print);  
   
 public:
 
   MHCalibrationChargeBlindCam(const char *name=NULL, const char *title=NULL);
-  ~MHCalibrationChargeBlindCam();
-
-  Bool_t SetupFill( const MParList *pList);
-  Bool_t ReInit   (       MParList *pList);
-  Bool_t Fill     ( const MParContainer *par, const Stat_t w=1);
-  Bool_t Finalize ( );
 
   // Clone
@@ -40,12 +57,7 @@
   
   // Draw
-  void   Draw(Option_t *opt="");
-  
-  const Int_t GetSize() const  { return fBlindPixelsArray->GetSize(); }
-  
-        MHCalibrationChargeBlindPix &operator[] (UInt_t i);
-  const MHCalibrationChargeBlindPix &operator[] (UInt_t i)  const;
-
-  void   SetFitFunc(const MHCalibrationChargeBlindPix::FitFunc_t func)  { fFitFunc = func;  }  
+  void  Draw(Option_t *opt="");
+  void  SetFitFunc( const FitFunc_t func=fgFitFunc)  { fFitFunc = func;  }
+  void  SetSPheCut( const Axis_t a=fgSPheCut )  { fSPheCut = a;  }    
   
   ClassDef(MHCalibrationChargeBlindCam, 1)	// Histogram class for Blind Pixel Calibration
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindPix.cc	(revision 4985)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindPix.cc	(revision 4986)
@@ -32,5 +32,5 @@
 //  Performs the Single Photo-electron fit to extract the Poisson mean and its errors.
 //
-//  Different fits can be chosen with the function ChangeFitFunc().
+//  Different fits can be chosen with the function SetFitFunc().
 //
 //  The fit result is accepted under the condition that:
@@ -69,5 +69,5 @@
 //////////////////////////////////////////////////////////////////////////////
 #include "MHCalibrationChargeBlindPix.h"
-#include "MExtractBlindPixel.h"
+#include "MHCalibrationChargeBlindCam.h"
 
 #include <TStyle.h>
@@ -88,9 +88,5 @@
 #include "MParList.h"
 
-#include "MRawEvtData.h"
 #include "MRawEvtPixelIter.h"
-
-#include "MExtractedSignalBlindPixel.h"
-#include "MCalibrationChargeBlindPix.h"
 
 ClassImp(MHCalibrationChargeBlindPix);
@@ -101,9 +97,4 @@
 const Double_t MHCalibrationChargeBlindPix::gkElectronicAmpErr   = 0.002;
 const Float_t  MHCalibrationChargeBlindPix::gkSignalInitializer  = -9999.;
-
-const Int_t    MHCalibrationChargeBlindPix::fgChargeNbins        = 128;
-const Axis_t   MHCalibrationChargeBlindPix::fgChargeFirst        = -0.5;
-const Axis_t   MHCalibrationChargeBlindPix::fgChargeLast         = 511.5;
-const Float_t  MHCalibrationChargeBlindPix::fgSinglePheCut       =  20.;
 const Float_t  MHCalibrationChargeBlindPix::fgNumSinglePheLimit  =  50.;
 // --------------------------------------------------------------------------
@@ -112,15 +103,6 @@
 //
 // Sets: 
-// - the default number for fNbins        (fgChargeNbins)
-// - the default number for fFirst        (fgChargeFirst)
-// - the default number for fLast         (fgChargeLast)
-// - the default number for fSinglePheCut (fgSingePheCut)
 // - the default number for fNumSinglePheLimit (fgNumSinglePheLimit)
 // - the default number of bins after stripping (30)
-//
-// - the default name of the  fHGausHist ("HCalibrationChargeBlindPix")
-// - the default title of the fHGausHist ("Distribution of Summed FADC slices Blind Pixel ")
-// - the default x-axis title for fHGausHist ("Sum FADC Slices")
-// - the default y-axis title for fHGausHist ("Nr. of events")
 //
 // Initializes:
@@ -128,5 +110,4 @@
 // - fASinglePheFADCSlices(0);
 // - fAPedestalFADCSlices(0);
-// - fPixId to 0
 //
 // Calls:
@@ -134,6 +115,5 @@
 //
 MHCalibrationChargeBlindPix::MHCalibrationChargeBlindPix(const char *name, const char *title)
-    :  fBlindPix(NULL), fSignal(NULL), fRawEvt(NULL), 
-       fSinglePheFit(NULL), 
+    :  fSinglePheFit(NULL), 
        fFitLegend(NULL),
        fHSinglePheFADCSlices(NULL), fHPedestalFADCSlices(NULL)
@@ -143,22 +123,10 @@
     fTitle = title ? title : "Statistics of the FADC sums of Blind Pixel calibration events";
 
-    SetNbins( fgChargeNbins );
-    SetFirst( fgChargeFirst );
-    SetLast ( fgChargeLast  );
-    
     fASinglePheFADCSlices.ResizeTo(1);
     fAPedestalFADCSlices.ResizeTo(1);
 
-    SetSinglePheCut();
     SetNumSinglePheLimit();
     SetProbLimit(0.001);
     SetBinsAfterStripping(0);
-
-    fHGausHist.SetName("HCalibrationChargeBlindPix");
-    fHGausHist.SetTitle("Distribution of Summed FADC slices Blind Pixel");  
-    fHGausHist.SetXTitle("Signal Amplitude");
-    fHGausHist.SetYTitle("Nr. of events");
-
-    fPixId     = 0;
 
     Clear();
@@ -224,6 +192,5 @@
   fLambdaCheckErr = gkSignalInitializer;
   
-  //  fFitFunc = kEMichele;
-  fFitFunc = kEPoisson5;
+  fFitFunc = MHCalibrationChargeBlindCam::kEPoisson5;
 
   fNumSinglePhes    = 0;
@@ -356,8 +323,4 @@
   pix.fNDF            = fNDF;              
   pix.fProb           = fProb;             
-  pix.fMeanPedestal   = fMeanPedestal;     
-  pix.fSigmaPedestal  = fSigmaPedestal;    
-  pix.fMeanPedestalErr  = fMeanPedestalErr;  
-  pix.fSigmaPedestalErr = fSigmaPedestalErr; 
 
   return &pix;
@@ -427,159 +390,9 @@
 // --------------------------------------------------------------------------
 //
-// Gets the pointers to:
-// - MRawEvtData
-// - MExtractedSignalBlindPixel
+// Normalizes fASinglePheFADCSlices and fAPedestalFADCSlices
 // 
-Bool_t MHCalibrationChargeBlindPix::SetupFill(const MParList *pList) 
-{
-
-  fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
-  if (!fRawEvt)
-    {
-      *fLog << err << "MRawEvtData not found... aborting." << endl;
-      return kFALSE;
-    }
-  
-  fSignal  = (MExtractedSignalBlindPixel*)pList->FindObject("MExtractedSignalBlindPixel");
-  if (!fSignal)
-    {
-      *fLog << err << "MExtractedSignalBlindPixel not found... aborting " << endl;
-      return kFALSE;
-    }
-  
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Gets or creates the pointers to:
-// - MCalibrationChargeBlindPix
-//
-// Calls:
-// - MHGausHist::InitBins()
-//
-Bool_t MHCalibrationChargeBlindPix::ReInit(MParList *pList)
-{
-
-  fBlindPix = (MCalibrationChargeBlindPix*)pList->FindCreateObj("MCalibrationChargeBlindPix");
-  if (!fBlindPix)
-      return kFALSE;
-
-  const Int_t samples = fSignal->GetNumFADCSamples();
-  const Int_t integ   = fSignal->IsExtractionType( MExtractBlindPixel::kIntegral );
-
-  //
-  // Modify the histogram size in case, integrals have been used
-  //
-  if ( fLast < samples*integ*fgChargeLast )
-    {
-      SetLast        ( samples * (fgChargeLast+0.5) - 0.5 );
-      SetSinglePheCut( samples * fgSinglePheCut );
-    }
-
-  MHCalibrationPix::InitBins();
-  
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Retrieves from MExtractedSignalBlindPixel:
-// - number of FADC samples
-// - extracted signal 
-// - blind Pixel ID
-//
-// Resizes (if necessary):
-// - fASinglePheFADCSlices to sum of HiGain and LoGain samples
-// - fAPedestalFADCSlices to sum of HiGain and LoGain samples
-//
-// Fills the following histograms:
-// - MHGausEvents::FillHistAndArray(signal)
-//
-// Creates MRawEvtPixelIter, jumps to blind pixel ID, 
-// fills the vectors fASinglePheFADCSlices and fAPedestalFADCSlices 
-// with the full FADC slices, depending on the size of the signal w.r.t. fSinglePheCut
-//
-Bool_t MHCalibrationChargeBlindPix::Fill(const MParContainer *par, const Stat_t w)
-{
-
-  const Int_t samples = (Int_t)fRawEvt->GetNumHiGainSamples()
-                      +(Int_t)fRawEvt->GetNumLoGainSamples();
-
-  if (!fASinglePheFADCSlices.IsValid())
-    {
-      fASinglePheFADCSlices.ResizeTo(samples);
-      fAPedestalFADCSlices.ResizeTo(samples);
-    }
-
-  if (fASinglePheFADCSlices.GetNrows() != samples)
-    {
-      fASinglePheFADCSlices.ResizeTo(samples);
-      fAPedestalFADCSlices.ResizeTo(samples);
-    }
-
-  Float_t slices = (Float_t)fSignal->GetNumFADCSamples();
-  
-  if (slices == 0.)
-    {
-      *fLog << err 
-	    << "Number of used signal slices in MExtractedSignalBlindPix "
-	    << "is zero  ... abort." 
-            << endl;
-      return kFALSE;
-    }
-  
-  //
-  // Signal extraction and histogram filling
-  //
-  const Float_t signal = fSignal->GetExtractedSignal(fPixId);
-
-  if (signal > -0.5)
-    FillHist(signal);
-  else
-    return kTRUE;
-
-  //
-  // In order to study the single-phe posistion, we extract the slices
-  //
-  const Int_t blindpixIdx = fSignal->GetBlindPixelIdx(fPixId);
-
-  MRawEvtPixelIter pixel(fRawEvt);
-  pixel.Jump(blindpixIdx);
-
-  if (signal > fSinglePheCut)
-      FillSinglePheFADCSlices(pixel);
-  else
-      FillPedestalFADCSlices(pixel);
-
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Returns kFALSE, if empty
-//
-// - Creates the fourier spectrum and sets bit MHGausEvents::IsFourierSpectrumOK()
-// - Retrieves the pedestals from MExtractedSignalBlindPixel
-// - Normalizes fASinglePheFADCSlices and fAPedestalFADCSlices
-// - Executes FitPedestal()
-// - Executes FitSinglePhe()
-// - Retrieves fit results and stores them in MCalibrationChargeBlindPix
-// 
-Bool_t MHCalibrationChargeBlindPix::Finalize() 
-{
-  
-  if (IsEmpty())
-  {
-    *fLog << err << GetDescriptor() << " ID: " << fPixId 
-	  << " My histogram has not been filled !! " << endl;
-      return kFALSE;
-  }
-
-  fMeanPedestal     = fSignal->GetPed();
-  fMeanPedestalErr  = fSignal->GetPedErr();
-  fSigmaPedestal    = fSignal->GetPedRms();
-  fSigmaPedestalErr = fSignal->GetPedRmsErr();
-
+void MHCalibrationChargeBlindPix::FinalizeSinglePheSpectrum() 
+{
+  
   if (fNumSinglePhes > 1)
       for (Int_t i=0;i<fASinglePheFADCSlices.GetNrows();i++)
@@ -587,33 +400,6 @@
   if (fNumPedestals > 1)
       for (Int_t i=0;i<fAPedestalFADCSlices.GetNrows();i++)
-	  fAPedestalFADCSlices[i]  = fAPedestalFADCSlices[i]/fNumPedestals;
-
-  FitPedestal();
-
-  fBlindPix->SetValid(kTRUE);
-
-  if (FitSinglePhe())
-    fBlindPix->SetSinglePheFitOK();
-  else
-    fBlindPix->SetValid(IsPedestalFitOK());
-
-  fBlindPix->SetLambda      (    fLambda               );
-  fBlindPix->SetLambdaVar   (    fLambdaErr*fLambdaErr );
-  fBlindPix->SetMu0         (    fMu0                  );
-  fBlindPix->SetMu0Err      (    fMu0Err               );
-  fBlindPix->SetMu1         (    fMu1                  );
-  fBlindPix->SetMu1Err      (    fMu1Err               );
-  fBlindPix->SetSigma0      (    fSigma0               );
-  fBlindPix->SetSigma0Err   (    fSigma0Err            );
-  fBlindPix->SetSigma1      (    fSigma1               );
-  fBlindPix->SetSigma1Err   (    fSigma1Err            );
-  fBlindPix->SetProb        (    fProb                 );
-
-  fBlindPix->SetLambdaCheck    ( fLambdaCheck          );
-  fBlindPix->SetLambdaCheckErr ( fLambdaCheckErr       );
-
-  return kTRUE;
-}
-
+        fAPedestalFADCSlices[i]  = fAPedestalFADCSlices[i]/fNumPedestals;
+}
 
 // --------------------------------------------------------------------------
@@ -733,19 +519,19 @@
   switch (fFitFunc)
     {
-    case kEPoisson4:
+    case MHCalibrationChargeBlindCam::kEPoisson4:
       fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto4,rmin,rmax,6);
       rmin += 6.5;
       break;
-    case kEPoisson5:
+    case MHCalibrationChargeBlindCam::kEPoisson5:
       fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto5,rmin,rmax,6);
       rmin = 0.;
       break;
-    case kEPoisson6:
+    case MHCalibrationChargeBlindCam::kEPoisson6:
       fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto6,rmin,rmax,6);
       break;
-    case kEPolya:
+    case MHCalibrationChargeBlindCam::kEPolya:
       fSinglePheFit = new TF1("SinglePheFit",&fPolya,rmin,rmax,8);
       break;
-    case kEMichele:
+    case MHCalibrationChargeBlindCam::kEMichele:
       fSinglePheFit = new TF1("SinglePheFit",&fFitFuncMichele,rmin,rmax,9);
       break;
@@ -786,5 +572,5 @@
     {
       
-    case kEPoisson4:
+    case MHCalibrationChargeBlindCam::kEPoisson4:
 	fSinglePheFit->SetParNames(  "#lambda",   "#mu_{0}",    "#mu_{1}", "#sigma_{0}",  "#sigma_{1}","Area");
         fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm);
@@ -796,6 +582,6 @@
 	fSinglePheFit->SetParLimits(5,norm-(0.5*norm),norm+(0.7*norm));
 	break;
-    case kEPoisson5:
-    case kEPoisson6:
+    case MHCalibrationChargeBlindCam::kEPoisson5:
+    case MHCalibrationChargeBlindCam::kEPoisson6:
       fSinglePheFit->SetParNames("#lambda","#mu_{0}","#mu_{1}","#sigma_{0}","#sigma_{1}","Area");
       fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,800.,si_0_guess,500.,norm);
@@ -808,11 +594,11 @@
       break;
 
-    case kEPolya:
+    case MHCalibrationChargeBlindCam::kEPolya:
         fSinglePheFit->SetParameters(lambda_guess, excessPoisson_guess,
                                      delta1_guess,delta2_guess,
                                      electronicAmp_guess,
-                                     fSigmaPedestal,
+                                     10.,
                                      norm, 
-                                     fMeanPedestal);
+                                     0.);
       fSinglePheFit->SetParNames("#lambda","b_{tot}",
                                  "#delta_{1}","#delta_{2}",
@@ -825,13 +611,9 @@
       fSinglePheFit->SetParLimits(4,electronicAmp_guess-electronicAmp_limit,
                                     electronicAmp_guess+electronicAmp_limit);    
-      fSinglePheFit->SetParLimits(5,
-                                    fSigmaPedestal-3.*fSigmaPedestalErr,
-                                    fSigmaPedestal+3.*fSigmaPedestalErr);
+      fSinglePheFit->SetParLimits(5,0.,40.);
       fSinglePheFit->SetParLimits(6,norm-0.1,norm+0.1);
-      fSinglePheFit->SetParLimits(7,
-                                    fMeanPedestal-3.*fMeanPedestalErr,
-                                    fMeanPedestal+3.*fMeanPedestalErr);
-      break;
-    case kEMichele:
+      fSinglePheFit->SetParLimits(7,-10.,10.);
+      break;
+    case MHCalibrationChargeBlindCam::kEMichele:
       fSinglePheFit->SetParNames("#lambda_{cat}","#lambda_{dyn}",
                                  "#mu_{0}","#mu_{1cat}","#mu_{1dyn}",
@@ -879,8 +661,8 @@
     {
       
-    case kEPoisson4:
-    case kEPoisson5:
-    case kEPoisson6:
-    case kEPoisson7:
+    case MHCalibrationChargeBlindCam::kEPoisson4:
+    case MHCalibrationChargeBlindCam::kEPoisson5:
+    case MHCalibrationChargeBlindCam::kEPoisson6:
+    case MHCalibrationChargeBlindCam::kEPoisson7:
       fLambda = fSinglePheFit->GetParameter(0);
       fMu0    = fSinglePheFit->GetParameter(1);
@@ -895,5 +677,5 @@
       fSigma1Err = fSinglePheFit->GetParError(4);
       break;
-    case kEPolya:
+    case MHCalibrationChargeBlindCam::kEPolya:
       fLambda =  fSinglePheFit->GetParameter(0);
       fMu0    =  fSinglePheFit->GetParameter(7);
@@ -907,5 +689,5 @@
       fSigma0Err = fSinglePheFit->GetParError(5);
       fSigma1Err = 0.;
-    case kEMichele:
+    case MHCalibrationChargeBlindCam::kEMichele:
       fLambda =  fSinglePheFit->GetParameter(0);
       fMu0    =  fSinglePheFit->GetParameter(2);
@@ -1037,9 +819,10 @@
       fFitLegend = new TPaveText(0.05,0.05,0.95,0.95);
       fFitLegend->SetLabel(Form("%s%s", "Results of the single PhE Fit (",
-				(fFitFunc ==  kEPoisson4) ? "Poisson(k=4))" : 
-				(fFitFunc ==  kEPoisson5) ? "Poisson(k=5))" : 
-				(fFitFunc ==  kEPoisson6) ? "Poisson(k=6))" :
-				(fFitFunc ==  kEPolya   ) ? "Polya(k=4))"   : 
-				(fFitFunc ==  kEMichele ) ?  "Michele)"     : " none )" ));
+				(fFitFunc ==  MHCalibrationChargeBlindCam::kEPoisson4) ? "Poisson(k=4))" : 
+				(fFitFunc ==  MHCalibrationChargeBlindCam::kEPoisson5) ? "Poisson(k=5))" : 
+				(fFitFunc ==  MHCalibrationChargeBlindCam::kEPoisson6) ? "Poisson(k=6))" :
+				(fFitFunc ==  MHCalibrationChargeBlindCam::kEPolya   ) ? "Polya(k=4))"   : 
+				(fFitFunc ==  MHCalibrationChargeBlindCam::kEMichele ) ?  "Michele)"     
+                                                                                       : " none )" ));
       fFitLegend->SetTextSize(0.05);
   }
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindPix.h
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindPix.h	(revision 4985)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationChargeBlindPix.h	(revision 4986)
@@ -7,4 +7,8 @@
 #endif
 
+#ifndef MARS_MHCalibrationChargeBlindCam
+#include "MHCalibrationChargeBlindCam.h"
+#endif
+
 #ifndef ROOT_TF1
 #include <TF1.h>
@@ -18,9 +22,6 @@
 class TPaveText;
 class TText;
-class MRawEvtData;
+class MExtractedSignalBlindPixel;
 class MRawEvtPixelIter;
-class MCalibrationChargeBlindPix;
-class MExtractBlindPixel;
-class MExtractedSignalBlindPixel;
 
 class MHCalibrationChargeBlindPix : public MHCalibrationPix
@@ -28,8 +29,4 @@
 private:
 
-  static const Int_t    fgChargeNbins;       //! Default for fNBins        (now set to: 5300   )
-  static const Axis_t   fgChargeFirst;       //! Default for fFirst        (now set to: -100.5 )
-  static const Axis_t   fgChargeLast;        //! Default for fLast         (now set to: 5199.5 )
-  static const Float_t  fgSinglePheCut;      //! Default for fSinglePheCut (now set to: 200    )
   static const Float_t  fgNumSinglePheLimit; //! Default for fNumSinglePheLimit (now set to: 50)
   static const Float_t  gkSignalInitializer; //! Signal initializer (-9999.)
@@ -41,8 +38,4 @@
   Float_t fNumSinglePheLimit;                // Minimum number of single-phe events 
 
-  MCalibrationChargeBlindPix *fBlindPix;     //! Storage container results  
-  MExtractedSignalBlindPixel *fSignal;       //! Storage container extracted signal
-  MRawEvtData                *fRawEvt;       //! Storage container raw data
- 
   TVector fASinglePheFADCSlices;             // Averaged FADC slice entries supposed single-phe events
   TVector fAPedestalFADCSlices;              // Averaged FADC slice entries supposed pedestal   events
@@ -68,24 +61,20 @@
   Int_t     fNDF;                            // Ndof of single-phe fit 
   Double_t  fProb;                           // Probability of singleo-phe fit
-  Double_t  fMeanPedestal;                   // Mean pedestal from pedestal run
-  Double_t  fSigmaPedestal;                  // Sigma pedestal from pedestal run
-  Double_t  fMeanPedestalErr;                // Error of Mean pedestal from pedestal run 
-  Double_t  fSigmaPedestalErr;               // Error of Sigma pedestal from pedestal run
 				     
   Byte_t    fFlags;                          // Bit-field for the flags
   enum { kSinglePheFitOK, kPedestalFitOK };  // Possible bits to be set
 
+  MHCalibrationChargeBlindCam::FitFunc_t fFitFunc;
+
   TPaveText *fFitLegend;                     //! Some legend to display the fit results
   TH1F      *fHSinglePheFADCSlices;          //! A histogram created and deleted only in Draw()
   TH1F      *fHPedestalFADCSlices;           //! A histogram created and deleted only in Draw()
 
-  // Fill histos
-  void  FillSinglePheFADCSlices(const MRawEvtPixelIter &iter);
-  void  FillPedestalFADCSlices( const MRawEvtPixelIter &iter);
-
   // Fit
   Bool_t InitFit();
   void   ExitFit();  
   
+  void DrawLegend(Option_t *opt="");
+  
 public:
 
@@ -98,9 +87,4 @@
   //  TObject *Clone(const char *) const;
 
-  Bool_t SetupFill(const MParList *pList);
-  Bool_t ReInit   (      MParList *pList);
-  Bool_t Fill     (const MParContainer *par, const Stat_t w=1);
-  Bool_t Finalize();
-  
   // Getters
   const Double_t GetLambda        ()  const { return fLambda;         }
@@ -128,35 +112,23 @@
   
   // Setters
-  void SetCalibrationChargeBlindPix ( MCalibrationChargeBlindPix *pix)    { fBlindPix          = pix;  }
-  void SetSinglePheCut      ( const Float_t cut =fgSinglePheCut      )    { fSinglePheCut      = cut;  }
+  void SetFitFunc(const MHCalibrationChargeBlindCam::FitFunc_t func)  { fFitFunc = func;  }
+  void SetSinglePheCut      ( const Float_t cut = 0.               )    { fSinglePheCut      = cut;  }
   void SetNumSinglePheLimit ( const Float_t lim =fgNumSinglePheLimit )    { fNumSinglePheLimit = lim;  }
-
-  void SetMeanPedestal      ( const Float_t f )   { fMeanPedestal     = f;  }
-  void SetMeanPedestalErr   ( const Float_t f )   { fMeanPedestalErr  = f;  }
-  void SetSigmaPedestal     ( const Float_t f )   { fSigmaPedestal    = f;  }
-  void SetSigmaPedestalErr  ( const Float_t f )   { fSigmaPedestalErr = f;  }
 
   void SetSinglePheFitOK    ( const Bool_t b=kTRUE);
   void SetPedestalFitOK     ( const Bool_t b=kTRUE);
   
+  // Fill histos
+  void  FillSinglePheFADCSlices(const MRawEvtPixelIter &iter);
+  void  FillPedestalFADCSlices( const MRawEvtPixelIter &iter);
+  void  FinalizeSinglePheSpectrum();
+  
   // Draws
   void Draw(Option_t *opt="");
 
-private:
-  void DrawLegend(Option_t *opt="");
-  
   // Fits
-public:
-  enum FitFunc_t { kEPoisson4, kEPoisson5, kEPoisson6, kEPoisson7, kEPolya, kEMichele }; // The possible fit functions
-
-private:
-  FitFunc_t fFitFunc;
-
-public:
   Bool_t FitSinglePhe (Option_t *opt="RL0+Q");
   void   FitPedestal  (Option_t *opt="RL0+Q");
 
-  void   ChangeFitFunc(const FitFunc_t func)  { fFitFunc = func;  }
-  
   // Simulation
   Bool_t SimulateSinglePhe(const Double_t lambda,
Index: trunk/MagicSoft/Mars/mhcalib/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/Makefile	(revision 4985)
+++ trunk/MagicSoft/Mars/mhcalib/Makefile	(revision 4986)
@@ -32,10 +32,10 @@
 # mimage     MHillas
 
-SRCFILES = MHCalibrationChargeBlindPix.cc \
-           MHCalibrationChargeBlindCam.cc \
-           MHCalibrationChargePix.cc \
-           MHCalibrationCam.cc \
+SRCFILES = MHCalibrationCam.cc \
            MHCalibrationPix.cc \
            MHCalibrationChargeCam.cc \
+           MHCalibrationChargePix.cc \
+           MHCalibrationChargeBlindCam.cc \
+           MHCalibrationChargeBlindPix.cc \
            MHCalibrationChargePINDiode.cc \
            MHCalibrationRelTimeCam.cc \
