Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 1907)
+++ trunk/MagicSoft/Mars/Changelog	(revision 1910)
@@ -1,10 +1,39 @@
                                                  -*-*- END OF LINE -*-*-
 
- 2003/04/04: Thomas Bretz
-
-   * mtools/MagicReversi.cc:
+ 2003/04/07: Thomas Bretz
+
+   * Makefile:
+     - changed order
+     
+   * manalysis/MMultiDimDistCalc.[h,cc]:
+     - fixed default title
+     - simplified code
+     - added fHadronnessName
+
+   * manalysis/MRanForestCalc.[h,cc]:
+     - added fHadronnessName
+   
+   * mbase/MAGIC.h:
+     - fixed a bug with rootcint
+     
+   * meventdisp/MGFadcDisp.cc:
+     - fixed a variable name
+
+   * mhist/MHHadronness.cc:
+     - removed many old comments
+     - simplified some code
+     - uses argument in Fill now
+
+
+
+2003/04/04: Thomas Bretz
+
+   * mtools/MagicReversi.[h,cc]:
      - added support for Number of Players
      - added instructions
      - added support for Esc key
+
+   * mbase/MAGIC.h:
+     - added version check to MAGIC.h
 
 
Index: trunk/MagicSoft/Mars/Makefile
===================================================================
--- trunk/MagicSoft/Mars/Makefile	(revision 1907)
+++ trunk/MagicSoft/Mars/Makefile	(revision 1910)
@@ -38,4 +38,5 @@
           mbase       \
           mfileio     \
+          mfilter     \
 	  manalysis   \
           mmc         \
@@ -44,5 +45,4 @@
           mmontecarlo \
           mhist       \
-          mfilter     \
           mdata       \
           mtools      \
Index: trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.cc	(revision 1907)
+++ trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.cc	(revision 1910)
@@ -61,5 +61,6 @@
 
 static const TString gsDefName  = "MMultiDimDistCalc";
-static const TString gsDefTitle = "Composite Probabilities Loop 1/2";
+static const TString gsDefTitle = "Calculate Hadronness with Nearest Neighbor/Kernel Method";
+
 // --------------------------------------------------------------------------
 //
@@ -68,5 +69,5 @@
 //
 MMultiDimDistCalc::MMultiDimDistCalc(const char *name, const char *title)
-    : fNum(0), fUseKernel(kTRUE), fData(NULL)
+    : fNum(0), fUseKernel(kTRUE), fHadronnessName("MHadronness"), fData(NULL)
 {
     //
@@ -151,5 +152,5 @@
     }
 
-    fHadronness = (MHadronness*)plist->FindCreateObj("MHadronness");
+    fHadronness = (MHadronness*)plist->FindCreateObj(fHadronnessName, "MHadronness");
     if (!fHadronness)
         return kFALSE;
@@ -208,18 +209,5 @@
     }
 
-    Double_t arg;
-
-    if (dg+dh != 0.0)
-      arg = dg / (dg+dh);
-    else
-      arg = 1.e10;
-    //fHadronness->SetHadronness(arg);
-
-    if (dg != 0.0)
-      arg = exp(-dh/dg);
-    else
-      arg = 0.0;
-    fHadronness->SetHadronness(arg);
-      
+    fHadronness->SetHadronness(dg==0 ? 0 : exp(-dh/dg));
 
     return kTRUE;
@@ -238,4 +226,6 @@
     out << ";" << endl;
 
+    if (fHadronnessName!="MHadronness")
+        out << "   " << GetUniqueName() << ".SetHadronnessName(\"" << fHadronnessName << "\");" << endl;
     if (fNum!=0)
         out << "   " << GetUniqueName() << ".SetUseNumRows(" << fNum << ");" << endl;
Index: trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.h	(revision 1907)
+++ trunk/MagicSoft/Mars/manalysis/MMultiDimDistCalc.h	(revision 1910)
@@ -17,4 +17,6 @@
     Bool_t fUseKernel;        // Flag whether kernel method should be used
 
