Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 9481)
+++ trunk/MagicSoft/Mars/Changelog	(revision 9482)
@@ -27,5 +27,6 @@
      - added getter for command line
 
-   * mjobs/MJCalibration.cc, mjobs/MJCut.cc:
+   * mjobs/MJCalibration.cc, mjobs/MJCut.cc, mjobs/MJSpectrum.cc,
+     mjobs/MJStar.cc, mjobs/MJCalibrateSignal.cc:
      - write command line to output
 
@@ -36,6 +37,11 @@
      - added efault argumtn to Print()
 
-   * mjobs/MJCalibrateSignal.cc:
-     - write command line to output
+   * mjobs/MJStar.cc:
+     - added a sanity check for empty sequences
+     - write MCorsikaEvtHeader and MCorsikaRunHeader to output
+
+   * mjobs/MJSimulation.cc:
+     - use a MParameterCalc to calculate and later store the
+       incident angle
 
 
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 9481)
+++ trunk/MagicSoft/Mars/NEWS	(revision 9482)
@@ -17,4 +17,6 @@
    * Added a new camera layout MGeomCamFact which is the "four rectangular
      pixels ordered in a hexagonal geometry" layout
+
+   * All programs now store the command line as TNamed "CommandLine"
 
  ;showplot:
Index: trunk/MagicSoft/Mars/callisto.cc
===================================================================
--- trunk/MagicSoft/Mars/callisto.cc	(revision 9481)
+++ trunk/MagicSoft/Mars/callisto.cc	(revision 9482)
@@ -441,4 +441,5 @@
         job3.SetOverwrite(kOverwrite);
         job3.SetPathOut(kOutpathC);
+        job3.SetCommandLine(MArgs::GetCommandLine(argc, argv));
         // job2.SetPathIn(kInpathC); // not yet needed
 
@@ -625,4 +626,5 @@
         job4.SetMovieMode(kMovie);
         job4.SetNullOut(kNullOut);
+        job4.SetCommandLine(MArgs::GetCommandLine(argc, argv));
         if (!seq.IsMonteCarlo())
             job4.SetExtractor(job2.GetExtractor());
Index: trunk/MagicSoft/Mars/ceres.cc
===================================================================
--- trunk/MagicSoft/Mars/ceres.cc	(revision 9481)
+++ trunk/MagicSoft/Mars/ceres.cc	(revision 9482)
@@ -341,4 +341,5 @@
         job.SetForceMode(kForce);
         job.SetMode(opmode);
+        job.SetCommandLine(MArgs::GetCommandLine(argc, argv));
         // job.SetPathIn(kInpath); // not yet needed
 
Index: trunk/MagicSoft/Mars/ganymed.cc
===================================================================
--- trunk/MagicSoft/Mars/ganymed.cc	(revision 9481)
+++ trunk/MagicSoft/Mars/ganymed.cc	(revision 9482)
@@ -287,4 +287,5 @@
         job.SetNameOutFile(kOutfile);
         job.SetNameSummaryFile(kNameSummary);
+        job.SetCommandLine(MArgs::GetCommandLine(argc, argv));
         //job.SetNameResultFile(kNameResult);
         job.EnableWriteOnly(kWriteOnly);
Index: trunk/MagicSoft/Mars/mbase/MArgs.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MArgs.cc	(revision 9481)
+++ trunk/MagicSoft/Mars/mbase/MArgs.cc	(revision 9482)
@@ -506,2 +506,22 @@
     return rc;
 }
+
+// --------------------------------------------------------------------------
+//
+// Return all arguments and options in the order as they are stored
+// in memory.
+//
+TString MArgs::GetCommandLine() const
+{
+    TString rc;
+
+    TIter Next(&fArgv);
+    TString *s = NULL;
+    while ((s=dynamic_cast<TString*>(Next())))
+    {
+        rc += *s;
+        rc += " ";
+    }
+
+    return rc.Strip(TString::kBoth);
+}
Index: trunk/MagicSoft/Mars/mbase/MArgs.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MArgs.h	(revision 9481)
+++ trunk/MagicSoft/Mars/mbase/MArgs.h	(revision 9482)
@@ -31,4 +31,5 @@
 
     MArgsEntry *GetArgument(Int_t i) const;
+    MArgsEntry *GeOption(Int_t i) const;
 
 public:
@@ -70,4 +71,8 @@
     Bool_t   RemoveArgument(Int_t i);
 
