Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 5689)
+++ trunk/MagicSoft/Mars/Changelog	(revision 5690)
@@ -22,17 +22,60 @@
 
 
+ 2004/12/27 Thomas Bretz
+
+   * macros/CCDataCheck.C:
+     - fixed some warnings: Wrong data access operator
+
+   * manalysis/MCerPhotPix.h:
+     - added to possibility to reset the core-flag
+
+   * mcalib/MCalibColorSet.[h,cc]:
+     - moved some common code to a new function CheckAndSet for
+       simplicity of the color decoding
+     - added an include for stdlib.h (needed for some compilers and atoi)
+
+   * mcalib/MCalibrationIntensityChargeCam.cc:
+     - fixed a warning about a invalid escape sequence -- seems that
+       not all compilers do display this warning...
+     - corrected order of includes
+
+   * mfbase/MFEventSelector2.[h,cc]:
+     - some cosmetic fixes
+     - some adpations to standard output (eg. Separator() instead of ***)
+     - added a check whether 'filter' inherits from MFilter
+     - fixed the return of ReadDistribution
+     - made comments for data members in cleass header 'one line'
+
+   * mimage/MImgCleanStd.[h,cc]:
+     - added fNameGeomCam for parameter list access
+     - added fNameCerPhotEvt for parameter list access
+     - fixed a typo in an output
+     - NO change to ANY algorithm!
+     - changed class version from 1 to 2
+
+   * mjobs/MJCalibrateSignal.cc:
+     - added a rule to replace .raw by .root in MWriteRootFile
+
+   * mranforest/MRanForestCalc.[h,cc]:
+     - fixed missing data member initialization in constructor
+     - added ReadEnv which is able to read a random forest from a file
+     - added an owner flag for the random forest tree
+
+
+
  2004/12/22 Markus Gaug
 
-    * mraw/MRawEvtHeader.[h,cc]
+    * mraw/MRawEvtHeader.[h,cc]:
       - added some new Getter-functions for the calibration conf. 
         pattern
-    * mcalib/MCalibrationChargeCalc.[h,cc]
-    * mcalib/MCalibrationRelTimeCalc.[h,cc]
-    * mcalib/MCalibrationColorSteer.cc
+ 
+    * mcalib/MCalibrationChargeCalc.[h,cc],
+      mcalib/MCalibrationRelTimeCalc.[h,cc],
+      mcalib/MCalibrationColorSteer.cc:
       - use the new functions
 
-    * mhcalib/MHCalibrationCam.[h,cc]
-    * mhcalib/MHCalibrationRelTimeCam.[h,cc]
-    * mhcalib/MHCalibrationChargeCam.[h,cc]
+    * mhcalib/MHCalibrationCam.[h,cc],
+      mhcalib/MHCalibrationRelTimeCam.[h,cc],
+      mhcalib/MHCalibrationChargeCam.[h,cc]:
       - centralize the decision about the probability limit to be 
         taken inside these classes.
@@ -41,4 +84,5 @@
       - fix a bug in the calculation of outliers. Standard analyses  
         not affected!
+
 
 
@@ -91,4 +135,5 @@
 
 
+
  2004/12/22: Eva Domingo (for Wolfgang Wittek)
 
@@ -102,4 +147,5 @@
 
 
+
  2004/12/22: Abelardo Moralejo
 
@@ -112,4 +158,5 @@
 
 
+
  2004/12/17: Markus Gaug
 
@@ -117,9 +164,12 @@
      - added missing runs where run number does not appear any more in 
        project-name and is not yet set in the digital modules.
-   * mcalib/MCalibrationIntensityCam.[h,cc]
-   * mcalib/MCalibrationIntensityChargeCam.[h,cc]
-   * mcalib/MCalibrationIntensityRelTimeCam.[h,cc]
+
+   * mcalib/MCalibrationIntensityCam.[h,cc],
+     mcalib/MCalibrationIntensityChargeCam.[h,cc],
+     mcalib/MCalibrationIntensityRelTimeCam.[h,cc]:
      - added some new functions to display the results of the intensity
        calibration
+
+
 
  2004/12/17: Thomas Bretz
Index: trunk/MagicSoft/Mars/macros/CCDataCheck.C
===================================================================
--- trunk/MagicSoft/Mars/macros/CCDataCheck.C	(revision 5689)
+++ trunk/MagicSoft/Mars/macros/CCDataCheck.C	(revision 5690)
@@ -509,8 +509,10 @@
   // Drive report (pointing.C from T. Bretz)
   //
+  TCanvas *c1;
   if ((d = evtloop.GetDisplay()))
-    TCanvas &c1 = d.AddTab("DRIVE SYSTEM");
+      c1 = &d->AddTab("DRIVE SYSTEM");
   else
-    TCanvas *c1 = new TCanvas();
+      c1 = new TCanvas();
+
   // ************* Plot the telescope tracking positions on the sky ***********
   TGraph *g1 = hZd.GetGraph();
@@ -563,18 +565,18 @@
   gStyle->SetStatFormat(".2g");
   mh3 = (MH3*)hError.DrawClone("nonew");
