Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 4600)
+++ trunk/MagicSoft/Mars/Changelog	(revision 4601)
@@ -47,4 +47,56 @@
    * Makefile:
      - added showlog
+
+   * macros/sql/filldotrbk.C, macros/sql/filldotrun.C:
+     - update of comments
+
+   * mbase/MEvtLoop.cc:
+     - first interprete environment for fLog
+
+   * mbase/MEvtLoop.[h,cc], mbase/MParContainer.[h,cc],
+     mbase/MParList.[h,cc], mbase/MTaskList.[h,cc],
+     mfileio/MRead.[h,cc], mhbase/MHMatrix.[h,cc],
+     mpedestal/MPedCalcFromLoGain.[h,cc],
+     mpedestal/MPedCalcFromPedRun.[h,cc],
+     msignal/MExtractor.[h,cc]:
+     - changed type of ReadEnv from Bool_t to Int_t
+
+   * mbase/MLog.cc:
+     - fixed ReadEnv
+
+   * mbase/MParContainer.[h,cc]:
+     - added TestEnv
+
+   * mbase/MParList.cc, mbase/MTaskList.cc:
+     - moved some code to MParContainer::TestEnv
+
+   * mbase/Makefile, mbase/BaseLinkDef.h:
+     - added MTaskEnv
+
+   * mhist/MHCamera.cc:
+     - removed some output (Draw function don't write something
+       to the console) - it is displayed anyhow
+     - added some SetBorderMode(0)
+
+   * mjobs/JobsLinkDef.h, mjobs/Makefile:
+     - added MSequence
+
+   * mjobs/MJPedestal.[h,cc]:
+     - changed to allow a sequence as input
+     - changed to allow setting up the extractor from a TEnv
+
+   * mpedestal/MPedCalcFromLoGain.[h,cc]:
+     - moved a common block of code to a new Calc function
+     - fixed ReadEnv
+
+   * mpedestal/MPedCalcPedRun.cc, msignal/MExtractor.cc:
+     - fixed ReadEnv
+
+   * mraw/MRawCrateData.cc:
+     - updated Print()
+
+   * mraw/MRawFileRead.h:
+     - added default to first constructor argument
+
 
 
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 4600)
+++ trunk/MagicSoft/Mars/NEWS	(revision 4601)
@@ -7,4 +7,11 @@
      into a file back into colored text (for example to display it with
      more): showlog
+
+   - Added support for Sequences (MSequence). Sequences are blocks of run
+     files containing the same calibration and belonging to the same 
+     source
+
+   - Added a new task (MTaskEnv) which can be used in setup files to switch
+     between different tasks (for example to choose a signal extractor)
 
 
Index: trunk/MagicSoft/Mars/macros/sql/filldotrbk.C
===================================================================
--- trunk/MagicSoft/Mars/macros/sql/filldotrbk.C	(revision 4600)
+++ trunk/MagicSoft/Mars/macros/sql/filldotrbk.C	(revision 4601)
@@ -31,5 +31,6 @@
 // the data center and store their contents in the runbook-database.
 //
-// Usage: root readrbk.C("/data/MAGIC/Period014", kTRUE)
+// Usage:
+//   .x readrbk.C("/data/MAGIC/Period014", kTRUE)
 //
 // While the first argument is the directory in which all subdirectories where
Index: trunk/MagicSoft/Mars/macros/sql/filldotrun.C
===================================================================
--- trunk/MagicSoft/Mars/macros/sql/filldotrun.C	(revision 4600)
+++ trunk/MagicSoft/Mars/macros/sql/filldotrun.C	(revision 4601)
@@ -39,5 +39,5 @@
 //
 // Usage:
-//    root -q -l -b filldotrun.C+("/data/MAGIC/Period019/ccdata", kTRUE) 2>&1 | tee filldotrun.log
+//    .x filldotrun.C+("/data/MAGIC/Period019/ccdata", kTRUE)
 //
 // While the first argument is the directory in which all subdirectories where
Index: trunk/MagicSoft/Mars/mbase/BaseLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 4600)
+++ trunk/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 4601)
@@ -33,4 +33,5 @@
 
 #pragma link C++ class MTask+;
+#pragma link C++ class MTaskEnv+;
 #pragma link C++ class MTaskInteractive+;
 #pragma link C++ class MTaskList+;
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 4601)
@@ -936,5 +936,5 @@
 //          all Mars classes.
 //
-Bool_t MEvtLoop::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+Int_t MEvtLoop::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
     if (!prefix.IsNull())
@@ -946,4 +946,6 @@
     *fLog << inf << "Reading resources for " << prefix /*TEnv::fRcName << " from " << env.GetRcName()*/ << endl;
 
+    fLog->ReadEnv(env, prefix, print);
+
     if (fParList->ReadEnv(env, prefix, print)==kERROR)
     {
@@ -951,6 +953,4 @@
         return kFALSE;
     }
-
-    fLog->ReadEnv(env, prefix, print);
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 4600)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 4601)
@@ -77,5 +77,5 @@
     void Print(Option_t *opt="") const;
 
-    Bool_t ReadEnv(const TEnv &env, TString prefix="", Bool_t print=kFALSE);
+    Int_t  ReadEnv(const TEnv &env, TString prefix="", Bool_t print=kFALSE);
     Bool_t WriteEnv(TEnv &env, TString prefix="", Bool_t print=kFALSE) const;
 
Index: trunk/MagicSoft/Mars/mbase/MGList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MGList.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/mbase/MGList.cc	(revision 4601)
@@ -37,4 +37,5 @@
 #include <iostream>
 
+#include <TROOT.h>
 #include <TClass.h>
 #include <TGClient.h>
@@ -45,4 +46,14 @@
 
 using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Add the list to the global list of cleanups
+//  objects in the list.
+//
+MGList::MGList() : TList()
+{
+    gROOT->GetListOfCleanups()->Add(this);
+}
 
 // --------------------------------------------------------------------------
@@ -159,4 +170,5 @@
 
     TList::Add(obj);
+    obj->SetBit(kMustCleanup);
 }
 
@@ -180,4 +192,5 @@
 
     TList::Add(obj, opt);
+    obj->SetBit(kMustCleanup);
 }
 
@@ -187,5 +200,5 @@
 //   - The picture is freed as often as it was retrieved from gClient
 //
-void MGList::AddPicture(const TGPicture *pic, const char *name)
+void MGList::AddPicture(TGPicture *pic, const char *name)
 {
     //
@@ -204,5 +217,6 @@
     // Add the picture to the list
     //
-    TList::Add(const_cast<TGPicture*>(pic));
+    TList::Add(pic);
+    pic->SetBit(kMustCleanup);
 }
 
@@ -221,5 +235,5 @@
 const TGPicture *MGList::GetPicture(const char *name)
 {
-    const TGPicture *pic = gClient->GetPicture(name);
+    TGPicture *pic = const_cast<TGPicture*>(gClient->GetPicture(name));
     AddPicture(pic, name);
     return pic;
@@ -240,5 +254,5 @@
 const TGPicture *MGList::GetPicture(const char *name, Int_t width, Int_t height)
 {
-    const TGPicture *pic = gClient->GetPicture(name, width, height);
+    TGPicture *pic = const_cast<TGPicture*>(gClient->GetPicture(name, width, height));
     AddPicture(pic, name);
     return pic;
Index: trunk/MagicSoft/Mars/mbase/MGList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MGList.h	(revision 4600)
+++ trunk/MagicSoft/Mars/mbase/MGList.h	(revision 4601)
@@ -15,9 +15,9 @@
     Bool_t    IsExisting(TObject *obj) const;
 
-    void      AddPicture(const TGPicture *pic, const char *name);
+    void      AddPicture(TGPicture *pic, const char *name);
 
 public:
-    MGList() : TList() {}
-    virtual ~MGList();
+    MGList();
+    ~MGList();
 
     void Add(TObject *obj);
Index: trunk/MagicSoft/Mars/mbase/MLog.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLog.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/mbase/MLog.cc	(revision 4601)
@@ -544,19 +544,23 @@
 void MLog::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
-    if (!prefix.IsNull())
-        prefix += ".";
-    prefix += "MLog";
-
     MParContainer mlog("MLog");
 
-    if (mlog.IsEnvDefined(env, prefix, "VerbosityLevel", print))
-        SetDebugLevel(mlog.GetEnvValue(env, prefix, "VerbosityLevel", 2));
-
-    if (mlog.IsEnvDefined(env, prefix, "DebugLevel", print))
-        gDebug = mlog.GetEnvValue(env, prefix, "DebugLevel", 0);
-
-    if (mlog.IsEnvDefined(env, prefix, "NoColors", print))
-        if (mlog.GetEnvValue(env, prefix, "NoColors", 1)>0)
-            SetNoColors();
+    if (mlog.IsEnvDefined(env, prefix+"MLog", "VerbosityLevel", print))
+        SetDebugLevel(mlog.GetEnvValue(env, prefix+"MLog", "VerbosityLevel", 2));
+    else
+        if (mlog.IsEnvDefined(env, "MLog", "VerbosityLevel", print))
+            SetDebugLevel(mlog.GetEnvValue(env, "MLog", "VerbosityLevel", 2));
+
+    if (mlog.IsEnvDefined(env, prefix+"MLog", "DebugLevel", print))
+        gDebug = mlog.GetEnvValue(env, prefix+"MLog", "DebugLevel", 0);
+    else
+        if (mlog.IsEnvDefined(env, "MLog", "DebugLevel", print))
+            gDebug = mlog.GetEnvValue(env, "MLog", "DebugLevel", 0);
+
+    if (mlog.IsEnvDefined(env, prefix+"MLog", "NoColors", print))
+        SetNoColors(mlog.GetEnvValue(env, prefix+"MLog", "NoColors", kFALSE));
+    else
+        if (mlog.IsEnvDefined(env, "MLog", "NoColors", print))
+            SetNoColors(mlog.GetEnvValue(env, "MLog", "NoColors", kFALSE));
 }
 
Index: trunk/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 4601)
@@ -569,5 +569,13 @@
 //          all Mars classes.
 //
-Bool_t MParContainer::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+// Return values:
+//  kTRUE:  Environment string found
+//  kFALSE: Environment string not found
+//  kERROR: Error occured, eg. environment invalid
+//
+// Overload this if you don't want to control the level of setup-string. In
+// this case ReadEnv gets called with the different possibilities, see TestEnv.
+//
+Int_t MParContainer::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
     if (!IsEnvDefined(env, prefix, "", print))
