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

Last change on this file since 1974 was 1967, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 8.7 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! 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
59ClassImp(MHSigmaTheta);
60
61
62// --------------------------------------------------------------------------
63//
64// Default Constructor. It sets name and title of the histogram.
65//
66MHSigmaTheta::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: \\bar{\\sigma}_{ped}, \\Theta");
75 fSigmaTheta.SetXTitle("\\Theta [\\circ]");
76 fSigmaTheta.SetYTitle("\\bar{\\Theta}");
77
78 fSigmaPixTheta.SetDirectory(NULL);
79 fSigmaPixTheta.SetName("3D-ThetaPixSigma");
80 fSigmaPixTheta.SetTitle("3D : \\Theta, Pixel Id, \\sigma_{ped}");
81 fSigmaPixTheta.SetXTitle("\\Theta [\\circ]");
82 fSigmaPixTheta.SetYTitle("Pixel Id");
83 fSigmaPixTheta.SetZTitle("\\sigma_{ped}");
84
85 fDiffPixTheta.SetDirectory(NULL);
86 fDiffPixTheta.SetName("3D-ThetaPixDiff");
87 fDiffPixTheta.SetTitle("3D : \\Theta, Pixel Id, \\sigma_{ped}^{2}-\\bar{\\sigma}^{2}");
88 fDiffPixTheta.SetXTitle("\\Theta [\\circ]");
89 fDiffPixTheta.SetYTitle("Pixel Id");
90 fDiffPixTheta.SetZTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}^{2}");
91}
92
93// --------------------------------------------------------------------------
94//
95// Set the binnings and prepare the filling of the histogram
96//
97Bool_t MHSigmaTheta::SetupFill(const MParList *plist)
98{
99
100 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
101 if (!fMcEvt)
102 {
103 *fLog << err << "MMcEvt not found... aborting." << endl;
104 return kFALSE;
105 }
106
107 fPed = (MPedestalCam*)plist->FindObject("MPedestalCam");
108 if (!fPed)
109 {
110 *fLog << err << "MPedestalCam not found... aborting." << endl;
111 return kFALSE;
112 }
113
114 fCam = (MGeomCam*)plist->FindObject("MGeomCam");
115 if (!fCam)
116 {
117 *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
118 return kFALSE;
119 }
120
121 fEvt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
122 if (!fEvt)
123 {
124 *fLog << err << "MCerPhotEvt not found... aborting." << endl;
125 return kFALSE;
126 }
127
128 fSigmabar = (MSigmabar*)plist->FindObject("MSigmabar");
129 if (!fSigmabar)
130 {
131 *fLog << err << "MSigmabar not found... aborting." << endl;
132 return kFALSE;
133 }
134
135 // Get Theta Binning
136 MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta");
137 if (!binstheta)
138 {
139 *fLog << err << "BinningTheta [MBinning] not found... aborting." << endl;
140 return kFALSE;
141 }
142
143 // Get Sigmabar binning
144 MBinning* binssigma = (MBinning*)plist->FindObject("BinningSigmabar");
145 if (!binssigma)
146 {
147 *fLog << err << "BinningSigmabar [MBinning] not found... aborting." << endl;
148 return kFALSE;
149 }
150
151 // Get binning for (sigma^2-sigmabar^2)
152 MBinning* binsdiff = (MBinning*)plist->FindObject("BinningDiffsigma2");
153 if (!binsdiff)
154 {
155 *fLog << err << "BinningDiffsigma2 [MBinning] not found... aborting." << endl;
156 return kFALSE;
157 }
158
159
160 // Set binnings in histograms
161 SetBinning(&fSigmaTheta, binstheta, binssigma);
162
163 // Get binning for pixel number
164 const UInt_t npix = fPed->GetSize();
165
166 MBinning binspix("BinningPixel");
167 binspix.SetEdges(npix+1, -0.5, 0.5+npix );
168
169 SetBinning(&fSigmaPixTheta, binstheta, &binspix, binssigma);
170 SetBinning(&fDiffPixTheta, binstheta, &binspix, binsdiff);
171
172 return kTRUE;
173}
174
175// --------------------------------------------------------------------------
176//
177// Fill the histograms
178//
179Bool_t MHSigmaTheta::Fill(const MParContainer *par)
180{
181 Double_t theta = fMcEvt->GetTelescopeTheta()*kRad2Deg;
182 Double_t mySig = fSigmabar->Calc(*fCam, *fPed, *fEvt);
183
184 fSigmaTheta.Fill(theta, mySig);
185
186 const UInt_t npix = fEvt->GetNumPixels();
187
188 for (UInt_t i=0; i<npix; i++)
189 {
190 MCerPhotPix cerpix = (*fEvt)[i];
191 if (!cerpix.IsPixelUsed())
192 continue;
193
194 const Int_t id = cerpix.GetPixId();
195 const MPedestalPix &pix = (*fPed)[id];
196
197 const Double_t sigma = pix.GetMeanRms();
198 const Double_t area = fCam->GetPixRatio(id);
199
200
201 fSigmaPixTheta.Fill(theta, (Double_t)id, sigma);
202
203 const Double_t diff = sigma*sigma/area - mySig*mySig;
204 fDiffPixTheta.Fill(theta, (Double_t)id, diff);
205 }
206
207 return kTRUE;
208}
209
210// --------------------------------------------------------------------------
211//
212// Draw a copy of the histogram
213//
214TObject *MHSigmaTheta::DrawClone(Option_t *opt)
215{
216 return MH::DrawClone(opt, 900, 900);
217}
218
219// --------------------------------------------------------------------------
220//
221// Draw the histogram
222//
223void MHSigmaTheta::Draw(Option_t *opt)
224{
225 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 900, 900);
226 pad->SetBorderMode(0);
227
228 AppendPad("");
229
230 pad->Divide(3, 3);
231
232 // draw the 2D histogram Sigmabar versus Theta
233 TH1 *h;
234
235 pad->cd(1);
236 gPad->SetLogy();
237 h = fSigmaTheta.ProjectionX("ProjX-Theta", -1, 9999, "E");
238 h->SetDirectory(NULL);
239 h->SetTitle("Distribution of \\Theta");
240 h->SetXTitle("\\Theta [\\circ]");
241 h->SetYTitle("No.of events");
242 h->Draw("box");
243 h->SetBit(kCanDelete);
244
245 pad->cd(2);
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->SetBit(kCanDelete);
252
253 pad->cd(3);
254 h = fSigmaPixTheta.Project3D("zx");
255 h->SetDirectory(NULL);
256 h->SetTitle("\\sigma_{ped} vs. \\Theta (all pixels)");
257 h->SetXTitle("\\Theta [\\circ]");
258 h->SetYTitle("\\sigma_{ped}");
259 h->Draw("box");
260 h->SetBit(kCanDelete);
261
262 pad->cd(4);
263 h = fSigmaTheta.ProjectionY("ProjY-sigma", -1, 9999, "E");
264 h->SetDirectory(NULL);
265 h->SetTitle("Distribution of \\bar{\\sigma}_{ped}");
266 h->SetXTitle("\\bar{\\sigma}_{ped}");
267 h->SetYTitle("No.of events");
268 h->Draw(opt);
269 h->SetBit(kCanDelete);
270
271 pad->cd(5);
272 h = fDiffPixTheta.Project3D("zy");
273 h->SetDirectory(NULL);
274 h->SetTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2} vs. pixel Id (all \\Theta)");
275 h->SetXTitle("Id");
276 h->SetYTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2}");
277 h->Draw("box");
278 h->SetBit(kCanDelete);
279
280 pad->cd(6);
281 h = fSigmaPixTheta.Project3D("zy");
282 h->SetDirectory(NULL);
283 h->SetTitle("\\sigma_{ped} vs. pixel Id (all \\Theta)");
284 h->SetXTitle("Id");
285 h->SetYTitle("\\sigma_{ped}");
286 h->Draw("box");
287 h->SetBit(kCanDelete);
288
289 pad->cd(7);
290 fSigmaTheta.Draw(opt);
291
292 pad->cd(8);
293 fDiffPixTheta.Draw(opt);
294
295 pad->cd(9);
296 fSigmaPixTheta.Draw(opt);
297}
Note: See TracBrowser for help on using the repository browser.