Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 892)
+++ trunk/MagicSoft/Mars/Changelog	(revision 893)
@@ -1,3 +1,16 @@
                                                                   -*-*- END -*-*-
+ 2001/07/23: Thomas Bretz
+ 
+   * mmontecarlo/MMcThresholdCalc.[cc,h]:
+     - changed PreProcess action to new stylish lists of containers
+
+   * mhist/Makefile:
+     - removed MEnergies.cc
+
+   * mhist/HistLinkDef.h:
+     - removed MEnergies.cc
+
+
+
  2001/07/20: Thomas Bretz
  
Index: trunk/MagicSoft/Mars/mhist/HistLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 892)
+++ trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 893)
@@ -11,5 +11,4 @@
 #pragma link C++ class MHStarMap;
 #pragma link C++ class MHMcEnergy;
-#pragma link C++ class MHMcEnergies;
 #pragma link C++ class MHMcCollectionArea;
 #pragma link C++ class MHMcRate;
Index: trunk/MagicSoft/Mars/mhist/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mhist/Makefile	(revision 892)
+++ trunk/MagicSoft/Mars/mhist/Makefile	(revision 893)
@@ -39,5 +39,4 @@
            MHMcCollectionArea.cc \
            MHMcEnergy.cc \
-           MHMcEnergies.cc \
 	   MHMcRate.cc
 
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 892)
+++ trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 893)
@@ -58,33 +58,29 @@
 // Default Constructor.
 //
