Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 6993)
+++ trunk/MagicSoft/Mars/Changelog	(revision 6994)
@@ -21,4 +21,31 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2005/05/04 Thomas Bretz
+
+   * mfileio/MWriteRootFile.cc:
+     - fixed a possible infinite loop when compiling the new
+       file name as suggested by Abelardo
+
+   * mhflux/MHAlpha.cc:
+     - search for fName+"Off" instead of ClassName()+"Off"
+
+   * mjobs/MJSpectrum.cc:
+     - scale the displayed zd-plots by their maximum as the 
+       histograms are scaled before
+
+   * mjobs/MJStar.cc:
+     - implemented writing of the muon parameters. This takes another
+       5% of the time (in total 15-20% for muon analysis). It enlarges
+       the file size by roughly 15% (a test file was enlarged from
+       5.1M to 5.9M)
+
+   * mmuon/MMuonCalibPar.cc:
+     - set default of ArcPhi to an invalid value = -1
+
+   * mreport/MReportDrive.cc:
+     - fixed a typo in the comments
+
+
 
  2005/05/03 Thomas Bretz
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 6993)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 6994)
@@ -856,11 +856,21 @@
         // Replace source by destination
         const TRegexp regexp(src);
-        while (1)
-        {
-            idx = regexp.Index(fname, &len);
+
+        Ssiz_t ichar = 0;
+        while (1) // Replace all occurrences of src by dest
+        {
+            idx = regexp.Index(fname, &len, ichar);
             if (idx<0)
                 break;
 
             fname.Replace(idx, len, dest);
+	    ichar = idx + dest.Length();
+
+            // In next iteration, we start searching the string fname
+	    // right after the last character of the previous substitution
+	    // (indicated by ichar). This avoids infinite loops in the case 
+	    // we want to replace, for instance, "_w" by "_Y_w". Without 
+	    // the use of ichar, the second string would be replaced by 
+	    // "_Y_Y_w", and this would never end... 
         }
     }
Index: trunk/MagicSoft/Mars/mhflux/MHAlpha.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHAlpha.cc	(revision 6993)
+++ trunk/MagicSoft/Mars/mhflux/MHAlpha.cc	(revision 6994)
@@ -223,5 +223,5 @@
     fHTime.Reset();
 
-    const TString off(Form("%sOff", ClassName()));
+    const TString off(Form("%sOff", fName.Data()));
     if (fName!=off && fOffData==NULL)
     {
Index: trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 6993)
+++ trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 6994)
@@ -321,5 +321,5 @@
     if (theta)
     {
-        proj.Scale(theta->Integral()/proj.Integral());
+        proj.Scale(theta->GetMaximum()/proj.GetMaximum());
         theta->SetMaximum(1.05*TMath::Max(theta->GetMaximum(), proj.GetMaximum()));
     }
Index: trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 6993)
+++ trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 6994)
@@ -54,4 +54,5 @@
 #include "MReadMarsFile.h"
 #include "MF.h"
+#include "MFDataMember.h"
 #include "MFDeltaT.h"
 #include "MFSoftwareTrigger.h"
@@ -286,5 +287,7 @@
     // ------------------ Setup write task ----------------
 
-    MWriteRootFile write(2, Form("%s{s/_Y_/_I_}", fPathOut.Data()), fOverwrite?"RECREATE":"NEW");
+    const TString rule(Form("%s{s/_Y_/_I_}", fPathOut.Data()));
+    MWriteRootFile write( 2, rule, fOverwrite?"RECREATE":"NEW");
+    MWriteRootFile writem(2, rule, fOverwrite?"RECREATE":"NEW");
     // Data
     write.AddContainer("MHillas",       "Events");
@@ -305,9 +308,9 @@
 
     // Muon Setup
-    write.AddContainer("BinningRadius",          "RunHeaders");
-    write.AddContainer("BinningArcWidth",        "RunHeaders");
-    write.AddContainer("BinningRingBroadening",  "RunHeaders");
-    write.AddContainer("BinningSizeVsArcRadius", "RunHeaders");
-    write.AddContainer("MMuonSetup",             "RunHeaders");
+    write.AddContainer("BinningRadius",            "RunHeaders");
+    write.AddContainer("BinningArcWidth",          "RunHeaders");
+    write.AddContainer("BinningRingBroadening",    "RunHeaders");
+    write.AddContainer("BinningSizeVsArcRadius",   "RunHeaders");
+    write.AddContainer("MMuonSetup",               "RunHeaders");
 
     if (ismc)
@@ -333,4 +336,21 @@
         write.AddContainer("MEffectiveOnTime",     "EffectiveOnTime");
         write.AddContainer("MTimeEffectiveOnTime", "EffectiveOnTime");
+    }
+
+    // What to write in muon tree
+    writem.AddContainer("MMuonSearchPar", "Muons");
+    writem.AddContainer("MMuonCalibPar",  "Muons");
+    writem.AddContainer("MHillas",        "Muons");
+    writem.AddContainer("MHillasExt",     "Muons");
+    writem.AddContainer("MHillasSrc",     "Muons");
+    writem.AddContainer("MImagePar",      "Muons");
+    writem.AddContainer("MNewImagePar",   "Muons");
+    writem.AddContainer("MRawEvtHeader",  "Muons");
+    writem.AddContainer("MPointingPos",   "Muons");
+    if (ismc)
+    {
+        // Monte Carlo Data
+        writem.AddContainer("MMcEvt",     "Muons");
+        writem.AddContainer("MMcTrig",    "Muons");
     }
 
@@ -369,4 +389,6 @@
     MF fmuon3("(MMuonCalibPar.fArcPhi>175)  && (MMuonSearchPar.fDeviation<37)",
               "MuonFinalCut");
+    MFDataMember fmuon4("MMuonCalibPar.fArcPhi", '>', -0.5, "MuonWriteCut");
+    writem.SetFilter(&fmuon4);
 
     MMuonSearchParCalc muscalc;
@@ -390,4 +412,6 @@
         tlist2.AddToList(&fmuon3);
         tlist2.AddToList(&fillmpar);
+        tlist2.AddToList(&fmuon4);
+        tlist2.AddToList(&writem);
     }
     // ------------------------------------------------------------
Index: trunk/MagicSoft/Mars/mmuon/MMuonCalibPar.cc
===================================================================
--- trunk/MagicSoft/Mars/mmuon/MMuonCalibPar.cc	(revision 6993)
+++ trunk/MagicSoft/Mars/mmuon/MMuonCalibPar.cc	(revision 6994)
@@ -62,5 +62,5 @@
 {
     fArcLength   = -1.;
-    fArcPhi      =  0.;
+    fArcPhi      = -1.;
     fArcWidth    = -1.;
     fChiArcPhi   = -1.;
Index: trunk/MagicSoft/Mars/mreport/MReportDrive.cc
===================================================================
--- trunk/MagicSoft/Mars/mreport/MReportDrive.cc	(revision 6993)
+++ trunk/MagicSoft/Mars/mreport/MReportDrive.cc	(revision 6994)
@@ -41,5 +41,5 @@
 // Double_t fDec;        // [deg] Declination
 // Double_t fHa;         // [h]   Hour angle
-//  Currently this descries the nominal source position
+//  Currently this describes the nominal source position
 //
 // Double_t fNominalZd;  // [deg] Nominal zenith distance
