Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 1879)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 1880)
@@ -1,3 +1,83 @@
                                                  -*-*- END OF LINE -*-*-
+
+ 2003/03/31: Thomas Bretz
+ 
+   * Makefile.conf.linux:
+     - removed -fno-rtti to make it compatible with root 3.04.02
+   
+   * NEWS:
+     - changed
+   
+   * manalysis/MImgCleanStd.[h,cc]:
+     - added SetLvl1
+     - added SetLvl2
+     - added ReadEnv
+   
+   * manalysis/MNewImagePar.[h,cc]:
+     - removed unnecessary fHillas data member
+     - removed unnecessary fSrcPos data member
+     - removed unnecessary Set/GetSrcPos 
+   
+   * manalysis/MNewImageParCalc.[h,cc]:
+     - removed unnecessary SetSrcPos 
+     - removed const-qualifier from fGeomCam, fCerPhotEvt
+       (trouble with root 3.02/06)
+   
+   * manalysis/MRanForest.cc:
+     - changed cout-output
+     
+   * manalysis/MSigmabar.cc:
+     - changed Area to area (local variable)
+
+   * mbase/MEvtLoop.[h,cc]:
+     - added evtloop name to constructor (default=Evtloop)
+     - adapted StreamPrimitive
+     - added ReadEnv
+     - added WriteEnv
+     
+   * mbase/MParContainer.[h,cc]:
+     - removed TROOT.h
+     - fixed const-qualifier for Copy-function for root>3.04.01
+     - added ReadEnv
+     - added WriteEnv
+     - added IsEnvDefined
+     - added GetEnvValue
+     
+   * mbase/MParList.[h,cc], mbase/MTaskList.[h,cc]:
+     - added ReadEnv
+     - added WriteEnv
+   
+   * mfileio/MCT1ReadAscii.[h,cc], mfileio/MCT1ReadPreProc.[h,cc]:
+     - changed AddFile declaration to declaration in MRead
+     - added return value to AddFile
+     
+   * mfileio/MRead.[h,cc]:
+     - added template for AddFile
+     - added ReadEnv
+     
+   * mgui/MHexagon.[h,cc]:
+     - fixed const-qualifier for Copy-function for root>3.04.01
+   
+   * mhist/MH.cc:
+     - fixed the FindGoodLimit stuff for root> 3.04.01
+     
+   * mhist/MHRanForest.[h,cc], mhist/MHRanForestGini.[h,cc]:
+     - removed unnecessary casts
+     - fixed a copilation error with root 3.04.01 (kFullDotlarge 
+       doesn't exist)
+     - removed second Draw (one should not add something twice to 
+       the pad)
+       
+   * mmontecarlo/MMcTriggerRateCalc.cc:
+     - changes to the header
+     - changes to the fLog stuff
+     - added a cast to get rid of a warning
+     
+   * mtools/Makefile, mtools/ToolsLinkDef.h:
+     - added MagicReversi
+   
+   * mtools/MagicRevers.[h,cc]:
+     - added
+
 
 
@@ -384,4 +464,5 @@
       - Added axis labels in graphic output
       - Added Get function for rate histograms
+
     * macros/trigrate.C
       - Added output file with rate histograms
Index: /trunk/MagicSoft/Mars/Makefile.conf.linux
===================================================================
--- /trunk/MagicSoft/Mars/Makefile.conf.linux	(revision 1879)
+++ /trunk/MagicSoft/Mars/Makefile.conf.linux	(revision 1880)
@@ -20,5 +20,5 @@
 #  ----->>>   settings for compilation
 #
-OPTIM    = -O5 -Wall -fno-rtti -fnonnull-objects -fno-exceptions -fPIC -Wtraditional -Wpointer-arith -Wcast-align -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Woverloaded-virtual
+OPTIM    = -O5 -Wall -fnonnull-objects -fno-exceptions -fPIC -Wtraditional -Wpointer-arith -Wcast-align -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Woverloaded-virtual
 DEBUG    =
 ARCHDEF  = -D__LINUX__
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 1879)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 1880)
@@ -40,4 +40,6 @@
    
    - added Random Forest - method for g/h-separation
+
+   - made compatible with the latest PRO version of root (3.04/02)
 
 
Index: /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 1880)
@@ -414,4 +414,16 @@
 }
 
+void MImgCleanStd::SetLvl1(Float_t lvl)
+{
+    fCleanLvl1 = lvl;
+    *fLog << inf << "Cleaning level 1 set to " << lvl << " sigma." << endl;
+}
+
+void MImgCleanStd::SetLvl2(Float_t lvl)
+{
+    fCleanLvl2 = lvl;
+    *fLog << inf << "Cleaning level 2 set to " << lvl << " sigma." << endl;
+}
+
 // --------------------------------------------------------------------------
 //
@@ -433,11 +445,9 @@
     {
     case kImgCleanLvl1:
-        fCleanLvl1 = lvl;
-        *fLog << "Cleaning level 1 set to " << lvl << " sigma." << endl;
+        SetLvl1(lvl);
         return kTRUE;
 
     case kImgCleanLvl2:
-        fCleanLvl2 = lvl;
-        *fLog << "Cleaning level 2 set to " << lvl << " sigma." << endl;
+        SetLvl2(lvl);
         return kTRUE;
     }
@@ -465,2 +475,38 @@
     out << ");" << endl;
 }
+
+// --------------------------------------------------------------------------
+//
+// Read the setup from a TEnv:
+//   Float_t fCleanLvl1: CleaningLevel1
+//   Float_t fCleanLvl2: CleaningLevel2
+//
+Bool_t MImgCleanStd::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    Bool_t rc = kTRUE;
+    if (!IsEnvDefined(env, prefix, "CleaningLevel1", print))
+        rc = kFALSE;
+    else
+    {
+        SetLvl1(GetEnvValue(env, prefix, "CleaningLevel1", fCleanLvl1));
+        if (fCleanLvl1<0)
+        {
+            *fLog << err << "ERROR - Negative values for Cleaning Level 1 forbidden." << endl;
+            return kERROR;
+        }
+    }
+
+    if (!IsEnvDefined(env, prefix, "CleaningLevel2", print))
+        rc = kFALSE;
+    else
+    {
+        SetLvl2(GetEnvValue(env, prefix, "CleaningLevel2", fCleanLvl2));
+        if (fCleanLvl2<0)
+        {
+            *fLog << err << "ERROR - Negative values for Cleaning Level 2 forbidden." << endl;
+            return kERROR;
+        }
+    }
+
+    return rc;
+}
Index: /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 1880)
@@ -20,4 +20,7 @@
     Float_t fCleanLvl2;
 
+    void SetLvl1(Float_t lvl);
+    void SetLvl2(Float_t lvl);
+
     void CreateGuiElements(MGGroupFrame *f);
     void StreamPrimitive(ofstream &out) const;
@@ -40,4 +43,5 @@
 
     Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2);
