Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 1204)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 1205)
@@ -11,4 +11,11 @@
    * mgui/MGeomPix.h:
      - implemented first version of GetA
+
+   * mhist/MBinning.h:
+     - small changes to formulas
+     
+   * mhist/MH.[h,cc]:
+     - implemented SetBinnign functions
+
 
 
@@ -263,4 +270,5 @@
 
 
+>>>>>>> 1.148
  2001/12/18: Oscar Blanch
 								 
@@ -290,6 +298,9 @@
      - fix bug of Pedestal and Pedestal fluctuaions correspondence.
 
-
-     
+<<<<<<< Changelog
+
+=======
+>>>>>>> 1.148
+
  2001/12/18: Thomas Bretz
  
Index: /trunk/MagicSoft/Mars/mhist/MBinning.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MBinning.h	(revision 1204)
+++ /trunk/MagicSoft/Mars/mhist/MBinning.h	(revision 1205)
@@ -36,5 +36,7 @@
     void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up)
     {
-        const Double_t binsize = (log10(up)-log10(lo))/nbins;
+        // if (lo==0) ...
+
+        const Double_t binsize = log10(up/lo)/nbins;
         fEdges.Set(nbins+1);
         for (int i=0; i<=nbins; i++)
@@ -42,5 +44,5 @@
     }
 
-    // ROOT workaround: "operator[] const" missing
+    // FIXME: ROOT workaround: "operator[] const" missing
     Double_t GetEdgeLo() const { return (*(TArrayD*)(&fEdges))[0]; }
     Double_t GetEdgeHi() const { return (*(TArrayD*)(&fEdges))[fEdges.GetSize()-1]; }
Index: /trunk/MagicSoft/Mars/mhist/MH.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MH.cc	(revision 1204)
+++ /trunk/MagicSoft/Mars/mhist/MH.cc	(revision 1205)
@@ -28,6 +28,15 @@
 //                                                                          //
 //  This is a base tasks for mars histograms. It defines a common interface //
-//  for filling the histograms with data (MH::Fill) which is used by a      //
-//  common 'filler' (s. MFillH)                                             //
+//  for filling the histograms with events (MH::Fill) which is used by a    //
+//  common 'filler' And a SetupFill member function which may be used       //
+//  by MFillH. The idea is:                                                 //
+//   1) If your Histogram can become filled by one single container         //
+//      (like MHHillas) you overload MH::Fill and it gets called with       //
+//      a pointer to the container with which it should be filled.          //
+//                                                                          //
+//   2) You histogram needs several containers to get filled. Than you      //
+//      have to overload MH::SetupFill and get the necessary objects from   //
+//      the parameter list. Use this objects in Fill to fill your           //
+//      histogram.                                                          //
 //                                                                          //
 //  If you want to create your own histogram class the new class must be    //
@@ -40,5 +49,8 @@
 #include "MH.h"
 
+#include <TH1.h>
 #include <TCanvas.h>
+
+#include "MBinning.h"
 
 ClassImp(MH);
@@ -101,2 +113,111 @@
     return MakeDefCanvas(obj->GetName(), obj->GetTitle(), w, h);
 }
