Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 9327)
+++ trunk/MagicSoft/Mars/Changelog	(revision 9328)
@@ -22,4 +22,54 @@
    * datacenter/macros/fillsources.C:
      - updated
+
+   * mfileio/MWriteRootFile.[h,cc]:
+     - added some comments
+     - renamed GetNewFileName to SubstituteName
+     - made SubstituteName static
+
+   * mhist/MHCamera.cc:
+     - fixed the number in the legend (was wrong since last update)
+
+   * mjobs/MDataSet.cc:
+     - replaced From by MString::Format
+
+   * mjobs/MJSimulation.cc:
+     - a lot of things were renamed
+     - the refelctor can now be set from the setup file
+     - changed the binning for the event width
+     - removed plot "CamShadow"
+     - changed rules for file names
+
+   * ceres.rc:
+     - updated according to the changes in MJSimulation
+
+   * mjobs/MSequence.cc:
+     - replaced use of Form by MString::Format
+     - allow non-setting of fNight
+     - don't print period if -1
+
+   * mmain/MEventDisplay.cc:
+     - decode trigger pattern for display 
+
+   * mmain/Makefile:
+     - included mtrigger
+
+   * msim/MHPhotonEvent.cc:
+     - search Reflector instead of MReflector
+
+   * msim/MSimAbsorption.cc:
+     - added some info output
+
+   * msimcamera/MSimAPD.[h,cc]:
+     - added an option to set the geom cam name. Can be used to skip 
+       this task
+
+   * msimcamera/MSimCamera.[h,cc]:
+     - allow to set BaselineGain from resource file
+
+   * msimreflector/MSimReflector.cc:
+     - removed CamShadow container
+     - search Reflector instead of MReflector
+
 
 
Index: trunk/MagicSoft/Mars/Makefile
===================================================================
--- trunk/MagicSoft/Mars/Makefile	(revision 9327)
+++ trunk/MagicSoft/Mars/Makefile	(revision 9328)
@@ -55,5 +55,4 @@
           mpedestal \
           mfileio \
-          mreflector \
           mgeom \
 	  melectronics \
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 9327)
+++ trunk/MagicSoft/Mars/NEWS	(revision 9328)
@@ -7,4 +7,7 @@
    * fixed a few small bugs which could cause the display to crash in ganymed
      and sponde
+
+   * in sequence file the date can now be omittet. In this case the
+     leading date with the underscore is missing in the expected filename
 
  ;database
Index: trunk/MagicSoft/Mars/ceres.rc
===================================================================
--- trunk/MagicSoft/Mars/ceres.rc	(revision 9327)
+++ trunk/MagicSoft/Mars/ceres.rc	(revision 9328)
@@ -73,10 +73,11 @@
 # Setup the reflector and camera geometry
 # -------------------------------------------------------------------------
-#MReflector.FileName: mreflector/reflector-magic.def
-MReflector.FileName: mreflector/reflector-dwarf.def
+Reflector.Constructor: MReflector
+#Reflector.FileName: mreflector/reflector-magic.def
+Reflector.FileName: mreflector/reflector-dwarf.def
 
 # --- DWARF ---
-#GeomAPDs.Constructor:  MGeomCamDwarf(419., 15, 17);
-#MGeomCam.Constructor:  MGeomCamDwarf(419., 30, 17);
+#GeomCones.Constructor:  MGeomCamDwarf(419., 15, 17);
+#MGeomCam.Constructor:   MGeomCamDwarf(419., 30, 17);
 
 # distance from mirror to camera [cm]
@@ -85,6 +86,6 @@
 #paraboloid_focal   488.87
 
-GeomAPDs.Constructor:  MGeomCamDwarf(209.5, 7.5, 4.8887);
-MGeomCam.Constructor:  MGeomCamDwarf(209.5, 15,  4.8887);
+GeomCones.Constructor:  MGeomCamDwarf(209.5, 7.5, 4.8887);
+MGeomCam.Constructor:   MGeomCamDwarf(209.5, 15,  4.8887);
 
 MSimBundlePhotons.FileName: mreflector/dwarf-apdmap.txt
@@ -93,14 +94,14 @@
 
 # --- MAGIC ---
-#GeomAPDs.Class: MGeomCamMagic
-#MGeomCam.Class: MGeomCamMagic
-
+#GeomCones.Class: MGeomCamMagic
+#MGeomCam.Class:  MGeomCamMagic
+#MSimAPD.NameGeomCam:
 
 # -------------------------------------------------------------------------
 # Setup the absorption, conversion efficiency and angular acceptance
 # -------------------------------------------------------------------------
