Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 6552)
+++ trunk/MagicSoft/Mars/Changelog	(revision 6553)
@@ -21,4 +21,5 @@
 
                                                  -*-*- END OF LINE -*-*-
+
  2005/02/16 Javier Rico
 
@@ -38,11 +39,33 @@
        branch containing the energy estimator). This may be used 
        as layout for spectrum computation program.
-	
- 2005/02/16 Abelardo Moralejo
-
-   * mtemp/mpadova/macros/resize.C
-     - Changed weights
+
+
+
+ 2005/02/16 Markus Gaug
+
+   * mdata/MDataChain.cc
+     - replaced ROOT version check for the compiler from 4.02.00 to 
+       4.01.00
+
+   * mranforest/MRFEnergyEst.cc
+     - include "TVector.h", otherwise this class does not compile
+       in newer root versions
+
+   * msignal/MExtractTimeAndCharge.cc
+     - initialize fLoGainStartShift correctly if read from conf. file 
+       and modified fOffsetLoGain exists.
+
+   * msignal/*weights*.dat
+     - new weights with the uniform pedestal RMS. (Please use these!)
+
+   * msignal/pulpo_weights*.dat
+     - new weights with the pulpo-pulse form and without NSB!!
+
+
 
  2005/02/16 Thomas Hengstebeck
+
+   * mranforest/MRFEnergyEst.[h,cc]
+     - added RF class for energy estimation
 
    * mranforest/MRFEnergyEst.cc
@@ -50,34 +73,4 @@
        are returned                                                                        	
 
- 2005/02/16 Abelardo Moralejo
-
-   * mhistmc/MHMcCollectionArea.cc
-     - Changed default fName to "MHMcCollectionArea"
-
- 2005/02/16 Markus Gaug
-
-   * mdata/MDataChain.cc
-     - replaced ROOT version check for the compiler from 4.02.00 to 
-       4.01.00
-
-   * mranforest/MRFEnergyEst.cc
-     - include "TVector.h", otherwise this class does not compile
-       in newer root versions
-
-   * msignal/MExtractTimeAndCharge.cc
-     - initialize fLoGainStartShift correctly if read from conf. file 
-       and modified fOffsetLoGain exists.
-
-   * msignal/*weights*.dat
-     - new weights with the uniform pedestal RMS. (Please use these!)
-
-   * msignal/pulpo_weights*.dat
-     - new weights with the pulpo-pulse form and without NSB!!
-
-
- 2005/02/16 Thomas Hengstebeck
-
-   * mranforest/MRFEnergyEst.[h,cc]
-     - added RF class for energy estimation
 
 
@@ -89,4 +82,10 @@
        MWriteRootFile::AddCopySource
 
+   * mhistmc/MHMcCollectionArea.cc
+     - Changed default fName to "MHMcCollectionArea"
+
+   * mtemp/mpadova/macros/resize.C
+     - Changed weights
+
 
 
@@ -121,4 +120,20 @@
    * mranforest/MRFEnergyEst.[h,cc]: 
      - cleaned up includes
+
+   * callisto.cc, ganymed.cc, star.cc:
+     - implemented enhanced handling of resource debugging
+
+   * mbase/Makefile, mbase/BaseLinkDef.h:
+     - added MEnv
+
+   * mbase/MEnv.[h,cc]:
+     - added
+
+   * mjobs/MJob.[h,cc]:
+     - added new function to allow distribution of extranl MEnv
+     - replaced Bool_t by Int_t for fEnvDebug
+
+   * mjobs/MJPedestal.cc:
+     - adapted to changes of EnvDebug
 
 
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 6552)
+++ trunk/MagicSoft/Mars/NEWS	(revision 6553)
@@ -81,4 +81,6 @@
       camera files.
 
+    - enhanced possibility to debug reading of resource file
+
 
 
Index: trunk/MagicSoft/Mars/callisto.cc
===================================================================
--- trunk/MagicSoft/Mars/callisto.cc	(revision 6552)
+++ trunk/MagicSoft/Mars/callisto.cc	(revision 6553)
@@ -9,4 +9,5 @@
 #include "MLogManip.h"
 
+#include "MEnv.h"
 #include "MArgs.h"
 #include "MArray.h"
@@ -59,5 +60,8 @@
     gLog << " Options:" << endl;
     gLog.Usage();
-    gLog << "   --debug-env               Debug setting resources from file" << endl;
+    gLog << "   --debug-env=0             Disable debugging setting resources <default>" << endl;
+    gLog << "   --debug-env[=1]           Display untouched resources after program execution" << endl;
+    gLog << "   --debug-env=2             Display untouched resources after eventloop setup" << endl;
+    gLog << "   --debug-env=3             Debug setting resources from resource file" << endl;
     gLog << "   --debug-mem               Debug memory usage" << endl << endl;
     gLog << endl;
@@ -150,6 +154,7 @@
     const Bool_t  kPrintFound = arg.HasOnlyAndRemove("--print-found");
     const Bool_t  kUseTest    = arg.HasOnlyAndRemove("--use-test");
-    const Bool_t  kDebugEnv   = arg.HasOnlyAndRemove("--debug-env");
     const Bool_t  kDebugMem   = arg.HasOnlyAndRemove("--debug-mem");
+    Int_t kDebugEnv = arg.HasOnlyAndRemove("--debug-env") ? 1 : 0;
+    kDebugEnv = arg.GetIntAndRemove("--debug-env=", kDebugEnv);
 
     const Bool_t  kQuit       = arg.HasOnlyAndRemove("-q");
@@ -235,4 +240,10 @@
     {
         gLog << err << "Sorry, sequence file '" << kSequence << "' doesn't exist." << endl;
+        return -1;
+    }
+
+    if (gSystem->AccessPathName(kConfig, kFileExists))
+    {
+        gLog << err << "Sorry, config file '" << kConfig << "' doesn't exist." << endl;
         return -1;
     }
@@ -309,4 +320,5 @@
     d->SetTitle(kSequence);
 
+    MEnv env(kConfig);
     if (kModeC/* || kUseTest*/)
     {
@@ -317,5 +329,5 @@
         job1.SetNoStorage();
         job1.SetSequence(seq);
-        job1.SetEnv(kConfig);
+        job1.SetEnv(&env);
         job1.SetEnvDebug(kDebugEnv);
         job1.SetDisplay(d);
@@ -346,5 +358,5 @@
         job2.SetNoStorage();
         job2.SetSequence(seq);
-        job2.SetEnv(kConfig);
+        job2.SetEnv(&env);
         job2.SetEnvDebug(kDebugEnv);
         job2.SetDisplay(d);;
@@ -380,5 +392,5 @@
             MJCalibration job3(Form("MJCalibration #%d", seq.GetSequence()));
             job3.SetSequence(seq);
-            job3.SetEnv(kConfig);
+            job3.SetEnv(&env);
             job3.SetEnvDebug(kDebugEnv);
             job3.SetDisplay(d);
@@ -411,5 +423,5 @@
             job4.SetBadPixels(job2.GetBadPixels());
             job4.SetSequence(seq);
-            job4.SetEnv(kConfig);
+            job4.SetEnv(&env);
             job4.SetEnvDebug(kDebugEnv);
             job4.SetDisplay(d);;
@@ -431,4 +443,6 @@
             }
         }
