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 |
|
---|
45 | ClassImp(MHMcEfficiencyImpact);
|
---|
46 |
|
---|
47 | // -------------------------------------------------------------------------
|
---|
48 | //
|
---|
49 | // Default Constructor.
|
---|
50 | //
|
---|
51 | MHMcEfficiencyImpact::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 |
|
---|
75 | void MHMcEfficiencyImpact::SetName(const char *name)
|
---|
76 | {
|
---|
77 | fName = name;
|
---|
78 | fHist.SetName(name);
|
---|
79 | fHist.SetDirectory(NULL);
|
---|
80 | }
|
---|
81 |
|
---|
82 | void MHMcEfficiencyImpact::SetTitle(const char *title)
|
---|
83 | {
|
---|
84 | fTitle = title;
|
---|
85 | fHist.SetTitle(title);
|
---|
86 | }
|
---|
87 |
|
---|
88 | // ------------------------------------------------------------------------
|
---|
89 | //
|
---|
90 | // Drawing function. It creates its own canvas.
|
---|
91 | //
|
---|
92 | void MHMcEfficiencyImpact::Draw(Option_t *option)
|
---|
93 | {
|
---|
94 | TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
|
---|
95 | pad->SetBorderMode(0);
|
---|
96 |
|
---|
97 | AppendPad("");
|
---|
98 |
|
---|
99 | pad->SetLogx();
|
---|
100 |
|
---|
101 | fHist.Draw(option);
|
---|
102 |
|
---|
103 | pad->Modified();
|
---|
104 | pad->Update();
|
---|
105 | }
|
---|
106 |
|
---|
107 | void MHMcEfficiencyImpact::Calc(const TH2D &hsel, const TH2D &hall)
|
---|
108 | {
|
---|
109 | //
|
---|
110 | // Set the binning from the two axis of one of the two histograms
|
---|
111 | //
|
---|
112 | MH::SetBinning(&fHist, ((TH2D&)hsel).GetYaxis());
|
---|
113 |
|
---|
114 | //
|
---|
115 | // This is necessary to initialize thze error calculation correctly
|
---|
116 | // (Nothing important: The histogram set the size of its internal
|
---|
117 | // array storing the errors to the correct size)
|
---|
118 | //
|
---|
119 | fHist.Sumw2();
|
---|
120 |
|
---|
121 | //
|
---|
122 | // Calculate the efficiency by dividing the number of selected
|
---|
123 | // (eg. triggered) showers by the number of all showers per bin.
|
---|
124 | // Both histograms are weighted with weight 1, and for the error
|
---|
125 | // calculation we assume a binomial error calculation.
|
---|
126 | //
|
---|
127 | TH1D &tsel = *((TH2D&)hsel).ProjectionY();
|
---|
128 | TH1D &tall = *((TH2D&)hall).ProjectionY();
|
---|
129 | fHist.Divide(&tsel, &tall, 1, 1);
|
---|
130 | delete &tsel;
|
---|
131 | delete &tall;
|
---|
132 |
|
---|
133 | SetReadyToSave();
|
---|
134 | }
|
---|
135 |
|
---|
136 | // --------------------------------------------------------------------------
|
---|
137 | //
|
---|
138 | // Calculate the EfficiencyImpact and set the 'ReadyToSave' flag.
|
---|
139 | // The EfficiencyImpact is calculated as the number of selected showers
|
---|
140 | // (eg. triggered ones) divided by the number of all showers.
|
---|
141 | // For error calculation Binomial errors are computed.
|
---|
142 | //
|
---|
143 | void MHMcEfficiencyImpact::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
|
---|
144 | {
|
---|
145 | Calc(*mcsel.GetHist(), *mcall.GetHist());
|
---|
146 | }
|
---|