Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7168)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7169)
@@ -21,4 +21,43 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2005/06/17 Thomas Bretz
+
+   * mbase/MArgs.[h,cc]:
+     - handle possible char \015 in arguments
+
+   * mdata/MDataArray.h:
+     - added Print function to //*MENU*
+
+   * mhflux/MAlphaFitter.[h,cc]:
+     - added new Option for Scale: Fixed
+     - fixed typo in IsEnvDefined for Signalfunction
+
+   * mhist/MHCamera.cc:
+     - plot profile in deg instead of mm
+
+   * mjobs/MDataSet.[h,cc]
+     - changed error handling when reading source catalog
+
+   * mjobs/MJCut.cc:
+     - added MImagePar to output
+     - take new error handling into account when reading source catalog
+
+   * mjobs/MJSpectrum.cc:
+     - print energy estimator
+     - removed the double minus displaying the fitted spectrum 
+
+   * mjoptim/MJOptimizeDisp.cc, mjoptim/MJOptimizeEnergy.cc:
+     - print rule when optimization has finished
+
+   * mmain/MBrowser.cc:
+     - replaced old path with new path to datacenter
+
+   * mranforest/MRFEnergyEst.[h,cc]:
+     - store binning in new data member fBinning to avoid many calles
+       to atof
+
+
+
  2005/06/15 Daniela Dorner
 
Index: trunk/MagicSoft/Mars/NEWS
===================================================================
--- trunk/MagicSoft/Mars/NEWS	(revision 7168)
+++ trunk/MagicSoft/Mars/NEWS	(revision 7169)
@@ -8,4 +8,8 @@
    - general: Added a class to correct for the missfocussing in
      April (MSrcPosCorrect)
+
+   - general: Random Forest energy estimator should now work properly
+
+   - general: MHCamera now displays the profiles in deg instead of mm
 
    - ganymed: the Conc1 plot was incorrectly scaled in MHVsSize
Index: trunk/MagicSoft/Mars/mbase/MArgs.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MArgs.cc	(revision 7168)
+++ trunk/MagicSoft/Mars/mbase/MArgs.cc	(revision 7169)
@@ -72,5 +72,4 @@
     {
         MArgsEntry &o = *new MArgsEntry(argv[i]);
-        dynamic_cast<TString&>(o) = o.Strip(TString::kBoth);
         fArgv->Add(&o);
     }
Index: trunk/MagicSoft/Mars/mbase/MArgs.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MArgs.h	(revision 7168)
+++ trunk/MagicSoft/Mars/mbase/MArgs.h	(revision 7169)
@@ -13,5 +13,9 @@
 {
 public:
-    MArgsEntry(const char *c) : TString(c), TObject() {}
+    MArgsEntry(const char *c) : TString(c), TObject()
+    {
+        ReplaceAll("\015", "");
+        dynamic_cast<TString&>(*this) = Strip(TString::kBoth);
+    }
 
     void Print(const Option_t *o) const;
Index: trunk/MagicSoft/Mars/mdata/MDataArray.h
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataArray.h	(revision 7168)
+++ trunk/MagicSoft/Mars/mdata/MDataArray.h	(revision 7169)
@@ -51,5 +51,5 @@
     TString GetDataMember() const;
 
-    void Print(Option_t *opt = "") const;
+    void Print(Option_t *opt = "") const; //*MENU*
     Bool_t AsciiWrite(ostream &out) const;
 
Index: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 7168)
+++ trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 7169)
@@ -624,5 +624,9 @@
         rc = kTRUE;
     }
-
+    if (IsEnvDefined(env, prefix, "Scale", print))
+    {
+        fScaleUser = GetEnvValue(env, prefix, "Scale", fScaleUser);
+        rc = kTRUE;
+    }
     if (IsEnvDefined(env, prefix, "ScaleMode", print))
     {
@@ -644,7 +648,13 @@
         if (txt==(TString)"userscale")
             fScaleMode = kUserScale;
-        rc = kTRUE;
-    }
-    if (IsEnvDefined(env, prefix, "Signalfunction", print))
+        if (txt==(TString)"fixed")
+        {
+            fScaleMode = kUserScale;
+            fScaleUser = fScaleFactor;
+            cout << "---------> " << fScaleFactor << " <----------" << endl;
+        }
+        rc = kTRUE;
+    }
+    if (IsEnvDefined(env, prefix, "SignalFunction", print))
     {
         TString txt = GetEnvValue(env, prefix, "SignalFunction", "");
@@ -657,10 +667,5 @@
         rc = kTRUE;
     }
