source: trunk/MagicSoft/Mars/mcalib/MCalibrationCam.cc@ 4636

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