-  mh3->GetHist()->SetXTitle("\\Delta [arcmin]");
-  mh3->GetHist()->SetYTitle("");
-  mh3->GetHist()->SetTitle("Control deviation of the motors");
-  mh3->GetHist()->SetStats(1);
-  mh3->GetHist()->SetLabelSize(0.06,"X");
-  mh3->GetHist()->SetLabelSize(0.06,"Y");
-  mh3->GetHist()->SetTitleSize(0.06,"X");
+  mh3->GetHist().SetXTitle("\\Delta [arcmin]");
+  mh3->GetHist().SetYTitle("");
+  mh3->GetHist().SetTitle("Control deviation of the motors");
+  mh3->GetHist().SetStats(1);
+  mh3->GetHist().SetLabelSize(0.06,"X");
+  mh3->GetHist().SetLabelSize(0.06,"Y");
+  mh3->GetHist().SetTitleSize(0.06,"X");
   TLine ln;
   ln.SetLineColor(kGreen);
-  ln.DrawLine(0.5*360*60/16384., 0, 0.5*360*60/16384., hError.GetHist()->GetMaximum());
+  ln.DrawLine(0.5*360*60/16384., 0, 0.5*360*60/16384., hError.GetHist().GetMaximum());
   ln.SetLineColor(kYellow);
-  ln.DrawLine(1.0*360*60/16384., 0, 1.0*360*60/16384., hError.GetHist()->GetMaximum());
+  ln.DrawLine(1.0*360*60/16384., 0, 1.0*360*60/16384., hError.GetHist().GetMaximum());
   ln.SetLineColor(kRed);
-  ln.DrawLine(2.0*360*60/16384., 0, 2.0*360*60/16384., hError.GetHist()->GetMaximum());
+  ln.DrawLine(2.0*360*60/16384., 0, 2.0*360*60/16384., hError.GetHist().GetMaximum());
   // ---------------------- Plot the drive status vs time ---------------------
   c1->cd();
@@ -616,13 +618,13 @@
   gStyle->SetStatFormat(".2g");
   mh3 = (MH3*)hError2.DrawClone("nonew");
-  mh3->GetHist()->SetXTitle("Zd [\\circ]");
-  mh3->GetHist()->SetYTitle("\\Delta [arcmin]");
-  mh3->GetHist()->SetTitle("Control deviation of the motors");
-  mh3->GetHist()->SetLabelSize(0.06,"X");
-  mh3->GetHist()->SetLabelSize(0.06,"Y");
-  mh3->GetHist()->SetTitleSize(0.06,"X");
-  mh3->GetHist()->SetTitleSize(0.06,"Y");
-  mh3->GetHist()->SetStats(1);
-  mh3->GetHist()->Draw("box");
+  mh3->GetHist().SetXTitle("Zd [\\circ]");
+  mh3->GetHist().SetYTitle("\\Delta [arcmin]");
+  mh3->GetHist().SetTitle("Control deviation of the motors");
+  mh3->GetHist().SetLabelSize(0.06,"X");
+  mh3->GetHist().SetLabelSize(0.06,"Y");
+  mh3->GetHist().SetTitleSize(0.06,"X");
+  mh3->GetHist().SetTitleSize(0.06,"Y");
+  mh3->GetHist().SetStats(1);
+  mh3->GetHist().Draw("box");
   // -------------------------- Zenith angle vs time --------------------------
   c1->cd();
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h	(revision 5689)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h	(revision 5690)
@@ -42,5 +42,5 @@
     Short_t GetRing() const             { return fRing;}
 
-    void    SetPixelCore()              { fIsCore = kTRUE; }
+    void    SetPixelCore(Bool_t b=kTRUE){ fIsCore = b; }
     Bool_t  IsPixelCore() const         { return fIsCore;  }
 
Index: trunk/MagicSoft/Mars/mcalib/MCalibColorSet.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibColorSet.cc	(revision 5689)
+++ trunk/MagicSoft/Mars/mcalib/MCalibColorSet.cc	(revision 5690)
@@ -39,5 +39,7 @@
 #include "MCalibColorSet.h"
 
-#include "TRegexp.h"
+#include <stdlib.h>   // needed for atoi on some platforms
+
+#include <TRegexp.h>
 
 #include "MLog.h"
@@ -51,10 +53,10 @@
 ClassImp(MCalibColorSet);
 
-
 using namespace std;
 
-const Int_t MCalibColorSet::gkIFAEBoxInaugurationRun = 20113;
-const Int_t MCalibColorSet::gkMCRunLimit             = 1000;
-const UInt_t MCalibColorSet::gkFirstRunWithFinalBits = 45626;
+const Int_t  MCalibColorSet::gkIFAEBoxInaugurationRun = 20113;
+const Int_t  MCalibColorSet::gkMCRunLimit             = 1000;
+const UInt_t MCalibColorSet::gkFirstRunWithFinalBits  = 45626;
+
 // --------------------------------------------------------------------------
 //
@@ -95,4 +97,23 @@
 
   return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check if str contains regexp.
+// If so or pat to pattern and set color to col.
+// Otherwise do nothing.
+//
+// Normally this function is much to simple (more arguments than lines!)
+// but in this particular case it is worth to have it to avois chaotic
+// repitions of the same piece of code for many many times.
+//
+void MCalibColorSet::CheckAndSet(const TString &str, const char *regexp, UInt_t &pattern, UInt_t pat, Int_t &color, Int_t col) const
+{
+    if (!str.Contains(TRegexp(regexp)))
+        return;
+
+    pattern |= pat;
+    color = col;
 }
 
@@ -295,198 +316,129 @@
   
   if (color!=kNONE)
