Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 987)
+++ trunk/MagicSoft/Mars/NEWS	(revision 988)
@@ -12,4 +12,11 @@
      object at any state of the analysis, so that the output are several
      states
+
+   - Fixed a bug in the collection area error calculation 
+     (Thanks to Ciro and Abelardo)
+
+   - Fixed a bug which causes merpp to crash in some environments
+
+   - Speed up reading MC files alot, by choosing the right Branches/Leafs
 
 
Index: trunk/MagicSoft/Mars/macros/collarea.C
===================================================================
--- trunk/MagicSoft/Mars/macros/collarea.C	(revision 987)
+++ trunk/MagicSoft/Mars/macros/collarea.C	(revision 988)
@@ -34,17 +34,5 @@
     MTaskList tasklist;
 
-    //
-    // Setup the parameter list.
-    //  - we need to create MCollArea only. The other containers
-    //    are created automatically without loss - we don't have to
-    //    access them-
-    //  - MCollArea must be created by us because we need the pointer
-    //    to it and if it would get created automatically it would also be
-    //    deleted automatically
-    //
     parlist.AddToList(&tasklist);
-
-    MHMcCollectionArea *collArea = new MHMcCollectionArea;
-    parlist.AddToList(collArea);
 
     //
@@ -64,5 +52,4 @@
     MTask task;
     tasklist.AddToList(&task);
-
 
     //
@@ -84,4 +71,4 @@
     // filled and can be displayd
     //
-    collArea->Draw();
+    parlist.FindObject("MHMcCollectionArea")->DrawClone();
 }
Index: trunk/MagicSoft/Mars/macros/threshold.C
===================================================================
--- trunk/MagicSoft/Mars/macros/threshold.C	(revision 987)
+++ trunk/MagicSoft/Mars/macros/threshold.C	(revision 988)
@@ -24,5 +24,5 @@
 
 
-void threshold(char* filename="data/CrabNebula_dnsb_09_loop.root")
+void threshold(char* filename="data/camera.root")
 {
     //
@@ -30,5 +30,5 @@
     // MMcThresholdCalc and shows the results.
     //
-    MParList  parlist;
+    MParList parlist;
 
     MTaskList tasklist;
@@ -43,5 +43,10 @@
     //      taking only the trigger information from MMcTrig
     //
-    const UInt_t numtriggerconditions = 4;
+    const UInt_t numtrigcond = 0;
+
+    UInt_t from = numtrigcond>0 ?           1 : -numtrigcond;
+    UInt_t to   = numtrigcond>0 ? numtrigcond : -numtrigcond;
+
+    Int_t dim = to-from+1;
 
     //
@@ -49,10 +54,11 @@
     // and store the histograms in an TObjArray
     //
-    TObjArray *hists = new TObjArray(MParList::CreateObjList("MHMcEnergy", numtriggerconditions));
+    TObjArray hists(MParList::CreateObjList("MHMcEnergy", from, to));
+    hists.SetOwner();
 
     //
     // Check if the list really contains the right number of histograms
     //
-    if (hists->GetEntriesFast() != numtriggerconditions)
+    if (hists.GetEntriesFast() != dim)
         return;
 
@@ -60,5 +66,5 @@
     // Add the histograms to the paramater list.
     //
-    parlist.AddToList(hists);
+    parlist.AddToList(&hists);
 
     //
@@ -71,6 +77,9 @@
     //      like one dimension MMcThresholdCalc
     //
-    MReadTree        read("Events;7", filename);
-    MMcThresholdCalc calc(numtriggerconditions);
+    MReadTree read("Events", filename);
+    read.UseLeaf("fEnergy");
+    read.UseLeaf("fNumFirstLevel");
+
+    MMcThresholdCalc calc(numtrigcond);
 
     tasklist.AddToList(&read);
@@ -90,5 +99,7 @@
     // Now you can display the results
     //
-    for (UInt_t i=0; i<numtriggerconditions; i++)
-        ((*hists)[i])->Draw();
+    TIter Next(&hists);
+    TObject *obj;
+    while ((obj=Next()))
+        obj->DrawClone();
 }
Index: trunk/MagicSoft/Mars/macros/trigrate.C
===================================================================
--- trunk/MagicSoft/Mars/macros/trigrate.C	(revision 987)
+++ trunk/MagicSoft/Mars/macros/trigrate.C	(revision 988)
@@ -109,7 +109,4 @@
         return;
 
