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 | ! Author(s): Thomas Bretz 4/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | //////////////////////////////////////////////////////////////////////////////
|
---|
27 | // //
|
---|
28 | // MHSigmaTheta (extension of Robert's MHSigmabarTheta) //
|
---|
29 | // //
|
---|
30 | // calculates - the 2D-histogram sigmabar vs. Theta, and //
|
---|
31 | // - the 3D-histogram sigma, pixel no., Theta //
|
---|
32 | // - the 3D-histogram (sigma^2-sigmabar^2), pixel no., Theta //
|
---|
33 | // //
|
---|
34 | //////////////////////////////////////////////////////////////////////////////
|
---|
35 |
|
---|
36 | #include "MHSigmaTheta.h"
|
---|
37 |
|
---|
38 | #include <TCanvas.h>
|
---|
39 |
|
---|
40 | #include "MTime.h"
|
---|
41 | #include "MMcEvt.hxx"
|
---|
42 |
|
---|
43 | #include "MBinning.h"
|
---|
44 | #include "MParList.h"
|
---|
45 | #include "MSigmabar.h"
|
---|
46 |
|
---|
47 | #include "MGeomCam.h"
|
---|
48 |
|
---|
49 | #include "MPedestalCam.h"
|
---|
50 | #include "MPedestalPix.h"
|
---|
51 |
|
---|
52 | #include "MCerPhotEvt.h"
|
---|
53 | #include "MCerPhotPix.h"
|
---|
54 |
|
---|
55 | #include "MLog.h"
|
---|
56 | #include "MLogManip.h"
|
---|
57 |
|
---|
58 |
|
---|
59 | ClassImp(MHSigmaTheta);
|
---|
60 |
|
---|
61 |
|
---|
62 | // --------------------------------------------------------------------------
|
---|
63 | //
|
---|
64 | // Default Constructor. It sets name and title of the histogram.
|
---|
65 | //
|
---|
66 | MHSigmaTheta::MHSigmaTheta(const char *name, const char *title)
|
---|
67 | : fSigmaTheta(), fSigmaPixTheta()
|
---|
68 | {
|
---|
69 | fName = name ? name : "MHSigmaTheta";
|
---|
70 | fTitle = title ? title : "2D histogram sigmabar vs. Theta";
|
---|
71 |
|
---|
72 | fSigmaTheta.SetDirectory(NULL);
|
---|
73 | fSigmaTheta.SetName("2D-ThetaSigmabar");
|
---|
74 | fSigmaTheta.SetTitle("2D: Sigmabar, \\Theta");
|
---|
75 | fSigmaTheta.SetXTitle("\\Theta [\\circ]");
|
---|
76 | fSigmaTheta.SetYTitle("Sigmabar");
|
---|
77 |
|
---|
78 | fSigmaPixTheta.SetDirectory(NULL);
|
---|
79 | fSigmaPixTheta.SetName("3D-ThetaPixSigma");
|
---|
80 | fSigmaPixTheta.SetTitle("3D : \\Theta, Pixel Id, Sigma");
|
---|
81 | fSigmaPixTheta.SetXTitle("\\Theta [\\circ]");
|
---|
82 | fSigmaPixTheta.SetYTitle("Pixel Id");
|
---|
83 | fSigmaPixTheta.SetZTitle("Sigma");
|
---|
84 |
|
---|
85 | fDiffPixTheta.SetDirectory(NULL);
|
---|
86 | fDiffPixTheta.SetName("3D-ThetaPixDiff");
|
---|
87 | fDiffPixTheta.SetTitle("3D : \\Theta, Pixel Id, Sigma^2-Sigmabar^2");
|
---|
88 | fDiffPixTheta.SetXTitle("\\Theta [\\circ]");
|
---|
89 | fDiffPixTheta.SetYTitle("Pixel Id");
|
---|
90 | fDiffPixTheta.SetZTitle("Sigma^2-Sigmabar^2");
|
---|
91 | }
|
---|
92 | // --------------------------------------------------------------------------
|
---|
93 | //
|
---|
94 | // Default Destructor
|
---|
95 | //
|
---|
96 | MHSigmaTheta::~MHSigmaTheta()
|
---|
97 | {
|
---|
98 |
|
---|
99 | }
|
---|
100 |
|
---|
101 | // --------------------------------------------------------------------------
|
---|
102 | //
|
---|
103 | // Set the binnings and prepare the filling of the histogram
|
---|
104 | //
|
---|
105 | Bool_t MHSigmaTheta::SetupFill(const MParList *plist)
|
---|
106 | {
|
---|
107 |
|
---|
108 | fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
|
---|
109 | if (!fMcEvt)
|
---|
110 | {
|
---|
111 | *fLog << err << "MMcEvt not found... aborting." << endl;
|
---|
112 | return kFALSE;
|
---|
113 | }
|
---|
114 |
|
---|
115 | fPed = (MPedestalCam*)plist->FindObject("MPedestalCam");
|
---|
116 | if (!fPed)
|
---|
117 | {
|
---|
118 | *fLog << err << "MPedestalCam not found... aborting." << endl;
|
---|
119 | return kFALSE;
|
---|
120 | }
|
---|
121 |
|
---|
122 | fCam = (MGeomCam*)plist->FindObject("MGeomCam");
|
---|
123 | if (!fCam)
|
---|
124 | {
|
---|
125 | *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
|
---|
126 | return kFALSE;
|
---|
127 | }
|
---|
128 |
|
---|
129 | fEvt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
|
---|
130 | if (!fEvt)
|
---|
131 | {
|
---|
132 | *fLog << err << "MCerPhotEvt not found... aborting." << endl;
|
---|
133 | return kFALSE;
|
---|
134 | }
|
---|
135 |
|
---|
136 | fSigmabar = (MSigmabar*)plist->FindObject("MSigmabar");
|
---|
137 | if (!fSigmabar)
|
---|
138 | {
|
---|
139 | *fLog << err << "MSigmabar not found... aborting." << endl;
|
---|
140 | return kFALSE;
|
---|
141 | }
|
---|
142 |
|
---|
143 | // Get Theta Binning
|
---|
144 | MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta");
|
---|
145 | if (!binstheta)
|
---|
146 | {
|
---|
147 | *fLog << err << "BinningTheta [MBinning] not found... aborting." << endl;
|
---|
148 | return kFALSE;
|
---|
149 | }
|
---|
150 |
|
---|
151 | // Get Sigmabar binning
|
---|
152 | MBinning* binssigma = (MBinning*)plist->FindObject("BinningSigmabar");
|
---|
153 | if (!binssigma)
|
---|
154 | {
|
---|
155 | *fLog << err << "BinningSigmabar [MBinning] not found... aborting." << endl;
|
---|
156 | return kFALSE;
|
---|
157 | }
|
---|
158 |
|
---|
159 | // Get binning for (sigma^2-sigmabar^2)
|
---|
160 | MBinning* binsdiff = (MBinning*)plist->FindObject("BinningDiffsigma2");
|
---|
161 | if (!binsdiff)
|
---|
162 | {
|
---|
163 | *fLog << err << "BinningDiffsigma2 [MBinning] not found... aborting." << endl;
|
---|
164 | return kFALSE;
|
---|
165 | }
|
---|
166 |
|
---|
167 |
|
---|
168 | // Set binnings in histograms
|
---|
169 | SetBinning(&fSigmaTheta, binstheta, binssigma);
|
---|
170 |
|
---|
171 | // Get binning for pixel number
|
---|
172 | const UInt_t npix = fPed->GetSize();
|
---|
173 |
|
---|
174 | MBinning binspix("BinningPixel");
|
---|
175 | binspix.SetEdges(npix+1, -0.5, 0.5+npix );
|
---|
176 |
|
---|
177 | SetBinning(&fSigmaPixTheta, binstheta, &binspix, binssigma);
|
---|
178 | SetBinning(&fDiffPixTheta, binstheta, &binspix, binsdiff);
|
---|
179 |
|
---|
180 | return kTRUE;
|
---|
181 | }
|
---|
182 |
|
---|
183 | // --------------------------------------------------------------------------
|
---|
184 | //
|
---|
185 | // Fill the histograms
|
---|
186 | //
|
---|
187 | Bool_t MHSigmaTheta::Fill(const MParContainer *par, const Stat_t w)
|
---|
188 | {
|
---|
189 | Double_t theta = fMcEvt->GetTelescopeTheta()*kRad2Deg;
|
---|
190 | Double_t mysig = fSigmabar->Calc(*fCam, *fPed, *fEvt);
|
---|
191 |
|
---|
192 | fSigmaTheta.Fill(theta, mysig);
|
---|
193 |
|
---|
194 | const UInt_t npix = fEvt->GetNumPixels();
|
---|
195 |
|
---|
196 | for (UInt_t i=0; i<npix; i++)
|
---|
197 | {
|
---|
198 | MCerPhotPix cerpix = (*fEvt)[i];
|
---|
199 | if (!cerpix.IsPixelUsed())
|
---|
200 | continue;
|
---|
201 |
|
---|
202 | const Int_t id = cerpix.GetPixId();
|
---|
203 | const MPedestalPix &pix = (*fPed)[id];
|
---|
204 |
|
---|
205 | const Double_t sigma = pix.GetMeanRms();
|
---|
206 | const Double_t area = fCam->GetPixRatio(id);
|
---|
207 |
|
---|
208 | fSigmaPixTheta.Fill(theta, (Double_t)id, sigma);
|
---|
209 |
|
---|
210 | const Double_t diff = sigma*sigma/area - mysig*mysig;
|
---|
211 | fDiffPixTheta.Fill(theta, (Double_t)id, diff);
|
---|
212 | }
|
---|
213 |
|
---|
214 | return kTRUE;
|
---|
215 | }
|
---|
216 |
|
---|
217 | // --------------------------------------------------------------------------
|
---|
218 | //
|
---|
219 | // Draw the histogram
|
---|
220 | //
|
---|
221 | void MHSigmaTheta::Draw(Option_t *opt)
|
---|
222 | {
|
---|
223 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 900, 900);
|
---|
224 | pad->SetBorderMode(0);
|
---|
225 |
|
---|
226 | AppendPad("");
|
---|
227 |
|
---|
228 | pad->Divide(3, 2);
|
---|
229 |
|
---|
230 | // draw the 2D histogram Sigmabar versus Theta
|
---|
231 | TH1 *h;
|
---|
232 |
|
---|
233 | pad->cd(1);
|
---|
234 | gPad->SetBorderMode(0);
|
---|
235 | gPad->SetLogy();
|
---|
236 | h = fSigmaTheta.ProjectionX("ProjX-Theta", -1, 9999, "E");
|
---|
237 | h->SetDirectory(NULL);
|
---|
238 | h->SetTitle("Distribution of \\Theta");
|
---|
239 | h->SetXTitle("\\Theta [\\circ]");
|
---|
240 | h->SetYTitle("No.of events");
|
---|
241 | h->Draw(opt);
|
---|
242 | h->SetBit(kCanDelete);
|
---|
243 |
|
---|
244 | pad->cd(2);
|
---|
245 | gPad->SetBorderMode(0);
|
---|
246 | h = fDiffPixTheta.Project3D("zx");
|
---|
247 | h->SetDirectory(NULL);
|
---|
248 | h->SetTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2} vs. \\Theta (all pixels)");
|
---|
249 | h->SetXTitle("\\Theta [\\circ]");
|
---|
250 | h->SetYTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2}");
|
---|
251 | h->Draw("box");
|
---|
252 | h->SetBit(kCanDelete);
|
---|
253 |
|
---|
254 | pad->cd(3);
|
---|
255 | gPad->SetBorderMode(0);
|
---|
256 | h = fSigmaPixTheta.Project3D("zx");
|
---|
257 | h->SetDirectory(NULL);
|
---|
258 | h->SetTitle("\\sigma_{ped} vs. \\Theta (all pixels)");
|
---|
259 | h->SetXTitle("\\Theta [\\circ]");
|
---|
260 | h->SetYTitle("\\sigma_{ped}");
|
---|
261 | h->Draw("box");
|
---|
262 | h->SetBit(kCanDelete);
|
---|
263 |
|
---|
264 | pad->cd(4);
|
---|
265 | gPad->SetBorderMode(0);
|
---|
266 | h = fSigmaTheta.ProjectionY("ProjY-sigma", -1, 9999, "E");
|
---|
267 | h->SetDirectory(NULL);
|
---|
268 | h->SetTitle("Distribution of \\bar{\\sigma}_{ped}");
|
---|
269 | h->SetXTitle("\\bar{\\sigma}_{ped}");
|
---|
270 | h->SetYTitle("No.of events");
|
---|
271 | h->Draw(opt);
|
---|
272 | h->SetBit(kCanDelete);
|
---|
273 |
|
---|
274 | pad->cd(5);
|
---|
275 | gPad->SetBorderMode(0);
|
---|
276 | h = fDiffPixTheta.Project3D("zy");
|
---|
277 | h->SetDirectory(NULL);
|
---|
278 | h->SetTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2} vs. pixel Id (all \\Theta)");
|
---|
279 | h->SetXTitle("Id");
|
---|
280 | h->SetYTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2}");
|
---|
281 | h->Draw("box");
|
---|
282 | h->SetBit(kCanDelete);
|
---|
283 |
|
---|
284 | pad->cd(6);
|
---|
285 | gPad->SetBorderMode(0);
|
---|
286 | h = fSigmaPixTheta.Project3D("zy");
|
---|
287 | h->SetDirectory(NULL);
|
---|
288 | h->SetTitle("\\sigma_{ped} vs. pixel Id (all \\Theta)");
|
---|
289 | h->SetXTitle("Id");
|
---|
290 | h->SetYTitle("\\sigma_{ped}");
|
---|
291 | h->Draw("box");
|
---|
292 | h->SetBit(kCanDelete);
|
---|
293 |
|
---|
294 | //pad->cd(7);
|
---|
295 | //fSigmaTheta.Draw(opt);
|
---|
296 |
|
---|
297 | //pad->cd(8);
|
---|
298 | //fDiffPixTheta.Draw(opt);
|
---|
299 |
|
---|
300 | //pad->cd(9);
|
---|
301 | //fSigmaPixTheta.Draw(opt);
|
---|
302 | }
|
---|