-    {
+  {
       *fLog << inf << "Color determined from the run-number... ";
       switch (color)
-        {
-        case kGREEN: *fLog << "Green."; fPattern |= k5LedGreen; break;
-        case kBLUE:  *fLog << "Blue.";  fPattern |= k5LedBlue1; break;
-        case kUV:    *fLog << "UV.";    fPattern |= k10LedUV; break;
-        }
+      {
+      case kGREEN: *fLog << "Green."; fPattern |= k5LedGreen; break;
+      case kBLUE:  *fLog << "Blue.";  fPattern |= k5LedBlue1; break;
+      case kUV:    *fLog << "UV.";    fPattern |= k10LedUV;   break;
+      }
       *fLog << endl;
       fIsValid  = kTRUE;
       return kTRUE;
-    }
-  else
-    {
-
-      TString proj = header->GetProjectName();
-      proj.ToLower();
-
-      // Possible green combinations
-      TRegexp gre0("0.1led[sS]?gree");
-      if (proj.Contains(gre0))
-        { fPattern |= k01LedGreen; color = kGREEN;    }
-      TRegexp gre1("1led[sS]?gree");
-      if (proj.Contains(gre1))
-        { fPattern |= k1LedGreen; color = kGREEN;    }
-      TRegexp gre2("2led[sS]?gree");
-      if (proj.Contains(gre2))
-        { fPattern |= k2LedGreen; color = kGREEN;    }
-      TRegexp gre3("3led[sS]?gree");
-      if (proj.Contains(gre3))
-        { fPattern |= k3LedGreen; color = kGREEN;    }
-      TRegexp gre5("5led[sS]?gree");
-      if (proj.Contains(gre5))
-        { fPattern |= k5LedGreen; color = kGREEN;    }
-      TRegexp gre6("6led[sS]?gree");
-      if (proj.Contains(gre6))
-        { fPattern |= k6LedGreen; color = kGREEN;    }
-      TRegexp gre7("7led[sS]?gree");
-      if (proj.Contains(gre7))
-        { fPattern |= k7LedGreen; color = kGREEN;    }
-      TRegexp gre8("8led[sS]?gree");
-      if (proj.Contains(gre8))
-        { fPattern |= k8LedGreen; color = kGREEN;    }
-
-      // Possible blue combinations
-      TRegexp blu0("0.1led[sS]?blue");
-      if (proj.Contains(blu0))
-        { fPattern |= k01LedBlue; color = kBLUE;    }
-      TRegexp blu1("1led[sS]?blue");
-      if (proj.Contains(blu1))
-        { fPattern |= k1LedBlue; color = kBLUE;    }
-      TRegexp blu2("2led[sS]?blue");
-      if (proj.Contains(blu2))
-        { fPattern |= k2LedBlue; color = kBLUE;    }
-      TRegexp blu3("3led[sS]?blue");
-      if (proj.Contains(blu3))
-        { fPattern |= k3LedBlue; color = kBLUE;    }
-      TRegexp blu5("5led[sS]?blue");
-      if (proj.Contains(blu5))
-        { fPattern |= k5LedBlue1; color = kBLUE;    }
-      TRegexp blu6("6led[sS]?blue");
-      if (proj.Contains(blu6))
-        { fPattern |= k6LedBlue; color = kBLUE;    }
-      TRegexp blu7("7led[sS]?blue");
-      if (proj.Contains(blu7))
-        { fPattern |= k7LedBlue; color = kBLUE;    }
-      TRegexp blu8("8led[sS]?blue");
-      if (proj.Contains(blu8))
-        { fPattern |= k8LedBlue; color = kBLUE;    }
-      TRegexp blu10("10led[sS]?blue");
-      if (proj.Contains(blu10))
-        { fPattern |= k10LedBlue; color = kBLUE;    }
-      TRegexp blu15("15led[sS]?blue");
-      if (proj.Contains(blu15))
-        { fPattern |= k15LedBlue; color = kBLUE;    }
-      TRegexp blu20("20led[sS]?blue");
-      if (proj.Contains(blu20))
-        { fPattern |= k20LedBlue; color = kBLUE;    }
-      TRegexp blu21("21led[sS]?blue");
-      if (proj.Contains(blu21))
-        { fPattern |= k21LedBlue; color = kBLUE;    }
-      TRegexp blu22("22led[sS]?blue");
-      if (proj.Contains(blu22))
-        { fPattern |= k22LedBlue; color = kBLUE;    }
-      TRegexp blu23("23led[sS]?blue");
-      if (proj.Contains(blu23))
-        { fPattern |= k23LedBlue; color = kBLUE;    }
-
-      // Possible UV combinations
-      TRegexp uv1("1led[sS]?uv");
-      if (proj.Contains(uv1))
-        { fPattern |= k1LedUV; color = kUV;    }
-      TRegexp uv2("2led[sS]?uv");
-      if (proj.Contains(uv2))
-        { fPattern |= k2LedUV; color = kUV;    }
-      TRegexp uv3("3led[sS]?uv");
-      if (proj.Contains(uv3))
-        { fPattern |= k3LedUV; color = kUV;    }
-      TRegexp uv5("5led[sS]?uv");
-      if (proj.Contains(uv5))
-        { fPattern |= k5LedUV1; color = kUV;    }
-      TRegexp uv6("6led[sS]?uv");
-      if (proj.Contains(uv6))
-        { fPattern |= k6LedUV; color = kUV;    }
-      TRegexp uv7("7led[sS]?uv");
-      if (proj.Contains(uv7))
-        { fPattern |= k7LedUV; color = kUV;    }
-      TRegexp uv8("8led[sS]?uv");
-      if (proj.Contains(uv8))
-        { fPattern |= k8LedUV; color = kUV;    }
-      TRegexp uv10("10led[sS]?uv");
-      if (proj.Contains(uv10))
-        { fPattern |= k10LedUV; color = kUV;    }
-      TRegexp uv11("11led[sS]?uv");
-      if (proj.Contains(uv11))
-        { fPattern |= k11LedUV; color = kUV;    }
-      TRegexp uv12("12led[sS]?uv");
-      if (proj.Contains(uv12))
-        { fPattern |= k12LedUV; color = kUV;    }
-      TRegexp uv13("13led[sS]?uv");
-      if (proj.Contains(uv13))
-        { fPattern |= k13LedUV; color = kUV;    }
-
-      // Possible slot combinations
-      TRegexp slot("slot");
-      if (proj.Contains(slot))
-        {
-          proj.ReplaceAll("slot","");
-          UInt_t nr = 0;
-          TRegexp slotnr("^[0-9]");
-          
-          if (proj.Contains(slotnr))
-            { fPattern = 0; proj.Replace(2,99,""); 
-            proj.ReplaceAll("u","");
-            proj.ReplaceAll("v","");
-            proj.ReplaceAll("g","");
-            nr = atoi(proj.Data())-1; 
-            fPattern |= BIT(nr);
-            color = nr < 2 ? kGREEN : 
-              ( nr < 3 ) ? kBLUE : 
-              ( nr < 5 ) ? kUV : 
-              ( nr < 11 ) ? kBLUE : 
-              ( nr < 13 ) ? kUV : 
-              ( nr < 14 ) ? kBLUE : 
-              ( nr < 16 ) ? kGREEN : 
-              kCT1;    
-            }
-        }
-      
+  }
+
+  TString proj = header->GetProjectName();
+  proj.ToLower();
+
+  // Possible green combinations
+  CheckAndSet(proj, "0.1led[sS]?gree", fPattern, k01LedGreen, color, kGREEN);
+  CheckAndSet(proj, "1led[sS]?gree",   fPattern, k1LedGreen,  color, kGREEN);
+  CheckAndSet(proj, "2led[sS]?gree",   fPattern, k2LedGreen,  color, kGREEN);
+  CheckAndSet(proj, "3led[sS]?gree",   fPattern, k3LedGreen,  color, kGREEN);
+  CheckAndSet(proj, "5led[sS]?gree",   fPattern, k5LedGreen,  color, kGREEN);
+  CheckAndSet(proj, "6led[sS]?gree",   fPattern, k6LedGreen,  color, kGREEN);
+  CheckAndSet(proj, "7led[sS]?gree",   fPattern, k7LedGreen,  color, kGREEN);
+  CheckAndSet(proj, "8led[sS]?gree",   fPattern, k8LedGreen,  color, kGREEN);
+
+  // Possible blue combinations
+  CheckAndSet(proj, "0.1led[sS]?blue", fPattern, k01LedBlue,  color, kBLUE);
+  CheckAndSet(proj, "1led[sS]?blue",   fPattern, k1LedBlue,   color, kBLUE);
+  CheckAndSet(proj, "2led[sS]?blue",   fPattern, k2LedBlue,   color, kBLUE);
+  CheckAndSet(proj, "3led[sS]?blue",   fPattern, k3LedBlue,   color, kBLUE);
+  CheckAndSet(proj, "5led[sS]?blue",   fPattern, k5LedBlue1,  color, kBLUE);
+  CheckAndSet(proj, "6led[sS]?blue",   fPattern, k6LedBlue,   color, kBLUE);
+  CheckAndSet(proj, "7led[sS]?blue",   fPattern, k7LedBlue,   color, kBLUE);
+  CheckAndSet(proj, "8led[sS]?blue",   fPattern, k8LedBlue,   color, kBLUE);
+  CheckAndSet(proj, "10led[sS]?blue",  fPattern, k10LedBlue,  color, kBLUE);
+  CheckAndSet(proj, "15led[sS]?blue",  fPattern, k15LedBlue,  color, kBLUE);
+  CheckAndSet(proj, "20led[sS]?blue",  fPattern, k20LedBlue,  color, kBLUE);
+  CheckAndSet(proj, "21led[sS]?blue",  fPattern, k21LedBlue,  color, kBLUE);
+  CheckAndSet(proj, "22led[sS]?blue",  fPattern, k22LedBlue,  color, kBLUE);
+  CheckAndSet(proj, "23led[sS]?blue",  fPattern, k23LedBlue,  color, kBLUE);
+
+  // Possible UV combinations
+  CheckAndSet(proj, "1led[sS]?uv",     fPattern, k1LedUV,    color,  kUV);
+  CheckAndSet(proj, "2led[sS]?uv",     fPattern, k2LedUV,    color,  kUV);
+  CheckAndSet(proj, "3led[sS]?uv",     fPattern, k3LedUV,    color,  kUV);
+  CheckAndSet(proj, "5led[sS]?uv",     fPattern, k5LedUV1,   color,  kUV);
+  CheckAndSet(proj, "6led[sS]?uv",     fPattern, k6LedUV,    color,  kUV);
+  CheckAndSet(proj, "7led[sS]?uv",     fPattern, k7LedUV,    color,  kUV);
+  CheckAndSet(proj, "8led[sS]?uv",     fPattern, k8LedUV,    color,  kUV);
+  CheckAndSet(proj, "10led[sS]?uv",    fPattern, k10LedUV,   color,  kUV);
+  CheckAndSet(proj, "11led[sS]?uv",    fPattern, k11LedUV,   color,  kUV);
+  CheckAndSet(proj, "12led[sS]?uv",    fPattern, k12LedUV,   color,  kUV);
+  CheckAndSet(proj, "13led[sS]?uv",    fPattern, k13LedUV,   color,  kUV);
+
+  // Possible slot combinations
+  TRegexp slot("slot");
+  if (proj.Contains(slot))
+  {
+      proj.ReplaceAll("slot","");
+      UInt_t nr = 0;
+      TRegexp slotnr("^[0-9]");
+
+      if (proj.Contains(slotnr))
+      {
+          fPattern = 0;
+          proj.Replace(2,99,"");
+          proj.ReplaceAll("u","");
+          proj.ReplaceAll("v","");
+          proj.ReplaceAll("g","");
+          nr = atoi(proj.Data())-1;
+
+          fPattern |= BIT(nr);
+
+          color = nr < 2 ? kGREEN :
+              ( nr < 3 ) ? kBLUE :
+              ( nr < 5 ) ? kUV :
+              ( nr < 11 ) ? kBLUE :
+              ( nr < 13 ) ? kUV :
+              ( nr < 14 ) ? kBLUE :
+              ( nr < 16 ) ? kGREEN :
+              kCT1;
+      }
+  }
+
+  if (color == kNONE)
+  {
+      CheckAndSet(proj, "gree", fPattern, k5LedGreen, color, kGREEN);
+      CheckAndSet(proj, "blue", fPattern, k5LedBlue1, color, kBLUE);
+      CheckAndSet(proj, "uv",   fPattern, k5LedUV1,   color, kUV);
+      CheckAndSet(proj, "ct1",  fPattern, kCT1Pulser, color, kCT1);
+
       if (color != kNONE)
-        *fLog << inf << "Color and Intensity determined from project-name (" << proj << ")... ";          
+          *fLog << inf << "Color determined from project-name (" << proj << ")... ";
       else
-        {
-          if (proj.Contains("gree",TString::kIgnoreCase))
-            { fPattern |= k5LedGreen; color = kGREEN; }
-          if (proj.Contains("blue",TString::kIgnoreCase))
-            { fPattern |=k5LedBlue1; color = kBLUE;}
-          if (proj.Contains("uv",TString::kIgnoreCase))
-            { fPattern |=k5LedUV1  ; color = kUV;  }
-          if (proj.Contains("ct1",TString::kIgnoreCase))
-            { fPattern |=kCT1Pulser; color = kCT1; }
-          if (color != kNONE)
-            *fLog << inf << "Color determined from project-name (" << proj << ")... ";
-          else if (proj.Contains("cl",TString::kIgnoreCase))
-            {
-              *fLog << warn << "This run has been taken with the continuous light source." << endl;
-              *fLog << warn 
-                    << "It cannot be used for calibration. Try to run a pedestal extraction on it." << endl;
+          if (proj.Contains("cl",TString::kIgnoreCase))
+          {
+              *fLog << warn;
+              *fLog << "This run has been taken with the continuous light source." << endl;
+              *fLog << "It cannot be used for calibration. Try to run a pedestal extraction on it." << endl;
               fPattern = 0;
               fIsValid = kTRUE;
               return kTRUE;
-            }
-        }
-    }
-  
-  if (color==kNONE)
-    {
-      *fLog << err << "Sorry, calibration run " << num << " was taken before the events could be" << endl;
+          }
+
+      *fLog << err;
+      *fLog << "Sorry, calibration run " << num << " was taken before the events could be" << endl;
       *fLog << "flagged with a color by the digital modul and no color" << endl;
       *fLog << "could be determined... abort." << endl;
       return kFALSE;
-    }
-  
+  }
+
+  *fLog << inf << "Color and Intensity determined from project-name (" << proj << ")... ";
+
   switch (color)