-AbsorptionMirrors.FileName: mreflector/pde-mirror.txt
-AbsorptionAPDs.FileName:    mreflector/pde-apd.txt
-AbsorptionCones.FileName:   mreflector/dwarf-cones.txt
+MirrorReflectivity.FileName:           mreflector/pde-mirror.txt
+PhotonDetectionEfficiency.FileName:    mreflector/pde-apd.txt
+ConesAngularAcceptance.FileName:       mreflector/dwarf-cones.txt
 
 
@@ -134,14 +135,14 @@
 
 # Magic like 3NN trigger (inner 396 pixel)
-#MSimTrigger.FileNameCoincidenceMap:  3NN-lut-uniq.txt
-#MSimTrigger.DiscriminatorThreshold:  4.5
+MSimTrigger.FileNameCoincidenceMap:  3NN-lut-uniq.txt
+MSimTrigger.DiscriminatorThreshold:  6.0
+MSimTrigger.DigitalSignalLength:     8
+MSimTrigger.CoincidenceTime:         0.5
+
+# Magic like 4NN trigger (inner 396 pixel)
+#MSimTrigger.FileNameCoincidenceMap:  4NN-lut-uniq.txt
+#MSimTrigger.DiscriminatorThreshold:  5.0
 #MSimTrigger.DigitalSignalLength:     8
 #MSimTrigger.CoincidenceTime:         0.5
-
-# Magic like 4NN trigger (inner 396 pixel)
-MSimTrigger.FileNameCoincidenceMap:  4NN-lut-uniq.txt
-MSimTrigger.DiscriminatorThreshold:  5.0
-MSimTrigger.DigitalSignalLength:     8
-MSimTrigger.CoincidenceTime:         0.5
 
 IntendedPulsePos.Val: 40
@@ -167,2 +168,3 @@
 MRawRunHeader.FadcResolution:      12
 
+#MSimReadout.fConversionFactor: 1
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 9327)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 9328)
@@ -192,5 +192,5 @@
 //
 // comp:        Compression Level (see TFile, TBranch)
-// rule:        Rule to create output file name (see GetNewFileName())
+// rule:        Rule to create output file name (see SubstituteName())
 // overwrite:   Allow newly created file to overwrite old files ("RECREATE")
 // ftitle:      File title stored in the file (see TFile)
@@ -849,5 +849,6 @@
 //   "s/source/destination/"
 //
-// For more details on regular expression see a proper documentation.
+// For more details on regular expression see a proper documentation,
+// for example, "man 7 regex" if installed, or TPRegexp.
 //
 // Here is an example:
@@ -862,8 +863,10 @@
 // your set in your program it must look \\/.
 //
-TString MWriteRootFile::GetNewFileName(const char *inname) const
+// Note, that this function has been made static to allow your to
+// test your split rules, i.e. regular expressions.
+//
+TString MWriteRootFile::SubstituteName(const char *regexp, TString fname)
 {
     // Remove the path from the filename
-    TString fname(inname);
     if (fname.Last('/')>=0)
         fname.Remove(0, fname.Last('/')+1);
@@ -873,8 +876,8 @@
 
     // Do splitting
-    TObjArray *subStrL = TPRegexp(sed).MatchS(fSplitRule);
+    TObjArray *subStrL = TPRegexp(sed).MatchS(regexp);
     if (subStrL->GetEntries()!=6)
     {
-        *fLog << err << "ERROR - GetNewFileName: Evaluating split rule " << fSplitRule << " failed." << endl;
+        gLog << err << "ERROR - SubstituteName: Evaluating regexp " << regexp << " failed." << endl;
         subStrL->Print();
         delete subStrL;
@@ -1045,5 +1048,5 @@
 
     const TString oldname = read->GetFullFileName();
-    const TString newname = GetNewFileName(oldname);
+    const TString newname = SubstituteName(fSplitRule, oldname);
     if (!ChangeFile(newname))
         return kFALSE;
Index: trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 9327)
+++ trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 9328)
@@ -94,5 +94,4 @@
     // File handling
     void    Close();
-    TString GetNewFileName(const char *inname) const;
     Bool_t  ChangeFile(const char *fname);
     TFile  *OpenFile(const char *name, Option_t *option, const char *title, Int_t comp);
@@ -145,4 +144,6 @@
     void RecursiveRemove(TObject *obj);
 
+    static TString SubstituteName(const char *regexp, TString fname);
+
     ClassDef(MWriteRootFile, 1)	// Task to write data into a root file
 };
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 9327)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 9328)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.116 2009-02-11 12:25:42 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.117 2009-02-12 20:05:06 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -1889,5 +1889,5 @@
         newtxt2.PaintText(-range*.95, -range*.95, text);
 
-        text = MString::Format("%.2f\\circ", range*.3*fGeomCam->GetConvMm2Deg());
+        text = MString::Format("%.2f\\circ", range*(0.99-0.60)*fGeomCam->GetConvMm2Deg());
         text = text.Strip(TString::kLeading);
 
Index: trunk/MagicSoft/Mars/mjobs/MDataSet.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 9327)
+++ trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 9328)
@@ -217,4 +217,5 @@
 #include "MEnv.h"
 #include "MAstro.h"
+#include "MString.h"
 #include "MDirIter.h"
 #include "MSequence.h"
@@ -297,7 +298,7 @@
         // Set default sequence file and dir name
         if (name.IsNull())
-            name = Form("%s%04d/sequence%08d.txt", sequences.Data(), num[i]/10000, num[i]);
+            name = MString::Format("%s%04d/sequence%08d.txt", sequences.Data(), num[i]/10000, num[i]);
         if (dir.IsNull())
-            dir = Form("%s%04d/%08d", data.Data(), num[i]/10000, num[i]);
+            dir = MString::Format("%s%04d/%08d", data.Data(), num[i]/10000, num[i]);
 
         // Check if sequence information is contained in Dataset file
@@ -385,5 +386,5 @@
 
     // Determin the prefix to access this resource
-    const TString prefix = num==(UInt_t)-1 ? "" : Form("%d", num);
+    const TString prefix = num==(UInt_t)-1 ? "" : MString::Format("%d", num);
 
     // Open and read the file
@@ -494,8 +495,8 @@
     const Bool_t useds = seq.GetFileName()==fFileName;
 
-    out << "Sequence" << Form("%08d", seq.GetSequence()) << ".File:   " << (useds?"-":seq.GetFileName()) << endl;
-    out << "Sequence" << Form("%08d", seq.GetSequence()) << ".Dir:    " << seq.GetDataPath() << endl;
+    out << "Sequence" << MString::Format("%08d", seq.GetSequence()) << ".File:   " << (useds?"-":seq.GetFileName()) << endl;
+    out << "Sequence" << MString::Format("%08d", seq.GetSequence()) << ".Dir:    " << seq.GetDataPath() << endl;
     if (!useds && seq.GetNumExclRuns()>0)
-        out << "Sequence" << Form("%08d", seq.GetSequence()) << ".Exclude: " << seq.GetExcludedRuns() << endl;
+        out << "Sequence" << MString::Format("%08d", seq.GetSequence()) << ".Exclude: " << seq.GetExcludedRuns() << endl;
 
     if (useds)
Index: trunk/MagicSoft/Mars/mjobs/MJSimulation.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJSimulation.cc	(revision 9327)
+++ trunk/MagicSoft/Mars/mjobs/MJSimulation.cc	(revision 9328)
@@ -152,7 +152,7 @@
 
     cont.Add(plist.FindObject("MPulseShape"));
-    cont.Add(plist.FindObject("MReflector"));
+    cont.Add(plist.FindObject("Reflector"));
     cont.Add(plist.FindObject("MGeomCam"));
-    cont.Add(plist.FindObject("GeomAPDs"));
+    cont.Add(plist.FindObject("GeomCones"));
 
     if (fDisplay)
@@ -248,16 +248,14 @@
     // --------------------------------------------------------------------------------
 
-    // ---------- FIXME FIXME FIXME -----------
-    // FIXME: Find a better name (What if both cams are identical?)
-    MParEnv env1("GeomAPDs");  // Inheritance!
-    MParEnv env2("MGeomCam");  // Inheritance!
+    // FIXME: Allow empty GeomCones!
+    MParEnv env0("Reflector");
+    MParEnv env1("GeomCones");
+    MParEnv env2("MGeomCam");
+    env0.SetClassName("MReflector");
     env1.SetClassName("MGeomCam");
     env2.SetClassName("MGeomCam");
+    plist.AddToList(&env0);
     plist.AddToList(&env1);
     plist.AddToList(&env2);
-
-    // FIXME: Allow the user to create other reflectors
-    MReflector reflector;
-    plist.AddToList(&reflector);
 
     plist.FindCreateObj("MPedPhotCam", "MPedPhotFromExtractorRndm");
@@ -314,7 +312,7 @@
     MSimMMCS simmmcs;
 
-    MSimAbsorption absapd("AbsorptionAPDs");
-    MSimAbsorption absmir("AbsorptionMirrors");
-    MSimAbsorption cones("AbsorptionCones");
+    MSimAbsorption absapd("PhotonDetectionEfficiency");
+    MSimAbsorption absmir("MirrorReflectivity");
+    MSimAbsorption cones("ConesAngularAcceptance");
     cones.SetUseTheta();
 
@@ -322,5 +320,5 @@
 
     MSimReflector reflect;
-    reflect.SetNameGeomCam("GeomAPDs");
+    reflect.SetNameGeomCam("GeomCones");
 //  MSimStarField stars;
 
@@ -337,5 +335,5 @@
     MBinning binszd( 70,     0,       70, "BinningZd");
     MBinning binsvc(155,     0,       31, "BinningViewCone");
-    MBinning binsew(150,     0,       25, "BinningEvtWidth");
+    MBinning binsew(150,     0,       50, "BinningEvtWidth");
     MBinning binstr("BinningTrigPos");
 
@@ -357,9 +355,9 @@
     MH3 mhtp("TriggerPos.fVal-IntendedPulsePos.fVal-MPulseShape.GetPulseWidth");
     mhtp.SetName("TrigPos");
-    mhtp.SetTitle("Trigger position w.r.t. the first photon hitting an APD");
+    mhtp.SetTitle("Trigger position w.r.t. the first photon hitting a detector");
 
     MH3 mhew("MPhotonStatistics.fTimeLast-MPhotonStatistics.fTimeFirst - MRawRunHeader.GetFreqSampling/1000.*MRawRunHeader.fNumSamplesHiGain - 2*MPulseShape.GetPulseWidth");
     mhew.SetName("EvtWidth");
-    mhew.SetTitle("Time between first and last photon hitting an APD");
+    mhew.SetTitle("Time between first and last photon hitting a detector");
 
     MFillH fillh1(&mhn1, "", "FillH1");
@@ -372,5 +370,5 @@
     fillh3.SetNameTab("H3", "Distribution after trigger");
     filltp.SetNameTab("TrigPos", "TriggerPosition w.r.t the first photon");
-    fillew.SetNameTab("EvtWidth", "Time between first and last photon hitting an APD");
+    fillew.SetNameTab("EvtWidth", "Time between first and last photon hitting a detector");
 
     MHPhotonEvent planeG(1);     // Get from MaxImpact
@@ -387,27 +385,28 @@
     MFillH fillG(&planeG,   "MPhotonEvent", "FillGround");
     MFillH fill0(&plane0,   "MirrorPlane0", "FillReflector");
-    MFillH fill1(&plane1,   "MirrorPlane1", "FillCamShadow");
+    //MFillH fill1(&plane1,   "MirrorPlane1", "FillCamShadow");
     MFillH fill2(&plane2,   "MirrorPlane2", "FillCandidates");
     MFillH fill3(&plane3,   "MirrorPlane3", "FillReflected");
     MFillH fill4(&plane4,   "MirrorPlane4", "FillFocal");
     MFillH fillF1(&planeF1, "MPhotonEvent", "FillCamera");
-    MFillH fillF2(&planeF2, "MPhotonEvent", "FillAPDs");
+    MFillH fillF2(&planeF2, "MPhotonEvent", "FillCones");
     //MFillH fillP(&psf,      "MPhotonEvent", "FillPSF");
 
     fillG.SetNameTab("Ground",     "Photon distribution at ground");
     fill0.SetNameTab("Reflector",  "Photon distribution at reflector plane w/o camera shadow");
-    fill1.SetNameTab("CamShadow",  "Photon distribution at reflector plane w/ camera shadow");
+    //fill1.SetNameTab("CamShadow",  "Photon distribution at reflector plane w/ camera shadow");
     fill2.SetNameTab("Candidates", "'Can hit' photon distribution at reflector plane w/ camera shadow");
     fill3.SetNameTab("Reflected",  "Photon distribution after reflector projected to reflector plane");
     fill4.SetNameTab("Focal",      "Photon distribution at focal plane");
     fillF1.SetNameTab("Camera",    "Photon distribution which hit the detector");
-    fillF2.SetNameTab("APDs",      "Photon distribution after cones");
+    fillF2.SetNameTab("Cones",     "Photon distribution after cones");
     //fillP.SetNameTab("PSF",        "Photon distribution after cones for all mirrors");
 
     // -------------------------------------------------------------------
 
-    const TString rule1(Form("s/cer([0-9]+)/%s\\/ref$1.root/", Esc(fPathOut).Data()));
-    const TString rule2(Form("s/cer([0-9]+)/%s\\/sig$1.root/", Esc(fPathOut).Data()));
-    const TString rule3(Form("s/cer([0-9]+)/%s\\/cam$1.root/", Esc(fPathOut).Data()));
+    // FIXME: Pedestal and Calibration runs should get P and C
+    const TString rule1(Form("s/cer([0-9]+)/%s\\/00$1_R_MonteCarlo.root/", Esc(fPathOut).Data()));
+    const TString rule2(Form("s/cer([0-9]+)/%s\\/00$1_I_MonteCarlo.root/", Esc(fPathOut).Data()));
+    const TString rule3(Form("s/cer([0-9]+)/%s\\/00$1_D_MonteCarlo.root/", Esc(fPathOut).Data()));
 
     MWriteRootFile write3a( 2, rule3, fOverwrite?"RECREATE":"NEW", "Camera file");
@@ -471,8 +470,8 @@
 
     MSimGeomCam simgeom;
-    simgeom.SetNameGeomCam("GeomAPDs");
+    simgeom.SetNameGeomCam("GeomCones");
 
     MSimCalibrationSignal simcal;
-    simcal.SetNameGeomCam("GeomAPDs");
+    simcal.SetNameGeomCam("GeomCones");
 
     //  Dark Current: 4MHz = 0.004 GHz
@@ -484,5 +483,5 @@
 //    simnsb.SetFreq(0.005, 0.004);    // 5MHz/cm^2, 4MHz
     simnsb.SetFreq(0, 0.04);           // 40MHz fixed for each APD
-    simnsb.SetNameGeomCam("GeomAPDs");
+    simnsb.SetNameGeomCam("GeomCones");
 
     // FIXME: How do we handle star-light? We need the rate but we also
@@ -491,5 +490,5 @@
     MSimAPD simapd;
     simapd.SetFreq(0.04); // Must be identical to MSimRanodmPhotons!!
-    simapd.SetNameGeomCam("GeomAPDs");
+    simapd.SetNameGeomCam("GeomCones");
 
     MSimExcessNoise   simexcnoise;
@@ -563,5 +562,5 @@
         {
             tasks.AddToList(&fill0);
-            tasks.AddToList(&fill1);
+            //tasks.AddToList(&fill1);
             tasks.AddToList(&fill2);
             tasks.AddToList(&fill3);
@@ -645,4 +644,5 @@
         return kFALSE;
 
+    // FIXME: If pedestal file given use the values from this file
     //-------------------------------------------
 
@@ -652,4 +652,6 @@
 
     header.Print();
+
+    // FIXME: Display acceptance curves!
 
     if (fDisplay)
@@ -666,5 +668,5 @@
         shape.DrawClone()->SetBit(kCanDelete);
 
-        if (header.IsDataRun() || header.IsPointRun())
+        if (env0.GetCont() && (header.IsDataRun() || header.IsPointRun()))
         {
             c.cd(3);
@@ -674,5 +676,5 @@
             gPad->SetGridy();
             gROOT->SetSelectedPad(0);
-            reflector.DrawClone("line")->SetBit(kCanDelete);
+            static_cast<MReflector*>(env0.GetCont())->DrawClone("line")->SetBit(kCanDelete);
 
         }
@@ -680,5 +682,5 @@
         if (fCamera)
         {
-            if (dynamic_cast<MGeomCam*>(env1.GetCont()))
+            if (env1.GetCont())
             {
                 c.cd(2);
@@ -696,5 +698,5 @@
             }
 
-            if (dynamic_cast<MGeomCam*>(env2.GetCont()))
+            if (env2.GetCont())
             {
                 c.cd(4);
Index: trunk/MagicSoft/Mars/mjobs/MSequence.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 9327)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 9328)
@@ -416,4 +416,6 @@
         case kRoot: // mcdata
             d += "rawfiles/";
+            if (!fNight)
+                *fLog << "WARNING - No Night-resource... path not supported." << endl;
             d += fNight.GetStringFmt("%Y/%m/%d");
             break;
@@ -423,8 +425,8 @@
             break;
         case kCalibrated:
-            d += Form("callisto/%04d/%08d", fSequence/10000, fSequence);
+            d += MString::Format("callisto/%04d/%08d", fSequence/10000, fSequence);
             break;
         case kImages:
-            d += Form("star/%04d/%08d", fSequence/10000, fSequence);
+            d += MString::Format("star/%04d/%08d", fSequence/10000, fSequence);
             break;
         }
