Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 4729)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 4732)
@@ -148,28 +148,34 @@
 
     TObject *o = file.Get("ExtractSignal");
-    if (!o)
-    {
-        *fLog << err << dbginf << "ERROR - Unable to read ExtractSignal from file " << fname << endl;
-        return kFALSE;
-    }
-    if (!o->InheritsFrom(MExtractor::Class()))
+//    if (!o)
+//    {
+//        *fLog << err << dbginf << "ERROR - Unable to read ExtractSignal from file " << fname << endl;
+//        return kFALSE;
+//    }
+    if (o && !o->InheritsFrom(MExtractor::Class()))
     {
         *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
         return kFALSE;
     }
-    ext1 = (MTask*)o->Clone();
+    ext1 = o ? (MTask*)o->Clone() : NULL;
 
     o = file.Get("ExtractTime");
-    if (!o)
-    {
-        *fLog << err << dbginf << "ERROR - Unable to read ExtractTime from file " << fname << endl;
-        return kFALSE;
-    }
-    if (!o->InheritsFrom(MExtractor::Class()))
+//    if (!o)
+//    {
+//        *fLog << err << dbginf << "ERROR - Unable to read ExtractTime from file " << fname << endl;
+//        return kFALSE;
+//    }
+    if (o && !o->InheritsFrom(MExtractor::Class()))
     {
         *fLog << err << dbginf << "ERROR - ExtractTime read from " << fname << " doesn't inherit from MExtractor!" << endl;
         return kFALSE;
     }
-    ext2 = (MTask*)o->Clone();
+    ext2 = o ? (MTask*)o->Clone() : NULL;
+
+    if (!ext1 && !ext2)
+    {
+        *fLog << err << dbginf << "ERROR - Neither ExtractSignal nor ExrtractTime found in " << fname << "!" << endl;
+        return kFALSE;
+    }
 
     return kTRUE;
@@ -226,10 +232,21 @@
 
     *fLog << all;
-    *fLog << "Extractors read from file" << endl;
-    *fLog << "=========================" << endl;
-    extractor1->Print();
-    *fLog << endl;
-    extractor2->Print();
-    *fLog << endl;
+    if (extractor1)
+    {
+        *fLog << underline << "Signal Extractor found in calibration file" << endl;
+        extractor1->Print();
+        *fLog << endl;
+    }
+    else
+        *fLog << inf << "No Signal Extractor: ExtractSignal in file." << endl;
+
+    if (extractor2)
+    {
+        *fLog << underline << "Time Extractor found in calibration file" << endl;
+        extractor2->Print();
+        *fLog << endl;
+    }
+    else
+        *fLog << inf << "No Time Extractor: ExtractTime in file." << endl;
 
     // This is necessary for the case in which it is not in the files
@@ -302,6 +319,8 @@
     tlist.AddToList(&pedlo);
     tlist.AddToList(&fill0);
-    tlist.AddToList(&taskenv1);
-    tlist.AddToList(&taskenv2);
+    if (extractor1)
+        tlist.AddToList(&taskenv1);
+    if (extractor2)
+        tlist.AddToList(&taskenv2);
     tlist.AddToList(&fill1);
     tlist.AddToList(&calib);
@@ -320,6 +339,6 @@
     evtloop.SetDisplay(fDisplay);
     evtloop.SetLogStream(fLog);
-    if (GetEnv())
-        evtloop.ReadEnv(*GetEnv());
+    if (!SetupEnv(evtloop))
+        return kFALSE;
 
     // Execute first analysis
Index: trunk/MagicSoft/Mars/mjobs/MJCalibration.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4729)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibration.cc	(revision 4732)
@@ -248,5 +248,5 @@
     TString title = fDisplay->GetTitle();
     title += "--  Calibration ";
-    title += fSequence.IsValid() ? Form("calib%06d", fSequence.GetSequence()) : fRuns->GetRunsAsString();
+    title += fSequence.IsValid() ? Form("calib%06d", fSequence.GetSequence()) : (const char*)fRuns->GetRunsAsString();
     title += "  --";
     fDisplay->SetTitle(title);
