Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 5955)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 5956)
@@ -21,4 +21,47 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2005/01/24 Thomas Bretz
+
+   * callisto.cc:
+     - removed non-existing option from output
+
+   * manalysis/MEnergyEstimate.[h,cc]:
+     - added ReadEnv member function
+
+   * mbase/MContinue.[h,cc]:
+     - implementes AllowEmpty option to support doing nothing 
+       defined in resource file
+     - added a first draft to allow usage of class-filters instead of 
+       rules
+
+   * mbase/MMath.[h,cc]:
+     - implemented a function suggested by Florian Goebel which reduces
+       the precision of a float to ~0.5% which is usefull for data
+       compression by gzip
+
+   * mdata/MDataChain.[h,cc]:
+     - implemented ReadEnv member function
+
+   * mfbase/MF.cc:
+     - a small enhancement to the output in ReadEnv
+
+   * mhbase/MH3.cc:
+     - fixed call to FindObject in Paint which caused a profile to be
+       displayed incorrectly in case it was read from a file
+
+   * mhflux/MHFalseSource.[h,cc]:
+     - removed old obsolete unsused Significance functions
+     - implemented ReadEnv member function
+
+   * mjobs/MJCalibrateSignal.cc, mjobs/MJCalibration.cc, 
+     mjobs/MJPedestal.cc:
+     - added an additional check and output if output-file could
+       not be opened
+
+   * mjobs/MJob.h:
+     - added some Getter
+
+
+
  2005/01/24 Markus Gaug
 
@@ -28,4 +71,6 @@
   * msignal/MExtractedSignalPix.cc
     - change sign of default initializer to negative.
+
+
 
  2005/01/23 Markus Gaug
@@ -46,4 +91,6 @@
   * mbadpixels/MBadPixelsCam.cc
     - removed some bugs in the Print() function
+
+
 
  2005/01/22 Markus Gaug
@@ -67,4 +114,6 @@
    * macros/calibration.C
      - update to changes in MJExtractCalibTest
+
+
 
  2005/01/21 Markus Gaug
Index: /trunk/MagicSoft/Mars/callisto.cc
===================================================================
--- /trunk/MagicSoft/Mars/callisto.cc	(revision 5955)
+++ /trunk/MagicSoft/Mars/callisto.cc	(revision 5956)
@@ -58,5 +58,5 @@
     gLog << "   -q                        Quit when job is finished" << endl;
     gLog << "   -f                        Force overwrite of existing files" << endl;
-    gLog << "   -ff                       Force execution if not all files found" << endl;
+    //gLog << "   -ff                       Force execution if not all files found" << endl;
     gLog << "   --ind=path                Path where to search for the data files" << endl;
     gLog << "                             [default=standard path in datacenter]" << endl;
Index: /trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.cc	(revision 5955)
+++ /trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.cc	(revision 5956)
@@ -134,2 +134,42 @@
     return kTRUE;
 }
+
+// --------------------------------------------------------------------------
+//
+// Check for corresponding entries in resource file and setup filters.
+// Avoid trailing 0's!
+//
+// Example:
+//   test.C:
+//     MEnergyEstimate est("MyEstimator");
+//
+//   test.rc:
+//     MyEstimator.Rule: {0} + {1}
+//     MyEstimator.0: log10(MHillas.fSize)
+//     MyEstimator.1: 5.5
+//
+// For more details see MDataChain::ReadEnv
+//
+Int_t MEnergyEstimate::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    MDataChain *f = new MDataChain;
+    f->SetName(fName);
+
+    const Bool_t rc = f->ReadEnv(env, prefix, print);
+    if (rc!=kTRUE)
+    {
+        delete f;
+        return rc;
+    }
+
+    delete fData;
+    fData = f;
+
+    if (!fData->IsValid())
+    {
+        *fLog << err << "MEnergyEst::ReadEnv - ERROR: Inavlid rule from resource file." << endl;
+        return kERROR;
+    }
+
+    return kTRUE;
+}
Index: /trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.h
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.h	(revision 5955)
+++ /trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.h	(revision 5956)
@@ -14,4 +14,6 @@
     MData      *fData;    //->
     MEnergyEst *fEnergy;
+
+    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
 
 public:
Index: /trunk/MagicSoft/Mars/mbase/MContinue.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MContinue.cc	(revision 5955)
+++ /trunk/MagicSoft/Mars/mbase/MContinue.cc	(revision 5956)
@@ -73,4 +73,5 @@
 //
 MContinue::MContinue(const TString rule, const char *name, const char *title)
