source: trunk/MagicSoft/Mars/mhist/MHSupercuts.cc@ 4692

Last change on this file since 4692 was 2663, checked in by wittek, 21 years ago
*** empty log message ***
File size: 6.3 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): Wolfgang Wittek 2003 <mailto:wittek@mppmu.mpg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25///////////////////////////////////////////////////////////////////////
26//
27// MHSupercuts
28//
29// This class contains histograms for the supercuts
30//
31// the histograms are filled during the optimization of the supercuts
32//
33///////////////////////////////////////////////////////////////////////
34#include "MHSupercuts.h"
35
36#include <math.h>
37
38#include <TH1.h>
39#include <TH2.h>
40#include <TPad.h>
41#include <TCanvas.h>
42
43#include "MParList.h"
44#include "MHFindSignificance.h"
45
46#include "MLog.h"
47#include "MLogManip.h"
48
49ClassImp(MHSupercuts);
50
51using namespace std;
52
53// --------------------------------------------------------------------------
54//
55// Setup four histograms for Alpha, and Dist
56//
57MHSupercuts::MHSupercuts(const char *name, const char *title)
58{
59 //
60 // set the name and title of this object
61 //
62 fName = name ? name : "MHSupercuts";
63 fTitle = title ? title : "Container for histograms for the supercuts";
64
65
66 fDegree = new TH1F("Degree", "Degree of polynomial", 5, -0.5, 4.5);
67 fProb = new TH1F("Prob", "chi2 probability", 40, 0, 1.0);
68 fNdf = new TH1F("NDF", "NDF of polynomial fit", 60, -0.5, 59.5);
69 fGamma = new TH1F("gamma", "gamma", 40, 0.0, 8.0);
70 fNexNon = new TH1F("NexNon", "Nex / Non", 50, 0.0, 1.0);
71 fSigLiMa= new TH1F("Significance", "significance of gamma signal",
72 60, 0.0, 120.0);
73 fSigtoBackg= new TH2F("SigtoBackg", "Significance vs signal/backg ratio",
74 50, 0.0, 10.0, 60, 0.0, 120.0);
75 fSigDegree = new TH2F("SigDegree", "Significance vs Degree of polynomial",
76 5, -0.5, 4.5, 60, 0.0, 120.0);
77 fSigNbins = new TH2F("SigNbins", "Significance vs number of bins",
78 40, -0.5, 79.5, 60, 0.0, 120.0);
79
80 fDegree->SetDirectory(NULL);
81 fProb->SetDirectory(NULL);
82 fNdf->SetDirectory(NULL);
83 fGamma->SetDirectory(NULL);
84 fNexNon->SetDirectory(NULL);
85 fSigLiMa->SetDirectory(NULL);
86 fSigtoBackg->SetDirectory(NULL);
87 fSigDegree->SetDirectory(NULL);
88 fSigNbins->SetDirectory(NULL);
89
90 fDegree->SetXTitle("order of polynomial");
91 fProb->SetXTitle("chi2 probability of polynomial fit");
92 fNdf->SetXTitle("NDF of polynomial fit");
93 fGamma->SetXTitle("gamma");
94 fNexNon->SetXTitle("Nex / Non");
95 fSigLiMa->SetXTitle("significance");
96
97 fSigtoBackg->SetXTitle("signa./background ratio");
98 fSigtoBackg->SetYTitle("significance");
99
100 fSigDegree->SetXTitle("order of polynomial");
101 fSigDegree->SetYTitle("significance");
102
103 fSigNbins->SetXTitle("number of bins");
104 fSigNbins->SetYTitle("significance");
105
106 fDegree->SetYTitle("Counts");
107 fProb->SetYTitle("Counts");
108 fNdf->SetYTitle("Counts");
109 fGamma->SetYTitle("Counts");
110 fNexNon->SetYTitle("Counts");
111 fSigLiMa->SetYTitle("Counts");
112
113 fSigtoBackg->SetZTitle("Counts");
114 fSigDegree->SetZTitle("Counts");
115 fSigNbins->SetZTitle("Counts");
116}
117
118// --------------------------------------------------------------------------
119//
120// Delete the histograms
121//
122MHSupercuts::~MHSupercuts()
123{
124 delete fDegree;
125 delete fProb;
126 delete fNdf;
127 delete fGamma;
128 delete fNexNon;
129 delete fSigLiMa;
130
131 delete fSigtoBackg;
132 delete fSigDegree;
133 delete fSigNbins;
134}
135
136// --------------------------------------------------------------------------
137//
138// Fill the histograms from the 'MHFindSignificance' container
139//
140Bool_t MHSupercuts::Fill(const MParContainer *par, const Stat_t w)
141{
142 if (!par)
143 {
144 *fLog << err << "MHSupercuts::Fill: Pointer (!=NULL) expected." << endl;
145 return kFALSE;
146 }
147
148 MHFindSignificance &h = *(MHFindSignificance*)par;
149
150 fDegree ->Fill(h.GetDegree( ), w);
151 fProb ->Fill(h.GetProb(), w);
152 fNdf ->Fill(h.GetNdf(), w);
153 fGamma ->Fill(h.GetGamma(), w);
154
155 Double_t ratio = h.GetNon()>0.0 ? h.GetNex()/h.GetNon() : 0.0;
156 fNexNon ->Fill(ratio, w);
157
158 fSigLiMa ->Fill(h.GetSigLiMa(), w);
159
160 Double_t sigtobackg = h.GetNbg()!=0.0 ? h.GetNex() / h.GetNbg() : 0.0;
161 fSigtoBackg->Fill(sigtobackg, h.GetSigLiMa(), w);
162
163 fSigDegree ->Fill(h.GetDegree(), h.GetSigLiMa(), w);
164 fSigNbins ->Fill(h.GetMbins(), h.GetSigLiMa(), w);
165
166 return kTRUE;
167}
168
169
170// --------------------------------------------------------------------------
171//
172// Creates a new canvas and draws the two histograms into it.
173// Be careful: The histograms belongs to this object and won't get deleted
174// together with the canvas.
175//
176void MHSupercuts::Draw(Option_t *)
177{
178 //TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
179 //pad->SetBorderMode(0);
180 //AppendPad("");
181
182 TCanvas *pad = new TCanvas("Supercuts", "Supercut plots", 900, 900);
183 gROOT->SetSelectedPad(NULL);
184
185 pad->Divide(3, 3);
186
187 pad->cd(1);
188 gPad->SetBorderMode(0);
189 fDegree->Draw();
190
191 pad->cd(2);
192 gPad->SetBorderMode(0);
193 fProb->Draw();
194
195 pad->cd(3);
196 gPad->SetBorderMode(0);
197 fNdf->Draw();
198
199 pad->cd(4);
200 gPad->SetBorderMode(0);
201 fGamma->Draw();
202
203 pad->cd(5);
204 gPad->SetBorderMode(0);
205 fNexNon->Draw();
206
207 pad->cd(6);
208 gPad->SetBorderMode(0);
209 fSigLiMa->Draw();
210
211 pad->cd(7);
212 gPad->SetBorderMode(0);
213 fSigtoBackg->Draw();
214
215 pad->cd(8);
216 gPad->SetBorderMode(0);
217 fSigDegree->Draw();
218
219 pad->cd(9);
220 gPad->SetBorderMode(0);
221 fSigNbins->Draw();
222
223 pad->Modified();
224 pad->Update();
225}
Note: See TracBrowser for help on using the repository browser.