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

Last change on this file since 2072 was 2072, checked in by wittek, 21 years ago
*** empty log message ***
File size: 8.6 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: 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//
96MHSigmaTheta::~MHSigmaTheta()
97{
98
99}
100
101// --------------------------------------------------------------------------
102//
103// Set the binnings and prepare the filling of the histogram
104//
105Bool_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//
187Bool_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//
221void 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->SetLogy();
235 h = fSigmaTheta.ProjectionX("ProjX-Theta", -1, 9999, "E");
236 h->SetDirectory(NULL);
237 h->SetTitle("Distribution of \\Theta");
238 h->SetXTitle("\\Theta [\\circ]");
239 h->SetYTitle("No.of events");
240 h->Draw(opt);
241 h->SetBit(kCanDelete);
242
243 pad->cd(2);
244 h = fDiffPixTheta.Project3D("zx");
245 h->SetDirectory(NULL);
246 h->SetTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2} vs. \\Theta (all pixels)");
247 h->SetXTitle("\\Theta [\\circ]");
248 h->SetYTitle("\\sigma_{ped}^2-\\bar{\\sigma}_{ped}^{2}");
249 h->Draw("box");
250 h->SetBit(kCanDelete);
251
252 pad->cd(3);
253 h = fSigmaPixTheta.Project3D("zx");
254 h->SetDirectory(NULL);
255 h->SetTitle("\\sigma_{ped} vs. \\Theta (all pixels)");
256 h->SetXTitle("\\Theta [\\circ]");
257 h->SetYTitle("\\sigma_{ped}");
258 h->Draw("box");
259 h->SetBit(kCanDelete);
260
261 pad->cd(4);
262 h = fSigmaTheta.ProjectionY("ProjY-sigma", -1, 9999, "E");
263 h->SetDirectory(NULL);
264 h->SetTitle("Distribution of \\bar{\\sigma}_{ped}");
265 h->SetXTitle("\\bar{\\sigma}_{ped}");
266 h->SetYTitle("No.of events");
267 h->Draw(opt);
268 h->SetBit(kCanDelete);
269
270 pad->cd(5);
271 h = fDiffPixTheta.Project3D("zy");
272 h->SetDirectory(NULL);
273 h->SetTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2} vs. pixel Id (all \\Theta)");
274 h->SetXTitle("Id");
275 h->SetYTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2}");
276 h->Draw("box");
277 h->SetBit(kCanDelete);
278
279 pad->cd(6);
280 h = fSigmaPixTheta.Project3D("zy");
281 h->SetDirectory(NULL);
282 h->SetTitle("\\sigma_{ped} vs. pixel Id (all \\Theta)");
283 h->SetXTitle("Id");
284 h->SetYTitle("\\sigma_{ped}");
285 h->Draw("box");
286 h->SetBit(kCanDelete);
287
288 //pad->cd(7);
289 //fSigmaTheta.Draw(opt);
290
291 //pad->cd(8);
292 //fDiffPixTheta.Draw(opt);
293
294 //pad->cd(9);
295 //fSigmaPixTheta.Draw(opt);
296}
297
298
299
300
301
302
303
304
305
Note: See TracBrowser for help on using the repository browser.