+    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
 
     ClassDef(MImgCleanStd, 0)    // task doing a standard image cleaning
Index: /trunk/MagicSoft/Mars/manalysis/MNewImagePar.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MNewImagePar.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/manalysis/MNewImagePar.cc	(revision 1880)
@@ -72,5 +72,5 @@
                           const MHillas *hillas)
 {
-    fHillas = hillas;
+    //fHillas = (MHillas*)hillas;
 
     const UInt_t npixevt = evt.GetNumPixels();
@@ -96,7 +96,6 @@
     }
 
-
-    fLeakage1 = edgepix1 / fHillas->GetSize();
-    fLeakage2 = edgepix2 / fHillas->GetSize();
+    fLeakage1 = edgepix1 / hillas->GetSize();
+    fLeakage2 = edgepix2 / hillas->GetSize();
 
     SetReadyToSave();
Index: /trunk/MagicSoft/Mars/manalysis/MNewImagePar.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MNewImagePar.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/manalysis/MNewImagePar.h	(revision 1880)
@@ -11,7 +11,4 @@
 {
 private:
-    const MHillas    *fHillas; //! Input parameters
-    const MSrcPosCam *fSrcPos; //! Source position in the camera
-
     Float_t fLeakage1;   // (photons in most outer ring of pixels) over fSize
     Float_t fLeakage2;   // (photons in the 2 outer rings of pixels) over fSize
@@ -20,6 +17,6 @@
     MNewImagePar(const char *name=NULL, const char *title=NULL);
 
-    void SetSrcPos(const MSrcPosCam *pos) { fSrcPos = pos; }
-    const MSrcPosCam *GetSrcPos() const   { return fSrcPos; }
+    //    void SetSrcPos(MSrcPosCam *pos) { fSrcPos = pos; }
+    //    const MSrcPosCam *GetSrcPos() const   { return fSrcPos; }
 
     void Reset();
Index: /trunk/MagicSoft/Mars/manalysis/MNewImageParCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MNewImageParCalc.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/manalysis/MNewImageParCalc.cc	(revision 1880)
@@ -107,6 +107,4 @@
         return kFALSE;
 
-    fNewImagePar->SetSrcPos(fSrcPos);
-
     fErrors = 0;
 
Index: /trunk/MagicSoft/Mars/manalysis/MNewImageParCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MNewImageParCalc.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/manalysis/MNewImageParCalc.h	(revision 1880)
@@ -15,6 +15,6 @@
 {
 private:
-    const MGeomCam    *fGeomCam;
-    const MCerPhotEvt *fCerPhotEvt;
+    MGeomCam    *fGeomCam;
+    MCerPhotEvt *fCerPhotEvt;
 
     MHillas      *fHillas;       //! Pointer to the source independent hillas parameters
Index: /trunk/MagicSoft/Mars/manalysis/MRanForest.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MRanForest.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/manalysis/MRanForest.cc	(revision 1880)
@@ -288,7 +288,5 @@
 
     // give running output
-    TString str=Form("%.2f",100.*fErr);
-    cout.width(5);  cout<<fTreeNo;
-    cout.width(15); cout<<str<<endl;
+    cout << setw(5) << fTreeNo << setw(15) << Form("%.2f",100.*fErr) << endl;
 
     // adding tree to forest
Index: /trunk/MagicSoft/Mars/manalysis/MSigmabar.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MSigmabar.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/manalysis/MSigmabar.cc	(revision 1880)
@@ -91,7 +91,4 @@
   Int_t outerPixels[6]       = {0,0,0,0,0,0};
 
-  Int_t currentSector;
-  Float_t angle;
-  
   // sum up sigma**2 for each sector, separately for inner and outer region;
   // all pixels are renormalized to the area of pixel 0
@@ -117,5 +114,5 @@
 
       Int_t j = cerpix.GetPixId();
-      Double_t Area = geom.GetPixRatio(j);
+      Double_t area = geom.GetPixRatio(j);
 
       const MGeomPix    &gpix = geom[j];
@@ -125,7 +122,8 @@
       //if (angle<0.0) angle+=6.0;
 
-      angle = 6.0*atan2(gpix.GetY(),gpix.GetX()) / (2.0*TMath::Pi());
-      if (angle<0.0) angle+=6.0;
-      currentSector=(Int_t)angle;
+      Float_t angle = atan2(gpix.GetY(),gpix.GetX())*6 / (TMath::Pi()*2);
+      if (angle<0) angle+=6;
+
+      Int_t currentSector=(Int_t)angle;
        
       // count only those pixels which have a sigma != 0.0 
@@ -134,13 +132,13 @@
       if ( sigma != 0.0 )
       {  
-        if (Area < 1.5)
+        if (area < 1.5)
         {
           innerPixels[currentSector]++;
-          innerSquaredSum[currentSector]+= sigma*sigma / Area;
+          innerSquaredSum[currentSector]+= sigma*sigma / area;
         }
         else
         {
           outerPixels[currentSector]++;
-          outerSquaredSum[currentSector]+= sigma*sigma / Area;
+          outerSquaredSum[currentSector]+= sigma*sigma / area;
         }
       }
@@ -191,5 +189,5 @@
   }
     
-  return (fSigmabar);
+  return fSigmabar;
 }
 
Index: /trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 1880)
@@ -103,7 +103,7 @@
 // default constructor - emty
 //
