Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 1901)
+++ trunk/MagicSoft/Mars/Changelog	(revision 1902)
@@ -6,5 +6,15 @@
        floor() is unkown)
 
- 2003/04/02: Thomas Bretz
+
+
+ 2003/04/03: Thomas Bretz
+
+   * mbase/MEvtLopp.cc, mbase/MParContainer.[h,cc], 
+     mbase/MParList.cc, mbase/MTaskList.cc:
+     - changed the stuff for reading steering card - didn't really
+       work like expected
+
+   * mhist/MHMatrix.cc, mfileio/MRead.cc, manalysis/MImgCleanStd.cc:
+     - adapted ReadEnv
 
    * mhist/MHMatrix.[h,cc]:
@@ -22,4 +32,17 @@
      - added Clear
      - added Delete
+
+   * mbase/MEvtLoop.cc:
+     - added output of the name
+   
+   * mbase/MLog.[h,cc]:
+     - don't use any pthread stuff if _REENTRANT is not defined
+   
+   * mfileio/MRead.cc, mhist/MHMatrix.cc:
+     - fixed waring for unreachable statement
+   
+   * mhist/MHArray.cc:
+     - fixed: redifinition of default argument
+     
 
 
Index: trunk/MagicSoft/Mars/macros/testenv.C
===================================================================
--- trunk/MagicSoft/Mars/macros/testenv.C	(revision 1902)
+++ trunk/MagicSoft/Mars/macros/testenv.C	(revision 1902)
@@ -0,0 +1,79 @@
+void testenv()
+{
+    // Setup for all MHMatrix objects is done by:
+    // MHMatrix.Column0: ...
+    //
+    // This can be overwritten for a MHMatrix called MatrixGammas by:
+    // MatrixGammas.Column0;
+    //
+    // This can be overwritten for all MHMatrix in one Job by:
+    // Job1.MHMatrix.Column0;
+    //
+    // This can be overwritten for a MHMatrix called MatrixGammas in one Job by:
+    // Job1.MatrixGammas.Column0;
+    //
+    TEnv env(".marsrc");
+
+    //
+    // For developers: Set this to kTRUE to see how the TEnv file
+    // entries are checked.
+    //
+    Bool_t print = kFALSE;
+
+    // ------------ Job 1 -------------------
+    if (env.GetValue("Job1", kFALSE))
+    {
+        cout << "++++++++++++++++++ Job 1 +++++++++++++++++++" << endl;
+        MParList plist1;
+        MTaskList tlist1;
+
+        plist1.AddToList(&tlist1);
+
+        MReadMarsFile read1("Events");
+
+        MHMatrix matrix1("MatrixGammas");
+
+        MFillH fillm1(&matrix1);
+        plist1.AddToList(&matrix1);
+
+        tlist1.AddToList(&read1);
+        tlist1.AddToList(&fillm1);
+
+        MEvtLoop evtloop1("Job1");
+        evtloop1.SetParList(&plist1);
+        cout << "--------------------------------------------" << endl;
+        evtloop1.ReadEnv(env, "", print);
+        cout << "--------------------------------------------" << endl;
+        evtloop1.Eventloop();
+        cout << endl;
+    }
+
+    // ------------ Job 2 -------------------
+
+    if (env.GetValue("Job2", kTRUE))
+    {
+        cout << "++++++++++++++++++ Job 2 +++++++++++++++++++" << endl;
+        MParList plist2;
+        MTaskList tlist2;
+
+        plist2.AddToList(&tlist2);
+
+        MReadMarsFile read2("Events");
+
+        MHMatrix matrix2("MatrixGammas");
+
+        MFillH fillm2(&matrix2);
+        plist2.AddToList(&matrix2);
+
+        tlist2.AddToList(&read2);
+        tlist2.AddToList(&fillm2);
+
+        MEvtLoop evtloop2("Job2");
+        evtloop2.SetParList(&plist2);
+        cout << "--------------------------------------------" << endl;
+        evtloop2.ReadEnv(env, "", print);
+        cout << "--------------------------------------------" << endl;
+        evtloop2.Eventloop();
+        cout << endl;
+    }
+}
Index: trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 1901)
+++ trunk/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 1902)
@@ -701,6 +701,4 @@
         *fLog << warn << "WARNING - Second argument in MEvtLoop::ReadEnv has no meaning... ignored." << endl;
 
-    *fLog << "1: " << "'" << prefix << "'" << (int)print << endl;
-
     prefix = fName;
     prefix += ".";
Index: trunk/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 1901)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.cc	(revision 1902)
@@ -520,5 +520,5 @@
         postfix.Insert(0, ".");
 
-    return IsEnvDefined(env, prefix+fName+postfix, print);
+    return IsEnvDefined(env, prefix+postfix, print);
 }
 
@@ -543,14 +543,29 @@
 Int_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, TString postfix, Int_t dflt) const
 {
-    return ((TEnv&)env).GetValue(prefix+fName+"."+postfix, dflt);
+    return GetEnvValue(env, prefix+"."+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);
+    return GetEnvValue(env, prefix+"."+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);
-}
+    return GetEnvValue(env, prefix+"."+postfix, dflt);
+}
+
+Int_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, Int_t dflt) const
+{
+    return ((TEnv&)env).GetValue(prefix, dflt);
+}
+
+Double_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, Double_t dflt) const
+{
+    return ((TEnv&)env).GetValue(prefix, dflt);
+}
+
+const char *MParContainer::GetEnvValue(const TEnv &env, TString prefix, const char *dflt) const
+{
+    return ((TEnv&)env).GetValue(prefix, dflt);
+}
Index: trunk/MagicSoft/Mars/mbase/MParContainer.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 1901)
+++ trunk/MagicSoft/Mars/mbase/MParContainer.h	(revision 1902)
@@ -113,4 +113,8 @@
     const char *GetEnvValue(const TEnv &env, TString prefix, TString postfix, const char *dflt) const;
 
