source: trunk/MagicSoft/Mars/mhist/MHSigmaTheta.cc@ 1965

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