-MMcThresholdCalc::MMcThresholdCalc(const UInt_t dim, const char* name,
+// Specify the number of trigger conditions you want to use.
+// The default is 0.
+//
+// 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
+//
+MMcThresholdCalc::MMcThresholdCalc(const Int_t dim, const char* name,
                                    const char* title) : fDimension(dim)
 {
     *fName  = name  ? name  : "MMcThresholdCalc";
     *fTitle = title ? title : "Task to calculate the energy threshold from Monte Carlo";
-
-    // Arrays of MMcTrig* and MHMcEnergy* are created in order to be 
-    // able to work with root files with several trigger conditions.
-    fMcTrig     = new MMcTrig*[fDimension];
-    fHMcEnergy  = new MHMcEnergy*[fDimension];
-    fMustDelete = new Bool_t[fDimension];
-
-    for (unsigned int i=0; i<fDimension; i++)
-        fMustDelete[i]=kFALSE;
 }
 
 // -------------------------------------------------------------------------
 //
-// Default Destructor.
+// Destructor.
 //
 MMcThresholdCalc::~MMcThresholdCalc()
 {
-    for (unsigned int i=0; i<fDimension; i++)
-        if (fMustDelete[i])
-            delete fHMcEnergy[i];
+    if (fMcTrig)
+        delete fMcTrig;
 
-    delete fMcTrig;
-    delete fHMcEnergy;
-    delete fMustDelete;
+    if (fEnergy)
+        delete fEnergy;
 }
 
@@ -95,4 +91,5 @@
 Bool_t MMcThresholdCalc::PreProcess(MParList* pList)
 {
+    //
     // This task takes into accout if the root file has one trigger
     // condition (MMcTrig) or severl of them (MMcTrig;#.)
@@ -105,39 +102,20 @@
     }
 
-    char auxname[15]="MMcTrig"; // string to write container names
 
-    for (unsigned int i=0; i<fDimension; i++)
+    const UInt_t from = fDimension<=0 ? -fDimension : 0;
+
+    if (fDimension<=0)
+        fDimension = -fDimension;
+
+    fMcTrig = new TObjArray(pList->FindObjectList("MMcTrig", from, fDimension));
+    if (fMcTrig->GetEntriesFast() != fDimension)
     {
-        if (fDimension>1)
-            sprintf(auxname+7, ";%i", i+1);
-
-        fMcTrig[i] = (MMcTrig*)pList->FindObject(auxname);
-        if (fMcTrig[i])
-            continue;
-
-        *fLog << dbginf << "'MMcTrig";
-        if (fDimension>1)
-            *fLog << ";" << i+1;
-        *fLog << "' not found... aborting." << endl;
-
+        *fLog << dbginf << "Error: Not all requested MMcTrig objects are available...aborting." << endl;
         return kFALSE;
     }
 
-    strcpy(auxname, "MHMcEnergy");
-    for (unsigned int i=0; i<fDimension; i++)
-    {
-        if (fDimension>1&&i!=0)
-            sprintf(auxname+10, ";%i", i);
-
-        fHMcEnergy[i] = (MHMcEnergy*)pList->FindObject(auxname);
-        if (fHMcEnergy[i])
-            continue;
-
-        *fLog << dbginf << "'" << auxname << "' not found in list... creating." << endl;
-
-        fHMcEnergy[i] = new MHMcEnergy(fDimension>1&&i!=0 ? i : 0);
-        fMustDelete[i] = kTRUE;
-        pList->AddToList(fHMcEnergy[i]);
-    }
+    fEnergy = new TObjArray(pList->FindCreateObjList("MHMcEnergy", from, fDimension));
+    if (fMcTrig->GetEntriesFast() != fDimension)
+        return kFALSE;
 
     return kTRUE;
@@ -156,7 +134,7 @@
     const Float_t reciproc = 1./energy;
 
-    for (unsigned int i=0; i<fDimension; i++)
-        if (fMcTrig[i]->GetFirstLevel()>0)
-            fHMcEnergy[i]->Fill(lg10, reciproc);
+    for (Int_t i=0; i<fDimension; i++)
+        if (GetTrig(i)->GetFirstLevel()>0)
+            GetHEnergy(i)->Fill(lg10, reciproc);
 
     return kTRUE;
@@ -170,18 +148,20 @@
 Bool_t MMcThresholdCalc::PostProcess()
 {
-    for (unsigned int i=0; i<fDimension; i++)
+    for (Int_t i=0; i<fDimension; i++)
     {
-      Float_t peak;
-      Float_t sigma;
+        MHMcEnergy &hist = *GetHEnergy(i);
 
-      fHMcEnergy[i]->Fit(1, 3);
-      
-      peak  = fHMcEnergy[i]->GetGaussPeak();
-      sigma = fHMcEnergy[i]->GetGaussSigma();
-      fHMcEnergy[i]->Fit(peak - 2.   *sigma, peak + 2.   *sigma);
-	
-      peak  = fHMcEnergy[i]->GetGaussPeak();
-      sigma = fHMcEnergy[i]->GetGaussSigma();
-      fHMcEnergy[i]->Fit(peak - fSqrt2*sigma, peak + fSqrt2*sigma);
+        Float_t peak;
+        Float_t sigma;
+
+        hist.Fit(1, 3);
+
+        peak  = hist.GetGaussPeak();
+        sigma = hist.GetGaussSigma();
+        hist.Fit(peak - 2.   *sigma, peak + 2.   *sigma);
+
+        peak  = hist.GetGaussPeak();
+        sigma = hist.GetGaussSigma();
+        hist.Fit(peak - fSqrt2*sigma, peak + fSqrt2*sigma);
     }
     return kTRUE;
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.h	(revision 892)
+++ trunk/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.h	(revision 893)
@@ -13,4 +13,7 @@
 #include "MTask.h"
 #endif
+#ifndef ROOT_TObjArray
+#include "TObjArray.h"
+#endif
 
 class MMcEvt;
@@ -21,17 +24,19 @@
 {
 private:
-    UInt_t fDimension;
+    Int_t fDimension;
 
     const MMcEvt  *fMcEvt;       // Container with Monte Carlo information
-    MMcTrig      **fMcTrig;      // Container with Monte Carlo trigger information
-    MHMcEnergy   **fHMcEnergy;   // Container where we save the energy (threshold)
 
-    Bool_t        *fMustDelete;  // delete indicator for selfcreated energy hists
+    TObjArray    *fMcTrig;       // Container with Monte Carlo trigger information
+    TObjArray    *fEnergy;       // Container where we save the energy (threshold)
 
     const static Float_t fSqrt2; // sqrt(2)
 
+    MMcTrig    *GetTrig   (UInt_t i) { return (MMcTrig*)   (*fMcTrig)[i]; }
+    MHMcEnergy *GetHEnergy(UInt_t i) { return (MHMcEnergy*)(*fEnergy)[i]; }
+
 public:
 
-    MMcThresholdCalc(const UInt_t dim = 1,
+    MMcThresholdCalc(const Int_t dim = 0,
                      const char* name = NULL, const char* title = NULL);
     ~MMcThresholdCalc();
