Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 854)
+++ trunk/MagicSoft/Mars/Changelog	(revision 855)
@@ -1,4 +1,40 @@
                                                                   -*-*- END -*-*-
 
+ 2001/07/05: Thomas Bretz
+
+   * macros/CT1Hillas.C:
+     - changed the wrong pointers to dots.
+     
+   * macros/getThreshold.C:
+     - added some comments
+     - removed the canvas creation
+     - drawing replaced by a loop
+     - changed trigger conditions to 1 (should work with any MC file)
+     
+   * macros/readMagic.C:
+     - changed the event counter to the number of the event in the file
+     - removed icound
+     
+   * manalysis/MPedCalcPedRun.cc, manalysis/MCerPhotCalc.cc,
+     mbase/MParContainer.cc, mbase/MParContainer.h, mbase/MParList.cc,
+     mbase/MParList.h, mbase/MTaskList.cc, mbase/MWriteAsciiFile.cc,
+     mbase/MWriteRootFile.cc, mhist/MFillHFadc.cc, mhist/MFillHHillas.cc,
+     mhist/MFillHStarMap.cc,
+     - changed HasChanged to ReadyToSave
+     
+   * mbase/MReadTree.cc:
+     - added some comments
+     
+   * mhist/MHMcEnergies.h:
+     - fixed bug in []-operator
+     
+   * mhist/MHMcEnergy.cc:
+     - added canvas creation to draw function
+   
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - fixed a bug in the constructor
+ 
+ 
+ 
  2001/06/20: Thomas Bretz
  
Index: trunk/MagicSoft/Mars/macros/getThreshold.C
===================================================================
--- trunk/MagicSoft/Mars/macros/getThreshold.C	(revision 854)
+++ trunk/MagicSoft/Mars/macros/getThreshold.C	(revision 855)
@@ -1,74 +1,53 @@
-void getThreshold( char* filename = "/hdb1/users/jlopez/temp_loop.root")
+void getThreshold( char* filename = "data/oscar_protons.root")
 {
+    //
     // This macro fill the container MMcEnerThre using the task
     // MMcEnerThreCalc and shows the results.
+    //
+    MParList  parlist;
 
-    MParList parlist;
     MTaskList tasklist;
+    parlist.AddToList(&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
+    //      you declarete the MHMcEnergies
+    //    + If you don't put any dimension to MHMcEnergies 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.
+    //
+    const UInt_t numtriggerconditions = 1;
 
-    Int_t numtrigcond = 5;
-    MHMcEnergies *hists = new MHMcEnergies(numtrigcond);
-
-    parlist.AddToList(&tasklist);
+    MHMcEnergies *hists = new MHMcEnergies(numtriggerconditions);
     hists->AddEntriesToList(&parlist);
 
+    //
     // Setup the task list
-    // - You need the read and the MMcEnerThreCalc tasks
+    // - You need the read and the MMcThresholdCalc tasks
+    // - You have to fill the histograms for the Energy threshold
     //    + 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);
+    //      you declarete the MMcThresholdCalc
+    //    + If you don't put any dimension to MMcThresholdCalc it works
+    //      like one dimension MMcThresholdCalc
+    //
+    MReadTree        read("Events", filename);
+    MMcThresholdCalc calc(numtriggerconditions);
 
     tasklist.AddToList(&read);
-    tasklist.AddToList(&tcalc);
+    tasklist.AddToList(&calc);
 
     MEvtLoop evtloop;
     evtloop.SetParList(&parlist);
 
+    //
     // Begin the loop
-
+    //
     evtloop.Eventloop();
 
+    //
     // Now you can display the results
-
-    TCanvas *c;
-
-    c=new TCanvas("c0","Energy distribution for triggered events", 50, 50, 850, 550);
-    hists[0].Print();
-    hists[0].Draw();
-    c->Update();
-
-    c= new TCanvas("c1","Energy distribution for triggered events", 50, 50, 850, 550);
-    hists[1].Print();
-    hists[1].Draw();
-    c->Update();
-
-    c= new TCanvas("c2","Energy distribution for triggered events", 50, 50, 850, 550);
-    hists[2].Print();
-    hists[2].Draw();
-    c->Update();
-
-    c= new TCanvas("c3","Energy distribution for triggered events", 50, 50, 850, 550);
-    hists[3].Print();
-    hists[3].Draw();
-    c->Update();
-
-    c= new TCanvas("c4","Energy distribution for triggered events", 50, 50, 850, 550);
-    hists[4].Print();
-    hists[4].Draw();
-    c->Update();
+    //
+    for (UInt_t i=0; i<numtriggerconditions; i++)
+        ((*hists)[i]).Draw();
 }
Index: trunk/MagicSoft/Mars/macros/readMagic.C
===================================================================
--- trunk/MagicSoft/Mars/macros/readMagic.C	(revision 854)
+++ trunk/MagicSoft/Mars/macros/readMagic.C	(revision 855)
@@ -31,10 +31,9 @@
     MCerPhotEvt &phevt = *(MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
 
-    Int_t icount = 0 ;
     MCamDisplay display(&geomcam) ;
 
     while (read.Process())
     {
-        cout << "Event: " << icount++  << endl  ;
+        cout << "Event #" << read.GetEventNum() ":" << endl;
 
         ncalc.Process();
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 854)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 855)
@@ -113,5 +113,5 @@
     }
 