-    if (IsEnvDefined(env, prefix, "Scale", print))
-    {
-        fScaleUser = GetEnvValue(env, prefix, "Scale", fScaleUser);
-        rc = kTRUE;
-    }
-
-    return rc;
-}
+
+    return rc;
+}
Index: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 7168)
+++ trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 7169)
@@ -51,5 +51,5 @@
     Int_t   fPolynomOrder;      // order of polyom to be fitted to the background
     Bool_t  fFitBackground;     // Backround fit: yes/no
-    SignalFunc_t fSignalFunc;  // Type of signal function
+    SignalFunc_t fSignalFunc;   // Type of signal function
     // Result
     Double_t fSignificance;     // significance of signal
@@ -61,5 +61,5 @@
     Double_t fChiSqBg;          // Reduced (chi^2/NDF) chisq of bg fit
     Double_t fIntegralMax;      // Calculated bin border to which it was integrated
-    Double_t fScaleFactor;      // Scale factor for off-data
+    Double_t fScaleFactor;      // Scale factor determined for off-data
 
     TArrayD fCoefficients;      // Fit result
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 7168)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 7169)
@@ -717,6 +717,8 @@
     }
 
+    const Double_t m2d = fGeomCam->GetConvMm2Deg();
+
     Double_t min = 0.;
-    Double_t max = fGeomCam->GetMaxRadius();
+    Double_t max = fGeomCam->GetMaxRadius()*m2d;
 
     Int_t newbins=0;
@@ -730,5 +732,5 @@
     for (Int_t idx=0; idx<fNcells-2; idx++)
         if (IsUsed(idx) && MatchSector(idx, sector, aidx))
-            h1->Fill(TMath::Hypot((*fGeomCam)[idx].GetX(),(*fGeomCam)[idx].GetY()),
+            h1->Fill(TMath::Hypot((*fGeomCam)[idx].GetX(),(*fGeomCam)[idx].GetY())*m2d,
                      GetBinContent(idx+1));
     return h1;
@@ -910,4 +912,5 @@
 
         Float_t x = pix.GetX()*conv/(fAbberation+1);
+
         Float_t y = pix.GetY()*conv/(fAbberation+1);
         Float_t d = pix.GetD()*conv;
Index: trunk/MagicSoft/Mars/mjobs/MJCut.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 7168)
+++ trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 7169)
@@ -331,4 +331,5 @@
     write->AddContainer("MPointingPos",   "Events");
     write->AddContainer("MHillasSrcAnti", "Events", kFALSE);
+    write->AddContainer("MImagePar",      "Events", kFALSE);
     write->AddContainer("MNewImagePar",   "Events", kFALSE);
     write->AddContainer("MNewImagePar2",  "Events", kFALSE);
@@ -338,10 +339,4 @@
     write->AddContainer("MMcEvt",         "Events", kFALSE);
     write->AddContainer("DataType",       "Events");
-
-    // Should not be the default: Either as option, or as
-    // setup from resource file
-    // write.AddContainer("MHillasExt",    "Events");
-    // write.AddContainer("MImagePar",     "Events");
-    // write.AddContainer("MNewImagePar",  "Events");
 }
 
@@ -439,6 +434,8 @@
     // Possible source position (eg. Wobble Mode)
     MPointingPos source("MSourcePos");
-    if (set.GetSourcePos(source))
-    {
+    if (set.HasSource())
+    {
+        if (!set.GetSourcePos(source))
+            return kFALSE;
         plist.AddToList(&source);
         *fLog << inf << "Using Source Position: " << source.GetTitle() << endl;
Index: trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 7168)
+++ trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 7169)
@@ -637,5 +637,5 @@
     TString str;
     str += Form("(%.2f#pm%.2f)10^{%d}", p1/exp, e1/exp, np);
