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 1/2003 <mailto:wittek@mppmu.mpg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2002
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | // //
|
---|
27 | // MHSigmaTheta (extension of Robert's MHSigmabarTheta) //
|
---|
28 | // //
|
---|
29 | // calculates - the 2D-histogram sigmabar vs. Theta, and //
|
---|
30 | // - the 3D-histogram sigma, pixel no., Theta //
|
---|
31 | // - the 3D-histogram (sigma^2-sigmabar^2), pixel no., Theta //
|
---|
32 | // //
|
---|
33 | //////////////////////////////////////////////////////////////////////////////
|
---|
34 |
|
---|
35 | #include "MHSigmaTheta.h"
|
---|
36 |
|
---|
37 | #include <TCanvas.h>
|
---|
38 |
|
---|
39 | #include "MTime.h"
|
---|
40 | #include "MMcEvt.hxx"
|
---|
41 |
|
---|
42 | #include "MBinning.h"
|
---|
43 | #include "MParList.h"
|
---|
44 | #include "MPedestalCam.h"
|
---|
45 | #include "MPedestalPix.h"
|
---|
46 | #include "MCerPhotEvt.h"
|
---|
47 | #include "MCerPhotPix.h"
|
---|
48 |
|
---|
49 | #include "MLog.h"
|
---|
50 | #include "MLogManip.h"
|
---|
51 |
|
---|
52 | #include "MSigmabar.h"
|
---|
53 |
|
---|
54 | ClassImp(MHSigmaTheta);
|
---|
55 |
|
---|
56 |
|
---|
57 | // --------------------------------------------------------------------------
|
---|
58 | //
|
---|
59 | // Default Constructor. It sets name and title of the histogram.
|
---|
60 | //
|
---|
61 | MHSigmaTheta::MHSigmaTheta(const char *name, const char *title)
|
---|
62 | : fSigmaTheta(), fSigmaPixTheta()
|
---|
63 | {
|
---|
64 | fName = name ? name : "MHSigmaTheta";
|
---|
65 | fTitle = title ? title : "2D histogram sigmabar vs. Theta";
|
---|
66 |
|
---|
67 | fSigmaTheta.SetDirectory(NULL);
|
---|
68 | fSigmaTheta.SetName("2D-ThetaSigmabar");
|
---|
69 | fSigmaTheta.SetTitle("2D : Sigmabar, \\Theta");
|
---|
70 | fSigmaTheta.SetXTitle("\\Theta [\\circ]");
|
---|
71 | fSigmaTheta.SetYTitle("Sigmabar");
|
---|
72 |
|
---|
73 | fSigmaPixTheta.SetDirectory(NULL);
|
---|
74 | fSigmaPixTheta.SetName("3D-ThetaPixSigma");
|
---|
75 | fSigmaPixTheta.SetTitle("3D : \\Theta, pixel no., Sigma");
|
---|
76 | fSigmaPixTheta.SetXTitle("\\Theta [\\circ]");
|
---|
77 | fSigmaPixTheta.SetYTitle("pixel number");
|
---|
78 | fSigmaPixTheta.SetZTitle("Sigma");
|
---|
79 |
|
---|
80 | fDiffPixTheta.SetDirectory(NULL);
|
---|
81 | fDiffPixTheta.SetName("3D-ThetaPixDiff");
|
---|
82 | fDiffPixTheta.SetTitle("3D : \\Theta, pixel, Sigma^2-Sigmabar^2");
|
---|
83 | fDiffPixTheta.SetXTitle("\\Theta [\\circ]");
|
---|
84 | fDiffPixTheta.SetYTitle("pixel number");
|
---|
85 | fDiffPixTheta.SetZTitle("Sigma^2-sigmabar^2");
|
---|
86 | }
|
---|
87 |
|
---|
88 | // --------------------------------------------------------------------------
|
---|
89 | //
|
---|
90 | // Set the binnings and prepare the filling of the histogram
|
---|
91 | //
|
---|
92 | Bool_t MHSigmaTheta::SetupFill(const MParList *plist)
|
---|
93 | {
|
---|
94 |
|
---|
95 | fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
|
---|
96 | if (!fMcEvt)
|
---|
97 | {
|
---|
98 | *fLog << err << dbginf << "MHSigmaTheta::SetupFill : MMcEvt not found... aborting." << endl;
|
---|
99 | return kFALSE;
|
---|
100 | }
|
---|
101 |
|
---|
102 | fPed = (MPedestalCam*)plist->FindObject("MPedestalCam");
|
---|
103 | if (!fPed)
|
---|
104 | {
|
---|
105 | *fLog << dbginf << "MHSigmaTheta::SetupFill : MPedestalCam not found... aborting." << endl;
|
---|
106 | return kFALSE;
|
---|
107 | }
|
---|
108 |
|
---|
109 | fCam = (MGeomCam*)plist->FindObject("MGeomCam");
|
---|
110 | if (!fCam)
|
---|
111 | {
|
---|
112 | *fLog << dbginf << "MHSigmaTheta::SetupFill : MGeomCam not found (no geometry information available)... aborting." << endl;
|
---|
113 | return kFALSE;
|
---|
114 | }
|
---|
115 |
|
---|
116 | fEvt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
|
---|
117 | if (!fEvt)
|
---|
118 | {
|
---|
119 | *fLog << dbginf << "MHSigmaTheta::SetupFill : MCerPhotEvt not found... aborting." << endl;
|
---|
120 | return kFALSE;
|
---|
121 | }
|
---|
122 |
|
---|
123 | fSigmabar = (MSigmabar*)plist->FindObject("MSigmabar");
|
---|
124 | if (!fSigmabar)
|
---|
125 | {
|
---|
126 | *fLog << dbginf << "MHSigmaTheta::SetupFill : MSigmabar not found... aborting." << endl;
|
---|
127 | return kFALSE;
|
---|
128 | }
|
---|
129 |
|
---|
130 | // Get Theta Binning
|
---|
131 | MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta");
|
---|
132 | if (!binstheta)
|
---|
133 | {
|
---|
134 | *fLog << err << dbginf << "MHSigmaTheta::SetupFill : BinningTheta not found... aborting." << endl;
|
---|
135 | return kFALSE;
|
---|
136 | }
|
---|
137 |
|
---|
138 | // Get Sigmabar binning
|
---|
139 | MBinning* binssigma = (MBinning*)plist->FindObject("BinningSigmabar");
|
---|
140 | if (!binssigma)
|
---|
141 | {
|
---|
142 | *fLog << err << dbginf << "MHSigmaTheta::SetupFill : BinningSigmabar not found... aborting." << endl;
|
---|
143 | return kFALSE;
|
---|
144 | }
|
---|
145 |
|
---|
146 | // Get binning for (sigma^2-sigmabar^2)
|
---|
147 | MBinning* binsdiff = (MBinning*)plist->FindObject("BinningDiffsigma2");
|
---|
148 | if (!binsdiff)
|
---|
149 | {
|
---|
150 | *fLog << err << dbginf << "MHSigmaTheta::SetupFill : BinningDiffsigma2 not found... aborting." << endl;
|
---|
151 | return kFALSE;
|
---|
152 | }
|
---|
153 |
|
---|
154 |
|
---|
155 | // Set binnings in histograms
|
---|
156 | SetBinning(&fSigmaTheta, binstheta, binssigma);
|
---|
157 |
|
---|
158 | // Get binning for pixel number
|
---|
159 | UInt_t npix = fPed->GetSize();
|
---|
160 | MBinning binspix("BinningPixel");
|
---|
161 | MBinning* binspixel = &binspix;
|
---|
162 | binspixel->SetEdges(npix, -0.5, ((float)npix)-0.5 );
|
---|
163 |
|
---|
164 | SetBinning(&fSigmaPixTheta, binstheta, binspixel, binssigma);
|
---|
165 | SetBinning(&fDiffPixTheta, binstheta, binspixel, binsdiff);
|
---|
166 |
|
---|
167 | return kTRUE;
|
---|
168 | }
|
---|
169 |
|
---|
170 | // --------------------------------------------------------------------------
|
---|
171 | //
|
---|
172 | // Fill the histograms
|
---|
173 | //
|
---|
174 | Bool_t MHSigmaTheta::Fill(const MParContainer *par)
|
---|
175 | {
|
---|
176 | //*fLog << "entry Fill" << endl;
|
---|
177 |
|
---|
178 | Double_t Theta = fMcEvt->GetTelescopeTheta()*kRad2Deg;
|
---|
179 | Double_t mySig = fSigmabar->Calc(*fCam, *fPed, *fEvt);
|
---|
180 | fSigmaTheta.Fill(Theta, mySig);
|
---|
181 |
|
---|
182 | //*fLog << "Theta, mySig = " << Theta << ", " << mySig << endl;
|
---|
183 |
|
---|
184 | const UInt_t npix = fEvt->GetNumPixels();
|
---|
185 | for (Int_t i=0; i<npix; i++)
|
---|
186 | {
|
---|
187 | MCerPhotPix cerpix = fEvt->operator[](i);
|
---|
188 | if (!cerpix.IsPixelUsed())
|
---|
189 | continue;
|
---|
190 |
|
---|
191 | if (cerpix.GetNumPhotons() == 0)
|
---|
192 | continue;
|
---|
193 |
|
---|
194 | Int_t j = cerpix.GetPixId();
|
---|
195 | const MPedestalPix pix = fPed->operator[](j);
|
---|
196 |
|
---|
197 | Double_t Sigma = pix.GetMeanRms();
|
---|
198 | Double_t Area = fCam->GetPixRatio(j);
|
---|
199 |
|
---|
200 | fSigmaPixTheta.Fill(Theta, (Double_t)j, Sigma);
|
---|
201 |
|
---|
202 | Double_t Diff = Sigma*Sigma/Area - mySig*mySig;
|
---|
203 | fDiffPixTheta.Fill (Theta, (Double_t)j, Diff);
|
---|
204 | }
|
---|
205 |
|
---|
206 | return kTRUE;
|
---|
207 | }
|
---|
208 |
|
---|
209 | // --------------------------------------------------------------------------
|
---|
210 | //
|
---|
211 | // Plot the results
|
---|
212 | //
|
---|
213 | Bool_t MHSigmaTheta::Finalize()
|
---|
214 | {
|
---|
215 | DrawClone();
|
---|
216 |
|
---|
217 | return kTRUE;
|
---|
218 | }
|
---|
219 |
|
---|
220 | // --------------------------------------------------------------------------
|
---|
221 | //
|
---|
222 | // Draw a copy of the histogram
|
---|
223 | //
|
---|
224 | TObject *MHSigmaTheta::DrawClone(Option_t *opt)
|
---|
225 | {
|
---|
226 | TCanvas &c = *MakeDefCanvas("SigmaTheta", "Sigmabar vs. Theta",
|
---|
227 | 900, 900);
|
---|
228 | c.Divide(3, 3);
|
---|
229 |
|
---|
230 | gROOT->SetSelectedPad(NULL);
|
---|
231 |
|
---|
232 | //--------------------------------------------------------------------
|
---|
233 | // draw the 2D histogram Sigmabar versus Theta
|
---|
234 | TH1D *h;
|
---|
235 |
|
---|
236 | c.cd(1);
|
---|
237 | h = ((TH2*)&fSigmaTheta)->ProjectionX("ProjX-Theta", -1, 9999, "E");
|
---|
238 | h->SetTitle("Distribution of \\Theta");
|
---|
239 | h->SetXTitle("\\Theta [\\circ]");
|
---|
240 | h->SetYTitle("No.of events");
|
---|
241 |
|
---|
242 | h->Draw(opt);
|
---|
243 | h->SetBit(kCanDelete);;
|
---|
244 | gPad->SetLogy();
|
---|
245 |
|
---|
246 | c.cd(4);
|
---|
247 | h = ((TH2*)&fSigmaTheta)->ProjectionY("ProjY-sigma", -1, 9999, "E");
|
---|
248 | h->SetTitle("Distribution of Sigmabar");
|
---|
249 | h->SetXTitle("Sigmabar");
|
---|
250 | h->SetYTitle("No.of events");
|
---|
251 |
|
---|
252 | h->Draw(opt);
|
---|
253 | h->SetBit(kCanDelete);;
|
---|
254 |
|
---|
255 | c.cd(7);
|
---|
256 | ((TH2*)&fSigmaTheta)->DrawCopy(opt);
|
---|
257 |
|
---|
258 | //--------------------------------------------------------------------
|
---|
259 | // draw the 3D histogram : Theta, pixel, Sigma^2-Sigmabar^2
|
---|
260 |
|
---|
261 | TH2D *l;
|
---|
262 |
|
---|
263 | c.cd(2);
|
---|
264 | l = (TH2D*) ((TH3*)&fDiffPixTheta)->Project3D("zx");
|
---|
265 | l->SetTitle("Sigma^2-Sigmabar^2 vs. \\Theta (all pixels)");
|
---|
266 | l->SetXTitle("\\Theta [\\circ]");
|
---|
267 | l->SetYTitle("Sigma^2-Sigmabar^2");
|
---|
268 |
|
---|
269 | l->Draw("box");
|
---|
270 | l->SetBit(kCanDelete);;
|
---|
271 |
|
---|
272 | c.cd(5);
|
---|
273 | l = (TH2D*) ((TH3*)&fDiffPixTheta)->Project3D("zy");
|
---|
274 | l->SetTitle("Sigma^2-Sigmabar^2 vs. pixel number (all \\Theta)");
|
---|
275 | l->SetXTitle("pixel");
|
---|
276 | l->SetYTitle("Sigma^2-Sigmabar^2");
|
---|
277 |
|
---|
278 | l->Draw("box");
|
---|
279 | l->SetBit(kCanDelete);;
|
---|
280 |
|
---|
281 | c.cd(8);
|
---|
282 | ((TH2*)&fDiffPixTheta)->DrawCopy(opt);
|
---|
283 |
|
---|
284 |
|
---|
285 | //--------------------------------------------------------------------
|
---|
286 | // draw the 3D histogram : Theta, pixel, Sigma
|
---|
287 |
|
---|
288 | TH2D *k;
|
---|
289 |
|
---|
290 | c.cd(3);
|
---|
291 | k = (TH2D*) ((TH3*)&fSigmaPixTheta)->Project3D("zx");
|
---|
292 | k->SetTitle("Sigma vs. \\Theta (all pixels)");
|
---|
293 | k->SetXTitle("\\Theta [\\circ]");
|
---|
294 | k->SetYTitle("Sigma");
|
---|
295 |
|
---|
296 | k->Draw("box");
|
---|
297 | k->SetBit(kCanDelete);;
|
---|
298 |
|
---|
299 | c.cd(6);
|
---|
300 | k = (TH2D*) ((TH3*)&fSigmaPixTheta)->Project3D("zy");
|
---|
301 | k->SetTitle("Sigma vs. pixel number (all \\Theta)");
|
---|
302 | k->SetXTitle("pixel");
|
---|
303 | k->SetYTitle("Sigma");
|
---|
304 |
|
---|
305 | k->Draw("box");
|
---|
306 | k->SetBit(kCanDelete);;
|
---|
307 |
|
---|
308 | c.cd(9);
|
---|
309 | ((TH2*)&fSigmaPixTheta)->DrawCopy(opt);
|
---|
310 |
|
---|
311 | //--------------------------------------------------------------------
|
---|
312 | c.Modified();
|
---|
313 | c.Update();
|
---|
314 |
|
---|
315 | return &c;
|
---|
316 | }
|
---|
317 |
|
---|
318 | // --------------------------------------------------------------------------
|
---|
319 | //
|
---|
320 | // Draw the histogram
|
---|
321 | //
|
---|
322 | void MHSigmaTheta::Draw(Option_t *opt)
|
---|
323 | {
|
---|
324 | if (!gPad)
|
---|
325 | MakeDefCanvas("SigmaTheta", "Sigmabar vs. Theta",
|
---|
326 | 600, 600);
|
---|
327 |
|
---|
328 | TH1D *h;
|
---|
329 |
|
---|
330 | gPad->Divide(2,2);
|
---|
331 |
|
---|
332 | gPad->cd(1);
|
---|
333 | h = ((TH2*)&fSigmaTheta)->ProjectionX("ProjX-Theta", -1, 9999, "E");
|
---|
334 | h->SetTitle("Distribution of \\Theta");
|
---|
335 | h->SetXTitle("\\Theta [\\circ]");
|
---|
336 | h->SetYTitle("No.of events");
|
---|
337 |
|
---|
338 | h->Draw(opt);
|
---|
339 | h->SetBit(kCanDelete);;
|
---|
340 | gPad->SetLogy();
|
---|
341 |
|
---|
342 | gPad->cd(2);
|
---|
343 | h = ((TH2*)&fSigmaTheta)->ProjectionY("ProjY-sigma", -1, 9999, "E");
|
---|
344 | h->SetTitle("Distribution of Sigmabar");
|
---|
345 | h->SetXTitle("Sigmabar");
|
---|
346 | h->SetYTitle("No.of events");
|
---|
347 |
|
---|
348 | h->Draw(opt);
|
---|
349 | h->SetBit(kCanDelete);;
|
---|
350 |
|
---|
351 | gPad->cd(3);
|
---|
352 | fSigmaTheta.DrawCopy(opt);
|
---|
353 |
|
---|
354 |
|
---|
355 |
|
---|
356 | gPad->Modified();
|
---|
357 | gPad->Update();
|
---|
358 | }
|
---|
359 | // --------------------------------------------------------------------------
|
---|
360 |
|
---|
361 |
|
---|
362 |
|
---|
363 |
|
---|