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, 03/2003 <mailto:wittek@mppmu.mpg.de>
|
---|
19 | ! Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | /////////////////////////////////////////////////////////////////////////////
|
---|
27 | //
|
---|
28 | // MHNewImagePar
|
---|
29 | //
|
---|
30 | ////////////////////////////////////////////////////////////////////////////
|
---|
31 | #include "MHNewImagePar.h"
|
---|
32 |
|
---|
33 | #include <math.h>
|
---|
34 |
|
---|
35 | #include <TH1.h>
|
---|
36 | #include <TPad.h>
|
---|
37 | #include <TCanvas.h>
|
---|
38 |
|
---|
39 | #include "MLog.h"
|
---|
40 | #include "MLogManip.h"
|
---|
41 |
|
---|
42 | #include "MGeomCam.h"
|
---|
43 | #include "MBinning.h"
|
---|
44 | #include "MParList.h"
|
---|
45 |
|
---|
46 | #include "MHillas.h"
|
---|
47 | #include "MNewImagePar.h"
|
---|
48 |
|
---|
49 | ClassImp(MHNewImagePar);
|
---|
50 |
|
---|
51 | using namespace std;
|
---|
52 |
|
---|
53 | // --------------------------------------------------------------------------
|
---|
54 | //
|
---|
55 | // Setup histograms
|
---|
56 | //
|
---|
57 | MHNewImagePar::MHNewImagePar(const char *name, const char *title)
|
---|
58 | {
|
---|
59 | fName = name ? name : "MHNewImagePar";
|
---|
60 | fTitle = title ? title : "Histograms of new image parameters";
|
---|
61 |
|
---|
62 | fHistLeakage1.SetName("Leakage1");
|
---|
63 | fHistLeakage1.SetTitle("Leakage_{1}");
|
---|
64 | fHistLeakage1.SetXTitle("Leakage");
|
---|
65 | fHistLeakage1.SetYTitle("Counts");
|
---|
66 | fHistLeakage1.SetDirectory(NULL);
|
---|
67 | fHistLeakage1.UseCurrentStyle();
|
---|
68 | fHistLeakage1.SetFillStyle(4000);
|
---|
69 |
|
---|
70 | fHistLeakage2.SetName("Leakage2");
|
---|
71 | fHistLeakage2.SetTitle("Leakage_{2}");
|
---|
72 | fHistLeakage2.SetXTitle("Leakage");
|
---|
73 | fHistLeakage2.SetYTitle("Counts");
|
---|
74 | fHistLeakage2.SetDirectory(NULL);
|
---|
75 | fHistLeakage2.UseCurrentStyle();
|
---|
76 | fHistLeakage2.SetLineColor(kBlue);
|
---|
77 | fHistLeakage2.SetFillStyle(4000);
|
---|
78 |
|
---|
79 | fHistUsedPix.SetName("UsedPix");
|
---|
80 | fHistUsedPix.SetTitle("Number of used pixels");
|
---|
81 | fHistUsedPix.SetXTitle("Number of Pixels");
|
---|
82 | fHistUsedPix.SetYTitle("Counts");
|
---|
83 | fHistUsedPix.SetDirectory(NULL);
|
---|
84 | fHistUsedPix.UseCurrentStyle();
|
---|
85 | fHistUsedPix.SetLineColor(kBlue);
|
---|
86 | fHistUsedPix.SetFillStyle(4000);
|
---|
87 |
|
---|
88 | fHistCorePix.SetName("CorePix");
|
---|
89 | fHistCorePix.SetTitle("Number of core pixels");
|
---|
90 | fHistCorePix.SetXTitle("Number of Pixels");
|
---|
91 | fHistCorePix.SetYTitle("Counts");
|
---|
92 | fHistCorePix.SetDirectory(NULL);
|
---|
93 | fHistCorePix.UseCurrentStyle();
|
---|
94 | fHistCorePix.SetLineColor(kBlack);
|
---|
95 | fHistCorePix.SetFillStyle(4000);
|
---|
96 |
|
---|
97 | fHistUsedArea.SetName("UsedArea");
|
---|
98 | fHistUsedArea.SetTitle("Area of used pixels");
|
---|
99 | fHistUsedArea.SetXTitle("Area [m^2]");
|
---|
100 | fHistUsedArea.SetYTitle("Counts");
|
---|
101 | fHistUsedArea.SetDirectory(NULL);
|
---|
102 | fHistUsedArea.UseCurrentStyle();
|
---|
103 | fHistUsedArea.SetLineColor(kBlue);
|
---|
104 | fHistUsedArea.SetFillStyle(4000);
|
---|
105 |
|
---|
106 | fHistCoreArea.SetName("CoreArea");
|
---|
107 | fHistCoreArea.SetTitle("Area of core pixels");
|
---|
108 | fHistCoreArea.SetXTitle("Area [m^2]");
|
---|
109 | fHistCoreArea.SetYTitle("Counts");
|
---|
110 | fHistCoreArea.SetDirectory(NULL);
|
---|
111 | fHistCoreArea.UseCurrentStyle();
|
---|
112 | fHistCoreArea.SetLineColor(kBlack);
|
---|
113 | fHistCoreArea.SetFillStyle(4000);
|
---|
114 |
|
---|
115 | fHistConc.SetDirectory(NULL);
|
---|
116 | fHistConc1.SetDirectory(NULL);
|
---|
117 | fHistConc.SetName("Conc2");
|
---|
118 | fHistConc1.SetName("Conc1");
|
---|
119 | fHistConc.SetTitle("Ratio: Conc");
|
---|
120 | fHistConc1.SetTitle("Ratio: Conc1");
|
---|
121 | fHistConc.SetXTitle("Ratio");
|
---|
122 | fHistConc1.SetXTitle("Ratio");
|
---|
123 | fHistConc.SetYTitle("Counts");
|
---|
124 | fHistConc1.SetYTitle("Counts");
|
---|
125 | fHistConc1.UseCurrentStyle();
|
---|
126 | fHistConc.UseCurrentStyle();
|
---|
127 | fHistConc.SetFillStyle(4000);
|
---|
128 | fHistConc1.SetFillStyle(4000);
|
---|
129 | fHistConc1.SetLineColor(kBlue);
|
---|
130 | fHistConc.SetFillStyle(0);
|
---|
131 |
|
---|
132 |
|
---|
133 | MBinning bins;
|
---|
134 |
|
---|
135 | bins.SetEdges(100, 0, 1);
|
---|
136 | bins.Apply(fHistLeakage1);
|
---|
137 | bins.Apply(fHistLeakage2);
|
---|
138 | bins.Apply(fHistConc);
|
---|
139 | bins.Apply(fHistConc1);
|
---|
140 |
|
---|
141 | bins.SetEdges(75, 0, 150);
|
---|
142 | bins.Apply(fHistUsedPix);
|
---|
143 | bins.Apply(fHistCorePix);
|
---|
144 |
|
---|
145 | bins.SetEdges(75, 0, 0.249);
|
---|
146 | bins.Apply(fHistUsedArea);
|
---|
147 | bins.Apply(fHistCoreArea);
|
---|
148 | }
|
---|
149 |
|
---|
150 | // --------------------------------------------------------------------------
|
---|
151 | //
|
---|
152 | // Setup the Binning for the histograms automatically if the correct
|
---|
153 | // instances of MBinning
|
---|
154 | //
|
---|
155 | Bool_t MHNewImagePar::SetupFill(const MParList *plist)
|
---|
156 | {
|
---|
157 | ApplyBinning(*plist, "Leakage", &fHistLeakage1);
|
---|
158 | ApplyBinning(*plist, "Leakage", &fHistLeakage2);
|
---|
159 |
|
---|
160 | ApplyBinning(*plist, "Pixels", &fHistUsedPix);
|
---|
161 | ApplyBinning(*plist, "Pixels", &fHistCorePix);
|
---|
162 |
|
---|
163 | ApplyBinning(*plist, "Area", &fHistUsedArea);
|
---|
164 | ApplyBinning(*plist, "Area", &fHistCoreArea);
|
---|
165 |
|
---|
166 | ApplyBinning(*plist, "Conc", &fHistConc);
|
---|
167 | ApplyBinning(*plist, "Conc1", &fHistConc1);
|
---|
168 |
|
---|
169 | return kTRUE;
|
---|
170 | }
|
---|
171 |
|
---|
172 |
|
---|
173 | // --------------------------------------------------------------------------
|
---|
174 | //
|
---|
175 | // Fill the histograms with data from a MNewImagePar container.
|
---|
176 | //
|
---|
177 | Bool_t MHNewImagePar::Fill(const MParContainer *par, const Stat_t w)
|
---|
178 | {
|
---|
179 | if (!par)
|
---|
180 | {
|
---|
181 | *fLog << err << "MHNewImagePar::Fill: Pointer (!=NULL) expected." << endl;
|
---|
182 | return kFALSE;
|
---|
183 | }
|
---|
184 |
|
---|
185 | const MNewImagePar &h = *(MNewImagePar*)par;
|
---|
186 |
|
---|
187 | fHistLeakage1.Fill(h.GetLeakage1(), w);
|
---|
188 | fHistLeakage2.Fill(h.GetLeakage2(), w);
|
---|
189 |
|
---|
190 | fHistUsedPix.Fill(h.GetNumUsedPixels(), w);
|
---|
191 | fHistCorePix.Fill(h.GetNumCorePixels(), w);
|
---|
192 |
|
---|
193 | fHistUsedArea.Fill(h.GetUsedArea()/1000000, w);
|
---|
194 | fHistCoreArea.Fill(h.GetCoreArea()/1000000, w);
|
---|
195 |
|
---|
196 | fHistConc.Fill(h.GetConc(), w);
|
---|
197 | fHistConc1.Fill(h.GetConc1(), w);
|
---|
198 |
|
---|
199 | return kTRUE;
|
---|
200 | }
|
---|
201 |
|
---|
202 | void MHNewImagePar::Paint(Option_t *)
|
---|
203 | {
|
---|
204 | TVirtualPad *savepad = gPad;
|
---|
205 | if (fHistLeakage1.GetEntries()>0 && fHistLeakage2.GetEntries()>0)
|
---|
206 | {
|
---|
207 | fHistLeakage1.SetMinimum(-1111);
|
---|
208 | fHistLeakage2.SetMinimum(-1111);
|
---|
209 | gPad->cd(1);
|
---|
210 | gPad->SetLogy();
|
---|
211 | }
|
---|
212 | gPad = savepad;
|
---|
213 | }
|
---|
214 |
|
---|
215 | // --------------------------------------------------------------------------
|
---|
216 | //
|
---|
217 | // Creates a new canvas and draws the two histograms into it.
|
---|
218 | // Be careful: The histograms belongs to this object and won't get deleted
|
---|
219 | // together with the canvas.
|
---|
220 | //
|
---|
221 | void MHNewImagePar::Draw(Option_t *)
|
---|
222 | {
|
---|
223 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
---|
224 | pad->SetBorderMode(0);
|
---|
225 |
|
---|
226 | AppendPad("");
|
---|
227 |
|
---|
228 | pad->Divide(2,2);
|
---|
229 |
|
---|
230 | pad->cd(1);
|
---|
231 | gPad->SetBorderMode(0);
|
---|
232 | TAxis &x = *fHistLeakage1.GetXaxis();
|
---|
233 | x.SetRangeUser(0.0, x.GetXmax());
|
---|
234 | MH::DrawSame(fHistLeakage1, fHistLeakage2, "Leakage1 and Leakage2");
|
---|
235 |
|
---|
236 | pad->cd(2);
|
---|
237 | gPad->SetBorderMode(0);
|
---|
238 | MH::DrawSame(fHistCorePix, fHistUsedPix, "Number of core/used Pixels");
|
---|
239 |
|
---|
240 | pad->cd(3);
|
---|
241 | gPad->SetBorderMode(0);
|
---|
242 | MH::DrawSame(fHistConc1, fHistConc, "Concentrations");
|
---|
243 |
|
---|
244 | pad->cd(4);
|
---|
245 | gPad->SetBorderMode(0);
|
---|
246 | MH::DrawSame(fHistCoreArea, fHistUsedArea, "Area of core/used Pixels");
|
---|
247 |
|
---|
248 | pad->Modified();
|
---|
249 | pad->Update();
|
---|
250 | }
|
---|
251 |
|
---|
252 | TH1 *MHNewImagePar::GetHistByName(const TString name)
|
---|
253 | {
|
---|
254 | if (name.Contains("Leakage1", TString::kIgnoreCase))
|
---|
255 | return &fHistLeakage1;
|
---|
256 | if (name.Contains("Leakage2", TString::kIgnoreCase))
|
---|
257 | return &fHistLeakage2;
|
---|
258 | if (name.Contains("Conc", TString::kIgnoreCase))
|
---|
259 | return &fHistConc;
|
---|
260 | if (name.Contains("Conc1", TString::kIgnoreCase))
|
---|
261 | return &fHistConc1;
|
---|
262 | if (name.Contains("UsedPix", TString::kIgnoreCase))
|
---|
263 | return &fHistUsedPix;
|
---|
264 | if (name.Contains("CorePix", TString::kIgnoreCase))
|
---|
265 | return &fHistCorePix;
|
---|
266 | if (name.Contains("UsedArea", TString::kIgnoreCase))
|
---|
267 | return &fHistUsedArea;
|
---|
268 | if (name.Contains("CoreArea", TString::kIgnoreCase))
|
---|
269 | return &fHistCoreArea;
|
---|
270 |
|
---|
271 | return NULL;
|
---|
272 | }
|
---|