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, 10/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | ! Author(s): Hendrik Bartko, 08/2004 <mailto:hbartko@mppmu.mpg.de>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | /////////////////////////////////////////////////////////////////////////////
|
---|
27 | //
|
---|
28 | // MCameraData
|
---|
29 | //
|
---|
30 | // This is a generalized class storing camera data. For example the cleaning
|
---|
31 | // level for the image cleaning is one possibility.
|
---|
32 | //
|
---|
33 | /////////////////////////////////////////////////////////////////////////////
|
---|
34 | #include "MCameraData.h"
|
---|
35 |
|
---|
36 | #include "MCerPhotEvt.h"
|
---|
37 | #include "MCerPhotPix.h"
|
---|
38 |
|
---|
39 | #include "MGeomCam.h"
|
---|
40 | #include "MGeomPix.h"
|
---|
41 |
|
---|
42 | #include "MLog.h"
|
---|
43 | #include "MLogManip.h"
|
---|
44 |
|
---|
45 | #include "MPedPhotCam.h"
|
---|
46 | #include "MPedPhotPix.h"
|
---|
47 |
|
---|
48 | #include "MSigmabar.h"
|
---|
49 |
|
---|
50 | ClassImp(MCameraData);
|
---|
51 |
|
---|
52 | using namespace std;
|
---|
53 |
|
---|
54 | // --------------------------------------------------------------------------
|
---|
55 | //
|
---|
56 | // Creates a MCerPhotPix object for each pixel in the event
|
---|
57 | //
|
---|
58 | MCameraData::MCameraData(const char *name, const char *title)
|
---|
59 | {
|
---|
60 | fName = name ? name : "MCameraData";
|
---|
61 | fTitle = title ? title : "Generalized storage container for camera contents";
|
---|
62 | }
|
---|
63 |
|
---|
64 | /*
|
---|
65 | // --------------------------------------------------------------------------
|
---|
66 | //
|
---|
67 | // This is not yet implemented like it should.
|
---|
68 | //
|
---|
69 |
|
---|
70 | void MCameraData::Draw(Option_t* option)
|
---|
71 | {
|
---|
72 | //
|
---|
73 | // FIXME!!! Here the Draw function of the CamDisplay
|
---|
74 | // should be called to add the CamDisplay to the Pad.
|
---|
75 | // The drawing should be done in MCamDisplay::Paint
|
---|
76 | //
|
---|
77 |
|
---|
78 | // MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1;
|
---|
79 | // MCamDisplay *disp = new MCamDisplay(geom);
|
---|
80 | // delete geom;
|
---|
81 | // disp->DrawPhotNum(this);
|
---|
82 | }
|
---|
83 | */
|
---|
84 |
|
---|
85 |
|
---|
86 | // --------------------------------------------------------------------------
|
---|
87 | //
|
---|
88 | // Function to calculate the cleaning level for all pixels in a given event
|
---|
89 | // as the ratio between the measured photons and the pedestal rms.
|
---|
90 | // In order to do the image cleaning on average in the same photon flux
|
---|
91 | // (reconstructed photons per pixel area) for the inner and outer pixels,
|
---|
92 | // a correction factor is applied to the outer pixels (see TDAS 02-14).
|
---|
93 | // The correction factor assumes the ideal case that the pedestal rms
|
---|
94 | // scales with the inverse square root of the pixel area.
|
---|
95 | //
|
---|
96 | // FIXME: Should the check noise<=0 be replaced by MBadPixels?
|
---|
97 | //
|
---|
98 | void MCameraData::CalcCleaningLevel(const MCerPhotEvt &evt, const MPedPhotCam &cam,
|
---|
99 | const MGeomCam &geom)
|
---|
100 | {
|
---|
101 | const Int_t n = geom.GetNumPixels();
|
---|
102 |
|
---|
103 | fData.Set(n);
|
---|
104 | fData.Reset();
|
---|
105 |
|
---|
106 | fValidity.Set(n);
|
---|
107 | fValidity.Reset();
|
---|
108 |
|
---|
109 | const Int_t entries = evt.GetNumPixels();
|
---|
110 |
|
---|
111 | //
|
---|
112 | // check the number of all pixels against the noise level and
|
---|
113 | // set them to 'unused' state if necessary
|
---|
114 | //
|
---|
115 | for (Int_t i=0; i<entries; i++)
|
---|
116 | {
|
---|
117 | const MCerPhotPix &pix = evt[i];
|
---|
118 |
|
---|
119 | const Int_t idx = pix.GetPixId();
|
---|
120 | const Float_t noise = cam[idx].GetRms();
|
---|
121 |
|
---|
122 | if (noise<=0) // fData[idx]=0, fValidity[idx]=0
|
---|
123 | continue;
|
---|
124 |
|
---|
125 | //
|
---|
126 | // We calculate a correction factor which accounts for the
|
---|
127 | // fact that pixels have different size (see TDAS 02-14).
|
---|
128 | //
|
---|
129 | fData[idx] = pix.GetNumPhotons() * geom.GetPixRatioSqrt(idx) / noise;
|
---|
130 | fValidity[idx] = 1;
|
---|
131 | }
|
---|
132 | }
|
---|
133 |
|
---|
134 | // --------------------------------------------------------------------------
|
---|
135 | //
|
---|
136 | // Function to calculate the cleaning level for all pixels in a given event
|
---|
137 | // as the ratio between the measured photons and the pedestal rms.
|
---|
138 | // In order to do the image cleaning on average in the same photon flux
|
---|
139 | // (reconstructed photons per pixel area) for the inner and outer pixels,
|
---|
140 | // a correction factor is applied to the outer pixels (see TDAS 02-14).
|
---|
141 | // The correction factor takes the actual average pedestal RMS of the
|
---|
142 | // inner and outer pixels into account.
|
---|
143 | //
|
---|
144 | // FIXME: Should the check noise<=0 be replaced by MBadPixels?
|
---|
145 | //
|
---|
146 | void MCameraData::CalcCleaningLevel2(const MCerPhotEvt &evt, const MPedPhotCam &cam,
|
---|
147 | const MGeomCam &geom)
|
---|
148 | {
|
---|
149 | const Int_t n = geom.GetNumPixels();
|
---|
150 |
|
---|
151 | fData.Set(n);
|
---|
152 | fData.Reset();
|
---|
153 |
|
---|
154 | fValidity.Set(n);
|
---|
155 | fValidity.Reset();
|
---|
156 |
|
---|
157 | const Int_t entries = evt.GetNumPixels();
|
---|
158 | const Float_t anoise0 = cam.GetArea(0).GetRms();
|
---|
159 | if (anoise0<=0)
|
---|
160 | return;
|
---|
161 |
|
---|
162 | //
|
---|
163 | // check the number of all pixels against the noise level and
|
---|
164 | // set them to 'unused' state if necessary
|
---|
165 | //
|
---|
166 | for (Int_t i=0; i<entries; i++)
|
---|
167 | {
|
---|
168 | const MCerPhotPix &pix = evt[i];
|
---|
169 |
|
---|
170 | const Int_t idx = pix.GetPixId();
|
---|
171 | const Float_t noise = cam[idx].GetRms();
|
---|
172 |
|
---|
173 | if (noise<=0) // fData[idx]=0, fValidity[idx]=0
|
---|
174 | continue;
|
---|
175 |
|
---|
176 | //
|
---|
177 | // We calculate a correction factor which accounts for the
|
---|
178 | // fact that pixels have different size (see TDAS 02-14).
|
---|
179 | // We also take into account that the RMS does not scale
|
---|
180 | // with the square root of the pixel area.
|
---|
181 | //
|
---|
182 | const UInt_t aidx = geom[idx].GetAidx();
|
---|
183 | const Float_t ratio = cam.GetArea(aidx).GetRms()/anoise0;
|
---|
184 |
|
---|
185 | fData[idx] = pix.GetNumPhotons() * geom.GetPixRatio(idx) * ratio / noise;
|
---|
186 | fValidity[idx] = 1;
|
---|
187 | }
|
---|
188 | }
|
---|
189 |
|
---|
190 |
|
---|
191 | void MCameraData::CalcCleaningLevel(const MCerPhotEvt &evt, const MSigmabar &sgb,
|
---|
192 | const MGeomCam &geom)
|
---|
193 | {
|
---|
194 | CalcCleaningLevel(evt, sgb.GetSigmabarInner(), geom);
|
---|
195 | }
|
---|
196 |
|
---|
197 | void MCameraData::CalcCleaningLevel(const MCerPhotEvt &evt, Double_t noise,
|
---|
198 | const MGeomCam &geom)
|
---|
199 | {
|
---|
200 | const Int_t n = geom.GetNumPixels();
|
---|
201 |
|
---|
202 | fData.Set(n);
|
---|
203 | fData.Reset();
|
---|
204 |
|
---|
205 | fValidity.Set(n);
|
---|
206 | fValidity.Reset();
|
---|
207 |
|
---|
208 | if (noise<=0)
|
---|
209 | return;
|
---|
210 |
|
---|
211 | const Int_t entries = evt.GetNumPixels();
|
---|
212 |
|
---|
213 | //
|
---|
214 | // check the number of all pixels against the noise level and
|
---|
215 | // set them to 'unused' state if necessary
|
---|
216 | //
|
---|
217 | for (Int_t i=0; i<entries; i++)
|
---|
218 | {
|
---|
219 | const MCerPhotPix &pix = evt[i];
|
---|
220 |
|
---|
221 | const Int_t idx = pix.GetPixId();
|
---|
222 |
|
---|
223 | //
|
---|
224 | // We calculate a correction factor which accounts for the
|
---|
225 | // fact that pixels have different size (see TDAS 02-14).
|
---|
226 | //
|
---|
227 | fData[idx] = pix.GetNumPhotons() * geom.GetPixRatio(idx) / noise;
|
---|
228 | fValidity[idx] = 1;
|
---|
229 | }
|
---|
230 | }
|
---|
231 |
|
---|
232 | // --------------------------------------------------------------------------
|
---|
233 | //
|
---|
234 | // Function to calculate the cleaning level for all pixels in a given event
|
---|
235 | // as the ratio between the reconstructed number of photons per area of an
|
---|
236 | // inner pixel and the average pedestal RMS of the inner pixels (democratic
|
---|
237 | // image cleaning, see TDAS 02-14).
|
---|
238 | //
|
---|
239 | // FIXME: Should the check noise<=0 be replaced by MBadPixels?
|
---|
240 | //
|
---|
241 | void MCameraData::CalcCleaningLevelDemocratic(const MCerPhotEvt &evt, const MPedPhotCam &cam,
|
---|
242 | const MGeomCam &geom)
|
---|
243 | {
|
---|
244 | const Int_t n = geom.GetNumPixels();
|
---|
245 |
|
---|
246 | fData.Set(n);
|
---|
247 | fData.Reset();
|
---|
248 |
|
---|
249 | fValidity.Set(n);
|
---|
250 | fValidity.Reset();
|
---|
251 |
|
---|
252 | const Int_t entries = evt.GetNumPixels();
|
---|
253 | const Float_t noise0 = cam.GetArea(0).GetRms();
|
---|
254 | if (noise0<=0)
|
---|
255 | return;
|
---|
256 |
|
---|
257 | //
|
---|
258 | // check the number of all pixels against the noise level and
|
---|
259 | // set them to 'unused' state if necessary
|
---|
260 | //
|
---|
261 | for (Int_t i=0; i<entries; i++)
|
---|
262 | {
|
---|
263 | const MCerPhotPix &pix = evt[i];
|
---|
264 |
|
---|
265 | const Int_t idx = pix.GetPixId();
|
---|
266 | const Float_t noise = cam[idx].GetRms();
|
---|
267 |
|
---|
268 | if (noise<=0)
|
---|
269 | continue;
|
---|
270 |
|
---|
271 | //
|
---|
272 | // We calculate a correction factor which accounts for the
|
---|
273 | // fact that pixels have different size (see TDAS 02-14).
|
---|
274 | //
|
---|
275 | fData[idx] = pix.GetNumPhotons() * geom.GetPixRatio(idx) / noise0;
|
---|
276 | fValidity[idx] = 1;
|
---|
277 | }
|
---|
278 | }
|
---|
279 |
|
---|
280 | // --------------------------------------------------------------------------
|
---|
281 | //
|
---|
282 | // Returns the contents of the pixel.
|
---|
283 | //
|
---|
284 | Bool_t MCameraData::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
285 | {
|
---|
286 | if (idx<0 || idx>=fData.GetSize())
|
---|
287 | return kFALSE;
|
---|
288 |
|
---|
289 | val = fData[idx];
|
---|
290 | return fValidity[idx];
|
---|
291 | }
|
---|
292 |
|
---|
293 | void MCameraData::DrawPixelContent(Int_t num) const
|
---|
294 | {
|
---|
295 | *fLog << warn << "MCameraData::DrawPixelContent - not available." << endl;
|
---|
296 | }
|
---|