Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 3787)
+++ trunk/MagicSoft/Mars/Changelog	(revision 3788)
@@ -18,4 +18,29 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2004/04/21: Thomas Bretz
+
+   * mbase/MTask.cc,  mbase/MTaskList.cc:
+     - let MTask in list fTaskProcess to be used as a counter
+
+   * mdata/MDataChain.[h,cc]:
+     - added some treatments for combinations of +/- signs
+
+   * mfbase/MFilterList.[h,cc]:
+     - added a new constructor to simplyfy filter-inversions
+
+   * mfileio/MReadReports.cc:
+     - added comment
+
+   * mhbase/MBinning.[h,cc]:
+     - added new constructor to simplify calls in macros
+
+   * mhbase/MFillH.[h,cc]:
+     - added fDrawOption to be used in MStatusDisplay
+
+   * mhist/MHFalseSource.cc:
+     - added comment
+
+
+
  2004/04/20: Thomas Bretz
 
Index: trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 3787)
+++ trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 3788)
@@ -77,4 +77,11 @@
 //                     etc. PostProcess is only executed in case of
 //                     PreProcess was successfull (returned kTRUE)
+//
+//
+//  Remark: Using a MTask in your tasklist doesn't make much sense,
+//          because it is doing nothing. However it is a nice tool
+//          to count something (exspecially if used together with a
+//          filter)
+//
 //
 //  Version 1:
@@ -391,5 +398,5 @@
 void MTask::PrintStatistics(const Int_t lvl, Bool_t title, Double_t time) const
 {
-    if (!OverwritesProcess())
+    if (!OverwritesProcess() && IsA()!=MTask::Class())
         return;
 
@@ -447,5 +454,5 @@
     // Check whether we reached the base class MTask
     //
-    if (TString(cls->GetName())=="MTask")
+    if (cls==MTask::Class())
         return kFALSE;
 
Index: trunk/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 3787)
+++ trunk/MagicSoft/Mars/mbase/MTaskList.cc	(revision 3788)
@@ -43,4 +43,9 @@
 // from the list.
 //
+// Remark: The Process function is only executed if the class of your task
+//         overloads Process() or if the task itself is a MTask. This
+//         means if you have a task without Process() (only PreProcess
+//         and PostProcess no time is lost during execution)
+//
 // Warning:
 //  Be carefull if you are writing your tasklist
@@ -300,4 +305,104 @@
 // --------------------------------------------------------------------------
 //
+//  removes a task from the list (used in PreProcess).
+//  if kIsOwner is set the task is deleted. (see SetOwner())
+//
+void MTaskList::Remove(MTask *task)
+{
+    TObject *obj = fTasks->Remove(task);
+
+    if (TestBit(kIsOwner))
+        delete obj;
+}
+
+// --------------------------------------------------------------------------
+//
+//  do pre processing (before eventloop) of all tasks in the task-list
+//  Only if a task overwrites the Process function the task is
+//  added to the fTaskProcess-List. This makes the execution of the
+//  tasklist a little bit (only a little bit) faster, bacause tasks
+//  doing no Processing are not Processed.
+//
+Int_t MTaskList::PreProcess(MParList *pList)
+{
+    *fLog << all << "Preprocessing... " << flush;
+    if (fDisplay)
+    {
+        // Set status lines
+        fDisplay->SetStatusLine1("PreProcessing...");
+        fDisplay->SetStatusLine2("");
+    }
+
+    fParList = pList;
+
+    //
+    // Make sure, that the ReadyToSave flag is not reset from a tasklist
+    // running as a task in another tasklist.
+    //
+    const Bool_t noreset = fParList->TestBit(MParList::kDoNotReset);
+    if (!noreset)
+        fParList->SetBit(MParList::kDoNotReset);
+
+    //
+    //  create the Iterator over the tasklist
+    //
+    TIter Next(fTasks);
+
+    MTask *task=NULL;
+
+    //
+    // loop over all tasks for preproccesing
+    //
+    while ((task=(MTask*)Next()))
+    {
+        //
+        // PreProcess the task and check for it's return value.
+        //
+        switch (task->CallPreProcess(fParList))
+        {
+        case kFALSE:
+            return kFALSE;
+
+        case kTRUE:
+            // Handle GUI events (display changes, mouse clicks)
+            if (fDisplay)
+                gSystem->ProcessEvents();
+            continue;
+
+        case kSKIP:
+            Remove(task);
+            continue;
+        }
+
+        *fLog << err << dbginf << "PreProcess of " << task->GetDescriptor();
+        *fLog << " returned an unknown value... aborting." << endl;
+        return kFALSE;
+    }
+
+    *fLog << all << endl;
+
+    //
+    // Reset the ReadyToSave flag.
+    //
+    if (!noreset)
+    {
+        fParList->SetReadyToSave(kFALSE);
+        fParList->ResetBit(MParList::kDoNotReset);
+    }
+
+    //
+    // loop over all tasks to fill fTasksProcess
+    //
+    Next.Reset();
+    fTasksProcess.Clear();
+    while ((task=(MTask*)Next()))
+        if (task->IsA()==MTask::Class() || task->OverwritesProcess())
+            fTasksProcess.Add(task);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
 //  do reinit of all tasks in the task-list
 //
@@ -348,104 +453,4 @@
         pList->ResetBit(MParList::kDoNotReset);
     }