-    {
-    case kGREEN: *fLog << "Green.";  break;
-    case kBLUE:  *fLog << "Blue.";   break;
-    case kUV:    *fLog << "UV.";     break;
-    case kCT1:   *fLog << "CT1.";    break;
-    }
+  {
+  case kGREEN: *fLog << "Green.";  break;
+  case kBLUE:  *fLog << "Blue.";   break;
+  case kUV:    *fLog << "UV.";     break;
+  case kCT1:   *fLog << "CT1.";    break;
+  }
   *fLog << endl;
-  
+
   fIsValid = kTRUE;
-  
+
   return kTRUE;
 }
Index: trunk/MagicSoft/Mars/mcalib/MCalibColorSet.h
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibColorSet.h	(revision 5689)
+++ trunk/MagicSoft/Mars/mcalib/MCalibColorSet.h	(revision 5690)
@@ -21,5 +21,7 @@
   UInt_t fPattern;                            //  Current pulse pattern
   Bool_t fIsValid;                            //  Have to set the pulse pattern?
-  
+
+  void CheckAndSet(const TString &str, const char *regexp, UInt_t &pattern, UInt_t pat, Int_t &color, Int_t col) const;
+
   Bool_t ReInit(MParList *pList);
   Int_t  PreProcess(MParList *pList);