-    fCerPhotEvt->SetHasChanged();
+    fCerPhotEvt->SetReadyToSave();
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc	(revision 854)
+++ trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc	(revision 855)
@@ -92,5 +92,5 @@
     }
 
-    fPedestals->SetHasChanged();
+    fPedestals->SetReadyToSave();
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 854)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 855)
@@ -51,10 +51,10 @@
 MParContainer::MParContainer(const MParContainer &named)
 {
-    *fName = *(named.fName);
+    *fName  = *(named.fName);
     *fTitle = *(named.fTitle);
 
     fLog = named.fLog;
 
-    fHasChanged = named.fHasChanged;
+    fReadyToSave = named.fReadyToSave;
 }
 
@@ -73,6 +73,6 @@
     *fTitle = *(rhs.fTitle);
 
-    fLog        = rhs.fLog;
-    fHasChanged = rhs.fHasChanged;
+    fLog         = rhs.fLog;
+    fReadyToSave = rhs.fReadyToSave;
 
     return *this;
@@ -103,6 +103,6 @@
     *cont.fTitle = *fTitle;
 
-    cont.fLog        = fLog;
-    cont.fHasChanged = fHasChanged;
+    cont.fLog         = fLog;
+    cont.fReadyToSave = fReadyToSave;
 }
 
Index: trunk/MagicSoft/Mars/mbase/MParContainer.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 854)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 855)
@@ -35,14 +35,14 @@
 
 protected:
-    MLog    *fLog;        //! The general log facility for this object, initialized with the global object
+    MLog    *fLog;         //! The general log facility for this object, initialized with the global object
 
-    TString *fName;       //! parameter container identifier (name)
-    TString *fTitle;      //! parameter container title
+    TString *fName;        //! parameter container identifier (name)
+    TString *fTitle;       //! parameter container title
 
-    Bool_t   fHasChanged; //! should be set to true if the contents of the container is changed somehow
+    Bool_t   fReadyToSave; //! should be set to true if the contents of the container is changed somehow
 
 public:
-    MParContainer(const char *name="", const char *title="") : fLog(&gLog), fHasChanged(kFALSE) { Init(name, title); }
-    MParContainer(const TString &name, const TString &title) : fLog(&gLog), fHasChanged(kFALSE) { Init(name, title); }
+    MParContainer(const char *name="", const char *title="") : fLog(&gLog), fReadyToSave(kFALSE) { Init(name, title); }
+    MParContainer(const TString &name, const TString &title) : fLog(&gLog), fReadyToSave(kFALSE) { Init(name, title); }
     MParContainer(const MParContainer &named);
     MParContainer& operator=(const MParContainer& rhs);
@@ -69,6 +69,6 @@
     virtual void     Reset() {};
 
-    virtual Bool_t HasChanged() { return fHasChanged; }
-    virtual void   SetHasChanged(Bool_t flag=kTRUE) { fHasChanged=flag; }
+    virtual Bool_t IsReadyToSave() { return fReadyToSave; }
+    virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
 
     virtual void AsciiRead(ifstream &fin);
Index: trunk/MagicSoft/Mars/mbase/MParList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 854)
+++ trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 855)
@@ -265,5 +265,5 @@
 //   itself) to unchanged
 //
