source: trunk/MagicSoft/Mars/mbadpixels/MHBadPixels.cc@ 9492

Last change on this file since 9492 was 9153, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 6.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): Thomas Bretz 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MHBadPixels
28//
29////////////////////////////////////////////////////////////////////////////
30#include "MHBadPixels.h"
31
32#include <TCanvas.h>
33
34#include "MPointingPos.h"
35#include "MBadPixelsCam.h"
36#include "MGeomCam.h"
37#include "MPedPhotCam.h"
38#include "MParList.h"
39#include "MBinning.h"
40
41#include "MLog.h"
42#include "MLogManip.h"
43
44ClassImp(MHBadPixels);
45
46using namespace std;
47
48// -------------------------------------------------------------------------
49//
50// Constructor.
51//
52MHBadPixels::MHBadPixels(const char *name, const char *title)
53{
54 fName = name ? name : "MHBadPixels";
55 fTitle = title ? title : "Histogram for Bad Pixels vs. Theta";
56
57 fBadId = new TH2D;
58 fBadId->SetName("2D-IdBadPixels");
59 fBadId->SetTitle("2D-IdBadPixels");
60 fBadId->SetDirectory(NULL);
61 fBadId->UseCurrentStyle();
62 fBadId->SetXTitle("\\Theta [\\circ]");
63 fBadId->SetYTitle("pixel Id");
64 fBadId->SetTitleOffset(1.2, "Y");
65
66 fBadN = new TH2D;
67 fBadN->SetName("2D-NBadPixels");
68 fBadN->SetTitle("2D-NBadPixels");
69 fBadN->SetDirectory(NULL);
70 fBadN->UseCurrentStyle();
71 fBadN->SetXTitle("\\Theta [\\circ]");
72 fBadN->SetYTitle("number of bad pixels");
73 fBadN->SetTitleOffset(1.2, "Y");
74
75 // define default binnings
76 fBinsTheta = new MBinning;
77 fBinsTheta->SetEdgesCos(10, 0.0, 90.0); // theta
78
79 fBinsPix = new MBinning;
80 fBinsPix->SetEdges(578, -0.5, 577.5); // pixel id
81
82 SetBinning(fBadId, fBinsTheta, fBinsPix);
83 SetBinning(fBadN, fBinsTheta, fBinsPix);
84
85 //-----------------------------------------
86 fNamePedPhotCam = "MPedPhotCamFromData";
87}
88
89
90// -------------------------------------------------------------------------
91//
92// Destructor.
93//
94MHBadPixels::~MHBadPixels()
95{
96 delete fBadId;
97 delete fBadN;
98
99 delete fBinsTheta;
100 delete fBinsPix;
101}
102
103// --------------------------------------------------------------------------
104//
105// Set the binnings and prepare the filling of the histogram
106//
107Bool_t MHBadPixels::SetupFill(const MParList *plist)
108{
109 fCam = (MGeomCam*)plist->FindObject(AddSerialNumber("MGeomCam"));
110 if (!fCam)
111 {
112 *fLog << err << "MHBadPixels::SetupFill; MGeomCam not found... aborting." << endl;
113 return kFALSE;
114 }
115 *fLog << "MHBadPixels::SetupFill; fCam = " << fCam << endl;
116
117 fPointPos = (MPointingPos*)plist->FindObject("MPointingPos");
118 if (!fPointPos)
119 {
120 *fLog << err << "MPointingPos not found... aborting." << endl;
121 return kFALSE;
122 }
123
124 fPedPhot = (MPedPhotCam*)plist->FindObject(AddSerialNumber(fNamePedPhotCam), "MPedPhotCam");
125 if (!fPedPhot)
126 {
127 *fLog << err << AddSerialNumber(fNamePedPhotCam)
128 << "[MPedPhotCam] not found... aborting." << endl;
129 return kFALSE;
130 }
131 fPedPhot->InitSize(fCam->GetNumPixels());
132
133
134 //----------------------------------------------------
135 *fLog << inf << "Name of MPedPhotCam container : " << fNamePedPhotCam
136 << endl;
137
138
139 //----------------------------------------------------
140 // redefine the binnings
141
142 // Get Theta Binning
143 const MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta", "MBinning");
144 if (!binstheta)
145 {
146 *fLog << err << "Object 'BinningTheta' [MBinning] not found... use default binning." << endl;
147 binstheta = fBinsTheta;
148 }
149
150 // Define binning for pixel number
151 const UInt_t npix1 = fPedPhot->GetSize()+1;
152 //*fLog << "MHBadPixels::SetupFill(); npix1 = " << npix1 << endl;
153 MBinning binspix("BinningPixel");
154 binspix.SetEdges(npix1, -0.5, npix1-0.5);
155
156 // Set binnings in histograms
157 SetBinning(fBadId, binstheta, &binspix);
158 SetBinning(fBadN, binstheta, &binspix);
159
160 *fLog << "MHBadPixels::SetupFill(); binnings were set" << endl;
161
162
163
164 return kTRUE;
165}
166
167// ------------------------------------------------------------------------
168//
169// Fill the histograms
170//
171
172Int_t MHBadPixels::Fill(const MParContainer *par, const Stat_t w)
173{
174 if (!par)
175 {
176 *fLog << err << "ERROR - par==NULL." << endl;
177 return kERROR;
178 }
179
180 const Double_t theta = fPointPos->GetZd();
181
182 const MBadPixelsCam *fBadPixels = (MBadPixelsCam*)par;
183
184 const UInt_t entries = fPedPhot->GetSize();
185 UInt_t nb = 0;
186 for (UInt_t i=0; i<entries; i++)
187 {
188 //*fLog << "MHBadPixels::Fill; i = " << i << endl;
189
190 if ( (*fBadPixels)[i].IsUnsuitable() )
191 {
192 //*fLog << "MHBadPixels::Fill; (UnSuitable) " << endl;
193
194 fBadId->Fill(theta, i, w);
195 nb++;
196 }
197 }
198 fBadN->Fill(theta, nb, w);
199
200 return kTRUE;
201}
202
203// --------------------------------------------------------------------
204//
205// Draw the histograms
206//
207void MHBadPixels::Draw(Option_t *option)
208{
209 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
210 pad->SetBorderMode(0);
211
212 pad->Divide(2,2);
213
214 TH1D *h;
215
216 pad->cd(1);
217 fBadId->Draw(option);
218
219 pad->cd(2);
220 fBadN->Draw(option);
221
222 pad->cd(3);
223 gPad->SetBorderMode(0);
224 h = ((TH2*)fBadId)->ProjectionY("ProjY-pixId", -1, 9999, "");
225 h->SetDirectory(NULL);
226 h->SetTitle("Distribution of bad pixel Id");
227 h->SetXTitle("Id of bad pixel");
228 h->SetYTitle("No. of events");
229 h->SetTitleOffset(1.2, "Y");
230 h->Draw(option);
231 h->SetBit(kCanDelete);
232
233 pad->cd(4);
234 gPad->SetBorderMode(0);
235 h = ((TH2*)fBadN)->ProjectionY("ProjY-pixN", -1, 9999, "");
236 h->SetDirectory(NULL);
237 h->SetTitle("Distribution of no.of bad pixels");
238 h->SetXTitle("No. of bad pixels");
239 h->SetYTitle("No. of events");
240 h->SetTitleOffset(1.2, "Y");
241 h->Draw(option);
242 h->SetBit(kCanDelete);
243
244 pad->Modified();
245 pad->Update();
246}
247//==========================================================================
248
249
250
251
252
253
254
255
256
257
258
Note: See TracBrowser for help on using the repository browser.