Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 850)
+++ trunk/MagicSoft/Mars/Changelog	(revision 851)
@@ -17,4 +17,27 @@
    * mgui/MParContainer.cc:
      - made Copy-function more readable
+
+   * mhist/MHMcEnergies.[h,cc]:
+     - files added as a container to make handling of several MHMcEnergy easier
+   
+   * mbase/MAGIC.h:
+     - encapsulated include of TROOT
+
+   * mbase/MTaskList.cc:
+     - added SetHasChange and Reset to PostProcess
+
+   * mhist/HistLinkDef.h
+     - added MHMcEnergies
+     
+   * mhist/MHMcEnergy.[h,cc]:
+     - added name and title to constructor
+     - added number to name of container
+   
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - corrected typo in creation of the container names
+   
+   * mraw/MRawEvtData.cc:
+     - Set kCanDelete in Draw function
+   
 
 
Index: trunk/MagicSoft/Mars/macros/getCollArea.C
===================================================================
--- trunk/MagicSoft/Mars/macros/getCollArea.C	(revision 850)
+++ trunk/MagicSoft/Mars/macros/getCollArea.C	(revision 851)
@@ -1,3 +1,3 @@
-void getCollArea(char *filename = "/big0/Maggi/CamData/Gamma/gamma_15_on.root" ) 
+void getCollArea(char *filename = "data/gamma_15_on.root" )
 { 
     // FIXME: Harald, you should tell the people what the result of
@@ -21,5 +21,5 @@
     parlist.AddToList(&tasklist);
 
-    MCollArea *collArea = new MCollArea();
+    MHMcCollectionArea *collArea = new MHMcCollectionArea();
     parlist.AddToList(collArea);
 
Index: trunk/MagicSoft/Mars/macros/getThreshold.C
===================================================================
--- trunk/MagicSoft/Mars/macros/getThreshold.C	(revision 850)
+++ trunk/MagicSoft/Mars/macros/getThreshold.C	(revision 851)
@@ -1,87 +1,74 @@
 void getThreshold( char* filename = "/hdb1/users/jlopez/temp_loop.root")
 {
+    // This macro fill the container MMcEnerThre using the task
+    // MMcEnerThreCalc and shows the results.
 
-  // This macro fill the container MMcEnerThre using the task
-  // MMcEnerThreCalc and shows the results.
+    MParList parlist;
+    MTaskList tasklist;
 
-  MParList parlist;
-  MTaskList tasklist;
+    // Setup the parameter list
+    // - You need create the container MMcEnerThre.
+    //    + You need to put the number of trigger conditions when
+    //      you declarete the MMcEnerThre
+    //    + If you don't put any dimension to MMcEnerThre it works
+    //      taking only the trigger information from MMcTrig
+    // - You can control the number of bins in the energy distribution
+    //   histogram used to compute the energy threshold using
+    //   the SetBins() function.
 
-  // Setup the parameter list
-  // - You need create the container MMcEnerThre.
-  //    · You need to put the number of trigger conditions when
-  //      you declarete the MMcEnerThre
-  //    · If you don't put any dimension to MMcEnerThre it works
-  //      taking only the trigger information from MMcTrig
-  // - You can control the number of bins in the energy distribution
-  //   histogram used to compute the energy threshold using 
-  //   the SetBins() function.
+    Int_t numtrigcond = 5;
+    MHMcEnergies *hists = new MHMcEnergies(numtrigcond);
 
-  Int_t NumTrigCond = 5;
-  MMcEnerThre enerthre(NumTrigCond);
-  enerthre[0].SetBins(60);
-  enerthre[1].SetBins(60);
-  enerthre[2].SetBins(60);
-  enerthre[3].SetBins(60);
-  enerthre[4].SetBins(60);
+    parlist.AddToList(&tasklist);
+    hists->AddEntriesToList(&parlist);
 
-  parlist.AddToList(&tasklist);
-  parlist.AddToList(&enerthre);
+    // Setup the task list
+    // - You need the read and the MMcEnerThreCalc tasks
+    //    + You need to put the number of trigger conditions when
+    //      you declarete the MMcEnerThreCalc
+    //    + If you don't put any dimension to MMcEnerThreCalc it works
+    //      like one dimension MMcEnerThreCalc
 
-  // Setup the task list
-  // - You need the read and the MMcEnerThreCalc tasks
-  //    · You need to put the number of trigger conditions when
-  //      you declarete the MMcEnerThreCalc
-  //    · If you don't put any dimension to MMcEnerThreCalc it works
-  //      like one dimension MMcEnerThreCalc
+    MReadTree read("Events", filename);
 
+    MMcThresholdCalc tcalc(numtrigcond);
 
+    tasklist.AddToList(&read);
+    tasklist.AddToList(&tcalc);
 
-  MReadTree read("Events",filename);
+    MEvtLoop evtloop;
+    evtloop.SetParList(&parlist);
 
-  MMcEnerThreCalc enerthrecalc(NumTrigCond);
-  
-  tasklist.AddToList(&read);
-  tasklist.AddToList(&enerthrecalc);
+    // Begin the loop
 
-  MEvtLoop evtloop;
-  evtloop.SetParList(&parlist);
+    evtloop.Eventloop();
 
-  // Begin the loop
+    // Now you can display the results
 
-  evtloop.Eventloop();
+    TCanvas *c;
 
-  // Now you can display the results
+    c=new TCanvas("c0","Energy distribution for triggered events", 50, 50, 850, 550);
+    hists[0].Print();
+    hists[0].Draw();
+    c->Update();
 
-  gROOT->Reset();
+    c= new TCanvas("c1","Energy distribution for triggered events", 50, 50, 850, 550);
+    hists[1].Print();
+    hists[1].Draw();
+    c->Update();
 
-  c0= new TCanvas("c0","Energy distribution for triggered events",50,50,850,550);
-  enerthre[0].Print();
-  enerthre[0].Draw();
-  c0->Update();
+    c= new TCanvas("c2","Energy distribution for triggered events", 50, 50, 850, 550);
+    hists[2].Print();
+    hists[2].Draw();
+    c->Update();
 
-  c1= new TCanvas("c1","Energy distribution for triggered events",50,50,850,550);
-  enerthre[1].Print();
-  enerthre[1].Draw();
-  c1->Update();
+    c= new TCanvas("c3","Energy distribution for triggered events", 50, 50, 850, 550);
+    hists[3].Print();
+    hists[3].Draw();
+    c->Update();
 
-  c2= new TCanvas("c2","Energy distribution for triggered events",50,50,850,550);
-  enerthre[2].Print();
-  enerthre[2].Draw();
-  c2->Update();
-
-  c3= new TCanvas("c3","Energy distribution for triggered events",50,50,850,550);
-  enerthre[3].Print();
-  enerthre[3].Draw();
-  c3->Update();
-
-  c4= new TCanvas("c4","Energy distribution for triggered events",50,50,850,550);
-  enerthre[4].Print();
-  enerthre[4].Draw();
-  c4->Update();
-
+    c= new TCanvas("c4","Energy distribution for triggered events", 50, 50, 850, 550);
+    hists[4].Print();
+    hists[4].Draw();
+    c->Update();
 }
-
-
-
-
Index: trunk/MagicSoft/Mars/mbase/MAGIC.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MAGIC.h	(revision 850)
+++ trunk/MagicSoft/Mars/mbase/MAGIC.h	(revision 851)
@@ -9,5 +9,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
+#ifndef ROOT_TROOT
 #include <TROOT.h>
+#endif
 
 //
Index: trunk/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 850)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 851)
@@ -65,11 +65,15 @@
 MParContainer& MParContainer::operator=(const MParContainer& rhs)
 {
-    if (this != &rhs) {
-        TObject::operator=(rhs);
-        *fName  = *(rhs.fName);
-        *fTitle = *(rhs.fTitle);
-        fLog    = rhs.fLog;
-        fHasChanged = rhs.fHasChanged;
-    }
+    if (this == &rhs)
+        return *this;
+
+    TObject::operator=(rhs);
+
+    *fName  = *(rhs.fName);
+    *fTitle = *(rhs.fTitle);
+
+    fLog        = rhs.fLog;
+    fHasChanged = rhs.fHasChanged;
+
     return *this;
 }
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 850)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 851)
@@ -227,6 +227,13 @@
     *fLog << "Postprocessing... " << flush;
 