-MEvtLoop::MEvtLoop() : fParList(NULL), fProgress(NULL)
-{
-    fName = "Evtloop";
+MEvtLoop::MEvtLoop(const char *name) : fParList(NULL), fProgress(NULL)
+{
+    fName = name;
 }
 
@@ -444,10 +444,15 @@
 // gui elements to a macro-file.
 //
-
 void MEvtLoop::StreamPrimitive(ofstream &out) const
 {
-    out << "   MEvtLoop " << GetUniqueName() << ";" << endl;
-}
-
+    out << "   MEvtLoop " << GetUniqueName();
+    if (fName!="Evtloop")
+        out << "(\"" << fName << "\")";
+    out << ";" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//
 void MEvtLoop::SavePrimitive(ofstream &out, Option_t *opt)
 {
@@ -666,2 +671,86 @@
     return n;
 }
+
+// --------------------------------------------------------------------------
+//
+// Read the contents/setup of a parameter container/task from a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we should search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MEvtLoop::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    if (!prefix.IsNull())
+        *fLog << warn << "WARNING - Second argument in MEvtLoop::ReadEnv has no meaning... ignored." << endl;
+
+    *fLog << "1: " << "'" << prefix << "'" << (int)print << endl;
+
+    prefix = fName;
+    prefix += ".";
+
+    *fLog << inf << "Reading resources for " << prefix /*TEnv::fRcName << " from " << env.GetRcName()*/ << endl;
+
+    if (fParList->ReadEnv(env, prefix, print)==kERROR)
+    {
+        *fLog << err << "ERROR - Reading Environment file." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Write the contents/setup of a parameter container/task to a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we should search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MEvtLoop::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
+{
+    if (!prefix.IsNull())
+        *fLog << warn << "WARNING - Second argument in MEvtLoop::WriteEnv has no meaning... ignored." << endl;
+
+    prefix = fName;
+    prefix += ".";
+
+    *fLog << inf << "Writing resources: " << prefix /*TEnv::fRcName << " to " << env.GetRcName()*/ << endl;
+
+    if (fParList->WriteEnv(env, prefix, print)!=kTRUE)
+    {
+        *fLog << err << "ERROR - Writing Environment file." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
Index: /trunk/MagicSoft/Mars/mbase/MEvtLoop.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 1880)
@@ -37,5 +37,5 @@
 
 public:
-    MEvtLoop();
+    MEvtLoop(const char *name="Evtloop");
     virtual ~MEvtLoop();
 
@@ -66,4 +66,7 @@
     void Print(Option_t *opt="") const;
 
+    Bool_t ReadEnv(const TEnv &env, TString prefix="", Bool_t print=kFALSE);
+    Bool_t WriteEnv(TEnv &env, TString prefix="", Bool_t print=kFALSE) const;
+
     ClassDef(MEvtLoop, 1) // Class to execute the tasks in a tasklist
 };
Index: /trunk/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 1880)
@@ -40,5 +40,5 @@
 #include <fstream.h>     // ofstream, AsciiWrite
 
-#include <TROOT.h>       // TROOT::Identlevel
+#include <TEnv.h>        // Env::Lookup
 #include <TClass.h>      // IsA
 #include <TObjArray.h>   // TObjArray
@@ -54,5 +54,5 @@
 #include "MEvtLoop.h"    // gListOfPrimitives
 #else
-TList *gListOfPrimitives;
+TList *gListOfPrimitives; // forard declaration in MParContainer.h
 #endif
 
@@ -122,4 +122,7 @@
 //
 void MParContainer::Copy(TObject &obj)
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+const
+#endif
 {
     MParContainer &cont = (MParContainer&)obj;
@@ -449,2 +452,105 @@
     return (MParContainer*)IsA()->New();
 }
+
+// --------------------------------------------------------------------------
+//
+// Read the contents/setup of a parameter container/task from a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we should search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MParContainer::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    if (!IsEnvDefined(env, prefix, "", print))
+        return kFALSE;
+
+    *fLog << warn << "WARNING - Resource " << prefix+fName << " found, but no " << IsA()->GetName() << "::ReadEnv." << endl;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Write the contents/setup of a parameter container/task to a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we should search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MParContainer::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
+{
+    if (!IsEnvDefined(env, prefix, "", print))
+        return kFALSE;
+
+    *fLog << warn << "WARNING - Resource " << prefix+fName << " found, but " << IsA()->GetName() << "::WriteEnv not overloaded." << endl;
+    return kTRUE;
+}
+
+Bool_t MParContainer::IsEnvDefined(const TEnv &env, TString prefix, TString postfix, Bool_t print) const
+{
+    if (!postfix.IsNull())
+        postfix.Insert(0, ".");
+
+    return IsEnvDefined(env, prefix+fName+postfix, print);
+}
+
+Bool_t MParContainer::IsEnvDefined(const TEnv &env, TString name, Bool_t print) const
+{
+    if (print)
+        *fLog << all << GetDescriptor() << " - " << name << "... " << flush;
+
+    if (!((TEnv&)env).Defined(name))
+    {
+        if (print)
+            *fLog << "not found." << endl;
+        return kFALSE;
+    }
+
+    if (print)
+        *fLog << "found." << endl;
+
+    return kTRUE;
+}
+
+Int_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, TString postfix, Int_t dflt) const
+{
+    return ((TEnv&)env).GetValue(prefix+fName+"."+postfix, dflt);
+}
+
+Double_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, TString postfix, Double_t dflt) const
+{
+    return ((TEnv&)env).GetValue(prefix+fName+"."+postfix, dflt);
+}
+
+const char *MParContainer::GetEnvValue(const TEnv &env, TString prefix, TString postfix, const char *dflt) const
+{
+    return ((TEnv&)env).GetValue(prefix+fName+"."+postfix, dflt);
+}
Index: /trunk/MagicSoft/Mars/mbase/MParContainer.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 1880)
@@ -23,4 +23,5 @@
 class ifstream;
 
+class TEnv;
 class TDataMember;
 class TMethodCall;
@@ -56,5 +57,9 @@
     virtual TObject    *Clone(const char *newname="") const;
     virtual Int_t       Compare(const TObject *obj) const;
-    virtual void        Copy(TObject &named);
+    virtual void        Copy(TObject &named)
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+const
+#endif
+        ;
     virtual void        FillBuffer(char *&buffer);
 
@@ -95,4 +100,17 @@
     virtual void SetNames(TObjArray &arr);
 
+    virtual Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
+    virtual Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
+
+    Bool_t ReadEnv(const TEnv &env, Bool_t print=kFALSE) { return ReadEnv(env, "", print); }
+    Bool_t WriteEnv(TEnv &env, Bool_t print=kFALSE) const { return WriteEnv(env, "", print); }
+
+    Bool_t IsEnvDefined(const TEnv &env, TString prefix, TString postfix, Bool_t print) const;
+    Bool_t IsEnvDefined(const TEnv &env, TString name, Bool_t print) const;
+
+    Int_t       GetEnvValue(const TEnv &env, TString prefix, TString postfix, Int_t dflt) const;
+    Double_t    GetEnvValue(const TEnv &env, TString prefix, TString postfix, Double_t dflt) const;
+    const char *GetEnvValue(const TEnv &env, TString prefix, TString postfix, const char *dflt) const;
+
     ClassDef(MParContainer, 0)  //The basis for all parameter containers
 };
Index: /trunk/MagicSoft/Mars/mbase/MParList.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 1880)
@@ -768,2 +768,73 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Read the contents/setup of a parameter container/task from a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MParList::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    MParContainer *cont = NULL;
+
+    TIter Next(fContainer);
+    while ((cont=(MParContainer*)Next()))
+        if (cont->ReadEnv(env, print)==kERROR)
+            return kERROR;
+
+    Next.Reset();
+    while ((cont=(MParContainer*)Next()))
+        if (cont->ReadEnv(env, prefix, print)==kERROR)
+            return kERROR;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Write the contents/setup of a parameter container/task to a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MParList::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
+{
+    MParContainer *cont = NULL;
+
+    TIter Next(fContainer);
+    while ((cont=(MParContainer*)Next()))
+        if (!cont->WriteEnv(env, prefix, print))
+            return kFALSE;
+    return kTRUE;
+}
Index: /trunk/MagicSoft/Mars/mbase/MParList.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MParList.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/mbase/MParList.h	(revision 1880)
@@ -90,4 +90,7 @@
     void SavePrimitive(ofstream &out, Option_t *o="");
 
+    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
+    Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
+
     ClassDef(MParList, 1) // list of parameter containers (MParContainer)
 };
