Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7441)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7442)
@@ -18,4 +18,19 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2005/12/06 Thomas Bretz
+
+   * mbase/MEnv.[h,cc]:
+     - added new function to get fillstyle by name
+     - added new function to get attributes of a TPave
+
+   * mbase/MTime.cc:
+     - fixed layout of a comment
+
+   * mhflux/MAlphaFitter.[h,cc]:
+     - added a function to calc upper limits
+     - exchaged some GetListOfFunctions()-Remove() with SetName
+
+
+
  2005/12/01 Thomas Bretz
 
@@ -110,4 +125,7 @@
    * mjobs/MJCut.cc:
      - output is called "Hadronness" not "MHadronness"
+
+   * mjtrain/MJTrainDisp.cc, mjtrain/MJTrainEnergy.cc:
+     - fixed bug which caused the traincuts to be ignored
 
 
Index: trunk/MagicSoft/Mars/mbase/MEnv.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEnv.cc	(revision 7441)
+++ trunk/MagicSoft/Mars/mbase/MEnv.cc	(revision 7442)
@@ -37,7 +37,8 @@
 #include <TObjString.h>
 
+#include <TPave.h>
 #include <TAttText.h>
-#include <TAttFill.h>
-#include <TAttLine.h>
+//#include <TAttFill.h>
+//#include <TAttLine.h>
 #include <TAttMarker.h>
 
@@ -68,4 +69,23 @@
         fChecked.Add(new TObjString(name));
     return TEnv::GetValue(name, dflt);
+}
+
+Int_t MEnv::GetFillStyle(const char *name, Int_t dftl)
+{
+    TString str = GetValue(name, "");
+    str = str.Strip(TString::kBoth);
+    if (str.IsNull())
+        return dftl;
+
+    str.ToLower();
+
+    switch (str.Hash())
+    {
+    case (unsigned)-1920099718/*2374867578*/: return 0;// hollow
+    case 764279305:  return 1001;// solid
+    case 1854683492: return 2001; // hatch
+    }
+
+    return str.EndsWith("%") ? 4000+str.Atoi() : str.Atoi();
 }
 
@@ -106,5 +126,5 @@
 TString MEnv::Compile(TString str, const char *post) const
 {
-    if (!str.IsNull() && str[str.Length()-1]!='.')
+    if (!str.IsNull() && !str.EndsWith("."))
         str += ".";
 
@@ -165,6 +185,6 @@
 
     const Color_t col = GetColor(color, dftl->GetFillColor());
-    const Style_t sty = GetValue(style, dftl->GetFillStyle());
-
+    const Style_t sty = GetFillStyle(style, dftl->GetFillStyle());
+ 
     fill.SetFillColor(col);
     fill.SetFillStyle(sty);
@@ -187,4 +207,43 @@
     marker.SetMarkerStyle(sty);
     marker.SetMarkerSize(siz);
+}
+
+void MEnv::GetAttPave(const char *str, TPave &pave, TPave *dftl)
+{
+    const TString post(str);
+
+    TString name(pave.GetName());
+    if (!name.IsNull() && name!=pave.ClassName())
+        name = Compile(name, post);
+
+    GetAttLine(name, pave, dftl);
+    GetAttFill(name, pave, dftl);
+
+    const TString corner = Compile(name, "CornerRadius");
+    const TString border = Compile(name, "BorderSize");
+    const TString option = Compile(name, "Option");
+
+    if (!dftl)
+        dftl = &pave;
+
+    const Double_t cor = GetValue(corner, dftl->GetCornerRadius());
+    const Int_t    bor = GetValue(border, dftl->GetBorderSize());
+
+    pave.SetCornerRadius(cor);
+    pave.SetBorderSize(bor);
+
+    TString  opt = GetValue(option, dftl->GetOption());
+    opt.ToLower();
+
+    const Bool_t has = pave.GetCornerRadius()>0;
+
+    if (has && !opt.Contains("arc"))
+        opt += "arc";
+
+    if (!has && opt.Contains("arc"))
+        opt.ReplaceAll("arc", "");
+
+    pave.SetOption(opt);
+
 }
 
@@ -204,4 +263,5 @@
     //TAttTextEditor   *line = dynamic_cast<TAttTextEditor*>(obj);
 
+    TPave      *pave = dynamic_cast<TPave*>(/*(TAttLine*)*/obj);
     TAttLine   *line = dynamic_cast<TAttLine*>(/*(TAttLine*)*/obj);
     TAttText   *text = dynamic_cast<TAttText*>(/*(TAttText*)*/obj);
@@ -210,4 +270,10 @@
 
     cout << line << " " << text << " " << fill << " " << mark << endl;