+    TString fHadronnessName;  // Name of container storing hadronness
+
     MHMatrix   *fMGammas;     //! Gammas describing matrix
     MHMatrix   *fMHadrons;    //! Hadrons (non gammas) describing matrix
@@ -30,4 +32,7 @@
     ~MMultiDimDistCalc();
 
+    void SetHadronnessName(const TString name) { fHadronnessName = name; }
+    TString GetHadronnessName() const { return fHadronnessName; }
+
     void SetUseNumRows(UShort_t n=0) { fNum = n; }
     void SetUseKernelMethod(Bool_t k=kTRUE) { fUseKernel = k; }
@@ -36,5 +41,5 @@
     Bool_t Process();
 
-    ClassDef(MMultiDimDistCalc, 0) // Task to calculate multidimensional distances
+    ClassDef(MMultiDimDistCalc, 0) // Task to calculate nearest neighbor-/kernel-hadronness
 };
 
Index: trunk/MagicSoft/Mars/manalysis/MRanForestCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MRanForestCalc.cc	(revision 1907)
+++ trunk/MagicSoft/Mars/manalysis/MRanForestCalc.cc	(revision 1910)
@@ -60,5 +60,5 @@
 //
 MRanForestCalc::MRanForestCalc(const char *name, const char *title)
-    : fNum(100), fData(NULL)
+    : fNum(100), fHadronnessName("MHadronness"), fData(NULL)
 {
     //
@@ -125,5 +125,5 @@
     }
 
-    fHadroness = (MHadronness*)plist->FindCreateObj("MHadronness");
+    fHadroness = (MHadronness*)plist->FindCreateObj(fHadronnessName, "MHadronness");
     if (!fHadroness)
         return kFALSE;
Index: trunk/MagicSoft/Mars/manalysis/MRanForestCalc.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MRanForestCalc.h	(revision 1907)
+++ trunk/MagicSoft/Mars/manalysis/MRanForestCalc.h	(revision 1910)
@@ -15,14 +15,19 @@
 {
 private:
-    Int_t  fNum;             // number of trees used to compute hadronness
+    Int_t  fNum;              // number of trees used to compute hadronness
 
-    MHadronness *fHadroness; //! Output container for calculated hadroness
-    MDataArray *fData;       //! Used to store the MDataChains to get the event values
-    MRanForest *fRanForest;
-    MRanTree   *fRanTree;
+    TString fHadronnessName;  // Name of container storing hadronness
+
+    MHadronness *fHadroness;  //! Output container for calculated hadroness
+    MDataArray  *fData;       //! Used to store the MDataChains to get the event values
+    MRanForest  *fRanForest;
+    MRanTree    *fRanTree;
 
 public:
     MRanForestCalc(const char *name=NULL, const char *title=NULL);
     ~MRanForestCalc();
+
+    void SetHadronnessName(const TString name) { fHadronnessName = name; }
+    TString GetHadronnessName() const { return fHadronnessName; }
 
     void SetUseNumTrees(UShort_t n=100) { fNum = n; }
Index: trunk/MagicSoft/Mars/mbase/MAGIC.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MAGIC.h	(revision 1907)
+++ trunk/MagicSoft/Mars/mbase/MAGIC.h	(revision 1910)
@@ -12,6 +12,8 @@
 #endif
 
+#ifndef __CINT__
 #if ROOT_VERSION_CODE < ROOT_VERSION(3,02,00)
 #error Your root version is too old to compile Mars, use root>=3.02
+#endif
 #endif
 
Index: trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.cc
===================================================================
--- trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.cc	(revision 1907)
+++ trunk/MagicSoft/Mars/meventdisp/MGFadcDisp.cc	(revision 1910)
@@ -77,21 +77,21 @@
     fTab1->AddFrame(fPixelList, layplist);
 
-    TGVerticalFrame *fMidFrame = new TGVerticalFrame(fTab1, 300, 100);
-    fList->Add(fMidFrame);
+    TGVerticalFrame *midframe = new TGVerticalFrame(fTab1, 300, 100);
+    fList->Add(midframe);
 
     TGLayoutHints *laytab = new TGLayoutHints(kLHintsRight|kLHintsExpandY, 5, 5, 5, 5);
     fList->Add(laytab);
 
-    fTab1->AddFrame(fMidFrame, laytab);
+    fTab1->AddFrame(midframe, laytab);
 
     //
     // Create gui elements for vertical frame
     //
-    TGTextButton *prevpix = new TGTextButton(fMidFrame, "<< Prev Pixel", M_PREVPIXEL);
-    TGTextButton *nextpix = new TGTextButton(fMidFrame, "Next Pixel >>", M_NEXTPIXEL);
+    TGTextButton *prevpix = new TGTextButton(midframe, "<< Prev Pixel", M_PREVPIXEL);
+    TGTextButton *nextpix = new TGTextButton(midframe, "Next Pixel >>", M_NEXTPIXEL);
     prevpix->Associate(this);
     nextpix->Associate(this);
 
-    TGVSlider *slider = new TGVSlider(fMidFrame, 200, kSlider1|kScaleBoth);
+    TGVSlider *slider = new TGVSlider(midframe, 200, kSlider1|kScaleBoth);
     slider->Associate(this);
     slider->SetRange(0, 576);
@@ -103,7 +103,7 @@
     TGLayoutHints *layslider = new TGLayoutHints(kLHintsCenterX|kLHintsExpandY);
 
-    fMidFrame->AddFrame(prevpix, laybut);
-    fMidFrame->AddFrame(slider,  layslider);
-    fMidFrame->AddFrame(nextpix, laybut);
+    midframe->AddFrame(prevpix, laybut);
+    midframe->AddFrame(slider,  layslider);
+    midframe->AddFrame(nextpix, laybut);
 }
 