Index: /trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1880)
@@ -643,2 +643,73 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Read the contents/setup of a parameter container/task from a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we should search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MTaskList::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    MParContainer *cont = NULL;
+
+    TIter Next(fTasks);
+    while ((cont=(MParContainer*)Next()))
+        if (cont->ReadEnv(env, print)==kERROR)
+            return kERROR;
+
+    Next.Reset();
+    while ((cont=(MParContainer*)Next()))
+        if (cont->ReadEnv(env, prefix, print)==kERROR)
+            return kERROR;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Write the contents/setup of a parameter container/task to a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we should search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MTaskList::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
+{
+    MParContainer *cont = NULL;
+
+    TIter Next(fTasks);
+    while ((cont=(MParContainer*)Next()))
+        if (!cont->WriteEnv(env, prefix, print))
+            return kFALSE;
+    return kTRUE;
+}
Index: /trunk/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/mbase/MTaskList.h	(revision 1880)
@@ -67,4 +67,7 @@
     void SetNames(TObjArray &arr);
 
+    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
+    Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
+
     ClassDef(MTaskList, 1) //collection of tasks to be performed in the eventloop
 };
Index: /trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.cc	(revision 1880)
@@ -96,8 +96,9 @@
 // Add this file as the last entry in the chain
 //
-void MCT1ReadAscii::AddFile(const char *txt)
+Int_t MCT1ReadAscii::AddFile(const char *txt, Int_t)
 {
     TNamed *name = new TNamed(txt, "");
     fFileNames->AddLast(name);
+    return 1;
 }
 
@@ -299,3 +300,2 @@
     return kTRUE;
 }
-
Index: /trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.h
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/mfileio/MCT1ReadAscii.h	(revision 1880)
@@ -30,5 +30,5 @@
     ~MCT1ReadAscii();
 
-    void AddFile(const char *fname);
+    Int_t AddFile(const char *fname, Int_t dummy=-1);
 
     Bool_t PreProcess(MParList *pList);
Index: /trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 1880)
@@ -119,5 +119,5 @@
 // Add this file as the last entry in the chain
 //
-void MCT1ReadPreProc::AddFile(const char *txt)
+Int_t MCT1ReadPreProc::AddFile(const char *txt, Int_t)
 {
     const char *name = gSystem->ExpandPathName(txt);
@@ -129,5 +129,5 @@
     {
         *fLog << warn << "WARNING - Problem reading header... ignored." << endl;
-        return;
+        return 0;
     }
 
@@ -136,5 +136,5 @@
     {
         *fLog << warn << "WARNING - File contains no data... ignored." << endl;
-        return;
+        return 0;
     }
 
@@ -144,4 +144,5 @@
 
     fFileNames->AddLast(new TNamed(txt, ""));
+    return 1;
 }
 
Index: /trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h	(revision 1880)
@@ -77,5 +77,5 @@
     ~MCT1ReadPreProc();
 
-    void AddFile(const char *fname);
+    Int_t AddFile(const char *fname, Int_t dummy=-1);
 
     UInt_t GetEntries() { return fEntries; }
Index: /trunk/MagicSoft/Mars/mfileio/MRead.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MRead.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/mfileio/MRead.cc	(revision 1880)
@@ -39,2 +39,48 @@
 ClassImp(MRead);
 
+// --------------------------------------------------------------------------
+//
+// Read the setup from a TEnv:
+//   File0, File1, File2, ..., File10, ..., File100, ...
+//
+// Searching stops if the first key isn't found in the TEnv
+//
+// Enclosing quotation marks (") are removed
+//
+// Number of entries at the moment not supported
+//
+Bool_t MRead::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    //
+    // Don't allow 'global' setup of files
+    //
+    if (prefix.IsNull())
+        return kFALSE;
+
+    //
+    // Search (beginning with 0) all keys
+    //
+    for (int i=0;; i++)
+    {
+        TString idx = "File";
+        idx += i;
+
+        // Output if print set to kTRUE
+        IsEnvDefined(env, prefix, idx, print);
+
+        // Try to get the file name
+        TString name = GetEnvValue(env, prefix, idx, "");
+        if (name.IsNull())
+            return kTRUE;
+
+        if (name.BeginsWith("\"") && name.EndsWith("\""))
+        {
+            name.Remove(name.Last('\"'), 1);
+            name.Remove(name.First('\"'), 1);
+        }
+
+        AddFile(name);
+    }
+
+    return kTRUE;
+}
Index: /trunk/MagicSoft/Mars/mfileio/MRead.h
===================================================================
--- /trunk/MagicSoft/Mars/mfileio/MRead.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/mfileio/MRead.h	(revision 1880)
@@ -21,4 +21,8 @@
     MFilter *GetSelector() { return fSelector; }
 
+    Int_t AddFile(const char *fname, Int_t entries=-1) { return -1; }
+
+    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
+
     ClassDef(MRead, 0)	// Base class for a reading task
 };
Index: /trunk/MagicSoft/Mars/mgui/MHexagon.cc
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MHexagon.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/mgui/MHexagon.cc	(revision 1880)
@@ -92,4 +92,8 @@
 //
 void MHexagon::Copy(TObject &obj)
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+const
+#endif
+
 {
     MHexagon &hex = (MHexagon&) obj;
Index: /trunk/MagicSoft/Mars/mgui/MHexagon.h
===================================================================
--- /trunk/MagicSoft/Mars/mgui/MHexagon.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/mgui/MHexagon.h	(revision 1880)
@@ -44,5 +44,9 @@
     virtual ~MHexagon();
 
-    virtual void  Copy(TObject &hexagon);
+    virtual void  Copy(TObject &hexagon)
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+const
+#endif
+        ;
 
     virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
Index: /trunk/MagicSoft/Mars/mhist/MH.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MH.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/mhist/MH.cc	(revision 1880)
@@ -59,4 +59,7 @@
 #include <TLegend.h>
 #include <TPaveStats.h>
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+#include <THLimitsFinder.h>
+#endif
 
 #include "MLog.h"
@@ -469,4 +472,7 @@
 void MH::FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger)
 {
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+    THLimitsFinder::OptimizeLimits(nbins, newbins, xmin, xmax, isInteger);
+#else
 //*-*-*-*-*-*-*-*-*Find reasonable bin values*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
 //*-*              ==========================
@@ -486,13 +492,5 @@
     Double_t binwidth=0;
 
-#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,01)
     TGaxis::Optimize(umin, umax, nbins, binlow, binhigh, nbins, binwidth, "");
-#else
-    gLog << all << "*********************************************************" << endl;
-    gLog << all << "ERROR, because Abelardo removed TGaxis::Optimize from" << endl;
-    gLog << all << " MH::FindGoodLimits to be able to compile Mars with newer" << endl;
-    gLog << all << " root versions, whatever you are trying to do will fail!!!" << endl;
-    gLog << all << "*********************************************************" << endl;
-#endif
 
     if (binwidth <= 0 || binwidth > 1.e+39)
@@ -532,4 +530,5 @@
 
     newbins = nbins;
+#endif
 }
 
