Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 5099)
+++ trunk/MagicSoft/Mars/Changelog	(revision 5100)
@@ -19,4 +19,38 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2004/09/17: Thomas Bretz
+
+   * mhcalib/MH*.[h,cc]:
+     - redone some changes from yesterday - for unknown reason they
+       were lost
+
+   * mbase/MTask.cc:
+     - make sure that the correct number of executions is returned
+       counter which cannot be reset properly)
+
+   * mdata/MDataArray.cc:
+     - some changes to Print-output
+
+   * mfbase/MF.[h,cc]:
+     - added GetRule
+
+   * mfileio/MReadTree.cc:
+     - some improvements to output
+
+   * mhbase/MHMatrix.cc:
+     - some improvements in Print
+
+   * mhflux/MAlphaFitter.[h,cc]:
+     - calculate the significance also from the first bins
+     - added Copy
+     - added print
+
+   * mhflux/MHAlpha.[h,cc]:
+     - added some fFit.Print to keep track of what's going on
+
+   * mhflux/MHFalseSource.cc:
+     - made lines of 2D-Gauss smaller
+
+
 
  2004/09/16: Abelardo Moralejo
@@ -31,4 +65,5 @@
 
 
+
  2004/09/16: Markus Gaug
 
@@ -40,4 +75,5 @@
      - re-installed the Clone-function. Without, DrawClone() does not 
        Clone()
+
 
 
Index: trunk/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 5099)
+++ trunk/MagicSoft/Mars/mbase/MTask.cc	(revision 5100)
@@ -201,5 +201,9 @@
 Int_t MTask::CallPreProcess(MParList *plist)
 {
-    fStopwatch->Reset();
+    // This does not reset the counter!
+    // fStopwatch->Reset();
+
+    delete fStopwatch;
+    fStopwatch = new TStopwatch;
 
     *fLog << all << fName << "... " << flush;
Index: trunk/MagicSoft/Mars/mdata/MDataArray.cc
===================================================================
--- trunk/MagicSoft/Mars/mdata/MDataArray.cc	(revision 5099)
+++ trunk/MagicSoft/Mars/mdata/MDataArray.cc	(revision 5100)
@@ -135,5 +135,5 @@
     while ((data=(MData*)Next()))
     {
-        *fLog << all << " Line " << setw(3) << n++ << ": " << flush;
+        *fLog << all << " " << fName << "[" << setw(3) << n++ << "] = " << flush;
         data->Print();
         *fLog << endl;
Index: trunk/MagicSoft/Mars/mfbase/MF.h
===================================================================
--- trunk/MagicSoft/Mars/mfbase/MF.h	(revision 5099)
+++ trunk/MagicSoft/Mars/mfbase/MF.h	(revision 5100)
@@ -37,4 +37,6 @@
     ~MF();
 
+    TString GetRule() const { return fF ? fF->GetRule() : MFilter::GetRule(); }
+
     Bool_t IsExpressionTrue() const;
 
Index: trunk/MagicSoft/Mars/mfileio/MReadTree.cc
===================================================================
--- trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 5099)
+++ trunk/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 5100)
@@ -724,5 +724,5 @@
         fChain->SetBranchAddress(bname, pcont);
 
-        *fLog << inf << "Master branch address " << bname << " [";
+        *fLog << inf << "Master branch address '" << bname << "' [";
         *fLog << classname << "] setup for reading." << endl;
 
Index: trunk/MagicSoft/Mars/mhbase/MHMatrix.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MHMatrix.cc	(revision 5099)
+++ trunk/MagicSoft/Mars/mhbase/MHMatrix.cc	(revision 5100)
@@ -369,5 +369,8 @@
 
     if (fData && str.Contains("cols", TString::kIgnoreCase))
+    {
+        fData->SetName(fName);
         fData->Print();
+    }
 
     if (str.Contains("data", TString::kIgnoreCase))
Index: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 5099)
+++ trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc	(revision 5100)
@@ -84,8 +84,9 @@
 Bool_t MAlphaFitter::Fit(TH1D &h, Bool_t paint)
 {
-    Double_t sigint=fSigInt;
     Double_t sigmax=fSigMax;
     Double_t bgmin =fBgMin;
     Double_t bgmax =fBgMax;
+
+    //*fLog << inf << "Fit: " << sigmax << " " << fSigInt << "  " << bgmin << " " << bgmax << endl;
 
     //TF1 fFunc("", Form("gaus(0) + pol%d(3)", fPolynomOrder), 0, 90);
@@ -167,12 +168,13 @@
     }
     // ------------------------------------