-    str += Form("(\\frac{E}{TeV})^{-%.2f#pm%.2f}", p0, e0);
+    str += Form("(\\frac{E}{TeV})^{%.2f#pm%.2f}", p0, e0);
     str += "\\frac{ph}{TeVm^{2}s}";
 
@@ -814,5 +814,5 @@
             TLatex tex;
             tex.SetBit(TLatex::kTextNDC);
-            tex.DrawLatex(0.7, 0.93, Form("P(\\chi^{2})=%.0f", p*100));
+            tex.DrawLatex(0.75, 0.93, Form("P(\\chi^{2})=%.0f%%", p*100));
         }
     }
@@ -1063,4 +1063,10 @@
     }
 
+    gLog.Separator("Energy Estimator");
+    if (plist.FindObject("EstimateEnergy"))
+        plist.FindObject("EstimateEnergy")->Print();
+
+    gLog.Separator("Spectrum");
+
     // -------------------------- Spectrum ----------------------------
 
Index: trunk/MagicSoft/Mars/mjoptim/MJOptimizeDisp.cc
===================================================================
--- trunk/MagicSoft/Mars/mjoptim/MJOptimizeDisp.cc	(revision 7168)
+++ trunk/MagicSoft/Mars/mjoptim/MJOptimizeDisp.cc	(revision 7169)
@@ -184,4 +184,5 @@
 
     // Print the result
+    *fLog << inf << "Rule: " << rule << endl;
     hist.GetAlphaFitter().Print("result");
 
Index: trunk/MagicSoft/Mars/mjoptim/MJOptimizeEnergy.cc
===================================================================
--- trunk/MagicSoft/Mars/mjoptim/MJOptimizeEnergy.cc	(revision 7168)
+++ trunk/MagicSoft/Mars/mjoptim/MJOptimizeEnergy.cc	(revision 7169)
@@ -143,4 +143,5 @@
 
     // Print the result
+    *fLog << inf << "Rule: " << rule << endl;
     hist.Print();
 
Index: trunk/MagicSoft/Mars/mmain/MBrowser.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MBrowser.cc	(revision 7168)
+++ trunk/MagicSoft/Mars/mmain/MBrowser.cc	(revision 7169)
@@ -141,6 +141,6 @@
         dir->GetListBox()->Resize(100, 150);
         TGTreeLBEntry *entry = new TGTreeLBEntry(dir->GetListBox()->GetContainer(),
-                                                 new TGString("/data/MAGIC"), pic0, 6000,
-                                                 new TGString("/data/MAGIC"));
+                                                 new TGString("/magic/data"), pic0, 6000,
+                                                 new TGString("/magic/data"));
         TGLayoutHints *laylb = new TGLayoutHints(kLHintsLeft|kLHintsTop, 14, 0, 0, 0);
         dir->AddEntry(entry, laylb);
Index: trunk/MagicSoft/Mars/mranforest/MRFEnergyEst.cc
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRFEnergyEst.cc	(revision 7168)
+++ trunk/MagicSoft/Mars/mranforest/MRFEnergyEst.cc	(revision 7169)
@@ -70,5 +70,5 @@
 MRFEnergyEst::MRFEnergyEst(const char *name, const char *title)
     : fNumTrees(-1), fNumTry(-1), fNdSize(-1), fDebug(kFALSE),
-    fData(0), fEnergyEst(0), fTestMatrix(0)
+    fData(0), fEnergyEst(0), fTestMatrix(0), fEstimationMode(kMean)
 {
     fName  = name  ? name  : gsDefName.Data();
@@ -91,8 +91,6 @@
     }
 