Index: trunk/MagicSoft/Mars/mhist/MHHadronness.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHHadronness.cc	(revision 1907)
+++ trunk/MagicSoft/Mars/mhist/MHHadronness.cc	(revision 1910)
@@ -19,5 +19,5 @@
 !   Author(s): Abelardo Moralejo <mailto:moralejo@pd.infn.it>
 !
-!   Copyright: MAGIC Software Development, 2000-2002
+!   Copyright: MAGIC Software Development, 2000-2003
 !
 !
@@ -51,11 +51,11 @@
 //    - blue cross: minimum of distance to (0, 1)
 //
+// As a default MHHadronness searches for the container "MHadronness".
+// This can be overwritten by a different pointer specified in the
+// Fill function (No type check is done!) Use a different name in
+// MFillH.
+//
 ////////////////////////////////////////////////////////////////////////////
 #include "MHHadronness.h"
-
-/*
- // - blue:  2D distance of (acceptance_hadrons, acceptances_gammas)
- //          to optimum (0, 1):  1-sqrt(Ag*Ag + (1-Ah)*(1-Ah))
- */
 
 #include <TPad.h>
@@ -107,22 +107,9 @@
     fIntPhness->SetYTitle("Acceptance");
 
-    /*
-    fQfac = new TH1D("Qfac", "Naive Quality factor", nbins, 0, 1);
-    fQfac->SetXTitle("Hadronness");
-    fQfac->SetYTitle("Quality");
-    */
     fQfac = new TGraph;
     fQfac->SetTitle(" Naive Quality factor ");
 
-    /*
-     fMinDist = new TH1D("MinDist", "Minimum Dist to (0, 1)", nbins, 0, 1);
-     fMinDist->SetXTitle("Hadronness");
-     fMinDist->SetYTitle("Distance");
-     */
-
-    //fQfac->SetDirectory(NULL);
     fGhness->SetDirectory(NULL);
     fPhness->SetDirectory(NULL);
-    //fMinDist->SetDirectory(NULL);
     fIntGhness->SetDirectory(NULL);
     fIntPhness->SetDirectory(NULL);
