Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 4898)
+++ trunk/MagicSoft/Mars/Changelog	(revision 4899)
@@ -21,4 +21,31 @@
 
  2004/09/09: Markus Gaug
+
+   * mcalib/MCalibrationIntensityCam.[h,cc]
+   * mcalib/MCalibrationIntensityChargeCam.[h,cc]
+   * mcalib/MCalibrationIntensityQECam.[h,cc]
+   * mcalib/MCalibrationIntensityRelTimeCam.[h,cc]
+   * mcalib/Makefile
+   * mcalib/CalibLinkDef.h
+     - new classes for the intensity calibration. First is base class, 
+       other derive from it.
+
+   * mcalib/MHGausEvents.[h,cc]
+   * mcalib/MHCalibrationPix.[h,cc]
+   * mcalib/Makefile
+   * mcalib/CalibLinkDef.h
+     - put typical calibration members into new base class MHCalibrationPix
+       and leave only typical Gaussian behaviour members in MHGausEvents.
+     - all MHCalibration*Pix classes derive now from MHCalibrationPix
+       
+   * mcalib/MCalibColorSet.[h,cc]
+     - finished
+
+   * mcalib/MCalibColorSteer.[h,cc]
+   * mcalib/Makefile
+   * mcalib/CalibLinkDef.h
+     - new task to be executed before the calibration tasks. Steers the 
+       occurrance of multiple intensities and the new *Intensity* 
+       containers
 
    * msignal/MExtractor.cc
Index: trunk/MagicSoft/Mars/mcalib/MCalibColorSet.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibColorSet.cc	(revision 4898)
+++ trunk/MagicSoft/Mars/mcalib/MCalibColorSet.cc	(revision 4899)
@@ -39,4 +39,6 @@
 #include "MCalibColorSet.h"
 
+#include "TRegexp.h"
+
 #include "MLog.h"
 #include "MLogManip.h"
@@ -49,7 +51,9 @@
 ClassImp(MCalibColorSet);
 
+
 using namespace std;
 
 const Int_t MCalibColorSet::gkIFAEBoxInaugurationRun = 20113;
+const Int_t MCalibColorSet::gkMCRunLimit             = 1000;
 // --------------------------------------------------------------------------
 //
@@ -126,33 +130,50 @@
       k1LedGreen   = BIT(14),
       k2LedGreen   = BIT(1 ),
-      k3LedGreen   = k1LedGreen & k2LedGreen,
+      k3LedGreen   = k1LedGreen | k2LedGreen,
       k5LedGreen   = BIT(0 ),
+      k6LedGreen   = k5LedGreen | k1LedGreen,
+      k7LedGreen   = k5LedGreen | k2LedGreen,
+      k8LedGreen   = k5LedGreen | k3LedGreen,
       k1LedUV      = BIT(3 ),
       k2LedUV      = BIT(4 ),
-      k3LedUV      = k1LedUV & k2LedUV,
+      k3LedUV      = k1LedUV | k2LedUV,
       k5LedUV1     = BIT(11),
       k5LedUV2     = BIT(12),
-      k10LedUV     = k5LedUV1 & k5LedUV2,
-      k11LedUV     = k10LedUV & k1LedUV,
-      k12LedUV     = k10LedUV & k2LedUV,
-      k13LedUV     = k10LedUV & k1LedUV,
+      k6LedUV      = k5LedUV1 | k1LedUV,
+      k7LedUV      = k5LedUV1 | k2LedUV,
+      k8LedUV      = k5LedUV1 | k3LedUV,
+      k10LedUV     = k5LedUV1 | k5LedUV2,
+      k11LedUV     = k10LedUV | k1LedUV,
+      k12LedUV     = k10LedUV | k2LedUV,
+      k13LedUV     = k10LedUV | k1LedUV,
       k01LedBlue   = BIT(8 ),
       k1LedBlue    = BIT(10),
       k2LedBlue    = BIT(7 ),
-      k3LedBlue    = k1LedBlue & k2LedBlue,
+      k3LedBlue    = k1LedBlue | k2LedBlue,
       k5LedBlue1   = BIT(13),
       k5LedBlue2   = BIT(2 ),      
       k5LedBlue3   = BIT(5 ),
       k5LedBlue4   = BIT(6 ),
-      k10LedBlue   = k5LedBlue1 & k5LedBlue2,
-      k15LedBlue   = k10LedBlue & k5LedBlue3,
-      k20LedBlue   = k15LedBlue & k5LedBlue4,
-      k21LedBlue   = k20LedBlue & k1LedBlue,
-      k22LedBlue   = k20LedBlue & k2LedBlue,
-      k23LedBlue   = k22LedBlue & k1LedBlue,
+      k6LedBlue    = k5LedBlue1 | k1LedBlue,
+      k7LedBlue    = k5LedBlue1 | k2LedBlue,
+      k8LedBlue    = k5LedBlue1 | k3LedBlue,
+      k10LedBlue   = k5LedBlue1 | k5LedBlue2,
+      k15LedBlue   = k10LedBlue | k5LedBlue3,
+      k20LedBlue   = k15LedBlue | k5LedBlue4,
+      k21LedBlue   = k20LedBlue | k1LedBlue,
+      k22LedBlue   = k20LedBlue | k2LedBlue,
+      k23LedBlue   = k22LedBlue | k1LedBlue,
       kCT1Pulser   = BIT(16)
     };
 
   const Int_t num = header->GetRunNumber();
+
+  if (num<gkMCRunLimit)
+    {
+      *fLog << inf << "Assumed MC run ... using GREEN pulser." << endl;
+      fPattern |= k1LedGreen;
+      fIsValid  = kTRUE;
+      return kTRUE;
+    }
 
   if (num<gkIFAEBoxInaugurationRun)