+
+    if (pave)
+    {
+        GetAttPave(name, *pave, dynamic_cast<TPave*>(dftl));
+        return;
+    }
 
     if (line)
@@ -228,4 +294,5 @@
     TIter Next(GetTable());
     TObject *o=0;
+
     while ((o=Next()))
         if (!fChecked.FindObject(o->GetName()))
Index: trunk/MagicSoft/Mars/mbase/MEnv.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MEnv.h	(revision 7441)
+++ trunk/MagicSoft/Mars/mbase/MEnv.h	(revision 7442)
@@ -14,4 +14,5 @@
 class TAttText;
 class TAttFill;
+class TPave;
 
 class MEnv : public TEnv
@@ -30,4 +31,5 @@
 
     Int_t       GetColor(const char *name, Int_t dftl);
+    Int_t       GetFillStyle(const char *name, Int_t dftl);
 
     void        GetAttributes(const char *name, TObject *obj, TObject *dftl=0);
@@ -36,4 +38,5 @@
     void        GetAttFill(const char *name, TAttFill &fill, TAttFill *dftl=0);
     void        GetAttMarker(const char *name, TAttMarker &marker, TAttMarker *dftl=0);
+    void        GetAttPave(const char *name, TPave &pave, TPave *dftl=0);
 
     void PrintUntouched() const;
Index: trunk/MagicSoft/Mars/mbase/MTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTime.cc	(revision 7441)
+++ trunk/MagicSoft/Mars/mbase/MTime.cc	(revision 7442)
@@ -532,5 +532,5 @@
 // The maximum size of the return string is 128 (incl. NULL)
 //
-// For dates before 1.1.1902  a null string is returned
+// For dates before 1. 1.1902  a null string is returned
 // For dates after 31.12.2037 a null string is returned
 //
Index: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 7441)
+++ trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 7442)
@@ -47,4 +47,5 @@
 
 #include <TRandom.h>
+#include <TFeldmanCousins.h>
 
 #include <TLine.h>
@@ -256,4 +257,24 @@
 
     return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the upper limit for fEventsSignal number of observed events
+// and fEventsBackground number of background events.
+//
+// Therefor TFeldmanCousin is used.
+//
+// The Feldman-Cousins method as described in PRD V57 #7, p3873-3889
+//
+Double_t MAlphaFitter::CalcUpperLimit() const
+{
+    // get a FeldmanCousins calculation object with the default limits
+    // of calculating a 90% CL with the minimum signal value scanned
+    // = 0.0 and the maximum signal value scanned of 50.0
+    TFeldmanCousins f;
+    f.SetMuStep(0.05);
+    f.SetMuMax(100);
+    return f.CalculateUpperLimit(fEventsSignal, fEventsBackground);
 }
 
@@ -315,6 +336,6 @@
     TF1 *fcn = f.fFunc;
     f.fFunc = new TF1(*fFunc);
+    f.fFunc->SetName("Dummy");
     gROOT->GetListOfFunctions()->Remove(f.fFunc);
-    f.fFunc->SetName("Dummy");
     delete fcn;
 }
Index: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 7441)
+++ trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 7442)
@@ -53,6 +53,6 @@
     SignalFunc_t fSignalFunc;   // Type of signal function
     // Result
-    Double_t fSignificance;     // significance of signal
-    Double_t fSignificanceExc;  // significance of excess
+    Double_t fSignificance;     // significance of an unknown signal (Li/Ma 17)
+    Double_t fSignificanceExc;  // significance of a known excess    (Li/Ma 5)
     Double_t fEventsExcess;     // calculated number of excess events (signal-bg)
     Double_t fEventsSignal;     // calculated number of signal events
@@ -88,6 +88,6 @@
         fTitle = title ? title : "Fit alpha";
 
+        fFunc->SetName("Dummy");
         gROOT->GetListOfFunctions()->Remove(fFunc);
-        fFunc->SetName("Dummy");
 
         Clear();
@@ -147,6 +147,6 @@
         }
         fSignalFunc=func;
+        fFunc->SetName("Dummy");
         gROOT->GetListOfFunctions()->Remove(fFunc);
-        fFunc->SetName("Dummy");
         fCoefficients.Set(3+fPolynomOrder+1);
         fCoefficients.Reset();
@@ -175,4 +175,6 @@
     Double_t Eval(Double_t d) const { return fFunc ? fFunc->Eval(d) : 0; }
 
+    Double_t CalcUpperLimit() const;
+
     // Interface to fit
     Bool_t Fit(TH1D &h, Bool_t paint=kFALSE);
