Index: trunk/MagicSoft/Mars/mjobs/MJCut.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 6987)
+++ trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 6988)
@@ -77,6 +77,6 @@
 MJCut::MJCut(const char *name, const char *title)
     : fStoreSummary(kFALSE), fStoreResult(kTRUE), fWriteOnly(kFALSE),
-    fIsWobble(kFALSE), fIsMonteCarlo(kFALSE),  fFullDisplay(kFALSE), /*fSubstraction(kFALSE),*/
-    /*fEstimateEnergy(0),*/ fCalcHadronness(0)
+    fIsWobble(kFALSE), fIsMonteCarlo(kFALSE),  fFullDisplay(kFALSE),
+    fNameHist("MHTheta"), fCalcHadronness(0)
 {
     fName  = name  ? name  : "MJCut";
@@ -258,5 +258,5 @@
 
     // Save also the result, not only the setup
-    const MHAlpha *halpha = (MHAlpha*)plist.FindObject("MHAlpha");
+    const MHAlpha *halpha = (MHAlpha*)plist.FindObject(fNameHist, "MHAlpha");
     if (halpha)
         arr.Add((TObject*)(&halpha->GetAlphaFitter()));
@@ -285,4 +285,5 @@
 //   MJCut.WriteResult:  yes, no
 //   MJCut.ResultFile:   filename
+//   MJCut.HistName:     MHAlpha
 //
 Bool_t MJCut::CheckEnvLocal()
@@ -301,4 +302,6 @@
     EnableFullDisplay(GetEnv("FullDisplay", fFullDisplay));
     //EnableSubstraction(GetEnv("HistogramSubstraction", fSubstraction));
+
+    SetNameHist(GetEnv("NameHist", fNameHist));
 
     return kTRUE;
@@ -341,15 +344,33 @@
 }
 
-void MJCut::DisplayResult(const MParList &plist) const
-{
-    /*
-     TObject *h1 = plist.FindObject("MHHillasOffPre",  "MHHillas");
-     TObject *h2 = plist.FindObject("MHHillasOffPost", "MHHillas");
-     TObject *h3 = plist.FindObject("MHVsSizeOffPost", "MHVsSize");
-     TObject *h4 = plist.FindObject("MHHilExtOffPost", "MHHillasExt");
-     TObject *h5 = plist.FindObject("MHHilSrcOffPost", "MHHillasSrc");
-     TObject *h6 = plist.FindObject("MHImgParOffPost", "MHImagePar");
-     TObject *h7 = plist.FindObject("MHNewParOffPost", "MHNewImagePar");
-     */
+// --------------------------------------------------------------------------
+//
+// Create a new instance of an object with name name of class
+// type fNameHist in parlist. It must derive from MHAlpha.
+// Call ForceUsingSize for it and return its pointer.
+// If something fails NULL is returned.
+//
+MHAlpha *MJCut::CreateNewHist(MParList &plist, const char *name) const
+{
+    TClass *cls = gROOT->GetClass(fNameHist);
+    if (!cls)
+    {
+        *fLog << err << "Class " << fNameHist << " not found in dictionary... abort." << endl;
+        return NULL;
+    }
+    if (!cls->InheritsFrom(MHAlpha::Class()))
+    {
+        *fLog << err << "Class " << fNameHist << " doesn't inherit from MHAlpha... abort." << endl;
+        return NULL;
+    }
+
+    const TString objname(Form("%s%s", fNameHist.Data(), name));
+    MHAlpha *h = (MHAlpha*)plist.FindCreateObj(fNameHist, objname);
+    if (!h)
+        return NULL;
+
+    h->ForceUsingSize();
+
+    return h;
 }
 
@@ -424,9 +445,6 @@
         fit.SetScaleMode(MAlphaFitter::kNone);
 
-    MHAlpha halphaoff("MHAlphaOff");
-    halphaoff.ForceUsingSize();
-    plist.AddToList(&halphaoff);
-
-    MFillH falpha("MHAlphaOff [MHAlpha]", "MHillasSrc", "FillAlpha");
+    MHAlpha *halphaoff = CreateNewHist(plist, "Off");
+    MFillH falpha(halphaoff, "MHillasSrc", "FillAlpha");
     MFillH ffs("MHFalseSourceOff [MHFalseSource]", "MHillas", "FillFS");
 
@@ -655,9 +673,6 @@
     }
     */
-    MHAlpha halphaon("MHAlpha");
-    halphaon.ForceUsingSize();
-    plist.AddToList(&halphaon);
-
-    MFillH falpha2("MHAlpha", "MHillasSrc", "FillAlpha");
+    MHAlpha *halphaon=CreateNewHist(plist);
+    MFillH falpha2(halphaon, "MHillasSrc", "FillAlpha");
     MFillH ffs2("MHFalseSource", "MHillas", "FillFS");
 
@@ -706,6 +721,4 @@
     tlist.PrintStatistics();
 
-    DisplayResult(plist);
-
     // FIXME: Perform fit and plot energy dependant alpha plots
     // and fit result to new tabs!
Index: trunk/MagicSoft/Mars/mjobs/MJCut.h
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCut.h	(revision 6987)
+++ trunk/MagicSoft/Mars/mjobs/MJCut.h	(revision 6988)
@@ -9,4 +9,5 @@
 class MDataSet;
 class MParList;
+class MHAlpha;
 class MWriteRootFile;
 
@@ -26,16 +27,18 @@
     TString fNameOutput;
 
+    TString fNameHist;
+
     //MTask *fEstimateEnergy;
     MTask *fCalcHadronness;
 
-    TString GetOutputFile(UInt_t num) const;
-    Bool_t  CheckEnvLocal();
-    void    SetupWriter(MWriteRootFile *write, const char *name) const;
-    Bool_t  WriteTasks(UInt_t num, TObjArray &cont) const;
-    Bool_t  WriteResult(const MParList &plist, UInt_t num) const;
-    void    DisplayResult(const MParList &plist) const;
+    TString  GetOutputFile(UInt_t num) const;
+    Bool_t   CheckEnvLocal();
+    void     SetupWriter(MWriteRootFile *write, const char *name) const;
+    Bool_t   WriteTasks(UInt_t num, TObjArray &cont) const;
+    Bool_t   WriteResult(const MParList &plist, UInt_t num) const;
+    MHAlpha *CreateNewHist(MParList &plist, const char *name="") const;
 
-    Bool_t  CanStoreSummary() const { return !fPathOut.IsNull() && fStoreSummary; }
-    Bool_t  CanStoreResult() const  { return !fPathOut.IsNull() && fStoreResult;  }
+    Bool_t   CanStoreSummary() const { return !fPathOut.IsNull() && fStoreSummary; }
+    Bool_t   CanStoreResult() const  { return !fPathOut.IsNull() && fStoreResult;  }
 
 public:
@@ -57,4 +60,6 @@
     void SetNameOutFile(const char *name="")      { fNameOutput=name; }
 
+    void SetNameHist(const char *name) { fNameHist=name; }
+
     //void SetEnergyEstimator(const MTask *task=0);
     void SetHadronnessCalculator(const MTask *task=0);