-    TIter Next(&hists);
-    MHMcRate *r=NULL;
-    while ((r=(MHMcRate*)Next()))
-        r->Print();
+    hists.Print();
 }
Index: trunk/MagicSoft/Mars/mbase/MReadTree.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MReadTree.cc	(revision 987)
+++ trunk/MagicSoft/Mars/mbase/MReadTree.cc	(revision 988)
@@ -42,4 +42,6 @@
 // calling MReadTree::UseLeaf.                                             //
 //                                                                         //
+// FIXME: An automatic enabeling scheme would be nice.                     //
+//                                                                         //
 // Later we'll use TChain::SetNotify to notify MReadTree if the TChain     //
 // starts to read a new file.                                              //
@@ -258,5 +260,5 @@
 Bool_t MReadTree::Process()
 {
-    return fChain->GetEntry(fNumEntry++, 0) == 0 ? kFALSE : kTRUE;
+    return fChain->GetEntry(fNumEntry++) == 0 ? kFALSE : kTRUE;
 }
 
Index: trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 987)
+++ trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 988)
@@ -67,5 +67,69 @@
 #include "MTask.h"
 
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MFilter.h"
+
 ClassImp(MTask);
+
+MTask::MTask(const char *name, const char *title)
+    : fFilter(NULL), fIsPreprocessed(kFALSE), fNumExecutions()
+{
+    *fName  = name  ? name  : "MTask";
+    *fTitle = title ? title : "Base class for all tasks (dummy task).";
+}
+
+// --------------------------------------------------------------------------
+//
+// Mapper function for PreProcess.
+// Sets the preprocessed flag dependend on the return value of PreProcess.
+//
+Bool_t MTask::CallPreProcess(MParList *plist)
+{
+    if (!PreProcess(plist))
+        return kFALSE;
+
+    fIsPreprocessed = kTRUE;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Mapper function for Process.
+// Executes Process dependent on the existance of a filter and its possible
+// return value.
+// If Process is executed, the execution counter is increased.
+//
+inline Bool_t MTask::CallProcess()
+{
+    //
+    // Check for the existance of a filter. If a filter is existing
+    // check for its value. If the value is kFALSE don't execute
+    // this task.
+    //
+    const Bool_t exec = fFilter ? fFilter->IsExpressionTrue() : kTRUE;
+
+    if (!exec)
+        return kTRUE;
+
+    fNumExecutions++;
+    return Process();
+}
+
+// --------------------------------------------------------------------------
+//
+// Mapper function for PreProcess.
+// Calls Postprocess dependent on the state of the preprocessed flag,
+// resets this flag.
+//
+Bool_t MTask::CallPostProcess()
+{
+    if (!fIsPreprocessed)
+        return kTRUE;
+
+    fIsPreprocessed = kFALSE;
+    return PostProcess();
+}
 
 // --------------------------------------------------------------------------
@@ -105,3 +169,15 @@
 }
 
-
+// --------------------------------------------------------------------------
+//
+// Prints the number of times this task has been processed.
+// For convinience the lvl argument results in a number of spaces at the
+// beginning of the line. So that the structur of a tasklist can be
+// identified.
+//
+void MTask::PrintStatistics(const Int_t lvl) const
+{
+    *fLog << setw(lvl) << " " << GetName() << " [";
+    *fLog << ClassName() << "] \t" << fNumExecutions;
+    *fLog << endl;
+}
Index: trunk/MagicSoft/Mars/mbase/MTask.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.h	(revision 987)
+++ trunk/MagicSoft/Mars/mbase/MTask.h	(revision 988)
@@ -23,16 +23,5 @@
 
     Bool_t fIsPreprocessed; // Indicates the success of the PreProcessing (set by MTaskList)
-
-public:
-    MTask() : fFilter(NULL), fIsPreprocessed(kFALSE) {}
-    ~MTask()
-    {
-    }
-
-    const MFilter *GetFilter() const { return fFilter; }
-    void SetFilter(const MFilter *filter) { fFilter=filter; }
-
-    Bool_t IsPreprocessed() const { return fIsPreprocessed; }
-    void SetIsPreprocessed(Bool_t state=kTRUE) { fIsPreprocessed = state; }
+    UInt_t fNumExecutions;  // Number of Excutions
 
     virtual Bool_t PreProcess(MParList *pList);
