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 |
|
---|
44 | ClassImp(MHBadPixels);
|
---|
45 |
|
---|
46 | using namespace std;
|
---|
47 |
|
---|
48 | // -------------------------------------------------------------------------
|
---|
49 | //
|
---|
50 | // Default Constructor.
|
---|
51 | //
|
---|
52 | MHBadPixels::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 | //
|
---|
76 | Bool_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 |
|
---|
85 | fPointPos = (MPointingPos*)plist->FindObject("MPointingPos");
|
---|
86 | if (!fPointPos)
|
---|
87 | {
|
---|
88 | *fLog << err << "MPointingPos not found... aborting." << endl;
|
---|
89 | return kFALSE;
|
---|
90 | }
|
---|
91 |
|
---|
92 |
|
---|
93 | fPedPhot = (MPedPhotCam*)plist->FindObject(AddSerialNumber(fNamePedPhotCam), "MPedPhotCam");
|
---|
94 | if (!fPedPhot)
|
---|
95 | {
|
---|
96 | *fLog << err << AddSerialNumber(fNamePedPhotCam)
|
---|
97 | << "[MPedPhotCam] not found... aborting." << endl;
|
---|
98 | return kFALSE;
|
---|
99 | }
|
---|
100 | //fPedPhot->InitSize(fCam->GetNumPixels());
|
---|
101 |
|
---|
102 |
|
---|
103 | // Get Theta Binning
|
---|
104 | MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta", "MBinning");
|
---|
105 | if (!binstheta)
|
---|
106 | {
|
---|
107 | *fLog << err << "Object 'BinningTheta' [MBinning] not found... aborting" << endl;
|
---|
108 | return kFALSE;
|
---|
109 | }
|
---|
110 |
|
---|
111 | // Get binning for pixel number
|
---|
112 | const UInt_t npix1 = fPedPhot->GetSize()+1;
|
---|
113 |
|
---|
114 | MBinning binspix("BinningPixel");
|
---|
115 | binspix.SetEdges(npix1, -0.5, npix1-0.5);
|
---|
116 |
|
---|
117 | // Set binnings in histograms
|
---|
118 | SetBinning(&fBadId, binstheta, &binspix);
|
---|
119 | SetBinning(&fBadN, binstheta, &binspix);
|
---|
120 |
|
---|
121 | return kTRUE;
|
---|
122 | }
|
---|
123 |
|
---|
124 | // ------------------------------------------------------------------------
|
---|
125 | //
|
---|
126 | // Drawing function. It creates its own canvas.
|
---|
127 | //
|
---|
128 | void MHBadPixels::Draw(Option_t *option)
|
---|
129 | {
|
---|
130 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
---|
131 | pad->SetBorderMode(0);
|
---|
132 |
|
---|
133 | pad->Divide(2,2);
|
---|
134 |
|
---|
135 | TH1D *h;
|
---|
136 |
|
---|
137 | pad->cd(1);
|
---|
138 | fBadId.Draw(option);
|
---|
139 |
|
---|
140 | pad->cd(2);
|
---|
141 | fBadN.Draw(option);
|
---|
142 |
|
---|
143 | pad->cd(3);
|
---|
144 | gPad->SetBorderMode(0);
|
---|
145 | h = ((TH2*)&fBadId)->ProjectionY("ProjY-pixId", -1, 9999, "");
|
---|
146 | h->SetDirectory(NULL);
|
---|
147 | h->SetTitle("Distribution of bad pixel Id");
|
---|
148 | h->SetXTitle("Id of bad pixel");
|
---|
149 | h->SetYTitle("No. of events");
|
---|
150 | h->Draw(option);
|
---|
151 | h->SetBit(kCanDelete);
|
---|
152 |
|
---|
153 | pad->cd(4);
|
---|
154 | gPad->SetBorderMode(0);
|
---|
155 | h = ((TH2*)&fBadN)->ProjectionY("ProjY-pixN", -1, 9999, "");
|
---|
156 | h->SetDirectory(NULL);
|
---|
157 | h->SetTitle("Distribution of no.of bad pixels");
|
---|
158 | h->SetXTitle("No. of bad pixels");
|
---|
159 | h->SetYTitle("No. of events");
|
---|
160 | h->Draw(option);
|
---|
161 | h->SetBit(kCanDelete);
|
---|
162 |
|
---|
163 | pad->Modified();
|
---|
164 | pad->Update();
|
---|
165 | }
|
---|
166 |
|
---|
167 | Bool_t MHBadPixels::Fill(const MParContainer *par, const Stat_t w)
|
---|
168 | {
|
---|
169 | if (!par)
|
---|
170 | return kFALSE;
|
---|
171 |
|
---|
172 | Double_t theta = fPointPos->GetZd();
|
---|
173 |
|
---|
174 | const MBadPixelsCam *fBadPixels = (MBadPixelsCam*)par;
|
---|
175 |
|
---|
176 | UShort_t entries = fCam->GetNumPixels();
|
---|
177 | UInt_t nb = 0;
|
---|
178 | for (UInt_t i=0; i<entries; i++)
|
---|
179 | {
|
---|
180 | if ( (*fBadPixels)[i].IsUnsuitable() )
|
---|
181 | {
|
---|
182 | fBadId.Fill(theta, i, w);
|
---|
183 | nb++;
|
---|
184 | }
|
---|
185 | }
|
---|
186 | fBadN.Fill(theta, nb, w);
|
---|
187 |
|
---|
188 | return kTRUE;
|
---|
189 | }
|
---|
190 |
|
---|
191 |
|
---|
192 |
|
---|
193 |
|
---|
194 |
|
---|
195 |
|
---|
196 |
|
---|
197 |
|
---|
198 |
|
---|
199 |
|
---|
200 |
|
---|
201 |
|
---|