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): Markus Gaug 11/2003 <mailto:markus@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MCalibrationCam
|
---|
28 | //
|
---|
29 | // Base class for Camera Calibration results.
|
---|
30 | //
|
---|
31 | // Contains TClonesArrays for the following objects:
|
---|
32 | // - fPixels: Array of classes derived from MCalibrationPix, one entry
|
---|
33 | // per pixel. Has to be created
|
---|
34 | // - fAverageAreas: Array of classes derived from MCalibrationPix, one entry
|
---|
35 | // per pixel AREA. Has to be created
|
---|
36 | // - fAverageSectors: Array of classes derived from MCalibrationPix, one entry
|
---|
37 | // per camera SECTOR. Has to be created
|
---|
38 | //
|
---|
39 | // - fAverageBadAreas: Array of classes derived from MBadPixelsPix, one entry
|
---|
40 | // per pixel AREA. Is created automatically.
|
---|
41 | // - fAverageBadSectors: Array of classes derived from MBadPixelsPix, one entry
|
---|
42 | // per camera SECTOR. Is created automatically.
|
---|
43 | //
|
---|
44 | // All TClonesArrays have to enlarged by the corresponding calls to (e.g. in MGeomApply):
|
---|
45 | // - InitSize()
|
---|
46 | // - InitAverageAreas()
|
---|
47 | // - InitAverageSectors()
|
---|
48 | //
|
---|
49 | /////////////////////////////////////////////////////////////////////////////
|
---|
50 | #include "MCalibrationCam.h"
|
---|
51 |
|
---|
52 | #include <TClonesArray.h>
|
---|
53 |
|
---|
54 | #include "MGeomCam.h"
|
---|
55 | #include "MGeomPix.h"
|
---|
56 |
|
---|
57 | #include "MBadPixelsCam.h"
|
---|
58 | #include "MBadPixelsPix.h"
|
---|
59 |
|
---|
60 | #include "MCalibrationPix.h"
|
---|
61 |
|
---|
62 | ClassImp(MCalibrationCam);
|
---|
63 |
|
---|
64 | using namespace std;
|
---|
65 |
|
---|
66 | const Int_t MCalibrationCam::gkNumPulserColors = 4;
|
---|
67 | // --------------------------------------------------------------------------
|
---|
68 | //
|
---|
69 | // Default constructor.
|
---|
70 | //
|
---|
71 | // Set the following pointer to NULL:
|
---|
72 | // - fPixels
|
---|
73 | // - fAverageAreas
|
---|
74 | // - fAverageSectors
|
---|
75 | //
|
---|
76 | // Initializes:
|
---|
77 | // - fPulserColor to kNONE
|
---|
78 | // - fNumHiGainFADCSlices to 0.
|
---|
79 | // - fNumLoGainFADCSlices to 0.
|
---|
80 | //
|
---|
81 | // Creates a TClonesArray of MBadPixelsPix containers for the TClonesArray's:
|
---|
82 | // - fAverageBadAreas
|
---|
83 | // - fAverageBadSectors
|
---|
84 | // all initialized to 1 entry
|
---|
85 | //
|
---|
86 | // Later, a call to InitAverageAreas() and InitAverageSectors() (or Init())
|
---|
87 | // has to be performed in order to get the dimension correctly.
|
---|
88 | //
|
---|
89 | MCalibrationCam::MCalibrationCam(const char *name, const char *title)
|
---|
90 | : fPulserColor(kNONE),
|
---|
91 | fPixels(NULL), fAverageAreas(NULL), fAverageSectors(NULL),
|
---|
92 | fAverageBadAreas(NULL), fAverageBadSectors(NULL)
|
---|
93 | {
|
---|
94 |
|
---|
95 | fNumHiGainFADCSlices.Set(1);
|
---|
96 | fNumLoGainFADCSlices.Set(1);
|
---|
97 | }
|
---|
98 |
|
---|
99 | // --------------------------------------------------------------------------
|
---|
100 | //
|
---|
101 | // Deletes the following TClonesArray's of MCalibrationPix containers (if exist):
|
---|
102 | // - fPixels
|
---|
103 | // - fAverageAreas
|
---|
104 | // - fAverageSectors
|
---|
105 | //
|
---|
106 | // Deletes the following TClonesArray's of MBadPixelsPix containers (if exist):
|
---|
107 | // - fAverageBadAreas
|
---|
108 | // - fAverageBadSectors
|
---|
109 | //
|
---|
110 | MCalibrationCam::~MCalibrationCam()
|
---|
111 | {
|
---|
112 |
|
---|
113 | //
|
---|
114 | // delete fPixels should delete all Objects stored inside
|
---|
115 | //
|
---|
116 | if (fPixels)
|
---|
117 | delete fPixels;
|
---|
118 |
|
---|
119 | if (fAverageAreas)
|
---|
120 | delete fAverageAreas;
|
---|
121 |
|
---|
122 | if (fAverageSectors)
|
---|
123 | delete fAverageSectors;
|
---|
124 |
|
---|
125 | if (fAverageBadAreas)
|
---|
126 | delete fAverageBadAreas;
|
---|
127 |
|
---|
128 | if (fAverageBadSectors)
|
---|
129 | delete fAverageBadSectors;
|
---|
130 |
|
---|
131 | }
|
---|
132 |
|
---|
133 | // --------------------------------------
|
---|
134 | //
|
---|
135 | // Calls the ForEach macro for the TClonesArray fPixels with the argument Clear()
|
---|
136 | //
|
---|
137 | // Loops over the fAverageAreas, calling the function Clear() for
|
---|
138 | // every entry in:
|
---|
139 | // - fAverageAreas
|
---|
140 | // - fAverageBadAreas
|
---|
141 | //
|
---|
142 | // Loops over the fAverageSectors, calling the function Clear() for
|
---|
143 | // every entry in:
|
---|
144 | // - fAverageSectors
|
---|
145 | // - fAverageBadSectors
|
---|
146 | //
|
---|
147 | void MCalibrationCam::Clear(Option_t *o)
|
---|
148 | {
|
---|
149 |
|
---|
150 | { fPixels ->ForEach(TObject, Clear)(); }
|
---|
151 | { fAverageAreas ->ForEach(TObject, Clear)(); }
|
---|
152 | { fAverageSectors->ForEach(TObject, Clear)(); }
|
---|
153 |
|
---|
154 | return;
|
---|
155 | }
|
---|
156 |
|
---|
157 | // --------------------------------------------------------------------------
|
---|
158 | //
|
---|
159 | // Copy 'constructor'
|
---|
160 | //
|
---|
161 | void MCalibrationCam::Copy(TObject& object) const
|
---|
162 | {
|
---|
163 |
|
---|
164 | MCalibrationCam &calib = (MCalibrationCam&)object;
|
---|
165 |
|
---|
166 | MParContainer::Copy(calib);
|
---|
167 |
|
---|
168 | calib.fPulserColor = fPulserColor;
|
---|
169 |
|
---|
170 | const Int_t n3 = GetSize();
|
---|
171 | if (n3 != 0)
|
---|
172 | {
|
---|
173 | calib.InitSize(n3);
|
---|
174 | for (int i=0; i<n3; i++)
|
---|
175 | (*this)[i].Copy(calib[i]);
|
---|
176 | }
|
---|
177 |
|
---|
178 | const Int_t n4 = GetAverageAreas();
|
---|
179 | if (n4 != 0)
|
---|
180 | {
|
---|
181 | calib.InitAverageAreas(n4);
|
---|
182 | for (int i=0; i<n4; i++)
|
---|
183 | {
|
---|
184 | GetAverageArea (i).Copy(calib.GetAverageArea(i));
|
---|
185 | GetAverageBadArea(i).Copy(calib.GetAverageBadArea(i));
|
---|
186 | calib.fNumUnsuitable [i] = fNumUnsuitable[i];
|
---|
187 | calib.fNumUnreliable [i] = fNumUnreliable[i];
|
---|
188 | calib.fNumHiGainFADCSlices[i] = fNumHiGainFADCSlices[i];
|
---|
189 | calib.fNumLoGainFADCSlices[i] = fNumLoGainFADCSlices[i];
|
---|
190 | }
|
---|
191 | }
|
---|
192 |
|
---|
193 | const Int_t n5 = GetAverageSectors();
|
---|
194 | if (n5 != 0)
|
---|
195 | {
|
---|
196 | calib.InitAverageSectors(n5);
|
---|
197 | for (int i=0; i<n5; i++)
|
---|
198 | {
|
---|
199 | GetAverageSector (i).Copy(calib.GetAverageSector(i));
|
---|
200 | GetAverageBadSector(i).Copy(calib.GetAverageBadSector(i));
|
---|
201 | }
|
---|
202 | }
|
---|
203 | }
|
---|
204 |
|
---|
205 | // -------------------------------------------------------------------
|
---|
206 | //
|
---|
207 | // Calls TClonesArray::ExpandCreate() for fPixels
|
---|
208 | //
|
---|
209 | void MCalibrationCam::InitSize(const UInt_t i)
|
---|
210 | {
|
---|
211 | fPixels->ExpandCreate(i);
|
---|
212 | }
|
---|
213 |
|
---|
214 | // -------------------------------------------------------------------
|
---|
215 | //
|
---|
216 | // Calls TClonesArray::ExpandCreate() for:
|
---|
217 | // - fAverageAreas
|
---|
218 | // - fAverageBadAreas
|
---|
219 | //
|
---|
220 | void MCalibrationCam::InitAverageAreas(const UInt_t i)
|
---|
221 | {
|
---|
222 | fAverageAreas->ExpandCreate(i);
|
---|
223 | fAverageBadAreas->ExpandCreate(i);
|
---|
224 |
|
---|
225 | for (UInt_t j=0; j<i; j++)
|
---|
226 | GetAverageArea(j).SetPixId(j);
|
---|
227 |
|
---|
228 | fNumUnsuitable.Set(i);
|
---|
229 | fNumUnreliable.Set(i);
|
---|
230 | fNumHiGainFADCSlices.Set(i);
|
---|
231 | fNumLoGainFADCSlices.Set(i);
|
---|
232 | }
|
---|
233 |
|
---|
234 | // -------------------------------------------------------------------
|
---|
235 | //
|
---|
236 | // Calls TClonesArray::ExpandCreate() for:
|
---|
237 | // - fAverageSectors
|
---|
238 | // - fAverageBadSectors
|
---|
239 | //
|
---|
240 | void MCalibrationCam::InitAverageSectors(const UInt_t i)
|
---|
241 | {
|
---|
242 | fAverageSectors->ExpandCreate(i);
|
---|
243 | fAverageBadSectors->ExpandCreate(i);
|
---|
244 |
|
---|
245 | for (UInt_t j=0; j<i; j++)
|
---|
246 | GetAverageSector(j).SetPixId(j);
|
---|
247 |
|
---|
248 | }
|
---|
249 |
|
---|
250 | // -------------------------------------------------------------------
|
---|
251 | //
|
---|
252 | // Calls:
|
---|
253 | // - InitSize()
|
---|
254 | // - InitAverageAreas()
|
---|
255 | // - InitAverageSectors()
|
---|
256 | //
|
---|
257 | void MCalibrationCam::Init(const MGeomCam &geom)
|
---|
258 | {
|
---|
259 | InitSize (geom.GetNumPixels() );
|
---|
260 | InitAverageAreas (geom.GetNumAreas() );
|
---|
261 | InitAverageSectors(geom.GetNumSectors());
|
---|
262 | }
|
---|
263 |
|
---|
264 | // --------------------------------------------------------------------------
|
---|
265 | //
|
---|
266 | // Returns the number of un-suitable pixels per area index and -1 if
|
---|
267 | // the area index exceeds the initialized array.
|
---|
268 | //
|
---|
269 | const Int_t MCalibrationCam::GetNumUnsuitable( const Int_t aidx ) const
|
---|
270 | {
|
---|
271 | if (aidx < 0)
|
---|
272 | {
|
---|
273 | Int_t num = 0;
|
---|
274 | for (Int_t i=0;i<fNumUnsuitable.GetSize();i++)
|
---|
275 | num += fNumUnsuitable[i];
|
---|
276 | return num;
|
---|
277 | }
|
---|
278 |
|
---|
279 | return aidx > fNumUnsuitable.GetSize() ? -1 : fNumUnsuitable[aidx];
|
---|
280 | }
|
---|
281 |
|
---|
282 | // --------------------------------------------------------------------------
|
---|
283 | //
|
---|
284 | // Returns the number of un-reliable pixels per area index and -1 if
|
---|
285 | // the area index exceeds the initialized array.
|
---|
286 | //
|
---|
287 | const Int_t MCalibrationCam::GetNumUnreliable( const Int_t aidx ) const
|
---|
288 | {
|
---|
289 | if (aidx < 0)
|
---|
290 | {
|
---|
291 | Int_t num = 0;
|
---|
292 | for (Int_t i=0;i<fNumUnreliable.GetSize();i++)
|
---|
293 | num += fNumUnreliable[i];
|
---|
294 | return num;
|
---|
295 | }
|
---|
296 |
|
---|
297 | return aidx > fNumUnreliable.GetSize() ? -1 : fNumUnreliable[aidx];
|
---|
298 | }
|
---|
299 |
|
---|
300 | // --------------------------------------------------------------------------
|
---|
301 | //
|
---|
302 | // Returns the mean number of High-Gain FADC slices per area index and -1 if
|
---|
303 | // the area index exceeds the initialized array.
|
---|
304 | //
|
---|
305 | const Float_t MCalibrationCam::GetNumHiGainFADCSlices( const Int_t aidx ) const
|
---|
306 | {
|
---|
307 | if (aidx < 0)
|
---|
308 | return -1;
|
---|
309 |
|
---|
310 | return aidx > fNumHiGainFADCSlices.GetSize() ? -1 : fNumHiGainFADCSlices[aidx];
|
---|
311 | }
|
---|
312 |
|
---|
313 | // --------------------------------------------------------------------------
|
---|
314 | //
|
---|
315 | // Returns the mean number of Low-Gain FADC slices per area index and -1 if
|
---|
316 | // the area index exceeds the initialized array.
|
---|
317 | //
|
---|
318 | const Float_t MCalibrationCam::GetNumLoGainFADCSlices( const Int_t aidx ) const
|
---|
319 | {
|
---|
320 | if (aidx < 0)
|
---|
321 | return -1;
|
---|
322 |
|
---|
323 | return aidx > fNumLoGainFADCSlices.GetSize() ? -1 : fNumLoGainFADCSlices[aidx];
|
---|
324 | }
|
---|
325 |
|
---|
326 |
|
---|
327 |
|
---|
328 | // --------------------------------------------------------------------------
|
---|
329 | //
|
---|
330 | // Returns the current size of the TClonesArray fAverageAreas
|
---|
331 | // independently if the MCalibrationPix is filled with values or not.
|
---|
332 | //
|
---|
333 | const Int_t MCalibrationCam::GetAverageAreas() const
|
---|
334 | {
|
---|
335 | return fAverageAreas->GetEntriesFast();
|
---|
336 | }
|
---|
337 |
|
---|
338 | // --------------------------------------------------------------------------
|
---|
339 | //
|
---|
340 | // Returns the current size of the TClonesArray fAverageSectors
|
---|
341 | // independently if the MCalibrationPix is filled with values or not.
|
---|
342 | //
|
---|
343 | const Int_t MCalibrationCam::GetAverageSectors() const
|
---|
344 | {
|
---|
345 | return fAverageSectors->GetEntriesFast();
|
---|
346 | }
|
---|
347 |
|
---|
348 |
|
---|
349 | // --------------------------------------------------------------------------
|
---|
350 | //
|
---|
351 | // Get i-th pixel (pixel number)
|
---|
352 | //
|
---|
353 | MCalibrationPix &MCalibrationCam::operator[](UInt_t i)
|
---|
354 | {
|
---|
355 | return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
|
---|
356 | }
|
---|
357 |
|
---|
358 | // --------------------------------------------------------------------------
|
---|
359 | //
|
---|
360 | // Get i-th pixel (pixel number)
|
---|
361 | //
|
---|
362 | const MCalibrationPix &MCalibrationCam::operator[](UInt_t i) const
|
---|
363 | {
|
---|
364 | return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
|
---|
365 | }
|
---|
366 |
|
---|
367 | // --------------------------------------------------------------------------
|
---|
368 | //
|
---|
369 | // Returns the current size of the TClonesArray fPixels
|
---|
370 | // independently if the MCalibrationPix is filled with values or not.
|
---|
371 | //
|
---|
372 | const Int_t MCalibrationCam::GetSize() const
|
---|
373 | {
|
---|
374 | return fPixels->GetEntriesFast();
|
---|
375 | }
|
---|
376 |
|
---|
377 | // --------------------------------------------------------------------------
|
---|
378 | //
|
---|
379 | // Get i-th average pixel (area number)
|
---|
380 | //
|
---|
381 | MCalibrationPix &MCalibrationCam::GetAverageArea(const UInt_t i)
|
---|
382 | {
|
---|
383 | return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
|
---|
384 | }
|
---|
385 |
|
---|
386 | // --------------------------------------------------------------------------
|
---|
387 | //
|
---|
388 | // Get i-th average pixel (area number)
|
---|
389 | //
|
---|
390 | const MCalibrationPix &MCalibrationCam::GetAverageArea(const UInt_t i) const
|
---|
391 | {
|
---|
392 | return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
|
---|
393 | }
|
---|
394 |
|
---|
395 | // --------------------------------------------------------------------------
|
---|
396 | //
|
---|
397 | // Get i-th average pixel (sector number)
|
---|
398 | //
|
---|
399 | MCalibrationPix &MCalibrationCam::GetAverageSector(const UInt_t i)
|
---|
400 | {
|
---|
401 | return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
|
---|
402 | }
|
---|
403 |
|
---|
404 | // --------------------------------------------------------------------------
|
---|
405 | //
|
---|
406 | // Get i-th average pixel (sector number)
|
---|
407 | //
|
---|
408 | const MCalibrationPix &MCalibrationCam::GetAverageSector(const UInt_t i) const
|
---|
409 | {
|
---|
410 | return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
|
---|
411 | }
|
---|
412 |
|
---|
413 | // --------------------------------------------------------------------------
|
---|
414 | //
|
---|
415 | // Get i-th average pixel (area number)
|
---|
416 | //
|
---|
417 | MBadPixelsPix &MCalibrationCam::GetAverageBadArea(const UInt_t i)
|
---|
418 | {
|
---|
419 | return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
|
---|
420 | }
|
---|
421 |
|
---|
422 | // --------------------------------------------------------------------------
|
---|
423 | //
|
---|
424 | // Get i-th average pixel (area number)
|
---|
425 | //
|
---|
426 | const MBadPixelsPix &MCalibrationCam::GetAverageBadArea(const UInt_t i) const
|
---|
427 | {
|
---|
428 | return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
|
---|
429 | }
|
---|
430 |
|
---|
431 | // --------------------------------------------------------------------------
|
---|
432 | //
|
---|
433 | // Get i-th average pixel (sector number)
|
---|
434 | //
|
---|
435 | MBadPixelsPix &MCalibrationCam::GetAverageBadSector(const UInt_t i)
|
---|
436 | {
|
---|
437 | return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
|
---|
438 | }
|
---|
439 |
|
---|
440 | // --------------------------------------------------------------------------
|
---|
441 | //
|
---|
442 | // Get i-th average pixel (sector number)
|
---|
443 | //
|
---|
444 | const MBadPixelsPix &MCalibrationCam::GetAverageBadSector(const UInt_t i) const
|
---|
445 | {
|
---|
446 | return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
|
---|
447 | }
|
---|
448 |
|
---|
449 |
|
---|
450 |
|
---|
451 | // --------------------------------------------------------------------------
|
---|
452 | //
|
---|
453 | // Dummy needed for compilation with MCamEvent
|
---|
454 | //
|
---|
455 | Bool_t MCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
456 | {
|
---|
457 | return kTRUE;
|
---|
458 | }
|
---|
459 |
|
---|
460 |
|
---|
461 |
|
---|
462 | // --------------------------------------------------------------------------
|
---|
463 | //
|
---|
464 | // Calls MCalibrationPix::DrawClone()
|
---|
465 | //
|
---|
466 | void MCalibrationCam::DrawPixelContent(Int_t idx) const
|
---|
467 | {
|
---|
468 | (*this)[idx].DrawClone();
|
---|
469 | }
|
---|
470 |
|
---|
471 | void MCalibrationCam::SetNumHiGainFADCSlices( const Float_t i, const Int_t aidx)
|
---|
472 | {
|
---|
473 | if (aidx < 0)
|
---|
474 | return;
|
---|
475 |
|
---|
476 | if (aidx < fNumHiGainFADCSlices.GetSize())
|
---|
477 | fNumHiGainFADCSlices[aidx] = i;
|
---|
478 | }
|
---|
479 |
|
---|
480 | void MCalibrationCam::SetNumLoGainFADCSlices( const Float_t i, const Int_t aidx)
|
---|
481 | {
|
---|
482 | if (aidx < 0)
|
---|
483 | return;
|
---|
484 | if (aidx < fNumLoGainFADCSlices.GetSize())
|
---|
485 | fNumLoGainFADCSlices[aidx] = i;
|
---|
486 | }
|
---|
487 |
|
---|
488 | void MCalibrationCam::SetNumUnsuitable( const UInt_t i, const Int_t aidx)
|
---|
489 | {
|
---|
490 | if (aidx < 0)
|
---|
491 | return;
|
---|
492 |
|
---|
493 | if (aidx < fNumUnsuitable.GetSize())
|
---|
494 | fNumUnsuitable[aidx] = i;
|
---|
495 | }
|
---|
496 |
|
---|
497 | void MCalibrationCam::SetNumUnreliable( const UInt_t i, const Int_t aidx)
|
---|
498 | {
|
---|
499 | if (aidx < 0)
|
---|
500 | return;
|
---|
501 | if (aidx < fNumUnreliable.GetSize())
|
---|
502 | fNumUnreliable[aidx] = i;
|
---|
503 | }
|
---|