@@ -477,21 +479,24 @@
 
     // ------------- Create file name --------------
-    TString n = night.GetStringFmt("%Y%m%d_");
+    TString n;
+
+    if (night)
+        n += night.GetStringFmt("%Y%m%d_");
 
     // This is for MCs (FIXME!!!!)
     if (run<0)
-        n += Form("%08d", -run);
+        n += MString::Format("%08d", -run);
     else
     {
         if (tel>0)
-            n += Form("M%d_", tel);
+            n += MString::Format("M%d_", tel);
 
         // R. DeLosReyes and T. Bretz
         // Changes to read the DAQ numbering format. Changes takes place
         // between runs 35487 and 00035488 (2004_08_30)
-        n += Form(run>limit ? "%08d" : "%05d", run);
+        n += MString::Format(run>limit ? "%08d" : "%05d", run);
 
         if (tel>0)
-            n += Form(".%03d", file);
+            n += MString::Format(".%03d", file);
     }
 
@@ -876,5 +881,5 @@
     fSequence = (UInt_t)env.GetValue("Sequence", (Int_t)seq);
 
-    const TString prefix = Form("Sequence%08d", fSequence);
+    const TString prefix = MString::Format("Sequence%08d", fSequence);
 
     fTelescope = GetEnvValue2(env, prefix, "Telescope",  1);
@@ -890,13 +895,5 @@
 
     str = GetEnvValue2(env, prefix, "Night", "");
-    if (str.IsNull())
-        fNight = MTime();
-    else
-    {
-        str += " 00:00:00";
-        fNight.SetSqlDateTime(str);
-    }
-
-    fPeriod = fNight.GetMagicPeriod();
+    SetNight(str);
 
     fProject      = GetEnvValue2(env, prefix, "Project", "");
@@ -1160,5 +1157,5 @@
     while (p<pos+n)
     {
-        str += Form(" %d", f[p]);
+        str += MString::Format(" %d", f[p]);
 
         if (p==pos+n-1)
@@ -1171,5 +1168,5 @@
 
         if (i>1)
-            str += Form(":%d", f[p+i-1]);
+            str += MString::Format(":%d", f[p+i-1]);
 
         p += i;
@@ -1212,5 +1209,5 @@
             return str;
 
-        str += Form(" %d", r[p]);
+        str += MString::Format(" %d", r[p]);
         // p now points to the last entry which fits and
         // has a file number == 0
@@ -1219,5 +1216,5 @@
         // More tahn one found (i-1>1)
         str += i-1==1 ? " " : ":";
-        str += Form("%d", r[p]);
+        str += MString::Format("%d", r[p]);
 
         // One step forward
@@ -1294,5 +1291,5 @@
                 str += '\n';
                 str += pre;
-                str += Form("Run%08d:", r[pos]);
+                str += MString::Format("Run%08d:", r[pos]);
                 str += GetNumSequence(pos, n, f);
             }
@@ -1327,5 +1324,5 @@
     const TString opt(o);
 
-    const TString pre = opt.Contains("prefixed") ? Form("Sequence%08d.", fSequence) : "";
+    const TString pre = opt.Contains("prefixed") ? MString::Format("Sequence%08d.", fSequence) : "";
 
     if (!IsValid())
@@ -1345,5 +1342,5 @@
     if (fMonteCarlo)
         out << pre << "MonteCarlo:     Yes" << endl;
-    if (fPeriod>=0)
+    if (fPeriod!=(UInt_t)-1)
         out << pre << "Period:         " << fPeriod << endl;
     if (fNight!=MTime())
@@ -1513,4 +1510,12 @@
 {
     TString night(txt);
+
+    if (night.IsNull())
+    {
+        fNight  = MTime();
+        fPeriod = UInt_t(-1);
+        return;
+    }
+
     night += " 00:00:00";
     fNight.SetSqlDateTime(night);
@@ -1574,6 +1579,6 @@
             seq = "/magic/";
             if (ismc)
-            seq += "montecarlo/";
-            seq += Form("sequences/%04d/sequence%08d.txt", numseq/10000, numseq);
+                seq += "montecarlo/";
+            seq += MString::Format("sequences/%04d/sequence%08d.txt", numseq/10000, numseq);
             gLog << inf << "Inflated sequence file: " << seq << endl;
         }
