Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 1208)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 1209)
@@ -8,4 +8,11 @@
    * mfilter/MFAlpha.[h,cc]:
      - added
+
+   * mfilter/MFill.[h,cc]:
+     - implemented a new calling style which allows you to let MFillH
+       create the necessary histogram objects
+
+   * mmain/MAnalysis.cc, macros/MagicHillas.C:
+     - changed to new stylish MHillas parameter containers
 
 
Index: /trunk/MagicSoft/Mars/macros/MagicHillas.C
===================================================================
--- /trunk/MagicSoft/Mars/macros/MagicHillas.C	(revision 1208)
+++ /trunk/MagicSoft/Mars/macros/MagicHillas.C	(revision 1209)
@@ -24,5 +24,5 @@
 
 
-void MagicHillas(const char *filename="data/camera.root")
+void MagicHillas(const char *filename="~/data/Gamma*.root")
 {
     //
@@ -46,17 +46,21 @@
     plist.AddToList(&geomcam);
 
-    MPedestalCam pedest;
-    plist.AddToList(&pedest);
+    //
+    // Craete the object which hlods the source positions in the camera
+    // plain in respect to which the image parameters will be calculated.
+    // For real data the containers will be filled by a task.
+    //
+    MSrcPosCam source("Source")
+    source.SetXY(0, 0);
+
+    MSrcPosCam antisrc("AntiSrc");
+    antisrc.SetXY(240, 0);
+
+    plist.AddToList(&source);
+    plist.AddToList(&antisrc);
 
     //
     // Now setup the tasks and tasklist:
-    //
-    //  1) read in the data from a magic root file   MReadTree
-    //  2) calculate number of cerenkov photons      MCerPhotCalc
-    //  3) clean the image                           MImgCleanStd
-    //  4) calculate hillas                          MHillasCalc
-    //  5) fill the hillas into the histograms       MFillH
-    //
-
+    // ---------------------------------
     //
     // The first argument is the tree you want to read.
@@ -65,5 +69,5 @@
     //   CalEvents:  Calibration Events
     //
-    MReadMarsFile  read("Events",filename);
+    MReadMarsFile  read("Events", filename);
 
     MMcPedestalCopy   pcopy;
@@ -73,12 +77,16 @@
     MBlindPixelCalc   blind;
     MHillasCalc       hcalc;
-    MFillH            hfill("MHillas", "MHHillas");
-    MFillH            sfill("MHillas", "MHStarMap");
+    MHillasSrcCalc    csrc1("Source",  "HillasSource");
+    MHillasSrcCalc    csrc2("AntiSrc", "HillasAntiSrc");
 
-    //
-    // Crete and setup Tasklist
-    //
+    MFillH hfill("MHHillas",   "MHillas");
+    MFillH sfill("MHStarMap",  "MHillas");
+    MFillH hfill2s("HistSource  [MHHillasSrc]", "HillasSource");
+    MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
+
     MWriteRootFile write("hillas.root");
-    write.AddContainer("MHillas");
+    write.AddContainer("MHillas",       "Hillas");
+    write.AddContainer("HillasSource",  "Hillas");
+    write.AddContainer("HillasAntiSrc", "Hillas");
     write.AddContainer("MHStarMap");
 
@@ -90,6 +98,10 @@
     tlist.AddToList(&blind);
     tlist.AddToList(&hcalc);
+    tlist.AddToList(&csrc1);
+    tlist.AddToList(&csrc2);
     tlist.AddToList(&hfill);
     tlist.AddToList(&sfill);
+    tlist.AddToList(&hfill2s);
+    tlist.AddToList(&hfill2a);
     tlist.AddToList(&write);
 
@@ -112,4 +124,6 @@
     //
     plist.FindObject("MHHillas")->DrawClone();
+    plist.FindObject("HistSource")->DrawClone();
+    plist.FindObject("HistAntiSrc")->DrawClone();
     plist.FindObject("MHStarMap")->DrawClone();
 }