Index: /trunk/MagicSoft/Mars/mhist/MHRanForest.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHRanForest.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/mhist/MHRanForest.cc	(revision 1880)
@@ -114,5 +114,5 @@
 
     Int_t ntrees=fRanForest->GetNumTrees();
-    //cout<<"filling"<<endl;
+
     for (Int_t i=0;i<ntrees;i++)
     {
@@ -120,5 +120,5 @@
             hest+=fRanForest->GetTreeHad(j);
 
-        hest/=Double_t(i+1);
+        hest/=i+1;
         fSigma[i]+=(htrue-hest)*(htrue-hest);
     }
@@ -177,7 +177,8 @@
         g.GetXaxis()->SetTitle("Number of Trees");
         g.GetYaxis()->SetTitle("Standard deviation of estimated hadronness");
-        g.SetMarkerStyle(kFullDotlarge);
-        g.Draw("P");
-
+        g.SetMarkerStyle(kFullDotMedium);
+        gPad->Modified();
+        gPad->Update();
+        //g.Draw("P");
     }
     gPad->SetGrid();
@@ -209,5 +210,5 @@
 
         fGraphSigma->SetMarkerStyle(kFullDotSmall);
-        fGraphSigma->Draw("P");
+        //fGraphSigma->Draw("P");
         gPad->Modified();
         gPad->Update();
Index: /trunk/MagicSoft/Mars/mhist/MHRanForest.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHRanForest.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/mhist/MHRanForest.h	(revision 1880)
Index: /trunk/MagicSoft/Mars/mhist/MHRanForestGini.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHRanForestGini.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/mhist/MHRanForestGini.cc	(revision 1880)
@@ -121,10 +121,13 @@
     for (Int_t i=0; i<n; i++)
     {
+        fGini[i]/=fRanForest->GetNumTrees();
+        fGini[i]/=fRanForest->GetNumData();
+
         Stat_t ip = i+1.;
-        fGini[i]/=Stat_t(fRanForest->GetNumTrees());
-        fGini[i]/=Stat_t(fRanForest->GetNumData());
         Stat_t ig = fGini[i];
+
         max=TMath::Max(max,ig);
         min=TMath::Min(min,ig);
+
         fGraphGini->SetPoint(i,ip,ig);
     }
@@ -157,7 +160,8 @@
         g.GetXaxis()->SetTitle("No. of RF-input parameter");
         g.GetYaxis()->SetTitle("Mean decrease in Gini-index [a.u.]");
-        g.SetMarkerStyle(kFullDotlarge);
-        g.Draw("P");
-
+        g.SetMarkerStyle(kFullDotMedium);
+        //g.Draw("P");
+        gPad->Modified();
+        gPad->Update();
     }
     gPad->SetGrid();
@@ -189,5 +193,5 @@
 
         fGraphGini->SetMarkerStyle(kFullDotSmall);
-        fGraphGini->Draw("P");
+        //fGraphGini->Draw("P");
         gPad->Modified();
         gPad->Update();
Index: /trunk/MagicSoft/Mars/mhist/MHRanForestGini.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHRanForestGini.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/mhist/MHRanForestGini.h	(revision 1880)
@@ -19,8 +19,8 @@
 {
 private:
-    MRanForest *fRanForest;
+    MRanForest *fRanForest;  //!
 
-    TArrayF fGini;
-    TGraph *fGraphGini;
+    TArrayF fGini;           //!
+    TGraph *fGraphGini;      //->
 
 public:
Index: /trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 1879)
+++ /trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 1880)
@@ -16,8 +16,8 @@
 !
 !
-!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
 !   Author(s): Harald Kornmayer 1/2001
 !
-!   Copyright: MAGIC Software Development, 2000-2001
+!   Copyright: MAGIC Software Development, 2000-2003
 !
 !   Modified 4/7/2002 Abelardo Moralejo: now the dimension of fTrigger is
@@ -27,5 +27,4 @@
 !
 \* ======================================================================== */
-
 #include "MMcTriggerRateCalc.h"
 
@@ -105,22 +104,24 @@
     if (fMcRunHeader->GetAllEvtsTriggered())
       {
-	*fLog << endl << all << endl <<
-	  "WARNING: the input data file contains only the" << endl << 
-	  "events that triggered. I will assume the standard value" << endl <<
-	  "for maximum impact parameter (400 m)" <<endl;
-
-
-	if (fTrigNSB[0] > 0)
-	  *fLog << endl << all <<
-	    "WARNING: NSB rate can be overestimated by up to 5%." << endl <<
-	    "For a precise estimate of the total rate including NSB" << endl << 
-	    "accidental triggers I need a file containing all event headers." 
-		<< endl;
-	else 
-	  *fLog << endl << all <<
-	    "WARNING: calculating only shower rate (no NSB accidental triggers)" << endl;
+          *fLog << warn;
+          *fLog << "WARNING - the input data file contains only the" << endl;
+          *fLog << "events that triggered. I will assume the standard value" << endl;
+          *fLog << "for maximum impact parameter (400 m)" <<endl;
+
+
+          if (fTrigNSB[0] > 0)
+          {
+              *fLog << warn;
+              *fLog << "WARNING - NSB rate can be overestimated by up to 5%." << endl;
+              *fLog << "For a precise estimate of the total rate including NSB" << endl;
+              *fLog << "accidental triggers I need a file containing all event headers." << endl;
+          }
+          else
+          {
+            *fLog << warn << "WARNING - calculating only shower rate (no NSB accidental triggers)" << endl;
+          }
       }
 
-    *fLog << endl << all <<
+    *fLog << endl << warn <<
       "WARNING: I will assume the standard maximum off axis angle" << endl <<
       "(5 degrees) for the original showers" << endl;
@@ -168,5 +169,4 @@
 //      rate:    rate of incident showers
 //
-
 MMcTriggerRateCalc::MMcTriggerRateCalc(float rate, int dim,
                                        float *trigbg, float simbg,
@@ -325,9 +325,9 @@
 	  if (fMcCorRunHeader->GetSlopeSpec() != -2.75)
 	    {
-	      *fLog << err << dbginf <<
-		"Spectrum slope as read from  input file ("<< 
-		fMcCorRunHeader->GetSlopeSpec() << ") does not match the expected one (-2.75) for protons" << endl << "... aborting." << endl;
-	      return kFALSE;
-	    }
+                *fLog << err << dbginf << "Spectrum slope as read from input file (";
+                *fLog << fMcCorRunHeader->GetSlopeSpec() << ") does not match the expected ";
+                *fLog << "one (-2.75) for protons" << endl << "... aborting." << endl;
+                return kFALSE;
+            }
 	  rate.SetFlux(0.1091, 2.75);
 	  break;
