Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 9342)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 9343)
@@ -20,4 +20,49 @@
  2009/02/15 Thomas Bretz
 
+   * ceres.rc:
+     - added the MAGIC I high gain pulse as example
+
+   * sponde.cc:
+     - redirect root error handler
+     - added new option to force on-time fit
+
+   * datacenter/scripts/runcorsika:
+     - added a comment
+     - remove empty dat file after corsika finished
+
+   * mbase/MLog.cc:
+     - added several more log-levels to handling root's error handler
+
+   * mbase/MPrint.cc:
+     - flush buffer before printing
+     - set output level to all
+
+   * melectronics/MPulseShape.h:
+     - let clone also clone the spline
+
+   * mfileio/MWriteRootFile.cc:
+     - don't output title if empty
+
+   * mhflux/MHAlpha.cc:
+     - removed erronornously comittet SetSumw2
+     - don't output the numbe rof excess events vs time
+
+   * mhflux/MHEffectiveOnTime.[h,cc]:
+     - added new data mebers to store the result of the overall-fit
+       which is now done in Finalize
+     - output the results of the effective on-time fit as inf2
+     - increased clas version accordingly
+
+   * mjobs/MJSimulation.[h,cc]:
+     - simplified setting up the file structure
+
+   * mjobs/MJSpectrum.[h,cc]:
+     - added the possibility to force a new on-time fit.
+     - a MHEffectiveOnTime histogram is now always displayed 
+       for manual cross checks
+
+   * mjobs/MJStar.cc:
+     - added MSrcPosCam for Monte Carlos to output
+
    * mpointing/MSrcPosCalc.cc:
      - ignore the WobbleMode from the MMcCorsikaRunHeader 
@@ -46,7 +91,9 @@
      - support changing geometries (conversion factors) reading
        a new geometry from a run header
+     - increased class version by one
 
    * mhflux/MMcSpectrumWeight.cc:
      - replaced Form by MString::Format
+
      - made sure that nobody is mixing different energy-range monte
        carlos and normalizes by integral (to be implemented)
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 9342)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 9343)
@@ -76,4 +76,12 @@
      displayes the MSrcPosCam data from the input star-files. Unfortunately,
      this containes was never written to the star-files yet.
+
+   * A new Tab 'OnTime' is available which is an effective on-time
+     fit as in star but for all data. This is mainly for manual cross-check
+     of the effective on-time
+
+   * In some circumstances it might be necessary to re-calculate the 
+     eff. on-time from the fit in the new tab, e.g. when a zenith distance
+     cut was made in ganymed. This can now be forced by ''--force-ontimefit''
 
 
Index: /trunk/MagicSoft/Mars/ceres.rc
===================================================================
--- /trunk/MagicSoft/Mars/ceres.rc	(revision 9342)
+++ /trunk/MagicSoft/Mars/ceres.rc	(revision 9343)
@@ -196,2 +196,10 @@
 #MSimReadout.fConversionFactor: 1
 
+# The number of sampling points is almost irrelevant because they
+# are equidistant, i.e. calculated and no search is necessary.
+# Nevertheless, you must make sure that there are enough points
+# to sample the function accuratly enough.
+#MPulseShape.Function.Name:  3.51308*exp(-1.4105*(exp(-0.5*x)+0.310942*x)) + 4.33521e-3*exp(-1.4105*(exp(-0.5*x)+6.09265e-3*x))
+#MPulseShape.Function.Npx:   250
+#MPulseShape.Function.Xmin:   -5
+#MPulseShape.Function.Xmax:   45
Index: /trunk/MagicSoft/Mars/datacenter/scripts/runcorsika
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/scripts/runcorsika	(revision 9342)
+++ /trunk/MagicSoft/Mars/datacenter/scripts/runcorsika	(revision 9343)
@@ -92,4 +92,5 @@
    echo "MAXPRT 0"
    # Suppress file with partciles reaching ground (DATnnnnnn)