-    const TMatrix &m = matrixtrain.GetM();
-
-    const Int_t ncols = m.GetNcols();
-    const Int_t nrows = m.GetNrows();
+    const Int_t ncols = matrixtrain.GetM().GetNcols();
+    const Int_t nrows = matrixtrain.GetM().GetNrows();
     if (ncols<=0 || nrows <=0)
     {
@@ -132,4 +130,5 @@
         Int_t irow0=0;
 
+        const TMatrix &m = matrixtrain.GetM();
         for (Int_t j=0; j<nrows; j++)
         {
@@ -165,6 +164,6 @@
         MHMatrix matrix0(mat0, "MatrixGammas");
 
-        matrix1.AddColumns(&usedrules);
-        matrix0.AddColumns(&usedrules);
+        //matrix1.AddColumns(&usedrules);
+        //matrix0.AddColumns(&usedrules);
 
         // training of RF
@@ -186,9 +185,9 @@
         evtloop.SetParList(&plist);
 
+        if (!evtloop.Eventloop())
+            return kFALSE;
+
         if (fDebug)
             gLog.SetNullOutput(kFALSE);
-
-        if (!evtloop.Eventloop())
-            return kFALSE;
 
         const Double_t E = (log10(grid[ie])+log10(grid[ie+1]))/2;
@@ -220,4 +219,6 @@
     fEForests.Delete();
 
+    Int_t i=0;
+
     TIter Next(fileRF.GetListOfKeys());
     TObject *o=0;
@@ -231,4 +232,7 @@
         forest->SetTitle(o->GetTitle());
         forest->SetBit(kCanDelete);
+
+        fBinning.Set(i+1);
+        fBinning[i++] = atof(o->GetTitle());
 
         fEForests.Add(forest);
@@ -289,4 +293,8 @@
     Double_t eest = 0;
     Double_t hsum = 0;
+    Double_t maxh = 0;
+    Double_t maxe = 0;
+
+    Int_t i=0;
 
     TIter Next(&fEForests);
@@ -295,11 +303,24 @@
     {
         const Double_t h = rf->CalcHadroness(event);
-        const Double_t e = atof(rf->GetTitle());
+        const Double_t e = fBinning[i++];
 
         hsum += h;
         eest += e*h;
-    }
-
-    fEnergyEst->SetVal(pow(10, eest/hsum));
+        if (h>maxh)
+        {
+            maxh = h;
+            maxe = e;
+        }
+    }
+
+    switch (fEstimationMode)
+    {
+    case kMean:
+        fEnergyEst->SetVal(pow(10, eest/hsum));
+        break;
+    case kMaximum:
+        fEnergyEst->SetVal(pow(10, maxe));
+        break;
+    }
     fEnergyEst->SetReadyToSave();
 
@@ -323,4 +344,15 @@
         SetDebug(GetEnvValue(env, prefix, "Debug", fDebug));
     }
+    if (IsEnvDefined(env, prefix, "EstimationMode", print))
+    {
+        TString txt = GetEnvValue(env, prefix, "EstimationMode", "");
+        txt = txt.Strip(TString::kBoth);
+        txt.ToLower();
+        if (txt==(TString)"mean")
+            fEstimationMode = kMean;
+        if (txt==(TString)"maximum")
+            fEstimationMode = kMaximum;
+        rc = kTRUE;
+    }
     return rc;
 }
Index: trunk/MagicSoft/Mars/mranforest/MRFEnergyEst.h
===================================================================
--- trunk/MagicSoft/Mars/mranforest/MRFEnergyEst.h	(revision 7168)
+++ trunk/MagicSoft/Mars/mranforest/MRFEnergyEst.h	(revision 7169)
@@ -9,6 +9,7 @@
 #include <TObjArray.h>
 #endif
-
-class TArrayD;
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
 
 class MHMatrix;
@@ -18,4 +19,10 @@
 class MRFEnergyEst : public MTask
 {
+public:
+    enum EstimationMode_t
+    {
+        kMean,
+        kMaximum
+    };
 private:
     Int_t        fNumTrees;  // Training parameters
@@ -32,4 +39,8 @@
 
     MHMatrix *fTestMatrix;
+
+    TArrayD   fBinning;
+
+    EstimationMode_t fEstimationMode;
 
     Int_t PreProcess(MParList *plist);
@@ -52,5 +63,7 @@
     void  InitMapping(MHMatrix *m=0)   { fTestMatrix=m; }
 
-    void SetDebug(Bool_t b=kTRUE)      { fDebug = b; }
+    void  SetDebug(Bool_t b=kTRUE)     { fDebug = b; }
+
+    void  SetEstimationMode(EstimationMode_t op) { fEstimationMode = op; }
 
     Int_t Train(const MHMatrix &n, const TArrayD &grid);