@@ -1247,7 +1247,4 @@
 Bool_t MJCalibration::CheckEnv()
 {
-    if (!MJob::CheckEnv())
-        return kFALSE;
-
     TString col = GetEnv("Color", "");
     if (!col.IsNull())
@@ -1269,5 +1266,5 @@
     SetUsePINDiode(GetEnv("UsePINDiode", IsUsePINDiode()));
 
-    return kTRUE;
+    return MJob::CheckEnv();
 }
 
@@ -1557,9 +1554,12 @@
     evtloop.SetDisplay(fDisplay);
     evtloop.SetLogStream(fLog);
-    if (GetEnv())
-        evtloop.ReadEnv(*GetEnv());
-
-    //if (!WriteEventloop(evtloop))
-    //    return kFALSE;
+    if (!SetupEnv(evtloop))
+        return kFALSE;
+
+    if (!taskenv.GetTask() && !taskenv2.GetTask())
+    {
+        *fLog << err << "ERROR - Neither ExtractSignal nor ExtractTime initializedor both '<dummy>'." << endl;
+        return kFALSE;
+    }
 
     if (!WriteTasks(taskenv.GetTask(), taskenv2.GetTask()))
@@ -1738,10 +1738,10 @@
     }
 
-    if (t1->Write()<=0)
+    if (t1 && t1->Write()<=0)
     {
         *fLog << err << "Unable to write " << t1->GetName() << " to " << oname << endl;
         return kFALSE;
     }
-    if (t2->Write()<=0)
+    if (t2 && t2->Write()<=0)
     {
         *fLog << err << "Unable to write " << t2->GetName() << " to " << oname << endl;
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4729)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4732)
@@ -460,4 +460,16 @@
 }
 */
+
+Bool_t MJPedestal::CheckEnv()
+{
+    if (HasEnv("DataCheckDisplay"))
+        fDisplayType = GetEnv("DataCheckDisplay", kFALSE) ? kDataCheckDisplay : kNormalDisplay;
+
+    SetDataCheck(GetEnv("DataCheck", fDataCheck));
+    SetOverwrite(GetEnv("Overwrite", fOverwrite));
+
+    return MJob::CheckEnv();
+}
+
 Bool_t MJPedestal::WriteResult()
 {
@@ -617,6 +629,6 @@
     evtloop.SetDisplay(fDisplay);
     evtloop.SetLogStream(fLog);
-    if (GetEnv())
-        evtloop.ReadEnv(*GetEnv());
+    if (!SetupEnv(evtloop))
+        return kFALSE;
 
     //    if (!WriteEventloop(evtloop))
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 4729)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 4732)
@@ -61,4 +61,6 @@
     void   DisplayOutliers(TH1D *hist) const;
     void   FixDataCheckHist(TH1D *hist) const;
+
+    Bool_t CheckEnv();
     
 public:
@@ -78,5 +80,5 @@
     void SetInput(MRunIter *iter) { fRuns = iter; }
 
-    void SetDataCheck(const Bool_t b=kTRUE) { fDataCheck = b; SetDataCheckDisplay(); }
+    void SetDataCheck(const Bool_t b=kTRUE) { fDataCheck = b; b ? SetDataCheckDisplay() : SetNormalDisplay(); }
 
     void SetDataCheckDisplay() { fDisplayType = kDataCheckDisplay; }
Index: trunk/MagicSoft/Mars/mjobs/MJob.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJob.cc	(revision 4729)
+++ trunk/MagicSoft/Mars/mjobs/MJob.cc	(revision 4732)
@@ -37,4 +37,6 @@
 #include "MLog.h"
 #include "MLogManip.h"
+
+#include "MEvtLoop.h"
 
 ClassImp(MJob);
@@ -77,10 +79,10 @@
     fEnv = new TEnv(env);
 
-    fPrefixEnv = prefix;
+    fEnvPrefix = prefix;
     if (!prefix)