@@ -40,4 +29,17 @@
     virtual Bool_t PostProcess();
 
+public:
+    MTask(const char *name=NULL, const char *title=NULL);
+    virtual ~MTask()
+    {
+    }
+
+    void SetFilter(const MFilter *filter) { fFilter=filter; }
+    virtual void PrintStatistics(const Int_t lvl=0) const;
+
+    Bool_t CallPreProcess(MParList *plist);
+    Bool_t CallProcess();
+    Bool_t CallPostProcess();
+
     ClassDef(MTask, 0)		//Abstract base class for a task
 };
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 987)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 988)
@@ -49,5 +49,5 @@
 #include "MLog.h"
 #include "MLogManip.h"
-#include "MFilter.h"
+
 #include "MParList.h"
 #include "MInputStreamID.h"
@@ -232,8 +232,6 @@
         *fLog << task->GetName() << "... " << flush;
 
-        if (!task->PreProcess(fParList))
+        if (!task->CallPreProcess(fParList))
             return kFALSE;
-
-        task->SetIsPreprocessed();
     }
 
@@ -278,20 +276,11 @@
 
         //
-        // Check for the existance of a filter. If a filter is existing
-        // check for its value. If the value is kFALSE don't execute
-        // this task.
-        //
-        const MFilter *filter = task->GetFilter();
-
-        const Bool_t rc = filter ? filter->IsExpressionTrue() : kTRUE;
-
-        if (!rc)
-            continue;
-
-        //
-        // if it has the right stream id execute the Process() function
+        // if it has the right stream id execute the CallProcess() function
         // and check what the result of it is.
-        //
-        switch (task->Process())
+        // The CallProcess() function increases the execution counter and
+        // calls the Process() function dependent on the existance and
+        // return value of a filter.
+        //
+        switch (task->CallProcess())
         {
         case kTRUE:
@@ -312,4 +301,7 @@
             //
             return kTRUE;
+
+        default:
+            *fLog << "MTaskList::Process: Unknown return value from MTask::Process()... ignored." << endl;
         }
     }
@@ -349,14 +341,8 @@
     while ( (task=(MTask*)Next()) )
     {
-        if (!task->IsPreprocessed())
-            continue;
+        if (!task->CallPostProcess())
+            return kFALSE;
 
         *fLog << task->GetName() << "... " << flush;
-
-        //
-        // FIXME: should we only skip this task?
-        //
-        if (!task->PostProcess())
-            return kFALSE;
     }
 
@@ -367,7 +353,46 @@
 
 // --------------------------------------------------------------------------