Index: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.cc	(revision 5689)
+++ trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityChargeCam.cc	(revision 5690)
@@ -40,16 +40,17 @@
 /////////////////////////////////////////////////////////////////////////////
 #include "MCalibrationIntensityChargeCam.h"
+
+#include <TF1.h>
+#include <TH2.h>
+#include <TGraphErrors.h>
+#include <TOrdCollection.h>
+
+#include "MLog.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
 #include "MCalibrationChargeCam.h"
 #include "MCalibrationChargePix.h"
-
-#include "MGeomCam.h"
-#include "MGeomPix.h"
-
-#include "MLog.h"
-
-#include <TOrdCollection.h>
-#include <TGraphErrors.h>
-#include <TH2F.h>
-#include <TF1.h>
 
 ClassImp(MCalibrationIntensityChargeCam);
@@ -428,5 +429,5 @@
       const Float_t qe = pix.GetConvertedMeanErr();
       oneoverq   [i] = 1./q;
-      oneoverqerr[i] = qe / q / q;
+      oneoverqerr[i] = qe / (q * q);
     }
   
@@ -436,5 +437,5 @@
   gr->SetTitle(Form("%s%3i","Pixel ",pixid));
   gr->GetXaxis()->SetTitle("1/Q [FADC counts^{-1}]");
