Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 1227)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 1228)
@@ -1,3 +1,25 @@
                                                                   -*-*- END -*-*-
+
+ 2002/03/01: Thomas Bretz
+
+   * mhist/MHMcEfficiencyEnergy.[h,cc], mhist/MHMcEfficiencyImpact.[h,cc],
+     mhist/MHMcDifRate.[h,cc], mhist/MHMcIntRate.[h,cc]:
+     - added
+     
+   * mhist/Makefile, mhist/HistLinkDef.h:
+     - added MHMcEfficiencyEnergy and MHMcEfficiencyImpact
+     - added MHMcDifRate and MHMcIntRate
+
+   * mhist/MHMcCollectionArea.[h,cc]:
+     - changed instantiation of collection area histogram
+     - added settings for the binning
+     - replaced division by root function
+     - added Calc-functions
+     - added GetHist
+
+   * mhist/MHMcEfficiency.[h,cc]:
+     - changed pointers in Calc functions to references
+
+
 
  2002/02/28: Thomas Bretz
Index: /trunk/MagicSoft/Mars/mhist/HistLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 1227)
+++ /trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 1228)
@@ -25,5 +25,9 @@
 
 #pragma link C++ class MHMcRate+;
+#pragma link C++ class MHMcDifRate+;
+#pragma link C++ class MHMcIntRate+;
 #pragma link C++ class MHMcEfficiency+;
+#pragma link C++ class MHMcEfficiencyImpact+;
+#pragma link C++ class MHMcEfficiencyEnergy+;
 #pragma link C++ class MHMcEnergy+;
 #pragma link C++ class MHMcEnergyImpact+;
Index: /trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc	(revision 1227)
+++ /trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc	(revision 1228)
@@ -31,4 +31,5 @@
 #include "MH.h"
 #include "MHMcEfficiency.h"
+#include "MHMcEnergyImpact.h"
 
 ClassImp(MHMcCollectionArea);
@@ -52,5 +53,5 @@
   
     fName  = name  ? name  : "MHMcCollectionArea";
-    fTitle = title ? title : "Data to Calculate Collection Area";
+    fTitle = title ? title : "Collection Area vs. Energy";
 
     const Int_t  nbins = 50;
@@ -70,9 +71,11 @@
     fHistSel = new TH2D("SelectedEvents", "Selected showers - Radius vs Energy distribution",
                         nbins, binsx, nbins, binsy);
-    fHistCol = new TH1D("CollectionArea", "Collection Area vs. Energy",
-                        nbins, binsx);
 
     delete binsx;
     delete binsy;
+
+    fHistCol = new TH1D;
+    fHistCol->SetName(fName);
+    fHistCol->SetTitle(fTitle);
 
     fHistAll->SetDirectory(NULL);
@@ -193,5 +196,5 @@
 }
 
-void MHMcCollectionArea::Calc(MHMcEfficiency *heff)
+void MHMcCollectionArea::Calc(const MHMcEfficiency &heff)
 {
     //
@@ -199,5 +202,7 @@
     //  energies
     //
-    TH2D &h = (TH2D&)*heff->GetHist();
+    TH2D &h = (TH2D&)*heff.GetHist();
+
+    MH::SetBinning(fHistCol, h.GetXaxis());
 
     const Int_t nbinx = h.GetXaxis()->GetNbins();
@@ -228,4 +233,6 @@
         fHistCol->SetBinError(ix, sqrt(errA));
     }
+
+    SetReadyToSave();
 }
 
