Index: trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc	(revision 2206)
@@ -107,5 +107,5 @@
 //    from the monte carlo run header.
 //
-Bool_t MBlindPixelCalc::PreProcess (MParList *pList)
+Int_t MBlindPixelCalc::PreProcess (MParList *pList)
 {
     if (TESTBIT(fFlags, kUseBlindPixels))
@@ -252,5 +252,5 @@
 // Treat the blind pixels
 //
-Bool_t MBlindPixelCalc::Process()
+Int_t MBlindPixelCalc::Process()
 {
     if (TESTBIT(fFlags, kUseInterpolation) && fGeomCam)
Index: trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.h	(revision 2206)
@@ -36,4 +36,7 @@
     void StreamPrimitive(ofstream &out) const;
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
 public:
     MBlindPixelCalc(const char *name=NULL, const char *title=NULL);
@@ -52,7 +55,4 @@
     }
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-
     void SetPixels(Int_t num, Short_t *ids);
     void SetPixels(const TArrayS pix) { SetPixels((Int_t)pix.GetSize(), (Short_t*)pix.GetArray()); }
Index: trunk/MagicSoft/Mars/manalysis/MCT1PadONOFF.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1PadONOFF.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MCT1PadONOFF.cc	(revision 2206)
@@ -891,5 +891,5 @@
 //  Set the pointers and prepare the histograms
 //
-Bool_t MCT1PadONOFF::PreProcess(MParList *pList)
+Int_t MCT1PadONOFF::PreProcess(MParList *pList)
 {
   if ( !fHSigmaTheta       ||  !fHSigmaThetaON    ||  !fHSigmaThetaOFF    ||  
@@ -987,5 +987,5 @@
 // idealy the events to be padded should have been generated without NSB
 // 
-Bool_t MCT1PadONOFF::Process()
+Int_t MCT1PadONOFF::Process()
 {
   //*fLog << "Entry MCT1PadONOFF::Process();" << endl;
@@ -1622,5 +1622,5 @@
 //
 //
-Bool_t MCT1PadONOFF::PostProcess()
+Int_t MCT1PadONOFF::PostProcess()
 {
     if (GetNumExecutions() != 0)
Index: trunk/MagicSoft/Mars/manalysis/MCT1PadONOFF.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1PadONOFF.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MCT1PadONOFF.h	(revision 2206)
@@ -87,7 +87,7 @@
     void SetDataType(const char *type);   // type of data to be padded
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
     
     void SetPadFlag(Int_t padflag);
Index: trunk/MagicSoft/Mars/manalysis/MCT1PadSchweizer.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1PadSchweizer.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MCT1PadSchweizer.cc	(revision 2206)
@@ -181,5 +181,5 @@
 //  Set the pointers and prepare the histograms
 //
-Bool_t MCT1PadSchweizer::PreProcess(MParList *pList)
+Int_t MCT1PadSchweizer::PreProcess(MParList *pList)
 {
   if ( !fHSigmaTheta  || !fHSigmaPixTheta  || !fHDiffPixTheta  ||
@@ -266,5 +266,5 @@
 // idealy the events to be padded should have been generated without NSB
 // 
-Bool_t MCT1PadSchweizer::Process()
+Int_t MCT1PadSchweizer::Process()
 {
   //*fLog << "Entry MCT1PadSchweizer::Process();" << endl;
@@ -731,5 +731,5 @@
 //
 //
-Bool_t MCT1PadSchweizer::PostProcess()
+Int_t MCT1PadSchweizer::PostProcess()
 {
     if (GetNumExecutions() != 0)
Index: trunk/MagicSoft/Mars/manalysis/MCT1PadSchweizer.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1PadSchweizer.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MCT1PadSchweizer.h	(revision 2206)
@@ -60,7 +60,7 @@
                        TH2D *hist2Pix, TH2D *hist2PixN);
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
     
     void SetPadFlag(Int_t padflag);
Index: trunk/MagicSoft/Mars/manalysis/MCT1PointingCorrCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1PointingCorrCalc.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MCT1PointingCorrCalc.cc	(revision 2206)
@@ -60,5 +60,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MCT1PointingCorrCalc::PreProcess(MParList *pList)
+Int_t MCT1PointingCorrCalc::PreProcess(MParList *pList)
 {
     MGeomCam *geom = (MGeomCam*)pList->FindObject("MGeomCam");
@@ -70,5 +70,5 @@
     }
 
-   fHourAngle = (MParameterD*)pList->FindObject("HourAngle", "MParameterD");
+    fHourAngle = (MParameterD*)pList->FindObject("HourAngle", "MParameterD");
     if (!fHourAngle)
     {
@@ -95,5 +95,5 @@
 // the parametrization is for Mkn421 2001 data (Daniel Kranich)
 // 
-Bool_t MCT1PointingCorrCalc::Process()
+Int_t MCT1PointingCorrCalc::Process()
 {
    // fhourangle is the hour angle [degrees]
Index: trunk/MagicSoft/Mars/manalysis/MCT1PointingCorrCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1PointingCorrCalc.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MCT1PointingCorrCalc.h	(revision 2206)
@@ -32,6 +32,6 @@
                          const char *name=NULL, const char *title=NULL);
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
 
     ClassDef(MCT1PointingCorrCalc, 0)   // Task to do the CT1 pointing correction for Mkn421 2001 data
Index: trunk/MagicSoft/Mars/manalysis/MCT1SupercutsCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1SupercutsCalc.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MCT1SupercutsCalc.cc	(revision 2206)
@@ -149,5 +149,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MCT1SupercutsCalc::PreProcess(MParList *pList)
+Int_t MCT1SupercutsCalc::PreProcess(MParList *pList)
 {
     fHil = (MHillas*)pList->FindObject(fHilName, "MHillas");
@@ -235,5 +235,5 @@
 //                            0.75 otherwise
 //
-Bool_t MCT1SupercutsCalc::Process()
+Int_t MCT1SupercutsCalc::Process()
 {
     const Double_t kNomLogSize = 4.1;
Index: trunk/MagicSoft/Mars/manalysis/MCT1SupercutsCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCT1SupercutsCalc.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MCT1SupercutsCalc.h	(revision 2206)
@@ -50,6 +50,6 @@
     void InitParams();
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
 
 public:
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 2206)
@@ -385,9 +385,21 @@
 }
 
-Bool_t MCerPhotEvt::GetPixelContent(Float_t &val, Int_t idx, Float_t ratio, Int_t type) const
+// --------------------------------------------------------------------------
+//
+// Returns, depending on the type flag:
+//
+//  0: Number of Photons*PixRatio
+//  1: Error*sqrt(PixRatio)
+//  2: Cleaning level = Num Photons*sqrt(PixRatio)/Error
+//  3: Number of Photons
+//  4: Error
+//
+Bool_t MCerPhotEvt::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
 {
     MCerPhotPix *pix = GetPixById(idx);
     if (!pix || !pix->IsPixelUsed())
         return kFALSE;
+
+    const Double_t ratio = cam.GetPixRatio(idx);
 
     switch (type)
@@ -401,4 +413,10 @@
         val = pix->GetNumPhotons()*TMath::Sqrt(ratio)/pix->GetErrorPhot();
         return kTRUE;
+    case 3:
+        val = pix->GetNumPhotons();
+        break;
+    case 4:
+        val = pix->GetErrorPhot();
+        break;
     default:
         val = pix->GetNumPhotons()*ratio;
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 2206)
@@ -64,5 +64,5 @@
     void Clear(Option_t *opt=NULL) { Reset(); }
 
-    Bool_t GetPixelContent(Float_t &val, Int_t idx, Float_t ratio=1, Int_t type=0) const;
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
     void DrawPixelContent(Int_t num) const
     {
Index: trunk/MagicSoft/Mars/manalysis/MCompProbCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCompProbCalc.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MCompProbCalc.cc	(revision 2206)
@@ -81,5 +81,5 @@
 //  - MHadronness
 //
-Bool_t MCompProbCalc::PreProcess(MParList *plist)
+Int_t MCompProbCalc::PreProcess(MParList *plist)
 {
     MHCompProb *p = (MHCompProb*)plist->FindObject("MHCompProb");
@@ -140,5 +140,5 @@
 //  - This is the hadroness stored in the MHadronness container
 //
-Bool_t MCompProbCalc::Process()
+Int_t MCompProbCalc::Process()
 {
     Double_t p = 1;
Index: trunk/MagicSoft/Mars/manalysis/MCompProbCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCompProbCalc.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MCompProbCalc.h	(revision 2206)
@@ -25,6 +25,6 @@
     ~MCompProbCalc();
 
-    Bool_t PreProcess(MParList *plist);
-    Bool_t Process();
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
 
     ClassDef(MCompProbCalc, 1) // Task to calculate composite probabilities
Index: trunk/MagicSoft/Mars/manalysis/MCurrents.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCurrents.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MCurrents.h	(revision 2206)
@@ -37,5 +37,5 @@
     void Print(Option_t *opt=NULL) const;
 
-    Bool_t GetPixelContent(Float_t &val, Int_t idx, Float_t ratio=1, Int_t type=0) const
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
     {
         val = (*this)[idx];
Index: trunk/MagicSoft/Mars/manalysis/MEnergyEstParam.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MEnergyEstParam.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MEnergyEstParam.cc	(revision 2206)
@@ -133,5 +133,5 @@
 // Check for all necessary parameter containers.
 //
-Bool_t MEnergyEstParam::PreProcess(MParList *plist)
+Int_t MEnergyEstParam::PreProcess(MParList *plist)
 {
     if (!fMatrix)
@@ -299,5 +299,5 @@
 //  (see code)
 //
-Bool_t MEnergyEstParam::Process()
+Int_t MEnergyEstParam::Process()
 {
     const Double_t theta  = fMatrix ? GetVal(0) : fMc->GetTelescopeTheta();
Index: trunk/MagicSoft/Mars/manalysis/MEnergyEstParam.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MEnergyEstParam.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MEnergyEstParam.h	(revision 2206)
@@ -40,11 +40,10 @@
     Double_t GetVal(Int_t i) const;
 
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
 
 public:
     MEnergyEstParam(const char *hil="MHillas", const char *name=NULL, const char *title=NULL);
     ~MEnergyEstParam();
-
-    Bool_t PreProcess(MParList *plist);
-    Bool_t Process();
 
     void Add(const TString hillas, const TString energy="MEnergyEst");
Index: trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.cc	(revision 2206)
@@ -60,5 +60,5 @@
 }
 
-Bool_t MEnergyEstimate::PreProcess(MParList *plist)
+Int_t MEnergyEstimate::PreProcess(MParList *plist)
 {
    fHillas = (MHillas*)plist->FindObject("MHillas");
@@ -83,5 +83,5 @@
 }
 
-Bool_t MEnergyEstimate::Process()
+Int_t MEnergyEstimate::Process()
 {
   //fEnergy->SetEnergy(fHillas->GetSize());
Index: trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.h	(revision 2206)
@@ -20,6 +20,6 @@
     MEnergyEstimate(const char *name=NULL, const char *title=NULL);
 
-    Bool_t PreProcess(MParList *plist);
-    Bool_t Process();
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
 
     ClassDef(MEnergyEstimate, 0) // Task to copy the MC energy (preliminary)
Index: trunk/MagicSoft/Mars/manalysis/MFiltercutsCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MFiltercutsCalc.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MFiltercutsCalc.cc	(revision 2206)
@@ -62,4 +62,7 @@
     fList = new MFilterList;
     fList->SetOwner();
+    fList->SetBit(kMustCleanup);
+
+    gROOT->GetListOfCleanups()->Add(fList);
 }
 
@@ -80,4 +83,5 @@
 {
     f->SetName(f->GetRule());
+    f->SetBit(kMustCleanup);
     fList->AddToList(f);
 }
@@ -143,5 +147,5 @@
 // there. PreProcess the filter list.
 //
-Bool_t MFiltercutsCalc::PreProcess(MParList *pList)
+Int_t MFiltercutsCalc::PreProcess(MParList *pList)
 {
     if (!fList->PreProcess(pList))
@@ -160,5 +164,5 @@
 // 0.25, otherwise to 0.75.
 //
-Bool_t MFiltercutsCalc::Process()
+Int_t MFiltercutsCalc::Process()
 {
     if (!fList->Process())
Index: trunk/MagicSoft/Mars/manalysis/MFiltercutsCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MFiltercutsCalc.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MFiltercutsCalc.h	(revision 2206)
@@ -24,6 +24,6 @@
     TString     fHadronnessName;  // name of container to store hadronness
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
 
     void AddToList(MFilter *f);
Index: trunk/MagicSoft/Mars/manalysis/MMatrixLoop.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMatrixLoop.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MMatrixLoop.cc	(revision 2206)
@@ -56,5 +56,5 @@
 // been accessed.
 //
-Bool_t MMatrixLoop::Process()
+Int_t MMatrixLoop::Process()
 {
     return fMatrix->SetNumRow(fNumRow++);
Index: trunk/MagicSoft/Mars/manalysis/MMatrixLoop.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMatrixLoop.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MMatrixLoop.h	(revision 2206)
@@ -21,5 +21,5 @@
     MMatrixLoop(MHMatrix *mat, const char *name=NULL, const char *title=NULL);
 
-    Bool_t PreProcess(MParList *plist)
+    Int_t PreProcess(MParList *plist)
     {
         fNumRow = 0;
@@ -28,5 +28,5 @@
     }
 
-    Bool_t Process();
+    Int_t Process();
 
     ClassDef(MMatrixLoop, 0) // Task 'reading' events from a MHMatrix
Index: trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc	(revision 2206)
@@ -92,5 +92,5 @@
 // If the runtype check fails the task is removed from the task list.
 //
-Bool_t MMcPedestalCopy::PreProcess(MParList *pList)
+Int_t MMcPedestalCopy::PreProcess(MParList *pList)
 {
     if (!CheckRunType(pList))
Index: trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MMcPedestalCopy.h	(revision 2206)
@@ -17,10 +17,9 @@
     Bool_t CheckRunType(MParList *pList) const;
 
+    Int_t PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+
 public:
     MMcPedestalCopy(const char *name=NULL, const char *title=NULL);
-
-    Bool_t PreProcess(MParList *pList);
-
-    virtual Bool_t ReInit(MParList *pList);
 
     ClassDef(MMcPedestalCopy, 0)   // Task which copies the pedestals from the MC into the standard container
Index: trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 2206)
@@ -116,5 +116,5 @@
 // - try to find a MMcRunHeader, too
 //
-Bool_t MMcPedestalNSBAdd::PreProcess(MParList *pList)
+Int_t MMcPedestalNSBAdd::PreProcess(MParList *pList)
 {
     if (!CheckRunType(pList))
Index: trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.h	(revision 2206)
@@ -21,4 +21,7 @@
     Bool_t CheckRunType(MParList *pList) const;
     Float_t GetDnsb(MParList *pList) const;
+    Int_t PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+
 
 public:
@@ -26,8 +29,4 @@
                       const char *name=NULL, const char *title=NULL);
 
-    Bool_t PreProcess(MParList *pList);
-
-    virtual Bool_t ReInit(MParList *pList);
-
     ClassDef(MMcPedestalNSBAdd, 0)   // Task which adds the NSB fluctuations to the pedestals rms
 };
Index: trunk/MagicSoft/Mars/manalysis/MMcTriggerLvl2Calc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcTriggerLvl2Calc.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MMcTriggerLvl2Calc.cc	(revision 2206)
@@ -71,5 +71,5 @@
 //
 //
-Bool_t MMcTriggerLvl2Calc::PreProcess (MParList *pList)
+Int_t MMcTriggerLvl2Calc::PreProcess (MParList *pList)
 {
     // connect the raw data with this task
@@ -130,5 +130,5 @@
 // 
 //
-Bool_t MMcTriggerLvl2Calc::Process()
+Int_t MMcTriggerLvl2Calc::Process()
 {
   //const Float_t energy = fMcEvt->GetEnergy();
@@ -153,5 +153,5 @@
 //           !to be fixed: create an histogram class!
 //
-Bool_t MMcTriggerLvl2Calc::PostProcess()
+Int_t MMcTriggerLvl2Calc::PostProcess()
 { 
   
Index: trunk/MagicSoft/Mars/manalysis/MMcTriggerLvl2Calc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMcTriggerLvl2Calc.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MMcTriggerLvl2Calc.h	(revision 2206)
@@ -28,10 +28,10 @@
   MHMcTriggerLvl2 *fMHMcTriggerLvl2;
 
+  Int_t PreProcess(MParList *pList);
+  Int_t Process();
+  Int_t PostProcess();
+
  public:
     MMcTriggerLvl2Calc(const char *name=NULL, const char *title=NULL);   
-
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
 
     ClassDef(MMcTriggerLvl2Calc, 0) // Task to calculate the MMcTriggerLvl2 Parameters
Index: trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.cc	(revision 2206)
@@ -105,5 +105,5 @@
 // number of columns (with the same meaning).
 //
-Bool_t MMultiDimDistCalc::PreProcess(MParList *plist)
+Int_t MMultiDimDistCalc::PreProcess(MParList *plist)
 {
     fMGammas = (MHMatrix*)plist->FindObject("MatrixGammas", "MHMatrix");
@@ -172,5 +172,5 @@
 //  H = exp(-dh/dg);
 //
-Bool_t MMultiDimDistCalc::Process()
+Int_t MMultiDimDistCalc::Process()
 {
     // first copy the data from the data array to a vector event
Index: trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.h	(revision 2206)
@@ -27,4 +27,6 @@
 
     void StreamPrimitive(ofstream &out) const;
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
 
 public:
@@ -38,7 +40,4 @@
     void SetUseKernelMethod(Bool_t k=kTRUE) { fUseKernel = k; }
 
-    Bool_t PreProcess(MParList *plist);
-    Bool_t Process();
-
     ClassDef(MMultiDimDistCalc, 1) // Task to calculate nearest neighbor-/kernel-hadronness
 };
Index: trunk/MagicSoft/Mars/manalysis/MPadding.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPadding.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MPadding.cc	(revision 2206)
@@ -230,5 +230,5 @@
 //  if not create one and add them to the list
 //
-Bool_t MPadding::PreProcess(MParList *pList)
+Int_t MPadding::PreProcess(MParList *pList)
 {
   fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
@@ -407,5 +407,5 @@
 // Do the padding  (mySig ==> otherSig)
 // 
-Bool_t MPadding::Padding(const Double_t quadraticDiff, const Double_t theta)
+Int_t MPadding::Padding(const Double_t quadraticDiff, const Double_t theta)
 {
    const UInt_t npix = fEvt->GetNumPixels();
@@ -469,5 +469,5 @@
 // 3) pad event
 //
-Bool_t MPadding::Process()
+Int_t MPadding::Process()
 {
     const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
Index: trunk/MagicSoft/Mars/manalysis/MPadding.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPadding.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MPadding.h	(revision 2206)
@@ -43,12 +43,12 @@
     Bool_t   Padding(const Double_t quadDiff, const Double_t theta);
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
 public:
     MPadding(const char *name=NULL, const char *title=NULL);
     ~MPadding();
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
-    
     void SetRunType(Int_t runtype) { fRunType =  runtype; }
     void SetGroup(Int_t group)     { fGroup   =  group; }
Index: trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc	(revision 2206)
@@ -64,5 +64,5 @@
 }
 
-Bool_t MPedCalcPedRun::PreProcess( MParList *pList )
+Int_t MPedCalcPedRun::PreProcess( MParList *pList )
 {
     fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
@@ -83,5 +83,5 @@
 
 
-Bool_t MPedCalcPedRun::Process()
+Int_t MPedCalcPedRun::Process()
 {
     MRawEvtPixelIter pixel(fRawEvt);
Index: trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.h	(revision 2206)
@@ -29,10 +29,10 @@
     Float_t CalcHiGainRmsErr(Float_t higainrms) const;
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
 public:
 
     MPedCalcPedRun(const char *name=NULL, const char *title=NULL);
-
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
 
     ClassDef(MPedCalcPedRun, 0)   // Task to calculate pedestals from pedestal runs raw data
Index: trunk/MagicSoft/Mars/manalysis/MPedestalCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalCalc.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalCalc.cc	(revision 2206)
@@ -72,5 +72,5 @@
 }
 
-Bool_t MPedestalCalc::PreProcess(MParList *pList)
+Int_t MPedestalCalc::PreProcess(MParList *pList)
 {
     if (fHists)
@@ -123,5 +123,5 @@
 //  Then the current event is filled into the histograms.
 //
-Bool_t MPedestalCalc::Process()
+Int_t MPedestalCalc::Process()
 {
     //
Index: trunk/MagicSoft/Mars/manalysis/MPedestalCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalCalc.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalCalc.h	(revision 2206)
@@ -41,7 +41,7 @@
     void Check(Int_t i);
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
 public:
Index: trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 2206)
@@ -182,7 +182,7 @@
 }
 
-Bool_t MPedestalCam::GetPixelContent(Float_t &val, Int_t idx, Float_t ratio, Int_t type) const
+Bool_t MPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
 {
-    val = (*this)[idx].GetMean()*ratio;
+    val = (*this)[idx].GetMean()*cam.GetPixRatio(idx);
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/manalysis/MPedestalCam.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 2206)
@@ -35,5 +35,5 @@
     void Print(Option_t *o="") const;
 
-    Bool_t GetPixelContent(Float_t &val, Int_t idx, Float_t ratio=1, Int_t type=0) const;
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
     void DrawPixelContent(Int_t num) const
     {
Index: trunk/MagicSoft/Mars/manalysis/MPointingCorr.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPointingCorr.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MPointingCorr.cc	(revision 2206)
@@ -64,5 +64,5 @@
 // 
 //
-Bool_t MPointingCorr::PreProcess(MParList *pList)
+Int_t MPointingCorr::PreProcess(MParList *pList)
 {
     MGeomCam *geom = (MGeomCam*)pList->FindObject("MGeomCam");
@@ -107,5 +107,5 @@
 // the parametrization is for Mkn421 2001 data (Daniel Kranich)
 // 
-Bool_t MPointingCorr::Process()
+Int_t MPointingCorr::Process()
 {
    // fhourangle is the hour angle [degrees]
@@ -133,17 +133,2 @@
    return kTRUE;
 }
-// --------------------------------------------------------------------------
-//
-//  
-//
-Bool_t MPointingCorr::PostProcess()
-{
-    return kTRUE;
-}
-//============================================================================
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/manalysis/MPointingCorr.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPointingCorr.h	(revision 2205)
+++ trunk/MagicSoft/Mars/manalysis/MPointingCorr.h	(revision 2206)
@@ -28,11 +28,10 @@
     Float_t       fMm2Deg;
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
 public:
     MPointingCorr(const char *name=NULL, const char *title=NULL,
                   const char *srcname="MSrcPosCam");
-
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
 
     ClassDef(MPointingCorr, 0)   // Task to do the pointing correction
@@ -40,13 +39,2 @@
 
 #endif
-
-
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mbase/MClone.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MClone.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MClone.cc	(revision 2206)
@@ -112,5 +112,5 @@
 //  the name of it was given in the constructor.
 //
-Bool_t MClone::PreProcess(MParList *pList)
+Int_t MClone::PreProcess(MParList *pList)
 {
     //
@@ -158,5 +158,5 @@
 //  again.
 //
-Bool_t MClone::Process()
+Int_t MClone::Process()
 {
     //
Index: trunk/MagicSoft/Mars/mbase/MClone.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MClone.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MClone.h	(revision 2206)
@@ -27,6 +27,6 @@
     ~MClone();
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
 
     TObject *GetClone() const  { return fClone; }
Index: trunk/MagicSoft/Mars/mbase/MContinue.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MContinue.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MContinue.cc	(revision 2206)
@@ -112,5 +112,5 @@
 //  before this instance to the tasklist and preprocesses the filter.
 //
-Bool_t MContinue::PreProcess(MParList *list)
+Int_t MContinue::PreProcess(MParList *list)
 {
     if (!GetFilter())
@@ -147,4 +147,20 @@
 }
 
+void MContinue::SetDisplay(MStatusDisplay *d)
+{
+    if (GetFilter())
+        GetFilter()->SetDisplay(d);
+
+    MTask::SetDisplay(d);
+}
+
+void MContinue::SetLogStream(MLog *lg)
+{
+    if (GetFilter())
+        GetFilter()->SetLogStream(lg);
+
+    MTask::SetLogStream(lg);
+}
+
 // --------------------------------------------------------------------------
 //
@@ -152,5 +168,5 @@
 // from the tasklist.
 //
-Bool_t MContinue::PostProcess()
+Int_t MContinue::PostProcess()
 {
     if (!TestBit(kFilterIsPrivate))
Index: trunk/MagicSoft/Mars/mbase/MContinue.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MContinue.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MContinue.h	(revision 2206)
@@ -15,6 +15,8 @@
 #endif
 
+class MLog;
 class MFilter;
 class MTaskList;
+class MStatusDisplay;
 
 class MContinue : public MTask
@@ -23,7 +25,7 @@
     MTaskList *fTaskList;  //! pointer to the present tasklist
 
-    Bool_t PreProcess(MParList *list);
-    Bool_t Process() { return kCONTINUE; }
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *list);
+    Int_t Process() { return kCONTINUE; }
+    Int_t PostProcess();
 
     enum { kIsOwner = BIT(14), kFilterIsPrivate = BIT(15) };
@@ -37,4 +39,7 @@
     Bool_t IsInverted() const;
 
+    void SetDisplay(MStatusDisplay *d);
+    void SetLogStream(MLog *lg);
+
     ClassDef(MContinue, 1) //Task returning kCONTINUE
 };
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 2206)
@@ -109,4 +109,6 @@
     fName = name;
 
+    gROOT->GetListOfCleanups()->Add(this); // To remove fDisplay
+
     *fLog << inf << underline << "Instantiated MEvtLoop (" << name << "), using ROOT v" << ROOTVER << endl;
 }
@@ -122,4 +124,13 @@
 }
 
+void MEvtLoop::SetParList(MParList *p)
+{
+    if (!p)
+        return;
+
+    p->SetBit(kMustCleanup);
+    fParList = p;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -152,4 +163,10 @@
 }
 
+void MEvtLoop::SetProgressBar(TGProgressBar *bar)
+{
+    fProgress = bar;
+    fProgress->SetBit(kMustCleanup);
+}
+
 #ifdef __MARS__
 // --------------------------------------------------------------------------
@@ -160,5 +177,5 @@
 void MEvtLoop::SetProgressBar(MProgressBar *bar)
 {
-    fProgress = bar->GetBar();
+    SetProgressBar(bar->GetBar());
 }
 #endif
@@ -200,6 +217,4 @@
     // Check whether display is still existing
     //
-    if (fDisplay && !gROOT->GetListOfSpecials()->FindObject(fDisplay))
-        fDisplay = NULL;
     if (fDisplay)
     {
@@ -238,5 +253,5 @@
 Bool_t MEvtLoop::ProcessGuiEvents(Int_t num)
 {
-    if (!fProgress)
+    if (!fProgress || gROOT->IsBatch())
         return kTRUE;
 
@@ -255,11 +270,4 @@
             fDisplay->ClearStatus();
             break;
-        case MStatusDisplay::kFileExit:
-            fParList->SetDisplay(NULL);
-            delete fDisplay;
-            SetDisplay(NULL);
-            fProgress = NULL;
-            gSystem->ProcessEvents();
-            return kTRUE;
         default:
             *fLog << warn << "MEvtloop: fDisplay->ChecStatus() has returned unknown status #" << fDisplay->CheckStatus() << "... cleared." << endl;
@@ -348,5 +356,5 @@
     Int_t entries = INT_MAX;
 
-    if (fProgress)
+    if (fProgress && !gROOT->IsBatch())
     {
         fProgress->Reset();
@@ -409,5 +417,5 @@
     clock.Stop();
 
-    if (fProgress)
+    if (fProgress && !gROOT->IsBatch())
     {
         fProgress->SetPosition(maxcnt>0 ? TMath::Min(maxcnt, entries) : entries);
@@ -912,2 +920,29 @@
     return kTRUE;
 }
+
+void MEvtLoop::RecursiveRemove(TObject *obj)
+{
+    if (obj==fParList)
+    {
+        fParList=NULL;
+        fTaskList=NULL;
+    }
+
+    if (obj==fProgress)
+        fProgress = NULL;
+
+    if (obj==fDisplay)
+    {
+        if (fParList)
+            fParList->SetDisplay(NULL);
+        SetDisplay(NULL);
+        fProgress = NULL;
+    }
+
+    if (obj==fLog)
+    {
+        if (fParList)
+            fParList->SetLogStream(NULL);
+        SetLogStream(NULL);
+    }
+}
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 2206)
@@ -28,5 +28,5 @@
     MTaskList *fTaskList;      //!
 
-    TGProgressBar   *fProgress;  //!
+    TGProgressBar *fProgress;  //!
 
     enum { kIsOwner = BIT(14) };
@@ -43,7 +43,7 @@
     virtual ~MEvtLoop();
 
-    void       SetParList(MParList *p)  { fParList = p; }
-    MParList  *GetParList() const       { return fParList; }
-    MTaskList *GetTaskList() const      { return fTaskList; }
+    void       SetParList(MParList *p);
+    MParList  *GetParList() const  { return fParList; }
+    MTaskList *GetTaskList() const { return fTaskList; }
 
     MTask *FindTask(const char *name) const;
@@ -54,5 +54,5 @@
     void SetOwner(Bool_t enable=kTRUE);
 
-    void SetProgressBar(TGProgressBar *bar) { fProgress = bar; }
+    void SetProgressBar(TGProgressBar *bar);
 #ifdef __MARS__
     void SetProgressBar(MProgressBar *bar);
@@ -77,7 +77,10 @@
     Bool_t WriteEnv(TEnv &env, TString prefix="", Bool_t print=kFALSE) const;
 
+    void RecursiveRemove(TObject *obj);
+
     ClassDef(MEvtLoop, 1) // Class to execute the tasks in a tasklist
 };
 
+// FIXME: Move as (persistent) static data member to MParContainer
 R__EXTERN TList *gListOfPrimitives; // instantiation in MEvtLoop
 
Index: trunk/MagicSoft/Mars/mbase/MGTask.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MGTask.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MGTask.cc	(revision 2206)
@@ -70,5 +70,5 @@
 //  MTask::CallPreProcess
 //
-Bool_t MGTask::CallPreProcess(MParList *plist)
+Int_t MGTask::CallPreProcess(MParList *plist)
 {
     HideGui();
@@ -82,5 +82,5 @@
 //  MTask::CallPostProcess
 //
-Bool_t MGTask::CallPostProcess()
+Int_t MGTask::CallPostProcess()
 {
     ShowGui();
Index: trunk/MagicSoft/Mars/mbase/MGTask.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MGTask.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MGTask.h	(revision 2206)
@@ -38,6 +38,6 @@
     virtual ~MGTask();
 
-    Bool_t CallPreProcess(MParList *plist);
-    Bool_t CallPostProcess();
+    Int_t CallPreProcess(MParList *plist);
+    Int_t CallPostProcess();
 
     virtual Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2);
Index: trunk/MagicSoft/Mars/mbase/MPrint.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MPrint.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MPrint.cc	(revision 2206)
@@ -107,5 +107,5 @@
 //  the name of it was given in the constructor.
 //
-Bool_t MPrint::PreProcess(MParList *pList)
+Int_t MPrint::PreProcess(MParList *pList)
 {
     //
@@ -142,5 +142,5 @@
 //  Calls overloaded TObject::Print
 //
-Bool_t MPrint::Process()
+Int_t MPrint::Process()
 {
     fObject->Print(fOption);
Index: trunk/MagicSoft/Mars/mbase/MPrint.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MPrint.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MPrint.h	(revision 2206)
@@ -26,6 +26,6 @@
     void EnableSkip(Bool_t skip=kTRUE) { skip ? SetBit(kSkip) : ResetBit(kSkip); }
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
 
     ClassDef(MPrint, 0) // Task to call Print() function
Index: trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 2206)
@@ -165,5 +165,5 @@
 // Sets the preprocessed flag dependend on the return value of PreProcess.
 //
-Bool_t MTask::CallPreProcess(MParList *plist)
+Int_t MTask::CallPreProcess(MParList *plist)
 {
     fNumExecutions = 0;
@@ -199,5 +199,5 @@
 // If Process is executed, the execution counter is increased.
 //
-Bool_t MTask::CallProcess()
+Int_t MTask::CallProcess()
 {
     //
@@ -221,5 +221,5 @@
 // resets this flag.
 //
-Bool_t MTask::CallPostProcess()
+Int_t MTask::CallPostProcess()
 {
     if (!fIsPreprocessed)
@@ -261,5 +261,5 @@
 // the virtual implementation returns kTRUE
 //
-Bool_t MTask::PreProcess(MParList *pList)
+Int_t MTask::PreProcess(MParList *pList)
 {
     return kTRUE;
@@ -272,5 +272,5 @@
 // the virtual implementation returns kTRUE
 //
-Bool_t MTask::Process()
+Int_t MTask::Process()
 {
     return kTRUE;
@@ -283,5 +283,5 @@
 // the virtual implementation returns kTRUE
 //
-Bool_t MTask::PostProcess()
+Int_t MTask::PostProcess()
 {
     return kTRUE;
Index: trunk/MagicSoft/Mars/mbase/MTask.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MTask.h	(revision 2206)
@@ -29,7 +29,7 @@
     UInt_t fNumExecutions;  //! Number of Excutions
 
-    virtual Bool_t PreProcess(MParList *pList);
-    virtual Bool_t Process();
-    virtual Bool_t PostProcess();
+    virtual Int_t PreProcess(MParList *pList);
+    virtual Int_t Process();
+    virtual Int_t PostProcess();
 
 protected:
@@ -75,7 +75,7 @@
     virtual Bool_t ReInit(MParList *pList);
 
-    virtual Bool_t CallPreProcess(MParList *plist);
-    virtual Bool_t CallProcess();
-    virtual Bool_t CallPostProcess();
+    virtual Int_t CallPreProcess(MParList *plist);
+    virtual Int_t CallProcess();
+    virtual Int_t CallPostProcess();
 
     const TList *GetListOfBranches() const { return fListOfBranches; }
Index: trunk/MagicSoft/Mars/mbase/MTaskInteractive.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskInteractive.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MTaskInteractive.cc	(revision 2206)
@@ -75,5 +75,5 @@
 }
 
-inline Bool_t MTaskInteractive::Return(Int_t no, void *params)
+inline Int_t MTaskInteractive::Return(Int_t no, void *params)
 {
     // Static function called when SetFCN is called in interactive mode
Index: trunk/MagicSoft/Mars/mbase/MTaskInteractive.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskInteractive.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MTaskInteractive.h	(revision 2206)
@@ -23,13 +23,13 @@
     TMethodCall *fCall[3];
 
-    Bool_t (*fPreProcess)(MParList *list);
-    Bool_t (*fProcess)();
-    Bool_t (*fPostProcess)();
+    Int_t (*fPreProcess)(MParList *list);
+    Int_t (*fProcess)();
+    Int_t (*fPostProcess)();
 
-    Bool_t PreProcess(MParList *list) { if (fCall[0]) return Return(0, &list); return fPreProcess  ? (*fPreProcess)(list) : kTRUE; }
-    Bool_t Process()                  { if (fCall[1]) return Return(1);        return fProcess     ? (*fProcess)()        : kTRUE; }
-    Bool_t PostProcess()              { if (fCall[2]) return Return(2);        return fPostProcess ? (*fPostProcess)()    : kTRUE; }
+    Int_t PreProcess(MParList *list) { if (fCall[0]) return Return(0, &list); return fPreProcess  ? (*fPreProcess)(list) : kTRUE; }
+    Int_t Process()                  { if (fCall[1]) return Return(1);        return fProcess     ? (*fProcess)()        : kTRUE; }
+    Int_t PostProcess()              { if (fCall[2]) return Return(2);        return fPostProcess ? (*fPostProcess)()    : kTRUE; }
 
-    Bool_t Return(Int_t no, void *param=NULL);
+    Int_t Return(Int_t no, void *param=NULL);
     Bool_t Set(void *fcn, Int_t no, const char *params);
     void   Free(Int_t no);
@@ -40,7 +40,7 @@
 
     // This is to be used in compiled code
-    void SetPreProcess(Bool_t (*func)(MParList *list)) { fPreProcess = func;  Free(0); }
-    void SetProcess(Bool_t (*func)())                  { fProcess = func;     Free(1);  }
-    void SetPostProcess(Bool_t (*func)())              { fPostProcess = func; Free(2);  }
+    void SetPreProcess(Int_t (*func)(MParList *list)) { fPreProcess = func;  Free(0); }
+    void SetProcess(Int_t (*func)())                  { fProcess = func;     Free(1);  }
+    void SetPostProcess(Int_t (*func)())              { fPostProcess = func; Free(2);  }
 
     // This is for usage in CINT
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 2206)
@@ -92,4 +92,9 @@
 
     fTasks = new TList;
+
+    gROOT->GetListOfCleanups()->Add(fTasks);
+    gROOT->GetListOfCleanups()->Add(&fTasksProcess);
+    fTasks->SetBit(kMustCleanup);
+    fTasksProcess.SetBit(kMustCleanup);
 }
 
@@ -212,4 +217,5 @@
     *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush;
     task->SetStreamId(type);
+    task->SetBit(kMustCleanup);
     fTasks->AddBefore((TObject*)where, task);
     *fLog << "Done." << endl;
@@ -232,4 +238,5 @@
     *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush;
     task->SetStreamId(type);
+    task->SetBit(kMustCleanup);
     fTasks->AddAfter((TObject*)where, task);
     *fLog << "Done." << endl;
@@ -252,4 +259,5 @@
     *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush;
     task->SetStreamId(type);
+    task->SetBit(kMustCleanup);
     fTasks->Add(task);
     *fLog << "Done." << endl;
@@ -331,5 +339,5 @@
 //  doing no Processing are not Processed.
 //
-Bool_t MTaskList::PreProcess(MParList *pList)
+Int_t MTaskList::PreProcess(MParList *pList)
 {
     *fLog << all << "Preprocessing... " << flush;
@@ -399,5 +407,5 @@
 // do the event execution of all tasks in the task-list
 //
-Bool_t MTaskList::Process()
+Int_t MTaskList::Process()
 {
     //
@@ -501,5 +509,5 @@
 //  only tasks which have successfully been preprocessed are postprocessed.
 //
-Bool_t MTaskList::PostProcess()
+Int_t MTaskList::PostProcess()
 {
     *fLog << all << "Postprocessing... " << flush;
Index: trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 2206)
@@ -63,7 +63,7 @@
     Bool_t ReInit(MParList *pList=NULL);
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
     void Print(Option_t *opt = "") const;
Index: trunk/MagicSoft/Mars/mdata/MDataArray.cc
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataArray.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mdata/MDataArray.cc	(revision 2206)
@@ -57,4 +57,7 @@
     fName  = name  ? name  : gsDefName.Data();
     fTitle = title ? title : gsDefTitle.Data();
+
+    gROOT->GetListOfCleanups()->Add(&fList);
+    fList.SetBit(kMustCleanup);
 }
 
@@ -77,4 +80,5 @@
 void MDataArray::AddEntry(MData *data)
 {
+    data->SetBit(kMustCleanup);
     fList.Add(data);
 }
Index: trunk/MagicSoft/Mars/mdata/MDataList.cc
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataList.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mdata/MDataList.cc	(revision 2206)
@@ -45,4 +45,7 @@
 {
     fSign = kENone;
+
+    gROOT->GetListOfCleanups()->Add(&fMembers);
+    fMembers.SetBit(kMustCleanup);
 }
 
@@ -76,4 +79,7 @@
         fSign = kENone;
     }
+
+    gROOT->GetListOfCleanups()->Add(&fMembers);
+    fMembers.SetBit(kMustCleanup);
 }
 
@@ -179,4 +185,5 @@
     }
 
+    member->SetBit(kMustCleanup);
     fMembers.Add(member);
 
Index: trunk/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h	(revision 2206)
@@ -5,5 +5,3 @@
 #pragma link off all functions;
 
-#pragma link C++ class MDumpEvtHeader+;
-
 #endif
Index: trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc	(revision 2206)
@@ -60,5 +60,5 @@
 // data.
 //
-Bool_t MDumpEvtHeader::PreProcess (MParList *pList)
+Int_t MDumpEvtHeader::PreProcess (MParList *pList)
 {
     fRawEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
@@ -84,5 +84,5 @@
 // pixel ID's of all pixels in this event.
 //
-Bool_t MDumpEvtHeader::Process()
+Int_t MDumpEvtHeader::Process()
 {
     fRawEvtHeader->Print();
Index: trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h	(revision 2206)
@@ -16,10 +16,10 @@
     MRawEvtData   *fRawEvtData;
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
 public:
   MDumpEvtHeader () : fRawEvtHeader(NULL) { };
 
-  Bool_t PreProcess(MParList *pList);
-  Bool_t Process();
-  
   ClassDef(MDumpEvtHeader, 0)	// Class to dump the pixel ids of a raw evt to the screen
 
Index: trunk/MagicSoft/Mars/mdatacheck/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/Makefile	(revision 2205)
+++ trunk/MagicSoft/Mars/mdatacheck/Makefile	(revision 2206)
@@ -28,6 +28,5 @@
 .SUFFIXES: .c .cc .cxx .h .hxx .o 
 
-SRCFILES = MDumpEvtHeader.cc \
-	   MGDisplayAdc.cc
+SRCFILES = MGDisplayAdc.cc
 
 SRCS    = $(SRCFILES)
Index: trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.cc	(revision 2206)
@@ -156,5 +156,5 @@
 // Initialize the size of the MPedestalCam container to 127 pixels (CT1 camera)
 //
-Bool_t MCT1ReadAscii::PreProcess(MParList *pList)
+Int_t MCT1ReadAscii::PreProcess(MParList *pList)
 {
     //
@@ -264,5 +264,5 @@
 // there is now next file stop the eventloop.
 //
-Bool_t MCT1ReadAscii::Process()
+Int_t MCT1ReadAscii::Process()
 {
     //
Index: trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.h	(revision 2206)
@@ -23,4 +23,7 @@
     void ReadData();
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
 public:
     MCT1ReadAscii(const char *filename=NULL,
@@ -32,7 +35,4 @@
     Int_t AddFile(const char *fname, Int_t dummy=-1);
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-
     ClassDef(MCT1ReadAscii, 0)	// Reads the CT1 data file
 };
Index: trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 2206)
@@ -730,5 +730,5 @@
 // Initialize the size of the MPedestalCam container to 127 pixels (CT1 camera)
 //
-Bool_t MCT1ReadPreProc::PreProcess(MParList *pList)
+Int_t MCT1ReadPreProc::PreProcess(MParList *pList)
 {
     fParList = pList;
@@ -1091,5 +1091,5 @@
 // there is now next file stop the eventloop.
 //
-Bool_t MCT1ReadPreProc::Process()
+Int_t MCT1ReadPreProc::Process()
 {
     //
@@ -1152,5 +1152,5 @@
 }
 
-Bool_t MCT1ReadPreProc::PostProcess()
+Int_t MCT1ReadPreProc::PostProcess()
 {
     *fLog << all;
Index: trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h	(revision 2206)
@@ -79,7 +79,7 @@
     Double_t DiscreteTheta(Double_t theta);
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
     Bool_t Rewind();
Index: trunk/MagicSoft/Mars/mfileio/MReadCurrents.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadCurrents.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MReadCurrents.cc	(revision 2206)
@@ -151,5 +151,5 @@
 // Initialize the size of the MPedestalCam container to 127 pixels (CT1 camera)
 //
-Bool_t MReadCurrents::PreProcess(MParList *pList)
+Int_t MReadCurrents::PreProcess(MParList *pList)
 {
     //
@@ -190,5 +190,5 @@
 // there is now next file stop the eventloop.
 //
-Bool_t MReadCurrents::Process()
+Int_t MReadCurrents::Process()
 {
     //
Index: trunk/MagicSoft/Mars/mfileio/MReadCurrents.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadCurrents.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MReadCurrents.h	(revision 2206)
@@ -29,6 +29,6 @@
     Int_t AddFile(const char *fname, Int_t dummy=-1);
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
 
     ClassDef(MReadCurrents, 0)	// Reads a Central Control currents file
Index: trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc	(revision 2206)
@@ -199,5 +199,5 @@
 //  see MReadTree::PreProcess for more information
 //
-Bool_t MReadMarsFile::PreProcess(MParList *pList)
+Int_t MReadMarsFile::PreProcess(MParList *pList)
 {
     fParList = pList;
Index: trunk/MagicSoft/Mars/mfileio/MReadMarsFile.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadMarsFile.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MReadMarsFile.h	(revision 2206)
@@ -17,5 +17,5 @@
     Bool_t Notify();
 
-    Bool_t PreProcess(MParList *pList);
+    Int_t PreProcess(MParList *pList);
   
 public:
Index: trunk/MagicSoft/Mars/mfileio/MReadRflFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadRflFile.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MReadRflFile.cc	(revision 2206)
@@ -42,4 +42,5 @@
 #include "MRflEvtHeader.h"
 #include "MRflRunHeader.h"
+#include "MRflSinglePhoton.h"
 
 #include "MLog.h"
@@ -219,5 +220,5 @@
 }
 
-Bool_t MReadRflFile::Process()
+Int_t MReadRflFile::Process()
 {
     for (;;)
@@ -248,5 +249,5 @@
 }
 
-Bool_t MReadRflFile::PreProcess(MParList *plist)
+Int_t MReadRflFile::PreProcess(MParList *plist)
 {
     fEvtData=(MRflEvtData*)plist->FindCreateObj("MRflEvtData");
Index: trunk/MagicSoft/Mars/mfileio/MReadRflFile.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadRflFile.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MReadRflFile.h	(revision 2206)
@@ -38,6 +38,6 @@
     Bool_t OpenNextFile();
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
 
 public:
Index: trunk/MagicSoft/Mars/mfileio/MReadTree.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 2206)
@@ -572,5 +572,5 @@
 //  MReadTree::PreProcess
 //
-Bool_t MReadTree::PreProcess(MParList *pList)
+Int_t MReadTree::PreProcess(MParList *pList)
 {
     //
@@ -755,5 +755,5 @@
 #include "MRawEvtData.h"
 #endif
-Bool_t MReadTree::Process()
+Int_t MReadTree::Process()
 {
     //
@@ -816,5 +816,5 @@
 //  If a selector is given the selector is post processed
 //
-Bool_t MReadTree::PostProcess()
+Int_t MReadTree::PostProcess()
 {
     return GetSelector() ? GetSelector()->CallPostProcess() : kTRUE;
Index: trunk/MagicSoft/Mars/mfileio/MReadTree.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadTree.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MReadTree.h	(revision 2206)
@@ -68,7 +68,7 @@
     virtual Int_t AddFiles(const MReadTree &read);
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
     Bool_t Notify();
Index: trunk/MagicSoft/Mars/mfileio/MWriteFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteFile.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MWriteFile.cc	(revision 2206)
@@ -57,5 +57,5 @@
 // to the output file.
 //
-Bool_t MWriteFile::PreProcess(MParList *pList)
+Int_t MWriteFile::PreProcess(MParList *pList)
 {
     //
@@ -89,8 +89,7 @@
 // the container should be written to the output.
 //
-Bool_t MWriteFile::Process()
+Int_t MWriteFile::Process()
 {
     CheckAndWrite();
-
     return kTRUE;
 }
@@ -101,5 +100,5 @@
 // the container should be written to the output.
 //
-Bool_t MWriteFile::PostProcess()
+Int_t MWriteFile::PostProcess()
 {
     //
@@ -107,5 +106,4 @@
     //
     CheckAndWrite();
-
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mfileio/MWriteFile.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteFile.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfileio/MWriteFile.h	(revision 2206)
@@ -9,7 +9,7 @@
 {
 private:
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
     virtual Bool_t      IsFileOpen() const = 0;
Index: trunk/MagicSoft/Mars/mfilter/MF.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MF.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MF.cc	(revision 2206)
@@ -409,5 +409,5 @@
 // PreProcess all filters.
 //
-Bool_t MF::PreProcess(MParList *plist)
+Int_t MF::PreProcess(MParList *plist)
 {
     if (!fF)
@@ -431,5 +431,5 @@
 // Process all filters.
 //
-Bool_t MF::Process()
+Int_t MF::Process()
 {
     return fF->CallProcess();
@@ -440,5 +440,5 @@
 //  Postprocess all filters.
 //
-Bool_t MF::PostProcess()
+Int_t MF::PostProcess()
 {
     return fF->CallPostProcess();
Index: trunk/MagicSoft/Mars/mfilter/MF.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MF.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MF.h	(revision 2206)
@@ -37,7 +37,7 @@
     Bool_t IsExpressionTrue() const;
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
     void Print(Option_t *opt="") const;
Index: trunk/MagicSoft/Mars/mfilter/MFAlpha.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFAlpha.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFAlpha.cc	(revision 2206)
@@ -81,5 +81,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MFAlpha::PreProcess(MParList *pList)
+Int_t MFAlpha::PreProcess(MParList *pList)
 {
     if (fHillas)
@@ -96,5 +96,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MFAlpha::Process()
+Int_t MFAlpha::Process()
 {
     const Float_t alpha = fabs(fHillas->GetAlpha());
Index: trunk/MagicSoft/Mars/mfilter/MFAlpha.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFAlpha.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFAlpha.h	(revision 2206)
@@ -32,4 +32,7 @@
     void StreamPrimitive(ofstream &out) const;
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
 public:
     MFAlpha(const char *cname="MHillas", const char type='>', const Float_t deg=15,
@@ -39,6 +42,4 @@
 
     Bool_t IsExpressionTrue() const { return fResult; }
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
 
     ClassDef(MFAlpha, 1) // A Filter for cuts in fabs(alpha)
Index: trunk/MagicSoft/Mars/mfilter/MFCT1SelBasic.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFCT1SelBasic.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFCT1SelBasic.cc	(revision 2206)
@@ -93,5 +93,5 @@
 // 
 //
-Bool_t MFCT1SelBasic::PreProcess(MParList *pList)
+Int_t MFCT1SelBasic::PreProcess(MParList *pList)
 {
     /*
@@ -137,4 +137,11 @@
 }
 
+Int_t MFCT1SelBasic::Set(Int_t rc)
+{
+    fCut[rc]++;
+    fResult=kTRUE;
+    return kTRUE;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -144,28 +151,20 @@
 // if they are not fullfilled : fResult = kFALSE;
 //
-Bool_t MFCT1SelBasic::Process()
+Int_t MFCT1SelBasic::Process()
 {
     const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
 
-    Int_t rc = 0;
     fResult  = kFALSE;
 
-    if ( theta < fThetaMin )
-    {
-      rc = 1;
-      fResult = kTRUE;
-    }    
-    else if ( theta > fThetaMax )
-    {
-      rc = 2;
-      fResult = kTRUE;
-    }    
-    else if ( !SwTrigger() )
-    {
-      rc = 3;
-      fResult = kTRUE;
-    }    
-
-    fCut[rc]++;
+    if (theta<fThetaMin)
+        return Set(1);
+
+    if (theta>fThetaMax)
+        return Set(2);
+
+    if (!SwTrigger())
+        return Set(3);
+
+    fCut[0]++;
 
     return kTRUE;
@@ -227,5 +226,5 @@
 //  Prints some statistics about the Basic selections.
 //
-Bool_t MFCT1SelBasic::PostProcess()
+Int_t MFCT1SelBasic::PostProcess()
 {
     if (GetNumExecutions()==0)
Index: trunk/MagicSoft/Mars/mfilter/MFCT1SelBasic.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFCT1SelBasic.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFCT1SelBasic.h	(revision 2206)
@@ -37,7 +37,9 @@
     Bool_t      fResult;
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t Set(Int_t rc);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
     Bool_t IsExpressionTrue() const { return fResult; }
Index: trunk/MagicSoft/Mars/mfilter/MFCT1SelFinal.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFCT1SelFinal.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFCT1SelFinal.cc	(revision 2206)
@@ -94,5 +94,5 @@
 // Set the pointers
 //
-Bool_t MFCT1SelFinal::PreProcess(MParList *pList)
+Int_t MFCT1SelFinal::PreProcess(MParList *pList)
 {
     fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
@@ -124,4 +124,11 @@
 }
 
+Int_t MFCT1SelFinal::Set(Int_t rc)
+{
+    fCut[rc]++;
+    fResult=kTRUE;
+    return kTRUE;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -130,29 +137,21 @@
 // if cuts are fulfilled set fResult = kTRUE
 //
-Bool_t MFCT1SelFinal::Process()
+Int_t MFCT1SelFinal::Process()
 {
     const Double_t modalpha = fabs( fHilSrc->GetAlpha() );
     const Double_t h = fHadronness->GetHadronness();
 
-    Int_t rc = 0;
     fResult = kFALSE;
 
-    if ( h>fHadronnessMax )
-    {
-      rc = 1;
-      fResult = kTRUE;
-    }    
-    else if ( modalpha > fAlphaMax )
-    {
-      rc = 2;
-      fResult = kTRUE;
-    }
-    else if ( fMm2Deg*fHilSrc->GetDist() > fDistMax )
-    {
-      rc = 3;
-      fResult = kTRUE;
-    }    
+    if (h>fHadronnessMax)
+        return Set(1);
 
-    fCut[rc]++;
+    if (modalpha>fAlphaMax)
+        return Set(2);
+
+    if (fMm2Deg*fHilSrc->GetDist()>fDistMax)
+        return Set(3);
+
+    fCut[0]++;
 
     return kTRUE;
@@ -163,5 +162,5 @@
 //  Prints some statistics about the Final selections.
 //
-Bool_t MFCT1SelFinal::PostProcess()
+Int_t MFCT1SelFinal::PostProcess()
 {
     if (GetNumExecutions()==0)
Index: trunk/MagicSoft/Mars/mfilter/MFCT1SelFinal.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFCT1SelFinal.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFCT1SelFinal.h	(revision 2206)
@@ -38,7 +38,9 @@
     Bool_t       fResult;
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t Set(Int_t rc);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
     Bool_t IsExpressionTrue() const  { return fResult; }
Index: trunk/MagicSoft/Mars/mfilter/MFCT1SelStandard.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFCT1SelStandard.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFCT1SelStandard.cc	(revision 2206)
@@ -104,5 +104,5 @@
 // MISSING
 //
-Bool_t MFCT1SelStandard::PreProcess(MParList *pList)
+Int_t MFCT1SelStandard::PreProcess(MParList *pList)
 {
     fHil = (MHillas*)pList->FindObject(fHilName, "MHillas");
@@ -141,4 +141,10 @@
 }
 
+Bool_t MFCT1SelStandard::Set(Int_t rc)
+{
+    fResult = kTRUE;
+    fCut[rc]++;
+    return kTRUE;
+}
 // --------------------------------------------------------------------------
 //
@@ -148,5 +154,5 @@
 // 
 //
-Bool_t MFCT1SelStandard::Process()
+Int_t MFCT1SelStandard::Process()
 {
     const Double_t length     = fHil->GetLength() * fMm2Deg;
@@ -158,30 +164,19 @@
     const Int_t numcorepixels = fNewImgPar->GetNumCorePixels();
 
-    Int_t rc = 0;
     fResult  = kFALSE;
 
-    if ( numusedpixels >= fUsedPixelsMax  ||  numcorepixels <= fCorePixelsMin )
-    {
-      rc = 1;
-      fResult = kTRUE;
-    }    
-    else if ( size <= fSizeMin )
-    {
-      rc = 2;
-      fResult = kTRUE;
-    }    
-    else if ( dist< fDistMin   ||  dist > fDistMax )
-    {
-      rc = 3;
-      fResult = kTRUE;
-    }    
-    else if ( length <= fLengthMin   ||  width <= fWidthMin )
-    {
-      rc = 4;
-      fResult = kTRUE;
-    }    
-
-    fCut[rc]++;
-
+    if (numusedpixels>=fUsedPixelsMax || numcorepixels<=fCorePixelsMin)
+        return Set(1);
+
+    if (size<=fSizeMin )
+        return Set(2);
+
+    if (dist<fDistMin || dist>fDistMax)
+        return Set(3);
+
+    if (length<=fLengthMin || width<=fWidthMin)
+        return Set(4);
+
+    fCut[0]++;
     return kTRUE;
 }
@@ -191,5 +186,5 @@
 //  Prints some statistics about the Standard selections.
 //
-Bool_t MFCT1SelStandard::PostProcess()
+Int_t MFCT1SelStandard::PostProcess()
 {
     if (GetNumExecutions()==0)
Index: trunk/MagicSoft/Mars/mfilter/MFCT1SelStandard.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFCT1SelStandard.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFCT1SelStandard.h	(revision 2206)
@@ -43,9 +43,11 @@
     Bool_t       fResult;
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
     Bool_t IsExpressionTrue() const  { return fResult; }
+
+    Bool_t Set(Int_t rc);
 
 public:
Index: trunk/MagicSoft/Mars/mfilter/MFDataChain.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFDataChain.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFDataChain.cc	(revision 2206)
@@ -76,5 +76,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MFDataChain::PreProcess(MParList *plist)
+Int_t MFDataChain::PreProcess(MParList *plist)
 {
     return fData.PreProcess(plist);
@@ -83,5 +83,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MFDataChain::Process()
+Int_t MFDataChain::Process()
 {
     switch (fFilterType)
Index: trunk/MagicSoft/Mars/mfilter/MFDataChain.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFDataChain.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFDataChain.h	(revision 2206)
@@ -30,4 +30,7 @@
     void StreamPrimitive(ofstream &out) const;
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
 public:
     MFDataChain(const char *member, const char type, const Double_t val,
@@ -35,6 +38,4 @@
 
     Bool_t IsExpressionTrue() const { return fResult; }
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
 
     void Print(Option_t *opt = "") const;
Index: trunk/MagicSoft/Mars/mfilter/MFDataMember.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFDataMember.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFDataMember.cc	(revision 2206)
@@ -76,5 +76,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MFDataMember::PreProcess(MParList *plist)
+Int_t MFDataMember::PreProcess(MParList *plist)
 {
     return fData.PreProcess(plist);
@@ -83,5 +83,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MFDataMember::Process()
+Int_t MFDataMember::Process()
 {
     switch (fFilterType)
Index: trunk/MagicSoft/Mars/mfilter/MFDataMember.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFDataMember.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFDataMember.h	(revision 2206)
@@ -30,4 +30,7 @@
     void StreamPrimitive(ofstream &out) const;
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
 public:
     MFDataMember(const char *member, const char type, const Double_t val,
@@ -35,6 +38,4 @@
 
     Bool_t IsExpressionTrue() const { return fResult; }
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
 
     void Print(Option_t *opt = "") const;
Index: trunk/MagicSoft/Mars/mfilter/MFEnergySlope.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFEnergySlope.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFEnergySlope.cc	(revision 2206)
@@ -82,5 +82,5 @@
 //  Normalization factor is computed
 //
-Bool_t MFEnergySlope::PreProcess(MParList *pList)
+Int_t MFEnergySlope::PreProcess(MParList *pList)
 {
  
@@ -142,5 +142,5 @@
 //  run header (requires reflector ver.>0.6 and camera ver.>0.6) 
 //
-Bool_t MFEnergySlope::Process()
+Int_t MFEnergySlope::Process()
 {
   fResult = kTRUE;
Index: trunk/MagicSoft/Mars/mfilter/MFEnergySlope.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFEnergySlope.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFEnergySlope.h	(revision 2206)
@@ -31,6 +31,6 @@
     Float_t fN0;            // Normalization factor
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
 
 public:
Index: trunk/MagicSoft/Mars/mfilter/MFEventSelector.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFEventSelector.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFEventSelector.cc	(revision 2206)
@@ -107,5 +107,5 @@
 // PreProcess all filters.
 //
-Bool_t MFEventSelector::PreProcess(MParList *plist)
+Int_t MFEventSelector::PreProcess(MParList *plist)
 {
     memset(fErrors, 0, sizeof(fErrors));
@@ -145,5 +145,5 @@
 // Process all filters.
 //
-Bool_t MFEventSelector::Process()
+Int_t MFEventSelector::Process()
 {
     Int_t rc;
@@ -175,5 +175,5 @@
 //  Postprocess all filters.
 //
-Bool_t MFEventSelector::PostProcess()
+Int_t MFEventSelector::PostProcess()
 {
     //---------------------------------
Index: trunk/MagicSoft/Mars/mfilter/MFEventSelector.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFEventSelector.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFEventSelector.h	(revision 2206)
@@ -27,7 +27,7 @@
     void StreamPrimitive(ofstream &out) const;
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
     enum { kNumTotalFromFile = BIT(14) };
Index: trunk/MagicSoft/Mars/mfilter/MFEventSelector2.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFEventSelector2.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFEventSelector2.cc	(revision 2206)
@@ -327,5 +327,5 @@
 //  5) Repreprocess the reading task.
 //
-Bool_t MFEventSelector2::PreProcess(MParList *parlist)
+Int_t MFEventSelector2::PreProcess(MParList *parlist)
 {
     MTaskList *tasklist = (MTaskList*)parlist->FindObject("MTaskList");
@@ -374,5 +374,5 @@
 //     gRandom->Rndm()*fIs[bin]<=fNom[bin]
 //
-Bool_t MFEventSelector2::Process()
+Int_t MFEventSelector2::Process()
 {
     fResult = kFALSE;
@@ -411,5 +411,5 @@
 // Update online display if set.
 //
-Bool_t MFEventSelector2::PostProcess()
+Int_t MFEventSelector2::PostProcess()
 {
     if (!fCanvas || !fDisplay)
Index: trunk/MagicSoft/Mars/mfilter/MFEventSelector2.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFEventSelector2.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFEventSelector2.h	(revision 2206)
@@ -48,7 +48,7 @@
     Bool_t PreProcessData(MParList *parlist);
 
-    Bool_t PreProcess(MParList *parlist);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *parlist);
+    Int_t Process();
+    Int_t PostProcess();
 
 public:
Index: trunk/MagicSoft/Mars/mfilter/MFParticleId.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFParticleId.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFParticleId.cc	(revision 2206)
@@ -91,5 +91,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MFParticleId::PreProcess(MParList *pList)
+Int_t MFParticleId::PreProcess(MParList *pList)
 {
     if (fMcEvt)
@@ -106,5 +106,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MFParticleId::Process()
+Int_t MFParticleId::Process()
 {
     const Int_t id = fMcEvt->GetPartId();
Index: trunk/MagicSoft/Mars/mfilter/MFParticleId.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFParticleId.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFParticleId.h	(revision 2206)
@@ -32,4 +32,7 @@
     void StreamPrimitive(ofstream &out) const;
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
 public:
     MFParticleId(const char *cname="MMcEvt", const char type='=', const Int_t val=0,
@@ -39,6 +42,4 @@
 
     Bool_t IsExpressionTrue() const;
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
 
     ClassDef(MFParticleId, 1) // A Filter for the (corsika) particle Id
Index: trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.cc	(revision 2206)
@@ -87,5 +87,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MFTriggerLvl1::PreProcess(MParList *pList)
+Int_t MFTriggerLvl1::PreProcess(MParList *pList)
 {
     if (fMcTrig)
@@ -102,5 +102,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MFTriggerLvl1::Process()
+Int_t MFTriggerLvl1::Process()
 {
     const Int_t lvl1 = fMcTrig->GetFirstLevel();
Index: trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFTriggerLvl1.h	(revision 2206)
@@ -32,4 +32,7 @@
     void StreamPrimitive(ofstream &out) const;
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
 public:
     MFTriggerLvl1(const char *cname="MMcTrig", const char type='>', const Int_t val=0,
@@ -39,6 +42,4 @@
 
     Bool_t IsExpressionTrue() const;
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
 
     ClassDef(MFTriggerLvl1, 1) // A Filter for the Level 1 Trigger
Index: trunk/MagicSoft/Mars/mfilter/MFTriggerLvl2.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFTriggerLvl2.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFTriggerLvl2.cc	(revision 2206)
@@ -88,5 +88,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MFTriggerLvl2::PreProcess(MParList *pList)
+Int_t MFTriggerLvl2::PreProcess(MParList *pList)
 {
     if (fcell)
@@ -104,5 +104,5 @@
 // --------------------------------------------------------------------------
 //
-Bool_t MFTriggerLvl2::Process()
+Int_t MFTriggerLvl2::Process()
 {
 
Index: trunk/MagicSoft/Mars/mfilter/MFTriggerLvl2.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFTriggerLvl2.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFTriggerLvl2.h	(revision 2206)
@@ -38,4 +38,7 @@
     void StreamPrimitive(ofstream &out) const;
 
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
 public:
 
@@ -46,6 +49,4 @@
 
     Bool_t IsExpressionTrue() const;
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
 
     ClassDef(MFTriggerLvl2, 1) // A Filter for the Level 2 Trigger
Index: trunk/MagicSoft/Mars/mfilter/MFilterList.cc
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFilterList.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFilterList.cc	(revision 2206)
@@ -66,4 +66,7 @@
     fTitle = title ? title : gsDefTitle.Data();
 
+    gROOT->GetListOfCleanups()->Add(&fFilters);
+    fFilters.SetBit(kMustCleanup);
+
     fFilterType = kEAnd;
 
@@ -168,4 +171,5 @@
     *fLog << inf << "Adding " << name << " to " << GetName() << "... " << flush;
 
+    filter->SetBit(kMustCleanup);
     fFilters.Add(filter);
 
@@ -180,5 +184,5 @@
 // PreProcesses all filters in the list
 //
-Bool_t MFilterList::PreProcess(MParList *pList)
+Int_t MFilterList::PreProcess(MParList *pList)
 {
     TIter Next(&fFilters);
@@ -204,5 +208,5 @@
 // Processes (updates) all filters in the list.
 //
-Bool_t MFilterList::Process()
+Int_t MFilterList::Process()
 {
     TIter Next(&fFilters);
@@ -224,5 +228,5 @@
 // PostProcesses all filters in the list.
 //
-Bool_t MFilterList::PostProcess()
+Int_t MFilterList::PostProcess()
 {
     TIter Next(&fFilters);
Index: trunk/MagicSoft/Mars/mfilter/MFilterList.h
===================================================================
--- trunk/MagicSoft/Mars/mfilter/MFilterList.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mfilter/MFilterList.h	(revision 2206)
@@ -45,11 +45,11 @@
     Bool_t IsExpressionTrue() const;
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
-
     void Print(Option_t *opt = "") const;
     TString GetRule() const { return GetRule(""); }
     TString GetRule(Option_t *opt) const;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
     ClassDef(MFilterList, 1)		// List to combine several filters logically
Index: trunk/MagicSoft/Mars/mgui/MCamEvent.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamEvent.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mgui/MCamEvent.cc	(revision 2206)
@@ -30,3 +30,6 @@
 #include "MCamEvent.h"
 
+#include "MGeomCam.h"
+
 ClassImp(MCamEvent);
+
Index: trunk/MagicSoft/Mars/mgui/MCamEvent.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamEvent.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mgui/MCamEvent.h	(revision 2206)
@@ -18,8 +18,8 @@
 {
 public:
-    virtual Bool_t GetPixelContent(Float_t &val, Int_t idx, Float_t ratio=1, Int_t type=0) const = 0;
+    virtual Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const = 0;
     virtual void   DrawPixelContent(Int_t num) const = 0;
 
-    ClassDef(MCamEvent, 0)    // A hexagon for MAGIC
+    ClassDef(MCamEvent, 0) // A camera event
 };
 
Index: trunk/MagicSoft/Mars/mhist/MFillH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 2206)
@@ -360,5 +360,5 @@
 // with the same type as the given object name.
 //
-Bool_t MFillH::PreProcess(MParList *pList)
+Int_t MFillH::PreProcess(MParList *pList)
 {
     if (fIndex)
@@ -467,5 +467,5 @@
 // Fills the data from the parameter conatiner into the histogram container
 //
-Bool_t MFillH::Process()
+Int_t MFillH::Process()
 {
     if (fIndex)
@@ -485,5 +485,5 @@
 // has been filled into the histogram.
 //
-Bool_t MFillH::PostProcess()
+Int_t MFillH::PostProcess()
 {
     //
Index: trunk/MagicSoft/Mars/mhist/MFillH.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MFillH.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mhist/MFillH.h	(revision 2206)
@@ -59,7 +59,7 @@
     void SetWeight(const char *name) { fWeightName = name; }
 
-    Bool_t PreProcess(MParList *pList);
-    Bool_t Process();
-    Bool_t PostProcess();
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
 
     ClassDef(MFillH, 2) // Task to fill a histogram with data from a parameter container
Index: trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc	(revision 2205)
+++ trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc	(revision 2206)
@@ -36,5 +36,5 @@
 
 #include "MParList.h"
-#include "MCerPhotEvt.h"
+#include "MCamEvent.h"
 #include "MCamDisplay.h"
 
@@ -48,26 +48,9 @@
 // --------------------------------------------------------------------------
 //
-// Reset all pixels to 0 and reset fEntries to 0.
-//
-void MHCerPhotEvt::Clear(const Option_t *)
-{
-    fSum.Reset();
-//    fSum.InitSize(577);
-    for (int i=0; i<577; i++)
-    {
-        fSum.AddPixel(i, 0, 0);
-        fSum[i].SetPixelUnused();
-    }
-    fSum.FixSize();
-    fEntries = 0;
-}
-
-// --------------------------------------------------------------------------
-//
 // Initialize the name and title of the task.
 // Resets the sum histogram
 //
 MHCerPhotEvt::MHCerPhotEvt(const char *name, const char *title)
-    : fCam(NULL), fEvt(NULL), fDispl(NULL)
+    : fSum(NULL), fEvt(NULL)
 {
     //
@@ -76,6 +59,4 @@
     fName  = name  ? name  : "MHCerPhotEvt";
     fTitle = title ? title : "Average of MCerPhotEvts";
-
-    Clear();
 }
 
@@ -86,6 +67,6 @@
 MHCerPhotEvt::~MHCerPhotEvt()
 {
-    if (fDispl)
-        delete fDispl;
+    if (fSum)
+        delete fSum;
 }
 
@@ -99,13 +80,15 @@
 Bool_t MHCerPhotEvt::SetupFill(const MParList *plist)
 {
-    fEvt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
+    fEvt = (MCamEvent*)plist->FindObject(fNameEvt, "MCamEvent");
     if (!fEvt)
         *fLog << warn << GetDescriptor() << ": No MCerPhotEvt available..." << endl;
 
-    fCam = (MGeomCam*)plist->FindObject("MGeomCam");
-    if (!fCam)
+    MGeomCam *cam = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!cam)
         *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
 
-    Clear();
+    if (fSum)
+        delete (fSum);
+    fSum = new MCamDisplay(*cam, fNameEvt+";avg", fNameEvt+" Avarage");
 
     return kTRUE;
@@ -118,5 +101,5 @@
 Bool_t MHCerPhotEvt::Fill(const MParContainer *par, const Stat_t w)
 {
-    const MCerPhotEvt *evt = par ? (MCerPhotEvt*)par : fEvt;
+    const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
     if (!evt)
     {
@@ -124,18 +107,5 @@
         return kFALSE;
     }
-
-    const UInt_t n = evt->GetNumPixels();
-
-    for (UInt_t idx=0; idx<n; idx++)
-    {
-        Float_t val;
-        if (!evt->GetPixelContent(val, idx))
-            continue;
-
-        fSum[idx].SetPixelUsed();
-        fSum[idx].AddNumPhotons(val);
-    }
-
-    fEntries++;
+    fSum->AddCamContent(*evt);
 
     return kTRUE;
@@ -148,11 +118,9 @@
 Bool_t MHCerPhotEvt::Finalize()
 {
-    if (fEntries<1)
-        *fLog << warn << "WARNING - " << GetDescriptor() << " doesn't contain entries." << endl;
-    else
-        fSum.Scale(fEntries);
+    if (fSum->GetEntries()>0)
+        fSum->Scale(1./fSum->GetEntries());
     return kTRUE;
 }
-
+/*
 // --------------------------------------------------------------------------
 //
@@ -161,5 +129,5 @@
 void MHCerPhotEvt::Draw(Option_t *)
 {
-    if (!fCam)
+    if (!fSum)
     {
         *fLog << warn << "WARNING - Cannot draw " << GetDescriptor() << ": No Camera Geometry available." << endl;
@@ -169,4 +137,6 @@
     TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 750, 600);
     pad->SetBorderMode(0);
+    //pad->Divide(1,1);
+    //gPad->SetBorderMode(0);
 
     AppendPad("");
@@ -179,14 +149,13 @@
 void MHCerPhotEvt::Paint(Option_t *option)
 {
-    if (!fCam)
-    {
-        *fLog << warn << "WARNING - Cannot paint " << GetDescriptor() << ": No Camera Geometry available." << endl;
+    if (!fSum)
         return;
-    }
 
-    if (!fDispl)
-        fDispl = new MCamDisplay(fCam);
+    fSum->Paint();
+}
+*/
 
-    fDispl->Fill(fSum);
-    fDispl->Paint();
+TH1 *MHCerPhotEvt::GetHistByName(const TString name)
+{
+    return fSum;
 }
Index: trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.h	(revision 2205)
+++ trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.h	(revision 2206)
@@ -6,19 +6,18 @@
 #endif
 
-#ifndef MARS_MCerPhotEvt
-#include "MCerPhotEvt.h"
-#endif
-
-class TH1D;
 class MCamDisplay;
+class MCamEvent;
 
 class MHCerPhotEvt : public MH
 {
 private:
-    MCerPhotEvt  fSum;      // storing the sum
-    Int_t        fEntries;  // number of entries in the histogram
-    MGeomCam    *fCam;      // the present geometry
-    MCerPhotEvt *fEvt;      //! the current event
-    MCamDisplay *fDispl;    //! the camera display
+    MCamDisplay *fSum;      // storing the sum
+    MCamEvent   *fEvt;      //! the current event
+
+    TString fNameEvt;
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
 
 public:
@@ -26,16 +25,7 @@
     ~MHCerPhotEvt();
 
-    void Clear(const Option_t *o="");
+    void SetNameEvt(const TString name) { fNameEvt = name; }
 
-    Bool_t SetupFill(const MParList *pList);
-    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
-    Bool_t Finalize();
-
-    TH1 *GetHistByName(const TString name) { return NULL; }
-
-    const MCerPhotEvt &GetSum() const { return fSum; }
-
-    void Draw(Option_t *opt="");
-    void Paint(Option_t *option="");
+    TH1 *GetHistByName(const TString name="");
 
     ClassDef(MHCerPhotEvt, 1) // Histogram to sum camera events