+        if (kDebugEnv>0)
+            env.PrintUntouched();
     }
 
@@ -443,5 +457,5 @@
         job1.SetNoStorage();
         job1.SetSequence(seq);
-        job1.SetEnv(kConfig);
+        job1.SetEnv(&env);
         job1.SetEnvDebug(kDebugEnv);
         job1.SetDisplay(d);
@@ -473,5 +487,5 @@
         job2.SetNoStorage();
         job2.SetSequence(seq);
-        job2.SetEnv(kConfig);
+        job2.SetEnv(&env);
         job2.SetEnvDebug(kDebugEnv);
         job2.SetDisplay(d);
@@ -508,5 +522,5 @@
         job3.SetNoStorage();
         job3.SetSequence(seq);
-        job3.SetEnv(kConfig);
+        job3.SetEnv(&env);
         job3.SetEnvDebug(kDebugEnv);
         job3.SetDisplay(d);
@@ -543,5 +557,5 @@
         job4.SetSequence(seq);
         job4.SetDisplay(d);;
-        job4.SetEnv(kConfig);
+        job4.SetEnv(&env);
         job4.SetEnvDebug(kDebugEnv);
         job4.SetOverwrite(kOverwrite);
@@ -560,4 +574,7 @@
             return 1;
         }
+
+        if (kDebugEnv>0)
+            env.PrintUntouched();
     }
 