+   # FIXME: Should we make this switchable by the database?
    echo "PAROUT F F"
    # Don't write a database file
@@ -183,4 +184,6 @@
 printinputcard | ./cc6501p-linux >> $logfile 2>&1
 
+rm -f $outpath/dat`printf %06d $corsikarunno`
+
 check1=$?
 
Index: /trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.h	(revision 9342)
+++ /trunk/MagicSoft/Mars/manalysis/MMcCalibrationUpdate.h	(revision 9343)
@@ -20,5 +20,4 @@
 {
 private:
-    Bool_t CheckRunType(MParList *pList) const;
     Int_t  PreProcess(MParList *pList);
     Int_t  Process();
Index: /trunk/MagicSoft/Mars/mbase/MLog.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MLog.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mbase/MLog.cc	(revision 9343)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MLog.cc,v 1.63 2009-02-15 13:24:59 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MLog.cc,v 1.64 2009-02-15 23:00:34 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -834,5 +834,5 @@
     // annoying errors in case of a log-scale set too early
     if (level==kError && !strcmp(location, "THistPainter::PaintInit"))
-        level=kInfo;
+        level=kInfo+2;
 
     gLog << std::flush;
@@ -841,5 +841,9 @@
 
     if (level >= kInfo)
-       gLog << inf;
+        gLog << inf;
+    if (level==kInfo+1)
+        gLog << inf2;
+    if (level==kInfo+2)
+        gLog << inf3;
     if (level >= kWarning)
         gLog << warn;
Index: /trunk/MagicSoft/Mars/mbase/MPrint.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MPrint.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mbase/MPrint.cc	(revision 9343)
@@ -149,4 +149,5 @@
 Int_t MPrint::Process()
 {
+    gLog << flush << all;
     if (TestBit(kSeparator))
         gLog.Separator() << endl;
Index: /trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 9343)
@@ -584,5 +584,5 @@
     fTasksProcess.Clear();
     while ((task=(MTask*)Next()))
-        if (task->IsA()==MTask::Class() || task->OverwritesProcess())
+        if (task->IsA()==MTask::Class() || task->Overwrites("Process"))
             fTasksProcess.Add(task);
 
@@ -621,4 +621,8 @@
     while ((task=(MTask*)Next()))
     {
+        // Supress output if not necessary
+        if (!task->Overwrites("ReInit"))
+            continue;
+
         *fLog << all << task->GetName() << "... " << flush;
 
Index: /trunk/MagicSoft/Mars/melectronics/MPulseShape.h
===================================================================
--- /trunk/MagicSoft/Mars/melectronics/MPulseShape.h	(revision 9342)
+++ /trunk/MagicSoft/Mars/melectronics/MPulseShape.h	(revision 9343)
@@ -12,5 +12,5 @@
 {
 private:
-    MSpline3          *fSpline;     //! Spline to describe the pulse shape
+    MSpline3          *fSpline;     // Spline to describe the pulse shape
 
     TString fFileName;              // File name of a file describing the pulse shape
Index: /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 9343)
@@ -159,5 +159,8 @@
         }
 
-        *fLog << inf3 << "New file '" << name << "' <Title=" << title << "> created." << endl;
+        *fLog << inf3 << "New file '" << name << "' ";
+        if (!TString(title).IsNull())
+            *fLog << "<Title=" << title << "> ";
+        *fLog << "created." << endl;
 
         file->SetOption(option); // IMPORTANT!
Index: /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc	(revision 9343)
@@ -88,4 +88,8 @@
 //   +  Double_t fTotalTime;
 //
+//  Class version 4:
+//  ----------------
+//   +  Double_t fEffOnTime;    //[s] On time as fitted from the DeltaT distribution
+//   +  Double_t fEffOnTimeErr; //[s] On time error as fitted from the DeltaT distribution
 //
 // ==========================================================================
@@ -301,5 +305,6 @@
 MHEffectiveOnTime::MHEffectiveOnTime(const char *name, const char *title)
     : fPointPos(0), fTime(0), fParam(0), fIsFinalized(kFALSE), 
-    fNumEvents(200*60), fFirstBin(3), fTotalTime(-1)
+    fNumEvents(200*60), fFirstBin(3), fTotalTime(-1),
+    fEffOnTime(-1), fEffOnTimeErr(0)
     //fNumEvents(2*60), fFirstBin(1)
 {
@@ -479,4 +484,7 @@
    fTotalTime = 0;
 
+   fEffOnTime    = -1;
+   fEffOnTimeErr =  0;
+
    return kTRUE;
 }
@@ -714,5 +722,5 @@
     fTime->Plus1ns();
 
-    *fLog << fLastTime << ":  Val=" << res[0] << "  Err=" << res[1] << endl;
+    *fLog << inf2 << fLastTime << ":  Val=" << res[0] << "  Err=" << res[1] << endl;
 }
 
