Index: trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc	(revision 1800)
+++ trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc	(revision 1911)
@@ -91,5 +91,5 @@
      WARNING:
      Bacause of some strage and hidden dependencies the
-     GetMaiFrame call in the destructor of TGButton may fail if some
+     GetMainFrame call in the destructor of TGButton may fail if some
      of the other gui elemts is deleted first.
      AddFirst adds the buttons at the beginning of the deletion list,
@@ -279,5 +279,5 @@
 void MMonteCarlo::CalculateTriggerRate()
 {
-    // This macro has two input parameter:
+    //
     // dim : = 0 -> root file with 1 trigger condition.
     //       > 0 -> number of trigger condition to be analised 
@@ -285,6 +285,4 @@
     //       < 0 -> selects the -dim trigger condition.
     //
-    // first we have to create our empty lists
-    //
     const Int_t dim = GetDim();
 
@@ -294,26 +292,7 @@
     //
     // Setup the parameter list.
-    //  - we do not need to create any other container. All of them
-    //    are created automatically without loss - we don't have to
-    //    access them-
-    //
-    //  - we need to create MHMcRate only. The other containers
-    //    are created automatically without loss - we don't have to
-    //    access them-
-    //  - MHMcRate 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
-    //  - Actually, depending on using a single trigger option MonteCarlo
-    //    file or a multyple trigger option, a MHMcRate or an array of 
-    //    MHMcRate are needed.
     //
     plist.AddToList(&tlist);
 
-    //
-    // You don't have to add the MHMcRate container here by hand.
-    // But if you want to print or display these containers later on
-    // it is necessary (Rem: No printing or displaying is done in this
-    // macro yet)
-    //
     const UInt_t from = dim>0 ?   1 : -dim;
     const UInt_t to   = dim>0 ? dim : -dim;
@@ -334,10 +313,9 @@
     // produced with the trigger_loop option.
     //
-
     if (dim < 0)
-      ((MHMcRate*)(hists[0]))->SetTriggerCondNum((Short_t)(-dim));
-    else if (dim > 0)
-      for (Short_t i = from ; i <= to; i++)
-	((MHMcRate*)(hists[i-1]))->SetTriggerCondNum(i);
+        ((MHMcRate*)(hists[0]))->SetTriggerCondNum(to);
+    else
+        for (UInt_t i=from; i<=to; i++)
+            ((MHMcRate*)(hists[i-1]))->SetTriggerCondNum(i);
 
     //
@@ -393,4 +371,6 @@
     DestroyProgressBar(bar);
 
+    delete BgR;
+
     if (!rc)
         return;
@@ -403,21 +383,8 @@
     const Int_t dim = GetDim();
 
-    //
-    // This macro fill the container MHMcEnergies using the task
-    // MMcThresholdCalc and shows the results.
-    //
     MParList plist;
 
     MTaskList tlist;
     plist.AddToList(&tlist);
-
-    //
-    // Setup the parameter list
-    // - You need create the container MHMcEnergies.
-    //    + You need to put the number of trigger conditions when
-    //      you declarete the MHMcEnergies
-    //    + If you don't put any dimension to MHMcEnergies it works
-    //      taking only the trigger information from MMcTrig
-    //
 
     //
@@ -453,12 +420,5 @@
     //
     // Setup the task list
-    // - 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 MMcThresholdCalc
-    //    + If you don't put any dimension to MMcThresholdCalc it works
-    //      like one dimension MMcThresholdCalc
-    //
-
+    //
     MReadTree read("Events", fInputFile);
 
@@ -492,8 +452,5 @@
     // Now you can display the results
     //
-    TIter Next(&hists);
-    TObject *obj;
-    while ((obj=Next()))
-    obj->DrawClone();
+    hists.ForEach(TObject, DrawClone)();
 }
 
