source: trunk/MagicSoft/Mars/mhist/MHMcEfficiencyImpact.cc@ 1951

Last change on this file since 1951 was 1228, checked in by tbretz, 23 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.6 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// MHMcEfficiencyImpact
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 "MHMcEfficiencyImpact.h"
35
36#include <math.h>
37
38#include <TCanvas.h>
39
40#include "MH.h"
41#include "MBinning.h"
42
43#include "MHMcEnergyImpact.h"
44
45ClassImp(MHMcEfficiencyImpact);
46
47// -------------------------------------------------------------------------
48//
49// Default Constructor.
50//
51MHMcEfficiencyImpact::MHMcEfficiencyImpact(const char *name, const char *title)
52 : fHist()
53{
54 fName = name ? name : "MHMcEfficiencyImpact";
55 fTitle = title ? title : "Trigger Efficieny vs. Impact";
56
57 // - we initialize the histogram
58 // - we have to give diferent names for the diferent histograms because
59 // root don't allow us to have diferent histograms with the same name
60
61 fHist.SetName(fName);
62 fHist.SetTitle(fTitle);
63
64 fHist.SetDirectory(NULL);
65
66 fHist.SetXTitle("r [m]");
67 fHist.SetYTitle("Trig. Eff. [1]");
68
69
70 MBinning binsr;
71 binsr.SetEdges(9, 0, 450); // [m]
72 MH::SetBinning(&fHist, &binsr);
73}
74
75void MHMcEfficiencyImpact::SetName(const char *name)
76{
77 fName = name;
78 fHist.SetName(name);
79 fHist.SetDirectory(NULL);
80}
81
82void MHMcEfficiencyImpact::SetTitle(const char *title)
83{
84 fTitle = title;
85 fHist.SetTitle(title);
86}
87
88//-------------------------------------------------------------------------
89//
90// Defualt Destructor
91//
92MHMcEfficiencyImpact::~MHMcEfficiencyImpact()
93{
94}
95
96// ------------------------------------------------------------------------
97//
98// Drawing function. It creates its own canvas.
99//
100void MHMcEfficiencyImpact::Draw(Option_t *option)
101{
102 if (!gPad)
103 MH::MakeDefCanvas(&fHist);
104
105 gPad->SetLogx();
106
107 fHist.Draw(option);
108
109 gPad->Modified();
110 gPad->Update();
111}
112
113TObject *MHMcEfficiencyImpact::DrawClone(Option_t *option) const
114{
115 TCanvas *c = MH::MakeDefCanvas(&fHist);
116
117 c->SetLogx();
118
119 //
120 // This is necessary to get the expected bahviour of DrawClone
121 //
122 gROOT->SetSelectedPad(NULL);
123
124 ((TH1D&)fHist).DrawCopy(option);
125
126 c->Modified();
127 c->Update();
128
129 return c;
130}
131
132void MHMcEfficiencyImpact::Calc(const TH2D &hsel, const TH2D &hall)
133{
134 //
135 // Set the binning from the two axis of one of the two histograms
136 //
137 MH::SetBinning(&fHist, ((TH2D&)hsel).GetYaxis());
138
139 //
140 // This is necessary to initialize thze error calculation correctly
141 // (Nothing important: The histogram set the size of its internal
142 // array storing the errors to the correct size)
143 //
144 fHist.Sumw2();
145
146 //
147 // Calculate the efficiency by dividing the number of selected
148 // (eg. triggered) showers by the number of all showers per bin.
149 // Both histograms are weighted with weight 1, and for the error
150 // calculation we assume a binomial error calculation.
151 //
152 TH1D &tsel = *((TH2D&)hsel).ProjectionY();
153 TH1D &tall = *((TH2D&)hall).ProjectionY();
154 fHist.Divide(&tsel, &tall, 1, 1);
155 delete &tsel;
156 delete &tall;
157
158 SetReadyToSave();
159}
160
161// --------------------------------------------------------------------------
162//
163// Calculate the EfficiencyImpact and set the 'ReadyToSave' flag.
164// The EfficiencyImpact is calculated as the number of selected showers
165// (eg. triggered ones) divided by the number of all showers.
166// For error calculation Binomial errors are computed.
167//
168void MHMcEfficiencyImpact::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
169{
170 Calc(*mcsel.GetHist(), *mcall.GetHist());
171}
Note: See TracBrowser for help on using the repository browser.