-void MParList::SetHasChanged(Bool_t flag)
+void MParList::SetReadyToSave(Bool_t flag)
 {
     TIter Next(&fContainer);
@@ -275,7 +275,7 @@
     //
     while ( (cont=(MParContainer*)Next()) )
-        cont->SetHasChanged(flag);
-
-    MParContainer::SetHasChanged(flag);
+        cont->SetReadyToSave(flag);
+
+    MParContainer::SetReadyToSave(flag);
 }
 
Index: trunk/MagicSoft/Mars/mbase/MParList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.h	(revision 854)
+++ trunk/MagicSoft/Mars/mbase/MParList.h	(revision 855)
@@ -45,5 +45,5 @@
 
     void Reset();
-    void SetHasChanged(Bool_t flag=kTRUE);
+    void SetReadyToSave(Bool_t flag=kTRUE);
 
     void Print(Option_t *t = NULL);
Index: trunk/MagicSoft/Mars/mbase/MReadTree.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MReadTree.cc	(revision 854)
+++ trunk/MagicSoft/Mars/mbase/MReadTree.cc	(revision 855)
@@ -35,4 +35,7 @@
 // outside. It makes also possible to go back by decreasing the number.    //
 //                                                                         //
+// If you don't want to start reading the first event you have to call     //
+// MReadTree::SetEventNum after instantiating your MReadTree-object.       //
+//                                                                         //
 /////////////////////////////////////////////////////////////////////////////
 
@@ -178,4 +181,5 @@
         // the actual branch should be stored - enable branch.
         //
+        // FIXME: is it correct, that the pointer is deleted immediatly afterwards?
         branch->SetAddress(&pcont);
     }
@@ -190,4 +194,5 @@
 //  (Remark: The position can also be set by some member functions
 //  If the end of the file is reached the Eventloop is stopped.