Index: trunk/MagicSoft/Mars/ganymed.cc
===================================================================
--- trunk/MagicSoft/Mars/ganymed.cc	(revision 6552)
+++ trunk/MagicSoft/Mars/ganymed.cc	(revision 6553)
@@ -9,4 +9,5 @@
 #include "MLogManip.h"
 
+#include "MEnv.h"
 #include "MArgs.h"
 #include "MArray.h"
@@ -49,5 +50,8 @@
     gLog << " Options:" << endl;
     gLog.Usage();
-    gLog << "   --debug-env               Debug setting resources from file" << endl;
+    gLog << "   --debug-env=0             Disable debugging setting resources <default>" << endl;
+    gLog << "   --debug-env[=1]           Display untouched resources after program execution" << endl;
+    gLog << "   --debug-env=2             Display untouched resources after eventloop setup" << endl;
+    gLog << "   --debug-env=3             Debug setting resources from resource file" << endl;
     gLog << "   --debug-mem               Debug memory usage" << endl << endl;
     gLog << endl;
@@ -93,7 +97,8 @@
     const Bool_t  kPrintSeq     = arg.HasOnlyAndRemove("--print-seq");
     const Bool_t  kPrintFiles   = arg.HasOnlyAndRemove("--print-files");
-    const Bool_t  kDebugEnv     = arg.HasOnlyAndRemove("--debug-env");
     const Bool_t  kDebugMem     = arg.HasOnlyAndRemove("--debug-mem");
     const Bool_t  kWriteOnly    = arg.HasOnlyAndRemove("--write-only");
+    Int_t  kDebugEnv = arg.HasOnlyAndRemove("--debug-env") ? 1 : 0;
+    kDebugEnv = arg.GetIntAndRemove("--debug-env=", kDebugEnv);
 
     const Bool_t  kQuit         = arg.HasOnlyAndRemove("-q");
@@ -137,4 +142,10 @@
     }
 
+    if (gSystem->AccessPathName(kConfig, kFileExists))
+    {
+        gLog << err << "Sorry, config file '" << kConfig << "' doesn't exist." << endl;
+        return -1;
+    }
+
     if (kDebugMem)
         TObject::SetObjectStat(kTRUE);
@@ -184,6 +195,8 @@
     // Calculate pedestal for pedestal-calculation and calibration
     //
+    MEnv env(kConfig);
+
     MJCut job(Form("MJCut #%d", seq.GetNumAnalysis()));
-    job.SetEnv(kConfig);
+    job.SetEnv(&env);
     job.SetEnvDebug(kDebugEnv);
     job.SetDisplay(d);;
@@ -204,4 +217,6 @@
         return -1;
     }
+    if (kDebugEnv>0)
+        env.PrintUntouched();
 
     if (!job.GetDisplay())
Index: trunk/MagicSoft/Mars/mbase/BaseLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 6552)
+++ trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 6553)
@@ -22,4 +22,5 @@
 #pragma link C++ namespace MMath;
 #pragma link C++ class MString+;
+#pragma link C++ class MEnv+;
 #pragma link C++ class MIter+;
 #pragma link C++ class MDirIter+;