@@ -237,71 +244,15 @@
 void MHMcCollectionArea::CalcEfficiency()
 {
-    // Description!
-
-    /*
-    //
-    //  first of all calculate the efficency
-    //  do it here by hand to get the right error of efficency
-    //
-    const Int_t nbinx = fHistSel->GetXaxis()->GetNbins();
-    const Int_t nbiny = fHistSel->GetYaxis()->GetNbins();
-
-    for (Int_t ix=1; ix<=nbinx; ix++)
-    {
-        for (Int_t iy=1; iy<=nbiny; iy++)
-        {
-            const Float_t Na = fHistAll->GetCellContent(ix, iy);
-
-            if (Na <= 0)
-                continue;
-
-            const Float_t Ns = fHistSel->GetCellContent(ix, iy);
-
-            const Double_t eff = Ns/Na;
-            const Double_t err = sqrt((1.-eff)*Ns)/Na;
-
-            // old calculation from Harald:
-            //  const Double_t eff = Ns/Na;
-            //  const Double_t err = sqrt(Na + Na*Ns - Ns*Ns - Ns) / (Na*Na);
-
-            fHistSel->SetCellContent(ix, iy, eff);
-            fHistSel->SetCellError(ix, iy, err);
-        }
-    }
-
-    //
-    //  now calculate the Collection area for different
-    //  energies
-    //
-    for (Int_t ix=1; ix<=nbinx; ix++)
-    {
-        Double_t errA = 0;
-        Double_t colA = 0;
-
-        for (Int_t iy=1; iy<=nbiny; iy++)
-        {
-            TAxis *yaxis = fHistSel->GetYaxis();
-
-            const Double_t r1  = yaxis->GetBinLowEdge(iy);
-            const Double_t r2  = yaxis->GetBinLowEdge(iy+1);
-
-            const Double_t A   = TMath::Pi() * (r2*r2 - r1*r1);
-
-            const Double_t eff = fHistSel->GetCellContent(ix, iy);
-            const Double_t err = fHistSel->GetCellError(ix, iy);
-
-            colA += eff*A;
-            errA += A*A * err*err;
-        }
-
-        fHistCol->SetBinContent(ix, colA);
-        fHistCol->SetBinError(ix, sqrt(errA));
-        }
-        */
     MHMcEfficiency heff;
-    heff.Calc(fHistSel, fHistAll);
-
-    Calc(&heff);
-
-    SetReadyToSave();
-}
+    heff.Calc(*fHistSel, *fHistAll);
+
+    Calc(heff);
+}
+
+void MHMcCollectionArea::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
+{
+    MHMcEfficiency heff;
+    heff.Calc(*mcsel.GetHist(), *mcall.GetHist());
+
+    Calc(heff);
+}
Index: /trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.h	(revision 1227)
+++ /trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.h	(revision 1228)
@@ -10,4 +10,5 @@
 
 class MHMcEfficiency;
+class MHMcEnergyImpact;
 
 class MHMcCollectionArea : public MParContainer
@@ -30,4 +31,7 @@
     void DrawSel(Option_t *option="");
 
+    const TH1D *GetHist()       { return fHistCol; }
+    const TH1D *GetHist() const { return fHistCol; }
+
     void Draw(Option_t *option="");
     TObject *DrawClone(Option_t *option="") const;
@@ -35,5 +39,6 @@
     void CalcEfficiency();
 
-    void Calc(MHMcEfficiency *eff);
+    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
+    void Calc(const MHMcEfficiency &heff);
 
     ClassDef(MHMcCollectionArea, 1)  // Data Container to calculate Collection Area