Index: trunk/MagicSoft/Mars/mmain/MEventDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MEventDisplay.cc	(revision 9327)
+++ trunk/MagicSoft/Mars/mmain/MEventDisplay.cc	(revision 9328)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: MEventDisplay.cc,v 1.68 2009-02-11 12:31:47 tbretz Exp $
+! $Name: not supported by cvs2svn $:$Id: MEventDisplay.cc,v 1.69 2009-02-12 20:05:06 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -91,4 +91,5 @@
 #include "MMuonCalibParCalc.h"         // MMuonCalibParCalc
 #include "MContinue.h"                 // MContinue
+#include "MTriggerPatternDecode.h"     // MTriggerPatternDecode
 //#include "MMcTriggerLvl2Calc.h"        // MMcTriggerLvl2Calc
 
@@ -250,4 +251,6 @@
     tlist->AddToList(apl);
 
+    MTriggerPatternDecode *decode = new MTriggerPatternDecode;
+    tlist->AddToList(decode);
 
     //MArrivalTime *atime = new MArrivalTime;
Index: trunk/MagicSoft/Mars/mmain/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mmain/Makefile	(revision 9327)
+++ trunk/MagicSoft/Mars/mmain/Makefile	(revision 9328)
@@ -23,5 +23,6 @@
            -I../mfileio -I../mimage -I../mhistmc -I../mgbase -I../mfbase  \
            -I../mdata -I../msignal -I../mcalib -I../mbadpixels            \
-           -I../mpointing -I../mpedestal -I../mmuon -I../mfilter -I../mjobs
+           -I../mpointing -I../mpedestal -I../mmuon -I../mfilter -I../mjobs \
+	   -I../mtrigger
 
 SRCFILES = MBrowser.cc \
Index: trunk/MagicSoft/Mars/msim/MHPhotonEvent.cc
===================================================================
--- trunk/MagicSoft/Mars/msim/MHPhotonEvent.cc	(revision 9327)
+++ trunk/MagicSoft/Mars/msim/MHPhotonEvent.cc	(revision 9328)
@@ -194,8 +194,8 @@
     case 2:
         {
-            MReflector *r = (MReflector*)pList->FindObject("MReflector");
+            MReflector *r = (MReflector*)pList->FindObject("Reflector", "MReflector");
             if (!r)
             {
-                *fLog << err << "MReflector not found... aborting." << endl;
+                *fLog << err << "Reflector [MReflector] not found... aborting." << endl;
                 return kFALSE;
             }
Index: trunk/MagicSoft/Mars/msim/MSimAbsorption.cc
===================================================================
--- trunk/MagicSoft/Mars/msim/MSimAbsorption.cc	(revision 9327)
+++ trunk/MagicSoft/Mars/msim/MSimAbsorption.cc	(revision 9328)
@@ -235,4 +235,10 @@
 Int_t MSimAbsorption::PreProcess(MParList *pList)
 {
+    if (fFileName.IsNull())
+    {
+        *fLog << inf << "No file given... skipping." << endl;
+        return kSKIP;
+    }
+
     fEvt = (MPhotonEvent*)pList->FindObject("MPhotonEvent");
     if (!fEvt)
@@ -248,4 +254,6 @@
         return kFALSE;
     }
+
+    *fLog << inf << "Using " << (fUseTheta?"Theta":"Wavelength") << " for absorption." << endl;
 
     return ReadFile();
Index: trunk/MagicSoft/Mars/msimcamera/MSimAPD.cc
===================================================================
--- trunk/MagicSoft/Mars/msimcamera/MSimAPD.cc	(revision 9327)
+++ trunk/MagicSoft/Mars/msimcamera/MSimAPD.cc	(revision 9328)
@@ -89,4 +89,10 @@
 Int_t MSimAPD::PreProcess(MParList *pList)
 {
+    if (fNameGeomCam.IsNull())
+    {
+        *fLog << inf << "No geometry container... skipping." << endl;
+        return kSKIP;
+    }
+
     fGeom = (MGeomCam*)pList->FindObject(fNameGeomCam, "MGeomCam");
     if (!fGeom)
@@ -199,2 +205,18 @@
     return kTRUE;
 }
+
+// --------------------------------------------------------------------------
+//
+// NameGeomCam
+//
+Int_t MSimAPD::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    Bool_t rc = kFALSE;
+    if (IsEnvDefined(env, prefix, "NameGeomCam", print))
+    {
+        rc = kTRUE;
+        fNameGeomCam = GetEnvValue(env, prefix, "NameGeomCam", fNameGeomCam);
+    }
+
+    return rc;
+}
Index: trunk/MagicSoft/Mars/msimcamera/MSimAPD.h
===================================================================
--- trunk/MagicSoft/Mars/msimcamera/MSimAPD.h	(revision 9327)
+++ trunk/MagicSoft/Mars/msimcamera/MSimAPD.h	(revision 9328)
@@ -28,4 +28,7 @@
     Double_t fFreq;              // Frequency of random phtons which hit the APDs
 