+    TString  GetCommandLine() const;
+
+    static TString GetCommandLine(int argc, char **argv) { return MArgs(argc, argv).GetCommandLine(); }
+
     ClassDef(MArgs, 0)  //Class to parse command line arguments
 };
Index: trunk/MagicSoft/Mars/mjobs/MJSimulation.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJSimulation.cc	(revision 9481)
+++ trunk/MagicSoft/Mars/mjobs/MJSimulation.cc	(revision 9482)
@@ -74,4 +74,5 @@
 #include "MFillH.h"
 #include "MGeomApply.h"
+#include "MParameterCalc.h"
 #include "MHillasCalc.h"
 #include "MImgCleanStd.h"
@@ -166,4 +167,7 @@
     cont.Add(plist.FindObject("GeomCones"));
 
+    TNamed cmdline("CommandLine", fCommandLine.Data());
+    cont.Add(&cmdline);
+
     if (fDisplay)
     {
@@ -219,11 +223,5 @@
     hist.SetAutoRange();
 
-    TString sin2 = "sin(MCorsikaEvtHeader.fZd)*sin(MCorsikaRunHeader.fZdMin*TMath::DegToRad())";
-    TString cos2 = "cos(MCorsikaEvtHeader.fZd)*cos(MCorsikaRunHeader.fZdMin*TMath::DegToRad())";
-    TString cos  = "cos(MCorsikaEvtHeader.fAz-MCorsikaRunHeader.fAzMin*TMath::DegToRad())";
-
-    TString form = "acos("+sin2+"*"+cos+"+"+cos2+")*TMath::RadToDeg()";
-
-    hist.AddHist(form);
+    hist.AddHist("IncidentAngle.fVal");
     hist.InitName("ViewCone");
     hist.InitTitle("Incident Angle;\\alpha [\\deg]");
@@ -243,4 +241,5 @@
     write.AddContainer("MRawEvtHeader",       "Events");
     write.AddContainer("MMcEvt",              "Events");
+    write.AddContainer("IncidentAngle",       "Events", kFALSE);
 }
 
@@ -372,4 +371,13 @@
     plist.AddToList(&splinemirror);
     plist.AddToList(&splinecones);
+
+    const TString sin2 = "sin(MCorsikaEvtHeader.fZd)*sin(MCorsikaRunHeader.fZdMin*TMath::DegToRad())";
+    const TString cos2 = "cos(MCorsikaEvtHeader.fZd)*cos(MCorsikaRunHeader.fZdMin*TMath::DegToRad())";
+    const TString cos  = "cos(MCorsikaEvtHeader.fAz-MCorsikaRunHeader.fAzMin*TMath::DegToRad())";
+
+    const TString form = "acos("+sin2+"*"+cos+"+"+cos2+")*TMath::RadToDeg()";
+
+    MParameterCalc calcangle(form, "CalcIncidentAngle");
+    calcangle.SetNameParameter("IncidentAngle");
 
     MSimAtmosphere simatm;
@@ -637,4 +645,5 @@
         if (1)
             tasks.AddToList(&simatm); // Here because before fillh1
+        tasks.AddToList(&calcangle);
         tasks.AddToList(&fillh1);
         tasks.AddToList(&fillG);
Index: trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 9481)
+++ trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 9482)
@@ -1963,4 +1963,5 @@
     {
         TNamed ganame("ganymed.root", fPathIn.Data());
+        TNamed cmdline("CommandLine", fCommandLine.Data());
 
         // Write the output
@@ -1974,4 +1975,5 @@
         cont.Add(&hest);
         cont.Add(&ganame);
+        cont.Add(&cmdline);
 
         if (fDisplay)
Index: trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 9481)
+++ trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 9482)
@@ -118,4 +118,7 @@
     cont.Add(const_cast<MSequence*>(&fSequence));
 
+    TNamed cmdline("CommandLine", fCommandLine.Data());
+    cont.Add(&cmdline);
+
     if (fDisplay)
     {
@@ -155,5 +158,8 @@
     MDirIter iter;
     if (fSequence.GetRuns(iter, MSequence::kCalibrated)<=0)
+    {
+        *fLog << err << "ERROR - Sequence valid but without files." << endl;
         return kFALSE;
+    }
 
     // Setup Parlist
@@ -267,5 +273,6 @@
     plist.AddToList(&par); // without MTriggerPattern stored in the file
 
-    // For the effective on-time calculation we don't want SUM-only events
+    // For the effective on-time calculation and the muon statistics
+    // we don't want SUM-only events
     MFTriggerPattern fsum;
     fsum.SetDefault(kTRUE);
@@ -336,4 +343,5 @@
         write.AddContainer("MMcEvt",                "Events");
         write.AddContainer("MMcTrig",               "Events", kFALSE);
+        write.AddContainer("MCorsikaEvtHeader",     "Events", kFALSE);
         write.AddContainer("MSrcPosCam",            "Events");
         // Monte Carlo Run Headers
@@ -342,5 +350,6 @@
         write.AddContainer("MMcFadcHeader",         "RunHeaders", kFALSE);
         write.AddContainer("MMcConfigRunHeader",    "RunHeaders", kFALSE);
-        write.AddContainer("MMcCorsikaRunHeader",   "RunHeaders");
+        write.AddContainer("MMcCorsikaRunHeader",   "RunHeaders", kFALSE);
+        write.AddContainer("MCorsikaRunHeader",     "RunHeaders", kFALSE);
     }
     else
Index: trunk/MagicSoft/Mars/mjobs/MJob.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJob.h	(revision 9481)
+++ trunk/MagicSoft/Mars/mjobs/MJob.h	(revision 9482)
@@ -38,4 +38,6 @@
     // FIXME: Split into MJobSequence and MJobDataSet
     MSequence fSequence;      // Sequence
+
+    TString   fCommandLine;   // Command line for possible storage
 
     const TEnv *GetEnv() const;
@@ -79,4 +81,6 @@
     void   SetNullOut(Bool_t b=kTRUE) { fNullOut=b; }
 
+    void   SetCommandLine(const TString &s) { fCommandLine = s; }
+
     // Getter
     TString GetPathOut() const  { return fPathOut; }
Index: trunk/MagicSoft/Mars/mtrigger/MTriggerPattern.h
===================================================================
--- trunk/MagicSoft/Mars/mtrigger/MTriggerPattern.h	(revision 9481)
+++ trunk/MagicSoft/Mars/mtrigger/MTriggerPattern.h	(revision 9482)
@@ -12,5 +12,4 @@
 public:
     enum Pattern_t {
-//        kUndefined1  = BIT(0), //  1   1: Level 1 from L2 board
         kTriggerLvl1 = BIT(0), //  1   1: Level 1 from L2 board
         kCalibration = BIT(1), //  2   2: Pulse Trigger
@@ -19,7 +18,6 @@
         kPinDiode    = BIT(4), // 10  16:
         kSumTrigger  = BIT(5), // 20  32: Flag for an event taken with sum trigger
-//        kTriggerLvl1 = BIT(6), // 40  64: Trigger lvl1 directly from L1 without going through L2
         kUndefined1  = BIT(6), // 40  64: Trigger lvl1 directly from L1 without going through L2
-        kUndefined2  = BIT(7)  // 80 128: Undefined?
+        kUndefined2  = BIT(7)  // 80 128: Undefined? (L3?)
     };
 
@@ -31,5 +29,5 @@
     MTriggerPattern(const char *name=0, const char *title=0);
 
-    void Print(Option_t *) const;
+    void Print(Option_t *o="") const;
     void Copy(TObject &obj) const;
 
Index: trunk/MagicSoft/Mars/sponde.cc
===================================================================
--- trunk/MagicSoft/Mars/sponde.cc	(revision 9481)
+++ trunk/MagicSoft/Mars/sponde.cc	(revision 9482)
@@ -258,4 +258,5 @@
         job.SetPathOut(kOutfile);
         job.SetPathIn(kInfile);
+        job.SetCommandLine(MArgs::GetCommandLine(argc, argv));
 
         job.ForceTheta(kForceTheta);
Index: trunk/MagicSoft/Mars/star.cc
===================================================================
--- trunk/MagicSoft/Mars/star.cc	(revision 9481)
+++ trunk/MagicSoft/Mars/star.cc	(revision 9482)
@@ -246,4 +246,5 @@
         job.SetPathOut(kOutpath);
         job.SetNullOut(kNullOut);
+        job.SetCommandLine(MArgs::GetCommandLine(argc, argv));
         // job.SetPathIn(kInpath); // not yet needed
         if (kNoMuons)