@@ -140,5 +127,4 @@
     delete fIntPhness;
     delete fQfac;
-    //    delete fMinDist;
     delete fGraph;
 }
@@ -159,9 +145,4 @@
 
     fHadronness = (MHadronness*)plist->FindObject("MHadronness");
-    if (!fHadronness)
-    {
-        *fLog << err << dbginf << "MHadronness not found... aborting." << endl;
-        return kFALSE;
-    }
 
     /*
@@ -186,4 +167,10 @@
 // histogram dependant on the particle id.
 //
+// Every particle Id different than kGAMMA is considered a hadron.
+//
+// If you call Fill with a pointer (eg. from MFillH) this container is
+// used as a hadronness (Warning: No type check is done!) otherwise
+// the default is used ("MHadronness")
+//
 // Sometimes a distance is calculated as NaN (not a number). Such events
 // are skipped at the moment.
@@ -192,6 +179,13 @@
 {
     // Preliminary Workaround: FIXME!
-
-    const Double_t h = fHadronness->GetHadronness();
+    if (!par && !fHadronness)
+    {
+        *fLog << err << "MHHadronness::Fill: No MHadronness container specified!" << endl;
+        return kFALSE;
+    }
+
+    const MHadronness &had = par ? *(MHadronness*)par : *fHadronness;
+
+    const Double_t h = had.GetHadronness();
 
     if (TMath::IsNaN(h))
@@ -235,11 +229,5 @@
     }
 
-    Float_t retValue;
-    if (val2x-val1x != 0.0)
-      retValue = val1y - (val2y-val1y)/(val2x-val1x) * (val1x-0.5);
-    else
-      retValue = 0.0;
-
-    return retValue;
+    return val2x-val1x == 0 ? 0 : val1y - (val2y-val1y)/(val2x-val1x) * (val1x-0.5);
 }
 
@@ -258,57 +246,28 @@
     fQfac->Set(n);
 
-    Stat_t sumg;
-    Stat_t sump;
-
-    sumg = fGhness->Integral(1, n);
-    sump = fPhness->Integral(1, n);
-
-    if (sumg == 0.0  ||  sump == 0.0)
-    {
-      *fLog << "MHHadronness::Finalize; sumg or sump is zero;   sumg, sump = "
-            << sumg << ",  " << sump << ".  Cannot calculate hadronness" 
-            << endl;
-    }
+    const Stat_t sumg = fGhness->Integral();
+    const Stat_t sump = fPhness->Integral();
+
+    *fLog << inf << "MHHadronness::Finalize - Sum Hadronness: gammas=" << sumg << " hadrons=" << sump << endl;
+
+    if (sumg==0 || sump==0)
+        *fLog << warn << "MHHadronness::Finalize: Cannot calculate hadronness." << endl;
 
 
     // Normalize photon distribution
-    Stat_t con;
-    if (sumg > 0.0)
-      for (Int_t i=1; i<=n; i++)
-      {
-	con = (fGhness->GetBinContent(i)) / sumg;
-        fGhness->SetBinContent(i, con);       
-      }
+    if (sumg>0)
+        fGhness->Scale(1./sumg);
 
     // Normalize hadron distribution
-    if (sump > 0.0)
-      for (Int_t i=1; i<=n; i++)
-      {
-	con = (fPhness->GetBinContent(i)) / sump;
-        fPhness->SetBinContent(i, con);       
-      }
+    if (sump>0)
+        fGhness->Scale(1./sump);
 
     // Calculate acceptances
-    sumg = fGhness->Integral(1, n);
-    sump = fPhness->Integral(1, n);
-
-    *fLog << "MHHadronness::Finalize; sumg, sump = " << sumg << ",  "
-          << sump << endl;
-
     Float_t max=0;
 
     for (Int_t i=1; i<=n; i++)
     {
-        Stat_t ip; 
-        if (sump != 0.0)
-          ip = fPhness->Integral(1, i)/sump;
-        else
-          ip = 0;
-
-        Stat_t ig;
-        if (sumg != 0.0)
-          ig = fGhness->Integral(1, i)/sumg;
-        else
-          ig = 0;
+        const Stat_t ip = sump!=0 ? fPhness->Integral(1, i)/sump : 0;
+        const Stat_t ig = sumg!=0 ? fGhness->Integral(1, i)/sumg : 0;
 
         fIntPhness->SetBinContent(i, ip);
@@ -319,6 +278,4 @@
         if (ip<=0)
             continue;
-
-        //fMinDist->SetBinContent(i, 1-sqrt(ip*ip + (ig-1)*(ig-1)));
 
         const Double_t val = ig/sqrt(ip);
@@ -432,11 +389,4 @@
     *fLog << endl;
 
-    /*
-     const Int_t h = fMinDist->GetMaximumBin();
-     *fLog << "Minimum Distance to (0, 1): " << Form("%.2f", 1-fMinDist->GetMaximum()) << " @ H=" << fMinDist->GetBinCenter(h) << endl;
-     *fLog << "  Acc Gammas = " << Form("%3.0f", fIntGhness->GetBinContent(h)*100) << "%, ";
-     *fLog << "Acc Hadrons = " << Form("%3.0f", fIntPhness->GetBinContent(h)*100) << "%" << endl;
-     */
-
     *fLog << "Q-Factor @ Acc Gammas=0.5: Q(0.5)=" << Form("%.1f", GetQ05()) << endl;
     *fLog << "  Acc Hadrons = " << Form("%5.1f", GetHadronAcceptance(0.5)*100) << "%" << endl;