-  gr->GetYaxis()->SetTitle("\sigma_{red}^{2}/Q^{2} [1]");      
+  gr->GetYaxis()->SetTitle("\\sigma_{red}^{2}/Q^{2} [1]");
   return gr;
 }
Index: trunk/MagicSoft/Mars/mfbase/MFEventSelector2.cc
===================================================================
--- trunk/MagicSoft/Mars/mfbase/MFEventSelector2.cc	(revision 5689)
+++ trunk/MagicSoft/Mars/mfbase/MFEventSelector2.cc	(revision 5690)
@@ -116,5 +116,4 @@
 #include "MH3.h"            // MH3
 #include "MRead.h"          // MRead
-//#include "MProgressBar.h"   // 
 #include "MEvtLoop.h"       // MEvtLoop
 #include "MTaskList.h"      // MTaskList
@@ -158,16 +157,16 @@
 //     events outside these ranges won't be accepted).
 //
+//  Set default name of filter to be applied when determining the original
+//  distribution for all data on the input file to "FilterSelector2"
+//
 MFEventSelector2::MFEventSelector2(MH3 &hist, const char *name, const char *title)
-: fHistOrig(NULL), fHistNom(&hist), fHistRes(NULL),
-  fDataX(hist.GetRule('x')), fDataY(hist.GetRule('y')),
-  fDataZ(hist.GetRule('z')), fNumMax(-1), fHistIsProbability(kFALSE),
-  fUseOrigDist(kTRUE)
+    : fHistOrig(NULL), fHistNom(&hist), fHistRes(NULL),
+    fDataX(hist.GetRule('x')), fDataY(hist.GetRule('y')),
+    fDataZ(hist.GetRule('z')), fNumMax(-1), fCanvas(0),
+    fFilterName("FilterSelector2"), fHistIsProbability(kFALSE),
+    fUseOrigDist(kTRUE)
 {
     fName  = name  ? (TString)name  : gsDefName;
     fTitle = title ? (TString)title : gsDefTitle;
-
-    // name of filter to be applied when determining the original distribution
-    // for all data on the input file
-    fFilterName = "FilterSelector2";
 }
 
@@ -216,20 +215,13 @@
     }
 
-    *fLog << inf << underline << endl;
-    *fLog << "MFEventSelector2::ReadDistribution:" << endl;
-    *fLog << "**********************" << endl;
-    *fLog << " - Start of eventloop to generate the original distribution..." 
-          << endl;
+    *fLog << inf;
+    fLog->Separator("MFEventSelector2::ReadDistribution");
+    *fLog << " - Start of eventloop to generate the original distribution..." << endl;
 
     if (filter != NULL)
-    {
-      *fLog << "                      filter used : " << filter->GetName()
-            << endl;
-    }
+        *fLog << " - filter used: " << filter->GetDescriptor() << endl;
 
 
     MEvtLoop run("ReadDistribution");
-    //MProgressBar bar;
-    //run.SetProgressBar(&bar);
 
     MParList plist;
@@ -264,19 +256,15 @@
     if (!run.Eventloop())
     {
-        *fLog << err << dbginf 
-              << "Evtloop in MFEventSelector2::ReadDistribution failed." 
-              << endl;
-        return kFALSE;
-    }
-
-    tlist.PrintStatistics(0, kTRUE);
+        *fLog << err << dbginf << "Evtloop failed... abort." << endl;
+        return kFALSE;
+    }
+
+    tlist.PrintStatistics();
 
     *fLog << inf;
     *fLog << "MFEventSelector2::ReadDistribution:" << endl;
-    *fLog << " - Original distribution has " 
-          << fHistOrig->GetHist().GetEntries() << " entries." << endl;
-    *fLog << " - End of eventloop to generate the original distribution." 
-          << endl;
-    *fLog << "**********************" << endl;
+    *fLog << " - Original distribution has " << fHistOrig->GetHist().GetEntries() << " entries." << endl;
+    *fLog << " - End of eventloop to generate the original distribution." << endl;
+    fLog->Separator();
 
     return read.Rewind();
@@ -447,33 +435,28 @@
     if (!read)
     {
-        *fLog << err << "MRead not found... abort." << endl;
+        *fLog << err << "MRead not found in tasklist... abort." << endl;
         return kFALSE;
     }
 
     MFilter *filter = (MFilter*)tasklist->FindObject(fFilterName);
-    if (!filter)
-    {
-      *fLog << inf 
-            << "No filter will be used when making the original distribution"
-            << endl;
-      filter = NULL;
-    }
-
+    if (!filter || !filter->InheritsFrom(MFilter::Class()))
+    {
+        *fLog << inf << "No filter will be used when making the original distribution" << endl;
+        filter = NULL;
+    }
 
     if (!ReadDistribution(*read, filter))
         return kFALSE;
-
 
     // Prepare histograms and arrays for selection
     PrepareHistograms();
 