+//
 Bool_t MReadTree::Process()
 {
@@ -267,6 +272,6 @@
 // this function makes Process() read event number nr next
 //
-// Remark: You can use this function to set the event number from which
-//         you want to start reading.
+// Remark: You can use this function after instatiating you MReadTree-object
+//         to set the event number from which you want to start reading.
 //
 Bool_t MReadTree::SetEventNum(UInt_t nr)
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 854)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 855)
@@ -59,13 +59,17 @@
 MTaskList::MTaskList(MTaskList &ts)
 {
-  fTasks.AddAll(&ts.fTasks);
-}
-
-// --------------------------------------------------------------------------
-//
-//  create the Iterator over the tasklist
+    fTasks.AddAll(&ts.fTasks);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the logging stream for the all tasks in the list and the tasklist
+//  itself.
 //
 void MTaskList::SetLogStream(MLog *log)
 {
+    //
+    // create the Iterator over the tasklist
+    //
     TIter Next(&fTasks);
 
@@ -167,8 +171,11 @@
 {
     //
-    // Reset the HasChanged flag.
+    // Reset the ReadyToSave flag.
     // Reset all containers.
     //
-    fParList->SetHasChanged(kFALSE);
+    // FIXME: To run a tasklist as a single task in another tasklist we
+    //        have to make sure, that the Parameter list isn't reset.
+    //
+    fParList->SetReadyToSave(kFALSE);
     fParList->Reset();
 
@@ -231,8 +238,11 @@
 
     //
-    // Reset the HasChanged flag.
+    // Reset the ReadyToSave flag.
     // Reset all containers.
     //
-    fParList->SetHasChanged(kFALSE);
+    // FIXME: To run a tasklist as a single task in another tasklist we
+    //        have to make sure, that the Parameter list isn't reset.
+    //
+    fParList->SetReadyToSave(kFALSE);
     fParList->Reset();
 
Index: trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc	(revision 854)
+++ trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc	(revision 855)
@@ -32,5 +32,5 @@
 // This can be the name of the class or a given name, which identifies     //
 // the container in a parameter container list (MParList).                 //
-// The container is writte to the ascii file if its HasChanged flag is     //
+// The container is writte to the ascii file if its ReadyToSave flag is     //
 // set (MParContainer)                                                     //
 //                                                                         //
@@ -102,5 +102,5 @@
 void MWriteAsciiFile::CheckAndWrite() const
 {
-    if (fContainer->HasChanged())
+    if (fContainer->IsReadyToSave())
         fContainer->AsciiWrite(*fOut);
 }
Index: trunk/MagicSoft/Mars/mbase/MWriteRootFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MWriteRootFile.cc	(revision 854)
+++ trunk/MagicSoft/Mars/mbase/MWriteRootFile.cc	(revision 855)
@@ -322,5 +322,5 @@
         // Check for the Write flag
         //
-        if (!entry->GetContainer()->HasChanged())
+        if (!entry->GetContainer()->IsReadyToSave())
             continue;
 
Index: trunk/MagicSoft/Mars/mhist/MFillHFadc.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MFillHFadc.cc	(revision 854)
+++ trunk/MagicSoft/Mars/mhist/MFillHFadc.cc	(revision 855)
@@ -112,5 +112,5 @@
 Bool_t MFillHFadc::PostProcess()
 {
-    fHistos->SetHasChanged();
+    fHistos->SetReadyToSave();
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mhist/MFillHHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MFillHHillas.cc	(revision 854)
+++ trunk/MagicSoft/Mars/mhist/MFillHHillas.cc	(revision 855)
@@ -75,5 +75,5 @@
 Bool_t MFillHHillas::PostProcess()
 {
-    fHistos->SetHasChanged();
+    fHistos->SetReadyToSave();
     return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mhist/MFillHStarMap.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MFillHStarMap.cc	(revision 854)
+++ trunk/MagicSoft/Mars/mhist/MFillHStarMap.cc	(revision 855)
@@ -76,6 +76,5 @@
 Bool_t MFillHStarMap::PostProcess()
 {
-    fHistos->SetHasChanged();
-
+    fHistos->SetReadyToSave();
     return kTRUE;
 } 
Index: trunk/MagicSoft/Mars/mhist/MHMcEnergies.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcEnergies.h	(revision 854)
+++ trunk/MagicSoft/Mars/mhist/MHMcEnergies.h	(revision 855)
@@ -30,5 +30,5 @@
     void AddEntriesToList(MParList *plist);
 
-    MHMcEnergy &operator[](UInt_t idx) { return (MHMcEnergy&)fHists[idx]; }
+    MHMcEnergy &operator[](UInt_t idx) { return *(MHMcEnergy*)(*fHists)[idx]; }
 
     ClassDef(MHMcEnergies, 1)  // container to hold several MHMcEnergy histograms
Index: trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc	(revision 854)
+++ trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc	(revision 855)
@@ -29,4 +29,5 @@
 #include <TH1.h> 
 #include <TF1.h> 
+#include <TCanvas.h>
 #include <TPaveLabel.h> 
 
@@ -58,4 +59,6 @@
         sprintf(aux+10, ";%i", idx);
     hLogEner = new TH1F(aux, "", 100, 0.5, 4.5);
+    hLogEner->SetXTitle("log(E) [GeV]");
+    hLogEner->SetYTitle("dN/dE");
     //hLogEner->SetBins(60);
 }
@@ -75,9 +78,12 @@
 {
     //
+    // 0: don't draw the function (it is drawn together with the histogram)
+    // +: add these function to the list of fits. Don't delete the last fit.
+    //
     // FIXME: R means: use the range specified in the function (xxmin, xxmax are ignored!)
     //        Q means: quiet (why?)
     //
     //
-    hLogEner->Fit(fLogEner->GetName(), "RQ", "", xxmin, xxmax);
+    hLogEner->Fit(fLogEner->GetName(), "Q0+", "", xxmin, xxmax);
 }
 
@@ -92,12 +98,15 @@
     const Float_t sum = min+max;
 
+    TCanvas *c=new TCanvas("Energy Distribution","Energy distribution for triggered events");
+
+    hLogEner->Draw(option);
+
     TPaveLabel* label = new TPaveLabel(2.2, 0.75*sum, 4.4, 0.90*sum, text);
-
-    hLogEner->SetYTitle("dN/dE") ;
-    hLogEner->SetXTitle("log(E) [GeV]") ;
-    hLogEner->Draw(option) ;
     label->SetFillColor(10);
     label->SetTextSize(0.3);
     label->Draw();
+
+    c->Modified();
+    c->Update();
 }
 
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 854)
+++ trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 855)
@@ -57,5 +57,5 @@
 
     for (unsigned int i=0; i<fDimension; i++)
-        fMustDelete=kFALSE;
+        fMustDelete[i]=kFALSE;
 }
 