-
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-//  removes a task from the list (used in PreProcess).
-//  if kIsOwner is set the task is deleted. (see SetOwner())
-//
-void MTaskList::Remove(MTask *task)
-{
-    TObject *obj = fTasks->Remove(task);
-
-    if (TestBit(kIsOwner))
-        delete obj;
-}
-
-// --------------------------------------------------------------------------
-//
-//  do pre processing (before eventloop) of all tasks in the task-list
-//  Only if a task overwrites the Process function the task is
-//  added to the fTaskProcess-List. This makes the execution of the
-//  tasklist a little bit (only a little bit) faster, bacause tasks
-//  doing no Processing are not Processed.
-//
-Int_t MTaskList::PreProcess(MParList *pList)
-{
-    *fLog << all << "Preprocessing... " << flush;
-    if (fDisplay)
-    {
-        // Set status lines
-        fDisplay->SetStatusLine1("PreProcessing...");
-        fDisplay->SetStatusLine2("");
-    }
-
-    fParList = pList;
-
-    //
-    // Make sure, that the ReadyToSave flag is not reset from a tasklist
-    // running as a task in another tasklist.
-    //
-    const Bool_t noreset = fParList->TestBit(MParList::kDoNotReset);
-    if (!noreset)
-        fParList->SetBit(MParList::kDoNotReset);
-
-    //
-    //  create the Iterator over the tasklist
-    //
-    TIter Next(fTasks);
-
-    MTask *task=NULL;
-
-    //
-    // loop over all tasks for preproccesing
-    //
-    while ((task=(MTask*)Next()))
-    {
-        //
-        // PreProcess the task and check for it's return value.
-        //
-        switch (task->CallPreProcess(fParList))
-        {
-        case kFALSE:
-            return kFALSE;
-
-        case kTRUE:
-            // Handle GUI events (display changes, mouse clicks)
-            if (fDisplay)
-                gSystem->ProcessEvents();
-            continue;
-
-        case kSKIP:
-            Remove(task);
-            continue;
-        }
-
-        *fLog << err << dbginf << "PreProcess of " << task->GetDescriptor();
-        *fLog << " returned an unknown value... aborting." << endl;
-        return kFALSE;
-    }
-
-    *fLog << all << endl;
-
-    //
-    // Reset the ReadyToSave flag.
-    //
-    if (!noreset)
-    {
-        fParList->SetReadyToSave(kFALSE);
-        fParList->ResetBit(MParList::kDoNotReset);
-    }
-
-    //
-    // loop over all tasks to fill fTasksProcess
-    //
-    Next.Reset();
-    fTasksProcess.Clear();
-    while ((task=(MTask*)Next()))
-        if (task->OverwritesProcess())
-            fTasksProcess.Add(task);
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mdata/MDataChain.cc
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataChain.cc	(revision 3787)
+++ trunk/MagicSoft/Mars/mdata/MDataChain.cc	(revision 3788)
@@ -45,5 +45,5 @@
 //   "MCameraLV.fPowerSupplyA.fVoltagePos5V"
 //
-// You can also use brackets:
+// You can also use parantheses:
 //   "HillasDource.fDist / (MHillas.fLength + MHillas.fWidth)"
 //
@@ -57,5 +57,5 @@
 // While a^b returns a to the power of b
 //
-// Warning: There is no priority rule build in. So better use brackets
+// Warning: There is no priority rule build in. So better use parantheses
 //   to get correct results. The rule is parsed/evaluated from the left
 //   to the right, which means:
@@ -158,5 +158,5 @@
 //  - The possibility to use other objects inheriting from MData
 //    is missing.
-//  - By automatic pre-adding brackets to the rule it would be possible
+//  - By automatic pre-adding parantheses to the rule it would be possible
 //    to implement priorities for operators.
 //
@@ -365,4 +365,16 @@
 }
 