-    // FIXME: At the moment all containers are post processed independ of
+    // FIXME: At the moment all tasks are post processed independ of
     // whether it was preprocessed or not.
+
+    //
+    // Reset the HasChanged flag.
+    // Reset all containers.
+    //
+    fParList->SetHasChanged(kFALSE);
+    fParList->Reset();
 
     //
Index: trunk/MagicSoft/Mars/mhist/HistLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 850)
+++ trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 851)
@@ -10,4 +10,6 @@
 #pragma link C++ class MHStarMap;
 #pragma link C++ class MHMcEnergy;
+#pragma link C++ class MHMcEnergies;
+#pragma link C++ class MHMcCollectionArea;
 
 #pragma link C++ class MFillHFadc;
Index: trunk/MagicSoft/Mars/mhist/MHMcEnergies.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcEnergies.cc	(revision 851)
+++ trunk/MagicSoft/Mars/mhist/MHMcEnergies.cc	(revision 851)
@@ -0,0 +1,59 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Javier Lopez 05/2001 (jlopez@ifae.es)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MHMcEnergies.h" 
+
+#include "MParList.h"
+#include "MHMcEnergy.h"
+
+ClassImp(MHMcEnergies)
+
+MHMcEnergies::MHMcEnergies(const UInt_t count, const char *name, const char *title)
+    : fNum(count)
+{ 
+    //
+    //   default constructor
+    //
+    char aux[25]="MHMcEnergies";
+    sprintf(aux+12, "[%i]", fNum);
+
+    *fName  = name  ? name  : aux;
+    *fTitle = title ? title : "Container for a MC enegry histogram" ;
+
+    fHists = new TClonesArray("MHMcEnergy", fNum);
+
+    for (UInt_t i=0; i<fNum; i++)
+        new ((*fHists)[i]) MHMcEnergy(i);
+}
+
+MHMcEnergies::~MHMcEnergies()
+{
+    delete fHists;
+}
+
+void MHMcEnergies::AddEntriesToList(MParList *plist)
+{
+    for (UInt_t i=0; i<fNum; i++)
+        plist->AddToList((MParContainer*)(*fHists)[i]);
+}
Index: trunk/MagicSoft/Mars/mhist/MHMcEnergies.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcEnergies.h	(revision 851)
+++ trunk/MagicSoft/Mars/mhist/MHMcEnergies.h	(revision 851)
@@ -0,0 +1,37 @@
+#ifndef MHMCENERGIES_H
+#define MHMCENERGIES_H
+
+#ifndef MAGIC_H
+#include "MAGIC.h"
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+#ifndef MPARCONTAINER_H
+#include "MParContainer.h"
+#endif
+#ifndef MHMCENERGY_H
+#include "MHMcEnergy.h"
+#endif
+
+class MParList;
+
+class MHMcEnergies : public MParContainer
+{
+private:
+    UInt_t        fNum;
+    TClonesArray *fHists; // histograms
+
+public:
+
+    MHMcEnergies(const UInt_t count=0, const char *name=NULL, const char *title=NULL);
+    ~MHMcEnergies();
+
+    void AddEntriesToList(MParList *plist);
+
+    MHMcEnergy &operator[](UInt_t idx) { return (MHMcEnergy&)fHists[idx]; }
+
+    ClassDef(MHMcEnergies, 1)  // container to hold several MHMcEnergy histograms
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc	(revision 850)
+++ trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc	(revision 851)
@@ -33,9 +33,15 @@
 ClassImp(MHMcEnergy)
 
-MHMcEnergy::MHMcEnergy(const UInt_t idx)
+MHMcEnergy::MHMcEnergy(const UInt_t idx, const char *name, const char *title)
 { 
     //
     //   default constructor
     //
+    char aux[15]="MHMcEnergy";
+
+    if (idx>0)
+        sprintf(aux+10, ";%i", idx);
+    *fName  = name  ? name  : aux;
+    *fTitle = title ? title : "Container for a MC energy histogram" ;
 
     //  - we initialize the histogram and the gaus function
@@ -43,5 +49,8 @@
     //    root don't allow us to have diferent histograms with the same name
 
-    char aux[15];
+    strcpy(aux, "fLogEnergy");
+    if (idx>0)
+        sprintf(aux+10, ";%i", idx);
+    fLogEner = new TF1(aux, "gaus", 1., 3.);
 
     strcpy(aux, "hLogEnergy");
@@ -49,9 +58,5 @@
         sprintf(aux+10, ";%i", idx);
     hLogEner = new TH1F(aux, "", 100, 0.5, 4.5);
-
-    strcpy(aux, "fLogEnergy");
-    if (idx>0)
-        sprintf(aux+10, ";%i", idx);
-    fLogEner = new TF1(aux, "gaus", 1., 3.);
+    //hLogEner->SetBins(60);
 }
 
Index: trunk/MagicSoft/Mars/mhist/MHMcEnergy.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcEnergy.h	(revision 850)
+++ trunk/MagicSoft/Mars/mhist/MHMcEnergy.h	(revision 851)
@@ -21,5 +21,5 @@
 public:
 
-    MHMcEnergy(const UInt_t idx=0);
+    MHMcEnergy(const UInt_t idx=0, const char *name=NULL, const char *title=NULL);
     ~MHMcEnergy();
 
Index: trunk/MagicSoft/Mars/mhist/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mhist/Makefile	(revision 850)
+++ trunk/MagicSoft/Mars/mhist/Makefile	(revision 851)
@@ -35,5 +35,7 @@
            MHHillas.cc \
            MHStarMap.cc \
-           MHMcEnergy.cc
+           MHMcCollectionArea.cc \
+           MHMcEnergy.cc \
+           MHMcEnergies.cc
 
 SRCS    = $(SRCFILES)
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 850)
+++ trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 851)
@@ -87,5 +87,5 @@
     {
         if (fDimension>1)
-            sprintf(auxname+7, ";%i.", i+1);
+            sprintf(auxname+7, ";%i", i+1);
 
         fMcTrig[i] = (MMcTrig*)pList->FindObject(auxname);
@@ -105,5 +105,5 @@
     {
         if (fDimension>1)
-            sprintf(auxname+10, ";%i.", i+1);
+            sprintf(auxname+10, ";%i", i+1);
 
         fHMcEnergy[i] = (MHMcEnergy*)pList->FindObject(auxname);
Index: trunk/MagicSoft/Mars/mmontecarlo/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/Makefile	(revision 850)
+++ trunk/MagicSoft/Mars/mmontecarlo/Makefile	(revision 851)
@@ -28,6 +28,5 @@
 .SUFFIXES: .c .cc .cxx .h .hxx .o 
 
-SRCFILES = MCollArea.cc \
-	   MCollAreaTrigger.cc \
+SRCFILES = MMcCollectionAreaCalc.cc \
 	   MMcThresholdCalc.cc
 
Index: trunk/MagicSoft/Mars/mmontecarlo/MonteCarloLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MonteCarloLinkDef.h	(revision 850)
+++ trunk/MagicSoft/Mars/mmontecarlo/MonteCarloLinkDef.h	(revision 851)
@@ -5,7 +5,6 @@
 #pragma link off all functions;
 
-#pragma link C++ class MCollArea ; 
-#pragma link C++ class MCollAreaTrigger ; 
-#pragma link C++ class MMcThresholdCalc ;
+#pragma link C++ class MMcThresholdCalc;
+#pragma link C++ class MMcCollectionAreaCalc;
 
 #endif
Index: trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 850)
+++ trunk/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 851)
@@ -244,4 +244,5 @@
         graph->SetMinimum (0) ;
 
+        graph->SetBit(kCanDelete);
         graph->Draw("AC*");
 
@@ -272,4 +273,5 @@
             hist->Fill(0.5+i, (*fHiGainFadcSamples)[i + num*GetNumHiGainSamples()]);
 
+        hist->SetBit(kCanDelete);
         hist->Draw();
 