+    : fTaskList(0)
 {
     fName  = name  ? name  : "MContinue";
@@ -95,4 +96,5 @@
 //
 MContinue::MContinue(MFilter *f, const char *name, const char *title)
+    : fTaskList(0)
 {
     fName  = name  ? name  : "MContinue";
@@ -119,6 +121,14 @@
 Int_t MContinue::PreProcess(MParList *list)
 {
+    ResetBit(kFilterIsPrivate);
+
     if (!GetFilter())
     {
+        if (IsAllowEmpty())
+        {
+            *fLog << warn << GetDescriptor() << " - WARNING: Empty filter found... task removed." << endl;
+            return kSKIP;
+        }
+
         *fLog << err << dbginf << "Unknown fatal Error! (fFilter=NULL?!?)" << endl;
         return kFALSE;
@@ -144,7 +154,9 @@
     }
 
+    // Make sure, that everything is correctly propageted to the childs
     GetFilter()->SetDisplay(fDisplay);
     GetFilter()->SetLogStream(fLog);
 
+    // Remeber that the filter is not already in tasklist
     SetBit(kFilterIsPrivate);
 
@@ -229,4 +241,8 @@
 //     MyContinue.0: MHillas.fSize>1000
 //     MyContinue.1: MHillas.fSize<10000
+//   or
+//     MyContinue.Condition: <MMyClass>
+//     MMyClass.Variable1: ...
+//     MMyClass.Variable2: ...
 //
 // For more details see MF::ReadEnv
@@ -234,4 +250,15 @@
 Int_t MContinue::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
 {
+    if (IsEnvDefined(env, prefix, "Condition", print))
+    {
+        TString txt = GetEnvValue(env, prefix, "Condition", "");
+        txt = txt.Strip(TString::kBoth);
+        if (txt.BeginsWith("<") && txt.EndsWith(">"))
+        {
+            *fLog << err << "NOT YET IMPLEMENTED..." << endl;
+            return kERROR;
+        }
+    }
+
     MF *f = new MF;
     f->SetName(fName);
Index: /trunk/MagicSoft/Mars/mbase/MContinue.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MContinue.h	(revision 5955)
+++ /trunk/MagicSoft/Mars/mbase/MContinue.h	(revision 5956)
@@ -30,5 +30,5 @@
     Int_t PostProcess();
 
-    enum { kIsOwner = BIT(14), kFilterIsPrivate = BIT(15) };
+    enum { kIsOwner = BIT(14), kFilterIsPrivate = BIT(15), kAllowEmpty = BIT(16) };
 
 public:
@@ -36,4 +36,9 @@
     MContinue(MFilter *f, const char *name=NULL, const char *title=NULL);
     ~MContinue();
+
+    // MContinue
+    void SetAllowEmpty(Bool_t b=kTRUE) { b ? SetBit(kAllowEmpty) : ResetBit(kAllowEmpty); }
+    Bool_t IsAllowEmpty() const { return TestBit(kAllowEmpty); }
+
 
     void SetInverted(Bool_t i=kTRUE);
Index: /trunk/MagicSoft/Mars/mbase/MMath.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MMath.cc	(revision 5955)
+++ /trunk/MagicSoft/Mars/mbase/MMath.cc	(revision 5956)
@@ -135,4 +135,19 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// This function truncates the precision to roughly 0.5% of a Float_t by
+// changing its bit-pattern (Be carefull, in rare cases this function must
+// be adapted to different machines!). This is usefull to enforce better
+// compression by eg. gzip.
+//
+void MMath::TruncatePrecision(Float_t &val)
+{
+    UInt_t &f = (UInt_t&)val;
+
+    f += 0x00004000;
+    f &= 0xffff8000;
+}
+
 // -------------------------------------------------------------------------
 //
Index: /trunk/MagicSoft/Mars/mbase/MMath.h
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MMath.h	(revision 5955)
+++ /trunk/MagicSoft/Mars/mbase/MMath.h	(revision 5956)
@@ -18,4 +18,6 @@
     Double_t SignificanceLiMaSigned(Double_t s, Double_t b, Double_t alpha=1);
 
+    void TruncatePrecision(Float_t &val);
+
     TVector3 GetParab(const TVector3 &x, const TVector3 &y);
     Double_t InterpolParabLin(const TVector3 &vx, const TVector3 &vy, Double_t x);
Index: /trunk/MagicSoft/Mars/mdata/MDataChain.cc
===================================================================
--- /trunk/MagicSoft/Mars/mdata/MDataChain.cc	(revision 5955)
+++ /trunk/MagicSoft/Mars/mdata/MDataChain.cc	(revision 5956)
@@ -749,2 +749,81 @@
     return fMember->SetVariables(arr);
 }
+
+// --------------------------------------------------------------------------
+//
+// Check for corresponding entries in resource file and setup data chain.
+//
+// Assuming your MDataChain is called (Set/GetName): MyData
+//
+// Now setup the condition, eg:
+//     MyData.Rule: log10(MHillas.fSize)
+// or
+//     MyData.Rule: log10(MHillas.fSize) - 4.1
+//
+// If you want to use more difficult rules you can split the
+// condition into subrules. Subrules are identified
+// by {}-brackets. Avoid trailing 0's! For example:
+//
+//     MyData.Rule: log10(MHillas.fSize) + {0} - {1}
+//     MyData.0: 5.5*MHillas.fSize
+//     MyData.1: 2.3*log10(MHillas.fSize)
+//
+// The numbering must be continous and start with 0. You can use
+// a subrules more than once. All {}-brackets are simply replaced
+// by the corresponding conditions. The rules how conditions can
+// be written can be found in the class description of MDataChain.
+//
+Int_t MDataChain::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    Bool_t rc = kFALSE;
+    if (!IsEnvDefined(env, prefix, "Rule", print))
+        return rc;
+
+    TString rule = GetEnvValue(env, prefix, "Rule", "");
+    rule.ReplaceAll(" ", "");
+
+    Int_t idx=0;
+    while (1)
+    {
+        TString cond;
+        if (IsEnvDefined(env, prefix, Form("%d", idx), print))
+        {
+            cond += "(";
+            cond += GetEnvValue(env, prefix, Form("%d", idx), "");
+            cond += ")";
+        }
+
+        if (cond.IsNull())
+            break;
+
+        rule.ReplaceAll(Form("{%d}", idx), cond);
+        idx++;
+    }
+
+    if (fMember)
+    {
+        delete fMember;
+        fMember = 0;
+    }
+
+    if (rule.IsNull())
+    {
+        *fLog << warn << "MDataChain::ReadEnv - ERROR: Empty rule found." << endl;
+        return kERROR;
+    }
+
+    if (!(fMember=ParseString(rule, 1)))
+    {
+        *fLog << err << "MDataChain::ReadEnv - ERROR: Parsing '" << rule << "' failed." << endl;
+        return kERROR;
+    }
+
+    if (print)
+    {
+        *fLog << inf << "found: ";
+        fMember->Print();
+        *fLog << endl;
+    }
+
+    return kTRUE;
+}
Index: /trunk/MagicSoft/Mars/mdata/MDataChain.h
===================================================================
--- /trunk/MagicSoft/Mars/mdata/MDataChain.h	(revision 5955)
+++ /trunk/MagicSoft/Mars/mdata/MDataChain.h	(revision 5956)
@@ -17,5 +17,5 @@
 {
 private:
-    MData    *fMember; // Filter
+    MData *fMember; // Filter
 
     // PLEASE, always add new enums to the end of the enumeration,
@@ -54,16 +54,17 @@
     ~MDataChain();
 
+    // MData
     Double_t GetValue() const;
-    Bool_t PreProcess(const MParList *plist);
 
     Bool_t IsValid() const { return fMember ? kTRUE : kFALSE; }
-    Bool_t IsReadyToSave() const;
-
-//    void Print(Option_t *opt = "") const;
+    Bool_t PreProcess(const MParList *plist);
 
     TString GetRule() const;
     TString GetDataMember() const;
 
+    // MParContainer
+    Bool_t IsReadyToSave() const;
     void SetVariables(const TArrayD &arr);
+    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
 
     ClassDef(MDataChain, 1) // A chain/concatenation of MData objects
Index: /trunk/MagicSoft/Mars/mfbase/MF.cc
===================================================================
--- /trunk/MagicSoft/Mars/mfbase/MF.cc	(revision 5955)
+++ /trunk/MagicSoft/Mars/mfbase/MF.cc	(revision 5956)
@@ -478,5 +478,12 @@
 
     if (!IsEnvDefined(env, prefix, "Condition", print))
+    {
+        if (rc)
+        {
+            *fLog << warn << GetDescriptor() << " ::ReadEnv - WARNING: No condition found." << endl;
+            SetAllowEmpty();
+        }
         return rc;
+    }
 
     TString rule = GetEnvValue(env, prefix, "Condition", "");
@@ -509,5 +516,5 @@
     if (rule.IsNull())
     {
-        *fLog << warn << "MF::ReadEnv - WARNING: Empty condition found." << endl;
+        *fLog << warn << GetDescriptor() << " ::ReadEnv - WARNING: Empty condition found." << endl;
         SetAllowEmpty();
         return kTRUE;
Index: /trunk/MagicSoft/Mars/mhbase/MH3.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 5955)
+++ /trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 5956)
@@ -546,5 +546,5 @@
 
     // FIXME: We may have to remove all our own options from str!
-    if (!only && !gPad->GetListOfPrimitives()->FindObject(fHist))
+    if (!only && !gPad->FindObject(fHist))
         fHist->Draw(str);
 
@@ -552,5 +552,5 @@
     {
         TProfile *p = ((TH2*)fHist)->ProfileX("ProfX", -1, 9999, "s");
-        if (!gPad->GetListOfPrimitives()->FindObject(p))
+        if (!gPad->FindObject(p))
         {
             p->UseCurrentStyle();
@@ -566,5 +566,5 @@
     {
         TProfile *p = ((TH2*)fHist)->ProfileY("ProfY", -1, 9999, "s");
-        if (!gPad->GetListOfPrimitives()->FindObject(p))
+        if (!gPad->FindObject(p))
         {
             p->UseCurrentStyle();