Index: trunk/MagicSoft/Mars/mbase/MEnv.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEnv.cc	(revision 6553)
+++ trunk/MagicSoft/Mars/mbase/MEnv.cc	(revision 6553)
@@ -0,0 +1,83 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  2/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2005
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MEnv
+//
+// It is a slightly changed version of TEnv. It logs all resources which are
+// touched, so that you can print all untouched resources by
+// PrintUntouched()
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MEnv.h"
+
+#include <TObjString.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MEnv);
+
+using namespace std;
+
+Int_t MEnv::GetValue(const char *name, Int_t dflt)
+{
+    if (!fChecked.FindObject(name))
+        fChecked.Add(new TObjString(name));
+    return TEnv::GetValue(name, dflt);
+}
+
+Double_t MEnv::GetValue(const char *name, Double_t dflt)
+{
+    if (!fChecked.FindObject(name))
+        fChecked.Add(new TObjString(name));
+    return TEnv::GetValue(name, dflt);
+}
+
+const char *MEnv::GetValue(const char *name, const char *dflt)
+{
+    if (!fChecked.FindObject(name))
+        fChecked.Add(new TObjString(name));
+    return TEnv::GetValue(name, dflt);
+}
+
+void MEnv::PrintUntouched() const
+{
+    int i=0;
+    gLog << inf << flush;
+    gLog.Separator("Untouched Resources");
+    TIter Next(GetTable());
+    TObject *o=0;
+    while ((o=Next()))
+        if (!fChecked.FindObject(o->GetName()))
+        {
+            gLog << warn << " - Resource " << o->GetName() << " not touched" << endl;
+            i++;
+        }
+    if (i==0)
+        gLog << inf << "None." << endl;
+    else
+        gLog << inf << i << " resources have not been touched." << endl;
+}
Index: trunk/MagicSoft/Mars/mbase/MEnv.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEnv.h	(revision 6553)
+++ trunk/MagicSoft/Mars/mbase/MEnv.h	(revision 6553)
@@ -0,0 +1,30 @@
+#ifndef MARS_MEnv
+#define MARS_MEnv
+
+#ifndef ROOT_TEnv
+#include <TEnv.h>
+#endif
+
+#ifndef ROOT_TOrdCollection
+#include <TOrdCollection.h>
+#endif
+
+class MEnv : public TEnv
+{
+private:
+    TOrdCollection fChecked;
+
+public:
+    MEnv(const char *name="") : TEnv(name) { fChecked.SetOwner(); }
+
+    Int_t       GetValue(const char *name, Int_t dflt);
+    Double_t    GetValue(const char *name, Double_t dflt);
+    const char *GetValue(const char *name, const char *dflt);
+
+    void PrintUntouched() const;
+
+    ClassDef(MEnv, 0) // A slightly more advanced version of TEnv
+};
+    
+#endif
+
Index: trunk/MagicSoft/Mars/mbase/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mbase/Makefile	(revision 6552)
+++ trunk/MagicSoft/Mars/mbase/Makefile	(revision 6553)
@@ -22,4 +22,5 @@
            MString.cc \
            MMath.cc \
+           MEnv.cc \
 	   MLog.cc \
            MLogManip.cc \
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 6552)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 6553)
@@ -802,5 +802,5 @@
     tenv.SetDefault(fExtractor);
 
-    if (tenv.ReadEnv(*GetEnv(), GetEnvPrefix()+".ExtractSignal", GetEnvDebug())==kERROR)
+    if (tenv.ReadEnv(*GetEnv(), GetEnvPrefix()+".ExtractSignal", GetEnvDebug()>2)==kERROR)
         return kFALSE;
 
Index: trunk/MagicSoft/Mars/mjobs/MJob.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJob.cc	(revision 6552)
+++ trunk/MagicSoft/Mars/mjobs/MJob.cc	(revision 6553)
@@ -29,8 +29,13 @@
 // A base class for jobs
 //
+// SetDebugEnv(0) // switch off debugging
+// SetDebugEnv(1) // reserved
+// SetDebugEnv(2) // print untouched resources after evtloop resources setup
+// SetDebugEnv(3) // do 2) and debug setting env completely
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MJob.h"
 
-#include <TEnv.h>
+#include "MEnv.h"
 #include <TFile.h>
 #include <TSystem.h>