-        fPrefixEnv = fName.First(' ')>0 ? fName(0, fName.First(' ')) : fName;
+        fEnvPrefix = fName.First(' ')>0 ? fName(0, fName.First(' ')) : fName;
 
-    if (fPrefixEnv.EndsWith("."))
-        fPrefixEnv.Remove(fPrefixEnv.Length()-1);
+    if (fEnvPrefix.EndsWith("."))
+        fEnvPrefix.Remove(fEnvPrefix.Length()-1);
 
     return kTRUE;
@@ -118,30 +120,24 @@
 Int_t MJob::GetEnv(const char *name, Int_t dflt) const
 {
-    return fEnv->GetValue(Form("%s%s", fPrefixEnv.Data(), name), dflt);
+    return GetEnvValue(*fEnv, fEnvPrefix, name, dflt); //    return fEnv->GetValue(Form("%s%s", fEnvPrefix.Data(), name), dflt);
 }
 
 Double_t MJob::GetEnv(const char *name, Double_t dflt) const
 {
-    return fEnv->GetValue(Form("%s%s", fPrefixEnv.Data(), name), dflt);
+    return GetEnvValue(*fEnv, fEnvPrefix, name, dflt); //    return fEnv->GetValue(Form("%s%s", fEnvPrefix.Data(), name), dflt);
 }
 
 const char *MJob::GetEnv(const char *name, const char *dflt) const
 {
-    return fEnv->GetValue(Form("%s%s", fPrefixEnv.Data(), name), dflt);
+    return GetEnvValue(*fEnv, fEnvPrefix, name, dflt); //fEnv->GetValue(Form("%s%s", fEnvPrefix.Data(), name), dflt);
 }
 
 Bool_t MJob::HasEnv(const char *name) const
 {
-    return fEnv->Lookup(Form("%s%s", fPrefixEnv.Data(), name));
+    return IsEnvDefined(*fEnv, fEnvPrefix, name, fEnvDebug);//fEnv->Lookup(Form("%s%s", fEnvPrefix.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", "");
@@ -162,2 +158,10 @@
     return kTRUE;
 }
+
+Bool_t MJob::SetupEnv(MEvtLoop &loop) const
+{
+    if (!fEnv)
+        return kTRUE;
+
+    return loop.ReadEnv(*fEnv, fEnvPrefix, fEnvDebug) ? kTRUE : kFALSE;
+}
Index: trunk/MagicSoft/Mars/mjobs/MJob.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJob.h	(revision 4729)
+++ trunk/MagicSoft/Mars/mjobs/MJob.h	(revision 4732)
@@ -7,4 +7,5 @@
 
 class TEnv;
+class MEvtLoop;
 
 class MJob : public MParContainer
@@ -14,5 +15,6 @@
 
     TEnv     *fEnv;           // Resource file
-    TString   fPrefixEnv;     // Prefix for resources
+    TString   fEnvPrefix;     // Prefix for resources
+    Bool_t    fEnvDebug;      // Debug setup of resources
 
 protected:
@@ -27,11 +29,11 @@
     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;
+
+    Bool_t SetupEnv(MEvtLoop &loop) const;
+    virtual Bool_t CheckEnv();
 
 public:
@@ -45,4 +47,5 @@
     void   SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }
     Bool_t SetEnv(const char *env, const char *prefix=0);
+    void   SetEnvDebug(Bool_t b=kTRUE) { fEnvDebug=b; }
 
     void   SetMaxEvents(Int_t max) { fMaxEvents = max; }
Index: trunk/MagicSoft/Mars/mjobs/MSequence.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 4729)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 4732)
@@ -73,5 +73,5 @@
 }
 