Index: /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc	(revision 1208)
+++ /trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc	(revision 1209)
@@ -67,5 +67,5 @@
     if (!fHillas)
     {
-        *fLog << dbginf << "MHillas not found... aborting." << endl;
+        *fLog << err << dbginf << "MHillas not found... aborting." << endl;
         return kFALSE;
     }
@@ -74,5 +74,5 @@
     if (!fSrcPos)
     {
-        *fLog << dbginf << "MSrcPosCam missing in Parameter List... aborting." << endl;
+        *fLog << err << dbginf << fSrcName << " [MSrcPosCam] not found... aborting." << endl;
         return kFALSE;
     }
Index: /trunk/MagicSoft/Mars/mfilter/MFAlpha.h
===================================================================
--- /trunk/MagicSoft/Mars/mfilter/MFAlpha.h	(revision 1208)
+++ /trunk/MagicSoft/Mars/mfilter/MFAlpha.h	(revision 1209)
@@ -4,5 +4,5 @@
 /////////////////////////////////////////////////////////////////////////////
 //                                                                         //
-// MFAlpha                                                           //
+// MFAlpha                                                                 //
 //                                                                         //
 /////////////////////////////////////////////////////////////////////////////
@@ -37,5 +37,5 @@
     Bool_t Process();
 
-    ClassDef(MFAlpha, 0)		// A Filter for the Level 1 Trigger
+    ClassDef(MFAlpha, 0) // A Filter for cuts in fabs(alpha)
 };
 
Index: /trunk/MagicSoft/Mars/mhist/MFillH.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 1208)
+++ /trunk/MagicSoft/Mars/mhist/MFillH.cc	(revision 1209)
@@ -30,9 +30,23 @@
 //  histogram which is derived from MH can be filled with this task.        //
 //                                                                          //
-//  You must specifiy the parameter container with which data the histogram //
-//  container should be filled, and the histogram container which has       //
-//  to be filled. This can be done by either specifing the name of the      //
-//  objects in the parameter list or by specifiing a pointer to the object. //
-//  (s. Constructor)                                                        //
+//  There are two options to use:                                           //
+//                                                                          //
+//  1) You specifiy the parameter container with which data the             //
+//     histogram container should be filled, and the histogram container    //
+//     which has to be filled. This can be done by either specifing the     //
+//     name of the objects in the parameter list or by specifiing a pointer //
+//     to the object. (s. Constructor)                                      //                  //
+//                                                                          //
+//  2) You specify the name and/or type of the histogram to become filled.  //
+//     Any other action imust be taken by the histogram class.              //
+//                                                                          //
+//  PreProcess: In the preprocessing of this task we setup all pointers     //
+//              to instances which are needed and call FillSetup of the     //
+//              histogram class with the parameter list as an argument.     //
+//                                                                          //
+//  Process: The process function calls the Fill member function of the     //
+//           histogram class instance (inheriting from MH) with either      //
+//           a NULL pointer or a pointer to the corresponding container     //
+//           as an argument.                                                //
 //                                                                          //
 //  WARNING:                                                                //
@@ -81,14 +95,77 @@
 // Constructor.
 //