+void MDataChain::SimplifyString(TString &txt) const
+{
+    while (txt.First("--")>=0 || txt.First("++")>=0 ||
+           txt.First("+-")>=0 || txt.First("-+")>=0)
+    {
+        txt.ReplaceAll("--", "+");
+        txt.ReplaceAll("++", "+");
+        txt.ReplaceAll("-+", "-");
+        txt.ReplaceAll("+-", "-");
+    }
+}
+
 // --------------------------------------------------------------------------
 //
@@ -371,4 +383,7 @@
 MData *MDataChain::ParseString(TString txt, Int_t level)
 {
+    if (level==0)
+        SimplifyString(txt);
+
     MData *member0=NULL;
 
@@ -387,8 +402,7 @@
             {
                 //
-                // Search for the corresponding bracket
-                //
-                Int_t first=GetBracket(txt, '(', ')');
-
+                // Search for the corresponding parantheses
+                //
+                const Int_t first=GetBracket(txt, '(', ')');
                 if (first==txt.Length())
                 {
@@ -400,5 +414,5 @@
 
                 //
-                // Make a copy of the 'interieur' and delete the substringä
+                // Make a copy of the 'interieur' and delete the substring
                 // including the brackets
                 //
@@ -462,6 +476,6 @@
             if (txt[0]!='-' && txt[0]!='+')
             {
-                *fLog << err << dbginf << "Syntax Error: First argument of symbol '";
-                *fLog << txt[0] << "' missing." << endl;
+                *fLog << err << dbginf << "Syntax Error: First argument of '";
+                *fLog << txt[0] << "' opartor missing." << endl;
                 if (member0)
                     delete member0;
Index: trunk/MagicSoft/Mars/mdata/MDataChain.h
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataChain.h	(revision 3787)
+++ trunk/MagicSoft/Mars/mdata/MDataChain.h	(revision 3788)
@@ -44,4 +44,5 @@
     Int_t GetBracket(TString txt, char open, char close);
 
+    void   SimplifyString(TString &txt) const;
     MData *ParseString(TString txt, Int_t level);
     MData *ParseDataMember(TString txt);
Index: trunk/MagicSoft/Mars/mfbase/MFilterList.cc
===================================================================
--- trunk/MagicSoft/Mars/mfbase/MFilterList.cc	(revision 3787)
+++ trunk/MagicSoft/Mars/mfbase/MFilterList.cc	(revision 3788)
@@ -38,10 +38,15 @@
 // invert the meaning of a filter, by eg:
 //
-//   MF anyfilter("MHillas.fAlpha");
-//
-//   MFilterList alist;
-//   alist.AddToList(&anyfilter);
-//
-//   alist.SetInverted();
+//    MF anyfilter("MHillas.fAlpha");
+//
+//    MFilterList alist;
+//    alist.AddToList(&anyfilter);
+//
+//    alist.SetInverted();
+//
+//  or do
+//
+//    MFilterList alist(&anyfilter);
+//
 //
 // Adding the filterlist to the eventloop will process all contained filters.
@@ -72,5 +77,20 @@
 // --------------------------------------------------------------------------
 //
-//   Constructor.
+// Wrapper to simplify constructors.
+//
+void MFilterList::Init(const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    gROOT->GetListOfCleanups()->Add(&fFilters);
+    fFilters.SetBit(kMustCleanup);
+
+    fFilterType = kEAnd;
+}
+
+// --------------------------------------------------------------------------
+//
+//   Default Constructor.
 //
 //   Specify the boolean operation which is used to evaluate the
@@ -91,11 +111,5 @@
 MFilterList::MFilterList(const char *type, const char *name, const char *title)
 {
-    fName  = name  ? name  : gsDefName.Data();
-    fTitle = title ? title : gsDefTitle.Data();
-
-    gROOT->GetListOfCleanups()->Add(&fFilters);
-    fFilters.SetBit(kMustCleanup);
-
-    fFilterType = kEAnd;
+    Init(name, title);
 
     TString str(type);
@@ -113,4 +127,21 @@
 // --------------------------------------------------------------------------
 //
+//   Constructor.
+//
+// Setup an '&&' filter list, adds the filter to the list and
+// call MFilterList::SetInverted()
+//
+// To be used as a logical NOT.
+//
+MFilterList::MFilterList(MFilter *f, const char *name, const char *title)
+{
+    Init(name, title);
+
+    SetInverted();
+    AddToList(f);
+}
+
+// --------------------------------------------------------------------------
+//
 //   CopyConstructor
 //
Index: trunk/MagicSoft/Mars/mfbase/MFilterList.h
===================================================================
--- trunk/MagicSoft/Mars/mfbase/MFilterList.h	(revision 3787)
+++ trunk/MagicSoft/Mars/mfbase/MFilterList.h	(revision 3788)
@@ -31,6 +31,9 @@
     void StreamPrimitive(ofstream &out) const;
 
+    void Init(const char *name, const char *title);
+
 public:
     MFilterList(const char *type="&&", const char *name=NULL, const char *title=NULL);
+    MFilterList(MFilter *f, const char *name=NULL, const char *title=NULL);
     MFilterList(MFilterList &ts);
     ~MFilterList()
Index: trunk/MagicSoft/Mars/mfileio/MReadReports.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadReports.cc	(revision 3787)
+++ trunk/MagicSoft/Mars/mfileio/MReadReports.cc	(revision 3788)
@@ -127,4 +127,6 @@
 // All calls to AddTree _must_ be BEFORE the calls to AddFile!
 //
+// To be done: A flag(?) telling whether the headers can be skipped.
+//
 void MReadReports::AddTree(const char *tree, const char *time, Bool_t master)
 {
Index: trunk/MagicSoft/Mars/mhbase/MBinning.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MBinning.cc	(revision 3787)
+++ trunk/MagicSoft/Mars/mhbase/MBinning.cc	(revision 3788)
@@ -61,8 +61,15 @@
 
     SetEdges(10, 0, 1);
-
     fType = kIsDefault;
 }
 
+MBinning::MBinning(Int_t nbins, Axis_t lo, Axis_t hi, const char *name, const char *opt="", const char *title=NULL)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    SetEdges(nbins, lo, hi, opt);
+
+}
 void MBinning::SetEdges(const TAxis &axe)
 {
@@ -110,4 +117,26 @@
 
     fType = kIsLinear;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls SetEdgesLog if opt contains "log"
+// Calls SetEdgesCos if opt contains "cos"
+// Calls SetEdges in all other cases
+//
+void MBinning::SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up, const char *opt)
+{
+    const TString o(opt);
+    if (o.Contains("log", TString::kIgnoreCase))
+    {
+        SetEdgesLog(nbins, lo, up);
+        return;
+    }
+    if (o.Contains("cos", TString::kIgnoreCase))
+    {
+        SetEdgesCos(nbins, lo, up);
+        return;
+    }
+    SetEdges(nbins, lo, up);
 }
 
Index: trunk/MagicSoft/Mars/mhbase/MBinning.h
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MBinning.h	(revision 3787)
+++ trunk/MagicSoft/Mars/mhbase/MBinning.h	(revision 3788)
@@ -32,4 +32,5 @@
 public:
     MBinning(const char *name=NULL, const char *title=NULL);
+    MBinning(Int_t nbins, Axis_t lo, Axis_t hi, const char *name, const char *opt="", const char *title=NULL);
 
     void SetEdges(const TArrayD &arr)
@@ -42,4 +43,5 @@
     void SetEdges(const TH1 &h, const Char_t axis='x');
     void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up);
+    void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up, const char *opt);
     void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up);
     void SetEdgesCos(const Int_t nbins, const Axis_t lo, Axis_t up);
Index: trunk/MagicSoft/Mars/mhbase/MFillH.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MFillH.cc	(revision 3787)
+++ trunk/MagicSoft/Mars/mhbase/MFillH.cc	(revision 3788)
@@ -340,4 +340,14 @@
 // --------------------------------------------------------------------------
 //
+// Use this to set a draw option used when drawing automatically to the
+// status display.
+//
+void MFillH::SetDrawOption(Option_t *option="")
+{
+    fDrawOption = option;
+}
+
+// --------------------------------------------------------------------------
+//
 // Creates a new tab in a status display with the name of the MH class,
 // if fDisplay is set and the MH-class overwrites the Draw function
@@ -357,5 +367,5 @@
 
     fCanvas = &fDisplay->AddTab(fNameTab.IsNull() ? fH->GetName() : fNameTab.Data());
-    fH->Draw();
+    fH->Draw(fDrawOption);
 
     return kTRUE;
@@ -549,6 +559,7 @@
     if (fDisplay && fDisplay->HasCanvas(fCanvas))
     {
+        const TString opt(Form("nonew %s", fDrawOption));
         fCanvas->cd();
-        fH->DrawClone("nonew");
+        fH->DrawClone(opt);
         fCanvas->Modified();
         fCanvas->Update();
Index: trunk/MagicSoft/Mars/mhbase/MFillH.h
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MFillH.h	(revision 3787)
+++ trunk/MagicSoft/Mars/mhbase/MFillH.h	(revision 3788)
@@ -38,4 +38,6 @@
     TCanvas *fCanvas;             //! Canvas used to update a MStatusDisplay at the end of a loop
 
+    TString fDrawOption;          // Draw option for status display
+
     TString ExtractName(const char *name) const;
     TString ExtractClass(const char *name) const;
@@ -63,4 +65,7 @@
     void SetWeight(const char *name) { fWeightName = name; }
 
+    void      SetDrawOption(Option_t *option="");
+    Option_t *GetDrawOption() const { return fDrawOption; }
+
     Int_t  PreProcess(MParList *pList);
     Bool_t ReInit(MParList *pList);
Index: trunk/MagicSoft/Mars/mhist/MHFalseSource.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHFalseSource.cc	(revision 3787)
+++ trunk/MagicSoft/Mars/mhist/MHFalseSource.cc	(revision 3788)
@@ -107,4 +107,7 @@
 //  - currently a constant pointing position is assumed in Fill()
 //  - the center of rotation need not to be the camera center
+//  - ERRORS on each alpha bin to estimate the chi^2 correctly!
+//    (sqrt(N)/binwidth) needed for WOlfgangs proposed caluclation
+//    of alpha(Li/Ma)
 //
 //////////////////////////////////////////////////////////////////////////////