@@ -780,4 +788,15 @@
     FitThetaBins();
     FitTimeBin();
+
+
+    TH1D *h = fH2DeltaT.ProjectionX("FinalizeProjDeltaT", -1, -1, "E");
+    Double_t res[7];
+    if (FitH(h, res))
+    {
+        fEffOnTime    = res[0];
+        fEffOnTimeErr = res[1];
+    }
+    delete h;
+
 
     fIsFinalized = kTRUE;
Index: /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.h
===================================================================
--- /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.h	(revision 9342)
+++ /trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.h	(revision 9343)
@@ -50,5 +50,7 @@
     UInt_t fFirstBin;    // For bin for fit
 
-    Double_t fTotalTime; //[s] Total time accumulated from run-header
+    Double_t fTotalTime;    //[s] Total time accumulated from run-header
+    Double_t fEffOnTime;    //[s] On time as fitted from the DeltaT distribution
+    Double_t fEffOnTimeErr; //[s] On time error as fitted from the DeltaT distribution
 
     // MHEffectiveOnTime
@@ -81,4 +83,5 @@
     // Getter
     Double_t GetTotalTime() const { return fTotalTime; }
+    Double_t GetEffOnTime() const { return fEffOnTime; }
 
     const TH1D &GetHEffOnTheta() const { return fHThetaEffOn; }
Index: /trunk/MagicSoft/Mars/mimage/MHHillas.cc
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHHillas.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mimage/MHHillas.cc	(revision 9343)
@@ -19,5 +19,5 @@
 !   Author(s): Wolfgang Wittek  2002 <mailto:wittek@mppmu.mpg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2009
 !
 !
@@ -29,4 +29,9 @@
 //
 // This class contains histograms for the source independent image parameters
+//
+// ClassVersion 2:
+// ---------------
+//  - fMm2Deg
+//  - fUseMmScale
 //
 /////////////////////////////////////////////////////////////////////////////
Index: /trunk/MagicSoft/Mars/mimage/MHHillas.h
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHHillas.h	(revision 9342)
+++ /trunk/MagicSoft/Mars/mimage/MHHillas.h	(revision 9343)
@@ -54,5 +54,5 @@
     //Int_t DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
 
-    ClassDef(MHHillas, 1) // Container which holds histograms for the source independent image parameters
+    ClassDef(MHHillas, 2) // Container which holds histograms for the source independent image parameters
 };
 
Index: /trunk/MagicSoft/Mars/mimage/MHHillasExt.cc
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHHillasExt.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mimage/MHHillasExt.cc	(revision 9343)
@@ -34,4 +34,9 @@
 //  + fHSlopeL
 //
+// ClassVersion 3:
+// ---------------
+//  - fMm2Deg
+//  - fUseMmScale
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MHHillasExt.h"
Index: /trunk/MagicSoft/Mars/mimage/MHHillasExt.h
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHHillasExt.h	(revision 9342)
+++ /trunk/MagicSoft/Mars/mimage/MHHillasExt.h	(revision 9343)
@@ -44,5 +44,5 @@
     void Draw(Option_t *opt=NULL);
 