@@ -335,8 +335,8 @@
 	  if (fMcCorRunHeader->GetSlopeSpec() != -2.62)
 	    {
-	      *fLog << err << dbginf <<
-		"Spectrum slope as read from  input file ("<< 
-		fMcCorRunHeader->GetSlopeSpec() << ") does not match the expected one (-2.75) for Helium" << endl << "... aborting." << endl;
-	      return kFALSE;
+                *fLog << err << dbginf << "Spectrum slope as read from input file (";
+                *fLog << fMcCorRunHeader->GetSlopeSpec() << ") does not match the expected ";
+                *fLog << "one (-2.75) for Helium" << endl << "... aborting." << endl;
+                return kFALSE;
 	    }
 	  rate.SetFlux(0.0660, 2.62);
@@ -363,9 +363,15 @@
 void MMcTriggerRateCalc::Draw()
 {
+    /*
+     Commented out, because this is creating a memory leak!
+     The histograms are neither deleted anywhere, nor it is made
+     sure, that the histograms are not overwritten.
+     Also the comment for the function doesn't match the rules.
+
   TCanvas *c = MH::MakeDefCanvas("Rate");
 
   Float_t xmin = GetRate(0)->GetMeanThreshold()-0.55;
   Float_t xmax = GetRate(fNum-1)->GetMeanThreshold()+0.55;
-  Int_t  nbins = 10*(xmax-xmin);
+  Int_t  nbins = (Int_t)((xmax-xmin)*10);
 
   fHist[1] = new TH1F("Rate2","Trigger rate, mult. 2", nbins, xmin, xmax);
@@ -412,6 +418,5 @@
   fHist[4]->Draw("same");
   fHist[4]->SetMarkerColor(4);
-
-  return;
-}
-
+     */
+}
+
Index: /trunk/MagicSoft/Mars/mtools/MagicReversi.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtools/MagicReversi.cc	(revision 1880)
+++ /trunk/MagicSoft/Mars/mtools/MagicReversi.cc	(revision 1880)
@@ -0,0 +1,630 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 03/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MagicReversi
+// ------------
+//
+// Camera Display Games: Reversi
+//
+// Start the game by:
+//   MagicReversi reversi;
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MagicReversi.h"
+
+#include <iostream.h>
+
+#include <TText.h>
+#include <TMarker.h>
+#include <TRandom.h>
+#include <TCanvas.h>
+#include <TClonesArray.h>
+#include <TInterpreter.h>
+
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h"
+
+ClassImp(MagicReversi);
+/*
+const Int_t MagicReversi::fColorBombs[7] = {
+    22,
+    kYellow,
+    kGreen,
+    kBlue,
+    kCyan,
+    kMagenta,
+    kRed
+};
+*/
+void MagicReversi::Free()
+{
+    if (!fGeomCam)
+        return;
+
+    fPixels->Delete();
+    fText->Delete();
+    fFlags->Delete();
+
+    delete fText;
+    delete fFlags;
+    delete fPixels;
+
+    delete fGeomCam;
+}
+
+void MagicReversi::ChangeCamera()
+{
+    static Bool_t ct1=kFALSE;
+
+    cout << "Change to " << (ct1?"Magic":"CT1") << endl;
+
+    if (ct1)
+        SetNewCamera(new MGeomCamMagic);
+    else
+        SetNewCamera(new MGeomCamCT1);
+
+    ct1 = !ct1;
+
+    Reset();
+    DrawHexagons();
+}
+
+void MagicReversi::SetNewCamera(MGeomCam *geom)
+{
+    Free();
+
+    //
+    //  Reset the display geometry
+    //
+    fW=0;
+    fH=0;
+
+    //
+    //  Set new camera
+    //
+    fGeomCam = geom;
+
+    //
+    //  create the hexagons of the display
+    //
+    fNumPixels = fGeomCam->GetNumPixels();
+    fRange     = fGeomCam->GetMaxRadius();
+
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
+//    fNumBombs = fNumPixels/5;
+
+    fText   = new TClonesArray("TText",    fNumPixels);
+    fFlags  = new TClonesArray("TMarker",  fNumPixels);
+    fPixels = new TClonesArray("MHexagon", fNumPixels);
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        h.SetBit(kNoContextMenu|kCannotPick);
+#endif
+
+        TText &t = *new ((*fText)[i]) TText;
+        t.SetTextFont(122);
+        t.SetTextAlign(22);   // centered/centered
+        t.SetTextSize(0.3*h.GetD()/fRange);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        t.SetBit(kNoContextMenu|kCannotPick);
+#endif
+
+        const MGeomPix &pix = (*fGeomCam)[i];
+
+        TMarker &m = *new ((*fFlags)[i]) TMarker(pix.GetX(), pix.GetY(), kOpenStar);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        m.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw all pixels of the camera
+//  (means apend all pixelobjects to the current pad)
+//
+void MagicReversi::DrawHexagons()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MagicReversi::MagicReversi()
+    : fGeomCam(NULL), fDone(NULL), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
+{
+    SetNewCamera(new MGeomCamCT1);
+
+    //
+    // Make sure, that the object is destroyed when the canvas/pad is
+    // destroyed. Make also sure, that the interpreter doesn't try to
+    // delete it a second time.
+    //
+    SetBit(kCanDelete);
+    gInterpreter->DeleteGlobal(this);
+
+    Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MagicReversi::~MagicReversi()
+{
+    Free();
+
+    for (int i=0; i<6; i++)
+        delete fUsrTxt[i];
+
+    if (fDone)
+        delete fDone;
+
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// This is called at any time the canvas should get repainted.
+// Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
+// that the camera image doesn't get distorted by resizing the canvas.
+//
+void MagicReversi::Paint(Option_t *opt)
+{
+    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
+    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
+
+    //
+    // Check for a change in width or height, and make sure, that the
+    // first call also sets the range
+    //
+    if (w*fH == h*fW && fW && fH)
+        return;
+
+    //
+    // Calculate aspect ratio (5/4=1.25 recommended)
+    //
+    const Double_t ratio = (Double_t)w/h;
+
+    Float_t x;
+    Float_t y;
+
+    if (ratio>1.0)
+    {
+        x = fRange*(ratio*2-1);
+        y = fRange;
+    }
+    else
+    {
+        x = fRange;
+        y = fRange/ratio;
+    }
+
+    fH = h;
+    fW = w;
+
+    //
+    // Set new range
+    //
+    fDrawingPad->Range(-fRange, -y, x, y);
+
+    //
+    // Adopt absolute sized of markers to relative range
+    //
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        Float_t r = (*this)[i].GetD()*gPad->XtoAbsPixel(1)/325;
+        GetFlag(i)->SetMarkerSize(20.0*r/fRange);
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the camera layout into your canvas.
+// Setup a drawing canvas. Add this object and all child objects
+// (hexagons, etc) to the current pad. If no pad exists a new one is
+// created.
+//
+void MagicReversi::Draw(Option_t *option)
+{
+    // root 3.02:
+    // gPad->SetFixedAspectRatio()
+
+    if (fDrawingPad)
+        return;
+
+    //
+    // if no canvas is yet existing to draw into, create a new one
+    //
+    if (!gPad)
+    {
+        /*TCanvas *c =*/ new TCanvas("MagicReversi", "Magic Reversi", 0, 0, 800, 800);
+        //c->ToggleEventStatus();
+        fIsAllocated = kTRUE;
+    }
+    else
+        fIsAllocated = kFALSE;
+
+    fDrawingPad = gPad;
+    fDrawingPad->SetBorderMode(0);
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    //
+    AppendPad(option);
+
+    //
+    // Draw the title text
+    //
+    for (int i=0; i<6; i++)
+    {
+        fUsrTxt[i] = new TText;
+        fUsrTxt[i]->SetTextAlign(13);       // left/bottom
+        fUsrTxt[i]->SetTextSize(0.03);
+        fUsrTxt[i]->SetTextColor(kRed+i);  
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        fUsrTxt[i]->SetBit(kNoContextMenu|kCannotPick);
+#endif
+        fUsrTxt[i]->Draw();
+    }
+
+    //
+    // Reset the game pad
+    //
+    Reset();
+    DrawHexagons();
+}
+
+void MagicReversi::Update()
+{
+    for (int i=0; i<fNumUsers; i++)
+    {
+        TString txt = "Pixels: ";
+        txt += fUsrPts[i];
+
+        if (fNumUser==i)
+            txt += " <*>";
+
+        fUsrTxt[i]->SetText(-fRange*0.95, fRange-(i+1)*fRange*0.06, txt);
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// reset the all pixel colors to a default value
+//
+void MagicReversi::Reset()
+{
+    if (fDone)
+    {
+        delete fDone;
+        fDone = NULL;
+    }
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        Remove(GetText(i));
+        Remove(GetFlag(i));
+
+        (*this)[i].SetFillColor(kEmpty);
+        (*fGeomCam)[i].ResetBit(kUserBits);
+
+        GetFlag(i)->SetMarkerColor(kBlack);
+    }
+
+    fNumUsers = 2; // not more than 6!
+    fNumUser  = 0;
+
+    for (int i=0; i<6; i++)
+        fUsrPts[i]=0;
+
+    for (int i=1; i<5*fNumUsers; i++)
+    {
+        (*this)[i-1].SetFillColor(i%fNumUsers+kRed);
+        fUsrPts[i%fNumUsers]++;
+    }
+
+    Update();
+
+    fDrawingPad->SetFillColor(22);
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDrawingPad->SetBit(kNoContextMenu);
+    SetBit(kNoContextMenu);
+#endif
+}
+
+void MagicReversi::Done()
+{
+    Int_t max = 0;
+    Int_t winner = 0;
+
+    for (int i=0; i<6; i++)
+        if (fUsrPts[i]>max)
+        {
+            winner = i;
+            max = fUsrPts[i];
+        }
+
+    TString txt = "Player #";
+    txt += winner;
+    txt += " wins (";
+    txt += max;
+    txt += ")";
+
+    fDone = new TText(0, 0, txt);
+    fDone->SetTextColor(kWhite);
+    fDone->SetTextAlign(22);  
+    fDone->SetTextSize(0.05); 
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDone->SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fDone->Draw();
+
+    fDrawingPad->SetFillColor(winner+kRed);
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDrawingPad->ResetBit(kNoContextMenu);
+    ResetBit(kNoContextMenu);
+#endif
+}
+
+void MagicReversi::Remove(TObject *obj)
+{
+    fDrawingPad->RecursiveRemove(obj);
+}
+
+Int_t MagicReversi::GetDirection(Int_t src, Int_t dst) const
+{
+    const MGeomPix &pix1=(*fGeomCam)[dst];
+    const MGeomPix &pix2=(*fGeomCam)[src];
+
+    const Double_t x1 = pix1.GetX();
+    const Double_t y1 = pix1.GetY();
+
+    const Double_t x2 = pix2.GetX();
+    const Double_t y2 = pix2.GetY();
+
+    if (x1>=x2 && y1>y2) return kRightTop;
+    if (x1>=x2 && y1<y2) return kRightBottom;
+    if (x1<=x2 && y1>y2) return kLeftTop;
+    if (x1<=x2 && y1<y2) return kLeftBottom;
+    if (x1>x2)           return kRight;
+    if (x1<x2)           return kLeft;
+
+    return -1;
+}
+
+Int_t MagicReversi::GetNeighbor(Int_t idx, Int_t dir) const
+{
+    MGeomPix &pix=(*fGeomCam)[idx];
+
+    //
+    // search for the neighbor in the given direction
+    //
+    int i;
+    for (i=0; i<pix.GetNumNeighbors(); i++)
+        if (GetDirection(idx, pix.GetNeighbor(i))==dir)
+            return pix.GetNeighbor(i);
+
+    return -1;
+}
+
+Bool_t MagicReversi::Flip(Int_t origidx, Bool_t flip)
+{
+    const Int_t col = kRed+fNumUser;
+
+    int test[6] = {0,0,0,0,0,0};
+
+    for (int dir=kRightTop; dir<=kLeftTop; dir++)
+    {
+        Int_t idx = origidx;
+        Int_t length = 0;
+
+        while (1)
+        {
+            idx = GetNeighbor(idx, dir);
+            if (idx<0 || (*this)[idx].GetFillColor()==kEmpty)
+                break;
+
+            if ((*this)[idx].GetFillColor()==col)
+            {
+                if (length!=0)
+                    test[dir] = length;
+                break;
+            }
+
+            length++;
+        }
+    }
+
+    int cnt = 0;
+
+    for (int dir=kRightTop; dir<=kLeftTop; dir++)
+    {
+        Int_t idx = origidx;
+
+        if (test[dir])
+            cnt++;
+
+        if (flip)
+            for (int i=0; i<test[dir]; i++)
+            {
+                idx = GetNeighbor(idx, dir);
+
+                fUsrPts[(*this)[idx].GetFillColor()-kRed]--;
+                fUsrPts[fNumUser]++;
+
+                (*this)[idx].SetFillColor(col);
+            }
+    }
+
+    return cnt ? kTRUE : kFALSE;
+}
+
+Bool_t MagicReversi::CheckMoves()
+{
+    for (unsigned int i=0; i<fNumPixels; i++)
+        if ((*this)[i].GetFillColor()==kEmpty && Flip(i, kFALSE))
+            return kTRUE;
+    return kFALSE;
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MagicReversi::ExecuteEvent(Int_t event, Int_t px, Int_t py)
+{
+    if (event==kMouseMotion   || event==kMouseEnter    || event==kMouseLeave    ||
+        event==kButton1Up     || event==kButton2Up     || event==kButton3Up     ||
+        event==kButton1Motion || event==kButton2Motion || event==kButton3Motion ||
+                                 event==kButton2Double || event==kButton3Double ||
+        fDone)
+        return;
+
+    UInt_t idx;
+    for (idx=0; idx<fNumPixels; idx++)
+        if ((*fPixels)[idx]->DistancetoPrimitive(px, py)==0)
+            break;
+
+    if (idx==fNumPixels)
+        return;
+
+    if (event==kButton1Down && (*this)[idx].GetFillColor()==kEmpty)
+    {
+        if (!Flip(idx, kTRUE))
+            return;
+
+        fUsrPts[fNumUser]++;
+
+        (*this)[idx].SetFillColor(kRed+fNumUser);
+
+        Int_t start = fNumUser;
+
+        fNumUser++;
+        fNumUser%=fNumUsers;
+
+        while (!CheckMoves())
+        {
+            cout << "Sorry, no moves possible!" << endl;
+            fNumUser++;
+            fNumUser%=fNumUsers;
+
+            if (fNumUser==start)
+                Done();
+        }
+
+        Update();
+    }
+
+    fDrawingPad->Modified();
+
+    /*
+    if (event==kKeyPress && py==0x1000)
+    {
+        Reset();
+        return;
+    }
+    */
+    /*
+    UInt_t idx;
+    for (idx=0; idx<fNumPixels; idx++)
+        if ((*fPixels)[idx]->DistancetoPrimitive(px, py)==0)
+            break;
+
+    if (idx==fNumPixels)
+        return;
+
+    MGeomPix &pix=(*fGeomCam)[idx];
+
+    if (event==kButton1Double)
+    {
+        OpenHexagon(idx);
+
+        if (pix.TestBit(kHasBomb))
+            Done("Argh... you hit the Bomb!!!", kRed);
+    }
+
+    if (event==kButton1Down && !pix.TestBit(kIsVisible))
+    {
+        if (pix.TestBit(kHasFlag))
+            Remove(GetFlag(idx));
+        else
+            GetFlag(idx)->Draw();
+
+        pix.InvertBit(kHasFlag);
+    }
+
+    UInt_t vis=fNumBombs;
+    UInt_t flg=fNumBombs;
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        if ((*fGeomCam)[i].TestBit(kIsVisible))
+            vis++;
+        if ((*fGeomCam)[i].TestBit(kHasFlag))
+            flg--;
+    }
+
+    Update(flg);
+
+    if (vis==fNumPixels && !fDone)
+        Done("Great! Congratulations, you did it!", kGreen);
+
+    fDrawingPad->Modified();
+      */
+    /*
+     switch (event)
+     {
+     case kNoEvent:       cout << "No Event" << endl; break;
+     case kButton1Down:   cout << "Button 1 down" << endl; break;
+     case kButton2Down:   cout << "Button 2 down" << endl; break;
+     case kButton3Down:   cout << "Button 3 down" << endl; break;
+     case kKeyDown:       cout << "Key down" << endl; break;
+     case kKeyUp:         cout << "Key up" << endl; break;
+     case kKeyPress:      cout << "Key press" << endl; break;
+     case kButton1Locate: cout << "Button 1 locate" << endl; break;
+     case kButton2Locate: cout << "Button 2 locate" << endl; break;
+     case kButton3Locate: cout << "Button 3 locate" << endl; break;
+    }
+    */
+}
Index: /trunk/MagicSoft/Mars/mtools/MagicReversi.h
===================================================================
--- /trunk/MagicSoft/Mars/mtools/MagicReversi.h	(revision 1880)
+++ /trunk/MagicSoft/Mars/mtools/MagicReversi.h	(revision 1880)
@@ -0,0 +1,93 @@
+#ifndef MARS_MagicReversi
+#define MARS_MagicReversi
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class TText;
+class TMarker;
+class TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+
+class MagicReversi : public TObject
+{
+private:
+    enum {
+        kRightTop,
+        kRight,
+        kRightBottom,
+        kLeftBottom,
+        kLeft,
+        kLeftTop
+    };
+//    static const Int_t fColorBombs[7]; // colors for the hexagons
+
+    MGeomCam      *fGeomCam;       // pointer to camera geometry
+
+    UInt_t         fNumPixels;     // number of pixels in the present geometry
+    Float_t        fRange;         // the range in millimeters of the present geometry
+
+    TClonesArray  *fPixels;        // array of all hexagons
+    TClonesArray  *fText;          // array of all texts
+    TClonesArray  *fFlags;         // array of all texts
+
+    TText         *fDone;          // TText showing the 'Game over'
+    TText         *fUsrTxt[6];     // TText showing the numbers of pixels and bombs
+
+    UInt_t         fW;             // Width of canvas
+    UInt_t         fH;             // Height of canvas
+    TVirtualPad   *fDrawingPad;    // pad in which we are drawing
+    Bool_t         fIsAllocated;
+
+    Int_t          fNumUsers;
+    Int_t          fNumUser;
+    Int_t          fUsrPts[6];
+
+    enum
+    {
+        kEmpty     = 50,
+        kIsVisible = BIT(16),
+        kHasBomb   = BIT(17),
+        kHasFlag   = BIT(18),
+        kUserBits  = 0x7fc000 // 14-23 are allowed
+    };
+
+    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+
+    TText   *GetText(Int_t i) { return (TText*)fText->At(i); }
+    TMarker *GetFlag(Int_t i) { return (TMarker*)fFlags->At(i); }
+
+    void  Remove(TObject *);
+    void  Done();
+    void  Update();
+    void  SetNewCamera(MGeomCam *);
+    void  DrawHexagons();
+    void  Free();
+
+    Bool_t Flip(Int_t idx, Bool_t flip);
+    Int_t  GetDirection(Int_t src, Int_t dst) const;
+    Int_t  GetNeighbor(Int_t idx, Int_t dir) const;
+    Bool_t CheckMoves();
+
+    void  Paint(Option_t *option="");
+    void  Draw(Option_t *option="");
+    void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
+    Int_t DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
+
+public:
+    MagicReversi();
+    ~MagicReversi();
+
+    void Reset();        //*MENU*
+    void ChangeCamera(); //*MENU*
+
+    ClassDef(MagicReversi, 0) // Magic Camera Games
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/mtools/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mtools/Makefile	(revision 1879)
+++ /trunk/MagicSoft/Mars/mtools/Makefile	(revision 1880)
@@ -29,4 +29,5 @@
 
 SRCFILES = MChisqEval.cc \
+	   MagicReversi.cc \
 	   MagicSnake.cc \
            MagicShow.cc \
Index: /trunk/MagicSoft/Mars/mtools/ToolsLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mtools/ToolsLinkDef.h	(revision 1879)
+++ /trunk/MagicSoft/Mars/mtools/ToolsLinkDef.h	(revision 1880)
@@ -7,5 +7,5 @@
 #pragma link C++ class MChisqEval+;
 #pragma link C++ class MineSweeper+;
-// #pragma link C++ class MagicReversi+;
+#pragma link C++ class MagicReversi+;
 #pragma link C++ class MagicSnake+;
 #pragma link C++ class MagicShow+;