+    // MParContainer
+    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
+
     // MTask
     Int_t  PreProcess(MParList *pList);
Index: trunk/MagicSoft/Mars/msimcamera/MSimCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/msimcamera/MSimCamera.cc	(revision 9327)
+++ trunk/MagicSoft/Mars/msimcamera/MSimCamera.cc	(revision 9328)
@@ -281,2 +281,18 @@
     return kTRUE;
 }
+
+// --------------------------------------------------------------------------
+//
+// BaselineGain: Off
+//
+Int_t MSimCamera::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    Bool_t rc = kFALSE;
+    if (IsEnvDefined(env, prefix, "BaselineGain", print))
+    {
+        rc = kTRUE;
+        fBaselineGain = GetEnvValue(env, prefix, "BaselineGain", fBaselineGain);
+    }
+
+    return rc;
+}
Index: trunk/MagicSoft/Mars/msimcamera/MSimCamera.h
===================================================================
--- trunk/MagicSoft/Mars/msimcamera/MSimCamera.h	(revision 9327)
+++ trunk/MagicSoft/Mars/msimcamera/MSimCamera.h	(revision 9328)
@@ -32,4 +32,7 @@
     Bool_t fBaselineGain;  // Should the gain be applied to baseline and electronic noise?
 
+    // MParContainer
+    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
+
     // MTask
     Int_t  PreProcess(MParList *pList);
Index: trunk/MagicSoft/Mars/msimreflector/MSimReflector.cc
===================================================================
--- trunk/MagicSoft/Mars/msimreflector/MSimReflector.cc	(revision 9327)
+++ trunk/MagicSoft/Mars/msimreflector/MSimReflector.cc	(revision 9328)
@@ -103,8 +103,8 @@
         return kFALSE;
 
-    fReflector = (MReflector*)pList->FindObject("MReflector");
+    fReflector = (MReflector*)pList->FindObject("Reflector", "MReflector");
     if (!fReflector)
     {
-        *fLog << err << "MReflector not found... aborting." << endl;
+        *fLog << err << "Reflector [MReflector] not found... aborting." << endl;
         return kFALSE;
     }
@@ -430,10 +430,10 @@
 
     TClonesArray &cpy0 = fMirror0->GetArray();
-    TClonesArray &cpy1 = fMirror1->GetArray();
+    //TClonesArray &cpy1 = fMirror1->GetArray();
     TClonesArray &cpy2 = fMirror2->GetArray();
     TClonesArray &cpy3 = fMirror3->GetArray();
     TClonesArray &cpy4 = fMirror4->GetArray();
     cpy0.ExpandCreateFast(arr.GetEntriesFast());
-    cpy1.ExpandCreateFast(arr.GetEntriesFast());
+    //cpy1.ExpandCreateFast(arr.GetEntriesFast());
     cpy2.ExpandCreateFast(arr.GetEntriesFast());
     cpy3.ExpandCreateFast(arr.GetEntriesFast());
@@ -507,5 +507,5 @@
 
         // FIXME: Do we really need this one??
-        *static_cast<MPhotonData*>(cpy1.UncheckedAt(cnt[1]++)) = *dat;
+        //*static_cast<MPhotonData*>(cpy1.UncheckedAt(cnt[1]++)) = *dat;
 
         // Check if the reflector can be hit at all
@@ -549,5 +549,5 @@
     // MPhotonEvent::Shrink).
     fMirror0->Shrink(cnt[0]);
-    fMirror1->Shrink(cnt[1]);
+    //fMirror1->Shrink(cnt[1]);
     fMirror2->Shrink(cnt[2]);
     fMirror3->Shrink(cnt[3]);
