Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 9596)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 9597)
@@ -19,4 +19,18 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2010/06/25 Thomas Bretz
+
+   * mjobs/MJSimulation.[h,cc]:
+     - added data member fRunNumber
+     - changed the rules to create the output file names
+     - set default run-numbers for different run-ytpes
+     - apply run-number 
+     - added IntendedPulsePosition to output
+
+   * mraw/MRawRunHeader.h:
+     - added SetFileNumber member function
+
+
+
  2010/06/24 Thomas Bretz
 
Index: /trunk/MagicSoft/Mars/mjobs/MJSimulation.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJSimulation.cc	(revision 9596)
+++ /trunk/MagicSoft/Mars/mjobs/MJSimulation.cc	(revision 9597)
@@ -128,5 +128,5 @@
 MJSimulation::MJSimulation(const char *name, const char *title)
     : fForceMode(kFALSE), fCamera(kTRUE), fForceTrigger(kFALSE),
-    fOperationMode(kModeData)
+    fOperationMode(kModeData), fRunNumber(-1)
 {
     fName  = name  ? name  : "MJSimulation";
@@ -315,4 +315,5 @@
     case kModeData:
         header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTData);
+         header.SetRunInfo(0, fRunNumber<0 ? 3 : fRunNumber);
         break;
 
@@ -320,4 +321,5 @@
         header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPedestal);
         header.SetSourceInfo("Pedestal");
+        header.SetRunInfo(0, fRunNumber<0 ? 1 : fRunNumber);
         break;
 
@@ -325,8 +327,10 @@
         header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTCalibration);
         header.SetSourceInfo("Calibration");
+        header.SetRunInfo(0, fRunNumber<0 ? 2 : fRunNumber);
         break;
 
     case kModePointRun:
         header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPointRun);
+        header.SetRunInfo(0, fRunNumber<0 ? 0 : fRunNumber);
         break;
     }
@@ -512,11 +516,10 @@
     // -------------------------------------------------------------------
 
-    const char *fmt = Form("s/cer([0-9]+)/%%s\\/00$1_%c_MonteCarlo.root/", header.GetRunTypeChar());
-
-    // 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_Y_MonteCarlo.root/", Esc(fPathOut).Data()));
-    const TString rule4(Form("s/cer([0-9]+)/%s\\/00$1_I_MonteCarlo.root/", Esc(fPathOut).Data()));
-    const TString rule3(Form(fmt, Esc(fPathOut).Data()));
+    const char *fmt = Form("s/cer([0-9]+)([0-9][0-9][0-9])/%s\\/%08d.$2_%%c_MonteCarlo$1.root/", Esc(fPathOut).Data(), fRunNumber);
+
+    const TString rule1(Form(fmt, 'R'));
+    const TString rule2(Form(fmt, 'Y'));
+    const TString rule4(Form(fmt, 'I'));
+    const TString rule3(Form(fmt, header.GetRunTypeChar()));
 
     MWriteRootFile write4a( 2, rule4, fOverwrite?"RECREATE":"NEW", "Star file");
@@ -551,6 +554,12 @@
 
     // D: Dedicated file structure
-    write3a.AddContainer("ElectronicNoise", "RunHeaders");
-    write3a.AddContainer("MRawEvtData", "Events");
+    write3a.AddContainer("ElectronicNoise",  "RunHeaders");
+    write3a.AddContainer("IntendedPulsePos", "RunHeaders");
+    write3a.AddContainer("MRawEvtData",      "Events");
+    // It doesn't make much sene to write this information
+    // to the file because the units are internal units not
+    // related to the output samples
+    //    if (header.IsDataRun() || fForceTrigger)
+    //        write3a.AddContainer("TriggerPos",   "Events");
 
     // I: Dedicated file structure
Index: /trunk/MagicSoft/Mars/mjobs/MJSimulation.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJSimulation.h	(revision 9596)
+++ /trunk/MagicSoft/Mars/mjobs/MJSimulation.h	(revision 9597)
@@ -23,5 +23,6 @@
     Bool_t fForceTrigger;   // Force the use of the trigger "electronics"
 
-    Int_t fOperationMode;   // Operation mode (data, ped, cal, pointrun)
+    Int_t  fOperationMode;  // Operation mode (data, ped, cal, pointrun)
+    Int_t  fRunNumber;      // 8 digits run number to be used for the file names
 
     Bool_t WriteResult(const MParList &plist, const MSequence &seq);
@@ -38,4 +39,6 @@
     void SetMode(Int_t mode) { fOperationMode = mode; }
 
+    void SetRunNumber(Int_t n=-1) { fRunNumber = n%100000000; }
+
     // Process
     Bool_t Process(const MArgs &args, const MSequence &seq);