Index: /trunk/MagicSoft/Mars/mhist/MHMcDifRate.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMcDifRate.cc	(revision 1228)
+++ /trunk/MagicSoft/Mars/mhist/MHMcDifRate.cc	(revision 1228)
@@ -0,0 +1,183 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
+!   Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHMcDifRate
+//
+// This class holds the information (histogram and fit function)
+// about the energy threshold for a particular trigger condition.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHMcDifRate.h" 
+
+#include <math.h>
+
+#include <TCanvas.h>
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MHMcCollectionArea.h"
+
+ClassImp(MHMcDifRate);
+
+// -------------------------------------------------------------------------
+//
+//  Default Constructor.
+//
+MHMcDifRate::MHMcDifRate(const char *name, const char *title)
+    : fHist()
+{
+    fName  = name  ? name  : "MHMcDifRate";
+    fTitle = title ? title : "Differential Trigger Rate";
+
+    //  - we initialize the histogram
+    //  - we have to give diferent names for the diferent histograms because
+    //    root don't allow us to have diferent histograms with the same name
+
+    fHist.SetName(fName);
+    fHist.SetTitle(fTitle);
+
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("E [GeV]");
+    fHist.SetYTitle("dR/dE [Hz/GeV]");
+}
+
+void MHMcDifRate::SetName(const char *name)
+{
+    fName = name;
+    fHist.SetName(name);
+    fHist.SetDirectory(NULL);
+}
+
+void MHMcDifRate::SetTitle(const char *title)
+{
+    fTitle = title;
+    fHist.SetTitle(title);
+}
+
+//-------------------------------------------------------------------------
+//
+//  Defualt Destructor
+//
+MHMcDifRate::~MHMcDifRate()
+{
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcDifRate::Draw(Option_t *option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(&fHist);
+
+    gPad->SetLogx();
+
+    fHist.Draw(option);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TObject *MHMcDifRate::DrawClone(Option_t *option) const
+{
+    TCanvas *c = MH::MakeDefCanvas(&fHist);
+
+    c->SetLogx();
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    ((TH1D&)fHist).DrawCopy(option);
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+/*
+void MHMcDifRate::Calc(const TH2D &hsel, const TH2D &hall)
+{
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, ((TH2D&)hsel).GetXaxis(), ((TH2D&)hsel).GetYaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    //
+    // Calculate the efficiency by dividing the number of selected
+    // (eg. triggered) showers by the number of all showers per bin.
+    // Both histograms are weighted with weight 1, and for the error
+    // calculation we assume a binomial error calculation.
+    //
+    fHist.Divide((TH2D*)&hsel, (TH2D*)&hall, 1, 1, "B");
+
+    SetReadyToSave();
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the DifRate and set the 'ReadyToSave' flag.
+//  The DifRate is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcDifRate::Calc(const MHMcCollectionArea &cola, const TF1 &spect)
+{
+    /*const*/ TH1D &hcol = (TH1D&)*cola.GetHist();
+
+    fHist.Reset();
+
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, hcol.GetXaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    fHist.Add(&hcol);
+    fHist.Multiply((TF1*)&spect);
+
+    SetReadyToSave();
+}
Index: /trunk/MagicSoft/Mars/mhist/MHMcDifRate.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMcDifRate.h	(revision 1228)
+++ /trunk/MagicSoft/Mars/mhist/MHMcDifRate.h	(revision 1228)
@@ -0,0 +1,42 @@
+#ifndef MARS_MHMcDifRate
+#define MARS_MHMcDifRate
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+class TF1;
+class MMcEvt;
+class MHMcCollectionArea;
+
+class MHMcDifRate : public MParContainer
+{
+private:
+
+    TH1D fHist;           // histogram with the logarith of the energy
+
+    // const MMcEvt *fMcEvt;  //! container to fill histogram from
+
+public:
+    MHMcDifRate(const char *name=NULL, const char *title=NULL);
+    ~MHMcDifRate();
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH1D *GetHist()       { return &fHist; }
+    const TH1D *GetHist() const { return &fHist; }
+
+    void Draw(Option_t* option = "");
+    TObject *DrawClone(Option_t* option = "") const;
+
+//    void Calc(const TH2D &hsel, const TH2D &hall);
+    void Calc(const MHMcCollectionArea &cola, const TF1 &spect);
+
+    ClassDef(MHMcDifRate, 1)  // Histogram container for montecarlo energy threshold
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/mhist/MHMcEfficiency.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMcEfficiency.cc	(revision 1227)
+++ /trunk/MagicSoft/Mars/mhist/MHMcEfficiency.cc	(revision 1228)
@@ -41,4 +41,6 @@
 #include "MH.h"
 #include "MBinning.h"
+
+#include "MHMcEnergyImpact.h"
 
 ClassImp(MHMcEfficiency);
@@ -133,18 +135,10 @@
 }
 
-
-// --------------------------------------------------------------------------
-//
-//  Calculate the Efficiency and set the 'ReadyToSave' flag.
-//  The Efficiency is calculated as the number of selected showers
-//  (eg. triggered ones) divided by the number of all showers.
-//  For error calculation Binomial errors are computed.
-//
-void MHMcEfficiency::Calc(TH2D *hsel, TH2D *hall)
+void MHMcEfficiency::Calc(const TH2D &hsel, const TH2D &hall)
 {
     //
     // Set the binning from the two axis of one of the two histograms
     //
-    MH::SetBinning(&fHist, hsel->GetXaxis(), hsel->GetYaxis());
+    MH::SetBinning(&fHist, ((TH2D&)hsel).GetXaxis(), ((TH2D&)hsel).GetYaxis());
 
     //
@@ -161,6 +155,19 @@
     // calculation we assume a binomial error calculation.
     //
-    fHist.Divide(hsel, hall, 1, 1, "B");
+    fHist.Divide((TH2D*)&hsel, (TH2D*)&hall, 1, 1, "B");
 
     SetReadyToSave();
 }
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency and set the 'ReadyToSave' flag.
+//  The Efficiency is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcEfficiency::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
+{
+    Calc(*mcsel.GetHist(), *mcall.GetHist());
+
+}
Index: /trunk/MagicSoft/Mars/mhist/MHMcEfficiency.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMcEfficiency.h	(revision 1227)
+++ /trunk/MagicSoft/Mars/mhist/MHMcEfficiency.h	(revision 1228)
@@ -10,4 +10,5 @@
 
 class MMcEvt;
+class MHMcEnergyImpact;
 
 class MHMcEfficiency : public MParContainer
@@ -32,5 +33,6 @@
     TObject *DrawClone(Option_t* option = "") const;
 
-    void Calc(TH2D *hsel, TH2D *hall);
+    void Calc(const TH2D &hsel, const TH2D &hall);
+    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
 
     ClassDef(MHMcEfficiency, 1)  // Histogram container for montecarlo energy threshold
Index: /trunk/MagicSoft/Mars/mhist/MHMcEfficiencyEnergy.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMcEfficiencyEnergy.cc	(revision 1228)
+++ /trunk/MagicSoft/Mars/mhist/MHMcEfficiencyEnergy.cc	(revision 1228)
@@ -0,0 +1,171 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
+!   Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHMcEfficiencyEnergy
+//
+// This class holds the information (histogram and fit function)
+// about the energy threshold for a particular trigger condition.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHMcEfficiencyEnergy.h" 
+
+#include <math.h>
+
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MHMcEnergyImpact.h"
+
+ClassImp(MHMcEfficiencyEnergy);
+
+// -------------------------------------------------------------------------
+//
+//  Default Constructor.
+//
+MHMcEfficiencyEnergy::MHMcEfficiencyEnergy(const char *name, const char *title)
+    : fHist()
+{
+    fName  = name  ? name  : "MHMcEfficiencyEnergy";
+    fTitle = title ? title : "Trigger Efficieny vs. Energy";
+
+    //  - we initialize the histogram
+    //  - we have to give diferent names for the diferent histograms because
+    //    root don't allow us to have diferent histograms with the same name
+
+    fHist.SetName(fName);
+    fHist.SetTitle(fTitle);
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("E [GeV]");
+    fHist.SetYTitle("Trig. Eff. [1]");
+
+    MBinning binse;
+    binse.SetEdgesLog(10, 1, 100000); // [GeV]
+    MH::SetBinning(&fHist, &binse);
+}
+
+void MHMcEfficiencyEnergy::SetName(const char *name)
+{
+    fName = name;
+    fHist.SetName(name);
+    fHist.SetDirectory(NULL);
+}
+
+void MHMcEfficiencyEnergy::SetTitle(const char *title)
+{
+    fTitle = title;
+    fHist.SetTitle(title);
+}
+
+//-------------------------------------------------------------------------
+//
+//  Defualt Destructor
+//
+MHMcEfficiencyEnergy::~MHMcEfficiencyEnergy()
+{
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcEfficiencyEnergy::Draw(Option_t *option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(&fHist);
+
+    gPad->SetLogx();
+
+    fHist.Draw(option);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TObject *MHMcEfficiencyEnergy::DrawClone(Option_t *option) const
+{
+    TCanvas *c = MH::MakeDefCanvas(&fHist);
+
+    c->SetLogx();
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    ((TH1D&)fHist).DrawCopy(option);
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+void MHMcEfficiencyEnergy::Calc(const TH2D &hsel, const TH2D &hall)
+{
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, ((TH2D&)hsel).GetXaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    //
+    // Calculate the efficiency by dividing the number of selected
+    // (eg. triggered) showers by the number of all showers per bin.
+    // Both histograms are weighted with weight 1, and for the error
+    // calculation we assume a binomial error calculation.
+    //
+    TH1D &tsel = *((TH2D&)hsel).ProjectionX();
+    TH1D &tall = *((TH2D&)hall).ProjectionX();
+    fHist.Divide(&tsel, &tall, 1, 1);
+    delete &tsel;
+    delete &tall;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the EfficiencyEnergy and set the 'ReadyToSave' flag.
+//  The EfficiencyEnergy is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcEfficiencyEnergy::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
+{
+    Calc(*mcsel.GetHist(), *mcall.GetHist());
+}
Index: /trunk/MagicSoft/Mars/mhist/MHMcEfficiencyEnergy.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMcEfficiencyEnergy.h	(revision 1228)
+++ /trunk/MagicSoft/Mars/mhist/MHMcEfficiencyEnergy.h	(revision 1228)
@@ -0,0 +1,41 @@
+#ifndef MARS_MHMcEfficiencyEnergy
+#define MARS_MHMcEfficiencyEnergy
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class MMcEvt;
+class MHMcEnergyImpact;
+
+class MHMcEfficiencyEnergy : public MParContainer
+{
+private:
+
+    TH1D fHist;           // histogram with the logarith of the energy
+
+    // const MMcEvt *fMcEvt;  //! container to fill histogram from
+
+public:
+    MHMcEfficiencyEnergy(const char *name=NULL, const char *title=NULL);
+    ~MHMcEfficiencyEnergy();
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH1D *GetHist()       { return &fHist; }
+    const TH1D *GetHist() const { return &fHist; }
+
+    void Draw(Option_t* option = "");
+    TObject *DrawClone(Option_t* option = "") const;
+
+    void Calc(const TH2D &hsel, const TH2D &hall);
+    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
+
+    ClassDef(MHMcEfficiencyEnergy, 1)  // Histogram container for montecarlo energy threshold
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/mhist/MHMcEfficiencyImpact.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMcEfficiencyImpact.cc	(revision 1228)
+++ /trunk/MagicSoft/Mars/mhist/MHMcEfficiencyImpact.cc	(revision 1228)
@@ -0,0 +1,171 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
+!   Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHMcEfficiencyImpact
+//
+// This class holds the information (histogram and fit function)
+// about the energy threshold for a particular trigger condition.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHMcEfficiencyImpact.h" 
+
+#include <math.h>
+
+#include <TCanvas.h>
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MHMcEnergyImpact.h"
+
+ClassImp(MHMcEfficiencyImpact);
+
+// -------------------------------------------------------------------------
+//
+//  Default Constructor.
+//
+MHMcEfficiencyImpact::MHMcEfficiencyImpact(const char *name, const char *title)
+    : fHist()
+{
+    fName  = name  ? name  : "MHMcEfficiencyImpact";
+    fTitle = title ? title : "Trigger Efficieny vs. Impact";
+
+    //  - we initialize the histogram
+    //  - we have to give diferent names for the diferent histograms because
+    //    root don't allow us to have diferent histograms with the same name
+
+    fHist.SetName(fName);
+    fHist.SetTitle(fTitle);
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("r [m]");
+    fHist.SetYTitle("Trig. Eff. [1]");
+
+
+    MBinning binsr;
+    binsr.SetEdges(9, 0, 450);       // [m]
+    MH::SetBinning(&fHist, &binsr);
+}
+
+void MHMcEfficiencyImpact::SetName(const char *name)
+{
+    fName = name;
+    fHist.SetName(name);
+    fHist.SetDirectory(NULL);
+}
+
+void MHMcEfficiencyImpact::SetTitle(const char *title)
+{
+    fTitle = title;
+    fHist.SetTitle(title);
+}
+
+//-------------------------------------------------------------------------
+//
+//  Defualt Destructor
+//
+MHMcEfficiencyImpact::~MHMcEfficiencyImpact()
+{
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcEfficiencyImpact::Draw(Option_t *option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(&fHist);
+
+    gPad->SetLogx();
+
+    fHist.Draw(option);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TObject *MHMcEfficiencyImpact::DrawClone(Option_t *option) const
+{
+    TCanvas *c = MH::MakeDefCanvas(&fHist);
+
+    c->SetLogx();
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    ((TH1D&)fHist).DrawCopy(option);
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+void MHMcEfficiencyImpact::Calc(const TH2D &hsel, const TH2D &hall)
+{
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, ((TH2D&)hsel).GetYaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    //
+    // Calculate the efficiency by dividing the number of selected
+    // (eg. triggered) showers by the number of all showers per bin.
+    // Both histograms are weighted with weight 1, and for the error
+    // calculation we assume a binomial error calculation.
+    //
+    TH1D &tsel = *((TH2D&)hsel).ProjectionY();
+    TH1D &tall = *((TH2D&)hall).ProjectionY();
+    fHist.Divide(&tsel, &tall, 1, 1);
+    delete &tsel;
+    delete &tall;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the EfficiencyImpact and set the 'ReadyToSave' flag.
+//  The EfficiencyImpact is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcEfficiencyImpact::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
+{
+    Calc(*mcsel.GetHist(), *mcall.GetHist());
+}
Index: /trunk/MagicSoft/Mars/mhist/MHMcEfficiencyImpact.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMcEfficiencyImpact.h	(revision 1228)
+++ /trunk/MagicSoft/Mars/mhist/MHMcEfficiencyImpact.h	(revision 1228)
@@ -0,0 +1,41 @@
+#ifndef MARS_MHMcEfficiencyImpact
+#define MARS_MHMcEfficiencyImpact
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class MMcEvt;
+class MHMcEnergyImpact;
+
+class MHMcEfficiencyImpact : public MParContainer
+{
+private:
+
+    TH1D fHist;           // histogram with the logarith of the energy
+
+    // const MMcEvt *fMcEvt;  //! container to fill histogram from
+
+public:
+    MHMcEfficiencyImpact(const char *name=NULL, const char *title=NULL);
+    ~MHMcEfficiencyImpact();
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH1D *GetHist()       { return &fHist; }
+    const TH1D *GetHist() const { return &fHist; }
+
+    void Draw(Option_t* option = "");
+    TObject *DrawClone(Option_t* option = "") const;
+
+    void Calc(const TH2D &hsel, const TH2D &hall);
+    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
+
+    ClassDef(MHMcEfficiencyImpact, 1)  // Histogram container for montecarlo energy threshold
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/mhist/MHMcIntRate.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMcIntRate.cc	(revision 1228)
+++ /trunk/MagicSoft/Mars/mhist/MHMcIntRate.cc	(revision 1228)
@@ -0,0 +1,150 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
+!   Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHMcIntRate
+//
+// This class holds the information (histogram and fit function)
+// about the energy threshold for a particular trigger condition.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHMcIntRate.h" 
+
+#include <math.h>
+
+#include <TCanvas.h>
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MHMcDifRate.h"
+
+ClassImp(MHMcIntRate);
+
+// -------------------------------------------------------------------------
+//
+//  Default Constructor.
+//
+MHMcIntRate::MHMcIntRate(const char *name, const char *title)
+    : fHist()
+{
+    fName  = name  ? name  : "MHMcIntRate";
+    fTitle = title ? title : "Integral Trigger Rate";
+
+    //  - we initialize the histogram
+    //  - we have to give diferent names for the diferent histograms because
+    //    root don't allow us to have diferent histograms with the same name
+
+    fHist.SetName(fName);
+    fHist.SetTitle(fTitle);
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("E [GeV]");
+    fHist.SetYTitle("Rate [Hz]");
+}
+
+void MHMcIntRate::SetName(const char *name)
+{
+    fName = name;
+    fHist.SetName(name);
+    fHist.SetDirectory(NULL);
+}
+
+void MHMcIntRate::SetTitle(const char *title)
+{
+    fTitle = title;
+    fHist.SetTitle(title);
+}
+
+//-------------------------------------------------------------------------
+//
+//  Defualt Destructor
+//
+MHMcIntRate::~MHMcIntRate()
+{
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcIntRate::Draw(Option_t *option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(&fHist);
+
+    gPad->SetLogx();
+
+    fHist.Draw(option);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TObject *MHMcIntRate::DrawClone(Option_t *option) const
+{
+    TCanvas *c = MH::MakeDefCanvas(&fHist);
+
+    c->SetLogx();
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    ((TH1D&)fHist).DrawCopy(option);
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the IntRate and set the 'ReadyToSave' flag.
+//  The IntRate is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcIntRate::Calc(const MHMcDifRate &rate)
+{
+    /*const*/ TH1D  &hist = (TH1D&)*rate.GetHist();
+    const TAxis &axis = *hist.GetXaxis();
+
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, &axis);
+
+    const Int_t nbinsx = axis.GetNbins();
+
+    for (Int_t i=1; i<=nbinsx; i++)
+        fHist.SetBinContent(i, hist.Integral(i, nbinsx, "width"));
+
+    SetReadyToSave();
+}
Index: /trunk/MagicSoft/Mars/mhist/MHMcIntRate.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHMcIntRate.h	(revision 1228)
+++ /trunk/MagicSoft/Mars/mhist/MHMcIntRate.h	(revision 1228)
@@ -0,0 +1,39 @@
+#ifndef MARS_MHMcIntRate
+#define MARS_MHMcIntRate
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+class MHMcDifRate;
+
+class MHMcIntRate : public MParContainer
+{
+private:
+
+    TH1D fHist;           // histogram with the logarith of the energy
+
+    // const MMcEvt *fMcEvt;  //! container to fill histogram from
+
+public:
+    MHMcIntRate(const char *name=NULL, const char *title=NULL);
+    ~MHMcIntRate();
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH1D *GetHist()       { return &fHist; }
+    const TH1D *GetHist() const { return &fHist; }
+
+    void Draw(Option_t* option = "");
+    TObject *DrawClone(Option_t* option = "") const;
+
+    void Calc(const MHMcDifRate &rate);
+
+    ClassDef(MHMcIntRate, 1)  // Histogram container for montecarlo energy threshold
+};
+
+#endif
Index: /trunk/MagicSoft/Mars/mhist/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mhist/Makefile	(revision 1227)
+++ /trunk/MagicSoft/Mars/mhist/Makefile	(revision 1228)
@@ -47,6 +47,10 @@
            MHMcEnergy.cc \
            MHMcEfficiency.cc \
+           MHMcEfficiencyImpact.cc \
+           MHMcEfficiencyEnergy.cc \
            MHMcEnergyImpact.cc \
-	   MHMcRate.cc
+	   MHMcRate.cc \
+	   MHMcIntRate.cc \
+	   MHMcDifRate.cc 
 
 SRCS    = $(SRCFILES)
