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

Last change on this file since 2029 was 2015, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 8.5 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, Double_t w)
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 fSigmaPixTheta.Fill(theta, (Double_t)id, sigma);
201
202 const Double_t diff = sigma*sigma/area - mysig*mysig;
203 fDiffPixTheta.Fill(theta, (Double_t)id, diff);
204 }
205
206 return kTRUE;
207}
208
209// --------------------------------------------------------------------------
210//
211// Draw the histogram
212//
213void MHSigmaTheta::Draw(Option_t *opt)
214{
215 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 900, 900);
216 pad->SetBorderMode(0);
217
218 AppendPad("");
219
220 pad->Divide(3, 3);
221
222 // draw the 2D histogram Sigmabar versus Theta
223 TH1 *h;
224
225 pad->cd(1);
226 gPad->SetLogy();
227 h = fSigmaTheta.ProjectionX("ProjX-Theta", -1, 9999, "E");
228 h->SetDirectory(NULL);
229 h->SetTitle("Distribution of \\Theta");
230 h->SetXTitle("\\Theta [\\circ]");
231 h->SetYTitle("No.of events");
232 h->Draw("box");
233 h->SetBit(kCanDelete);
234
235 pad->cd(2);
236 h = fDiffPixTheta.Project3D("zx");
237 h->SetDirectory(NULL);
238 h->SetTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2} vs. \\Theta (all pixels)");
239 h->SetXTitle("\\Theta [\\circ]");
240 h->SetYTitle("\\sigma_{ped}^2-\\bar{\\sigma}_{ped}^{2}");
241 h->SetBit(kCanDelete);
242
243 pad->cd(3);
244 h = fSigmaPixTheta.Project3D("zx");
245 h->SetDirectory(NULL);
246 h->SetTitle("\\sigma_{ped} vs. \\Theta (all pixels)");
247 h->SetXTitle("\\Theta [\\circ]");
248 h->SetYTitle("\\sigma_{ped}");
249 h->Draw("box");
250 h->SetBit(kCanDelete);
251
252 pad->cd(4);
253 h = fSigmaTheta.ProjectionY("ProjY-sigma", -1, 9999, "E");
254 h->SetDirectory(NULL);
255 h->SetTitle("Distribution of \\bar{\\sigma}_{ped}");
256 h->SetXTitle("\\bar{\\sigma}_{ped}");
257 h->SetYTitle("No.of events");
258 h->Draw(opt);
259 h->SetBit(kCanDelete);
260
261 pad->cd(5);
262 h = fDiffPixTheta.Project3D("zy");
263 h->SetDirectory(NULL);
264 h->SetTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2} vs. pixel Id (all \\Theta)");
265 h->SetXTitle("Id");
266 h->SetYTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2}");
267 h->Draw("box");
268 h->SetBit(kCanDelete);
269
270 pad->cd(6);
271 h = fSigmaPixTheta.Project3D("zy");
272 h->SetDirectory(NULL);
273 h->SetTitle("\\sigma_{ped} vs. pixel Id (all \\Theta)");
274 h->SetXTitle("Id");
275 h->SetYTitle("\\sigma_{ped}");
276 h->Draw("box");
277 h->SetBit(kCanDelete);
278
279 pad->cd(7);
280 fSigmaTheta.Draw(opt);
281
282 pad->cd(8);
283 fDiffPixTheta.Draw(opt);
284
285 pad->cd(9);
286 fSigmaPixTheta.Draw(opt);
287}
Note: See TracBrowser for help on using the repository browser.