-    ClassDef(MHHillasExt, 2) // Container which holds histograms for the extended hillas parameters
+    ClassDef(MHHillasExt, 3) // Container which holds histograms for the extended hillas parameters
 };
 
Index: /trunk/MagicSoft/Mars/mimage/MHHillasSrc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHHillasSrc.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mimage/MHHillasSrc.cc	(revision 9343)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz  2001 <mailto:tbretz@uni-sw.gwdg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2001
+!   Copyright: MAGIC Software Development, 2000-2009
 !
 !
@@ -28,4 +28,9 @@
 //
 // This class contains histograms for every Hillas parameter
+//
+// ClassVersion 2:
+// ---------------
+//  - fMm2Deg
+//  - fUseMmScale
 //
 ///////////////////////////////////////////////////////////////////////
Index: /trunk/MagicSoft/Mars/mimage/MHHillasSrc.h
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHHillasSrc.h	(revision 9342)
+++ /trunk/MagicSoft/Mars/mimage/MHHillasSrc.h	(revision 9343)
@@ -46,5 +46,5 @@
 
 
-    ClassDef(MHHillasSrc, 1) // Container which holds histograms for the source dependant parameters
+    ClassDef(MHHillasSrc, 2) // Container which holds histograms for the source dependant parameters
 };
 
Index: /trunk/MagicSoft/Mars/mimage/MHNewImagePar.cc
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHNewImagePar.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mimage/MHNewImagePar.cc	(revision 9343)
@@ -19,5 +19,5 @@
 !   Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2006
+!   Copyright: MAGIC Software Development, 2000-2009
 !
 !
@@ -29,8 +29,13 @@
 //
 //
-// Version 2:
+// ClassVersion 2:
 // ----------
 //  + TH1F fHistConcCOG;   // [ratio] concentration around the center of gravity (all pixels)
 //  + TH1F fHistConcCore;  // [ratio] concentration of signals inside ellipse (used pixels)
+//
+// ClassVersion 3:
+// ---------------
+//  - fMm2Deg
+//  - fUseMmScale
 //
 ////////////////////////////////////////////////////////////////////////////
Index: /trunk/MagicSoft/Mars/mimage/MHNewImagePar.h
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHNewImagePar.h	(revision 9342)
+++ /trunk/MagicSoft/Mars/mimage/MHNewImagePar.h	(revision 9343)
@@ -61,5 +61,5 @@
     void Paint(Option_t *opt="");
 
-    ClassDef(MHNewImagePar, 2) // Histograms of new image parameters
+    ClassDef(MHNewImagePar, 3) // Histograms of new image parameters
 };
 
Index: /trunk/MagicSoft/Mars/mimage/MHNewImagePar2.cc
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHNewImagePar2.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mimage/MHNewImagePar2.cc	(revision 9343)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 03/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2009
 !
 !
@@ -26,4 +26,9 @@
 //
 // MHNewImagePar2
+//
+// ClassVersion 2:
+// ---------------
+//  - fMm2Deg
+//  - fUseMmScale
 //
 ////////////////////////////////////////////////////////////////////////////
Index: /trunk/MagicSoft/Mars/mimage/MHNewImagePar2.h
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHNewImagePar2.h	(revision 9342)
+++ /trunk/MagicSoft/Mars/mimage/MHNewImagePar2.h	(revision 9343)
@@ -28,5 +28,5 @@
     void Draw(Option_t *opt="");
 
-    ClassDef(MHNewImagePar2, 1) // Histograms of new image parameters
+    ClassDef(MHNewImagePar2, 2) // Histograms of new image parameters
 };
 
Index: /trunk/MagicSoft/Mars/mimage/MHVsSize.cc
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHVsSize.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mimage/MHVsSize.cc	(revision 9343)
@@ -19,5 +19,5 @@
 !   Author(s): Wolfgang Wittek  2002 <mailto:wittek@mppmu.mpg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2009
 !
 !
