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

Last change on this file since 4874 was 4874, checked in by wittek, 20 years ago
*** empty log message ***
File size: 5.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): 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// Default 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.SetName("2D-IdBadPixels");
58 fBadId.SetTitle("2D-IdBadPixels");
59 fBadId.SetDirectory(NULL);
60 fBadId.SetXTitle("\\Theta [\\circ]");
61 fBadId.SetYTitle("pixel Id");
62
63 fBadN.SetName("2D-NBadPixels");
64 fBadN.SetTitle("2D-NBadPixels");
65 fBadN.SetDirectory(NULL);
66 fBadN.SetXTitle("\\Theta [\\circ]");
67 fBadN.SetYTitle("number of bad pixels");
68
69 fNamePedPhotCam = "MPedPhotCamFromData";
70}
71
72// --------------------------------------------------------------------------
73//
74// Set the binnings and prepare the filling of the histogram
75//
76Bool_t MHBadPixels::SetupFill(const MParList *plist)
77{
78 MGeomCam *fCam = (MGeomCam*)plist->FindObject(AddSerialNumber("MGeomCam"));
79 if (!fCam)
80 {
81 *fLog << err << "MHBadPixels::SetupFill; MGeomCam not found... aborting." << endl;
82 return kFALSE;
83 }
84 *fLog << "MHBadPixels::SetupFill; fCam = " << fCam << endl;
85
86 fPointPos = (MPointingPos*)plist->FindObject("MPointingPos");
87 if (!fPointPos)
88 {
89 *fLog << err << "MPointingPos not found... aborting." << endl;
90 return kFALSE;
91 }
92
93
94 fPedPhot = (MPedPhotCam*)plist->FindObject(AddSerialNumber(fNamePedPhotCam), "MPedPhotCam");
95 if (!fPedPhot)
96 {
97 *fLog << err << AddSerialNumber(fNamePedPhotCam)
98 << "[MPedPhotCam] not found... aborting." << endl;
99 return kFALSE;
100 }
101 fPedPhot->InitSize(fCam->GetNumPixels());
102
103 //----------------------------------------------------
104 // Get Theta Binning
105 MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta", "MBinning");
106 if (!binstheta)
107 {
108 *fLog << err << "Object 'BinningTheta' [MBinning] not found... aborting" << endl;
109 return kFALSE;
110 }
111
112 // Get binning for pixel number
113 const UInt_t npix1 = fPedPhot->GetSize()+1;
114
115 *fLog << "MHBadPixels::SetupFill; npix1 = " << npix1 << endl;
116
117 MBinning binspix("BinningPixel");
118 binspix.SetEdges(npix1, -0.5, npix1-0.5);
119
120 // Set binnings in histograms
121 SetBinning(&fBadId, binstheta, &binspix);
122 SetBinning(&fBadN, binstheta, &binspix);
123
124 //----------------------------------------------------
125 *fLog << inf << "Name of MPedPhotCam container : " << fNamePedPhotCam
126 << endl;
127
128 return kTRUE;
129}
130
131// ------------------------------------------------------------------------
132//
133// Fill the histograms
134//
135
136Bool_t MHBadPixels::Fill(const MParContainer *par, const Stat_t w)
137{
138 if (!par)
139 return kFALSE;
140
141 Double_t theta = fPointPos->GetZd();
142
143 const MBadPixelsCam *fBadPixels = (MBadPixelsCam*)par;
144
145 const UInt_t entries = fPedPhot->GetSize();
146 UInt_t nb = 0;
147 for (UInt_t i=0; i<entries; i++)
148 {
149 //*fLog << "MHBadPixels::Fill; i = " << i << endl;
150
151 if ( (*fBadPixels)[i].IsUnsuitable() )
152 {
153 //*fLog << "MHBadPixels::Fill; (UnSuitable) " << endl;
154
155 fBadId.Fill(theta, i, w);
156 nb++;
157 }
158 }
159 fBadN.Fill(theta, nb, w);
160
161 return kTRUE;
162}
163
164// --------------------------------------------------------------------
165//
166// Draw the histograms
167//
168void MHBadPixels::Draw(Option_t *option)
169{
170 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
171 pad->SetBorderMode(0);
172
173 pad->Divide(2,2);
174
175 TH1D *h;
176
177 pad->cd(1);
178 fBadId.Draw(option);
179
180 pad->cd(2);
181 fBadN.Draw(option);
182
183 pad->cd(3);
184 gPad->SetBorderMode(0);
185 h = ((TH2*)&fBadId)->ProjectionY("ProjY-pixId", -1, 9999, "");
186 h->SetDirectory(NULL);
187 h->SetTitle("Distribution of bad pixel Id");
188 h->SetXTitle("Id of bad pixel");
189 h->SetYTitle("No. of events");
190 h->Draw(option);
191 h->SetBit(kCanDelete);
192
193 pad->cd(4);
194 gPad->SetBorderMode(0);
195 h = ((TH2*)&fBadN)->ProjectionY("ProjY-pixN", -1, 9999, "");
196 h->SetDirectory(NULL);
197 h->SetTitle("Distribution of no.of bad pixels");
198 h->SetXTitle("No. of bad pixels");
199 h->SetYTitle("No. of events");
200 h->Draw(option);
201 h->SetBit(kCanDelete);
202
203 pad->Modified();
204 pad->Update();
205}
206//==========================================================================
207
208
209
210
211
212
213
214
215
216
217
Note: See TracBrowser for help on using the repository browser.