+
+void MH::SetBinning(TH1 *h, const MBinning *binsx)
+{
+    //
+    // This is a necessary workaround if one wants to set
+    // non-equidistant bins after the initialization
+    // TH1D::fNcells must be set correctly.
+    //
+    h->SetBins(binsx->GetNumBins(), 0, 1);
+
+    //
+    // Set the binning of the current histogram to the binning
+    // in one of the two given histograms
+    //
+    h->GetXaxis()->Set(binsx->GetNumBins(), binsx->GetEdges());
+}
+
+void MH::SetBinning(TH1 *h, const MBinning *binsx, const MBinning *binsy)
+{
+    //
+    // This is a necessary workaround if one wants to set
+    // non-equidistant bins after the initialization
+    // TH1D::fNcells must be set correctly.
+    //
+    h->SetBins(binsx->GetNumBins(), 0, 1,
+               binsy->GetNumBins(), 0, 1);
+
+    //
+    // Set the binning of the current histogram to the binning
+    // in one of the two given histograms
+    //
+    h->GetXaxis()->Set(binsx->GetNumBins(), binsx->GetEdges());
+    h->GetYaxis()->Set(binsy->GetNumBins(), binsy->GetEdges());
+}
+
+void MH::SetBinning(TH1 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz)
+{
+    //
+    // This is a necessary workaround if one wants to set
+    // non-equidistant bins after the initialization
+    // TH1D::fNcells must be set correctly.
+    //
+    h->SetBins(binsx->GetNumBins(), 0, 1,
+               binsy->GetNumBins(), 0, 1,
+               binsz->GetNumBins(), 0, 1);
+
+    //
+    // Set the binning of the current histogram to the binning
+    // in one of the two given histograms
+    //
+    h->GetXaxis()->Set(binsx->GetNumBins(), binsx->GetEdges());
+    h->GetYaxis()->Set(binsy->GetNumBins(), binsy->GetEdges());
+    h->GetZaxis()->Set(binsz->GetNumBins(), binsz->GetEdges());
+}
+
+void MH::SetBinning(TH1 *h, const TArrayD *binsx)
+{
+    MBinning bx;
+    bx.SetEdges(*binsx);
+    SetBinning(h, &bx);
+}
+
+void MH::SetBinning(TH1 *h, const TArrayD *binsx, const TArrayD *binsy)
+{
+    MBinning bx;
+    MBinning by;
+    bx.SetEdges(*binsx);
+    by.SetEdges(*binsy);
+    SetBinning(h, &bx, &by);
+}
+
+void MH::SetBinning(TH1 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz)
+{
+    MBinning bx;
+    MBinning by;
+    MBinning bz;
+    bx.SetEdges(*binsx);
+    by.SetEdges(*binsy);
+    bz.SetEdges(*binsz);
+    SetBinning(h, &bx, &by, &bz);
+}
+
+void MH::SetBinning(TH1 *h, const TAxis *binsx)
+{
+    MBinning bx;
+    bx.SetEdges(*((TAxis*)binsx)->GetXbins()); // FIXME: Root!
+    SetBinning(h, &bx);
+}
+
+void MH::SetBinning(TH1 *h, const TAxis *binsx, const TAxis *binsy)
+{
+    MBinning bx;
+    MBinning by;
+    bx.SetEdges(*((TAxis*)binsx)->GetXbins()); // FIXME: Root!
+    by.SetEdges(*((TAxis*)binsy)->GetXbins()); // FIXME: Root!
+    SetBinning(h, &bx, &by);
+}
+
+void MH::SetBinning(TH1 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz)
+{
+    MBinning bx;
+    MBinning by;
+    MBinning bz;
+    bx.SetEdges(*((TAxis*)binsx)->GetXbins()); // FIXME: Root!
+    by.SetEdges(*((TAxis*)binsy)->GetXbins()); // FIXME: Root!
+    bz.SetEdges(*((TAxis*)binsz)->GetXbins()); // FIXME: Root!
+    SetBinning(h, &bx, &by, &bz);
+}
+
Index: /trunk/MagicSoft/Mars/mhist/MH.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MH.h	(revision 1204)
+++ /trunk/MagicSoft/Mars/mhist/MH.h	(revision 1205)
@@ -5,4 +5,10 @@
 #include "MParContainer.h"
 #endif
+
+class TH1;
+class MBinning;
+class MParList;
+class TArrayD;
+class TAxis;
 
 class TCanvas;
@@ -13,5 +19,6 @@
     MH(const char *name=NULL, const char *title=NULL);
 
-    virtual void Fill(const MParContainer *par) = 0;
+    virtual Bool_t SetupFill(const MParList *pList) { return kTRUE; }
+    virtual Bool_t Fill(const MParContainer *par) = 0;
 
     static TCanvas *MakeDefCanvas(const char *name=NULL, const char *title="",
@@ -20,4 +27,16 @@
                                   const UInt_t w=700, const UInt_t h=500);
 
+    static void SetBinning(TH1 *h, const MBinning *binsx);
+    static void SetBinning(TH1 *h, const MBinning *binsx, const MBinning *binsy);
+    static void SetBinning(TH1 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz);
+
+    static void SetBinning(TH1 *h, const TArrayD *binsx);
+    static void SetBinning(TH1 *h, const TArrayD *binsx, const TArrayD *binsy);
+    static void SetBinning(TH1 *h, const TArrayD *binsx, const TArrayD *binsy, const TArrayD *binsz);
+
+    static void SetBinning(TH1 *h, const TAxis *binsx);
+    static void SetBinning(TH1 *h, const TAxis *binsx, const TAxis *binsy);
+    static void SetBinning(TH1 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz);
+
     ClassDef(MH, 1) //A histogram base class for Mars histograms
 };