@@ -463,4 +413,5 @@
     Getphness()->SetLineColor(kRed);
     Getphness()->DrawCopy("same");
+
     c.cd(2);
     //gStyle->SetOptStat(0);
@@ -468,10 +419,6 @@
     Getiphness()->SetLineColor(kRed);
     Getiphness()->DrawCopy("same");
-    /*
-     fMinDist->SetLineColor(kBlue);
-     fMinDist->DrawCopy("same");
-     */
+
     c.cd(3);
-    //GetQfac()->DrawCopy();
     TGraph &g2 = (TGraph&)*fQfac->DrawClone("A*");
     g2.SetBit(kCanDelete);
@@ -489,4 +436,5 @@
         gPad->Update();
     }
+
     c.cd(4);
     gPad->Modified();
@@ -537,4 +485,5 @@
     Getphness()->SetLineColor(kRed);
     Getphness()->Draw("same");
+
     gPad->cd(2);
     //gStyle->SetOptStat(0);
@@ -542,10 +491,6 @@
     Getiphness()->SetLineColor(kRed);
     Getiphness()->Draw("same");
-    /*
-     fMinDist->SetLineColor(kBlue);
-     fMinDist->Draw("same");
-     */
+
     gPad->cd(3);
-    //GetQfac()->Draw();
     fQfac->Draw("A*");
     gPad->Modified();
@@ -578,11 +523,3 @@
         gPad->Update();
     }
-    /*
-    const Int_t h = fMinDist->GetMaximumBin();
-    TMarker *m = new TMarker(fIntPhness->GetBinContent(h),
-                             fIntGhness->GetBinContent(h), kStar);
-    m->SetMarkerColor(kBlue);
-    m->SetBit(kCanDelete);
-    m->Draw();
-    */
-}
+}
Index: trunk/MagicSoft/Mars/mhist/MHHadronness.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHHadronness.h	(revision 1907)
+++ trunk/MagicSoft/Mars/mhist/MHHadronness.h	(revision 1910)
@@ -22,5 +22,4 @@
     TH1D* fIntPhness; //-> Hadrons Acceptance
     TH1D* fIntGhness; //-> Gammas  Acceptance
-    //TH1D* fMinDist; //-> Minimum Distance to optimum acceptance
 
     TGraph *fQfac;    //-> Quality factor