@@ -609,4 +617,54 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Take the prefix and call ReadEnv for:
+//   prefix.containername
+//   prefix.classname
+//   containername
+//   classname
+//
+//  The existance of an environment variable is done in this order. If
+//  ReadEnv return kTRUE the existance of the container setup is assumed and
+//  the other tests are skipped. If kFALSE is assumed the sequence is
+//  continued. In case of kERROR failing of the setup from a file is assumed.
+//
+// Overload this if you want to control the handling of level of setup-string
+// mentioned above. In this case ReadEnv gets never called if you don't call
+// it explicitly.
+//
+Int_t MParContainer::TestEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    if (print)
+        *fLog << all << "Testing Prefix+ContName: " << prefix+GetName() << endl;
+    Int_t rc = ReadEnv(env, prefix+GetName(), print);
+    if (rc==kERROR || rc==kTRUE)
+        return rc;
+
+    // Check For: Job4.MClassName.Varname
+    if (print)
+        *fLog << all << "Testing Prefix+ClasName: " << prefix+ClassName() << endl;
+    rc = ReadEnv(env, prefix+ClassName(), print);
+    if (rc==kERROR || rc==kTRUE)
+        return rc;
+
+    // Check For: ContainerName.Varname
+    if (print)
+        *fLog << all << "Testing ContName: " << GetName() << endl;
+    rc = ReadEnv(env, GetName(), print);
+    if (rc==kERROR || rc==kTRUE)
+        return rc;
+
+    // Check For: MClassName.Varname
+    if (print)
+        *fLog << all << "Testing ClassName: " << ClassName() << endl;
+    rc = ReadEnv(env, ClassName(), print);
+    if (rc==kERROR || rc==kTRUE)
+        return rc;
+
+    // Not found
+    return kFALSE;
+}
+
 Bool_t MParContainer::IsEnvDefined(const TEnv &env, TString prefix, TString postfix, Bool_t print) const
 {
Index: trunk/MagicSoft/Mars/mbase/MParContainer.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 4600)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 4601)
@@ -118,5 +118,6 @@
     virtual void SetNames(TObjArray &arr);
 
-    virtual Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
+    virtual Int_t  TestEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
+    virtual Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
     virtual Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
 
Index: trunk/MagicSoft/Mars/mbase/MParList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 4601)
@@ -853,5 +853,5 @@
 //          all Mars classes.
 //
-Bool_t MParList::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+Int_t MParList::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
     if (print)
@@ -870,39 +870,6 @@
         }
 
-        // Check For: Job4.ContainerName.Varname
-        if (print)
-            *fLog << all << "Testing: " << prefix+cont->GetName() << endl;
-        Bool_t rc = cont->ReadEnv(env, prefix+cont->GetName(), print);
-        if (rc==kERROR)
+        if (cont->TestEnv(env, prefix, print)==kERROR)
             return kERROR;
-        if (rc==kTRUE)
-            continue;
-
-        // Check For: Job4.MClassName.Varname
-        if (print)
-            *fLog << all << "Testing: " << prefix+cont->ClassName() << endl;
-        rc = cont->ReadEnv(env, prefix+cont->ClassName(), print);
-        if (rc==kERROR)
-            return kERROR;
-        if (rc==kTRUE)
-            continue;
-
-        // Check For: ContainerName.Varname
-        if (print)
-            *fLog << all << "Testing: " << cont->GetName() << endl;
-        rc = cont->ReadEnv(env, cont->GetName(), print);
-        if (rc==kERROR)
-            return kERROR;
-        if (rc==kTRUE)
-            continue;
-
-        // Check For: MClassName.Varname
-        if (print)
-            *fLog << all << "Testing: " << cont->ClassName() << endl;
-        rc = cont->ReadEnv(env, cont->ClassName(), print);
-        if (rc==kERROR)
-            return kERROR;
-        if (rc==kTRUE)
-            continue;
     }
 
Index: trunk/MagicSoft/Mars/mbase/MParList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParList.h	(revision 4600)
+++ trunk/MagicSoft/Mars/mbase/MParList.h	(revision 4601)
@@ -91,5 +91,5 @@
     void SavePrimitive(ofstream &out, Option_t *o="");
 
-    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
+    Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
     Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
 
Index: trunk/MagicSoft/Mars/mbase/MTaskEnv.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskEnv.cc	(revision 4601)
+++ trunk/MagicSoft/Mars/mbase/MTaskEnv.cc	(revision 4601)
@@ -0,0 +1,216 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTaskEnv
+//
+// If you want to create a new task inside a macro you will have to compile
+// your macro using macro.C++, because the root interpreter cannot use
+// uncompiled classes. To workaround this problem you can write simple
+// funcions (which can be handled by CINT) and use MTaskEnv.
+//
+// This is a simple way to develop new code in a macro without need
+// to compile it.
+//
+// Example:
+//    Int_t Process()
+//    {
+//       gLog << "Processing..." << endl;
+//       return kTRUE;
+//    }
+//
+//    void main()
+//    {
+//       MTaskEnv task;
+//       task.SetProcess(Process);
+//       MTaskList list;
+//       list.AddToList(&task);
+//    }
+//
+//
+//  Input Containers:
+//   -/-
+//
+//  Output Containers:
+//   -/-
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTaskEnv.h"
+
+#include <TClass.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MTaskEnv);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. Takes name and title of the interactive task
+//
+MTaskEnv::MTaskEnv(const char *name, const char *title) : fTask(0)
+{
+    fName  = name  ? name  : "MTaskEnv";
+    fTitle = title ? title : "Task setup from Environment file";
+}
+
+MTaskEnv::~MTaskEnv()
+{
+    if (TestBit(kIsOwner))
+        delete fTask;
+}
+
+MTask *MTaskEnv::GetTask(const char *name) const
+{
+    //
+    // try to get class from root environment
+    //
+    TClass *cls = gROOT->GetClass(name);
+    Int_t rc = 0;
+    if (!cls)
+        rc =1;
+    else
+    {
+        if (!cls->Property())
+            rc = 5;
+        if (!cls->Size())
+            rc = 4;
+        if (!cls->IsLoaded())
+            rc = 3;
+        if (!cls->HasDefaultConstructor())
+            rc = 2;
+    }
+
+    if (rc)
+    {
+        *fLog << err << dbginf << "Cannot create new instance of class '" << name << "': ";
+        switch (rc)
+        {
+        case 1:
+            *fLog << "gROOT->GetClass() returned NULL." << endl;
+            return NULL;
+        case 2:
+            *fLog << "no default constructor." << endl;
+            return NULL;
+        case 3:
+            *fLog << "not loaded." << endl;
+            return NULL;
+        case 4:
+            *fLog << "zero size." << endl;
+            return NULL;
+        case 5:
+            *fLog << "no property." << endl;
+            return NULL;
+        }
+    }
+
+    if (!cls->InheritsFrom(MTask::Class()))
+    {
+        *fLog << " - Class doesn't inherit from MTask." << endl;
+        return NULL;
+    }
+
+    //
+    // create the parameter container of the the given class type
+    //
+    MTask *task = (MTask*)cls->New();
+    if (!task)
+    {
+        *fLog << " - Class has no default constructor." << endl;
+        *fLog << " - An abstract member functions of a base class is not overwritten." << endl;
+        return NULL;
+    }
+
+    task->SetName(fName);
+    task->SetTitle(fTitle);
+
+    return task;
+}
+
+void MTaskEnv::SetDefault(const char *def)
+{
+    if (TestBit(kIsOwner) && fTask)
+        delete fTask;
+
+    fTask = GetTask(def);
+    if (!fTask)
+        *fLog << err << dbginf << "ERROR - No default Task setup..." << endl;
+
+    SetBit(kIsOwner);
+}
+
+Bool_t MTaskEnv::ReInit(MParList *list)
+{
+    return fTask->ReInit(list);
+}
+
+Int_t MTaskEnv::PreProcess(MParList *list)
+{
+    if (!fTask)
+    {
+        *fLog << err << GetDescriptor() << " - ERROR: Not task setup." << endl;
+        return kFALSE;
+    }
+
+    *fLog << fTask->ClassName() << " - " << flush;
+    return fTask->CallPreProcess(list);
+}
+
+Int_t MTaskEnv::Process()
+{
+    return fTask->CallProcess();
+}
+
+Int_t MTaskEnv::PostProcess()
+{
+    return fTask->CallPostProcess();
+}
+
+Int_t MTaskEnv::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    if (!IsEnvDefined(env, prefix, print))
+        return kFALSE;
+
+    TString task = GetEnvValue(env, prefix, "");
+    task.ReplaceAll("\015", "");
+    task = task.Strip(TString::kBoth);
+    fTask = GetTask(task.Data());
+    if (!fTask)
+    {
+        *fLog << err << GetDescriptor() << " - ERROR: No task matching '";
+        *fLog << task << "' could be setup." << endl;
+        return kERROR;
+    }
+
+    SetBit(kIsOwner);
+
+    return fTask->ReadEnv(env, prefix, print);
+}
+
+Bool_t MTaskEnv::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
+{
+    return fTask->WriteEnv(env, prefix, print);
+}
Index: trunk/MagicSoft/Mars/mbase/MTaskEnv.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskEnv.h	(revision 4601)
+++ trunk/MagicSoft/Mars/mbase/MTaskEnv.h	(revision 4601)
@@ -0,0 +1,41 @@
+#ifndef MARS_MTaskEnv
+#define MARS_MTaskEnv
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MFilter;
+class MTaskList;
+
+class MTaskEnv : public MTask
+{
+private:
+    MTask *fTask;
+
+    enum { kIsOwner = BIT(14) };
+
+    MTask *GetTask(const char *name) const;
+
+    Bool_t ReInit(MParList *list);
+
+    Int_t  PreProcess(MParList *list);
+    Int_t  Process();
+    Int_t  PostProcess();
+
+    Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
+    Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
+
+public:
+    MTaskEnv(const char *name=NULL, const char *title=NULL);
+    ~MTaskEnv();
+
+    void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
+
+    void SetDefault(MTask *task) { fTask = task; }
+    void SetDefault(const char *def);
+
+    ClassDef(MTaskEnv, 0) // Task which can be setup from an environment file
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 4601)
@@ -734,5 +734,5 @@
 //          all Mars classes.
 //
-Bool_t MTaskList::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+Int_t MTaskList::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
     if (print)
@@ -751,39 +751,6 @@
         }
 
-        // Check For: Job4.ContainerName.Varname
-        if (print)
-            *fLog << all << "Testing: " << prefix+cont->GetName() << endl;
-        Bool_t rc = cont->ReadEnv(env, prefix+cont->GetName(), print);
-        if (rc==kERROR)
+        if (cont->TestEnv(env, prefix, print)==kERROR)
             return kERROR;