-    *fLog << "MFEventSelector2::PreProcess; call PreProcess() for read and filter object again"
-          << endl;
-    Int_t rcr = read->CallPreProcess(parlist);
-    Int_t rcf = filter->CallPreProcess(parlist);
-
-    *fLog << "rcr, rcf = " << rcr << ",  " << rcf << endl;
-
-    return rcf*rcr;
+    *fLog << all << "PreProcess..." << flush;
+    const Int_t rcf = filter->CallPreProcess(parlist);
+    if (rcf!=kTRUE)
+        return rcf;
+
+    const Int_t rcr = read->CallPreProcess(parlist);
+    return rcr;
 }
 
Index: trunk/MagicSoft/Mars/mfbase/MFEventSelector2.h
===================================================================
--- trunk/MagicSoft/Mars/mfbase/MFEventSelector2.h	(revision 5689)
+++ trunk/MagicSoft/Mars/mfbase/MFEventSelector2.h	(revision 5690)
@@ -41,11 +41,9 @@
     TCanvas   *fCanvas;   //! canvas for online display
 
-    TString    fFilterName; // name of the MFilter object to be used
-                            // when determining the original distribution
+    TString    fFilterName; // name of the MFilter object to be used when determining the original distribution
 
     Bool_t fResult;
     Bool_t fHistIsProbability;
-    Bool_t fUseOrigDist;    // flag indicating that in the selection the
-                            // original distribution is not changed
+    Bool_t fUseOrigDist;    // flag indicating that in the selection the original distribution is not changed
 
     Int_t  fCounter[3];
Index: trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 5689)
+++ trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc	(revision 5690)
@@ -325,4 +325,6 @@
 
 const TString MImgCleanStd::gsNamePedPhotCam="MPedPhotCam"; // default name of the 'MPedPhotCam' container
+const TString MImgCleanStd::gsNameCerPhotEvt="MCerPhotEvt"; // default name of the 'MCerPhotEvt' container
+const TString MImgCleanStd::gsNameGeomCam   ="MGeomCam";    // default name of the 'MGeomCam' container
 
 // --------------------------------------------------------------------------
@@ -337,5 +339,6 @@
                            const char *name, const char *title)
     : fCleaningMethod(kStandard), fCleanLvl1(lvl1),
-      fCleanLvl2(lvl2), fCleanRings(1), fNamePedPhotCam(gsNamePedPhotCam)
+    fCleanLvl2(lvl2), fCleanRings(1), fNamePedPhotCam(gsNamePedPhotCam),
+    fNameGeomCam(gsNameGeomCam), fNameCerPhotEvt(gsNameCerPhotEvt)
 
 {
@@ -540,15 +543,15 @@
 Int_t MImgCleanStd::PreProcess (MParList *pList)
 {
-    fCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    fCam = (MGeomCam*)pList->FindObject(AddSerialNumber(fNameGeomCam), "MGeomCam");
     if (!fCam)
     {
-        *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
+        *fLog << err << fNameGeomCam << " [MGeomCam] not found (no geometry information available)... aborting." << endl;
         return kFALSE;
     }
 
-    fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
+    fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber(fNameCerPhotEvt), "MCerPhotEvt");
     if (!fEvt)
     {
-        *fLog << err << "MCerPhotEvt not found... aborting." << endl;
+        *fLog << err << fNameCerPhotEvt << " [MCerPhotEvt] not found... aborting." << endl;
         return kFALSE;
     }
@@ -557,5 +560,5 @@
     if (!fPed)
     {
-        *fLog << err << "MPedPhotCam not found... aborting." << endl;
+        *fLog << err << fNamePedPhotCam << " [MPedPhotCam] not found... aborting." << endl;
         return kFALSE;
     }
@@ -755,10 +758,10 @@
     case kImgCleanLvl1:
         fCleanLvl1 = lvl;
-        *fLog << "Cleaning level 1 set to " << lvl << " sigma." << endl;
+        *fLog << "Cleaning level 1 set to " << lvl << endl;
         return kTRUE;
 
     case kImgCleanLvl2:
         fCleanLvl2 = lvl;
-        *fLog << "Cleaning level 2 set to " << lvl << " sigma." << endl;
+        *fLog << "Cleaning level 2 set to " << lvl << endl;
         return kTRUE;
     }
@@ -805,4 +808,8 @@
     if (gsNamePedPhotCam!=fNamePedPhotCam)
         out << "   " << GetUniqueName() << ".SetNamePedPhotCam(\"" << fNamePedPhotCam << "\");" << endl;
+    if (gsNameGeomCam!=fNameGeomCam)
+        out << "   " << GetUniqueName() << ".SetNameGeomCam(\"" << fNameGeomCam << "\");" << endl;
+    if (gsNameCerPhotEvt!=fNameCerPhotEvt)
+        out << "   " << GetUniqueName() << ".SetNameCerPhotEvt(\"" << fNameCerPhotEvt << "\");" << endl;
 }
 
Index: trunk/MagicSoft/Mars/mimage/MImgCleanStd.h
===================================================================
--- trunk/MagicSoft/Mars/mimage/MImgCleanStd.h	(revision 5689)
+++ trunk/MagicSoft/Mars/mimage/MImgCleanStd.h	(revision 5690)
@@ -29,4 +29,6 @@
 private:
     static const TString gsNamePedPhotCam; // default name of the 'MPedPhotCam' container
+    static const TString gsNameGeomCam;    // default name of the 'MGeomCam' container
+    static const TString gsNameCerPhotEvt; // default name of the 'MCerPhotEvt' container
 
     const MGeomCam     *fCam;  //!