-// - par is the name of the parameter container which should be filled into
-//   the histogram
-// - hist is the name of the histogram container (which must have been
-//   derived from MH)
-//
-MFillH::MFillH(const char *par, const char *hist, const char *name, const char *title)
+// 1) - par is the name of the parameter container which should be filled into
+//      the histogram
+//    - hist is the name of the histogram container (which must have been
+//      derived from MH)
+//
+//    In this case MH::Fill is called with a pointer to the corresponding
+//    histogram instance.
+//
+// 2) - hist is the name and/or type of the histogram.
+//      1) The name and type is identical, eg: "MHHillas"
+//      2) They are not identical, eg: "MyHistogram [MHHillas]"
+//         This searches for a class instance of MHHillas with the name
+//         "MyHistogram". If it doesn't exist one is created.
+//
+//    In this case PreProcess calls MH::SetupFill with a pointer to the
+//    parameter list and MH::Fill is called with a NULL-pointer.
+//
+MFillH::MFillH(const char *hist, const char *par, const char *name, const char *title)
 {
     Init(name, title);
 
     fHName = hist;
+    fParContainerName = par;
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+// 1) - par is a pointer to the instance of your parameter container from which
+//      the data should be used to fill the histogram.
+//    - hist is the name of the histogram container (which must have been
+//      derived from MH)
+//
+//    In this case MH::Fill is called with a pointer to the corresponding
+//    histogram instance.
+//
+// 2) - hist is the name and/or type of the histogram.
+//      1) The name and type is identical, eg: "MHHillas"
+//      2) They are not identical, eg: "MyHistogram [MHHillas]"
+//         This searches for a class instance of MHHillas with the name
+//         "MyHistogram". If it doesn't exist one is created. Everything
+//         which is between the first '[' and the last ']' in the string
+//         is used as the histogram type.
+//
+//    In this case PreProcess calls MH::SetupFill with a pointer to the
+//    parameter list and MH::Fill is called with a NULL-pointer.
+//
+//
+MFillH::MFillH(const char *hist, const MParContainer *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fHName = hist;
+    fParContainer = par;
+    fParContainerName = par->GetName();
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+// - par is a pointer to the instance of your parameter container from which
+//   the data should be used to fill the histogram.
+// - hist is a pointer to the instance of your histogram container (which must
+//   have been derived from MH) into which the data should flow
+//
+MFillH::MFillH(MH *hist, const char *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fH = hist;
+    fHName = hist->GetName();
     fParContainerName = par;
 }
@@ -103,41 +180,5 @@
 //   derived from MH)
 //
-MFillH::MFillH(const MParContainer *par, const char *hist, const char *name, const char *title)
-{
-    Init(name, title);
-
-    fHName = hist;
-    fParContainer = par;
-    fParContainerName = par->GetName();
-}
-
-// --------------------------------------------------------------------------
-//
-// Constructor.
-//
-// - par is a pointer to the instance of your parameter container from which
-//   the data should be used to fill the histogram.
-// - hist is a pointer to the instance of your histogram container (which must
-//   have been derived from MH) into which the data should flow
-//
-MFillH::MFillH(const char *par, MH *hist, const char *name, const char *title)
-{
-    Init(name, title);
-
-    fH = hist;
-    fHName = hist->GetName();
-    fParContainerName = par;
-}
-
-// --------------------------------------------------------------------------
-//
-// Constructor.
-//
-// - par is a pointer to the instance of your parameter container from which
-//   the data should be used to fill the histogram.
-// - hist is the name of the histogram container (which must have been
-//   derived from MH)
-//
-MFillH::MFillH(const MParContainer *par, MH *hist, const char *name, const char *title)
+MFillH::MFillH(MH *hist, const MParContainer *par, const char *name, const char *title)
 {
     Init(name, title);
@@ -147,4 +188,33 @@
     fParContainer = par;
     fParContainerName = par->GetName();
+}
+
+TString MFillH::ExtractName(const char *name) const
+{
+    TString type = name;
+
+    const Ssiz_t first = type.First('[');
+    const Ssiz_t last  = type.First(']');
+
+    if (!first || !last || first>=last)
+        return type;
+
+    return type.Remove(first).Strip(TString::kBoth);
+}
+
+TString MFillH::ExtractClass(const char *name) const
+{
+    TString type = name;
+
+    const Ssiz_t first = type.First('[');
+    const Ssiz_t last  = type.First(']');
+
+    if (!first || !last || first>=last)
+        return type;
+
+    const Ssiz_t length = last-first-1;
+
+    TString strip = fHName(first+1, length);
+    return strip.Strip(TString::kBoth);
 }
 
@@ -159,29 +229,58 @@
 Bool_t MFillH::PreProcess(MParList *pList)
 {
-    if (!fParContainer)
+    //
+    // Try to get the histogram container with name fHName from list
+    // or create one with this name
+    //
+    if (!fH)
     {
-        fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
-        if (!fParContainer)
+        const TString cls  = ExtractClass(fHName);
+        const TString name = ExtractName(fHName);
+
+        TObject *obj = pList->FindCreateObj(cls, name);
+        if (!obj)
+            return kFALSE;
+
+        //
+        // We were successfull getting it. Check whether it really inherits
+        // from MH, FindCreateObj does only check for inheritance from
+        // 'type'.
+        //
+        if (!obj->InheritsFrom(MH::Class()))
         {
-            *fLog << err << dbginf << fParContainerName << " [MParContainer] not found... aborting." << endl;
+            *fLog << err << dbginf << obj->GetName() << " doesn't inherit ";
+            *fLog << "from MH - cannot be used for MFillH... aborting." << endl;
             return kFALSE;
         }
+
+        fH = (MH*)obj;
     }
 
-    if (!fH)
+    //
+    // Now we have the histogram container available. Try to Setup Fill.
+    //
+    if (!fH->SetupFill(pList))
     {
-        fH = (MH*)pList->FindCreateObj(fHName);
-        if (!fH)
-            return kFALSE;
-    }
-
-    if (!fH->InheritsFrom("MH"))
-    {
-        *fLog << err << dbginf << fH->GetDescriptor() << " ";
-        *fLog << "doesn't inherit from MH - cannot be used for MFillH... aborting." << endl;
+        *fLog << err << dbginf << "Error: calling SetupFill for ";
+        *fLog << fH->GetDescriptor() << "... aborting." << endl;
         return kFALSE;
     }
 
-    return kTRUE;
+    //
+    // If also a parameter container is already set we are done.
+    //
+    if (fParContainer)
+        return kTRUE;
+
+    //
+    // If a name is given try to find the input container in the
+    // list. If it could not be found we cannot proceed.
+    //
+    fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
+    if (fParContainer)
+        return kTRUE;
+
+    *fLog << err << dbginf << fParContainerName << " [MParContainer] not found... aborting." << endl;
+    return kFALSE;
 }
 
@@ -192,7 +291,5 @@
 Bool_t MFillH::Process()
 {
-    fH->Fill(fParContainer);
-
-    return kTRUE;
+    return fH->Fill(fParContainer);
 } 
 
Index: /trunk/MagicSoft/Mars/mhist/MFillH.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MFillH.h	(revision 1208)
+++ /trunk/MagicSoft/Mars/mhist/MFillH.h	(revision 1209)
@@ -18,11 +18,14 @@
     TString fHName;
 
+    TString ExtractName(const char *name) const;
+    TString ExtractClass(const char *name) const;
+
     void Init(const char *name, const char *title);
 
 public:
-    MFillH(const char *par,          const char *hist, const char *name=NULL, const char *title=NULL);
-    MFillH(const MParContainer *par, const char *hist, const char *name=NULL, const char *title=NULL);
-    MFillH(const char *par,          MH *hist,         const char *name=NULL, const char *title=NULL);
-    MFillH(const MParContainer *par, MH *hist,         const char *name=NULL, const char *title=NULL);
+    MFillH(const char *hist, const char *par=NULL,     const char *name=NULL, const char *title=NULL);
+    MFillH(const char *hist, const MParContainer *par, const char *name=NULL, const char *title=NULL);
+    MFillH(MH *hist,         const char *par=NULL,     const char *name=NULL, const char *title=NULL);
+    MFillH(MH *hist,         const MParContainer *par, const char *name=NULL, const char *title=NULL);
 
     Bool_t PreProcess(MParList *pList);
Index: /trunk/MagicSoft/Mars/mhist/MHHillas.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHHillas.h	(revision 1208)
+++ /trunk/MagicSoft/Mars/mhist/MHHillas.h	(revision 1209)
@@ -27,5 +27,5 @@
     TObject *DrawClone(Option_t *opt=NULL) const;
 
-    ClassDef(MHHillas, 1) // Container which hilds hostograms for the Hillas parameters
+    ClassDef(MHHillas, 1) // Container which holds histograms for length and width
 };
 
Index: /trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc	(revision 1208)
+++ /trunk/MagicSoft/Mars/mhist/MHHillasSrc.cc	(revision 1209)
@@ -100,5 +100,5 @@
 // --------------------------------------------------------------------------
 //
-// Draw clones of all four histograms. So that the object can be deleted
+// Draw clones of all two histograms. So that the object can be deleted
 // and the histograms are still visible in the canvas.
 // The cloned object are deleted together with the canvas if the canvas is
@@ -108,7 +108,9 @@
 TObject *MHHillasSrc::DrawClone(Option_t *opt) const
 {
-    TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Hillas Parameters",
+    TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Source dependant Parameters",
                                350, 500);
     c->Divide(1, 2);
+
+    // FIXME: Display Source position
 
     gROOT->SetSelectedPad(NULL);
@@ -131,5 +133,5 @@
 // --------------------------------------------------------------------------
 //
-// Creates a new canvas and draws the four histograms into it.
+// Creates a new canvas and draws the two histograms into it.
 // Be careful: The histograms belongs to this object and won't get deleted
 // together with the canvas.
@@ -138,5 +140,7 @@
 {
     if (!gPad)
-        MakeDefCanvas("Hillas", "Histograms of Hillas Parameters", 350, 500);
+        MakeDefCanvas("Hillas", "Histograms of Src dependant Parameters", 350, 500);
+
+    // FIXME: Display Source position
 
     gPad->Divide(1, 2);
Index: /trunk/MagicSoft/Mars/mhist/MHHillasSrc.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHHillasSrc.h	(revision 1208)
+++ /trunk/MagicSoft/Mars/mhist/MHHillasSrc.h	(revision 1209)
@@ -27,5 +27,5 @@
     TObject *DrawClone(Option_t *opt=NULL) const;
 
-    ClassDef(MHHillasSrc, 1) // Container which hilds hostograms for the Hillas parameters
+    ClassDef(MHHillasSrc, 1) // Container which holds histograms for the source dependant parameters
 };
 
Index: /trunk/MagicSoft/Mars/mmain/MAnalysis.cc
===================================================================
--- /trunk/MagicSoft/Mars/mmain/MAnalysis.cc	(revision 1208)
+++ /trunk/MagicSoft/Mars/mmain/MAnalysis.cc	(revision 1209)
@@ -132,4 +132,6 @@
 #include "MBlindPixelCalc.h"
 #include "MHillasCalc.h"
+#include "MHillasSrcCalc.h"
+#include "MSrcPosCam.h"
 #include "MFillH.h"
 #include "MEvtLoop.h"
@@ -161,6 +163,12 @@
     plist.AddToList(&geomcam);
 
-    MPedestalCam pedest;
-    plist.AddToList(&pedest);
+    MSrcPosCam source("Source");
+    source.SetXY(0, 0);
+
+    MSrcPosCam antisrc("AntiSrc");
+    antisrc.SetXY(240, 0);
+
+    plist.AddToList(&source);
+    plist.AddToList(&antisrc);
 
     //
@@ -187,4 +195,12 @@
     MBlindPixelCalc    blind;
     MHillasCalc        hcalc;
+    MHillasSrcCalc    csrc1("Source",     "HillasSource");
+    MHillasSrcCalc    csrc2("AntiSource", "HillasAntiSrc");
+
+    MFillH hfill("MHHillas",   "MHillas");
+    MFillH sfill("MHStarMap",  "MHillas");
+
+    MFillH hfill2s("HistSource  [MHHillasSrc]", "HillasSource");
+    MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
 
     tlist.AddToList(&read);
@@ -195,10 +211,13 @@
     tlist.AddToList(&blind);
     tlist.AddToList(&hcalc);
-
-    MFillH hfill("MHillas", "MHHillas");
-    MFillH sfill("MHillas", "MHStarMap");
+    tlist.AddToList(&csrc1);
+    tlist.AddToList(&csrc2);
 
     if (displhillas)
+    {
         tlist.AddToList(&hfill);
+        tlist.AddToList(&hfill2s);
+        tlist.AddToList(&hfill2a);
+    }
 
     if (displstarmap)
@@ -234,5 +253,9 @@
     //
     if (displhillas)
+    {
         plist.FindObject("MHHillas")->DrawClone();
+        plist.FindObject("HistSource")->DrawClone();
+        plist.FindObject("HistAntiSrc")->DrawClone();
+    }
 
     if (displstarmap)
