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 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
|
---|
19 | ! Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2001
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | #include "MCerPhotEvt.h"
|
---|
27 |
|
---|
28 | #include <math.h>
|
---|
29 | #include <limits.h>
|
---|
30 | #include <fstream.h>
|
---|
31 |
|
---|
32 | #include <TCanvas.h>
|
---|
33 |
|
---|
34 | #include "MLog.h"
|
---|
35 |
|
---|
36 | #include "MGeomCam.h"
|
---|
37 |
|
---|
38 | ClassImp(MCerPhotEvt);
|
---|
39 |
|
---|
40 | // --------------------------------------------------------------------------
|
---|
41 | //
|
---|
42 | // Creates a MCerPhotPix object for each pixel in the event
|
---|
43 | //
|
---|
44 | MCerPhotEvt::MCerPhotEvt(const char *name, const char *title) : fNumPixels(0)
|
---|
45 | {
|
---|
46 | fName = name ? name : "MCerPhotEvt";
|
---|
47 | fTitle = title ? title : "(Number of Photon)-Event Information";
|
---|
48 |
|
---|
49 | fPixels = new TClonesArray("MCerPhotPix", 0);
|
---|
50 | }
|
---|
51 |
|
---|
52 | // --------------------------------------------------------------------------
|
---|
53 | //
|
---|
54 | // This is not yet implemented like it should.
|
---|
55 | //
|
---|
56 | void MCerPhotEvt::Draw(Option_t* option)
|
---|
57 | {
|
---|
58 | //
|
---|
59 | // FIXME!!! Here the Draw function of the CamDisplay
|
---|
60 | // should be called to add the CamDisplay to the Pad.
|
---|
61 | // The drawing should be done in MCamDisplay::Paint
|
---|
62 | //
|
---|
63 |
|
---|
64 | // MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1;
|
---|
65 | // MCamDisplay *disp = new MCamDisplay(geom);
|
---|
66 | // delete geom;
|
---|
67 | // disp->DrawPhotNum(this);
|
---|
68 | }
|
---|
69 |
|
---|
70 | // --------------------------------------------------------------------------
|
---|
71 | //
|
---|
72 | // reset counter and delete netries in list.
|
---|
73 | //
|
---|
74 | void MCerPhotEvt::Reset()
|
---|
75 | {
|
---|
76 | fNumPixels = 0;
|
---|
77 | fPixels->Delete();
|
---|
78 | }
|
---|
79 |
|
---|
80 | // --------------------------------------------------------------------------
|
---|
81 | //
|
---|
82 | // Dump the cerenkov photon event to *fLog
|
---|
83 | //
|
---|
84 | void MCerPhotEvt::Print(Option_t *) const
|
---|
85 | {
|
---|
86 | const Int_t entries = fPixels->GetEntries();
|
---|
87 |
|
---|
88 | *fLog << GetDescriptor() << dec << endl;
|
---|
89 | *fLog << " Number of Pixels: " << fNumPixels << "(" << entries << ")" << endl;
|
---|
90 |
|
---|
91 | for (Int_t i=0; i<entries; i++ )
|
---|
92 | (*this)[i].Print();
|
---|
93 | }
|
---|
94 |
|
---|
95 | // --------------------------------------------------------------------------
|
---|
96 | //
|
---|
97 | // Checks if in the pixel list is an entry with pixel id
|
---|
98 | //
|
---|
99 | Bool_t MCerPhotEvt::IsPixelExisting(Int_t id) const
|
---|
100 | {
|
---|
101 | const Int_t entries = fPixels->GetEntries();
|
---|
102 |
|
---|
103 | for (Int_t i=0; i<entries; i++)
|
---|
104 | {
|
---|
105 | if (id == (*this)[i].GetPixId())
|
---|
106 | return kTRUE;
|
---|
107 | }
|
---|
108 |
|
---|
109 | return kFALSE;
|
---|
110 | }
|
---|
111 |
|
---|
112 | // --------------------------------------------------------------------------
|
---|
113 | //
|
---|
114 | // Checks if in the pixel list is an entry with pixel id
|
---|
115 | //
|
---|
116 | Bool_t MCerPhotEvt::IsPixelUsed(Int_t id) const
|
---|
117 | {
|
---|
118 | const Int_t entries = fPixels->GetEntries();
|
---|
119 |
|
---|
120 | for (Int_t i=0; i<entries; i++)
|
---|
121 | {
|
---|
122 | const MCerPhotPix &pix = (*this)[i];
|
---|
123 | if (!pix.IsPixelUsed())
|
---|
124 | continue;
|
---|
125 |
|
---|
126 | if (id == pix.GetPixId() && pix.IsPixelUsed())
|
---|
127 | return kTRUE;
|
---|
128 | }
|
---|
129 |
|
---|
130 | return kFALSE;
|
---|
131 | }
|
---|
132 |
|
---|
133 | // --------------------------------------------------------------------------
|
---|
134 | //
|
---|
135 | // Checks if in the pixel list is an entry with pixel id
|
---|
136 | //
|
---|
137 | Bool_t MCerPhotEvt::IsPixelCore(Int_t id) const
|
---|
138 | {
|
---|
139 | const Int_t entries = fPixels->GetEntries();
|
---|
140 |
|
---|
141 | for (Int_t i=0; i<entries; i++)
|
---|
142 | {
|
---|
143 | const MCerPhotPix &pix = (*this)[i];
|
---|
144 | if (!pix.IsPixelUsed())
|
---|
145 | continue;
|
---|
146 |
|
---|
147 | if (id == pix.GetPixId() && pix.IsPixelCore())
|
---|
148 | return kTRUE;
|
---|
149 | }
|
---|
150 |
|
---|
151 | return kFALSE;
|
---|
152 | }
|
---|
153 |
|
---|
154 | // --------------------------------------------------------------------------
|
---|
155 | //
|
---|
156 | // get the minimum number of photons of all valid pixels in the list
|
---|
157 | // If you specify a geometry the number of photons is weighted with the
|
---|
158 | // area of the pixel
|
---|
159 | //
|
---|
160 | Float_t MCerPhotEvt::GetNumPhotonsMin(const MGeomCam *geom) const
|
---|
161 | {
|
---|
162 | if (fNumPixels <= 0)
|
---|
163 | return -5.;
|
---|
164 |
|
---|
165 | const UInt_t n = geom->GetNumPixels();
|
---|
166 |
|
---|
167 | Float_t minval = FLT_MAX;
|
---|
168 |
|
---|
169 | for (UInt_t i=1; i<fNumPixels; i++)
|
---|
170 | {
|
---|
171 | const MCerPhotPix &pix = (*this)[i];
|
---|
172 | if (!pix.IsPixelUsed())
|
---|
173 | continue;
|
---|
174 |
|
---|
175 | const UInt_t id = pix.GetPixId();
|
---|
176 | if (id>=n)
|
---|
177 | continue;
|
---|
178 |
|
---|
179 | Float_t testval = pix.GetNumPhotons();
|
---|
180 |
|
---|
181 | if (geom)
|
---|
182 | testval *= geom->GetPixRatio(id);
|
---|
183 |
|
---|
184 | if (testval < minval)
|
---|
185 | minval = testval;
|
---|
186 | }
|
---|
187 |
|
---|
188 | return minval;
|
---|
189 | }
|
---|
190 |
|
---|
191 | // --------------------------------------------------------------------------
|
---|
192 | //
|
---|
193 | // get the maximum number of photons of all valid pixels in the list
|
---|
194 | // If you specify a geometry the number of photons is weighted with the
|
---|
195 | // area of the pixel
|
---|
196 | //
|
---|
197 | Float_t MCerPhotEvt::GetNumPhotonsMax(const MGeomCam *geom) const
|
---|
198 | {
|
---|
199 | if (fNumPixels <= 0)
|
---|
200 | return 50.;
|
---|
201 |
|
---|
202 | const UInt_t n = geom->GetNumPixels();
|
---|
203 |
|
---|
204 | Float_t maxval = -FLT_MAX;
|
---|
205 |
|
---|
206 | for (UInt_t i=1; i<fNumPixels; i++)
|
---|
207 | {
|
---|
208 | const MCerPhotPix &pix = (*this)[i];
|
---|
209 | if (!pix.IsPixelUsed())
|
---|
210 | continue;
|
---|
211 |
|
---|
212 | const UInt_t id = pix.GetPixId();
|
---|
213 | if (id>=n)
|
---|
214 | continue;
|
---|
215 |
|
---|
216 | Float_t testval = pix.GetNumPhotons();
|
---|
217 | if (geom)
|
---|
218 | testval *= geom->GetPixRatio(id);
|
---|
219 |
|
---|
220 | if (testval > maxval)
|
---|
221 | maxval = testval;
|
---|
222 | }
|
---|
223 | return maxval;
|
---|
224 | }
|
---|
225 |
|
---|
226 | // --------------------------------------------------------------------------
|
---|
227 | //
|
---|
228 | // get the minimum ratio of photons/error
|
---|
229 | //
|
---|
230 | Float_t MCerPhotEvt::GetRatioMin() const
|
---|
231 | {
|
---|
232 | if (fNumPixels <= 0)
|
---|
233 | return -5.;
|
---|
234 |
|
---|
235 | Float_t minval = (*this)[0].GetNumPhotons()/(*this)[0].GetErrorPhot();
|
---|
236 |
|
---|
237 | for (UInt_t i=1; i<fNumPixels; i++)
|
---|
238 | {
|
---|
239 | const MCerPhotPix &pix = (*this)[i];
|
---|
240 | if (!pix.IsPixelUsed())
|
---|
241 | continue;
|
---|
242 |
|
---|
243 | Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
|
---|
244 | if (testval < minval)
|
---|
245 | minval = testval;
|
---|
246 | }
|
---|
247 |
|
---|
248 | return minval;
|
---|
249 | }
|
---|
250 |
|
---|
251 | // --------------------------------------------------------------------------
|
---|
252 | //
|
---|
253 | // get the maximum ratio of photons/error
|
---|
254 | //
|
---|
255 | Float_t MCerPhotEvt::GetRatioMax() const
|
---|
256 | {
|
---|
257 | if (fNumPixels <= 0)
|
---|
258 | return -5.;
|
---|
259 |
|
---|
260 | Float_t maxval = -FLT_MAX;
|
---|
261 |
|
---|
262 | for (UInt_t i=1; i<fNumPixels; i++)
|
---|
263 | {
|
---|
264 | const MCerPhotPix &pix = (*this)[i];
|
---|
265 | if (!pix.IsPixelUsed())
|
---|
266 | continue;
|
---|
267 |
|
---|
268 | Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
|
---|
269 | if (testval > maxval)
|
---|
270 | maxval = testval;
|
---|
271 | }
|
---|
272 |
|
---|
273 | return maxval;
|
---|
274 | }
|
---|
275 |
|
---|
276 | // --------------------------------------------------------------------------
|
---|
277 | //
|
---|
278 | // get the minimum of error
|
---|
279 | // If you specify a geometry the number of photons is weighted with the
|
---|
280 | // area of the pixel
|
---|
281 | //
|
---|
282 | Float_t MCerPhotEvt::GetErrorPhotMin(const MGeomCam *geom) const
|
---|
283 | {
|
---|
284 | if (fNumPixels <= 0)
|
---|
285 | return 50.;
|
---|
286 |
|
---|
287 | Float_t minval = FLT_MAX;
|
---|
288 |
|
---|
289 | for (UInt_t i=1; i<fNumPixels; i++)
|
---|
290 | {
|
---|
291 | const MCerPhotPix &pix = (*this)[i];
|
---|
292 | if (!pix.IsPixelUsed())
|
---|
293 | continue;
|
---|
294 |
|
---|
295 | Float_t testval = pix.GetErrorPhot();
|
---|
296 |
|
---|
297 | if (geom)
|
---|
298 | testval *= geom->GetPixRatio(pix.GetPixId());
|
---|
299 |
|
---|
300 | if (testval < minval)
|
---|
301 | minval = testval;
|
---|
302 | }
|
---|
303 | return minval;
|
---|
304 | }
|
---|
305 |
|
---|
306 | // --------------------------------------------------------------------------
|
---|
307 | //
|
---|
308 | // get the maximum ratio of photons/error
|
---|
309 | // If you specify a geometry the number of photons is weighted with the
|
---|
310 | // area of the pixel
|
---|
311 | //
|
---|
312 | Float_t MCerPhotEvt::GetErrorPhotMax(const MGeomCam *geom) const
|
---|
313 | {
|
---|
314 | if (fNumPixels <= 0)
|
---|
315 | return 50.;
|
---|
316 |
|
---|
317 | Float_t maxval = -FLT_MAX;
|
---|
318 |
|
---|
319 | for (UInt_t i=1; i<fNumPixels; i++)
|
---|
320 | {
|
---|
321 | const MCerPhotPix &pix = (*this)[i];
|
---|
322 | if (!pix.IsPixelUsed())
|
---|
323 | continue;
|
---|
324 |
|
---|
325 | Float_t testval = pix.GetErrorPhot();
|
---|
326 |
|
---|
327 | if (geom)
|
---|
328 | testval *= geom->GetPixRatio(pix.GetPixId());
|
---|
329 |
|
---|
330 | if (testval > maxval)
|
---|
331 | maxval = testval;
|
---|
332 | }
|
---|
333 | return maxval;
|
---|
334 | }
|
---|
335 |
|
---|
336 | // --------------------------------------------------------------------------
|
---|
337 | //
|
---|
338 | // Return a pointer to the pixel with the requested id. NULL if it doesn't
|
---|
339 | // exist.
|
---|
340 | //
|
---|
341 | MCerPhotPix *MCerPhotEvt::GetPixById(int id) const
|
---|
342 | {
|
---|
343 | TIter Next(fPixels);
|
---|
344 | MCerPhotPix *pix = NULL;
|
---|
345 |
|
---|
346 | while ((pix=(MCerPhotPix*)Next()))
|
---|
347 | if (pix->GetPixId()==id)
|
---|
348 | return pix;
|
---|
349 |
|
---|
350 | return NULL;
|
---|
351 | }
|
---|
352 |
|
---|
353 | void MCerPhotEvt::Scale(Double_t f)
|
---|
354 | {
|
---|
355 | fPixels->ForEach(MCerPhotPix, Scale)(f);
|
---|
356 | }
|
---|
357 |
|
---|
358 | void MCerPhotEvt::RemoveUnusedPixels()
|
---|
359 | {
|
---|
360 | TIter Next(fPixels);
|
---|
361 | MCerPhotPix *pix = NULL;
|
---|
362 |
|
---|
363 | while ((pix=(MCerPhotPix*)Next()))
|
---|
364 | if (!pix->IsPixelUsed())
|
---|
365 | fPixels->Remove(pix);
|
---|
366 |
|
---|
367 | fPixels->Compress();
|
---|
368 | fNumPixels=fPixels->GetEntriesFast();
|
---|
369 | }
|
---|