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 | {
|
---|
93 |
|
---|
94 | fAverageBadAreas = new TClonesArray("MBadPixelsPix",1);
|
---|
95 | fAverageBadSectors = new TClonesArray("MBadPixelsPix",1);
|
---|
96 |
|
---|
97 | fNumHiGainFADCSlices.Set(1);
|
---|
98 | fNumLoGainFADCSlices.Set(1);
|
---|
99 | }
|
---|
100 |
|
---|
101 | // --------------------------------------------------------------------------
|
---|
102 | //
|
---|
103 | // Deletes the following TClonesArray's of MCalibrationPix containers (if exist):
|
---|
104 | // - fPixels
|
---|
105 | // - fAverageAreas
|
---|
106 | // - fAverageSectors
|
---|
107 | //
|
---|
108 | // Deletes the following TClonesArray's of MBadPixelsPix containers (if exist):
|
---|
109 | // - fAverageBadAreas
|
---|
110 | // - fAverageBadSectors
|
---|
111 | //
|
---|
112 | MCalibrationCam::~MCalibrationCam()
|
---|
113 | {
|
---|
114 |
|
---|
115 | //
|
---|
116 | // delete fPixels should delete all Objects stored inside
|
---|
117 | //
|
---|
118 | if (fPixels)
|
---|
119 | delete fPixels;
|
---|
120 |
|
---|
121 | if (fAverageAreas)
|
---|
122 | delete fAverageAreas;
|
---|
123 |
|
---|
124 | if (fAverageSectors)
|
---|
125 | delete fAverageSectors;
|
---|
126 |
|
---|
127 | delete fAverageBadAreas;
|
---|
128 | delete fAverageBadSectors;
|
---|
129 |
|
---|
130 | }
|
---|
131 |
|
---|
132 | // --------------------------------------
|
---|
133 | //
|
---|
134 | // Calls the ForEach macro for the TClonesArray fPixels with the argument Clear()
|
---|
135 | //
|
---|
136 | // Loops over the fAverageAreas, calling the function Clear() for
|
---|
137 | // every entry in:
|
---|
138 | // - fAverageAreas
|
---|
139 | // - fAverageBadAreas
|
---|
140 | //
|
---|
141 | // Loops over the fAverageSectors, calling the function Clear() for
|
---|
142 | // every entry in:
|
---|
143 | // - fAverageSectors
|
---|
144 | // - fAverageBadSectors
|
---|
145 | //
|
---|
146 | void MCalibrationCam::Clear(Option_t *o)
|
---|
147 | {
|
---|
148 |
|
---|
149 | { fPixels ->ForEach(TObject, Clear)(); }
|
---|
150 | { fAverageAreas ->ForEach(TObject, Clear)(); }
|
---|
151 | { fAverageSectors->ForEach(TObject, Clear)(); }
|
---|
152 |
|
---|
153 | return;
|
---|
154 | }
|
---|
155 |
|
---|
156 | // --------------------------------------------------------------------------
|
---|
157 | //
|
---|
158 | // Copy 'constructor'
|
---|
159 | //
|
---|
160 | void MCalibrationCam::Copy(TObject& object) const
|
---|
161 | {
|
---|
162 |
|
---|
163 | MCalibrationCam &calib = (MCalibrationCam&)object;
|
---|
164 |
|
---|
165 | MParContainer::Copy(calib);
|
---|
166 |
|
---|
167 | calib.fPulserColor = fPulserColor;
|
---|
168 |
|
---|
169 | const Int_t n3 = GetSize();
|
---|
170 | if (n3 != 0)
|
---|
171 | {
|
---|
172 | calib.InitSize(n3);
|
---|
173 | for (int i=0; i<n3; i++)
|
---|
174 | (*this)[i].Copy(calib[i]);
|
---|
175 | }
|
---|
176 |
|
---|
177 | const Int_t n4 = GetAverageAreas();
|
---|
178 | if (n4 != 0)
|
---|
179 | {
|
---|
180 | calib.InitAverageAreas(n4);
|
---|
181 | for (int i=0; i<n4; i++)
|
---|
182 | {
|
---|
183 | GetAverageArea (i).Copy(calib.GetAverageArea(i));
|
---|
184 | GetAverageBadArea(i).Copy(calib.GetAverageBadArea(i));
|
---|
185 | calib.fNumUnsuitable [i] = fNumUnsuitable[i];
|
---|
186 | calib.fNumUnreliable [i] = fNumUnreliable[i];
|
---|
187 | calib.fNumHiGainFADCSlices[i] = fNumHiGainFADCSlices[i];
|
---|
188 | calib.fNumLoGainFADCSlices[i] = fNumLoGainFADCSlices[i];
|
---|
189 | }
|
---|
190 | }
|
---|
191 |
|
---|
192 | const Int_t n5 = GetAverageSectors();
|
---|
193 | if (n5 != 0)
|
---|
194 | {
|
---|
195 | calib.InitAverageSectors(n5);
|
---|
196 | for (int i=0; i<n5; i++)
|
---|
197 | {
|
---|
198 | GetAverageSector (i).Copy(calib.GetAverageSector(i));
|
---|
199 | GetAverageBadSector(i).Copy(calib.GetAverageBadSector(i));
|
---|
200 | }
|
---|
201 | }
|
---|
202 | }
|
---|
203 |
|
---|
204 | // -------------------------------------------------------------------
|
---|
205 | //
|
---|
206 | // Calls TClonesArray::ExpandCreate() for fPixels
|
---|
207 | //
|
---|
208 | void MCalibrationCam::InitSize(const UInt_t i)
|
---|
209 | {
|
---|
210 | fPixels->ExpandCreate(i);
|
---|
211 | }
|
---|
212 |
|
---|
213 | // -------------------------------------------------------------------
|
---|
214 | //
|
---|
215 | // Calls TClonesArray::ExpandCreate() for:
|
---|
216 | // - fAverageAreas
|
---|
217 | // - fAverageBadAreas
|
---|
218 | //
|
---|
219 | void MCalibrationCam::InitAverageAreas(const UInt_t i)
|
---|
220 | {
|
---|
221 | fAverageAreas->ExpandCreate(i);
|
---|
222 | fAverageBadAreas->ExpandCreate(i);
|
---|
223 |
|
---|
224 | for (UInt_t j=0; j<i; j++)
|
---|
225 | GetAverageArea(j).SetPixId(j);
|
---|
226 |
|
---|
227 | fNumUnsuitable.Set(i);
|
---|
228 | fNumUnreliable.Set(i);
|
---|
229 | fNumHiGainFADCSlices.Set(i);
|
---|
230 | fNumLoGainFADCSlices.Set(i);
|
---|
231 | }
|
---|
232 |
|
---|
233 | // -------------------------------------------------------------------
|
---|
234 | //
|
---|
235 | // Calls TClonesArray::ExpandCreate() for:
|
---|
236 | // - fAverageSectors
|
---|
237 | // - fAverageBadSectors
|
---|
238 | //
|
---|
239 | void MCalibrationCam::InitAverageSectors(const UInt_t i)
|
---|
240 | {
|
---|
241 | fAverageSectors->ExpandCreate(i);
|
---|
242 | fAverageBadSectors->ExpandCreate(i);
|
---|
243 |
|
---|
244 | for (UInt_t j=0; j<i; j++)
|
---|
245 | GetAverageSector(j).SetPixId(j);
|
---|
246 |
|
---|
247 | }
|
---|
248 |
|
---|
249 | // -------------------------------------------------------------------
|
---|
250 | //
|
---|
251 | // Calls:
|
---|
252 | // - InitSize()
|
---|
253 | // - InitAverageAreas()
|
---|
254 | // - InitAverageSectors()
|
---|
255 | //
|
---|
256 | void MCalibrationCam::Init(const MGeomCam &geom)
|
---|
257 | {
|
---|
258 | InitSize (geom.GetNumPixels() );
|
---|
259 | InitAverageAreas (geom.GetNumAreas() );
|
---|
260 | InitAverageSectors(geom.GetNumSectors());
|
---|
261 | }
|
---|
262 |
|
---|
263 | // --------------------------------------------------------------------------
|
---|
264 | //
|
---|
265 | // Returns the number of un-suitable pixels per area index and -1 if
|
---|
266 | // the area index exceeds the initialized array.
|
---|
267 | //
|
---|
268 | const Int_t MCalibrationCam::GetNumUnsuitable( const Int_t aidx ) const
|
---|
269 | {
|
---|
270 | if (aidx < 0)
|
---|
271 | {
|
---|
272 | Int_t num = 0;
|
---|
273 | for (Int_t i=0;i<fNumUnsuitable.GetSize();i++)
|
---|
274 | num += fNumUnsuitable[i];
|
---|
275 | return num;
|
---|
276 | }
|
---|
277 |
|
---|
278 | return aidx > fNumUnsuitable.GetSize() ? -1 : fNumUnsuitable[aidx];
|
---|
279 | }
|
---|
280 |
|
---|
281 | // --------------------------------------------------------------------------
|
---|
282 | //
|
---|
283 | // Returns the number of un-reliable pixels per area index and -1 if
|
---|
284 | // the area index exceeds the initialized array.
|
---|
285 | //
|
---|
286 | const Int_t MCalibrationCam::GetNumUnreliable( const Int_t aidx ) const
|
---|
287 | {
|
---|
288 | if (aidx < 0)
|
---|
289 | {
|
---|
290 | Int_t num = 0;
|
---|
291 | for (Int_t i=0;i<fNumUnreliable.GetSize();i++)
|
---|
292 | num += fNumUnreliable[i];
|
---|
293 | return num;
|
---|
294 | }
|
---|
295 |
|
---|
296 | return aidx > fNumUnreliable.GetSize() ? -1 : fNumUnreliable[aidx];
|
---|
297 | }
|
---|
298 |
|
---|
299 | // --------------------------------------------------------------------------
|
---|
300 | //
|
---|
301 | // Returns the mean number of High-Gain FADC slices per area index and -1 if
|
---|
302 | // the area index exceeds the initialized array.
|
---|
303 | //
|
---|
304 | const Float_t MCalibrationCam::GetNumHiGainFADCSlices( const Int_t aidx ) const
|
---|
305 | {
|
---|
306 | if (aidx < 0)
|
---|
307 | return -1;
|
---|
308 |
|
---|
309 | return aidx > fNumHiGainFADCSlices.GetSize() ? -1 : fNumHiGainFADCSlices[aidx];
|
---|
310 | }
|
---|
311 |
|
---|
312 | // --------------------------------------------------------------------------
|
---|
313 | //
|
---|
314 | // Returns the mean number of Low-Gain FADC slices per area index and -1 if
|
---|
315 | // the area index exceeds the initialized array.
|
---|
316 | //
|
---|
317 | const Float_t MCalibrationCam::GetNumLoGainFADCSlices( const Int_t aidx ) const
|
---|
318 | {
|
---|
319 | if (aidx < 0)
|
---|
320 | return -1;
|
---|
321 |
|
---|
322 | return aidx > fNumLoGainFADCSlices.GetSize() ? -1 : fNumLoGainFADCSlices[aidx];
|
---|
323 | }
|
---|
324 |
|
---|
325 |
|
---|
326 |
|
---|
327 | // --------------------------------------------------------------------------
|
---|
328 | //
|
---|
329 | // Returns the current size of the TClonesArray fAverageAreas
|
---|
330 | // independently if the MCalibrationPix is filled with values or not.
|
---|
331 | //
|
---|
332 | const Int_t MCalibrationCam::GetAverageAreas() const
|
---|
333 | {
|
---|
334 | return fAverageAreas->GetEntriesFast();
|
---|
335 | }
|
---|
336 |
|
---|
337 | // --------------------------------------------------------------------------
|
---|
338 | //
|
---|
339 | // Returns the current size of the TClonesArray fAverageSectors
|
---|
340 | // independently if the MCalibrationPix is filled with values or not.
|
---|
341 | //
|
---|
342 | const Int_t MCalibrationCam::GetAverageSectors() const
|
---|
343 | {
|
---|
344 | return fAverageSectors->GetEntriesFast();
|
---|
345 | }
|
---|
346 |
|
---|
347 |
|
---|
348 | // --------------------------------------------------------------------------
|
---|
349 | //
|
---|
350 | // Get i-th pixel (pixel number)
|
---|
351 | //
|
---|
352 | MCalibrationPix &MCalibrationCam::operator[](UInt_t i)
|
---|
353 | {
|
---|
354 | return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
|
---|
355 | }
|
---|
356 |
|
---|
357 | // --------------------------------------------------------------------------
|
---|
358 | //
|
---|
359 | // Get i-th pixel (pixel number)
|
---|
360 | //
|
---|
361 | const MCalibrationPix &MCalibrationCam::operator[](UInt_t i) const
|
---|
362 | {
|
---|
363 | return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
|
---|
364 | }
|
---|
365 |
|
---|
366 | // --------------------------------------------------------------------------
|
---|
367 | //
|
---|
368 | // Returns the current size of the TClonesArray fPixels
|
---|
369 | // independently if the MCalibrationPix is filled with values or not.
|
---|
370 | //
|
---|
371 | const Int_t MCalibrationCam::GetSize() const
|
---|
372 | {
|
---|
373 | return fPixels->GetEntriesFast();
|
---|
374 | }
|
---|
375 |
|
---|
376 | // --------------------------------------------------------------------------
|
---|
377 | //
|
---|
378 | // Get i-th average pixel (area number)
|
---|
379 | //
|
---|
380 | MCalibrationPix &MCalibrationCam::GetAverageArea(const UInt_t i)
|
---|
381 | {
|
---|
382 | return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
|
---|
383 | }
|
---|
384 |
|
---|
385 | // --------------------------------------------------------------------------
|
---|
386 | //
|
---|
387 | // Get i-th average pixel (area number)
|
---|
388 | //
|
---|
389 | const MCalibrationPix &MCalibrationCam::GetAverageArea(const UInt_t i) const
|
---|
390 | {
|
---|
391 | return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
|
---|
392 | }
|
---|
393 |
|
---|
394 | // --------------------------------------------------------------------------
|
---|
395 | //
|
---|
396 | // Get i-th average pixel (sector number)
|
---|
397 | //
|
---|
398 | MCalibrationPix &MCalibrationCam::GetAverageSector(const UInt_t i)
|
---|
399 | {
|
---|
400 | return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
|
---|
401 | }
|
---|
402 |
|
---|
403 | // --------------------------------------------------------------------------
|
---|
404 | //
|
---|
405 | // Get i-th average pixel (sector number)
|
---|
406 | //
|
---|
407 | const MCalibrationPix &MCalibrationCam::GetAverageSector(const UInt_t i) const
|
---|
408 | {
|
---|
409 | return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
|
---|
410 | }
|
---|
411 |
|
---|
412 | // --------------------------------------------------------------------------
|
---|
413 | //
|
---|
414 | // Get i-th average pixel (area number)
|
---|
415 | //
|
---|
416 | MBadPixelsPix &MCalibrationCam::GetAverageBadArea(const UInt_t i)
|
---|
417 | {
|
---|
418 | return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
|
---|
419 | }
|
---|
420 |
|
---|
421 | // --------------------------------------------------------------------------
|
---|
422 | //
|
---|
423 | // Get i-th average pixel (area number)
|
---|
424 | //
|
---|
425 | const MBadPixelsPix &MCalibrationCam::GetAverageBadArea(const UInt_t i) const
|
---|
426 | {
|
---|
427 | return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
|
---|
428 | }
|
---|
429 |
|
---|
430 | // --------------------------------------------------------------------------
|
---|
431 | //
|
---|
432 | // Get i-th average pixel (sector number)
|
---|
433 | //
|
---|
434 | MBadPixelsPix &MCalibrationCam::GetAverageBadSector(const UInt_t i)
|
---|
435 | {
|
---|
436 | return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
|
---|
437 | }
|
---|
438 |
|
---|
439 | // --------------------------------------------------------------------------
|
---|
440 | //
|
---|
441 | // Get i-th average pixel (sector number)
|
---|
442 | //
|
---|
443 | const MBadPixelsPix &MCalibrationCam::GetAverageBadSector(const UInt_t i) const
|
---|
444 | {
|
---|
445 | return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
|
---|
446 | }
|
---|
447 |
|
---|
448 |
|
---|
449 |
|
---|
450 | // --------------------------------------------------------------------------
|
---|
451 | //
|
---|
452 | // Dummy needed for compilation with MCamEvent
|
---|
453 | //
|
---|
454 | Bool_t MCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
455 | {
|
---|
456 | return kTRUE;
|
---|
457 | }
|
---|
458 |
|
---|
459 |
|
---|
460 |
|
---|
461 | // --------------------------------------------------------------------------
|
---|
462 | //
|
---|
463 | // Calls MCalibrationPix::DrawClone()
|
---|
464 | //
|
---|
465 | void MCalibrationCam::DrawPixelContent(Int_t idx) const
|
---|
466 | {
|
---|
467 | (*this)[idx].DrawClone();
|
---|
468 | }
|
---|
469 |
|
---|
470 | void MCalibrationCam::SetNumHiGainFADCSlices( const Float_t i, const Int_t aidx)
|
---|
471 | {
|
---|
472 | if (aidx < 0)
|
---|
473 | return;
|
---|
474 |
|
---|
475 | if (aidx < fNumHiGainFADCSlices.GetSize())
|
---|
476 | fNumHiGainFADCSlices[aidx] = i;
|
---|
477 | }
|
---|
478 |
|
---|
479 | void MCalibrationCam::SetNumLoGainFADCSlices( const Float_t i, const Int_t aidx)
|
---|
480 | {
|
---|
481 | if (aidx < 0)
|
---|
482 | return;
|
---|
483 | if (aidx < fNumLoGainFADCSlices.GetSize())
|
---|
484 | fNumLoGainFADCSlices[aidx] = i;
|
---|
485 | }
|
---|
486 |
|
---|
487 | void MCalibrationCam::SetNumUnsuitable( const UInt_t i, const Int_t aidx)
|
---|
488 | {
|
---|
489 | if (aidx < 0)
|
---|
490 | return;
|
---|
491 |
|
---|
492 | if (aidx < fNumUnsuitable.GetSize())
|
---|
493 | fNumUnsuitable[aidx] = i;
|
---|
494 | }
|
---|
495 |
|
---|
496 | void MCalibrationCam::SetNumUnreliable( const UInt_t i, const Int_t aidx)
|
---|
497 | {
|
---|
498 | if (aidx < 0)
|
---|
499 | return;
|
---|
500 | if (aidx < fNumUnreliable.GetSize())
|
---|
501 | fNumUnreliable[aidx] = i;
|
---|
502 | }
|
---|