Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 1799)
+++ trunk/MagicSoft/Mars/Changelog	(revision 1800)
@@ -4,8 +4,19 @@
     * mmontecarlo/MMcTriggerRateCalc.cc:
       - Fixed: MMCTrigHeader could not be found in the case of camera
-	files containing single trigger condition. To be fixed: selection of
-	one condition within a file with several.
+	files containing single trigger condition.
+
     * macros/trigrate.C
       - no plot is made in the case of single trigger condition.
+
+    * mhist/MHMcRate.[h,cc]
+      - Added member fTriggerCondNum to keep track of what trigger condition
+	corresponds to each MHMcRate object, for the case of files with more
+	than one condition (when running camera in trigger_loop mode). Added
+	also Set and Get procedures for nre member.
+
+    * mmain/MMonteCarlo.cc
+      - Fixed bug: matrix BgR was created with dimension "dim", a number which
+	can be negative. Put "num" instead of "dim".
+
 
  2003/02/25: Thomas Bretz
Index: trunk/MagicSoft/Mars/macros/trigrate.C
===================================================================
--- trunk/MagicSoft/Mars/macros/trigrate.C	(revision 1799)
+++ trunk/MagicSoft/Mars/macros/trigrate.C	(revision 1800)
@@ -131,4 +131,15 @@
         return;
 
+    // Set for each MHMcRate object the trigger condition number in the 
+    // camera file (for the case of camera files with several conditions,
+    // 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);
+
     //
     // Add the histograms to the paramater list.
@@ -187,8 +198,12 @@
 	gStyle->SetOptStat(0);
 	rate->Draw();
+
+	TFile f("ratehists.root", "recreate");
+	
+	rate->GetHist(2)->Write();
+	rate->GetHist(3)->Write();
+	rate->GetHist(4)->Write();
       }
+
+
 }
-
-
-
-
Index: trunk/MagicSoft/Mars/mhist/MHMcRate.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcRate.cc	(revision 1799)
+++ trunk/MagicSoft/Mars/mhist/MHMcRate.cc	(revision 1800)
@@ -62,6 +62,7 @@
     fTriggerRateError= -1.0; // Estimated error for the trigger rate in Hz
 
-    fMultiplicity = -1;
-    fMeanThreshold = -1.;
+    fMultiplicity = -1;      // Multiplicity of the trigger condition
+    fMeanThreshold = -1.;    // Discr. threshold of the trigger condition
+    fTriggerCondNum = 0;     // Trigger condition number within camera file
 
 }
Index: trunk/MagicSoft/Mars/mhist/MHMcRate.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMcRate.h	(revision 1799)
+++ trunk/MagicSoft/Mars/mhist/MHMcRate.h	(revision 1800)
@@ -43,4 +43,6 @@
     Short_t fMultiplicity;      // L1 trigger multiplicity.
 
+    Short_t fTriggerCondNum;    // Trigger condition number, for the case of
+                                // running over camra files containing several.
 
     void Init(const char *name, const char *title);
@@ -74,4 +76,6 @@
     void SetMeanThreshold(Float_t thresh) {fMeanThreshold = thresh;}
 
+    void SetTriggerCondNum(Short_t num) {fTriggerCondNum = num;}
+
     void UpdateBoundaries(Float_t energy, Float_t theta, Float_t phi, Float_t impact);
 
@@ -80,5 +84,7 @@
 
     Short_t GetMultiplicity() {return fMultiplicity;}
-    Float_t  GetMeanThreshold() {return fMeanThreshold;}
+    Float_t GetMeanThreshold() {return fMeanThreshold;}
+    Short_t GetTriggerCondNum() {return fTriggerCondNum;}
+
 
     void CalcRate(Float_t trig, Float_t anal, Float_t simu);
Index: trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc	(revision 1799)
+++ trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc	(revision 1800)
@@ -330,5 +330,17 @@
 
     //
-    // Add the histograms to the paramater list.
+    // Set for each MHMcRate object the trigger condition number in the 
+    // camera file (for the case of camera files with several conditions,
+    // 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);
+
+    //
+    // Add the histograms to the parameter list.
     //
     plist.AddToList(&hists);
@@ -353,5 +365,5 @@
 
     // We calculate only shower rate (not including NSB-only triggers)
-    Float_t* BgR = new Float_t[dim];
+    Float_t* BgR = new Float_t[num];
     memset(BgR, 0, num*sizeof(Float_t));
 
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 1799)
+++ trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 1800)
@@ -143,8 +143,8 @@
 
         TString th("MMcTrigHeader");
-	if (fNum > 1)
+	if (GetRate(i)->GetTriggerCondNum() > 0)
 	  {
 	    th += ";";
-	    th += i+1;
+	    th += GetRate(i)->GetTriggerCondNum();
 	  }
 