-    const Double_t s = fFunc->Integral(0, sigint)/alphaw;
-    fFunc->SetParameter(0, 0);
-    fFunc->SetParameter(2, 1);
-    const Double_t b = fFunc->Integral(0, sigint)/alphaw;
-    fSignificance = MMath::SignificanceLiMaSigned(s, b);
-
-    const Double_t uin = 1.25*sigint;
-    const Int_t    bin = h.GetXaxis()->FindFixBin(uin);
+
+     //const Double_t s = fFunc->Integral(0, fSigInt)/alphaw;
+     fFunc->SetParameter(0, 0);
+     fFunc->SetParameter(2, 1);
+     //const Double_t b = fFunc->Integral(0, fSigInt)/alphaw;
+     //fSignificance = MMath::SignificanceLiMaSigned(s, b);
+
+
+    const Int_t bin = h.GetXaxis()->FindFixBin(fSigInt*0.999);
 
     fIntegralMax      = h.GetBinLowEdge(bin+1);
@@ -180,5 +182,8 @@
     fEventsSignal     = h.Integral(0, bin);
     fEventsExcess     = fEventsSignal-fEventsBackground;
-    //fSignificance     = MMath::SignificanceLiMaSigned(fEventsSignal, fEventsBackground);
+    fSignificance     = MMath::SignificanceLiMaSigned(fEventsSignal, fEventsBackground);
+
+    if (fEventsExcess<0)
+        fEventsExcess=0;
 
     return kTRUE;
@@ -187,6 +192,6 @@
 void MAlphaFitter::PaintResult(Float_t x, Float_t y, Float_t size) const
 {
-    TLatex text(x, y, Form("\\sigma_{Li/Ma}=%.1f (\\alpha<%.1f\\circ)  \\omega=%.1f\\circ  E=%d  (\\alpha<%.1f\\circ)  (\\chi_{b}^{2}=%.1f  \\chi_{s}^{2}=%.1f)",
-                           fSignificance, fSigInt, GetGausSigma(),
+    TLatex text(x, y, Form("\\sigma_{Li/Ma}=%.1f  \\omega=%.1f\\circ  E=%d  (\\alpha<%.1f\\circ)  (\\chi_{b}^{2}=%.1f  \\chi_{s}^{2}=%.1f)",
+                           fSignificance, GetGausSigma(),
                            (int)fEventsExcess, fIntegralMax,
                            fChiSqBg, fChiSqSignal));
@@ -196,2 +201,28 @@
     text.Paint();
 }
+
+void MAlphaFitter::Copy(TObject &o) const
+{
+    MAlphaFitter &f = static_cast<MAlphaFitter&>(o);
+
+    f.fSigInt       = fSigInt;
+    f.fSigMax       = fSigMax;
+    f.fBgMin        = fBgMin;
+    f.fBgMax        = fBgMax;
+    f.fPolynomOrder = fPolynomOrder;
+    f.fCoefficients.Set(fCoefficients.GetSize());
+    f.fCoefficients.Reset();
+
+    TF1 *fcn = f.fFunc;
+    f.fFunc = new TF1(*fFunc);
+    gROOT->GetListOfFunctions()->Remove(f.fFunc);
+    delete fcn;
+}
+
+void MAlphaFitter::Print(Option_t *o) const
+{
+    *fLog << inf << GetDescriptor() << ": Fitting..." << endl;
+    *fLog << " ...background from " << fBgMin << " to " << fBgMax << endl;
+    *fLog << " ...signal to " << fSigMax << " (integrate into bin at " << fSigInt << ")" << endl;
+    *fLog << " ...polynom order " << fPolynomOrder << endl;
+}
Index: trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 5099)
+++ trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h	(revision 5100)
@@ -19,6 +19,4 @@
 {
 private:
-    TF1 *fFunc;
-
     Float_t fSigInt;
     Float_t fSigMax;
@@ -38,8 +36,13 @@
     TArrayD fCoefficients;
 
+    TF1 *fFunc;
+
 public:
     // Implementing the function yourself is only about 5% faster
-    MAlphaFitter() : fFunc(new TF1("", "gaus(0) + pol1(3)", 0, 90)), fSigInt(10), fSigMax(75), fBgMin(45), fBgMax(85), fPolynomOrder(1), fCoefficients(3+fPolynomOrder+1)
+    MAlphaFitter(const char *name=0, const char *title=0) : fSigInt(15), fSigMax(75), fBgMin(45), fBgMax(85), fPolynomOrder(2), fCoefficients(3+fPolynomOrder+1), fFunc(new TF1("", Form("gaus(0) + pol%d(3)", fPolynomOrder), 0, 90))
     {
+        fName  = name  ? name  : "MAlphaFitter";
+        fTitle = title ? title : "Fit alpha";
+
         gROOT->GetListOfFunctions()->Remove(fFunc);
     }
@@ -54,21 +57,6 @@
     }
 
-    void Copy(TObject &o) const
-    {
-        MAlphaFitter &f = static_cast<MAlphaFitter&>(o);
-
-        f.fSigInt       = fSigInt;
-        f.fSigMax       = fSigMax;
-        f.fBgMin        = fBgMin;
-        f.fBgMax        = fBgMax;
-        f.fPolynomOrder = fPolynomOrder;
-        f.fCoefficients.Set(fCoefficients.GetSize());
-        f.fCoefficients.Reset();
-
-        TF1 *fcn = f.fFunc;
-        f.fFunc = new TF1(*fFunc);
-        gROOT->GetListOfFunctions()->Remove(f.fFunc);
-        delete fcn;
-    }
+    void Print(Option_t *o=0) const;
+    void Copy(TObject &o) const;
 
     void SetSignalIntegralMax(Float_t s)   { fSigInt       = s; }
Index: trunk/MagicSoft/Mars/mhflux/MHAlpha.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHAlpha.cc	(revision 5099)
+++ trunk/MagicSoft/Mars/mhflux/MHAlpha.cc	(revision 5100)
@@ -277,4 +277,6 @@
         fit->Copy(fFit);
 
+    fFit.Print();
+
     return kTRUE;
 }