@@ -54,5 +59,5 @@
 // Sets fDataFlag to 0
 //
-MJob::MJob(const char *name, const char *title) : fEnv(0), fOverwrite(kFALSE), fMaxEvents(0)
+MJob::MJob(const char *name, const char *title) : fEnv(0), fEnvDebug(0), fOverwrite(kFALSE), fMaxEvents(0)
   
 {
@@ -61,17 +66,20 @@
 }
 
+void MJob::ClearEnv()
+{
+    if (fEnv && TestBit(kIsOwner))
+        delete fEnv;
+    ResetBit(kIsOwner);
+    fEnv=0;
+}
+
 MJob::~MJob()
 {
-    if (fEnv)
-        delete fEnv;
+    ClearEnv();
 }
 
 Bool_t MJob::SetEnv(const char *env, const char *prefix)
 {
-    if (fEnv)
-    {
-        delete fEnv;
-        fEnv = 0;
-    }
+    ClearEnv();
 
     const Bool_t fileexist = !gSystem->AccessPathName(env, kFileExists);
@@ -82,5 +90,6 @@
     }
 
-    fEnv = new TEnv(env);
+    fEnv = new MEnv(env);
+    SetBit(kIsOwner);
 
     fEnvPrefix = prefix;
@@ -94,4 +103,18 @@
 }
 
+void MJob::SetEnv(MEnv *env, const char *prefix)
+{
+    ClearEnv();
+
+    fEnv = env;
+
+    fEnvPrefix = prefix;
+    if (!prefix)
+        fEnvPrefix = fName.First(' ')>0 ? fName(0, fName.First(' ')) : fName;
+
+    if (fEnvPrefix.EndsWith("."))
+        fEnvPrefix.Remove(fEnvPrefix.Length()-1);
+}
+
 void MJob::FixPath(TString &path) const
 {
@@ -123,4 +146,9 @@
 }
 
+const TEnv *MJob::GetEnv() const
+{
+    return static_cast<const TEnv *const>(fEnv);
+}
+
 Int_t MJob::GetEnv(const char *name, Int_t dflt) const
 {
@@ -140,5 +168,5 @@
 Bool_t MJob::HasEnv(const char *name) const
 {
-    return IsEnvDefined(*fEnv, fEnvPrefix, name, fEnvDebug);//fEnv->Lookup(Form("%s%s", fEnvPrefix.Data(), name));
+    return IsEnvDefined(*fEnv, fEnvPrefix, name, fEnvDebug>2);//fEnv->Lookup(Form("%s%s", fEnvPrefix.Data(), name));
 }
 
@@ -163,4 +191,5 @@
     SetMaxEvents(GetEnv("MaxEvents", fMaxEvents));
     SetOverwrite(GetEnv("Overwrite", fOverwrite));
+    SetEnvDebug( GetEnv("EnvDebug",  fEnvDebug));
 
     return CheckEnvLocal();
@@ -172,5 +201,11 @@
         return kTRUE;
 
-    return loop.ReadEnv(*fEnv, fEnvPrefix, fEnvDebug) ? kTRUE : kFALSE;
+    if (!loop.ReadEnv(*fEnv, fEnvPrefix, fEnvDebug>2))
+        return kFALSE;
+
+    if (fEnvDebug>1)
+        fEnv->PrintUntouched();
+
+    return kTRUE;
 }
 
Index: trunk/MagicSoft/Mars/mjobs/MJob.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJob.h	(revision 6552)
+++ trunk/MagicSoft/Mars/mjobs/MJob.h	(revision 6553)
@@ -6,5 +6,5 @@
 #endif
 
-class TEnv;
+class MEnv;
 class MEvtLoop;
 
@@ -12,12 +12,14 @@
 {
 private:
+    enum { kIsOwner = BIT(14) };
+
     void FixPath(TString &path) const;
+    void ClearEnv();
 
-    const TEnv *fEnv;         // Resource file
+    const MEnv *fEnv;         // Resource file
     TString     fEnvPrefix;   // Prefix for resources
-    Bool_t      fEnvDebug;    // Debug setup of resources
+    Int_t       fEnvDebug;    // Debug setup of resources
 
 protected:
-
     TString   fPathOut;       // Directory to write output file to (eg. calib*.root)
     TString   fPathIn;        // Directory to read output from (eg. calib*.root)
@@ -29,7 +31,8 @@
     MSequence fSequence;      // Sequence
 
-    const TEnv *GetEnv() const { return fEnv; }
+    const TEnv *GetEnv() const;
+    const MEnv *GetMEnv() const { return fEnv; }
     const TString &GetEnvPrefix() const { return fEnvPrefix; }
-    Bool_t GetEnvDebug() const { return fEnvDebug; }
+    Int_t GetEnvDebug() const { return fEnvDebug; }
 
     Int_t       GetEnv(const char *name, Int_t dflt) const;
@@ -40,4 +43,5 @@
     Bool_t SetupEnv(MEvtLoop &loop) const;
     Bool_t CheckEnv();
+    void PrintUntouchedEnv() const;
     virtual Bool_t CheckEnvLocal() { return kTRUE; }
 
@@ -57,5 +61,6 @@
     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   SetEnv(MEnv *env, const char *prefix=0);
+    void   SetEnvDebug(Int_t d=2) { fEnvDebug=d; }
 
     void   SetMaxEvents(Int_t max) { fMaxEvents = max; }
Index: trunk/MagicSoft/Mars/star.cc
===================================================================
--- trunk/MagicSoft/Mars/star.cc	(revision 6552)
+++ trunk/MagicSoft/Mars/star.cc	(revision 6553)
@@ -9,4 +9,5 @@
 #include "MLogManip.h"
 
+#include "MEnv.h"
 #include "MArgs.h"
 #include "MArray.h"
@@ -49,5 +50,8 @@
     gLog << " Options:" << endl;
     gLog.Usage();
-    gLog << "   --debug-env               Debug setting resources from file" << endl;
+    gLog << "   --debug-env=0             Disable debugging setting resources <default>" << endl;
+    gLog << "   --debug-env[=1]           Display untouched resources after program execution" << endl;
+    gLog << "   --debug-env=2             Display untouched resources after eventloop setup" << endl;
+    gLog << "   --debug-env=3             Debug setting resources from resource file" << endl;
     gLog << "   --debug-mem               Debug memory usage" << endl << endl;
     gLog << endl;
@@ -109,6 +113,7 @@
     const Bool_t  kPrintFiles = arg.HasOnlyAndRemove("--print-files");
     const Bool_t  kPrintFound = arg.HasOnlyAndRemove("--print-found");
-    const Bool_t  kDebugEnv   = arg.HasOnlyAndRemove("--debug-env");
     const Bool_t  kDebugMem   = arg.HasOnlyAndRemove("--debug-mem");
+    Int_t  kDebugEnv = arg.HasOnlyAndRemove("--debug-env") ? 1 : 0;
+    kDebugEnv = arg.GetIntAndRemove("--debug-env=", kDebugEnv);
 
     const Bool_t  kQuit       = arg.HasOnlyAndRemove("-q");
@@ -149,4 +154,10 @@
     }
 
+    if (gSystem->AccessPathName(kConfig, kFileExists))
+    {
+        gLog << err << "Sorry, config file '" << kConfig << "' doesn't exist." << endl;
+        return -1;
+    }
+
     //
     // Setup sequence and check its validity
@@ -202,8 +213,9 @@
     // Do calibration in a block (debug mem)
     //
+    MEnv env(kConfig);
     {
         MJStar job(Form("MJStar #%d", seq.GetSequence()));
         job.SetSequence(seq);
-        job.SetEnv(kConfig);
+        job.SetEnv(&env);
         job.SetEnvDebug(kDebugEnv);
         job.SetDisplay(d);;
@@ -219,4 +231,7 @@
         }
 
+        if (kDebugEnv>0)
+            env.PrintUntouched();
+
         if (!job.GetDisplay())
         {