-        if (rc==kTRUE)
-            continue;
-
-        // Check For: Job4.MClassName.Varname
-        if (print)
-            *fLog << all << "Testing: " << prefix+cont->ClassName() << endl;
-        rc = cont->ReadEnv(env, prefix+cont->ClassName(), print);
-        if (rc==kERROR)
-            return kERROR;
-        if (rc==kTRUE)
-            continue;
-
-        // Check For: ContainerName.Varname
-        if (print)
-            *fLog << all << "Testing: " << cont->GetName() << endl;
-        rc = cont->ReadEnv(env, cont->GetName(), print);
-        if (rc==kERROR)
-            return kERROR;
-        if (rc==kTRUE)
-            continue;
-
-        // Check For: MClassName.Varname
-        if (print)
-            *fLog << all << "Testing: " << cont->ClassName() << endl;
-        rc = cont->ReadEnv(env, cont->ClassName(), print);
-        if (rc==kERROR)
-            return kERROR;
-        if (rc==kTRUE)
-            continue;
     }
 
Index: trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 4600)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 4601)
@@ -78,5 +78,5 @@
     void SetNames(TObjArray &arr);
 
-    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
+    Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
     Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
 
Index: trunk/MagicSoft/Mars/mbase/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mbase/Makefile	(revision 4600)
+++ trunk/MagicSoft/Mars/mbase/Makefile	(revision 4601)
@@ -30,4 +30,5 @@
 	   MInputStreamID.cc \
            MTask.cc \
+           MTaskEnv.cc \
            MTaskInteractive.cc \
 	   MTaskList.cc \
Index: trunk/MagicSoft/Mars/mfileio/MRead.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MRead.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/mfileio/MRead.cc	(revision 4601)
@@ -82,5 +82,5 @@
 // Number of entries at the moment not supported
 //
-Bool_t MRead::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+Int_t MRead::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
     //
Index: trunk/MagicSoft/Mars/mfileio/MRead.h
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MRead.h	(revision 4600)
+++ trunk/MagicSoft/Mars/mfileio/MRead.h	(revision 4601)
@@ -26,5 +26,5 @@
     Int_t AddFiles(MDirIter &dir);
 
-    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
+    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
 
     ClassDef(MRead, 0)	// Base class for a reading task
Index: trunk/MagicSoft/Mars/mhbase/MHMatrix.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MHMatrix.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/mhbase/MHMatrix.cc	(revision 4601)
@@ -1055,5 +1055,5 @@
 //     MHMatrix.Column1: MHillasSrc.fAlpha
 //
-Bool_t MHMatrix::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+Int_t MHMatrix::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
     if (fM.IsValid())
Index: trunk/MagicSoft/Mars/mhbase/MHMatrix.h
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MHMatrix.h	(revision 4600)
+++ trunk/MagicSoft/Mars/mhbase/MHMatrix.h	(revision 4601)
@@ -112,5 +112,5 @@
     Bool_t DefRefMatrix(Int_t nmaxevts=0, TMatrix *mrest=NULL);
 
-    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
+    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
 
     void ShuffleRows(UInt_t seed);
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 4601)
@@ -1676,5 +1676,4 @@
 } 
 
-
 // --------------------------------------------------------------------------
 //
@@ -1695,220 +1694,208 @@
 // 7: Single Gauss with TLegend to show the meaning of the colours
 //
-//
 void MHCamera::DrawProjection(Int_t fit) const
 {
-  
-  TArrayI inner(1);
-  inner[0] = 0;
-  
-  TArrayI outer(1);
-  outer[0] = 1;
-          
-  if (fit==5 || fit==6)
-    {
-      
-      if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
+    TArrayI inner(1);
+    inner[0] = 0;
+
+    TArrayI outer(1);
+    outer[0] = 1;
+
+    if (fit==5 || fit==6)
+    {
+        if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
         {
-          TArrayI s0(6);
-          s0[0] = 6;
-          s0[1] = 1;
-          s0[2] = 2;
-          s0[3] = 3;
-          s0[4] = 4;
-          s0[5] = 5;
-
-          TArrayI s1(3);
-          s1[0] = 6;
-          s1[1] = 1;
-          s1[2] = 2;
-          
-          TArrayI s2(3);
-          s2[0] = 3;
-          s2[1] = 4;
-          s2[2] = 5;
-
-          gPad->Clear();
-          TVirtualPad *pad = gPad;
-          pad->Divide(2,1);
-          
-          TH1D *inout[2];
-          inout[0] = ProjectionS(s0, inner, "Inner");
-          inout[1] = ProjectionS(s0, outer, "Outer");
-          
-          inout[0]->SetDirectory(NULL);
-          inout[1]->SetDirectory(NULL);
-
-          for (int i=0; i<2; i++)
+            TArrayI s0(6);
+            s0[0] = 6;
+            s0[1] = 1;
+            s0[2] = 2;
+            s0[3] = 3;
+            s0[4] = 4;
+            s0[5] = 5;
+
+            TArrayI s1(3);
+            s1[0] = 6;
+            s1[1] = 1;
+            s1[2] = 2;
+
+            TArrayI s2(3);
+            s2[0] = 3;
+            s2[1] = 4;
+            s2[2] = 5;
+
+            gPad->Clear();
+            TVirtualPad *pad = gPad;
+            pad->Divide(2,1);
+
+            TH1D *inout[2];
+            inout[0] = ProjectionS(s0, inner, "Inner");
+            inout[1] = ProjectionS(s0, outer, "Outer");
+
+            inout[0]->SetDirectory(NULL);
+            inout[1]->SetDirectory(NULL);
+
+            for (int i=0; i<2; i++)
             {
-              pad->cd(i+1);
-              inout[i]->SetLineColor(kRed+i);
-              inout[i]->SetBit(kCanDelete);
-              inout[i]->Draw();
-              inout[i]->Fit("gaus","Q");
-              
-              
-              if (fit == 6)
+                pad->cd(i+1);
+                gPad->SetBorderMode(0);
+
+                inout[i]->SetLineColor(kRed+i);
+                inout[i]->SetBit(kCanDelete);
+                inout[i]->Draw();
+                inout[i]->Fit("gaus","Q");
+
+                if (fit == 6)
                 {
-                  TH1D *half[2];
-                  half[0] = ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2");
-                  half[1] = ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5");
-                  
-                  for (int j=0; j<2; j++)
+                    TH1D *half[2];
+                    half[0] = ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2");
+                    half[1] = ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5");
+
+                    for (int j=0; j<2; j++)
                     {
-                      half[j]->SetLineColor(kRed+i+2*j+1);
-                      half[j]->SetDirectory(NULL);
-                      half[j]->SetBit(kCanDelete);
-                      half[j]->Draw("same");
+                        half[j]->SetLineColor(kRed+i+2*j+1);
+                        half[j]->SetDirectory(NULL);
+                        half[j]->SetBit(kCanDelete);
+                        half[j]->Draw("same");
                     }
                 }
-              
+
             }
-          
-          gLog << all << GetName() 
-               << Form("%s%5.3f%s%3.2f"," Inner Pixels: ",
-                       inout[0]->GetFunction("gaus")->GetParameter(1),"+-",
-                       inout[0]->GetFunction("gaus")->GetParameter(2));
-          gLog << Form("%s%5.3f%s%3.2f"," Outer Pixels: ",
-                       inout[1]->GetFunction("gaus")->GetParameter(1),"+-",
-                       inout[1]->GetFunction("gaus")->GetParameter(2)) << endl;
-
         }
-      return;
-    }
-  
-  TH1D *obj2 = (TH1D*)Projection(GetName());
-  obj2->SetDirectory(0);
-  obj2->Draw();
-  obj2->SetBit(kCanDelete);
-  
-  if (fit == 0)
-    return;
-  
-  if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
-    {
-      TArrayI s0(3);
-      s0[0] = 6;
-      s0[1] = 1;
-      s0[2] = 2;
+        return;
+    }
+
+    TH1D *obj2 = (TH1D*)Projection(GetName());
+    obj2->SetDirectory(0);
+    obj2->Draw();
+    obj2->SetBit(kCanDelete);
+
+    if (fit == 0)
+        return;
+
+    if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
+    {
+        TArrayI s0(3);
+        s0[0] = 6;
+        s0[1] = 1;
+        s0[2] = 2;
+
+        TArrayI s1(3);
+        s1[0] = 3;
+        s1[1] = 4;
+        s1[2] = 5;
+
+        TH1D *halfInOut[4];
+
+        // Just to get the right (maximum) binning
+        halfInOut[0] = ProjectionS(s0, inner, "Sector 6-1-2 Inner");
+        halfInOut[1] = ProjectionS(s1, inner, "Sector 3-4-5 Inner");
+        halfInOut[2] = ProjectionS(s0, outer, "Sector 6-1-2 Outer");
+        halfInOut[3] = ProjectionS(s1, outer, "Sector 3-4-5 Outer");
+
+        TLegend *leg = new TLegend(0.05,0.65,0.35,0.9);
+
+        for (int i=0; i<4; i++)
+        {
+            halfInOut[i]->SetLineColor(kRed+i);
+            halfInOut[i]->SetDirectory(0);
+            halfInOut[i]->SetBit(kCanDelete);
+            halfInOut[i]->Draw("same");
+            leg->AddEntry(halfInOut[i],halfInOut[i]->GetTitle(),"l");
+        }
+
+        if (fit==7)
+            leg->Draw();
       
-      TArrayI s1(3);
-      s1[0] = 3;
-      s1[1] = 4;
-      s1[2] = 5;
-      
-      
-      TH1D *halfInOut[4];
-      
-      // Just to get the right (maximum) binning
-      halfInOut[0] = ProjectionS(s0, inner, "Sector 6-1-2 Inner");
-      halfInOut[1] = ProjectionS(s1, inner, "Sector 3-4-5 Inner");
-      halfInOut[2] = ProjectionS(s0, outer, "Sector 6-1-2 Outer");
-      halfInOut[3] = ProjectionS(s1, outer, "Sector 3-4-5 Outer");
-
-      TLegend *leg = new TLegend(0.05,0.65,0.35,0.9);
-      
-      for (int i=0; i<4; i++)
-        {
-          halfInOut[i]->SetLineColor(kRed+i);
-          halfInOut[i]->SetDirectory(0);
-          halfInOut[i]->SetBit(kCanDelete);
-          halfInOut[i]->Draw("same");
-          leg->AddEntry(halfInOut[i],halfInOut[i]->GetTitle(),"l");
-        }
-
-      if (fit==7)
-        leg->Draw();
-      
-      gPad->Modified();
-      gPad->Update();
-    }
-  
-  const Double_t min   = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
-  const Double_t max   = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
-  const Double_t integ = obj2->Integral("width")/2.5;
-  const Double_t mean  = obj2->GetMean();
-  const Double_t rms   = obj2->GetRMS();
-  const Double_t width = max-min;
-  
-  const TString dgausformula = "([0]-[3])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])"
-    "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])";
-  
-  const TString tgausformula = "([0]-[3]-[6])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])"
-    "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])"
-    "+[6]/[8]*exp(-0.5*(x-[7])*(x-[7])/[8]/[8])";
-  TF1 *f=0;
-  switch (fit)
+        gPad->Modified();
+        gPad->Update();
+    }
+
+    const Double_t min   = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
+    const Double_t max   = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
+    const Double_t integ = obj2->Integral("width")/2.5;
+    const Double_t mean  = obj2->GetMean();
+    const Double_t rms   = obj2->GetRMS();
+    const Double_t width = max-min;
+
+    const TString dgausformula = "([0]-[3])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])"
+        "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])";
+
+    const TString tgausformula = "([0]-[3]-[6])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])"
+        "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])"
+        "+[6]/[8]*exp(-0.5*(x-[7])*(x-[7])/[8]/[8])";
+
+    TF1 *f=0;
+    switch (fit)
     {
     case 1:
-      f = new TF1("sgaus", "gaus(0)", min, max);
-      f->SetLineColor(kYellow);
-      f->SetBit(kCanDelete);
-      f->SetParNames("Area", "#mu", "#sigma");
-      f->SetParameters(integ/rms, mean, rms);
-      f->SetParLimits(0, 0,   integ);
-      f->SetParLimits(1, min, max);
-      f->SetParLimits(2, 0,   width/1.5);
-      
-      obj2->Fit(f, "QLR");
-      break;
-      
+        f = new TF1("sgaus", "gaus(0)", min, max);
+        f->SetLineColor(kYellow);
+        f->SetBit(kCanDelete);
+        f->SetParNames("Area", "#mu", "#sigma");
+        f->SetParameters(integ/rms, mean, rms);
+        f->SetParLimits(0, 0,   integ);
+        f->SetParLimits(1, min, max);
+        f->SetParLimits(2, 0,   width/1.5);
+
+        obj2->Fit(f, "QLR");
+        break;
+
     case 2:
-      f = new TF1("dgaus",dgausformula.Data(),min,max);
-      f->SetLineColor(kYellow);
-      f->SetBit(kCanDelete);
-      f->SetParNames("A_{tot}", "#mu1", "#sigma1", "A2", "#mu2", "#sigma2");
-      f->SetParameters(integ,(min+mean)/2.,width/4.,
-                       integ/width/2.,(max+mean)/2.,width/4.);
-      // The left-sided Gauss
-      f->SetParLimits(0,integ-1.5      , integ+1.5);
-      f->SetParLimits(1,min+(width/10.), mean);
-      f->SetParLimits(2,0              , width/2.);
-      // The right-sided Gauss
-      f->SetParLimits(3,0   , integ);
-      f->SetParLimits(4,mean, max-(width/10.));
-      f->SetParLimits(5,0   , width/2.);
-      obj2->Fit(f,"QLRM");
-      break;
-      
+        f = new TF1("dgaus",dgausformula.Data(),min,max);
+        f->SetLineColor(kYellow);
+        f->SetBit(kCanDelete);
+        f->SetParNames("A_{tot}", "#mu1", "#sigma1", "A2", "#mu2", "#sigma2");
+        f->SetParameters(integ,(min+mean)/2.,width/4.,
+                         integ/width/2.,(max+mean)/2.,width/4.);
+        // The left-sided Gauss
+        f->SetParLimits(0,integ-1.5      , integ+1.5);
+        f->SetParLimits(1,min+(width/10.), mean);
+        f->SetParLimits(2,0              , width/2.);
+        // The right-sided Gauss
+        f->SetParLimits(3,0   , integ);
+        f->SetParLimits(4,mean, max-(width/10.));
+        f->SetParLimits(5,0   , width/2.);
+        obj2->Fit(f,"QLRM");
+        break;
+
     case 3:
-      f = new TF1("tgaus",tgausformula.Data(),min,max);
-      f->SetLineColor(kYellow);
-      f->SetBit(kCanDelete);
-      f->SetParNames("A_{tot}","#mu_{1}","#sigma_{1}",
-                     "A_{2}","#mu_{2}","#sigma_{2}",
-                     "A_{3}","#mu_{3}","#sigma_{3}");
-      f->SetParameters(integ,(min+mean)/2,width/4.,
-                       integ/width/3.,(max+mean)/2.,width/4.,
-                       integ/width/3.,mean,width/2.);
-      // The left-sided Gauss
-      f->SetParLimits(0,integ-1.5,integ+1.5);
-      f->SetParLimits(1,min+(width/10.),mean);
-      f->SetParLimits(2,width/15.,width/2.);
-      // The right-sided Gauss
-      f->SetParLimits(3,0.,integ);
-      f->SetParLimits(4,mean,max-(width/10.));
-      f->SetParLimits(5,width/15.,width/2.);
-      // The Gauss describing the outliers
-      f->SetParLimits(6,0.,integ);
-      f->SetParLimits(7,min,max);
-      f->SetParLimits(8,width/4.,width/1.5);
-      obj2->Fit(f,"QLRM");
-      break;
-      
+        f = new TF1("tgaus",tgausformula.Data(),min,max);
+        f->SetLineColor(kYellow);
+        f->SetBit(kCanDelete);
+        f->SetParNames("A_{tot}","#mu_{1}","#sigma_{1}",
+                       "A_{2}","#mu_{2}","#sigma_{2}",
+                       "A_{3}","#mu_{3}","#sigma_{3}");
+        f->SetParameters(integ,(min+mean)/2,width/4.,
+                         integ/width/3.,(max+mean)/2.,width/4.,
+                         integ/width/3.,mean,width/2.);
+        // The left-sided Gauss
+        f->SetParLimits(0,integ-1.5,integ+1.5);
+        f->SetParLimits(1,min+(width/10.),mean);
+        f->SetParLimits(2,width/15.,width/2.);
+        // The right-sided Gauss
+        f->SetParLimits(3,0.,integ);
+        f->SetParLimits(4,mean,max-(width/10.));
+        f->SetParLimits(5,width/15.,width/2.);
+        // The Gauss describing the outliers
+        f->SetParLimits(6,0.,integ);
+        f->SetParLimits(7,min,max);
+        f->SetParLimits(8,width/4.,width/1.5);
+        obj2->Fit(f,"QLRM");
+        break;
+
     case 4:
-      obj2->Fit("pol0", "Q");
-      obj2->GetFunction("pol0")->SetLineColor(kYellow);
-      break;
-      
+        obj2->Fit("pol0", "Q");
+        obj2->GetFunction("pol0")->SetLineColor(kYellow);
+        break;
+
     case 9:
-      break;
-      
+        break;
+
     default:
-      obj2->Fit("gaus", "Q");
-      obj2->GetFunction("gaus")->SetLineColor(kYellow);
-      break;
-    }
-}
-
+        obj2->Fit("gaus", "Q");
+        obj2->GetFunction("gaus")->SetLineColor(kYellow);
+        break;
+    }
+}
 
 // --------------------------------------------------------------------------