@@ -540,4 +542,5 @@
     // Store the final result in fFit
     TH1D *h = fHAlpha.ProjectionZ("AlphaExc_px", -1, 9999, -1, 9999, "E");
+    fFit.Print();
     Bool_t rc = fFit.Fit(*h);
     delete h;
Index: trunk/MagicSoft/Mars/mhflux/MHAlpha.h
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHAlpha.h	(revision 5099)
+++ trunk/MagicSoft/Mars/mhflux/MHAlpha.h	(revision 5100)
@@ -84,5 +84,5 @@
 {
 private:
-    MAlphaFitter fFit;          //! SEEMS THAT STREAMER HAS SOME PROBLEMS... MAYBE IF FUNC IS USED AT THE SAME TIME FOR FITS (PAINT)
+    MAlphaFitter fFit;          // SEEMS THAT STREAMER HAS SOME PROBLEMS... MAYBE IF FUNC IS USED AT THE SAME TIME FOR FITS (PAINT)
 
     TH3D fHAlpha;               // Alpha vs. theta and energy
Index: trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc
===================================================================
--- trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc	(revision 5099)
+++ trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc	(revision 5100)
@@ -740,5 +740,5 @@
 
     //Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE);
-    return par[0]*(g0+g1);
+    return par[0]*g0*g1;
 }
 
@@ -942,5 +942,6 @@
 
 
-    TF2 f2d("", FcnGauss2d, -1.5, 1.5, -1.5, 1.5, 6);
+    TF2 f2d("Gaus-2D", FcnGauss2d, -1.5, 1.5, -1.5, 1.5, 6);
+    f2d.SetLineWidth(1);
     f2d.SetParName(0, "Max   sigma");
     f2d.SetParName(1, "Mean_1  deg");
@@ -954,12 +955,12 @@
     f2d.SetParLimits(4, 0, 1);     // sigma_2
     f2d.SetParLimits(5, 0, 90);    // phi
-    f2d.SetParameter(0, maxs); // A
-    f2d.SetParameter(1, 0);    // mu_1
-    f2d.SetParameter(2, 0.2);  // sigma_1
-    f2d.SetParameter(3, 0);    // mu_2
-    f2d.SetParameter(4, 0.2);  // sigma_2
-    f2d.SetParameter(5, 0);    // phi
-    hist->Fit(&f2d, "IN0");
-    //f2d.DrawClone("cont2same")->SetBit(kCanDelete);
+    f2d.SetParameter(0, maxs);     // A
+    f2d.SetParameter(1, 0);        // mu_1
+    f2d.SetParameter(2, 0.5);      // sigma_1
+    f2d.SetParameter(3, 0);        // mu_2
+    f2d.SetParameter(4, 0.5);      // sigma_2
+    f2d.SetParameter(5, 0);        // phi
+    hist->Fit(&f2d, "NI0");
+    f2d.DrawCopy("cont2same");
 
 