@@ -29,4 +29,9 @@
 //
 // This class contains histograms for the source independent image parameters
+//
+// ClassVersion 2:
+// ---------------
+//  - fMm2Deg
+//  - fUseMmScale
 //
 /////////////////////////////////////////////////////////////////////////////
Index: /trunk/MagicSoft/Mars/mimage/MHVsSize.h
===================================================================
--- /trunk/MagicSoft/Mars/mimage/MHVsSize.h	(revision 9342)
+++ /trunk/MagicSoft/Mars/mimage/MHVsSize.h	(revision 9343)
@@ -40,5 +40,5 @@
     void Draw(Option_t *opt=NULL);
 
-    ClassDef(MHVsSize, 1) // Container which holds histograms for image parameters vs size
+    ClassDef(MHVsSize, 2) // Container which holds histograms for image parameters vs size
 };
 
Index: /trunk/MagicSoft/Mars/mjobs/MJSimulation.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJSimulation.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mjobs/MJSimulation.cc	(revision 9343)
@@ -209,4 +209,18 @@
 }
 
+void MJSimulation::SetupCommonFileStructure(MWriteRootFile &write) const
+{
+    // Common run headers
+    write.AddContainer("MCorsikaRunHeader",   "RunHeaders", kFALSE);
+    write.AddContainer("MRawRunHeader",       "RunHeaders");
+    write.AddContainer("MGeomCam",            "RunHeaders");
+    write.AddContainer("MMcRunHeader",        "RunHeaders");
+
+    // Common events
+    write.AddContainer("MCorsikaEvtHeader",   "Events", kFALSE);
+    write.AddContainer("MRawEvtHeader",       "Events");
+    write.AddContainer("MMcEvt",              "Events");
+}
+
 Bool_t MJSimulation::Process(const MArgs &args)
 {
@@ -429,43 +443,23 @@
     write3b.SetName("WriteCamMC");
 
-    write1a.AddContainer("MCorsikaEvtHeader", "Events", kFALSE);
-    write1a.AddContainer("MPhotonEvent",      "Events");
-
-    write2a.AddContainer("MCorsikaRunHeader", "RunHeaders", kFALSE);
-    write2a.AddContainer("MRawRunHeader",     "RunHeaders");
-    write2a.AddContainer("MGeomCam",          "RunHeaders");
-    write2a.AddContainer("MSignalCam",        "Events");
-    write2a.AddContainer("MRawEvtHeader",     "Events",    kFALSE);
+    SetupCommonFileStructure(write1a);
+    SetupCommonFileStructure(write2a);
+    SetupCommonFileStructure(write3a);
+
+    // R: Dedicated file structureedicated events
+    write1a.AddContainer("MPhotonEvent", "Events");
+
+    // I: Dedicated file structureedicated events
     write2a.AddContainer("MPedPhotFromExtractorRndm", "RunHeaders"); // FIXME: Needed for the signal files to be display in MARS
-    write2a.AddContainer("MMcRunHeader",       "RunHeaders");
-    /* Monte Carlo Headers
-    write.AddContainer("MMcRunHeader",              "RunHeaders", kFALSE);
-    write.AddContainer("MMcFadcHeader",             "RunHeaders", kFALSE);
-    write.AddContainer("MMcTrigHeader",             "RunHeaders", kFALSE);
-    write.AddContainer("MMcConfigRunHeader",        "RunHeaders", kFALSE);
-    write.AddContainer("MMcCorsikaRunHeader",       "RunHeaders", kFALSE);
-    // Monte Carlo
-    write.AddContainer("MMcEvt",                    "Events",     kFALSE);
-    write.AddContainer("MMcTrig",                   "Events",     kFALSE);
-    */// Data tree
-    //write.AddContainer("MPedPhotFromExtractor",     "Events");
-    //write.AddContainer("MPedPhotFromExtractorRndm", "Events");
-    //write.AddContainer("MTime",                     "Events",     kFALSE);
-    //write.AddContainer("MRawEvtHeader",             "Events");
-    //write.AddContainer("MTriggerPattern",           "Events");
-
-    write3a.AddContainer("MRawEvtData",         "Events");
-    write3a.AddContainer("MRawRunHeader",       "RunHeaders");
-    write3a.AddContainer("MGeomCam",            "RunHeaders");
-    write3a.AddContainer("MRawEvtHeader",       "Events",     kFALSE);
-    //write3.AddContainer("MPedestalCam",  "RunHeaders", kFALSE);
-    write3a.AddContainer("MMcRunHeader",        "RunHeaders");
-    write3a.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
-    write3a.AddContainer("ElectronicNoise",     "RunHeaders", kFALSE);
-    write3a.AddContainer("MMcEvt",              "Events",     kFALSE);
-
-    write1b.AddContainer("MMcEvtBasic",         "OriginalMC");
-    write2b.AddContainer("MMcEvtBasic",         "OriginalMC");
-    write3b.AddContainer("MMcEvtBasic",         "OriginalMC");
+    write2a.AddContainer("MSignalCam", "Events");
+
+    // D: Dedicated file structureedicated events
+    write3a.AddContainer("ElectronicNoise", "RunHeaders");
+    write3a.AddContainer("MRawEvtData", "Events");
+
+    // Basic MC data
+    write1b.AddContainer("MMcEvtBasic", "OriginalMC");
+    write2b.AddContainer("MMcEvtBasic", "OriginalMC");
+    write3b.AddContainer("MMcEvtBasic", "OriginalMC");
 
     // -------------------------------------------------------------------
Index: /trunk/MagicSoft/Mars/mjobs/MJSimulation.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJSimulation.h	(revision 9342)
+++ /trunk/MagicSoft/Mars/mjobs/MJSimulation.h	(revision 9343)
@@ -9,4 +9,5 @@
 class MArgs;
 class MParList;
+class MWriteRootFile;
 
 class MJSimulation : public MJob
@@ -22,4 +23,5 @@
 
     void SetupHist(MHn &hist) const;
+    void SetupCommonFileStructure(MWriteRootFile &write) const;
 
 public:
Index: /trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 9343)
@@ -64,9 +64,10 @@
 
 // Spectrum