@@ -1921,44 +1908,42 @@
 void MHCamera::DrawRadialProfile() const
 {
-  
-  TProfile *obj2 = (TProfile*)RadialProfile(GetName());
-  obj2->SetDirectory(0);
-  obj2->Draw();
-  obj2->SetBit(kCanDelete);
-  
-  if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
-    {
-
-      TArrayI s0(6);
-      s0[0] = 1;
-      s0[1] = 2;
-      s0[2] = 3;
-      s0[3] = 4;
-      s0[4] = 5;
-      s0[5] = 6;
-
-      TArrayI inner(1);
-      inner[0] = 0;
-      
-      TArrayI outer(1);
-      outer[0] = 1;
-      
-      // Just to get the right (maximum) binning
-      TProfile *half[2];
-      half[0] = RadialProfileS(s0, inner,Form("%s%s",GetName(),"Inner"));
-      half[1] = RadialProfileS(s0, outer,Form("%s%s",GetName(),"Outer"));
-      
-      for (Int_t i=0; i<2; i++)
+    TProfile *obj2 = (TProfile*)RadialProfile(GetName());
+    obj2->SetDirectory(0);
+    obj2->Draw();
+    obj2->SetBit(kCanDelete);
+
+    if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
+    {
+        TArrayI s0(6);
+        s0[0] = 1;
+        s0[1] = 2;
+        s0[2] = 3;
+        s0[3] = 4;
+        s0[4] = 5;
+        s0[5] = 6;
+
+        TArrayI inner(1);
+        inner[0] = 0;
+
+        TArrayI outer(1);
+        outer[0] = 1;
+
+        // Just to get the right (maximum) binning
+        TProfile *half[2];
+        half[0] = RadialProfileS(s0, inner,Form("%sInner",GetName()));
+        half[1] = RadialProfileS(s0, outer,Form("%sOuter",GetName()));
+
+        for (Int_t i=0; i<2; i++)
         {
-          Double_t min = GetGeomCam().GetMinRadius(i);
-          Double_t max = GetGeomCam().GetMaxRadius(i);
-
-          half[i]->SetLineColor(kRed+i);
-          half[i]->SetDirectory(0);
-          half[i]->SetBit(kCanDelete);
-          half[i]->Draw("same");
-          half[i]->Fit("pol1","Q","",min,max);
-          half[i]->GetFunction("pol1")->SetLineColor(kRed+i);
-          half[i]->GetFunction("pol1")->SetLineWidth(1);
+            Double_t min = GetGeomCam().GetMinRadius(i);
+            Double_t max = GetGeomCam().GetMaxRadius(i);
+
+            half[i]->SetLineColor(kRed+i);
+            half[i]->SetDirectory(0);
+            half[i]->SetBit(kCanDelete);
+            half[i]->Draw("same");
+            half[i]->Fit("pol1","Q","",min,max);
+            half[i]->GetFunction("pol1")->SetLineColor(kRed+i);
+            half[i]->GetFunction("pol1")->SetLineWidth(1);
         }
     }
@@ -1974,33 +1959,31 @@
 void MHCamera::DrawAzimuthProfile() const
 {
-  
-  TProfile *obj2 = (TProfile*)AzimuthProfile(GetName());
-  obj2->SetDirectory(0);
-  obj2->Draw();
-  obj2->SetBit(kCanDelete);
-  obj2->Fit("pol0","Q","");
-  obj2->GetFunction("pol0")->SetLineWidth(1);
-  
-  if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
-    {
-
-      TArrayI inner(1);
-      inner[0] = 0;
-      
-      TArrayI outer(1);
-      outer[0] = 1;
-      
-      // Just to get the right (maximum) binning
-      TProfile *half[2];
-      half[0] = AzimuthProfileA(inner,Form("%s%s",GetName(),"Inner"));
-      half[1] = AzimuthProfileA(outer,Form("%s%s",GetName(),"Outer"));
-      
-      for (Int_t i=0; i<2; i++)
+    TProfile *obj2 = (TProfile*)AzimuthProfile(GetName());
+    obj2->SetDirectory(0);
+    obj2->Draw();
+    obj2->SetBit(kCanDelete);
+    obj2->Fit("pol0","Q","");
+    obj2->GetFunction("pol0")->SetLineWidth(1);
+
+    if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
+    {
+        TArrayI inner(1);
+        inner[0] = 0;
+
+        TArrayI outer(1);
+        outer[0] = 1;
+
+        // Just to get the right (maximum) binning
+        TProfile *half[2];
+        half[0] = AzimuthProfileA(inner,Form("%sInner",GetName()));
+        half[1] = AzimuthProfileA(outer,Form("%sOuter",GetName()));
+
+        for (Int_t i=0; i<2; i++)
         {
-          half[i]->SetLineColor(kRed+i);
-          half[i]->SetDirectory(0);
-          half[i]->SetBit(kCanDelete);
-          half[i]->SetMarkerSize(0.5);
-          half[i]->Draw("same");
+            half[i]->SetLineColor(kRed+i);
+            half[i]->SetDirectory(0);
+            half[i]->SetBit(kCanDelete);
+            half[i]->SetMarkerSize(0.5);
+            half[i]->Draw("same");
         }
     }
@@ -2028,47 +2011,44 @@
                        TObject *notify)
 {
-
-  c.cd(x);
-  gPad->SetBorderMode(0);
-  gPad->SetTicks();
-  MHCamera *obj1=(MHCamera*)DrawCopy("hist");
-  obj1->SetDirectory(NULL);
-  
-  if (notify)
-    obj1->AddNotify(notify);
-
-  c.cd(x+y);
-  gPad->SetBorderMode(0);
-  obj1->SetPrettyPalette();
-  obj1->Draw();
-
-  Int_t cnt = 2;
-
-  if (rad)
-    {
-      c.cd(x+2*y);
-      gPad->SetBorderMode(0);
-      gPad->SetTicks();
-      DrawRadialProfile();
-      cnt++;
-    }
-  
-  if (azi)
-    {
-      c.cd(x+cnt*y);
-      gPad->SetBorderMode(0);
-      gPad->SetTicks();
-      DrawAzimuthProfile();
-      cnt++;
-    }
-  
-  if (!fit)
-    return;
-  
-  c.cd(x + cnt*y);
-  gPad->SetBorderMode(0);
-  gPad->SetTicks();
-  DrawProjection(fit);
-}
-
-
+    c.cd(x);
+    gPad->SetBorderMode(0);
+    gPad->SetTicks();
+    MHCamera *obj1=(MHCamera*)DrawCopy("hist");
+    obj1->SetDirectory(NULL);
+
+    if (notify)
+        obj1->AddNotify(notify);
+
+    c.cd(x+y);
+    gPad->SetBorderMode(0);
+    obj1->SetPrettyPalette();
+    obj1->Draw();
+
+    Int_t cnt = 2;
+
+    if (rad)
+    {
+        c.cd(x+2*y);
+        gPad->SetBorderMode(0);
+        gPad->SetTicks();
+        DrawRadialProfile();
+        cnt++;
+    }
+
+    if (azi)
+    {
+        c.cd(x+cnt*y);
+        gPad->SetBorderMode(0);
+        gPad->SetTicks();
+        DrawAzimuthProfile();
+        cnt++;
+    }
+
+    if (!fit)
+        return;
+
+    c.cd(x + cnt*y);
+    gPad->SetBorderMode(0);
+    gPad->SetTicks();
+    DrawProjection(fit);
+}
Index: trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h	(revision 4600)
+++ trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h	(revision 4601)
@@ -4,4 +4,6 @@
 #pragma link off all classes;
 #pragma link off all functions;
+
+#pragma link C++ class MSequence+;
 
 #pragma link C++ class MJPedestal+;
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.cc	(revision 4601)
@@ -44,4 +44,6 @@
 #include "MLogManip.h"
 
+#include "MTaskEnv.h"
+#include "MSequence.h"
 #include "MRunIter.h"
 #include "MParList.h"
@@ -86,5 +88,5 @@
 //
 MJPedestal::MJPedestal(const char *name, const char *title) 
-    : fEnv(0), fRuns(0), fExtractor(NULL), fDisplayType(kNormalDisplay),
+    : fEnv(0), fRuns(0), fSequence(0), fExtractor(NULL), fDisplayType(kNormalDisplay),
       fDataCheck(kFALSE)
 {
@@ -101,4 +103,7 @@
 const char* MJPedestal::GetOutputFile() const
 {
+    if (fSequence)
+        return Form("%s/calped%05d", (const char*)fOutputPath, fSequence->GetSequence());
+
     if (!fRuns)
         return "";
@@ -143,5 +148,4 @@
 }
 
-
 void MJPedestal::DisplayResult(MParList &plist)
 {
@@ -154,6 +158,9 @@
     TString title = fDisplay->GetTitle();
     title += "--  Pedestal ";
-    if (fRuns)  // FIXME: What to do if an environmentfile was used?
-        title += fRuns->GetRunsAsString();
+    if (fSequence)
+        title += fSequence->GetName();
+    else
+        if (fRuns)  // FIXME: What to do if an environmentfile was used?
+            title += fRuns->GetRunsAsString();
     title += "  --";
     fDisplay->SetTitle(title);
@@ -242,14 +249,13 @@
     c3.cd(6);
     gPad->SetBorderMode(0);
-    gPad->SetTicks();
-
-    TArrayI inner(1);
-    inner[0] = 0;
-
-    TArrayI outer(1);
-    outer[0] = 1;
 
     if (geomcam.InheritsFrom("MGeomCamMagic"))
     {
+        TArrayI inner(1);
+        inner[0] = 0;
+
+        TArrayI outer(1);
+        outer[0] = 1;
+
         TArrayI s0(6);
         s0[0] = 6;
@@ -270,5 +276,4 @@
         s2[2] = 5;
 
-        gPad->Clear();
         TVirtualPad *pad = gPad;
         pad->Divide(2,1);
@@ -278,17 +283,19 @@
         inout[1] = disp1.ProjectionS(s0, outer, "Outer");
 
-        inout[0]->SetDirectory(NULL);
-        inout[1]->SetDirectory(NULL);
-
         for (int i=0; i<2; i++)
         {
-            TLegend *leg2 = new TLegend(0.6,0.2,0.9,0.55);
-            leg2->SetHeader(inout[i]->GetName());
             pad->cd(i+1);
+            gPad->SetBorderMode(0);
+            gPad->SetTicks();
+
+            inout[i]->SetDirectory(NULL);
             inout[i]->SetLineColor(kRed+i);
             inout[i]->SetBit(kCanDelete);
             inout[i]->Draw();
-            inout[i]->Fit("gaus","Q");
-            leg2->AddEntry(inout[i],inout[i]->GetName(),"l");
+            inout[i]->Fit("gaus", "Q");
+
+            TLegend *leg2 = new TLegend(0.6,0.2,0.9,0.55);
+            leg2->SetHeader(inout[i]->GetName());
+            leg2->AddEntry(inout[i], inout[i]->GetName(), "l");
 
             //
@@ -310,5 +317,5 @@
                 half[j]->SetBit(kCanDelete);
                 half[j]->Draw("same");
-                leg2->AddEntry(half[j],half[j]->GetName(),"l");
+                leg2->AddEntry(half[j], half[j]->GetName(), "l");
             }
             leg2->Draw();
@@ -419,10 +426,10 @@
 Bool_t MJPedestal::ProcessFile()
 {
-    if (!fRuns && !fEnv)
-    {
-        *fLog << err << "Neither AddRuns was called nor SetEnv was used... abort." << endl;
-        return kFALSE;
-    }
-    if (fRuns && fRuns->GetNumRuns() != fRuns->GetNumEntries())
+    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;
@@ -433,8 +440,11 @@
     fLog->Separator(GetDescriptor());
     *fLog << "Calculate MPedestalCam from Runs ";
-    if (fRuns)
-        *fLog << fRuns->GetRunsAsString() << endl;
+    if (fSequence)
+        *fLog << fSequence->GetName() << endl;
     else
-        *fLog << "in " << fEnv->GetName() << endl;
+        if (fRuns)
+            *fLog << fRuns->GetRunsAsString() << endl;
+        else
+            *fLog << "in " << fEnv->GetName() << endl;
     *fLog << endl;
 
@@ -446,15 +456,19 @@
     MRawFileRead rawread(NULL);
 
+    MDirIter iter;
+    if (fSequence)
+        fSequence->SetupPedRuns(iter);
+
     if (fDataCheck)
     {
-        if (fRuns)
-            rawread.AddFiles(*fRuns);
-	tlist.AddToList(&rawread);
+        if (fRuns || fSequence)
+            rawread.AddFiles(fSequence ? iter : *fRuns);
+        tlist.AddToList(&rawread);
     }
     else
     {
         read.DisableAutoScheme();
-        if (fRuns)
-            static_cast<MRead&>(read).AddFiles(*fRuns);
+        if (fRuns || fSequence)
+            static_cast<MRead&>(read).AddFiles(fSequence ? iter : *fRuns);
 	tlist.AddToList(&read);
     }
@@ -468,5 +482,9 @@
     MGeomApply      geomapl;
     MBadPixelsMerge merge(&fBadPixels);
+
     MPedCalcPedRun  pedcalc;
+
+    MTaskEnv taskenv("ExtractPedestal");
+    taskenv.SetDefault(&pedcalc);
 
     if (fExtractor)
@@ -483,5 +501,5 @@
     tlist.AddToList(&geomapl);
     tlist.AddToList(&merge);
-    tlist.AddToList(&pedcalc);
+    tlist.AddToList(&taskenv);
 
     //
Index: trunk/MagicSoft/Mars/mjobs/MJPedestal.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 4600)
+++ trunk/MagicSoft/Mars/mjobs/MJPedestal.h	(revision 4601)
@@ -12,4 +12,5 @@
 class TCanvas;
 class MParList;
+class MSequence;
 class MRunIter;
 class MHCamera;
@@ -36,6 +37,7 @@
 
     TEnv       *fEnv;           // Input setup-file
+    MRunIter   *fRuns;
+    MSequence  *fSequence;      //
 
-    MRunIter   *fRuns;
     MExtractor *fExtractor;     // Signal extractor, used to find the nr. of used FADC slices
 
@@ -70,6 +72,7 @@
 
     void SetBadPixels(const MBadPixelsCam &bad) { bad.Copy(fBadPixels); }
-    void SetExtractor(MExtractor* ext   ) { fExtractor = ext;     }
+    void SetExtractor(MExtractor* ext) { fExtractor = ext; }
     void SetInput(MRunIter *iter) { fRuns = iter; }
+    void SetSequence(MSequence *seq) { fSequence = seq; }
     void SetOutputPath(const char *path=".");
     void SetEnv(const char *env);
Index: trunk/MagicSoft/Mars/mjobs/MSequence.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 4601)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 4601)
@@ -0,0 +1,166 @@
+/* ======================================================================== *\
+!
+! *
+! * 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, 2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MSequence
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MSequence.h"
+
+#include <stdlib.h>
+
+#include <TEnv.h>
+#include <TRegexp.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MDirIter.h"
+
+ClassImp(MSequence);
+
+using namespace std;
+
+void MSequence::Split(TString &runs, TArrayI &data) const
+{
+    const TRegexp regexp("[0-9]+");
+
+    data.Set(0);
+    runs = runs.Strip(TString::kTrailing);
+
+    while (!runs.IsNull())
+    {
+        TString num = runs(regexp);
+
+        const Int_t n = data.GetSize();
+        data.Set(n+1);
+        data[n] = atoi(num.Data());
+
+        runs.Remove(0, runs.First(num)+num.Length());
+    }
+}
+
+void MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr) const
+{
+    for (int i=0; i<arr.GetSize(); i++)
+    {
+        TString d, n;
+        d  = "/data/MAGIC/Period";
+        d += Form("%03d", fPeriod);
+        d += "/rootdata/";
+        d += fNight.GetStringFmt("%Y_%m_%d");
+        n =  fNight.GetStringFmt("%Y%m%d_");
+        n += Form("%05d", arr[i]);
+        n += "_*_E.root";
+
+        iter.AddDirectory(d, n, 0);
+    }
+}
+
+MSequence::MSequence(const char *fname)
+{
+    fName  = fname;
+    fTitle = Form("Sequence contained in file %s", fName.Data());
+
+    TEnv env(fname);
+
+    TString str;
+
+    fSequence  = env.GetValue("Sequence", -1);
+    fLastRun   = env.GetValue("LastRun", -1);
+    fNumEvents = env.GetValue("NumEvents", -1);
+    fPeriod    = env.GetValue("Period", -1);
+
+    str = env.GetValue("Start", "");
+    fStart.SetSqlDateTime(str);
+    str = env.GetValue("Night", "");
+    str += " 00:00:00";
+    fNight.SetSqlDateTime(str);
+
+    fProject      = env.GetValue("Project", "");
+    fSource       = env.GetValue("Source", "");
+    fTriggerTable = env.GetValue("TriggerTable", "");
+    fHvSettings   = env.GetValue("HvSettings", "");
+
+    str = env.GetValue("Runs", "");
+    Split(str, fRuns);
+    str = env.GetValue("CalRuns", "");
+    Split(str, fCalRuns);
+    str = env.GetValue("PedRuns", "");
+    Split(str, fPedRuns);
+    str = env.GetValue("DatRuns", "");
+    Split(str, fDatRuns);
+}
+
+void MSequence::Print(Option_t *o) const
+{
+    gLog << all;
+    gLog << "Sequence:     " << fSequence << endl;
+    gLog << "Period:       " << fPeriod << endl;
+    gLog << "Night:        " << fNight << endl << endl;
+    gLog << "Start:        " << fStart << endl;
+    gLog << "LastRun:      " << fLastRun << endl;
+    gLog << "NumEvents:    " << fNumEvents << endl;
+    gLog << "Project:      " << fProject << endl;
+    gLog << "Source:       " << fSource << endl;
+    gLog << "TriggerTable: " << fTriggerTable << endl;
+    gLog << "HvSettings:   " << fHvSettings << endl << endl;
+    gLog << "Runs:";
+    for (int i=0; i<fRuns.GetSize(); i++)
+        gLog << " " << fRuns[i];
+    gLog << endl;
+    gLog << "CalRuns:";
+    for (int i=0; i<fCalRuns.GetSize(); i++)
+        gLog << " " << fCalRuns[i];
+    gLog << endl;
+    gLog << "PedRuns:";
+    for (int i=0; i<fPedRuns.GetSize(); i++)
+        gLog << " " << fPedRuns[i];
+    gLog << endl;
+    gLog << "DatRuns:";
+    for (int i=0; i<fDatRuns.GetSize(); i++)
+        gLog << " " << fDatRuns[i];
+    gLog << endl;
+}
+
+void MSequence::SetupPedRuns(MDirIter &iter) const
+{
+    SetupRuns(iter, fPedRuns);
+}
+
+void MSequence::SetupDatRuns(MDirIter &iter) const
+{
+    SetupRuns(iter, fDatRuns);
+}
+
+void MSequence::SetupAllRuns(MDirIter &iter) const
+{
+    SetupRuns(iter, fRuns);
+}
+
+void MSequence::SetupCalRuns(MDirIter &iter) const
+{
+    SetupRuns(iter, fCalRuns);
+}
Index: trunk/MagicSoft/Mars/mjobs/MSequence.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 4601)
+++ trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 4601)
@@ -0,0 +1,56 @@
+#ifndef MARS_MSequence
+#define MARS_MSequence
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+#ifndef MARS_MTime
+#include "MTime.h"
+#endif
+
+class MDirIter;
+
+class MSequence : public MParContainer
+{
+private:
+    UInt_t fSequence;
+
+    MTime  fStart;
+
+    UInt_t fLastRun;
+    UInt_t fNumEvents;
+
+    UInt_t fPeriod;
+    MTime  fNight;
+
+    TString fProject;
+    TString fSource;
+    TString fTriggerTable;
+    TString fHvSettings;
+
+    TArrayI fRuns;
+    TArrayI fCalRuns;
+    TArrayI fPedRuns;
+    TArrayI fDatRuns;
+
+    void Split(TString &runs, TArrayI &data) const;
+    void SetupRuns(MDirIter &iter, const TArrayI &arr) const;
+
+public:
+    MSequence(const char *fname);
+
+    void Print(Option_t *o="") const;
+
+    void SetupPedRuns(MDirIter &iter) const;
+    void SetupDatRuns(MDirIter &iter) const;
+    void SetupAllRuns(MDirIter &iter) const;
+    void SetupCalRuns(MDirIter &iter) const;
+
+    // Getter
+    UInt_t GetSequence() const { return fSequence; }
+
+    ClassDef(MSequence, 0)
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mjobs/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mjobs/Makefile	(revision 4600)
+++ trunk/MagicSoft/Mars/mjobs/Makefile	(revision 4601)
@@ -25,5 +25,6 @@
 #manalysis: MChisqEval (MParameters)
 
-SRCFILES = MJPedestal.cc \
+SRCFILES = MSequence.cc \
+	   MJPedestal.cc \
            MJCalibration.cc \
            MJExtractSignal.cc \
Index: trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 4601)
@@ -114,4 +114,14 @@
 //   fLoGainWindowSize = fgLoGainWindowSize = 0
 //
+//  Variables:
+//   fgHiGainFirst;      First FADC slice Hi-Gain (currently set to: 3)
+//   fgHiGainLast:       Last FADC slice Hi-Gain (currently set to: 14)
+//   fgLoGainFirst:      First FADC slice Lo-Gain (currently set to: 3)
+//   fgLoGainLast:       Last FADC slice Lo-Gain (currently set to: 14)
+//   fgHiGainWindowSize: The extraction window Hi-Gain
+//   fgLoGainWindowSize: The extraction window Lo-Gain
+//   fgMaxHiGainVar:     The maximum difference between the highest and lowest slice
+//                       in the high gain window allowed in order to use low gain
+//
 //  Input Containers:
 //   MRawEvtData
@@ -201,4 +211,16 @@
   fRunHeader = NULL;
   fPedestals = NULL;
+
+  // If the size is yet set, set the size
+  if (fSumx.GetSize()>0)
+  {
+      // Reset contents of arrays.
+      fSumx.Reset();
+      fSumx2.Reset();
+      fSumAB0.Reset();
+      fSumAB1.Reset();
+      fNumEventsUsed.Reset();
+      fTotalCounter.Reset();
+  }
 }
 
@@ -297,40 +319,34 @@
 //  - MPedestalCam
 //
-Int_t MPedCalcFromLoGain::PreProcess( MParList *pList )
-{
-  Clear();
-  
-  fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
-  if (!fRawEvt)
-    {
-      *fLog << err << "MRawEvtData not found... aborting." << endl;
-      return kFALSE;
-    }
-  
-  fRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
-  if (!fRunHeader)
-    {
-      *fLog << err << AddSerialNumber("MRawRunHeader") << " not found... aborting." << endl;
-      return kFALSE;
-    }
-
-  fGeom   =  (MGeomCam*)pList->FindObject("MGeomCam");
-  if (!fGeom)
-    {
-      *fLog << err << "MGeomCam not found... aborting." << endl;
-      return kFALSE;
-    }
-
-  *fLog << " searching for the container " << fPedContainerName << endl;
-
-  fPedestals = (MPedestalCam*)pList->FindCreateObj( AddSerialNumber("MPedestalCam"),fPedContainerName);  
-  if (!fPedestals)
-  {
-    *fLog << err << fPedContainerName << " can not be created" << endl;
-    return kFALSE;
-  }
-
-
-  return kTRUE;
+Int_t MPedCalcFromLoGain::PreProcess(MParList *pList)
+{
+    Clear();
+
+    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvt)
+    {
+        *fLog << err << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
+    if (!fRunHeader)
+    {
+        *fLog << err << AddSerialNumber("MRawRunHeader") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fGeom)
+    {
+        *fLog << err << "MGeomCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam", AddSerialNumber(fPedContainerName));
+    if (!fPedestals)
+        return kFALSE;
+
+    return kTRUE;
 }
 
@@ -353,5 +369,4 @@
 Bool_t MPedCalcFromLoGain::ReInit(MParList *pList)
 {
-      
   Int_t lastdesired   = (Int_t)fLoGainLast;
   Int_t lastavailable = (Int_t)fRunHeader->GetNumSamplesLoGain()-1;
@@ -413,8 +428,9 @@
 
 
-  Int_t npixels  = fPedestals->GetSize();
-  
+  // If the size is not yet set, set the size
   if (fSumx.GetSize()==0)
-    {
+  {
+      const Int_t npixels = fPedestals->GetSize();
+
       fSumx. Set(npixels);
       fSumx2.Set(npixels);
@@ -423,5 +439,6 @@
       fNumEventsUsed.Set(npixels);
       fTotalCounter.Set(npixels);
-      
+
+      // Reset contents of arrays.
       fSumx.Reset();
       fSumx2.Reset();
@@ -430,14 +447,13 @@
       fNumEventsUsed.Reset();
       fTotalCounter.Reset();
-    }
-  
-  if (fWindowSizeHiGain == 0 && fWindowSizeLoGain == 0)
-    {
-      *fLog << err << GetDescriptor() 
+  }
+  
+  if (fWindowSizeHiGain==0 && fWindowSizeLoGain==0)
+  {
+      *fLog << err << GetDescriptor()
             << ": Number of extracted Slices is 0, abort ... " << endl;
       return kFALSE;
-    }
-  
-  
+  }
+
   *fLog << endl;
   *fLog << inf << GetDescriptor() << ": Taking " << (int)fWindowSizeHiGain
@@ -449,4 +465,29 @@
 }
 
+void MPedCalcFromLoGain::Calc(ULong_t n, UInt_t idx)
+{
+    const ULong_t nsamplestot = n*fWindowSizeLoGain;
+
+    const Float_t sum  = fSumx.At(idx);
+    const Float_t sum2 = fSumx2.At(idx);
+    const Float_t ped  = sum/nsamplestot;
+
+    // 1. Calculate the Variance of the sums:
+    Float_t var = (sum2-sum*sum/n)/(n-1.);
+
+    // 2. Scale the variance to the number of slices:
+    var /= (Float_t)(fWindowSizeLoGain);
+
+    // 3. Calculate the RMS from the Variance:
+    const Float_t rms = var<0 ? 0 : TMath::Sqrt(var);
+
+    // 4. Calculate the amplitude of the 150MHz "AB" noise
+    const Float_t abOffs = (fSumAB0[idx] - fSumAB1[idx]) / nsamplestot;
+
+    (*fPedestals)[idx].Set(ped, rms, abOffs, n);
+
+    fTotalCounter[idx]++;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -457,97 +498,78 @@
 Int_t MPedCalcFromLoGain::Process()
 {
-  MRawEvtPixelIter pixel(fRawEvt);
-  
-  while (pixel.Next()) {
+    MRawEvtPixelIter pixel(fRawEvt);
+
+    while (pixel.Next())
+    {
+        const UInt_t idx = pixel.GetPixelId();
+
+        Byte_t *ptr = pixel.GetHiGainSamples() + fHiGainFirst;
+        Byte_t *end = ptr + fWindowSizeHiGain;
+
+        UInt_t sum = 0;
+        UInt_t sqr = 0;
+
+        UInt_t max = 0;
+        UInt_t min = 255;
     
-    const UInt_t idx    = pixel.GetPixelId();
-    
-    Byte_t *ptr = pixel.GetHiGainSamples() + fHiGainFirst;
-    Byte_t *end = ptr + fWindowSizeHiGain;
-
-    UInt_t sum = 0;
-    UInt_t sqr = 0;
-    
-    UInt_t max = 0;
-    UInt_t min = 255;
-    
-    // Find the maximum and minimum signal per slice in the high gain window
-    do {
-      if (*ptr > max) {
-	max = *ptr;
-      }
-      if (*ptr < min) {
-	min = *ptr;
-      }
-    } while (++ptr != end);
-    
-    // If the maximum in the high gain window is smaller than 
-    if ((max-min < fMaxHiGainVar) && (max < 255)) {
-      
-      Byte_t *firstSlice = pixel.GetLoGainSamples() + fLoGainFirst;
-      Byte_t *lastSlice  = firstSlice + fWindowSizeLoGain;
-      
-      Byte_t *slice = firstSlice;
-      do {
-	sum += *slice;
-	sqr += *slice * *slice;
-      } while (++slice != lastSlice);
-
-      const Float_t msum = (Float_t)sum;
-      const Float_t sqrsum  = msum*msum;
-      
-      fSumx[idx]  += msum;
-      fSumx2[idx] += sqrsum;
-      fNumEventsUsed[idx]++;
-
-      // Calculate the amplitude of the 150MHz "AB" noise
-
-      Int_t abFlag = (fRunHeader->GetNumSamplesHiGain()
-		       + fLoGainFirst
-		       + pixel.HasABFlag()) & 0x1;
-      for (Int_t islice=0; islice<fWindowSizeLoGain; islice+=2) {
-	Int_t sliceAB0 = islice + abFlag;
-	Int_t sliceAB1 = islice + 1 - abFlag;
-	fSumAB0[idx] += firstSlice[sliceAB0];
-	fSumAB1[idx] += firstSlice[sliceAB1];
-      }
-
-      if (fPedestalUpdate && (fNumEventsUsed[idx] >= fNumEventsDump)) {
-
-	const ULong_t n = fNumEventsDump;
-
-	const ULong_t nsamplestot = n*fWindowSizeLoGain;
-	
-	const Float_t sum  = fSumx.At(idx);
-	const Float_t sum2 = fSumx2.At(idx);
-	const Float_t ped  = sum/(nsamplestot);
-    
-	// 1. Calculate the Variance of the sums:
-	Float_t var = (sum2-sum*sum/n)/(n-1.);
-	
-	// 2. Scale the variance to the number of slices:
-	var /= (Float_t)(fWindowSizeLoGain);
-	
-	// 3. Calculate the RMS from the Variance:
-	Float_t rms = var < 0 ? 0. : TMath::Sqrt(var);
-
-	// 4. Calculate the amplitude of the 150MHz "AB" noise
-	Float_t abOffs = (fSumAB0[idx] - fSumAB1[idx]) / nsamplestot;
-
-	(*fPedestals)[idx].Set(ped, rms, abOffs, n);
-	
-	fTotalCounter[idx]++;
-	fNumEventsUsed[idx]=0;
-	fSumx[idx]=0;
-	fSumx2[idx]=0;
-	fSumAB0[idx]=0;
-	fSumAB1[idx]=0;
-      }
-    }
-  }
-  
-  fPedestals->SetReadyToSave();
-  
-  return kTRUE;
+        // Find the maximum and minimum signal per slice in the high gain window
+        do {
+            if (*ptr > max) {
+                max = *ptr;
+            }
+            if (*ptr < min) {
+                min = *ptr;
+            }
+        } while (++ptr != end);
+
+        // If the maximum in the high gain window is smaller than
+        if (max-min>=fMaxHiGainVar || max>=255)
+            continue;
+
+        Byte_t *firstSlice = pixel.GetLoGainSamples() + fLoGainFirst;
+        Byte_t *lastSlice  = firstSlice + fWindowSizeLoGain;
+
+        Byte_t *slice = firstSlice;
+        do {
+            sum += *slice;
+            sqr += *slice * *slice;
+        } while (++slice != lastSlice);
+
+        const Float_t msum   = (Float_t)sum;
+        const Float_t sqrsum = msum*msum;
+
+        fSumx[idx]  += msum;
+        fSumx2[idx] += sqrsum;
+        fNumEventsUsed[idx]++;
+
+        // Calculate the amplitude of the 150MHz "AB" noise
+
+        Int_t abFlag = (fRunHeader->GetNumSamplesHiGain()
+                        + fLoGainFirst
+                        + pixel.HasABFlag()) & 0x1;
+        for (Int_t islice=0; islice<fWindowSizeLoGain; islice+=2)
+        {
+            Int_t sliceAB0 = islice + abFlag;
+            Int_t sliceAB1 = islice - abFlag + 1;
+            fSumAB0[idx] += firstSlice[sliceAB0];
+            fSumAB1[idx] += firstSlice[sliceAB1];
+        }
+
+        if (!fPedestalUpdate || fNumEventsUsed[idx]<fNumEventsDump)
+            continue;
+
+        Calc(fNumEventsDump, idx);
+
+        fNumEventsUsed[idx]=0;
+        fSumx[idx]=0;
+        fSumx2[idx]=0;
+        fSumAB0[idx]=0;
+        fSumAB1[idx]=0;
+    }
+
+    if (fPedestalUpdate)
+        fPedestals->SetReadyToSave();
+
+    return kTRUE;
 }
 
@@ -558,53 +580,69 @@
 Int_t MPedCalcFromLoGain::PostProcess()
 {
-
-  // Compute pedestals and rms from the whole run
-
-  if (!fPedestalUpdate) {
-
-    MRawEvtPixelIter pixel(fRawEvt);
-    
-    while (pixel.Next()) {
-      
-      const Int_t  idx = pixel.GetPixelId();
-      
-      const ULong_t n = fNumEventsUsed[idx];
-      
-      if (n < 2)
-	continue;
-      
-      const ULong_t nsamplestot = n*fWindowSizeLoGain;
-      
-      const Float_t sum  = fSumx.At(idx);
-      const Float_t sum2 = fSumx2.At(idx);
-      const Float_t ped  = sum/(nsamplestot);
-      
-      // 1. Calculate the Variance of the sums:
-      Float_t var = (sum2-sum*sum/n)/(n-1.);
-      
-      // 2. Scale the variance to the number of slices:
-      var /= (Float_t)(fWindowSizeLoGain);
-      
-      // 3. Calculate the RMS from the Variance:
-      Float_t rms = var < 0 ? 0. : TMath::Sqrt(var);
-      
-      // 4. Calculate the amplitude of the 150MHz "AB" noise
-      Float_t abOffs = (fSumAB0[idx] - fSumAB1[idx]) / nsamplestot;
-      
-      (*fPedestals)[idx].Set(ped, rms, abOffs, n);
-      
-      fTotalCounter[idx]++;
+    // Compute pedestals and rms from the whole run
+    if (fPedestalUpdate)
+        return kTRUE;
+
+    *fLog << flush << inf << "Calculating Pedestals..." << flush;
+
+    const Int_t npix = fGeom->GetNumPixels();
+    for (Int_t idx=0; idx<npix; idx++)
+    {
+        const ULong_t n = fNumEventsUsed[idx];
+        if (n>1)
+            Calc(n, idx);
     }
 
     fPedestals->SetReadyToSave();
-  }
-
-  fSumx.Reset();
-  fSumx2.Reset();
-  fSumAB0.Reset();
-  fSumAB1.Reset();
-  fNumEventsUsed.Reset();
-  fTotalCounter.Reset();
-
-  return kTRUE;
-}
+    return kTRUE;
+}
+
+Int_t MPedCalcFromLoGain::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    if (MExtractor::ReadEnv(env, prefix, print)==kERROR)
+        return kERROR;
+
+    Bool_t rc=kFALSE;
+
+    Byte_t hw = fWindowSizeHiGain;
+    Byte_t lw = fWindowSizeLoGain;
+    if (IsEnvDefined(env, prefix, "WindowSizeHiGain", print))
+    {
+        hw = GetEnvValue(env, prefix, "WindowSizeHiGain", hw);
+        rc = kTRUE;
+    }
+    if (IsEnvDefined(env, prefix, "WindowSizeLoGain", print))
+    {
+        lw = GetEnvValue(env, prefix, "WindowSizeLoGain", lw);
+        rc = kTRUE;
+    }
+
+    if (rc)
+        SetWindowSize(hw, lw);
+
+    Int_t num = fNumEventsDump;
+    if (IsEnvDefined(env, prefix, "NumEventsDump", print))
+    {
+        num = GetEnvValue(env, prefix, "NumEventsDump", num);
+        rc = kTRUE;
+    }
+    SetDumpEvents(num);
+
+    Byte_t max = fMaxHiGainVar;
+    if (IsEnvDefined(env, prefix, "MaxHiGainVar", print))
+    {
+        max = GetEnvValue(env, prefix, "MaxHiGainVar", max);
+        rc = kTRUE;
+    }
+    SetMaxHiGainVar(max);
+
+    Bool_t upd = fPedestalUpdate;
+    if (IsEnvDefined(env, prefix, "PedestalUpdate", print))
+    {
+        upd = GetEnvValue(env, prefix, "PedestalUpdate", upd);
+        rc = kTRUE;
+    }
+    SetPedestalUpdate(upd);
+
+    return rc;
+}
Index: trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h	(revision 4600)
+++ trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h	(revision 4601)
@@ -19,52 +19,59 @@
 class MPedCalcFromLoGain : public MExtractor
 {
-  static const Byte_t fgHiGainFirst;      // First FADC slice Hi-Gain (currently set to: 3) 
-  static const Byte_t fgHiGainLast;       // Last FADC slice Hi-Gain (currently set to: 14) 
-  static const Byte_t fgLoGainFirst;      // First FADC slice Lo-Gain (currently set to: 3) 
-  static const Byte_t fgLoGainLast;       // Last FADC slice Lo-Gain (currently set to: 14) 
-  static const Byte_t fgHiGainWindowSize; // The extraction window Hi-Gain
-  static const Byte_t fgLoGainWindowSize; // The extraction window Lo-Gain
-  static const Byte_t fgMaxHiGainVar;     // The maximum difference between the highest and lowest slice 
-                                          // in the high gain window allowed in order to use low gain 
+    static const Byte_t fgHiGainFirst;      // First FADC slice Hi-Gain (currently set to: 3)
+    static const Byte_t fgHiGainLast;       // Last FADC slice Hi-Gain (currently set to: 14)
+    static const Byte_t fgLoGainFirst;      // First FADC slice Lo-Gain (currently set to: 3)
+    static const Byte_t fgLoGainLast;       // Last FADC slice Lo-Gain (currently set to: 14)
+    static const Byte_t fgHiGainWindowSize; // The extraction window Hi-Gain
+    static const Byte_t fgLoGainWindowSize; // The extraction window Lo-Gain
+    static const Byte_t fgMaxHiGainVar;     // The maximum difference between the highest and lowest slice
 
-  Int_t   fNumEventsDump;    // Number of event after which MPedestalCam gets updated
+    Int_t   fNumEventsDump;      // Number of event after which MPedestalCam gets updated
 
-  Byte_t  fMaxHiGainVar;
-  Byte_t  fWindowSizeHiGain; // Number of Hi Gain slices in window
-  Byte_t  fWindowSizeLoGain; // Number of Lo Gain slices in window
+    Byte_t  fMaxHiGainVar;
+    Byte_t  fWindowSizeHiGain;   // Number of Hi Gain slices in window
+    Byte_t  fWindowSizeLoGain;   // Number of Lo Gain slices in window
 
-  Bool_t  fPedestalUpdate;
+    Bool_t  fPedestalUpdate;
 
-  MGeomCam     *fGeom;       // Camera geometry
-  TString fPedContainerName; // name of the 'MPedestalCam' container
- 
-  TArrayI fNumEventsUsed;    // Number of events used for pedestal calc for each pixel
-  TArrayI fTotalCounter;     // Counter for dumping values to Pedestal Container
-  TArrayD fSumx;             // sum of values
-  TArrayD fSumx2;            // sum of squared values
-  TArrayD fSumAB0;           // sum of ABFlag=0 slices
-  TArrayD fSumAB1;           // sum of ABFlag=1 slices
+    MGeomCam *fGeom;             // Camera geometry
+    TString   fPedContainerName; // name of the 'MPedestalCam' container
 
-  
-  Int_t  PreProcess (MParList *pList);
-  Bool_t ReInit     (MParList *pList);
-  Int_t  Process    ();
-  Int_t  PostProcess();
-  
+    TArrayI fNumEventsUsed;      // Number of events used for pedestal calc for each pixel
+    TArrayI fTotalCounter;       // Counter for dumping values to Pedestal Container
+    TArrayD fSumx;               // sum of values
+    TArrayD fSumx2;              // sum of squared values
+    TArrayD fSumAB0;             // sum of ABFlag=0 slices
+    TArrayD fSumAB1;             // sum of ABFlag=1 slices
+
+    // MParContainer
+    Int_t  PreProcess (MParList *pList);
+    Bool_t ReInit     (MParList *pList);
+    Int_t  Process    ();
+    Int_t  PostProcess();
+    Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
+
+    // Calculation
+    void Calc(ULong_t n, UInt_t idx);
+
 public:
-  MPedCalcFromLoGain(const char *name=NULL, const char *title=NULL);
-  
-  void Clear(const Option_t *o="");
-  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
-  void SetWindowSize(Byte_t windowh=0, Byte_t windowl=0);
-  void SetMaxHiGainVar(Byte_t maxvar=0);
-  void SetDumpEvents(UInt_t dumpevents = 0) {fNumEventsDump = dumpevents;}
-  void SetPedestalUpdate(Bool_t pedupdate)  {fPedestalUpdate = pedupdate;}
-  
-  void SetPedContainerName(const char *name)    { fPedContainerName = name; }
+    MPedCalcFromLoGain(const char *name=NULL, const char *title=NULL);
 
-  TArrayI *GetNumEventsUsed() {return &fNumEventsUsed;};
-  
-  ClassDef(MPedCalcFromLoGain, 0)   // Task to calculate pedestals from pedestal runs raw data
+    // TObject
+    void Clear(const Option_t *o="");
+
+    // Setter
+    void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
+    void SetWindowSize(Byte_t windowh=0, Byte_t windowl=0);
+    void SetMaxHiGainVar(Byte_t maxvar=0);
+    void SetDumpEvents(UInt_t dumpevents = 0) {fNumEventsDump = dumpevents;}
+    void SetPedestalUpdate(Bool_t pedupdate)  {fPedestalUpdate = pedupdate;}
+
+    void SetPedContainerName(const char *name) { fPedContainerName = name; }
+
+    // Getter
+    TArrayI *GetNumEventsUsed() { return &fNumEventsUsed; }
+
+    ClassDef(MPedCalcFromLoGain, 0)   // Task to calculate pedestals from pedestal runs raw data
 };
 
Index: trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc	(revision 4601)
@@ -443,5 +443,4 @@
   while (pixel.Next())
     {
-
       const UInt_t idx    = pixel.GetPixelId();
       const UInt_t aidx   = (*fGeom)[idx].GetAidx();
@@ -620,2 +619,30 @@
   return kTRUE;
 }
+
+Int_t MPedCalcPedRun::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    if (MExtractor::ReadEnv(env, prefix, print)==kERROR)
+        return kERROR;
+
+    Byte_t hw = fWindowSizeHiGain;
+    Byte_t lw = fWindowSizeLoGain;
+
+    Bool_t rc = kFALSE;
+
+    if (IsEnvDefined(env, prefix, "WindowSizeHiGain", print))
+    {
+        hw = GetEnvValue(env, prefix, "WindowSizeHiGain", hw);
+        rc=kTRUE;
+    }
+
+    if (IsEnvDefined(env, prefix, "WindowSizeLoGain", print))
+    {
+        lw = GetEnvValue(env, prefix, "WindowSizeLoGain", lw);
+        rc=kTRUE;
+    }
+
+    if (rc)
+        SetWindowSize(hw, lw);
+
+    return rc;
+}
Index: trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.h
===================================================================
--- trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.h	(revision 4600)
+++ trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.h	(revision 4601)
@@ -44,4 +44,5 @@
     Int_t  Process    ();
     Int_t  PostProcess();
+    Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
 
 public:
Index: trunk/MagicSoft/Mars/mraw/MRawCrateData.cc
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawCrateData.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/mraw/MRawCrateData.cc	(revision 4601)
@@ -75,7 +75,7 @@
 {
     *fLog << all;
-    *fLog << "Crate Number " << dec << fDAQCrateNumber << ":  ";
-    *fLog << "FADCEventNr   = " << fFADCEvtNumber << "  ";
-    *fLog << "FADCClockTick = " << fFADCClockTick << " (20MHz)" << endl;
-    *fLog << "ABFlags       = " << hex << fABFlags << endl;
+    *fLog << "Crate #" << dec << fDAQCrateNumber << ":  ";
+    *fLog << "FADCEventNr = " << fFADCEvtNumber << "  ";
+    *fLog << "FADCClockTick = " << fFADCClockTick << " (20MHz)  ";
+    *fLog << "ABFlags = 0x" << Form("%02x", fABFlags) << endl;
 }
Index: trunk/MagicSoft/Mars/mraw/MRawFileRead.h
===================================================================
--- trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 4600)
+++ trunk/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 4601)
@@ -29,5 +29,5 @@
 
 public:
-    MRawFileRead(const char *filename, const char *name=NULL, const char *title=NULL);
+    MRawFileRead(const char *filename=NULL, const char *name=NULL, const char *title=NULL);
     ~MRawFileRead();
 
Index: trunk/MagicSoft/Mars/msignal/MExtractor.cc
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractor.cc	(revision 4600)
+++ trunk/MagicSoft/Mars/msignal/MExtractor.cc	(revision 4601)
@@ -302,5 +302,5 @@
 //   MJPedestal.MExtractor.SaturationLimit: 88
 //
-Bool_t MExtractor::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+Int_t MExtractor::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
     Byte_t hf = fHiGainFirst;
@@ -309,19 +309,36 @@
     Byte_t ll = fLoGainLast;
 
+    Bool_t rc = kFALSE;
+
     if (IsEnvDefined(env, prefix, "HiGainFirst", print))
+    {
         hf = GetEnvValue(env, prefix, "HiGainFirst", hf);
+        rc = kTRUE;
+    }
     if (IsEnvDefined(env, prefix, "LoGainFirst", print))
+    {
         lf = GetEnvValue(env, prefix, "LoGainFirst", lf);
+        rc = kTRUE;
+    }
 
     if (IsEnvDefined(env, prefix, "HiGainLast", print))
+    {
         hl = GetEnvValue(env, prefix, "HiGainLast", hl);
+        rc = kTRUE;
+    }
     if (IsEnvDefined(env, prefix, "LoGainLast", print))
+    {
         ll = GetEnvValue(env, prefix, "LoGainLast", ll);
+        rc = kTRUE;
+    }
 
     SetRange(hf, hl, lf, ll);
 
     if (IsEnvDefined(env, prefix, "SaturationLimit", print))
+    {
         SetSaturationLimit(GetEnvValue(env, prefix, "SaturationLimit", fSaturationLimit));
-
-    return kTRUE;
-}
+        rc = kTRUE;
+    }
+
+    return rc;
+}
Index: trunk/MagicSoft/Mars/msignal/MExtractor.h
===================================================================
--- trunk/MagicSoft/Mars/msignal/MExtractor.h	(revision 4600)
+++ trunk/MagicSoft/Mars/msignal/MExtractor.h	(revision 4601)
@@ -55,5 +55,5 @@
     Int_t  Process();
     void   StreamPrimitive(ofstream &out) const;
-    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
+    Int_t  ReadEnv(const TEnv &env, TString prefix, Bool_t print);
 
 public:
