Index: trunk/MagicSoft/Mars/mjobs/MDataSet.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MDataSet.cc	(revision 9319)
+++ 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 9319)
+++ 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 9319)
+++ 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;
         }