-#include "../mhflux/MAlphaFitter.h"
-#include "../mhflux/MHAlpha.h"
-#include "../mhflux/MHCollectionArea.h"
-#include "../mhflux/MHEnergyEst.h"
-#include "../mhflux/MMcSpectrumWeight.h"
+#include "MAlphaFitter.h"
+#include "MHAlpha.h"
+#include "MHCollectionArea.h"
+#include "MHEnergyEst.h"
+#include "MMcSpectrumWeight.h"
+#include "MHEffectiveOnTime.h"
 
 // Eventloop
@@ -91,5 +92,6 @@
 MJSpectrum::MJSpectrum(const char *name, const char *title)
     : fCutQ(0), fCut0(0),fCut1(0), fCut2(0), fCut3(0), fCutS(0),
-    fEstimateEnergy(0), fCalcHadronness(0),  fCalcDisp(0), fForceTheta(kFALSE)
+    fEstimateEnergy(0), fCalcHadronness(0),  fCalcDisp(0),
+    fForceTheta(kFALSE), fForceRunTime(kFALSE), fForceOnTimeFit(kFALSE)
 {
     fName  = name  ? name  : "MJSpectrum";
@@ -296,4 +298,8 @@
         return -1;
 
+    // We don't have to proceed. We later overwrite the result anyway
+    if (fForceOnTimeFit)
+        return 0;
+
     const Double_t ufl = vstime->GetBinContent(0);
     const Double_t ofl = vstime->GetBinContent(vstime->GetNbinsX()+1);
@@ -750,4 +756,9 @@
     MFillH fill2(Form("HistE    [%s]", cls.Data()), "", "FillHistE");
 
+    // Fill a new MHEffectiveOnTime. It can either be used to
+    // re-calculate the on-time or just for manual cross check
+    MFillH fillT("MHEffectiveOnTime", "MTime", "FillOnTime");
+    fillT.SetNameTab("OnTime");
+
     MFDataMember f0("DataType.fVal", '<', 0.5, "FilterOffData");
     MFDataMember f1("DataType.fVal", '>', 0.5, "FilterOnData");
@@ -755,12 +766,14 @@
     fill1.SetFilter(&f0);
     fill2.SetFilter(&f1);
+    fillT.SetFilter(&f1);
 
     tlist.AddToList(&read);
     //tlist.AddToList(&taskenv0); // not necessary, stored in file!
     //tlist.AddToList(&taskenv1); // not necessary, stored in file!
+    tlist.AddToList(&f1);
+    tlist.AddToList(&fillT);
     tlist.AddToList(fCutS);
     tlist.AddToList(&taskenv2);
     tlist.AddToList(&f0);
-    tlist.AddToList(&f1);
     tlist.AddToList(&fill1);
     tlist.AddToList(&fill2);
@@ -1545,5 +1558,5 @@
     // Read from the ganymed file
     TH1D htheta, size;
-    const Float_t ontime = ReadInput(plist, htheta, size);
+    Float_t ontime = ReadInput(plist, htheta, size);
     if (ontime<0)
     {
@@ -1562,4 +1575,55 @@
     }
     plist.AddToList(&bins2); // For later use in MC processing
+
+    // -------------- Fill excess events versus energy ---------------
+
+    TH1D excess;
+
+    if (fForceOnTimeFit)
+    {
+        // Refill excess histogram to determine the excess events
+        // If we use the eff. on-time fit we have to loop over the data first
+        // This is not really desired, because if something is wrong with
+        // the Monte Carlos the program runs quite long before it fails
+        if (!Refill(plist, excess))
+            return kFALSE;
+
+        // Print the setup and result of the MAlphaFitter, print used cuts
+        PrintSetup(fit);
+
+        // ------------ On user request redo eff. on-time fit ------------
+        const MHEffectiveOnTime *htime = (MHEffectiveOnTime*)plist.FindObject("MHEffectiveOnTime");
+        if (!htime)
+        {
+            // This should never happen, bt you never know
+            *fLog << err;
+            *fLog << "ERROR - Use of new effective on-time fit requested for on-time determination," << endl;
+            *fLog << "        but MHEffectiveOnTime not found in parameter list... aborting." << endl;
+            return kFALSE;
+        }
+
+        const TH1D &h = htime->GetHEffOnTheta();
+        /*
+        if (!htime->IsConsistent() || h.GetNbinsX()!=htheta.GetNbinsX())
+        {
+            *fLog << err << "ERROR - Effective on-time from newly filles MHEffectiveOnTime (Tab='OnTime) invalid... aborting." << endl;
+            return kFALSE;
+        }*/
+
+        *fLog << inf;
+        *fLog << "Using eff. on-time from new MHEffectiveOnTime (see also 'OnTime')" << endl;
+        *fLog << "   Orig. value: " << ontime << "s" << endl;
+
+        // Copy ontime from newly filled and fitted eff on-time histogram
+        ontime = htime->GetEffOnTime();
+
+        *fLog << "   New   value: " << ontime << "s" << endl;
+
+        h.Copy(htheta);           // Copy contents of newly filled hist into on-time vs. theta
+        htheta.SetName("Theta");  // Copy overwrites the name needed in DisplayResult
+        htheta.SetDirectory(0);   // Remove from global directory added by SetName
+    }
+
+    // ---------------------------------------------------------------
 
     // Initialize weighting to a new spectrum as defined in the resource file
@@ -1612,14 +1676,13 @@
         return kFALSE;
 
-    // -------------- Fill excess events versus energy ---------------
-
     // Refill excess histogram to determine the excess events
-    TH1D excess;
-    if (!Refill(plist, excess))
-        return kFALSE;
-
-    // Print the setup and result of the MAlphaFitter, print used cuts
-    PrintSetup(fit);
-
+    if (!fForceOnTimeFit)
+    {
+        if (!Refill(plist, excess))
+            return kFALSE;
+
+        // Print the setup and result of the MAlphaFitter, print used cuts
+        PrintSetup(fit);
+    }
 
     // ------------------------- Final loop --------------------------
@@ -1768,5 +1831,4 @@
     fillsp.SetWeight();
 
-    // Try to find the class used to determine the signal!
     // FIXME: To be done: A task checking the lower 1% after the lower
     // energy limit!
@@ -1789,4 +1851,9 @@
         return kFALSE;
     par->SetVal(2);
+
+    // Not really necessary but for sanity
+    TObject *cam = plist.FindObject("MSrcPosCam");
+    if (cam)
+        cam->Clear();
 
     tlist2.AddToList(&read);
Index: /trunk/MagicSoft/Mars/mjobs/MJSpectrum.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJSpectrum.h	(revision 9342)
+++ /trunk/MagicSoft/Mars/mjobs/MJSpectrum.h	(revision 9343)
@@ -38,4 +38,5 @@
     Bool_t fForceTheta;
     Bool_t fForceRunTime;
+    Bool_t fForceOnTimeFit;
 
     // Setup Histograms
@@ -76,4 +77,5 @@
     void ForceTheta(Bool_t b=kTRUE)   { fForceTheta=b; }
     void ForceRunTime(Bool_t b=kTRUE) { fForceRunTime=b; }
+    void ForceOnTimeFit(Bool_t b=kTRUE) { fForceOnTimeFit=b; }
 
     void SetEnergyEstimator(const MTask *task);
Index: /trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 9343)
@@ -334,4 +334,5 @@
         write.AddContainer("MMcEvt",                "Events");
         write.AddContainer("MMcTrig",               "Events", kFALSE);
+        write.AddContainer("MSrcPosCam",            "Events");
         // Monte Carlo Run Headers
         write.AddContainer("MMcRunHeader",          "RunHeaders");
Index: /trunk/MagicSoft/Mars/sponde.cc
===================================================================
--- /trunk/MagicSoft/Mars/sponde.cc	(revision 9342)
+++ /trunk/MagicSoft/Mars/sponde.cc	(revision 9343)
@@ -50,6 +50,10 @@
     gLog << "   -b                        Batch mode (no graphical output to screen)" << endl<<endl;
     gLog << " Operation Mode:" << endl;
-    gLog << "   --force-theta             Force execution even with non-fitting theta distributions." << endl;
-    gLog << "   --force-runtime           Force usage of runtime instead of eff. observation time." << endl;
+    gLog << "   --force-theta             Force execution even with non-fitting theta" << endl;
+    gLog << "                             distributions." << endl;
+    gLog << "   --force-runtime           Force usage of runtime instead of effective" << endl;
+    gLog << "                             observation time from fit in star." << endl;
+    gLog << "   --force-ontimefit         Force usage of effective on-time from a new fit to" << endl;
+    gLog << "                             the time-stamps (overwrites --force-runtime)." << endl;
     gLog << endl;
     gLog << " Options:" << endl;
@@ -95,4 +99,6 @@
         return 0xff;
 
+    MLog::RedirectErrorHandler(MLog::kColor);
+
     //
     // Evaluate arguments
@@ -129,4 +135,5 @@
     const Bool_t  kForceTheta    =  arg.HasOnlyAndRemove("--force-theta");
     const Bool_t  kForceRunTime  =  arg.HasOnlyAndRemove("--force-runtime");
+    const Bool_t  kForceOnTimeFit=  arg.HasOnlyAndRemove("--force-ontimefit");
 
     //
@@ -254,4 +261,5 @@
         job.ForceTheta(kForceTheta);
         job.ForceRunTime(kForceRunTime);
+        job.ForceOnTimeFit(kForceOnTimeFit);
 
         if (!job.Process(seq))