@@ -204,58 +225,110 @@
   else
     {
+
       const TString proj = header->GetProjectName();
       
       // Possible green combinations
-      if (proj.Contains("0.1ledgree",TString::kIgnoreCase))
+      TRegexp gre0("[0.1][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
+      if (proj.Contains(gre0))
         { fPattern |= k01LedGreen; color = kGREEN;    }
-      if (proj.Contains("1ledgree",TString::kIgnoreCase))
+      TRegexp gre1("[1][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
+      if (proj.Contains(gre1))
         { fPattern |= k1LedGreen; color = kGREEN;    }
-      if (proj.Contains("2ledgree",TString::kIgnoreCase))
+      TRegexp gre2("[2][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
+      if (proj.Contains(gre2))
         { fPattern |= k2LedGreen; color = kGREEN;    }
-      if (proj.Contains("3ledgree",TString::kIgnoreCase))
+      TRegexp gre3("[3][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
+      if (proj.Contains(gre3))
         { fPattern |= k3LedGreen; color = kGREEN;    }
-      if (proj.Contains("5ledgree",TString::kIgnoreCase))
+      TRegexp gre5("[5][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
+      if (proj.Contains(gre5))
         { fPattern |= k5LedGreen; color = kGREEN;    }
+      TRegexp gre6("[6][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
+      if (proj.Contains(gre6))
+        { fPattern |= k6LedGreen; color = kGREEN;    }
+      TRegexp gre7("[7][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
+      if (proj.Contains(gre7))
+        { fPattern |= k7LedGreen; color = kGREEN;    }
+      TRegexp gre8("[8][lL]?[eE]?[dD]?[sS]?[gG][rR][eE][eE]");
+      if (proj.Contains(gre8))
+        { fPattern |= k8LedGreen; color = kGREEN;    }
 
       // Possible green combinations
-      if (proj.Contains("0.1ledblue",TString::kIgnoreCase))
+      TRegexp blu0("[0.1][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu0))
         { fPattern |= k01LedBlue; color = kBLUE;    }
-      if (proj.Contains("1ledblue",TString::kIgnoreCase))
+      TRegexp blu1("[1][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu1))
         { fPattern |= k1LedBlue; color = kBLUE;    }
-      if (proj.Contains("2ledblue",TString::kIgnoreCase))
+      TRegexp blu2("[2][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu2))
         { fPattern |= k2LedBlue; color = kBLUE;    }
-      if (proj.Contains("3ledblue",TString::kIgnoreCase))
+      TRegexp blu3("[3][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu3))
         { fPattern |= k3LedBlue; color = kBLUE;    }
-      if (proj.Contains("5ledblue",TString::kIgnoreCase))
+      TRegexp blu5("[5][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu5))
         { fPattern |= k5LedBlue1; color = kBLUE;    }
-      if (proj.Contains("10ledblue",TString::kIgnoreCase))
+      TRegexp blu6("[6][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu6))
+        { fPattern |= k6LedBlue; color = kBLUE;    }
+      TRegexp blu7("[7][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu7))
+        { fPattern |= k7LedBlue; color = kBLUE;    }
+      TRegexp blu8("[8][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu8))
+        { fPattern |= k8LedBlue; color = kBLUE;    }
+      TRegexp blu10("[10][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu10))
         { fPattern |= k10LedBlue; color = kBLUE;    }
-      if (proj.Contains("15ledblue",TString::kIgnoreCase))
+      TRegexp blu15("[15][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu15))
         { fPattern |= k15LedBlue; color = kBLUE;    }
-      if (proj.Contains("20ledblue",TString::kIgnoreCase))
+      TRegexp blu20("[20][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu20))
         { fPattern |= k20LedBlue; color = kBLUE;    }
-      if (proj.Contains("21ledblue",TString::kIgnoreCase))
+      TRegexp blu21("[21][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu21))
         { fPattern |= k21LedBlue; color = kBLUE;    }
-      if (proj.Contains("22ledblue",TString::kIgnoreCase))
+      TRegexp blu22("[22][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu22))
         { fPattern |= k22LedBlue; color = kBLUE;    }
-      if (proj.Contains("23ledblue",TString::kIgnoreCase))
+      TRegexp blu23("[23][lL]?[eE]?[dD]?[sS]?[bB][lL][uU][eE]");
+      if (proj.Contains(blu23))
         { fPattern |= k23LedBlue; color = kBLUE;    }
-      
+
       // Possible UV combinations
-      if (proj.Contains("1leduv",TString::kIgnoreCase))
+      TRegexp uv1("[1][lL]?[eE]?[dD]?[sS]?[U][vV]");
+      if (proj.Contains(uv1))
         { fPattern |= k1LedUV; color = kUV;    }
-      if (proj.Contains("2leduv",TString::kIgnoreCase))
+      TRegexp uv2("[2][lL]?[eE]?[dD]?[sS]?[U][vV]");
+      if (proj.Contains(uv2))
         { fPattern |= k2LedUV; color = kUV;    }
-      if (proj.Contains("3leduv",TString::kIgnoreCase))
+      TRegexp uv3("[3][lL]?[eE]?[dD]?[sS]?[U][vV]");
+      if (proj.Contains(uv3))
         { fPattern |= k3LedUV; color = kUV;    }
-      if (proj.Contains("5leduv",TString::kIgnoreCase))
+      TRegexp uv5("[5][lL]?[eE]?[dD]?[sS]?[U][vV]");
+      if (proj.Contains(uv5))
         { fPattern |= k5LedUV1; color = kUV;    }
-      if (proj.Contains("10leduv",TString::kIgnoreCase))
+      TRegexp uv6("[6][lL]?[eE]?[dD]?[sS]?[U][vV]");
+      if (proj.Contains(uv6))
+        { fPattern |= k6LedUV; color = kUV;    }
+      TRegexp uv7("[7][lL]?[eE]?[dD]?[sS]?[U][vV]");
+      if (proj.Contains(uv7))
+        { fPattern |= k7LedUV; color = kUV;    }
+      TRegexp uv8("[8][lL]?[eE]?[dD]?[sS]?[U][vV]");
+      if (proj.Contains(uv8))
+        { fPattern |= k8LedUV; color = kUV;    }
+      TRegexp uv10("[10][lL]?[eE]?[dD]?[sS]?[U][vV]");
+      if (proj.Contains(uv10))
         { fPattern |= k10LedUV; color = kUV;    }
-      if (proj.Contains("11leduv",TString::kIgnoreCase))
+      TRegexp uv11("[11][lL]?[eE]?[dD]?[sS]?[U][vV]");
+      if (proj.Contains(uv11))
         { fPattern |= k11LedUV; color = kUV;    }
-      if (proj.Contains("12leduv",TString::kIgnoreCase))
+      TRegexp uv12("[12][lL]?[eE]?[dD]?[sS]?[U][vV]");
+      if (proj.Contains(uv12))
         { fPattern |= k12LedUV; color = kUV;    }
-      if (proj.Contains("13leduv",TString::kIgnoreCase))
+      TRegexp uv13("[13][lL]?[eE]?[dD]?[sS]?[U][vV]");
+      if (proj.Contains(uv13))
         { fPattern |= k13LedUV; color = kUV;    }
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibColorSet.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibColorSet.h	(revision 4898)
+++ trunk/MagicSoft/Mars/mcalib/MCalibColorSet.h	(revision 4899)
@@ -12,21 +12,24 @@
 {
 private:
-    static const Int_t gkIFAEBoxInaugurationRun; //! Run number of first IFAE box calibration
 
-    MRawEvtHeader *fHeader;
+  static const Int_t gkIFAEBoxInaugurationRun; //! Run number of first IFAE box calibration (set to: 20113)
+  static const Int_t gkMCRunLimit;             //! Maximum MC run number (now set to: 1000)
 
-    UInt_t fPattern;
-    Bool_t fIsValid;
+  MRawEvtHeader *fHeader;                     //! Event header with the pulse pattern information
+  
+  UInt_t fPattern;                            //  Current pulse pattern
+  Bool_t fIsValid;                            //  Have to set the pulse pattern?
+  
+  Bool_t ReInit(MParList *pList);
+  Int_t  PreProcess(MParList *pList);
+  Int_t  Process();
+  
+public:
 
-    Bool_t ReInit(MParList *pList);
-    Int_t  PreProcess(MParList *pList);
-    Int_t  Process();
-
-public:
-    MCalibColorSet(const char *name=NULL, const char *title=NULL);
-
-    void Clear(const Option_t *o="");
-
-    ClassDef(MCalibColorSet, 0) // Task to workaround missing colors
+  MCalibColorSet(const char *name=NULL, const char *title=NULL);
+  
+  void Clear(const Option_t *o="");
+  
+  ClassDef(MCalibColorSet, 0) // Task to workaround missing colors
 };
     
Index: trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.cc	(revision 4899)
+++ trunk/MagicSoft/Mars/mcalib/MCalibColorSteer.cc	(revision 4899)
@@ -0,0 +1,326 @@
+/* ======================================================================== *\
+!
+! *
+! * 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, 09/2004 <mailto:markus@ifae.es>
+!         
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MCalibColorSteer
+//
+//  Steers the occurrance of different calibration colours in one calibration 
+//  run. 
+// 
+//  Input Containers:
+//   MRawEvtHeader
+//   MParList
+//   MCalibrationIntensityChargeCam
+//   MCalibrationIntensityRelTimeCam
+//
+//  Output Containers:
+//   MCalibrationIntensityChargeCam
+//   MCalibrationIntensityRelTimeCam
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MCalibColorSteer.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MHCalibrationCam.h"
+
+#include "MCalibrationIntensityChargeCam.h"
+#include "MCalibrationIntensityQECam.h"
+#include "MCalibrationIntensityRelTimeCam.h"
+
+#include "MRawEvtHeader.h"
+
+#include "MGeomCam.h"
+
+ClassImp(MCalibColorSteer);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Default constructor. 
+//
+MCalibColorSteer::MCalibColorSteer(const char *name, const char *title)
+    : fHeader(NULL), fGeom(NULL), fParList(NULL), 
+      fIntensCharge(NULL), fIntensRelTime(NULL), 
+      fPattern(0)
+{
+
+  fName  = name  ? name  : "MCalibColorSteer";
+  fTitle = title ? title : "Task to steer the processing of different colours in the calibration events";
+
+}
+
+// -----------------------------------------------------------------------------------
+//
+// The following container are searched for and execution aborted if not in MParList:
+//  - MRawEvtHeader
+//  - MTaskList
+//
+Int_t MCalibColorSteer::PreProcess(MParList *pList)
+{
+
+  fHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
+  if (!fHeader)
+    {
+      *fLog << err << "MRawEvtHeader not found... abort." << endl;
+      return kFALSE;
+    }
+
+  fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
+  if (!fGeom)
+    {
+      *fLog << err << "MGeomCam not found... abort." << endl;
+      return kFALSE;
+    }
+
+  fParList = pList;
+  if (!fParList)
+    {
+      *fLog << err << "MParList not found... abort." << endl;
+      return kFALSE;
+    }
+
+  // 
+  // Look for the MFillH name "FillChargeCam". In case yes, initialize the 
+  // corresponding IntensityCam
+  //
+  if (pList->FindObject(AddSerialNumber("FillChargeCam")))
+  {
+    fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");
+    fIntensQE     = (MCalibrationIntensityQECam*)    pList->FindCreateObj("MCalibrationIntensityQECam");
+
+    if (!fIntensCharge)
+      {
+        *fLog << err << "Could not find nor create MCalibrationIntensityChargeCam abort... " << endl;
+        return kFALSE;
+      }
+    
+    if (fIntensQE)
+      {
+        *fLog << err << "Could not find nor create MCalibrationIntensityQECam abort... " << endl;
+        return kFALSE;
+      }
+  }
+      
+  // 
+  // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the 
+  // corresponding IntensityCam
+  //
+  if (pList->FindObject(AddSerialNumber("FillRelTimeCam")))
+  {
+    fIntensRelTime = (MCalibrationIntensityRelTimeCam*)pList->FindCreateObj("MCalibrationIntensityRelTimeCam");
+    if (!fIntensRelTime)
+      {
+        *fLog << err << "Could not find nor create MCalibrationIntensityRelTimeCam abort... " << endl;
+        return kFALSE;
+      }
+  }
+      
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets the pattern to MRawEvtHeader from outside, if fIsValid is set.
+//
+Int_t MCalibColorSteer::Process()
+{
+
+  const UInt_t pattern = fHeader->GetCalibrationPattern();
+
+  if (pattern == fPattern)
+    return kTRUE;
+
+  if (fPattern == 0)
+    {
+      fPattern = pattern;
+      //      ReInitialize();
+      return kTRUE;
+    }
+
+  fPattern = pattern;
+  
+  //
+  // Possible calibration histogram classes...
+  //
+  *fLog << inf << GetDescriptor() << " : Finalize calibration histograms..." << flush;
+  if (Finalize("MHCalibrationChargeCam"))   *fLog << "MHCalibrationChargeCam";
+  if (Finalize("MHCalibrationRelTimeCam"))  *fLog << "MHCalibrationRelTimeCam";  
+  if (Finalize("MHCalibrationTestCam"))     *fLog << "MHCalibrationChargeCam";  
+  if (Finalize("MHCalibrationTestTimeCam")) *fLog << "MHCalibrationChargeCam";  
+
+  ReInitialize();
+
+  return kTRUE;
+}
+
+Bool_t MCalibColorSteer::Finalize(const char* name)
+{
+
+  MHCalibrationCam *hist = (MHCalibrationCam*)fParList->FindObject(name);
+  if (hist)
+    {
+      hist->Finalize();
+      hist->ResetHists();
+      return kTRUE;
+    }
+
+  return kFALSE;
+  
+}
+
+Bool_t MCalibColorSteer::ReInitialize()
+{
+  if (fIntensCharge)
+    {
+      fIntensCharge->AddToList(Form("MCalibrationChargeCam%s",GetNamePattern()),*fGeom);
+      *fLog << inf << "New MHCalibrationChargeCam with " << GetNamePattern() << endl;
+    }
+  else
+    *fLog << warn << GetDescriptor() 
+          << ": No MCalibrationIntensityChargeCam loaded, but MHCalibrationChargeCam found " 
+          << endl;
+  if (fIntensQE)
+    {
+      fIntensQE->AddToList(Form("MCalibrationQECam%s",GetNamePattern()),*fGeom);
+      *fLog << inf << "New MHCalibrationQECam with " << GetNamePattern() << endl;
+    }
+  else
+    *fLog << warn << GetDescriptor() 
+          << ": No MCalibrationIntensityQECam loaded, but MHCalibrationChargeCam found " 
+          << endl;
+
+
+  if (fIntensRelTime)
+    {
+      fIntensRelTime->AddToList(Form("MCalibrationRelTimeCam%s",GetNamePattern()),*fGeom);
+      *fLog << inf << "New MHCalibrationRelTimeCam with " << GetNamePattern() << endl;
+    }
+  else
+    *fLog << warn << GetDescriptor() 
+          << ": No MCalibrationIntensityRelTimeCam loaded, but MHCalibrationRelTimeCam found " 
+          << endl;
+
+  return kTRUE;
+
+}
+
+const char* MCalibColorSteer::GetNamePattern()
+{
+
+  Float_t number[MCalibrationCam::gkNumPulserColors];
+  memset(number,0,MCalibrationCam::gkNumPulserColors*sizeof(Float_t));
+
+  enum ColorCode_t 
+    {
+      k5LedGreen   = BIT(0 ),
+      k2LedGreen   = BIT(1 ),
+      k5LedBlue2   = BIT(2 ),      
+      k1LedUV      = BIT(3 ),
+      k2LedUV      = BIT(4 ),
+      k5LedBlue3   = BIT(5 ),
+      k5LedBlue4   = BIT(6 ),
+      k2LedBlue    = BIT(7 ),
+      k01LedBlue   = BIT(8 ),
+      k1LedBlue    = BIT(10),
+      k5LedUV1     = BIT(11),
+      k5LedUV2     = BIT(12),
+      k5LedBlue1   = BIT(13),
+      k1LedGreen   = BIT(14),
+      k01LedGreen  = BIT(15),
+      kCT1Pulser   = BIT(16)
+    };
+
+  if (fPattern & k5LedGreen)
+    number[MCalibrationCam::kGREEN] += 5;
+  if (fPattern & k2LedGreen)
+    number[MCalibrationCam::kGREEN] += 2;
+  if (fPattern & k5LedBlue2)
+    number[MCalibrationCam::kBLUE]  += 2;
+  if (fPattern & k1LedUV)           
+    number[MCalibrationCam::kUV]    += 1;
+  if (fPattern & k2LedUV)           
+    number[MCalibrationCam::kUV]    += 2;
+  if (fPattern & k5LedBlue3)        
+    number[MCalibrationCam::kBLUE]  += 5;
+  if (fPattern & k5LedBlue4)        
+    number[MCalibrationCam::kBLUE]  += 5;
+  if (fPattern & k2LedBlue)         
+    number[MCalibrationCam::kBLUE]  += 2;
+  if (fPattern & k01LedBlue)        
+    number[MCalibrationCam::kBLUE]  += 0.5;
+  if (fPattern & k1LedBlue)         
+    number[MCalibrationCam::kBLUE]  += 1;
+  if (fPattern & k5LedUV1)          
+    number[MCalibrationCam::kUV]    += 5;
+  if (fPattern & k5LedUV2)        
+    number[MCalibrationCam::kUV]    += 5;
+  if (fPattern & k5LedBlue1)        
+    number[MCalibrationCam::kBLUE]  += 5;
+  if (fPattern & k1LedGreen)
+    number[MCalibrationCam::kGREEN] += 1;
+  if (fPattern & k01LedGreen)
+    number[MCalibrationCam::kGREEN] += 0.5;
+  if (fPattern & kCT1Pulser)
+    number[MCalibrationCam::kCT1]   += 1;
+
+  TString result;
+  
+  for (Int_t i=0; i<MCalibrationCam::gkNumPulserColors; i++)
+    {
+      switch (i)
+        {
+        case MCalibrationCam::kGREEN:
+          if (number[i] > 0.1)
+            {
+              result += number[i];
+              result += "GREEN";
+            }
+          break;
+        case MCalibrationCam::kBLUE:
+          if (number[i] > 0.1)
+            {
+              result += number[i];
+              result += "BLUE";
+            }
+          break;
+        case MCalibrationCam::kUV:
+          if (number[i] > 0.1)
+            {
+              result += number[i];
+              result += "UV";
+            }
+          break;
+        case MCalibrationCam::kCT1:
+          if (number[i] > 0.1)
+            result += "CT1";
+          break;
+        }
+    }
+  return result.Data();
+}
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc	(revision 4899)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc	(revision 4899)
@@ -0,0 +1,379 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationIntensityCam                                               
+//                                                               
+// Base class for intensity calibration results 
+//
+// Contains TClonesArrays for the following objects:
+// - fCams:  Array of classes derived from MCalibrationCam, one entry 
+//           per calibration camera result. Has to be created
+//
+// See also: MCalibrationIntensityChargeCam, MCalibrationIntensityQECam,
+//           MCalibrationIntensityRelTimeCam,
+//           MCalibrationCam, MCalibrationPix, 
+//           MCalibrationQECam, MCalibrationQEPix,
+//           MHCalibrationChargePix, MHCalibrationChargeCam              
+//           MCalibrationChargeBlindPix, MCalibrationChargePINDiode
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationIntensityCam.h"
+
+#include <TClonesArray.h>
+
+#include "MGeomCam.h"
+
+ClassImp(MCalibrationIntensityCam);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Set the following pointer to NULL:
+// - fCams
+//
+MCalibrationIntensityCam::MCalibrationIntensityCam(const char *name, const char *title)
+    : fCams(NULL)
+{
+
+  fName  = name  ? name  : "MCalibrationIntensityCam";
+  fTitle = title ? title : "Base container for the Intensity Calibration";
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Deletes the histograms if they exist
+//
+MCalibrationIntensityCam::~MCalibrationIntensityCam()
+{
+  if (fCams)
+    delete fCams;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new MCalibrationCam to fCams, give it the name "name" and initialize
+// it with geom.
+//
+void MCalibrationIntensityCam::AddToList( const char* name, const MGeomCam &geom) 
+{
+
+  fCams->ExpandCreate(GetSize()+1);
+
+  GetCam()->SetName(name);
+  GetCam()->Init(geom);
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Copy 'constructor'
+//
+void MCalibrationIntensityCam::Copy(TObject& object) const
+{
+  
+  MCalibrationIntensityCam &calib = (MCalibrationIntensityCam&)object;
+  
+  MParContainer::Copy(calib);
+  
+  calib.fOffsets = fOffsets;
+  calib.fSlopes  = fSlopes;
+  
+  const UInt_t n = GetSize();
+  if (n != 0)
+    {
+      calib.InitSize(n);
+      for (UInt_t i=0; i<n; i++)
+        GetCam(i)->Copy(*(calib.GetCam(i)));
+    }
+  
+}
+
+// -----------------------------------------------------
+//
+// Calls Clear() for all entries fCams
+//
+void MCalibrationIntensityCam::Clear(Option_t *o)
+{
+
+  fCams->ForEach(MCalibrationCam, Clear)(); 
+
+  return;
+}
+
+// -----------------------------------------------------
+//
+// Calls Print(o) for all entries fCams
+//
+void MCalibrationIntensityCam::Print(Option_t *o) const
+{
+  fCams->ForEach(MCalibrationCam, Print)(o); 
+}
+
+// -----------------------------------------------------
+//
+// Not yet installed...
+//
+void MCalibrationIntensityCam::DrawHiLoFits()
+{
+
+  /*
+  if (!fOffsets)
+    fOffsets = new TH1D("pp","Offsets of the HiGain LoGain Fit",100,-600.,400.);
+  if (!fSlopes)
+    fSlopes  = new TH1D("mm","Slopes of the HiGain LoGain Fit",100,-2.,2.);
+  if (!fOffvsSlope)
+    fOffvsSlope = new TH2D("aa","Slopes vs Offsets of the HiGain LoGain Fit",100,-600.,400.,100,-2.,2.);
+  
+  TIter Next(fPixels);
+  MCalibrationPix *pix;
+  MHCalibrationPixel *hist;
+  while ((pix=(MCalibrationPix*)Next()))
+    {
+      hist = pix->GetHist();
+      hist->FitHiGainvsLoGain();
+      fOffsets->Fill(hist->GetOffset(),1.);
+      fSlopes->Fill(hist->GetSlope(),1.);
+      fOffvsSlope->Fill(hist->GetOffset(),hist->GetSlope(),1.);
+    }
+
+   TCanvas *c1 = new TCanvas();
+
+   c1->Divide(1,3);
+   c1->cd(1);
+   fOffsets->Draw();
+   gPad->Modified();
+   gPad->Update();
+
+   c1->cd(2);
+  fSlopes->Draw();
+  gPad->Modified();
+  gPad->Update();
+
+  c1->cd(3);
+  fOffvsSlope->Draw("col1");
+  gPad->Modified();
+  gPad->Update();
+  */
+}
+
+// -------------------------------------------------------------------
+//
+// Calls TClonesArray::ExpandCreate() for fCams
+//
+void MCalibrationIntensityCam::InitSize(const UInt_t n)
+{
+  fCams->ExpandCreate(n);
+}
+
+// -------------------------------------------------------------------
+//
+// Calls Init(geom) for fCams
+//
+void MCalibrationIntensityCam::Init(const MGeomCam &geom)
+{
+  InitSize(1);
+  fCams->ForEach(MCalibrationCam,Init)(geom);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Returns the current size of the TClonesArray fCams 
+// independently if the MCalibrationCam is filled with values or not.
+//
+const Int_t MCalibrationIntensityCam::GetSize() const 
+{
+  return fCams->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel from current camera
+//
+MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i)
+{
+  return (*GetCam(GetSize()-1))[i];
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel from current camera
+//
+const MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i) const 
+{
+  return (*GetCam(GetSize()-1))[i];
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Returns the current size of the TObjArray fAverageAreas of the current camera.
+//
+const Int_t MCalibrationIntensityCam::GetAverageAreas() const
+{
+  return GetCam(GetSize()-1)->GetAverageAreas();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain pixel Area from the current camera
+//
+MCalibrationPix  &MCalibrationIntensityCam::GetAverageArea(UInt_t i)
+{
+  return GetCam(GetSize()-1)->GetAverageArea(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain pixel Area from the current camera
+//
+const MCalibrationPix  &MCalibrationIntensityCam::GetAverageArea(UInt_t i) const
+{
+  return GetCam(GetSize()-1)->GetAverageArea(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain pixel Area from the current camera
+//
+MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i)
+{
+  return GetCam(GetSize()-1)->GetAverageBadArea(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain pixel Area from the current camera
+//
+const MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i) const
+{
+  return GetCam(GetSize()-1)->GetAverageBadArea(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the current size of the TObjArray fAverageSectors or the current camera
+//
+const Int_t MCalibrationIntensityCam::GetAverageSectors() const
+{
+  return GetCam(GetSize()-1)->GetAverageSectors();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain Sector from the current camera
+//
+MCalibrationPix  &MCalibrationIntensityCam::GetAverageSector(UInt_t i)
+{
+  return GetCam(GetSize()-1)->GetAverageSector(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain Sector from the current camera
+//
+const MCalibrationPix  &MCalibrationIntensityCam::GetAverageSector(UInt_t i) const
+{
+  return GetCam(GetSize()-1)->GetAverageSector(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain Sector from the current camera
+//
+MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i)
+{
+  return GetCam(GetSize()-1)->GetAverageBadSector(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain Sector from the current camera
+//
+const MBadPixelsPix  &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i) const
+{
+  return GetCam(GetSize()-1)->GetAverageBadSector(i);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Get i-th camera 
+//
+MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i)
+{
+  return static_cast<MCalibrationCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th camera 
+//
+const MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i) const 
+{
+  return static_cast<MCalibrationCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get camera with name 'name' 
+//
+MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name )
+{
+  return static_cast<MCalibrationCam*>(fCams->FindObject(name));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get camera with name 'name' 
+//
+const MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name ) const 
+{
+  return static_cast<MCalibrationCam*>(fCams->FindObject(name));
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls GetPixelContent for the current entry in fCams
+//
+Bool_t MCalibrationIntensityCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+  return GetCam()->GetPixelContent(val,idx,cam,type);
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls DrawPixelContent for the current entry in fCams
+//
+void MCalibrationIntensityCam::DrawPixelContent( Int_t num ) const
+{
+  return GetCam()->DrawPixelContent(num);
+}
+
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.h	(revision 4899)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.h	(revision 4899)
@@ -0,0 +1,97 @@
+#ifndef MARS_MCalibrationIntensityCam
+#define MARS_MCalibrationIntensityCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+#ifndef MARS_MArrayD
+#include "MArrayD.h"
+#endif
+
+#ifndef MARS_MCalibrationCam
+#include "MCalibrationCam.h"
+#endif
+
+class TClonesArray;
+class MCalibrationPix;
+class MBadPixelsPix;
+class MGeomCam;
+class MCalibrationIntensityCam : public MParContainer, public MCamEvent
+{
+private:
+  
+  MArrayD fOffsets;           //! Arrays of Higain-vs-LoGain fit result Offsets
+  MArrayD fSlopes;            //! Arrays of Higain-vs-LoGain fit result Slopes
+
+  void InitSize( const UInt_t n );
+  
+protected:  
+
+  TClonesArray *fCams;        //-> Array of MCalibrationCams, one per pulse colour and intensity
+
+public:
+
+  MCalibrationIntensityCam(const char *name=NULL, const char *title=NULL);
+  ~MCalibrationIntensityCam();
+  
+  void  Clear ( Option_t *o="" );
+  void  Copy(TObject& object) const;  
+  
+  void AddToList( const char* name, const MGeomCam &geom );
+
+  // Draws
+  void DrawHiLoFits();
+  void DrawPixelContent( Int_t num) const;
+  
+  // Getters
+  Bool_t GetPixelContent( Double_t &val, Int_t idx, const MGeomCam &cam,Int_t type=0) const;
+  const Int_t GetSize() const;
+
+  const Int_t            GetAverageAreas     ()            const;	 
+        MCalibrationPix &GetAverageArea      ( UInt_t i );
+  const MCalibrationPix &GetAverageArea      ( UInt_t i )  const;
+        MBadPixelsPix   &GetAverageBadArea   ( UInt_t i );
+  const MBadPixelsPix   &GetAverageBadArea   ( UInt_t i )  const;
+  const Int_t            GetAverageSectors   ()            const;
+        MCalibrationPix &GetAverageSector    ( UInt_t i );
+  const MCalibrationPix &GetAverageSector    ( UInt_t i )  const;
+        MBadPixelsPix   &GetAverageBadSector ( UInt_t i );
+  const MBadPixelsPix   &GetAverageBadSector ( UInt_t i )  const;
+
+        MCalibrationCam *GetCam              ( Int_t i=-1);
+  const MCalibrationCam *GetCam              ( Int_t i=-1) const;
+
+        MCalibrationCam *GetCam              ( const char *name );
+  const MCalibrationCam *GetCam              ( const char *name ) const;
+
+        MCalibrationPix &operator[]          ( UInt_t i );
+  const MCalibrationPix &operator[]          ( UInt_t i )  const;
+ 
+  const Float_t GetNumHiGainFADCSlices ( const Int_t aidx=0 ) const { return GetCam()->GetNumHiGainFADCSlices(aidx); }
+  const Float_t GetNumLoGainFADCSlices ( const Int_t aidx=0 ) const { return GetCam()->GetNumLoGainFADCSlices(aidx); }
+  const Int_t   GetNumUnsuitable       ( const Int_t aidx=-1) const { return GetCam()->GetNumUnsuitable(aidx);       }
+  const Int_t   GetNumUnreliable       ( const Int_t aidx=-1) const { return GetCam()->GetNumUnreliable(aidx);       }
+  
+  // Inits
+  void  Init   ( const MGeomCam &geom );
+  
+  // Prints
+  void   Print(Option_t *o="")         const;
+
+  // Setters
+  void  SetNumHiGainFADCSlices( const Float_t f, const Int_t aidx=0) { GetCam()->SetNumHiGainFADCSlices(f,aidx); }
+  void  SetNumLoGainFADCSlices( const Float_t f, const Int_t aidx=0) { GetCam()->SetNumLoGainFADCSlices(f,aidx); }
+  void  SetNumUnsuitable      ( const UInt_t i,  const Int_t aidx  ) { GetCam()->SetNumUnsuitable(i,aidx);       }
+  void  SetNumUnreliable      ( const UInt_t i,  const Int_t aidx  ) { GetCam()->SetNumUnreliable(i,aidx);       }
+  void  SetPulserColor        ( const MCalibrationCam::PulserColor_t col=MCalibrationCam::kCT1) {
+                                                                GetCam()->SetPulserColor(col);            }
+
+  ClassDef(MCalibrationIntensityCam, 1) // Base Container Intensity Calibration Results
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.cc	(revision 4899)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.cc	(revision 4899)
@@ -0,0 +1,69 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationIntensityChargeCam                                               
+//                                                               
+// Storage container for intensity charge calibration results. 
+// 
+// Individual MCalibrationChargeCam'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, MCalibrationChargeCam,
+//           MCalibrationChargePix, MCalibrationChargeCalc, MCalibrationQECam
+//           MHCalibrationChargePix, MHCalibrationChargeCam              
+//           MCalibrationChargeBlindPix, MCalibrationChargePINDiode
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationIntensityChargeCam.h"
+
+#include <TClonesArray.h>
+
+ClassImp(MCalibrationIntensityChargeCam);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Sets all pointers to 0
+// 
+// Creates a TClonesArray of MCalibrationChargeCam containers, initialized to 1 entry, destinated 
+// to hold one container per camera. 
+//
+// Calls:
+// - Clear()
+//
+MCalibrationIntensityChargeCam::MCalibrationIntensityChargeCam(const char *name, const char *title)
+{
+
+  fName  = name  ? name  : "MCalibrationIntensityChargeCam";
+  fTitle = title ? title : "Results of the Intensity Calibration";
+  
+  fCams = new TClonesArray("MCalibrationChargeCam",1);
+  
+}
+
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.h	(revision 4899)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.h	(revision 4899)
@@ -0,0 +1,37 @@
+#ifndef MARS_MCalibrationIntensityChargeCam
+#define MARS_MCalibrationIntensityChargeCam
+
+#ifndef MARS_MCalibrationIntensityCam
+#include "MCalibrationIntensityCam.h"
+#endif
+
+#ifndef MARS_MCalibrationChargeCam
+#include "MCalibrationChargeCam.h"
+#endif
+
+class MCalibrationIntensityChargeCam : public MCalibrationIntensityCam
+{
+public:
+
+  MCalibrationIntensityChargeCam(const char *name=NULL, const char *title=NULL);
+
+  // Setters   
+  void  SetFFactorMethodValid           ( const Bool_t  b=kTRUE ) {
+    ((MCalibrationChargeCam*)GetCam())->SetFFactorMethodValid(b); }
+  void  SetNumPhotonsBlindPixelMethod   ( const Float_t f )  {
+    ((MCalibrationChargeCam*)GetCam())->SetNumPhotonsBlindPixelMethod(f); } 
+  void  SetNumPhotonsFFactorMethod      ( const Float_t f )  {
+    ((MCalibrationChargeCam*)GetCam())->SetNumPhotonsFFactorMethod   (f); }      
+  void  SetNumPhotonsPINDiodeMethod     ( const Float_t f )  {
+    ((MCalibrationChargeCam*)GetCam())->SetNumPhotonsPINDiodeMethod  (f); }   
+  void  SetNumPhotonsBlindPixelMethodErr( const Float_t f )  {
+    ((MCalibrationChargeCam*)GetCam())->SetNumPhotonsBlindPixelMethodErr(f); } 
+  void  SetNumPhotonsFFactorMethodErr   ( const Float_t f )  {
+    ((MCalibrationChargeCam*)GetCam())->SetNumPhotonsFFactorMethodErr(f); }      
+  void  SetNumPhotonsPINDiodeMethodErr  ( const Float_t f )  {
+    ((MCalibrationChargeCam*)GetCam())->SetNumPhotonsPINDiodeMethodErr(f); }   
+  
+  ClassDef(MCalibrationIntensityChargeCam, 1) // Container Intensity Charge Calibration Results Camera
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityQECam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityQECam.cc	(revision 4899)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityQECam.cc	(revision 4899)
@@ -0,0 +1,68 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationIntensityQECam                                               
+//                                                               
+// Storage container for intensity charge calibration results. 
+// 
+// Individual MCalibrationQECam'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, MCalibrationQECam,
+//           MCalibrationQEPix, MCalibrationChargeCalc
+//           MHCalibrationChargePix, MHCalibrationChargeCam              
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationIntensityQECam.h"
+
+#include <TClonesArray.h>
+
+ClassImp(MCalibrationIntensityQECam);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Sets all pointers to 0
+// 
+// Creates a TClonesArray of MCalibrationQECam containers, initialized to 1 entry, destinated 
+// to hold one container per camera. 
+//
+// Calls:
+// - Clear()
+//
+MCalibrationIntensityQECam::MCalibrationIntensityQECam(const char *name, const char *title)
+{
+
+  fName  = name  ? name  : "MCalibrationIntensityQECam";
+  fTitle = title ? title : "Results of the Intensity Calibration";
+  
+  fCams = new TClonesArray("MCalibrationQECam",1);
+
+}
+
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityQECam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityQECam.h	(revision 4899)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityQECam.h	(revision 4899)
@@ -0,0 +1,20 @@
+#ifndef MARS_MCalibrationIntensityQECam
+#define MARS_MCalibrationIntensityQECam
+
+#ifndef MARS_MCalibrationIntensityCam
+#include "MCalibrationIntensityCam.h"
+#endif
+
+class MCalibrationIntensityQECam : public MCalibrationIntensityCam
+{
+private:
+  
+
+public:
+
+  MCalibrationIntensityQECam(const char *name=NULL, const char *title=NULL);
+  
+  ClassDef(MCalibrationIntensityQECam, 1) // Container Intensity Rel.Times Calibration Results Camera
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityRelTimeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityRelTimeCam.cc	(revision 4899)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityRelTimeCam.cc	(revision 4899)
@@ -0,0 +1,68 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationIntensityRelTimeCam                                               
+//                                                               
+// Storage container for intensity charge calibration results. 
+// 
+// Individual MCalibrationRelTimeCam'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, MCalibrationRelTimeCam,
+//           MCalibrationRelTimePix, MCalibrationRelTimeCalc, MCalibrationQECam
+//           MHCalibrationRelTimePix, MHCalibrationRelTimeCam              
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationIntensityRelTimeCam.h"
+
+#include <TClonesArray.h>
+
+ClassImp(MCalibrationIntensityRelTimeCam);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Sets all pointers to 0
+// 
+// Creates a TClonesArray of MCalibrationRelTimeCam containers, initialized to 1 entry, destinated 
+// to hold one container per camera. 
+//
+// Calls:
+// - Clear()
+//
+MCalibrationIntensityRelTimeCam::MCalibrationIntensityRelTimeCam(const char *name, const char *title)
+{
+
+  fName  = name  ? name  : "MCalibrationIntensityRelTimeCam";
+  fTitle = title ? title : "Results of the Intensity Calibration";
+  
+  fCams = new TClonesArray("MCalibrationRelTimeCam",1);
+
+}
+
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityRelTimeCam.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityRelTimeCam.h	(revision 4899)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityRelTimeCam.h	(revision 4899)
@@ -0,0 +1,20 @@
+#ifndef MARS_MCalibrationIntensityRelTimeCam
+#define MARS_MCalibrationIntensityRelTimeCam
+
+#ifndef MARS_MCalibrationIntensityCam
+#include "MCalibrationIntensityCam.h"
+#endif
+
+class MCalibrationIntensityRelTimeCam : public MCalibrationIntensityCam
+{
+private:
+  
+
+public:
+
+  MCalibrationIntensityRelTimeCam(const char *name=NULL, const char *title=NULL);
+  
+  ClassDef(MCalibrationIntensityRelTimeCam, 1) // Container Intensity Rel.Times Calibration Results Camera
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationPix.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationPix.cc	(revision 4899)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationPix.cc	(revision 4899)
@@ -0,0 +1,327 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHCalibrationPix
+//
+//  A base class for events which are believed to follow a Gaussian distribution 
+//  with time, e.g. calibration events, observables containing white noise, ...
+//
+//  MHCalibrationPix derives from MHGausEvents, thus all features of 
+//  MHGausEvents can be used by a class deriving from MHCalibrationPix
+//
+//  See also: MHGausEvents
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationPix.h"
+
+#include <TH1.h>
+#include <TF1.h>
+#include <TGraph.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHCalibrationPix);
+
+using namespace std;
+
+const Float_t  MHCalibrationPix::fgBlackoutLimit        = 5.;
+const Float_t  MHCalibrationPix::fgPickupLimit          = 5.;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+// Sets: 
+// - the default number for fPickupLimit           (fgPickupLimit)
+// - the default number for fBlackoutLimit         (fgBlackoutLimit)
+//
+// Initializes:
+// - all variables to 0.
+//
+MHCalibrationPix::MHCalibrationPix(const char *name, const char *title)
+    : fEventFrequency(0), fPixId(-1)
+{ 
+
+  fName  = name  ? name  : "MHCalibrationPix";
+  fTitle = title ? title : "Calibration histogram events";
+
+  Clear();
+  
+  SetBlackoutLimit();
+  SetPickupLimit();
+}
+
+
+      
+// --------------------------------------------------------------------------
+//
+// Default Clear(), can be overloaded.
+//
+// Sets:
+// - all other pointers to NULL
+// - all variables to 0., except fPixId to -1 and keep fEventFrequency
+// - all flags to kFALSE
+// 
+// Deletes (if not NULL):
+// - all pointers
+//
+void MHCalibrationPix::Clear(Option_t *o)
+{
+
+  MHGausEvents::Clear();
+  fSaturated         = 0;
+}
+
+
+// -----------------------------------------------------------------------------
+// 
+// Bypasses the Gauss fit by taking mean and RMS from the histogram
+//
+// Errors are determined in the following way:
+// MeanErr  = RMS / Sqrt(entries)
+// SigmaErr = RMS / (2.*Sqrt(entries) )
+//
+void MHCalibrationPix::BypassFit()
+{
+
+  const Stat_t entries = fHGausHist.GetEntries();
+  
+  if (entries <= 0.)
+    {
+      *fLog << warn << GetDescriptor() 
+            << ": Cannot bypass fit. Number of entries smaller or equal 0 in pixel: " << fPixId << endl;
+      return;
+    }
+  
+  fMean     = fHGausHist.GetMean();
+  fMeanErr  = fHGausHist.GetRMS() / TMath::Sqrt(entries);
+  fSigma    = fHGausHist.GetRMS() ;
+  fSigmaErr = fHGausHist.GetRMS() / TMath::Sqrt(entries) / 2.;
+}
+
+// --------------------------------------------------------------------------
+//
+// - Set fPixId to id
+//
+// Add id to names and titles of:
+// - fHGausHist
+//
+void MHCalibrationPix::ChangeHistId(const Int_t id)
+{
+
+  fPixId = id;
+
+  fHGausHist.SetName(  Form("%s%d", fHGausHist.GetName(),  id));
+  fHGausHist.SetTitle( Form("%s%d", fHGausHist.GetTitle(), id));
+
+  fName  = Form("%s%d", fName.Data(),  id);
+  fTitle = Form("%s%d", fTitle.Data(), id);
+
+}
+
+
+// -----------------------------------------------------------------------------
+// 
+// Create the x-axis for the event graph
+//
+Float_t *MHCalibrationPix::CreateEventXaxis(Int_t n)
+{
+
+  Float_t *xaxis = new Float_t[n];  
+
+  if (fEventFrequency)
+    for (Int_t i=0;i<n;i++)
+      xaxis[i] = (Float_t)i/fEventFrequency;
+  else
+    for (Int_t i=0;i<n;i++)
+      xaxis[i] = (Float_t)i;
+
+  return xaxis;
+                 
+}
+
+// -----------------------------------------------------------------------------
+// 
+// Create the x-axis for the event graph
+//
+Float_t *MHCalibrationPix::CreatePSDXaxis(Int_t n)
+{
+
+  Float_t *xaxis = new Float_t[n];
+
+  if (fEventFrequency)
+    for (Int_t i=0;i<n;i++)
+      xaxis[i] = 0.5*(Float_t)i*fEventFrequency/n;
+  else
+    for (Int_t i=0;i<n;i++)
+      xaxis[i] = 0.5*(Float_t)i/n;
+
+  return xaxis;
+                 
+}
+
+// ----------------------------------------------------------------------------------
+//
+// Create a graph to display the array fEvents
+// If the variable fEventFrequency is set, the x-axis is transformed into real time.
+//
+void MHCalibrationPix::CreateGraphEvents()
+{
+
+  MHGausEvents::CreateGraphEvents();
+  fGraphEvents->GetXaxis()->SetTitle((fEventFrequency) ? "Time [s]" : "Event Nr.");
+}
+
+// ----------------------------------------------------------------------------------
+//
+// Create a graph to display the array fPowerSpectrum
+// If the variable fEventFrequency is set, the x-axis is transformed into real frequency.
+//
+void MHCalibrationPix::CreateGraphPowerSpectrum()
+{
+
+  MHGausEvents::CreateGraphPowerSpectrum();
+  
+  fGraphPowerSpectrum->GetXaxis()->SetTitle((fEventFrequency) ? "Frequency [Hz]" : "Frequency");
+}
+
+// -------------------------------------------------------------------------------
+//
+// Return the number of "blackout" events, which are events with values higher 
+// than fBlackoutLimit sigmas from the mean
+//
+//
+const Double_t MHCalibrationPix::GetBlackout() const 
+{
+  
+  if ((fMean == 0.) && (fSigma == 0.))
+    return -1.;
+
+  const Int_t first = fHGausHist.GetXaxis()->GetFirst();
+  const Int_t last  = fHGausHist.GetXaxis()->FindBin(fMean-fBlackoutLimit*fSigma);
+
+  if (first >= last)
+    return 0.;
+  
+  return fHGausHist.Integral(first, last, "width");
+}
+
+
+// -------------------------------------------------------------------------------
+//
+// Return the number of "pickup" events, which are events with values higher 
+// than fPickupLimit sigmas from the mean
+//
+//
+const Double_t MHCalibrationPix::GetPickup() const 
+{
+  
+  if ((fMean == 0.) && (fSigma == 0.))
+    return -1.;
+
+  const Int_t first = fHGausHist.GetXaxis()->FindBin(fMean+fPickupLimit*fSigma);
+  const Int_t last  = fHGausHist.GetXaxis()->GetLast();
+
+  if (first >= last)
+    return 0.;
+  
+  return fHGausHist.Integral(first, last, "width");
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Re-normalize the results, has to be overloaded
+//
+void  MHCalibrationPix::Renorm()
+{
+}
+
+// -----------------------------------------------------------------------------
+//
+// If flag IsGausFitOK() is set (histogram already successfully fitted), 
+// returns kTRUE
+// 
+// If both fMean and fSigma are still zero, call FitGaus() 
+// 
+// Repeats the Gauss fit in a smaller range, defined by: 
+// 
+// min = GetMean() - fBlackoutLimit * GetSigma();
+// max = GetMean() + fPickupLimit   * GetSigma();
+//
+// The fit results are retrieved and stored in class-own variables.  
+//
+// A flag IsGausFitOK() is set according to whether the fit probability 
+// is smaller or bigger than fProbLimit, whether the NDF is bigger than 
+// fNDFLimit and whether results are NaNs.
+//
+Bool_t MHCalibrationPix::RepeatFit(const Option_t *option)
+{
+
+  if (IsGausFitOK())
+    return kTRUE;
+
+  if ((fMean == 0.) && (fSigma == 0.))
+    return FitGaus();
+
+  //
+  // Get new fitting ranges
+  //
+  Axis_t rmin = fMean - fBlackoutLimit * fSigma;
+  Axis_t rmax = fMean + fPickupLimit   * fSigma;
+
+  Axis_t hmin = fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetFirst());
+  Axis_t hmax = fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetLast()) ;
+
+  fFGausFit->SetRange(hmin < rmin ? rmin : hmin , hmax > rmax ? rmax : hmax);
+
+  fHGausHist.Fit(fFGausFit,option);
+
+  fMean     = fFGausFit->GetParameter(1);
+  fSigma    = fFGausFit->GetParameter(2);
+  fMeanErr  = fFGausFit->GetParError(1) ; 
+  fSigmaErr = fFGausFit->GetParError(2) ; 
+  fProb     = fFGausFit->GetProb()      ;      
+
+  //
+  // The fit result is accepted under condition:
+  // 1) The results are not nan's
+  // 2) The NDF is not smaller than fNDFLimit (default: fgNDFLimit)
+  // 3) The Probability is greater than fProbLimit (default: fgProbLimit)
+  //
+  if (   TMath::IsNaN ( fMean     ) 
+      || TMath::IsNaN ( fMeanErr  )
+      || TMath::IsNaN ( fProb     )    
+      || TMath::IsNaN ( fSigma    )
+      || TMath::IsNaN ( fSigmaErr ) 
+      || fFGausFit->GetNDF() < fNDFLimit 
+      || fProb < fProbLimit )
+    return kFALSE;
+  
+  SetGausFitOK(kTRUE);
+  return kTRUE;
+
+}
+
Index: trunk/MagicSoft/Mars/mcalib/MHCalibrationPix.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MHCalibrationPix.h	(revision 4899)
+++ trunk/MagicSoft/Mars/mcalib/MHCalibrationPix.h	(revision 4899)
@@ -0,0 +1,60 @@
+#ifndef MARS_MHCalibrationPix
+#define MARS_MHCalibrationPix
+
+#ifndef MARS_MHGausEvents
+#include "MHGausEvents.h"
+#endif
+
+class MHCalibrationPix : public MHGausEvents
+{
+private:
+
+  const static Float_t  fgBlackoutLimit; //! Default for fBlackoutLimit (now set to: 5. )
+  const static Float_t  fgPickupLimit;   //! Default for fPickupLimit   (now set to: 5. )
+  
+  Float_t  fEventFrequency;              // Event frequency in Hertz (to be set)
+
+  Float_t *CreateEventXaxis(Int_t n);    // Create an x-axis for the Event TGraphs
+  Float_t *CreatePSDXaxis(Int_t n);      // Create an x-axis for the PSD TGraphs
+  void     CreateGraphEvents();          // Create the TGraph fGraphEvents of fEvents                    
+  void     CreateGraphPowerSpectrum();   // Create the TGraph fGraphPowerSpectrum out of fPowerSpectrum
+  
+protected:
+
+  Float_t  fBlackoutLimit;               // Lower nr sigmas from mean until event is considered blackout
+  Int_t    fSaturated;                   // Number of events classified as saturated
+  Float_t  fPickupLimit;                 // Upper nr sigmas from mean until event is considered pickup
+  Int_t    fPixId;                       // Pixel ID 
+
+public:
+
+  MHCalibrationPix(const char* name=NULL, const char* title=NULL);
+  ~MHCalibrationPix() {}
+
+  void  Clear(Option_t *o="");
+  
+  // Getters
+  const Double_t GetBlackout()           const;  
+  const Double_t GetPickup()             const;
+  const Int_t    GetPixId()              const { return fPixId;              }
+  const Float_t  GetSaturated()          const { return fSaturated;          }
+
+  // Fits
+  Bool_t RepeatFit(const Option_t *option="RQ0"); // Repeat fit within limits defined by fPickupLimit
+  void   BypassFit();                             // Take mean and RMS from the histogram
+  
+  // Setters
+  void  SetBlackoutLimit    ( const Float_t  lim=fgBlackoutLimit ) { fBlackoutLimit  = lim; }
+  void  SetEventFrequency   ( const Float_t  f                   ) { fEventFrequency = f;   }
+  void  SetPickupLimit      ( const Float_t  lim=fgPickupLimit   ) { fPickupLimit    = lim; }
+  void  SetPixId            ( const Int_t    i                   ) { fPixId          = i;   }
+  void  SetSaturated        ( const Int_t    i                   ) { fSaturated     += i;   }
+
+  // Miscelleaneous
+  virtual void ChangeHistId(const Int_t id);      // Changes names and titles of the histogram
+  virtual void Renorm();                          // Re-normalize the results 
+  
+  ClassDef(MHCalibrationPix, 1) // Base class for calibration events 
+};
+
+#endif
Index: trunk/MagicSoft/Mars/msignal/MArrivalTimePix.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MArrivalTimePix.h	(revision 4898)
+++ trunk/MagicSoft/Mars/msignal/MArrivalTimePix.h	(revision 4899)
@@ -38,6 +38,6 @@
     Byte_t GetNumLoGainSaturated()      const { return fNumLoGainSaturated; }
 
-    Bool_t IsLoGainUsed() const { return fNumHiGainSaturated > 0; }
-    Bool_t IsValid() const;   
+    Bool_t IsLoGainUsed()               const { return fNumHiGainSaturated > 0; }
+    Bool_t IsValid()                    const;   
 
     ClassDef(MArrivalTimePix, 1)	// Storage Container for ArrivalTime information of one pixel
Index: trunk/MagicSoft/Mars/msignal/MExtractAmplitudeSpline.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractAmplitudeSpline.cc	(revision 4898)
+++ trunk/MagicSoft/Mars/msignal/MExtractAmplitudeSpline.cc	(revision 4899)
@@ -121,5 +121,5 @@
 
   fNumHiGainSamples = 2.;
-  fNumLoGainSamples = 2.;
+  fNumLoGainSamples = lolast == 0 ? 0. : 2.;
 
   fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
@@ -166,5 +166,5 @@
   Int_t range = fHiGainLast - fHiGainFirst + 1 + fHiLoLast;
 
-  fHiGainSignal = new Float_t[range];
+  fHiGainSignal      = new Float_t[range];
   memset(fHiGainSignal,0,range*sizeof(Float_t));
   fHiGainFirstDeriv  = new Float_t[range];
@@ -181,5 +181,5 @@
         << endl;
 
-  range = fLoGainLast - fLoGainFirst + 1;
+  range = fLoGainLast ? fLoGainLast - fLoGainFirst + 1 : 0;
 
   fLoGainSignal = new Float_t[range];
@@ -189,5 +189,5 @@
   fLoGainSecondDeriv = new Float_t[range];
   memset(fLoGainSecondDeriv,0,range*sizeof(Float_t));
-
+  
   *fLog << endl;
   *fLog << inf << GetDescriptor() << ": Using for Low-Gain Extraction " << range
Index: trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.cc	(revision 4898)
+++ trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.cc	(revision 4899)
@@ -181,5 +181,8 @@
 
   fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst+1);
-  fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst+1);  
+  if (lolast)
+    fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst+1);
+  else
+    fNumLoGainSamples = 0.;
 
   fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
Index: trunk/MagicSoft/Mars/msignal/MExtractFixedWindowSpline.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractFixedWindowSpline.cc	(revision 4898)
+++ trunk/MagicSoft/Mars/msignal/MExtractFixedWindowSpline.cc	(revision 4899)
@@ -111,8 +111,5 @@
 
   const Byte_t windowhi = hilast-hifirst+1;
-  const Byte_t windowlo = lolast-lofirst+1;
-  
   const Byte_t whieven = windowhi & ~1;
-  const Byte_t wloeven = windowlo & ~1;
 
   if (whieven != windowhi)
@@ -124,12 +121,4 @@
     }
   
-  if (wloeven != windowlo)
-    {
-      *fLog << warn << GetDescriptor() 
-            << Form("%s%2i%s%2i",": Lo Gain window size has to be even, set last slice from "
-                    ,(int)lolast," to ",(int)(lolast-1)) << endl;
-      lolast -= 1;
-    }
-  
   if (whieven<2) 
     {
@@ -139,13 +128,28 @@
       hilast = hifirst+1;
     }
-  
-  if (wloeven<2) 
-    {
-      *fLog << warn << GetDescriptor() 
-            << Form("%s%2i%s%2i",": Lo Gain window is smaller than 2 FADC sampes, set last slice from" 
-                    ,(int)lolast," to ",(int)(lofirst+1)) << endl;
-      lolast = lofirst+1;        
-    }
-
+
+  const Byte_t windowlo = lolast-lofirst+1;
+  const Byte_t wloeven = windowlo & ~1;
+
+  if (lolast != 0)
+    {
+      if (wloeven != windowlo)
+        {
+          *fLog << warn << GetDescriptor() 
+                << Form("%s%2i%s%2i",": Lo Gain window size has to be even, set last slice from "
+                        ,(int)lolast," to ",(int)(lolast-1)) << endl;
+          lolast -= 1;
+        }
+      
+      
+      if (wloeven<2) 
+        {
+          *fLog << warn << GetDescriptor() 
+                << Form("%s%2i%s%2i",": Lo Gain window is smaller than 2 FADC sampes, set last slice from" 
+                        ,(int)lolast," to ",(int)(lofirst+1)) << endl;
+          lolast = lofirst+1;        
+        }
+    }
+  
 
   MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
@@ -157,5 +161,8 @@
   //
   fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst);
-  fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst);  
+  if (fLoGainLast != 0)
+    fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst);  
+  else
+    fNumLoGainSamples = 0.;
 
   fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
Index: trunk/MagicSoft/Mars/msignal/MExtractSlidingWindow.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractSlidingWindow.cc	(revision 4898)
+++ trunk/MagicSoft/Mars/msignal/MExtractSlidingWindow.cc	(revision 4899)
@@ -129,4 +129,13 @@
                               fLoGainFirst, fLoGainLast, fNumLoGainSamples);
 
+
+  *fLog << endl;
+  *fLog << inf << GetDescriptor() << ": Taking " << fNumHiGainSamples
+        << " HiGain samples from a window starting with slice " << (Int_t)fHiGainFirst
+        << " to " << (Int_t)(fHiGainLast+fHiLoLast) << " incl" << endl;
+  *fLog << inf << GetDescriptor() << ": Taking " << fNumLoGainSamples
+        << " LoGain samples from a window starting with slice " << (Int_t)fLoGainFirst
+        << " to " << (Int_t)fLoGainLast << " incl" << endl;
+
   return kTRUE;
   
@@ -161,5 +170,4 @@
     
   const Byte_t availhirange = (fHiGainLast-fHiGainFirst+1) & ~1;
-  const Byte_t availlorange = (fLoGainLast-fLoGainFirst+1) & ~1;
 
   if (fWindowSizeHiGain > availhirange)
@@ -173,14 +181,4 @@
     }
   
-  if (fWindowSizeLoGain > availlorange)
-    {
-      *fLog << warn << GetDescriptor() 
-            << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",(int)fWindowSizeLoGain,
-                    " is bigger than available range: [",(int)fLoGainFirst,",",(int)fLoGainLast,"]") << endl;
-      *fLog << warn << GetDescriptor() 
-            << ": Will set window size to: " << (int)availlorange << endl;
-      fWindowSizeLoGain = availlorange;
-    }
-  
   if (fWindowSizeHiGain<2) 
     {
@@ -189,10 +187,25 @@
     }
   
-  if (fWindowSizeLoGain<2) 
-    {
-      fWindowSizeLoGain = 2;
-      *fLog << warn << GetDescriptor() << ": Lo Gain window size set to two samples" << endl;
-    }
-    
+  if (fLoGainLast != 0 && fWindowSizeLoGain != 0)
+    {
+      const Byte_t availlorange = (fLoGainLast-fLoGainFirst+1) & ~1;
+      
+      if (fWindowSizeLoGain > availlorange)
+        {
+          *fLog << warn << GetDescriptor() 
+                << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",(int)fWindowSizeLoGain,
+                        " is bigger than available range: [",(int)fLoGainFirst,",",(int)fLoGainLast,"]") << endl;
+          *fLog << warn << GetDescriptor() 
+                << ": Will set window size to: " << (int)availlorange << endl;
+          fWindowSizeLoGain = availlorange;
+        }
+      
+      if (fWindowSizeLoGain<2) 
+        {
+          fWindowSizeLoGain = 2;
+          *fLog << warn << GetDescriptor() << ": Lo Gain window size set to two samples" << endl;
+        }
+    }
+  
   fNumHiGainSamples = (Float_t)fWindowSizeHiGain;
   fNumLoGainSamples = (Float_t)fWindowSizeLoGain;
