Index: /trunk/MagicSoft/Mars/callisto.cc
===================================================================
--- /trunk/MagicSoft/Mars/callisto.cc	(revision 4728)
+++ /trunk/MagicSoft/Mars/callisto.cc	(revision 4729)
@@ -53,11 +53,14 @@
     gLog << endl;
     gLog << "   -f                        Force overwrite of existing files" << endl;
-    gLog << "   --in=path                 Path where to search for the data files" << endl;
+    gLog << "   --ind=path                Path where to search for the data files" << endl;
     gLog << "                             [default=standard path in datacenter]" << endl;
     gLog << "   --iny=path                Path where to search for the calibration files" << endl;
     gLog << "                             [default=local path or output path of Mode-C]" << endl;
-    gLog << "   --out=path                Path to write the all results to [def=local path]" << endl;
     gLog << "   --outc=path               Path to write Mode-C result to   [def=local path]" << endl;
     gLog << "   --outy=path               Path to write Mode-Y result to   [def=local path]" << endl;
+    gLog << "   --out=path                Path to write the all results to [def=local path]" << endl;
+    gLog << "                             (overwrites --outc and --outy)" << endl;
+    gLog << "   --path=path               Path to write the all results to [def=local path]" << endl;
+    gLog << "                             (overwrites --iny, --outc and --outy)" << endl;
     gLog << "   --printseq                Print Sequence information" << endl;
     gLog << "   --printfiles              Print Files taken from Sequence" << endl;
@@ -70,4 +73,6 @@
     gLog << " especially CheckEnv() for more details.   Command line options might" << endl;
     gLog << " be overwritten by the resource file." << endl << endl;
+    gLog << " If running in Mode-C and Mode-Y --iny= is obsolete,  instead --outc=" << endl;
+    gLog << " is used." << endl << endl;
     gLog << "Description:" << endl;
     gLog << " callisto will calculate pedestals  from  pedestal-files defined in a" << endl;
@@ -97,13 +102,17 @@
 
     const TString kConfig     = arg.GetStringAndRemove("--config=", "callisto.rc");
+
     const Bool_t  kPrintSeq   = arg.HasOnlyAndRemove("--printseq");
     const Bool_t  kPrintFiles = arg.HasOnlyAndRemove("--printfiles");
     const Bool_t  kPrintOnly  = arg.HasOnlyAndRemove("--printonly");
+
     const Bool_t  kOverwrite  = arg.HasOnlyAndRemove("-f");
-    const TString kInpathY    = arg.GetStringAndRemove("--iny=",  "");
-          TString kInpath     = arg.GetStringAndRemove("--in=",  "");
-    const TString kOutpath    = arg.GetStringAndRemove("--out=", "");
-          TString kOutpathC   = arg.GetStringAndRemove("--outc=", "");
-          TString kOutpathY   = arg.GetStringAndRemove("--outy=", "");
+
+    const TString kInpathD    = arg.GetStringAndRemove("--ind=",  "");
+          TString kInpathY    = arg.GetStringAndRemove("--iny=",  ".");
+          TString kOutpathY   = arg.GetStringAndRemove("--outy=", ".");
+          TString kOutpathC   = arg.GetStringAndRemove("--outc=", ".");
+    const TString kOutpath    = arg.GetStringAndRemove("--out=",  "");
+    const TString kPath       = arg.GetStringAndRemove("--path=", "");
 
     const Bool_t  kModeC      = arg.HasOnlyAndRemove("-c");
@@ -115,17 +124,19 @@
         return 0;
     }