Index: /trunk/MagicSoft/Mars/mhist/MHHillas.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHHillas.cc	(revision 1204)
+++ /trunk/MagicSoft/Mars/mhist/MHHillas.cc	(revision 1205)
@@ -1,2 +1,3 @@
+<<<<<<< MHHillas.cc
 /* ======================================================================== *\
 !
@@ -45,5 +46,5 @@
 // --------------------------------------------------------------------------
 //
-// Setup four histograms for Width, Length
+// Setup four histograms for Alpha, Width, Length and Dist
 //
 MHHillas::MHHillas (const char *name, const char *title)
@@ -60,14 +61,22 @@
     // connect all the histogram with the container fHist
     //
+    fAlpha  = new TH1F("Alpha [deg]", "Alpha of Hillas",   90, 0,  90);
     fWidth  = new TH1F("Width [mm]",  "Width of Hillas",  100, 0, 300);
     fLength = new TH1F("Length [mm]", "Length of Hillas", 100, 0, 300);
+    fDist   = new TH1F("Dist [mm]",   "Dist of Hillas",   100, 0, 300);
 
+    fAlpha->SetDirectory(NULL);
     fLength->SetDirectory(NULL);
+    fDist->SetDirectory(NULL);
     fWidth->SetDirectory(NULL);
 
+    fAlpha->GetXaxis()->SetTitle("\\alpha [\\circ]");
     fLength->GetXaxis()->SetTitle("Length [mm]");
+    fDist->GetXaxis()->SetTitle("Dist [mm]");
     fWidth->GetXaxis()->SetTitle("Width [mm]");
 
+    fAlpha->GetYaxis()->SetTitle("Counts");
     fLength->GetYaxis()->SetTitle("Counts");
+    fDist->GetYaxis()->SetTitle("Counts");
     fWidth->GetYaxis()->SetTitle("Counts");
 }
@@ -79,6 +88,8 @@
 MHHillas::~MHHillas()
 {
+    delete fAlpha;
     delete fWidth;
     delete fLength;
+    delete fDist;
 }
 
@@ -88,10 +99,14 @@
 // Be careful: Only call this with an object of type MHillas
 //
-void MHHillas::Fill(const MParContainer *par)
+Bool_t MHHillas::Fill(const MParContainer *par)
 {
     const MHillas &h = *(MHillas*)par;
 
+    fAlpha ->Fill(fabs(h.GetAlpha()));
     fWidth ->Fill(h.GetWidth());
     fLength->Fill(h.GetLength());
+    fDist  ->Fill(h.GetDist());
+
+    return kTRUE;
 }
 
@@ -106,7 +121,6 @@
 TObject *MHHillas::DrawClone(Option_t *opt) const
 {
-    TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Hillas Parameters",
-                               350, 500);
-    c->Divide(1, 2);
+    TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Hillas Parameters");
+    c->Divide(2, 2);
 
     gROOT->SetSelectedPad(NULL);
@@ -116,7 +130,13 @@
     //
     c->cd(1);
+    fAlpha->DrawCopy();
+
+    c->cd(2);
     fLength->DrawCopy();
 
-    c->cd(2);
+    c->cd(3);
+    fDist->DrawCopy();
+
+    c->cd(4);
     fWidth->DrawCopy();
 
@@ -136,12 +156,18 @@
 {
     if (!gPad)
-        MakeDefCanvas("Hillas", "Histograms of Hillas Parameters", 350, 500);
+        MakeDefCanvas("Hillas", "Histograms of Hillas Parameters");
 
-    gPad->Divide(1, 2);
+    gPad->Divide(2,2);
 
     gPad->cd(1);
+    fAlpha->Draw();
+
+    gPad->cd(2);
     fLength->Draw();
 
-    gPad->cd(2);
+    gPad->cd(3);
+    fDist->Draw();
+
+    gPad->cd(4);
     fWidth->Draw();
 
Index: /trunk/MagicSoft/Mars/mhist/MHStarMap.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 1204)
+++ /trunk/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 1205)
@@ -1,2 +1,3 @@
+<<<<<<< MHStarMap.cc
 /* ======================================================================== *\
 !
@@ -47,5 +48,5 @@
 // Create the star map histogram
 //
-MHStarMap::MHStarMap(const char *name, const char *title)
+MHStarMap::MHStarMap (const char *name, const char *title)
 {
     //
@@ -72,6 +73,6 @@
     fStarMap->SetDirectory(NULL);
 
-    fStarMap->SetXTitle("x [mm]");
-    fStarMap->SetYTitle("y [mm]");
+    fStarMap->SetXTitle("x/mm");
+    fStarMap->SetYTitle("y/mm");
     fStarMap->SetZTitle("Counts");
 }
@@ -91,12 +92,14 @@
 // Be careful: Only call this with an object of type MHillas
 //
-void MHStarMap::Fill(const MParContainer *par)
+Bool_t MHStarMap::Fill(const MParContainer *par)
 {
     const MHillas &h = *(MHillas*)par;
 
-    const float delta = h.GetDelta();
-
-    const float m = tan(delta);
-    const float t = m*h.GetMeanX()-h.GetMeanY();
+    const float dist  = h.GetDist();
+    const float theta = h.GetTheta();
+    const float alpha = h.GetAlpha()/kRad2Deg;
+
+    const float m = tan(theta+alpha-kPI);
+    const float t = dist*(sin(theta)-cos(theta)*m);
 
     if (m>-1 && m<1)
@@ -114,4 +117,6 @@
             fStarMap->Fill(x, y);
         }
+
+    return kTRUE;
 }
 
@@ -209,2 +214,3 @@
     gPad->Update();
 }
+
Index: /trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h	(revision 1204)
+++ /trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h	(revision 1205)
@@ -1,4 +1,4 @@
-#ifndef MARS_MTriggerRateCalc
-#define MARS_MTriggerRateCalc
+#ifndef MARS_MMcTriggerRateCalc
+#define MARS_MMcTriggerRateCalc
 
 #ifndef ROOT_TObjArray
