source: trunk/Mars/mhistmc/MHMcEfficiency.cc@ 13369

Last change on this file since 13369 was 2017, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.2 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
19! Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2001
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MHMcEfficiency
29//
30// This class holds the information (histogram and fit function)
31// about the energy threshold for a particular trigger condition.
32//
33////////////////////////////////////////////////////////////////////////////
34#include "MHMcEfficiency.h"
35
36#include <math.h>
37
38#include <TH2.h>
39#include <TCanvas.h>
40
41#include "MH.h"
42#include "MBinning.h"
43
44#include "MHMcEnergyImpact.h"
45
46ClassImp(MHMcEfficiency);
47
48// -------------------------------------------------------------------------
49//
50// Default Constructor.
51//
52MHMcEfficiency::MHMcEfficiency(const char *name, const char *title)
53 : fHist()
54{
55 fName = name ? name : "MHMcEfficiency";
56 fTitle = title ? title : "Trigger Efficieny (Energy-Impact parameter plane)";
57
58 // - we initialize the histogram
59 // - we have to give diferent names for the diferent histograms because
60 // root don't allow us to have diferent histograms with the same name
61
62 fHist.SetName(fName);
63 fHist.SetTitle(fTitle);
64
65 fHist.SetDirectory(NULL);
66
67 fHist.SetXTitle("E [GeV]");
68 fHist.SetYTitle("r [m]");
69 fHist.SetZTitle("Trig. Eff. [1]");
70
71
72 MBinning binsx;
73 binsx.SetEdgesLog(10, 1, 100000); // [GeV]
74
75 MBinning binsy;
76 binsy.SetEdges(9, 0, 450); // [m]
77 MH::SetBinning(&fHist, &binsx, &binsy);
78}
79
80void MHMcEfficiency::SetName(const char *name)
81{
82 fName = name;
83 fHist.SetName(name);
84 fHist.SetDirectory(NULL);
85}
86
87void MHMcEfficiency::SetTitle(const char *title)
88{
89 fTitle = title;
90 fHist.SetTitle(title);
91}
92
93// ------------------------------------------------------------------------
94//
95// Drawing function. It creates its own canvas.
96//
97void MHMcEfficiency::Draw(Option_t *option)
98{
99 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
100 pad->SetBorderMode(0);
101
102 AppendPad("");
103
104 pad->SetLogx();
105
106 fHist.Draw(option);
107
108 pad->Modified();
109 pad->Update();
110}
111
112void MHMcEfficiency::Calc(const TH2D &hsel, const TH2D &hall)
113{
114 //
115 // Set the binning from the two axis of one of the two histograms
116 //
117 MH::SetBinning(&fHist, ((TH2D&)hsel).GetXaxis(), ((TH2D&)hsel).GetYaxis());
118
119 //
120 // This is necessary to initialize thze error calculation correctly
121 // (Nothing important: The histogram set the size of its internal
122 // array storing the errors to the correct size)
123 //
124 fHist.Sumw2();
125
126 //
127 // Calculate the efficiency by dividing the number of selected
128 // (eg. triggered) showers by the number of all showers per bin.
129 // Both histograms are weighted with weight 1, and for the error
130 // calculation we assume a binomial error calculation.
131 //
132 fHist.Divide((TH2D*)&hsel, (TH2D*)&hall, 1, 1, "B");
133
134 SetReadyToSave();
135}
136
137// --------------------------------------------------------------------------
138//
139// Calculate the Efficiency and set the 'ReadyToSave' flag.
140// The Efficiency is calculated as the number of selected showers
141// (eg. triggered ones) divided by the number of all showers.
142// For error calculation Binomial errors are computed.
143//
144void MHMcEfficiency::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
145{
146 Calc(*mcsel.GetHist(), *mcall.GetHist());
147
148}
Note: See TracBrowser for help on using the repository browser.