-
     if (!kOutpath.IsNull())
     {
-        if (!kOutpathC.IsNull() || !kOutpathY.IsNull())
-        {
-            gLog << err << "You cannot use --out= and --outc= or --outy= together!" << endl;
-            return 0;
-        }
-        if (kOutpathC.IsNull())
-            kOutpathC = kOutpath;
-        if (kOutpathY.IsNull())
-            kOutpathY = kOutpath;
-    }
+        kOutpathC = kOutpath;
+        kOutpathY = kOutpath;
+    }
+    if (!kPath.IsNull())
+    {
+        kOutpathC = kOutpath;
+        kOutpathY = kOutpath;
+        kInpathY  = kOutpath;
+    }
+
+    if (kModeC && kModeY)
+        kInpathY = kOutpathC;
+
     if (arg.GetNumOptions()>0)
     {
@@ -169,7 +180,8 @@
     if (kPrintFiles)
     {
-        MDirIter Next1, Next2;
-        seq.SetupPedRuns(Next1, kInpath);
-        seq.SetupDatRuns(Next2, kInpath);
+        MDirIter Next1, Next2, Next3;
+        seq.SetupPedRuns(Next1, kInpathD);
+        seq.SetupCalRuns(Next2, kInpathD);
+        seq.SetupDatRuns(Next3, kInpathD);
 
         gLog << all;
@@ -177,6 +189,9 @@
         Next1.Print("all");
         gLog << endl;
+        gLog.Separator("Calibration Files");
+        Next2.Print("all");
+        gLog << endl;
         gLog.Separator("Data Files");
-        Next2.Print("all");
+        Next3.Print("all");
         gLog << endl;
     }
@@ -199,11 +214,12 @@
     if (kModeC)
     {
-        MJPedestal job1(Form("MJPedestal #%d", seq.GetSequence()));
-        job1.SetSequence(&seq);
+        MJPedestal job1(Form("MJPedestalC #%d", seq.GetSequence()));
+        job1.SetSequence(seq);
         job1.SetEnv(kConfig);
         job1.SetDisplay(d);;
-        job1.SetInputPath(kInpath);
-        job1.SetOutputPath(kOutpathC);
         job1.SetOverwrite(kOverwrite);
+        job1.SetPathData(kInpathD);
+        // job1.SetPathOut(kOutpathC); // not yet needed
+        // job1.SetPathIn(kInpathC);   // not yet needed
 
         if (!job1.ProcessFile())
@@ -220,11 +236,12 @@
 
         MJCalibration job2(Form("MJCalibration #%d", seq.GetSequence()));
-        job2.SetSequence(&seq);
+        job2.SetSequence(seq);
         job2.SetEnv(kConfig);
         job2.SetDisplay(d);;
         job2.SetBadPixels(job1.GetBadPixels());
-        job2.SetInputPath(kInpath);
-        job2.SetOutputPath(kOutpathC);
         job2.SetOverwrite(kOverwrite);
+        job2.SetPathOut(kOutpathC);
+        job2.SetPathData(kInpathD);
+        // job2.SetPathIn(kInpathC); // not yet needed
 
         if (!job2.ProcessFile(job1.GetPedestalCam()))
@@ -245,14 +262,39 @@
         d->Reset();
 
-        MJCalibrateSignal job(Form("MJCalibrateSignal #%d", seq.GetSequence()));
-        job.SetDisplay(d);;
-        job.SetInputPath(kInpath); // Where to search for data files
-        job.SetOutputPath(kOutpathY);
-        job.SetOverwrite(kOverwrite);
+        MJPedestal job1(Form("MJPedestalY #%d", seq.GetSequence()));
+        job1.SetSequence(seq);
+        job1.SetEnv(kConfig);
+        job1.SetDisplay(d);;
+        //job1.SetPathIn(kInpathY);     // not yet needed
+        //job1.SetPathOut(kOutpathY);   // not yet needed
+        job1.SetPathData(kInpathD);
+        job1.SetOverwrite(kOverwrite);
+
+        if (!job1.ProcessFile())
+        {
+            gLog << err << "Calculation of pedestal failed." << endl << endl;
+            return -1;
+        }
+
+        if (!job1.GetDisplay())
+        {
+            gLog << warn << "Display closed by user... execution aborted." << endl << endl;
+            return 1;
+        }
+
+        MJCalibrateSignal job2(Form("MJCalibrateSignal #%d", seq.GetSequence()));
+        job2.SetSequence(seq);
+        job2.SetDisplay(d);;
+        job2.SetEnv(kConfig);
+        job2.SetOverwrite(kOverwrite);
+        job2.SetPathIn(kInpathY);
+        job2.SetPathOut(kOutpathY);
+        job2.SetPathData(kInpathD);
+
         // Where to search for calibration files
-        if (!job.ProcessFile(seq, kConfig, kModeC ? kOutpathC : kInpathY))
+        if (!job2.ProcessFile(job1.GetPedestalCam()))
             return -1;
 
-        if (!job.GetDisplay())
+        if (!job2.GetDisplay())
         {
             gLog << warn << "Display closed by user... execution aborted." << endl << endl;
Index: /trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h	(revision 4728)
+++ /trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h	(revision 4729)
@@ -5,4 +5,5 @@
 #pragma link off all functions;
 
+#pragma link C++ class MJob+;
 #pragma link C++ class MSequence+;
 
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 4728)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 4729)
@@ -43,5 +43,4 @@
 #include "MLogManip.h"
 
-#include "MSequence.h"
 #include "MDirIter.h"
 #include "MParList.h"
@@ -83,5 +82,4 @@
 //
 MJCalibrateSignal::MJCalibrateSignal(const char *name, const char *title) 
-    : fOverwrite(kFALSE), fMaxEvents(0)
 {
     fName  = name  ? name  : "MJCalibrateSignal";
@@ -89,14 +87,13 @@
 }
 
-MJCalibrateSignal::~MJCalibrateSignal()
+Bool_t MJCalibrateSignal::WriteResult()
 {
-}
-
-Bool_t MJCalibrateSignal::WriteResult(const MSequence &seq)
-{
-    if (fOutputPath.IsNull())
+    if (fPathOut.IsNull())
+    {
+        *fLog << inf << "No output path specified via SetPathOut - no output written." << endl;
         return kTRUE;
-
-    const TString oname = Form("%s/calped%06d.root", (const char*)fOutputPath, seq.GetSequence());
+    }
+
+    const TString oname = Form("%s/calped%06d.root", (const char*)fPathOut, fSequence.GetSequence());
 
     *fLog << inf << "Writing to file: " << oname << endl;
@@ -115,42 +112,10 @@
 }
 
-void MJCalibrateSignal::SetOutputPath(const char *path)
-{
-    fOutputPath = path;
-    if (fOutputPath.EndsWith("/"))
-        fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
-}
-void MJCalibrateSignal::SetInputPath(const char *path)
-{
-    fInputPath = path;
-    if (fInputPath.EndsWith("/"))
-        fInputPath = fInputPath(0, fInputPath.Length()-1);
-}
-
-void MJCalibrateSignal::CheckEnv(const char *env)
-{
-    TEnv e(env);
-
-    TString e1 = e.GetValue("MJCalibrateSignal.OutputPath", "");
-    if (!e1.IsNull())
-    {
-        e1.ReplaceAll("\015", "");
-        SetOutputPath(e1);
-    }
-
-    fMaxEvents = e.GetValue("MJCalibrateSignal.MaxEvents", fMaxEvents);
-}
-
-Bool_t MJCalibrateSignal::ReadCalibration(const MSequence &seq, const char *path,
-                                          MCalibrationCam &calcam,
+Bool_t MJCalibrateSignal::ReadCalibration(MCalibrationCam &calcam,
                                           MCalibrationCam &qecam,
                                           MCalibrationCam &tmcam,
                                           MBadPixelsCam &badpix, MTask* &ext1, MTask* &ext2) const
 {
-    TString inpath(path);
-    if (inpath.EndsWith("/"))
-        inpath = inpath(0, inpath.Length()-1);
-
-    const TString fname = Form("%s/calib%06d.root", inpath.Data(), seq.GetSequence());
+    const TString fname = Form("%s/calib%06d.root", fPathIn.Data(), fSequence.GetSequence());
 
     TFile file(fname, "READ");
@@ -211,31 +176,39 @@
 }
 
-Bool_t MJCalibrateSignal::ProcessFile(const MSequence &seq, const char *env, const char *path)
+Bool_t MJCalibrateSignal::ProcessFile(MPedestalCam &pedcam)
 {
+    if (!fSequence.IsValid())
+    {
+        *fLog << err << "ERROR - Sequence invalid!" << endl;
+        return kFALSE;
+    }
+
+    //if (!CheckEnv())
+    //    return kFALSE;
+
+    CheckEnv();
+
+    // --------------------------------------------------------------------------------
+
     *fLog << inf;
     fLog->Separator(GetDescriptor());
     *fLog << "Calculate calibrated data from runs ";
-    *fLog << seq.GetName() << endl;
+    *fLog << fSequence.GetName() << endl;
     *fLog << endl;
 
-    CheckEnv(env);
-
-    // -------------------------------------------------------------------------------
-
-    MJPedestal job1;
-    job1.SetSequence(&seq);
-    job1.SetDisplay(fDisplay);;
-    job1.SetEnv(env);
-
-    if (!job1.ProcessFile())
-        return kFALSE;
-
     // --------------------------------------------------------------------------------
 
     MDirIter iter;
-    if (seq.SetupDatRuns(iter, fInputPath)==0)
-    {
-            *fLog << err << "ERROR - No input files of sequence found!" << endl;
-            return kFALSE;
+    const Int_t n0 = fSequence.SetupDatRuns(iter, fPathData);
+    const Int_t n1 = fSequence.GetNumDatRuns();
+    if (n0==0)
+    {
+        *fLog << err << "ERROR - No input files of sequence found!" << endl;
+        return kFALSE;
+    }
+    if (n0!=n1)
+    {
+        *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl;
+        return kFALSE;
     }
 
@@ -249,5 +222,5 @@
     MTask *extractor2=0;
 
-    if (!ReadCalibration(seq, path, calcam, qecam, tmcam, badpix, extractor1, extractor2))
+    if (!ReadCalibration(calcam, qecam, tmcam, badpix, extractor1, extractor2))
         return kFALSE;
 
@@ -270,5 +243,5 @@
     plist.AddToList(&tmcam);
     plist.AddToList(&badcam);
-    plist.AddToList(&job1.GetPedestalCam());
+    plist.AddToList(&pedcam);
 
     // Setup Tasklist
@@ -314,5 +287,5 @@
     MFillH fill5(&evt5, "MArrivalTime",        "FillTimes");
 
-    MWriteRootFile write(2, Form("%s{s/_D_/_Y_}", fOutputPath.Data()), fOverwrite);
+    MWriteRootFile write(2, Form("%s{s/_D_/_Y_}", fPathOut.Data()), fOverwrite);
     write.AddContainer("MCerPhotEvt",    "Events");
     write.AddContainer("MPedPhotCam",    "Events");
@@ -347,5 +320,6 @@
     evtloop.SetDisplay(fDisplay);
     evtloop.SetLogStream(fLog);
-    evtloop.ReadEnv(env);
+    if (GetEnv())
+        evtloop.ReadEnv(*GetEnv());
 
     // Execute first analysis
@@ -358,5 +332,5 @@
     tlist.PrintStatistics();
 
-    if (!WriteResult(seq))
+    if (!WriteResult())
         return kFALSE;
 
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.h	(revision 4728)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.h	(revision 4729)
@@ -2,6 +2,6 @@
 #define MARS_MJCalibrateSignal
 
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
+#ifndef MARS_MJob
+#include "MJob.h"
 #endif
 
@@ -11,4 +11,5 @@
 class MParList;
 class MSequence;
+class MPedestalCam;
 class MBadPixelsCam;
 class MCalibrationCam;
@@ -17,16 +18,9 @@
 class MCalibrationChargeCam;
 
-class MJCalibrateSignal : public MParContainer
+class MJCalibrateSignal : public MJob
 {
 private:
-    TString fOutputPath;        // Directory to write signal*.root file to
-    TString fInputPath;         // Directory to read  calib*.root file from
-
-    Bool_t fOverwrite;          // Allow overwriting files
-    Int_t  fMaxEvents;          // Maximum number of events
-
-    void   CheckEnv(const char *env);
-    Bool_t WriteResult(const MSequence &seq);
-    Bool_t ReadCalibration(const MSequence &seq, const char *path, MCalibrationCam &calcam,
+    Bool_t WriteResult();
+    Bool_t ReadCalibration(MCalibrationCam &calcam,
                            MCalibrationCam &qecam, MCalibrationCam &tmcam,
                            MBadPixelsCam &badpix, MTask* &ext1, MTask* &ext2) const;
@@ -34,15 +28,6 @@
 public:
     MJCalibrateSignal(const char *name=NULL, const char *title=NULL);
-    ~MJCalibrateSignal();
 
-    Bool_t ProcessFile(const MSequence &seq, const char *env, const char *path=0);
-
-    void SetOutputPath(const char *path=".");
-    void SetInputPath(const char *path=".");
-    void SetMaxEvents(Int_t max) { fMaxEvents = max; }
-
-    void SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }
-
-    MStatusDisplay *GetDisplay() { return fDisplay; }
+    Bool_t ProcessFile(MPedestalCam &cam);
 
     ClassDef(MJCalibrateSignal, 0) // Tool to create a pedestal file (MPedestalCam)
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4728)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4729)
@@ -87,5 +87,4 @@
 #include "MJCalibration.h"
 
-#include <TEnv.h>
 #include <TFile.h>
 #include <TStyle.h>
@@ -174,4 +173,6 @@
 const Float_t  MJCalibration::fgRefQEInner                = 0.18;            
 const Float_t  MJCalibration::fgRefQEOuter                = 0.12;
+
+
 // --------------------------------------------------------------------------
 //
@@ -184,21 +185,13 @@
 //
 MJCalibration::MJCalibration(const char *name, const char *title) 
-    : fEnv(0), fRuns(0), fSequence(0), fExtractor(NULL), fTimeExtractor(NULL),
+    : fRuns(0), fExtractor(NULL), fTimeExtractor(NULL),
       fColor(MCalibrationCam::kNONE), fDisplayType(kNormalDisplay),
-      fRelTimes(kFALSE), fDataCheck(kFALSE), fDebug(kFALSE), fOverwrite(kFALSE)
-{
-
-  fName  = name  ? name  : "MJCalibration";
-  fTitle = title ? title : "Tool to create the calibration constants for one calibration run";
-
-  SetUseBlindPixel();
-  SetUsePINDiode();
-
-}
-
-MJCalibration::~MJCalibration()
-{
-    if (fEnv)
-        delete fEnv;
+      fRelTimes(kFALSE), fDataCheck(kFALSE), fDebug(kFALSE)
+{
+    fName  = name  ? name  : "MJCalibration";
+    fTitle = title ? title : "Tool to create the calibration constants for one calibration run";
+
+    SetUseBlindPixel();
+    SetUsePINDiode();
 }
 
@@ -255,5 +248,5 @@
     TString title = fDisplay->GetTitle();
     title += "--  Calibration ";
-    title += fSequence ? Form("calib%06d", fSequence->GetSequence()) : fRuns->GetRunsAsString();
+    title += fSequence.IsValid() ? Form("calib%06d", fSequence.GetSequence()) : fRuns->GetRunsAsString();
     title += "  --";
     fDisplay->SetTitle(title);
@@ -1126,5 +1119,5 @@
 Bool_t MJCalibration::FindColor() 
 {
-    if (fSequence)
+    if (fSequence.IsValid())
     {
         fColor = MCalibrationCam::kCT1;
@@ -1222,10 +1215,10 @@
 const char* MJCalibration::GetOutputFile() const
 {
-    if (fSequence)
-        return Form("%s/calib%06d.root", (const char*)fOutputPath, fSequence->GetSequence());
+    if (fSequence.IsValid())
+        return Form("%s/calib%06d.root", (const char*)fPathOut, fSequence.GetSequence());
     if (!fRuns)
         return "";
 
-    return Form("%s/%s-F1.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
+    return Form("%s/%s-F1.root", (const char*)fPathOut, (const char*)fRuns->GetRunsAsFileName());
 }
 
@@ -1240,16 +1233,7 @@
 }
 
-void MJCalibration::SetEnv(const char *env)
-{
-    if (fEnv)
-        delete fEnv;
-    fEnv = new TEnv(env);
-}
-
 // --------------------------------------------------------------------------
 //
 // MJCalibration allows to setup several option by a resource file:
-//   MJCalibration.OutputPath: path
-//   MJCalibration.InputPath: path
 //   MJCalibration.Display: full, datacheck, normal
 //   MJCalibration.RelTimeCalibration: yes,no
@@ -1261,22 +1245,15 @@
 // For more details see the class description and the corresponding Getters
 // 
-void MJCalibration::CheckEnv()
-{
-    if (!fEnv)
-        return;
-
-    TString e1 = fEnv->GetValue(Form("%s.OutputPath", fName.Data()), "");
-    if (!e1.IsNull())
-    {
-        e1.ReplaceAll("\015", "");
-        SetOutputPath(e1);
-    }
-
-    TString col = fEnv->GetValue(Form("%s.Color", fName.Data()), "");
+Bool_t MJCalibration::CheckEnv()
+{
+    if (!MJob::CheckEnv())
+        return kFALSE;
+
+    TString col = GetEnv("Color", "");
     if (!col.IsNull())
     {
     }
 
-    TString dis = fEnv->GetValue(Form("%s.Display", fName.Data()), "");
+    TString dis = GetEnv("Display", "");
     if (dis.BeginsWith("Full", TString::kIgnoreCase))
         SetFullDisplay();
@@ -1286,12 +1263,11 @@
         SetNormalDisplay();
 
-    SetRelTimeCalibration(fEnv->GetValue(Form("%s.RelTimeCalibration", fName.Data()), fRelTimes));
-    SetDataCheck(fEnv->GetValue(Form("%s.Datacheck", fName.Data()), fDataCheck));
-    SetDebug(fEnv->GetValue(Form("%s.Debug", fName.Data()), fDebug));
-    SetUseBlindPixel(fEnv->GetValue(Form("%s.UseBlindPixel", fName.Data()), IsUseBlindPixel()));
-    SetUsePINDiode(fEnv->GetValue(Form("%s.UsePINDiode", fName.Data()), IsUsePINDiode()));
-
-    SetOverwrite(fEnv->GetValue(Form("%s.AllowOverwrite", fName.Data()), fOverwrite));
-    SetInputPath(fEnv->GetValue(Form("%s.InputPath", fName.Data()), fInputPath));
+    SetRelTimeCalibration(GetEnv("RelTimeCalibration", fRelTimes));
+    SetDataCheck(GetEnv("Datacheck", fDataCheck));
+    SetDebug(GetEnv("Debug", fDebug));
+    SetUseBlindPixel(GetEnv("UseBlindPixel", IsUseBlindPixel()));
+    SetUsePINDiode(GetEnv("UsePINDiode", IsUsePINDiode()));
+
+    return kTRUE;
 }
 
@@ -1312,5 +1288,5 @@
 {
 
-  Int_t run = fSequence ? fSequence->GetLastRun() : fRuns->GetRuns()[fRuns->GetNumRuns()-1];
+  Int_t run = fSequence.IsValid() ? fSequence.GetLastRun() : fRuns->GetRuns()[fRuns->GetNumRuns()-1];
   
   //
@@ -1394,16 +1370,26 @@
 Bool_t MJCalibration::ProcessFile(MPedestalCam &pedcam)
 {
-    if (!fRuns && !fSequence)
-    {
-        *fLog << err << "No Runs choosen... abort." << endl;
-        return kFALSE;
-    }
-
-    if (!fSequence && fRuns->GetNumRuns() != fRuns->GetNumEntries())
-    {
-        *fLog << err << "Number of files found doesn't match number of runs... abort."
-            << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
-        return kFALSE;
-    }
+    if (!fSequence.IsValid())
+    {
+        if (!fRuns)
+        {
+            *fLog << err << "No Runs choosen... abort." << endl;
+            return kFALSE;
+        }
+
+        if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
+        {
+            *fLog << err << "Number of files found doesn't match number of runs... abort."
+                << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
+            return kFALSE;
+        }
+    }
+
+    //if (!CheckEnv())
+    //    return kFALSE;
+
+    CheckEnv();
+
+    // --------------------------------------------------------------------------------
 
     *fLog << inf;
@@ -1414,11 +1400,11 @@
 
     *fLog << "Calculate MCalibrationCam from ";
-    if (fSequence)
-        *fLog << "Sequence #" << fSequence->GetSequence() << endl;
+    if (fSequence.IsValid())
+        *fLog << "Sequence #" << fSequence.GetSequence() << endl;
     else
         *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
     *fLog << endl;
 
-    CheckEnv();
+    // --------------------------------------------------------------------------------
 
     // Setup Tasklist
@@ -1432,16 +1418,23 @@
 
     MDirIter iter;
-    if (fSequence)
-    {
-        if (fSequence->SetupCalRuns(iter, fInputPath)==0)
+    if (fSequence.IsValid())
+    {
+        const Int_t n0 = fSequence.SetupCalRuns(iter, fPathData);
+        const Int_t n1 = fSequence.GetNumCalRuns();
+        if (n0==0)
         {
             *fLog << err << "ERROR - No input files of sequence found!" << endl;
             return kFALSE;
         }
+        if (n0!=n1)
+        {
+            *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl;
+            return kFALSE;
+        }
     }
 
     if (fDataCheck)
     {
-        rawread.AddFiles(fSequence ? iter : *fRuns);
+        rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
         tlist.AddToList(&rawread);
     }
@@ -1449,5 +1442,5 @@
     {
         read.DisableAutoScheme();
-        read.AddFiles(fSequence ? iter : *fRuns);
+        read.AddFiles(fSequence.IsValid() ? iter : *fRuns);
         tlist.AddToList(&read);
     }
@@ -1478,7 +1471,7 @@
     MCalibrationRelTimeCalc  timecalc;
 
-    if (!fSequence)
-    {
-        calcalc.SetOutputPath(fOutputPath);
+    if (!fSequence.IsValid())
+    {
+        calcalc.SetOutputPath(fPathOut);
         calcalc.SetOutputFile(Form("%s-ChargeCalibStat.txt",(const char*)fRuns->GetRunsAsFileName()));
     }
@@ -1564,6 +1557,6 @@
     evtloop.SetDisplay(fDisplay);
     evtloop.SetLogStream(fLog);
-    if (fEnv)
-        evtloop.ReadEnv(*fEnv);
+    if (GetEnv())
+        evtloop.ReadEnv(*GetEnv());
 
     //if (!WriteEventloop(evtloop))
@@ -1688,26 +1681,4 @@
 // --------------------------------------------------------------------------
 //
-// Set the path for output files, written by WriteResult()
-// 
-void MJCalibration::SetOutputPath(const char *path)
-{
-    fOutputPath = path;
-    if (fOutputPath.EndsWith("/"))
-        fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
-}
-
-// --------------------------------------------------------------------------
-//
-// Set the path from which the sequence files are read
-// 
-void MJCalibration::SetInputPath(const char *path)
-{
-    fInputPath = path;
-    if (fInputPath.EndsWith("/"))
-        fInputPath = fInputPath(0, fInputPath.Length()-1);
-}
-
-// --------------------------------------------------------------------------
-//
 // Set the useage of the Blind Pixel device 
 // 
@@ -1728,5 +1699,5 @@
 Bool_t MJCalibration::WriteEventloop(MEvtLoop &evtloop) const
 {
-    if (fOutputPath.IsNull())
+    if (fPathOut.IsNull())
         return kTRUE;
 
@@ -1753,5 +1724,5 @@
 Bool_t MJCalibration::WriteTasks(MTask *t1, MTask *t2) const
 {
-    if (fOutputPath.IsNull())
+    if (fPathOut.IsNull())
         return kTRUE;
 
@@ -1794,5 +1765,5 @@
 Bool_t MJCalibration::WriteResult()
 {
-    if (fOutputPath.IsNull())
+    if (fPathOut.IsNull())
         return kTRUE;
 
Index: /trunk/MagicSoft/Mars/mjobs/MJCalibration.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCalibration.h	(revision 4728)
+++ /trunk/MagicSoft/Mars/mjobs/MJCalibration.h	(revision 4729)
@@ -2,4 +2,7 @@
 #define MARS_MJCalibration
 
+#ifndef MARS_MJob
+#include "MJob.h"
+#endif
 #ifndef MARS_MCalibrationChargeCam
 #include "MCalibrationChargeCam.h"
@@ -21,8 +24,8 @@
 #endif
 
-class TEnv;
+class TH1D;
+
 class MTask;
 class MRunIter;
-class MSequence;
 class MParList;
 class MPedestalCam;
@@ -30,10 +33,9 @@
 class MExtractTime;
 class MEvtLoop;
-
 class MExtractBlindPixel;
 class MHCalibrationChargeBlindCam;
 class MHCamera;
-class TH1D;
-class MJCalibration : public MParContainer
+
+class MJCalibration : public MJob
 {
 private:
@@ -57,10 +59,5 @@
   static const Float_t  fgRefQEOuter;                  //! Reference value for the quantum eff. cascades - outer
 
-  TString fOutputPath;                                 // Path to the output files
-  TString fInputPath;                                  // Path to get the data files from
-  
-  TEnv           *fEnv;                                // Input setup-file
   MRunIter       *fRuns;                               // Calibration files
-  MSequence      *fSequence;                           // Sequence
   
   MExtractor     *fExtractor;                          // Signal extractor
@@ -97,5 +94,4 @@
   Bool_t fDataCheck;                                   // Flag if the data check is run on raw data
   Bool_t fDebug;                                       // Flag if debug option is passed onto cal. classes
-  Bool_t fOverwrite;                                   // Allow to overwite existing files
   
   void   DisplayResult        ( MParList &plist );
@@ -109,5 +105,5 @@
   Bool_t WriteEventloop(MEvtLoop &evtloop) const;
   Bool_t WriteTasks(MTask *t1, MTask *t2) const;
-  void   CheckEnv();
+  Bool_t CheckEnv();
   
   // WORKAROUNDS!!!
@@ -117,10 +113,7 @@
   
 public:
-
   MJCalibration(const char *name=NULL, const char *title=NULL);
-  ~MJCalibration();
   
   const char* GetOutputFile() const;
-  void SetEnv(const char *env);
   
   MCalibrationChargeCam  &GetCalibrationCam() { return fCalibrationCam; }
@@ -137,10 +130,4 @@
   void SetQECam(const MCalibrationQECam &qe)     { qe.Copy(fQECam);        }
   void SetColor(const MCalibrationCam::PulserColor_t color) { fColor = color; }
-  
-  void SetInput(MRunIter *iter) { fRuns=iter; }
-  void SetSequence(MSequence *seq) { fSequence=seq; }
-  void SetOutputPath(const char *path=".");
-  void SetInputPath(const char *path=".");
-  void SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }
   
   // Displays
@@ -161,11 +148,10 @@
   void SetUseBlindPixel(const Bool_t b=kTRUE);
   void SetUsePINDiode(const Bool_t b=kTRUE);
-  
+
+  // Precessing
   Bool_t ReadCalibrationCam();
   Bool_t ProcessFile(MPedestalCam &pedcam);
   Bool_t Process(MPedestalCam &pedcam);
 
-  MStatusDisplay *GetDisplay() { return fDisplay; }
-  
   ClassDef(MJCalibration, 0) // Tool to run a calibration per pulser colour and intensity
 };
Index: /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4728)
+++ /trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4729)
@@ -90,6 +90,6 @@
 //
 MJPedestal::MJPedestal(const char *name, const char *title) 
-    : fEnv(0), fRuns(0), fSequence(0), fExtractor(NULL), fDisplayType(kNormalDisplay),
-      fDataCheck(kFALSE), fUseData(kFALSE), fOverwrite(kFALSE), fMaxEvents(0)
+    : fRuns(0), fExtractor(NULL), fDisplayType(kNormalDisplay),
+      fDataCheck(kFALSE), fUseData(kFALSE)
 {
     fName  = name  ? name  : "MJPedestal";
@@ -97,19 +97,13 @@
 }
 
-MJPedestal::~MJPedestal()
-{
-    if (fEnv)
-        delete fEnv;
-}
-
 const char* MJPedestal::GetOutputFile() const
 {
-    if (fSequence)
-        return Form("%s/calped%06d.root", (const char*)fOutputPath, fSequence->GetSequence());
+    if (fSequence.IsValid())
+        return Form("%s/calped%06d.root", (const char*)fPathOut, fSequence.GetSequence());
 
     if (!fRuns)
         return "";
 
-    return Form("%s/%s-F0.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
+    return Form("%s/%s-F0.root", (const char*)fPathOut, (const char*)fRuns->GetRunsAsFileName());
 }
 
@@ -160,6 +154,6 @@
     TString title = fDisplay->GetTitle();
     title += "--  Pedestal ";
-    if (fSequence)
-        title += fSequence->GetName();
+    if (fSequence.IsValid())
+        title += fSequence.GetName();
     else
         if (fRuns)  // FIXME: What to do if an environmentfile was used?
@@ -468,5 +462,5 @@
 Bool_t MJPedestal::WriteResult()
 {
-    if (fOutputPath.IsNull())
+    if (fPathOut.IsNull())
         return kTRUE;
 
@@ -503,29 +497,4 @@
 }
 
-void MJPedestal::SetOutputPath(const char *path)
-{
-    fOutputPath = path;
-    if (fOutputPath.EndsWith("/"))
-        fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
-}
-
-// --------------------------------------------------------------------------
-//
-// Set the path from which the sequence files are read
-// 
-void MJPedestal::SetInputPath(const char *path)
-{
-    fInputPath = path;
-    if (fInputPath.EndsWith("/"))
-        fInputPath = fInputPath(0, fInputPath.Length()-1);
-}
-
-void MJPedestal::SetEnv(const char *env)
-{
-    if (fEnv)
-        delete fEnv;
-    fEnv = new TEnv(env);
-}
-
 Bool_t MJPedestal::Process()
 {
@@ -536,58 +505,40 @@
 }
 
-// --------------------------------------------------------------------------
-//
-// MJPedestsl allows to setup several option by a resource file:
-//   MJPedestal.OutputPath: path
-//   MJPedestal.MaxEvents: 1000
-//   MJPedestal.AllowOverwrite: yes, no
-//   MJPedestal.UseData: yes, no (use DatRuns from sequence instead of PedRuns)
-//
-// For more details see the class description and the corresponding Getters
-// 
-void MJPedestal::CheckEnv()
-{
-    if (!fEnv)
-        return;
-
-    TString e1 = fEnv->GetValue(Form("%s.OutputPath", fName.Data()), "");
-    if (!e1.IsNull())
-    {
-        e1.ReplaceAll("\015", "");
-        SetOutputPath(e1);
-    }
-
-    SetMaxEvents(fEnv->GetValue(Form("%s.MaxEvents", fName.Data()), fMaxEvents));
-    SetOverwrite(fEnv->GetValue(Form("%s.AllowOverwrite", fName.Data()), fOverwrite));
-
-    fUseData = fEnv->GetValue(Form("%s.UseData", fName.Data()), fUseData);
-}
-
 Bool_t MJPedestal::ProcessFile()
 {
-    if (!fRuns && !fEnv && !fSequence)
-    {
-        *fLog << err << "Neither AddRuns nor SetSequence nor SetEnv was called... abort." << endl;
-        return kFALSE;
-    }
-    if (!fSequence && fRuns && fRuns->GetNumRuns() != fRuns->GetNumEntries())
-    {
-        *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
-        return kFALSE;
-    }
+    if (!fSequence.IsValid())
+    {
+        if (!fRuns)
+        {
+            *fLog << err << "Neither AddRuns nor SetSequence nor SetEnv was called... abort." << endl;
+            return kFALSE;
+        }
+        if (fRuns && fRuns->GetNumRuns() != fRuns->GetNumEntries())
+        {
+            *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
+            return kFALSE;
+        }
+    }
+
+    //if (!CheckEnv())
+    //    return kFALSE;
+
+    CheckEnv();
+
+    // --------------------------------------------------------------------------------
 
     *fLog << inf;
     fLog->Separator(GetDescriptor());
     *fLog << "Calculate MPedestalCam from Runs ";
-    if (fSequence)
-        *fLog << fSequence->GetName() << endl;
+    if (fSequence.IsValid())
+        *fLog << fSequence.GetName() << endl;
     else
         if (fRuns)
             *fLog << fRuns->GetRunsAsString() << endl;
         else
-            *fLog << "in " << fEnv->GetName() << endl;
+            *fLog << "in Resource File." << endl;
     *fLog << endl;
 
-    CheckEnv();
+    // --------------------------------------------------------------------------------
 
     MParList  plist;
@@ -600,18 +551,24 @@
 
     MDirIter iter;
-    if (fSequence)
-    {
-        const Int_t n = fUseData ? fSequence->SetupDatRuns(iter, fInputPath) : fSequence->SetupPedRuns(iter, fInputPath);
-        if (n==0)
+    if (fSequence.IsValid())
+    {
+        const Int_t n0 = fUseData ? fSequence.SetupDatRuns(iter, fPathData) : fSequence.SetupPedRuns(iter, fPathData);
+        const Int_t n1 = fUseData ? fSequence.GetNumDatRuns() : fSequence.GetNumPedRuns();
+        if (n0==0)
         {
             *fLog << err << "ERROR - No input files of sequence found!" << endl;
             return kFALSE;
         }
+        if (n0!=n1)
+        {
+            *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl;
+            return kFALSE;
+        }
     }
 
     if (fDataCheck)
     {
-        if (fRuns || fSequence)
-            rawread.AddFiles(fSequence ? iter : *fRuns);
+        if (fRuns || fSequence.IsValid())
+            rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
         tlist.AddToList(&rawread);
     }
@@ -619,10 +576,8 @@
     {
         read.DisableAutoScheme();
-        if (fRuns || fSequence)
-            read.AddFiles(fSequence ? iter : *fRuns);
+        if (fRuns || fSequence.IsValid())
+            read.AddFiles(fSequence.IsValid() ? iter : *fRuns);
 	tlist.AddToList(&read);
     }
-    // Enable logging to file
-    //*fLog.SetOutputFile(lname, kTRUE);
 
     // Setup Tasklist
@@ -662,6 +617,6 @@
     evtloop.SetDisplay(fDisplay);
     evtloop.SetLogStream(fLog);
-    if (fEnv)
-        evtloop.ReadEnv(*fEnv);
+    if (GetEnv())
+        evtloop.ReadEnv(*GetEnv());
 
     //    if (!WriteEventloop(evtloop))
Index: /trunk/MagicSoft/Mars/mjobs/MJPedestal.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 4728)
+++ /trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 4729)
@@ -2,4 +2,7 @@
 #define MARS_MJPedestal
 
+#ifndef MARS_MJob
+#include "MJob.h"
+#endif
 #ifndef MARS_MPedestalCam
 #include "MPedestalCam.h"
@@ -9,8 +12,6 @@
 #endif
 
-class TEnv;
 class TCanvas;
 class MParList;
-class MSequence;
 class MRunIter;
 class MHCamera;
@@ -19,5 +20,5 @@
 class MEvtLoop;
 
-class MJPedestal : public MParContainer
+class MJPedestal : public MJob
 {
 private:
@@ -39,11 +40,5 @@
     static const Float_t  fgRefPedRmsGalacticOuter;
     
-    TString fOutputPath;        // Directory where the F0-files get stored
-    TString fInputPath;         // Directory from which to read the data files
-
-    TEnv       *fEnv;           // Input setup-file
     MRunIter   *fRuns;          // Used pedestal runs
-    const MSequence  *fSequence;      // Sequence
-
     MExtractor *fExtractor;     // Signal extractor, used to find the nr. of used FADC slices
 
@@ -57,7 +52,4 @@
     Bool_t fDataCheck;          // Flag if the data check is run on raw data
     Bool_t fUseData;            // Use data-runs from sequence instead of pedestal runs
-    Bool_t fOverwrite;          // Allow to overwite existing files
-
-    Int_t fMaxEvents;           // Maximum number of events
 
     Bool_t ReadPedestalCam();
@@ -70,9 +62,6 @@
     void   FixDataCheckHist(TH1D *hist) const;
     
-    void   CheckEnv();
-
 public:
     MJPedestal(const char *name=NULL, const char *title=NULL);
-    ~MJPedestal();
 
     MPedestalCam &GetPedestalCam()            { return fPedestalCam; }
@@ -88,10 +77,4 @@
     void SetExtractor(MExtractor* ext) { fExtractor = ext; }
     void SetInput(MRunIter *iter) { fRuns = iter; }
-    void SetSequence(const MSequence *seq, Bool_t usedata=kFALSE) { fSequence = seq; }
-    void SetOutputPath(const char *path=".");
-    void SetInputPath(const char *path=".");
-    void SetEnv(const char *env);
-    void SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }
-    void SetMaxEvents(Int_t max) { fMaxEvents = max; }
 
     void SetDataCheck(const Bool_t b=kTRUE) { fDataCheck = b; SetDataCheckDisplay(); }
@@ -100,6 +83,4 @@
     void SetNormalDisplay()    { fDisplayType = kNormalDisplay;    }
 
-    MStatusDisplay *GetDisplay() { return fDisplay; }
-
     ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam)
 };
Index: /trunk/MagicSoft/Mars/mjobs/MJob.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJob.cc	(revision 4729)
+++ /trunk/MagicSoft/Mars/mjobs/MJob.cc	(revision 4729)
@@ -0,0 +1,163 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 8/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MJob
+//
+// A base class for jobs
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MJob.h"
+
+#include <TEnv.h>
+#include <TSystem.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MJob);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Sets fRuns to 0, fExtractor to NULL, fDataCheck to kFALSE
+//
+MJob::MJob(const char *name, const char *title) : fEnv(0), fOverwrite(kFALSE), fMaxEvents(0)
+{
+    fName  = name  ? name  : "MJob";
+    fTitle = title ? title : "Base class for jobs";
+}
+
+MJob::~MJob()
+{
+    if (fEnv)
+        delete fEnv;
+}
+
+Bool_t MJob::SetEnv(const char *env, const char *prefix)
+{
+    if (fEnv)
+    {
+        delete fEnv;
+        fEnv = 0;
+    }
+
+    const Bool_t fileexist = !gSystem->AccessPathName(env, kFileExists);
+    if (!fileexist)
+    {
+        *fLog << err << "ERROR - Resource file '" << env << "' not found... no resources applied." << endl;
+        return kFALSE;
+    }
+
+    fEnv = new TEnv(env);
+
+    fPrefixEnv = prefix;
+    if (!prefix)
+        fPrefixEnv = fName.First(' ')>0 ? fName(0, fName.First(' ')) : fName;
+
+    if (fPrefixEnv.EndsWith("."))
+        fPrefixEnv.Remove(fPrefixEnv.Length()-1);
+
+    return kTRUE;
+}
+
+void MJob::FixPath(TString &path) const
+{
+    path.ReplaceAll("\015", "");
+
+    if (path==(TString)"/")
+        return;
+
+    if (path.EndsWith("/"))
+        path.Remove(path.Length()-1);
+}
+
+void MJob::SetPathOut(const char *path)
+{
+    fPathOut = path;
+    FixPath(fPathOut);
+}
+
+void MJob::SetPathIn(const char *path)
+{
+    fPathIn = path;
+    FixPath(fPathIn);
+}
+
+void MJob::SetPathData(const char *path)
+{
+    fPathData = path;
+    FixPath(fPathData);
+}
+
+Int_t MJob::GetEnv(const char *name, Int_t dflt) const
+{
+    return fEnv->GetValue(Form("%s%s", fPrefixEnv.Data(), name), dflt);
+}
+
+Double_t MJob::GetEnv(const char *name, Double_t dflt) const
+{
+    return fEnv->GetValue(Form("%s%s", fPrefixEnv.Data(), name), dflt);
+}
+
+const char *MJob::GetEnv(const char *name, const char *dflt) const
+{
+    return fEnv->GetValue(Form("%s%s", fPrefixEnv.Data(), name), dflt);
+}
+
+Bool_t MJob::HasEnv(const char *name) const
+{
+    return fEnv->Lookup(Form("%s%s", fPrefixEnv.Data(), name));
+}
+
+Bool_t MJob::CheckEnv()
+{
+    if (!fEnv)
+    {
+        *fLog << warn << "WARNING - " << GetDescriptor() << " CheckEnv called without further SetEnv!" << endl;
+        return kFALSE;
+    }
+
+    TString p;
+    p = GetEnv("PathOut", "");
+    if (!p.IsNull())
+        SetPathOut(p);
+
+    p = GetEnv("PathIn", "");
+    if (!p.IsNull())
+        SetPathIn(p);
+
+    p = GetEnv("PathData", "");
+    if (!p.IsNull())
+        SetPathData(p);
+
+    SetMaxEvents(GetEnv("MaxEvents", fMaxEvents));
+    SetOverwrite(GetEnv("Overwrite", fOverwrite));
+
+    return kTRUE;
+}
Index: /trunk/MagicSoft/Mars/mjobs/MJob.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJob.h	(revision 4729)
+++ /trunk/MagicSoft/Mars/mjobs/MJob.h	(revision 4729)
@@ -0,0 +1,56 @@
+#ifndef MARS_MJob
+#define MARS_MJob
+
+#ifndef MARS_MSequence
+#include "MSequence.h"
+#endif
+
+class TEnv;
+
+class MJob : public MParContainer
+{
+private:
+    void FixPath(TString &path) const;
+
+    TEnv     *fEnv;           // Resource file
+    TString   fPrefixEnv;     // Prefix for resources
+
+protected:
+
+    TString   fPathOut;       // Directory to write output file to (eg. calib*.root)
+    TString   fPathIn;        // Directory to read output from (eg. calib*.root)
+    TString   fPathData;      // Directory to read  data files from (2004*.root)
+
+    Bool_t    fOverwrite;     // Allow overwriting output files
+    Int_t     fMaxEvents;     // Maximum number of events
+
+    MSequence fSequence;      // Sequence
+
+    virtual Bool_t CheckEnv();
+
+    TEnv       *GetEnv() const { return fEnv; }
+    Int_t       GetEnv(const char *name, Int_t dflt) const;
+    Double_t    GetEnv(const char *name, Double_t dflt) const;
+    const char *GetEnv(const char *name, const char *dflt) const;
+    Bool_t      HasEnv(const char *name) const;
+
+public:
+    MJob(const char *name=NULL, const char *title=NULL);
+    ~MJob();
+
+    void   SetPathOut(const char *path=".");
+    void   SetPathIn(const char *path=".");
+    void   SetPathData(const char *path=".");
+
+    void   SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }
+    Bool_t SetEnv(const char *env, const char *prefix=0);
+
+    void   SetMaxEvents(Int_t max) { fMaxEvents = max; }
+    void   SetSequence(const MSequence &seq) { fSequence = seq; }
+
+    MStatusDisplay *GetDisplay() { return fDisplay; }
+
+    ClassDef(MJob, 0) // Bas class for Jobs
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/mjobs/MSequence.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 4728)
+++ /trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 4729)
@@ -84,6 +84,4 @@
     }
 
-    Int_t num = 0;
-
     for (int i=0; i<arr.GetSize(); i++)
     {
@@ -95,7 +93,7 @@
 
         // Add Path/File to TIter
-        num += iter.AddDirectory(d, n, 0);
-    }
-    return num;
+        iter.AddDirectory(d, n, 0);
+    }
+    return iter.GetNumEntries();
 }
 
Index: /trunk/MagicSoft/Mars/mjobs/MSequence.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 4728)
+++ /trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 4729)
@@ -39,5 +39,13 @@
 
 public:
+    MSequence() : fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
+        fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1) { }
     MSequence(const char *fname);
+    MSequence(const MSequence &s) : fSequence(s.fSequence), fStart(s.fStart),
+        fLastRun(s.fLastRun), fNumEvents(s.fNumEvents), fPeriod(s.fPeriod),
+        fNight(s.fNight), fProject(s.fProject), fSource(s.fSource),
+        fTriggerTable(s.fTriggerTable), fHvSettings(s.fHvSettings),
+        fRuns(s.fRuns), fCalRuns(s.fCalRuns), fPedRuns(s.fPedRuns),
+        fDatRuns(s.fDatRuns) { }
 
     void Print(Option_t *o="") const;
@@ -50,4 +58,9 @@
     Int_t SetupCalRuns(MDirIter &iter, const char *path=0) const;
 
+    Int_t GetNumAllRuns() const { return fRuns.GetSize(); }
+    Int_t GetNumDatRuns() const { return fDatRuns.GetSize(); }
+    Int_t GetNumPedRuns() const { return fPedRuns.GetSize(); }
+    Int_t GetNumCalRuns() const { return fCalRuns.GetSize(); }
+
     // Getter
     UInt_t GetSequence() const { return fSequence; }
Index: /trunk/MagicSoft/Mars/mjobs/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/Makefile	(revision 4728)
+++ /trunk/MagicSoft/Mars/mjobs/Makefile	(revision 4729)
@@ -25,5 +25,6 @@
 #manalysis: MChisqEval (MParameters)
 
-SRCFILES = MSequence.cc \
+SRCFILES = MJob.cc \
+	   MSequence.cc \
 	   MJPedestal.cc \
            MJCalibration.cc \