-Int_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path) const
+Int_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path, Bool_t raw) const
 {
     TString d(path);
@@ -80,5 +80,6 @@
     if (d.IsNull())
     {
-        d  = Form("/data/MAGIC/Period%03d/rootdata/", fPeriod);
+        d  = Form("/data/MAGIC/Period%03d/", fPeriod);
+        d += raw ? "rawdata/" : "rootdata/";
         d += fNight.GetStringFmt("%Y_%m_%d");
     }
@@ -90,5 +91,6 @@
         // Create file name
         n =  fNight.GetStringFmt("%Y%m%d_");
-        n += Form("%05d_*_E.root", arr[i]);
+        n += Form("%05d_*_E", arr[i]);
+        n += raw ? ".raw" : ".root";
 
         // Add Path/File to TIter
@@ -182,9 +184,10 @@
 // If path==0 the standard path of the data-center is assumed.
 // If you have the runs locally use path="."
-// Return the number of files added.
-//
-Int_t MSequence::SetupPedRuns(MDirIter &iter, const char *path) const
-{
-    return SetupRuns(iter, fPedRuns, path);
+// Using raw=kTRUE you get correspodning raw-files setup.
+// Return the number of files added.
+//
+Int_t MSequence::SetupPedRuns(MDirIter &iter, const char *path, Bool_t raw) const
+{
+    return SetupRuns(iter, fPedRuns, path, raw);
 }
 
@@ -194,9 +197,10 @@
 // If path==0 the standard path of the data-center is assumed.
 // If you have the runs locally use path="."
-// Return the number of files added.
-//
-Int_t MSequence::SetupDatRuns(MDirIter &iter, const char *path) const
-{
-    return SetupRuns(iter, fDatRuns, path);
+// Using raw=kTRUE you get correspodning raw-files setup.
+// Return the number of files added.
+//
+Int_t MSequence::SetupDatRuns(MDirIter &iter, const char *path, Bool_t raw) const
+{
+    return SetupRuns(iter, fDatRuns, path, raw);
 }
 
@@ -206,9 +210,10 @@
 // If path==0 the standard path of the data-center is assumed.
 // If you have the runs locally use path="."
-// Return the number of files added.
-//
-Int_t MSequence::SetupAllRuns(MDirIter &iter, const char *path) const
-{
-    return SetupRuns(iter, fRuns, path);
+// Using raw=kTRUE you get correspodning raw-files setup.
+// Return the number of files added.
+//
+Int_t MSequence::SetupAllRuns(MDirIter &iter, const char *path, Bool_t raw) const
+{
+    return SetupRuns(iter, fRuns, path, raw);
 }
 
@@ -218,8 +223,9 @@
 // If path==0 the standard path of the data-center is assumed.
 // If you have the runs locally use path="."
-// Return the number of files added.
-//
-Int_t MSequence::SetupCalRuns(MDirIter &iter, const char *path) const
-{
-    return SetupRuns(iter, fCalRuns, path);
-}
+// Using raw=kTRUE you get correspodning raw-files setup.
+// Return the number of files added.
+//
+Int_t MSequence::SetupCalRuns(MDirIter &iter, const char *path, Bool_t raw) const
+{
+    return SetupRuns(iter, fCalRuns, path, raw);
+}
Index: trunk/MagicSoft/Mars/mjobs/MSequence.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 4729)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 4732)
@@ -36,5 +36,5 @@
 
     void Split(TString &runs, TArrayI &data) const;
-    Int_t SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path) const;
+    Int_t SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path, Bool_t raw=kFALSE) const;
 
 public:
@@ -53,8 +53,8 @@
     Bool_t IsValid() const { return fSequence!=(UInt_t)-1; }
 
-    Int_t SetupPedRuns(MDirIter &iter, const char *path=0) const;
-    Int_t SetupDatRuns(MDirIter &iter, const char *path=0) const;
-    Int_t SetupAllRuns(MDirIter &iter, const char *path=0) const;
-    Int_t SetupCalRuns(MDirIter &iter, const char *path=0) const;
+    Int_t SetupPedRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const;
+    Int_t SetupDatRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const;
+    Int_t SetupAllRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const;
+    Int_t SetupCalRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const;
 
     Int_t GetNumAllRuns() const { return fRuns.GetSize(); }