@@ -44,4 +46,6 @@
 
     TString  fNamePedPhotCam; // name of the 'MPedPhotCam' container
+    TString  fNameGeomCam;    // name of the 'MGeomCam' container
+    TString  fNameCerPhotEvt; // name of the 'MCerPhotEvt' container
 
 
@@ -73,7 +77,10 @@
 
     Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2);
+
     void SetNamePedPhotCam(const char *name)  { fNamePedPhotCam = name; }
+    void SetNameCerPhotEvt(const char *name)  { fNameCerPhotEvt = name; }
+    void SetNameGeomCam(const char *name)     { fNameGeomCam = name; }
 
-    ClassDef(MImgCleanStd, 2)    // task doing the image cleaning
+    ClassDef(MImgCleanStd, 3)    // task doing the image cleaning
 }; 
 
Index: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 5689)
+++ trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc	(revision 5690)
@@ -388,5 +388,6 @@
     MFillH fill7(&evt7, "MArrivalTime",        "FillTimes");
 
-    MWriteRootFile write(2, Form("%s{s/_D_/_Y_}", fPathOut.Data()), fOverwrite);
+    // The second rule is for the case reading raw-files!
+    MWriteRootFile write(2, Form("%s{s/_D_/_Y_}{s/.raw$/.root}", fPathOut.Data()), fOverwrite);
     // Run Header
     write.AddContainer("MRawRunHeader",       "RunHeaders");
Index: trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc	(revision 5689)
+++ trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc	(revision 5690)
@@ -72,5 +72,5 @@
 //
 MRanForestCalc::MRanForestCalc(const char *name, const char *title)
-    : fNum(100), fHadronnessName("MHadronness"), fData(NULL)
+    : fNum(100), fHadronnessName("MHadronness"), fData(NULL), fRanForest(0), fRanTree(0)
 {
     //
@@ -87,5 +87,9 @@
 MRanForestCalc::~MRanForestCalc()
 {
-    //    delete fData;
+    if (!IsOwner())
+        return;
+
+    delete fRanForest;
+    delete fRanTree;
 }
 
@@ -103,23 +107,23 @@
 Int_t MRanForestCalc::PreProcess(MParList *plist)
 {
-    fRanForest = (MRanForest*)plist->FindObject("MRanForest");
     if (!fRanForest)
     {
-        *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fRanTree = (MRanTree*)plist->FindObject("MRanTree");
+        fRanForest = (MRanForest*)plist->FindObject("MRanForest");
+        if (!fRanForest)
+        {
+            *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
+            return kFALSE;
+        }
+    }
+
     if (!fRanTree)
     {
-        *fLog << err << dbginf << "MRanTree not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    /*if(!fRanForest->GetCurTree())
-    {
-        *fLog << err << dbginf << "MRanForest does not contain trees... aborting." << endl;
-        return kFALSE;
-    }*/
+        fRanTree = (MRanTree*)plist->FindObject("MRanTree");
+        if (!fRanTree)
+        {
+            *fLog << err << dbginf << "MRanTree not found... aborting." << endl;
+            return kFALSE;
+        }
+    }
 
     fData = fRanTree->GetRules();
@@ -253,2 +257,59 @@
     return kTRUE;
 }
+
+Int_t MRanForestCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    if (!IsEnvDefined(env, prefix, "File",     print))
+        return kFALSE;
+
+    TString fname = GetEnvValue(env, prefix, "File", "RF.root");
+    TString tname = GetEnvValue(env, prefix, "Tree", "Tree");
+    const Int_t   num   = GetEnvValue(env, prefix, "NumTrees", 100);
+    const Bool_t  debug = GetEnvValue(env, prefix, "Debug", kFALSE);
+
+    fname.ReplaceAll("\015", "");
+    tname.ReplaceAll("\015", "");
+
+    *fLog << dbginf << "Reading " << num << " trees " << tname << " from file " << fname << endl;
+
+    gLog.SetNullOutput(!debug);
+    MEvtLoop evtloop;
+    MParList  plist;
+    evtloop.SetParList(&plist);
+    MLog l;
+    l.SetNullOutput(!debug);
+    evtloop.SetLogStream(&l);
+    gLog.SetNullOutput(debug);
+
+    if (IsOwner())
+    {
+        delete fRanForest;
+        delete fRanTree;
+    }
+    fRanForest = new MRanForest;
+    fRanTree   = new MRanTree;
+    SetOwner();
+
+    plist.AddToList(fRanForest);
+    plist.AddToList(fRanTree);
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    MReadTree read(tname, fname);
+    read.DisableAutoScheme();
+
+    MRanForestFill rffill;
+    rffill.SetNumTrees(num);
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&rffill);
+
+    if (!evtloop.Eventloop())
+    {
+        *fLog << err << "ERROR - Reading " << tname << " from file " << fname << endl;
+        return kERROR;
+    }
+
+    return kTRUE;
+}
Index: trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h	(revision 5689)
+++ trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h	(revision 5690)
@@ -31,7 +31,14 @@
     Int_t Process();
 
+    enum { kIsOwner = BIT(14) };
+
+    Bool_t IsOwner() const { return TestBit(kIsOwner); }
+    void SetOwner() { SetBit(kIsOwner); }
+
 public:
     MRanForestCalc(const char *name=NULL, const char *title=NULL);
     ~MRanForestCalc();
+
+    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
 
     void SetHadronnessName(const TString name) { fHadronnessName = name; }