+    Int_t       GetEnvValue(const TEnv &env, TString prefix, Int_t dflt) const;
+    Double_t    GetEnvValue(const TEnv &env, TString prefix, Double_t dflt) const;
+    const char *GetEnvValue(const TEnv &env, TString prefix, 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 1901)
+++ trunk/MagicSoft/Mars/mbase/MParList.cc	(revision 1902)
@@ -792,15 +792,55 @@
 Bool_t MParList::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
+    if (print)
+        *fLog << all << "MParList::ReadEnv: " << prefix << " (" << (int)print << ")" << endl;
+
     MParContainer *cont = NULL;
 
     TIter Next(fContainer);
     while ((cont=(MParContainer*)Next()))
-        if (cont->ReadEnv(env, print)==kERROR)
+    {
+        if (cont->InheritsFrom("MTaskList"))
+        {
+            if (cont->ReadEnv(env, prefix, print)==kERROR)
+                return kERROR;
+            continue;
+        }
+
+        // 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)
             return kERROR;
-
-    Next.Reset();
-    while ((cont=(MParContainer*)Next()))
-        if (cont->ReadEnv(env, prefix, print)==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;
+    }
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1901)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1902)
@@ -667,15 +667,55 @@
 Bool_t MTaskList::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
+    if (print)
+        *fLog << all << "MTaskList::ReadEnv: " << prefix << " (" << (int)print << ")" << endl;
+
     MParContainer *cont = NULL;
 
     TIter Next(fTasks);
     while ((cont=(MParContainer*)Next()))
-        if (cont->ReadEnv(env, print)==kERROR)
+    {
+        if (cont->InheritsFrom("MTaskList"))
+        {
+            if (cont->ReadEnv(env, prefix, print)==kERROR)
+                return kERROR;
+            continue;
+        }
+
+        // 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)
             return kERROR;
-
-    Next.Reset();
-    while ((cont=(MParContainer*)Next()))
-        if (cont->ReadEnv(env, prefix, print)==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;
+    }
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mfileio/MRead.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MRead.cc	(revision 1901)
+++ trunk/MagicSoft/Mars/mfileio/MRead.cc	(revision 1902)
@@ -56,13 +56,8 @@
 {
     //
-    // Don't allow 'global' setup of files
-    //
-    if (prefix.IsNull())
-        return kFALSE;
-
-    //
     // Search (beginning with 0) all keys
     //
-    for (int i=0;; i++)
+    int i=0;
+    while (1)
     {
         TString idx = "File";
@@ -70,10 +65,14 @@
 
         // Output if print set to kTRUE
-        IsEnvDefined(env, prefix, idx, print);
+        if (!IsEnvDefined(env, prefix, idx, print))
+            break;
 
         // Try to get the file name
         TString name = GetEnvValue(env, prefix, idx, "");
         if (name.IsNull())
-            break;
+        {
+            *fLog << warn << prefix+"."+idx << " empty." << endl;
+            continue;
+        }
 
         if (name.BeginsWith("\"") && name.EndsWith("\""))
@@ -83,9 +82,10 @@
         }
 
-        if (print)
-            *fLog << all << "Add File: " << name << endl;
+        *fLog << inf << "Add File: " << name << endl;
+
         AddFile(name);
+        i++;
     }
 
-    return kTRUE;
+    return i!=0;
 }
Index: trunk/MagicSoft/Mars/mhist/MHMatrix.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHMatrix.cc	(revision 1901)
+++ trunk/MagicSoft/Mars/mhist/MHMatrix.cc	(revision 1902)
@@ -1027,19 +1027,9 @@
     }
 
-    if (fData)
-    {
-        *fLog << inf << "Removing all existing columns in " << GetDescriptor() << endl;
-        fData->Delete();
-    }
-    else
-    {
-        fData = new MDataArray;
-        SetBit(kIsOwner);
-    }
-
     //
     // Search (beginning with 0) all keys
     //
-    for (int i=0;; i++)
+    int i=0;
+    while (1)
     {
         TString idx = "Column";
@@ -1047,16 +1037,31 @@
 
         // Output if print set to kTRUE
-        IsEnvDefined(env, prefix, idx, print);
+        if (!IsEnvDefined(env, prefix, idx, print))
+            break;
 
         // Try to get the file name
         TString name = GetEnvValue(env, prefix, idx, "");
         if (name.IsNull())
-            break;
-
-        if (print)
-            *fLog << all << "Add Column: " << name << endl;
+        {
+            *fLog << warn << prefix+"."+idx << " empty." << endl;
+            continue;
+        }
+
+        if (i==0)
+            if (fData)
+            {
+                *fLog << inf << "Removing all existing columns in " << GetDescriptor() << endl;
+                fData->Delete();
+            }
+            else
+            {
+                fData = new MDataArray;
+                SetBit(kIsOwner);
+            }
+
         fData->AddEntry(name);
-    }
-
-    return kTRUE;
-}
+        i++;
+    }
+
+    return i!=0;
+}