-void MTaskList::Print(Option_t *t)
-{
-    *fLog << "TaskList: " << this->GetName() << " <" <<  this->GetTitle() << ">" << endl;
+//
+//  Prints the number of times all the tasks in the list has been.
+//  For convinience the lvl argument results in a number of spaces at the
+//  beginning of the line. So that the structur of a tasklist can be
+//  identified. Use MTaskList::PrintStatistics without an argument.
+//
+void MTaskList::PrintStatistics(const Int_t lvl) const
+{
+    if (lvl==0)
+    {
+        *fLog << endl;
+        *fLog << "Execution Statistics: " << endl;
+        *fLog << "---------------------" << endl;
+        *fLog << GetName() << " [" << ClassName() << "]" << endl;
+    }
+    else
+    {
+        *fLog << setw(lvl) << " " << GetName() << " [";
+        *fLog << ClassName() << "]" << endl;
+    }
+
+    //
+    //  create the Iterator for the TaskList
+    //
+    TIter Next(&fTasks);
+
+    MTask *task=NULL;
+    //
+    //  loop over all tasks for postprocessing
+    //  only tasks which have successfully been preprocessed are postprocessed.
+    //
+    while ( (task=(MTask*)Next()) )
+        task->PrintStatistics(lvl+1);
+
+    if (lvl==0)
+        *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+void MTaskList::Print(Option_t *t) const
+{
+    *fLog << "TaskList: " << GetName() << " <" << GetTitle() << ">" << endl;
 
     fTasks.Print();
Index: trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 987)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 988)
@@ -27,4 +27,7 @@
     MParList      *fParList;
 
+    UInt_t *fCntContinue;
+    UInt_t *fCntTrue;
+
     enum { kIsOwner = BIT(14) };
 
@@ -46,5 +49,6 @@
     Bool_t PostProcess();
 
-    void Print(Option_t *opt = "");
+    void Print(Option_t *opt = "") const;
+    void PrintStatistics(const Int_t lvl=0) const;
     void SetOwner(Bool_t enable=kTRUE);
 
Index: trunk/MagicSoft/Mars/mdatacheck/MShowSpect.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MShowSpect.cc	(revision 987)
+++ 	(revision )
@@ -1,84 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
-!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
-!
-!   Copyright: MAGIC Software Development, 2000-2001
-!
-!
-\* ======================================================================== */
-
-#include "MShowSpect.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-#include "MParList.h"      // MParList
-#include "MGDisplayAdc.h"  // MGDisplayAdc
-
-
-////////////////////////////////////////////////////////////////////////
-//
-//  MGShowSpect.h
-//
-//  A Gui Task to show the raw ADC values in the histograms
-//
-
-ClassImp(MShowSpect)
-
-MShowSpect::MShowSpect(const char *nameHist, const char *name, const char *title)
-{
-    //
-    // default constructor
-    //
-
-    *fName  = name ? name : ClassName();
-    *fTitle = title ? title : "Task to ??? (Harald?)";
-
-    strcpy( fHistName, nameHist ) ;
-} 
-
-
-Bool_t MShowSpect::PreProcess(MParList *pList)
-{
-  //
-  //   Do the preprocessing for MShowSpect
-  // 
-  //   Connects Histogramms in the MHFadcCam container as the input
-  //
-
-  fHists = (MHFadcCam*) pList->FindObject( fHistName );
-  
-  if (!fHists)
-    {
-        *fLog << dbginf << " Error: MHFadcCam '" << fHistName << "' not found!" << endl;
-        return kFALSE;
-    }
-  
-  return kTRUE;
-} 
-
-
-Bool_t MShowSpect::PostProcess()
-{
-  //   just start the gui for displaying the adc spectra
-
-  new MGDisplayAdc(fHists, gClient->GetRoot(), gClient->GetRoot(), 600, 600);
-
-  return kTRUE;
-} 
-
Index: trunk/MagicSoft/Mars/mdatacheck/MShowSpect.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MShowSpect.h	(revision 987)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#ifndef MSHOWSPECT_H
-#define MSHOWSPECT_H
-
-#ifndef MAGIC_H
-#include "MAGIC.h"
-#endif
-
-#ifndef MTASK_H
-#include "MTask.h"
-#endif
-
-class MGDisplayAdc;
-class MHFadcCam;
-class MParList ;
-
-class MShowSpect : public MTask 
-{
-private:
-    char       fHistName[256] ;
-
-    MHFadcCam *fHists;		// Pointer to Container with the histograms
-  
- public:
-  
-     MShowSpect(const char* histName,
-                const char *name=NULL, const char *title=NULL);
-  
-     Bool_t PreProcess(MParList * pList);
-     Bool_t PostProcess();
-
-     ClassDef(MShowSpect, 0)	// Fill the raw ADC in the histograms
-};
-
-#endif
-
-
-
Index: trunk/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.cc
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.cc	(revision 987)
+++ 	(revision )
@@ -1,136 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
-!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
-!
-!   Copyright: MAGIC Software Development, 2000-2001
-!
-!
-\* ======================================================================== */
-
-#include "MViewAdcSpectra.h" 
-
-#include <iostream.h>
-
-#include "MParList.h"
-#include "MTaskList.h"
-#include "MEvtLoop.h"
-
-#include "MRawRunHeader.h"
-#include "MRawEvtHeader.h"
-#include "MRawEvtData.h"
-#include "MRawCrateArray.h"
-#include "MTime.h"
-
-#include "MReadTree.h" 
-#include "MDumpEvtHeader.h" 
-#include "MFillHFadc.h"
-#include "MShowSpect.h" 
-#include "MHFadcCam.h"
-
-ClassImp(MViewAdcSpectra);
-
-// ================================================================================
-//
-// default constructor
-//
-MViewAdcSpectra::MViewAdcSpectra() 
-{
-   fHistosAdc = new MHFadcCam;
-}
-
-// ================================================================================
-//
-// default destructor
-//
-MViewAdcSpectra::~MViewAdcSpectra() 
-{
-    delete fHistosAdc;
-} 
-
-
-// ================================================================================
-//
-//   This job reads in the FADC data from all events and fills
-//   the spectrum for each pmt pixel.
-//
-Bool_t MViewAdcSpectra::AdcSpectra(Char_t *inputfile, Char_t *treeName)
-{
-    cout << "MViewAdcSpectra:: Analyse the tree '" << treeName << "'";
-    cout << "in the file '" << inputfile << "'" << endl;
-
-    //
-    // create a (empty) list of parameters which can be used by the tasks
-    // and an (empty) list of tasks which should be executed
-    // connect them in the required way.
-    //
-
-    //
-    //   create the data containers for the raw data
-    //
-    MParList plist;
-
-    MRawRunHeader runheader;
-    plist.AddToList(&runheader);
-
-    MRawEvtHeader evtheader;
-    plist.AddToList(&evtheader);
-
-    MRawEvtData evtdata;
-    plist.AddToList(&evtdata);
-
-    MRawCrateArray cratearray;
-    plist.AddToList(&cratearray);
-
-    MTime evttime("MTime");
-    plist.AddToList(&evttime);
-
-    plist.AddToList(fHistosAdc);
-
-    //
-    // set up the tasks for this job
-    //
-    MTaskList tasks;
-    plist.AddToList(&tasks);
-
-    MReadTree readin(treeName, inputfile);
-    tasks.AddToList(&readin);
-
-    //
-    //  MDumpEvtHeader *dumpheader = new MDumpEvtHeader() ;
-    //  tasks->AddToList( dumpheader ) ;
-    //
-    MFillHFadc fillspect;
-    tasks.AddToList(&fillspect);
-
-    MShowSpect showspect("MHFadcCam");
-    tasks.AddToList(&showspect);
-
-    //
-    // set up the loop for the processing
-    //
-    MEvtLoop magic;
-    magic.SetParList(&plist);
-
-    //
-    // start the loop running
-    //
-    magic.Eventloop();
-
-    return kTRUE;
-}
Index: trunk/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.h
===================================================================
--- trunk/MagicSoft/Mars/mdatacheck/MViewAdcSpectra.h	(revision 987)
+++ 	(revision )
@@ -1,29 +1,0 @@
-#ifndef MVIEWADCSPECTRA_H
-#define MVIEWADCSPECTRA_H
-
-#ifndef MAGIC_H
-#include "MAGIC.h"
-#endif
-
-class MHFadcCam;
-
-class MViewAdcSpectra
-{
-private:
-    MHFadcCam *fHistosAdc;
-
-public:
-
-     MViewAdcSpectra();
-     virtual ~MViewAdcSpectra();
-  
-     Bool_t AdcSpectra(Char_t *inputFile, Char_t *treeName);
-
-     //  Bool_t CrAdcSpectra ( Char_t *inputFile ) ;
-     //  Bool_t PedTdcSpectra( Char_t *inputFile ) ;
-     //  Bool_t CrTdcSpectra ( Char_t *inputFile ) ;
-
-     ClassDef(MViewAdcSpectra, 0) // Part of the gui, displays Adc Spectras
-};
-
-#endif 
Index: trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc	(revision 987)
+++ trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc	(revision 988)
@@ -219,4 +219,8 @@
     //
     MReadTree reader("Events", fInputFile);
+    reader.UseLeaf("fImpact");
+    reader.UseLeaf("fEnergy");
+    reader.UseLeaf("fNumFirstLevel");
+
     tlist.AddToList(&reader);
 
@@ -288,5 +292,5 @@
     // Check if the list really contains the right number of histograms
     //
-    if (hists.GetEntriesFast() != dim)
+    if (hists.GetEntriesFast() != dim && dim)
         return;
 
@@ -304,9 +308,16 @@
     //
     MReadTree reader("Events", fInputFile);
+    reader.UseLeaf("fImpact");
+    reader.UseLeaf("fEnergy");
+    reader.UseLeaf("fPhi");
+    reader.UseLeaf("fTheta");
+    reader.UseLeaf("fNumFirstLevel");
+    reader.UseLeaf("fPhotElfromShower");
+
     tlist.AddToList(&reader);
 
-    Float_t BgR[10]={660,4,0,0,0,0,0,0,0,0};
-
-    MMcTriggerRateCalc crate(dim, 14, BgR, 100000, 2.75, 10.91e-2);
+    Float_t BgR[10]={660, 4, 0, 0, 0, 0, 0, 0, 0, 0};
+
+    MMcTriggerRateCalc crate(dim, 14, BgR, 100000);
     tlist.AddToList(&crate);
 
@@ -323,8 +334,5 @@
         return;
 
-    TIter Next(&hists);
-    MHMcRate *rate=NULL;
-    while ((rate=(MHMcRate*)Next()))
-        rate->Print();
+    hists.Print();
 }
 
@@ -378,7 +386,9 @@
     //      like one dimension MMcThresholdCalc
     //
-    MReadTree        read("Events", fInputFile);
+    MReadTree read("Events", fInputFile);
+    read.VetoBranch("MRawEvtData");
+    read.VetoBranch("MRawEvtHeader");
+
     MMcThresholdCalc calc(dim);
-
     tlist.AddToList(&read);
     tlist.AddToList(&calc);
@@ -398,7 +408,7 @@
     //
     TIter Next(&hists);
-    MHMcRate *hist=NULL;
-    while ((hist=(MHMcRate*)Next()))
-        hist->DrawClone();
+    TObject *obj;
+    while ((obj=Next()))
+        obj->DrawClone();
 }
 
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 987)
+++ trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 988)
@@ -63,5 +63,5 @@
 // dim < 0: use only condition number dim (eg "MMcTrig;3")
 // dim = 0: use only condition without a number ("MMcTrig")
-// dim > 0: use conditions up to dim
+// dim > 0: use conditions up to dim (from "MMcTrig;1" to "MMcTrig;dim")
 //
 MMcThresholdCalc::MMcThresholdCalc(const Int_t dim, const char* name,
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 987)
+++ trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 988)
@@ -43,4 +43,7 @@
     *fTitle = title ? title : "Task to calc the trigger rate ";
 
+    fMcTrig = NULL;
+    fMcRate = NULL;
+
     fDimension = dim;
 
@@ -91,4 +94,13 @@
 }
 
+MMcTriggerRateCalc::~MMcTriggerRateCalc()
+{
+    if (fMcTrig)
+        delete fMcTrig;
+
+    if (fMcRate)
+        delete fMcRate;
+}
+
 
 // --------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h	(revision 987)
+++ trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h	(revision 988)
@@ -50,4 +50,6 @@
                        const char *name=NULL, const char *title=NULL);
 
+    ~MMcTriggerRateCalc();
+
     Bool_t PreProcess(MParList *pList);
     Bool_t Process();
Index: trunk/MagicSoft/Mars/mraw/MRawCrateData.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawCrateData.h	(revision 987)
+++ trunk/MagicSoft/Mars/mraw/MRawCrateData.h	(revision 988)
@@ -40,5 +40,5 @@
     }
 
-    void Print(Option_t *t=NULL);
+    void Print(Option_t *t=NULL) const;
 
     void ReadEvt(istream& fin);
Index: trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 987)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 988)
@@ -178,5 +178,5 @@
 //  This member function prints all Data of one Event to *fLog.
 //
-void MRawEvtHeader::Print(Option_t *o)
+void MRawEvtHeader::Print(Option_t *o) const
 {
     *fLog << "DAQEvtNr: " << dec << fDAQEvtNumber << "  (";
Index: trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h	(revision 987)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtHeader.h	(revision 988)
@@ -49,5 +49,5 @@
 
     void Clear(Option_t * = NULL);
-    void Print(Option_t * = NULL);
+    void Print(Option_t * = NULL) const;
 
     void FillHeader(UInt_t, Float_t=0);
Index: trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc	(revision 987)
+++ trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc	(revision 988)
@@ -123,5 +123,5 @@
 // print run header information on *fLog
 //
-void MRawRunHeader::Print(Option_t *t)
+void MRawRunHeader::Print(Option_t *t) const
 {
     *fLog << endl;
Index: trunk/MagicSoft/Mars/mraw/MRawRunHeader.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawRunHeader.h	(revision 987)
+++ trunk/MagicSoft/Mars/mraw/MRawRunHeader.h	(revision 988)
@@ -88,5 +88,5 @@
     UShort_t GetNumPixel() const;
 
-    void Print(Option_t *t=NULL);
+    void Print(Option_t *t=NULL) const;
 
     void ReadEvt(istream& fin);
