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

Last change on this file since 4144 was 4142, checked in by gaug, 20 years ago
*** empty log message ***
File size: 11.4 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 : fNumUnsuitable(),
91 fNumUnreliable(),
92 fNumHiGainFADCSlices(0.), fNumLoGainFADCSlices(0.), fPulserColor(kNONE),
93 fPixels(NULL), fAverageAreas(NULL), fAverageSectors(NULL)
94{
95 fName = name ? name : "MCalibrationCam";
96 fTitle = title ? title : "Base class Storage container for Camera Calibration";
97
98 fAverageBadAreas = new TClonesArray("MBadPixelsPix",1);
99 fAverageBadSectors = new TClonesArray("MBadPixelsPix",1);
100
101}
102
103// --------------------------------------------------------------------------
104//
105// Deletes the following TClonesArray's of MCalibrationPix containers (if exist):
106// - fPixels
107// - fAverageAreas
108// - fAverageSectors
109//
110// Deletes the following TClonesArray's of MBadPixelsPix containers (if exist):
111// - fAverageBadAreas
112// - fAverageBadSectors
113//
114MCalibrationCam::~MCalibrationCam()
115{
116
117 //
118 // delete fPixels should delete all Objects stored inside
119 //
120 if (fPixels)
121 delete fPixels;
122
123 if (fAverageAreas)
124 delete fAverageAreas;
125
126 if (fAverageSectors)
127 delete fAverageSectors;
128
129 delete fAverageBadAreas;
130 delete fAverageBadSectors;
131
132}
133
134// --------------------------------------
135//
136// Calls the ForEach macro for the TClonesArray fPixels with the argument Clear()
137//
138// Loops over the fAverageAreas, calling the function Clear() for
139// every entry in:
140// - fAverageAreas
141// - fAverageBadAreas
142//
143// Loops over the fAverageSectors, calling the function Clear() for
144// every entry in:
145// - fAverageSectors
146// - fAverageBadSectors
147//
148void MCalibrationCam::Clear(Option_t *o)
149{
150
151 fPixels->ForEach(TObject, Clear)();
152
153 //
154 // another ForEach does not compile, thus have to do the loop ourselves:
155 //
156 for (Int_t i=0;i<GetAverageAreas();i++)
157 {
158 fAverageAreas[i].Clear();
159 fAverageBadAreas[i].Clear();
160 }
161
162 //
163 // another ForEach does not compile, thus have to do the loop ourselves:
164 //
165 for (Int_t i=0;i<GetAverageSectors();i++)
166 {
167 fAverageSectors[i].Clear();
168 fAverageBadSectors[i].Clear();
169 }
170
171 return;
172}
173
174// -------------------------------------------------------------------
175//
176// Calls TClonesArray::ExpandCreate() for fPixels
177//
178void MCalibrationCam::InitSize(const UInt_t i)
179{
180 fPixels->ExpandCreate(i);
181}
182
183// -------------------------------------------------------------------
184//
185// Calls TClonesArray::ExpandCreate() for:
186// - fAverageAreas
187// - fAverageBadAreas
188//
189void MCalibrationCam::InitAverageAreas(const UInt_t i)
190{
191 fAverageAreas->ExpandCreate(i);
192 fAverageBadAreas->ExpandCreate(i);
193
194 for (UInt_t j=0; j<i; j++)
195 GetAverageArea(j).SetPixId(j);
196
197 fNumUnsuitable.Set(i);
198 fNumUnreliable.Set(i);
199}
200
201// -------------------------------------------------------------------
202//
203// Calls TClonesArray::ExpandCreate() for:
204// - fAverageSectors
205// - fAverageBadSectors
206//
207void MCalibrationCam::InitAverageSectors(const UInt_t i)
208{
209 fAverageSectors->ExpandCreate(i);
210 fAverageBadSectors->ExpandCreate(i);
211
212 for (UInt_t j=0; j<i; j++)
213 GetAverageSector(j).SetPixId(j);
214
215}
216
217// -------------------------------------------------------------------
218//
219// Calls:
220// - InitSize()
221// - InitAverageAreas()
222// - InitAverageSectors()
223//
224void MCalibrationCam::Init(const MGeomCam &geom)
225{
226 InitSize (geom.GetNumPixels() );
227 InitAverageAreas (geom.GetNumAreas() );
228 InitAverageSectors(geom.GetNumSectors());
229}
230
231// --------------------------------------------------------------------------
232//
233// Returns the number of un-suitable pixels per area index and -1 if
234// the area index exceeds the initialized array.
235//
236const Int_t MCalibrationCam::GetNumUnsuitable( Int_t aidx ) const
237{
238 if (aidx < 0)
239 return -1;
240
241 return aidx > fNumUnsuitable.GetSize() ? -1 : fNumUnsuitable[aidx];
242}
243
244// --------------------------------------------------------------------------
245//
246// Returns the number of un-reliable pixels per area index and -1 if
247// the area index exceeds the initialized array.
248//
249const Int_t MCalibrationCam::GetNumUnreliable( Int_t aidx ) const
250{
251 if (aidx < 0)
252 return -1;
253
254 return aidx > fNumUnreliable.GetSize() ? -1 : fNumUnreliable[aidx];
255}
256
257
258// --------------------------------------------------------------------------
259//
260// Returns the current size of the TClonesArray fAverageAreas
261// independently if the MCalibrationPix is filled with values or not.
262//
263const Int_t MCalibrationCam::GetAverageAreas() const
264{
265 return fAverageAreas->GetEntriesFast();
266}
267
268// --------------------------------------------------------------------------
269//
270// Returns the current size of the TClonesArray fAverageSectors
271// independently if the MCalibrationPix is filled with values or not.
272//
273const Int_t MCalibrationCam::GetAverageSectors() const
274{
275 return fAverageSectors->GetEntriesFast();
276}
277
278
279// --------------------------------------------------------------------------
280//
281// Get i-th pixel (pixel number)
282//
283MCalibrationPix &MCalibrationCam::operator[](UInt_t i)
284{
285 return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
286}
287
288// --------------------------------------------------------------------------
289//
290// Get i-th pixel (pixel number)
291//
292const MCalibrationPix &MCalibrationCam::operator[](UInt_t i) const
293{
294 return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
295}
296
297// Returns the current size of the TClonesArray fPixels
298// independently if the MCalibrationPix is filled with values or not.
299const Int_t MCalibrationCam::GetSize() const
300{
301 return fPixels->GetEntriesFast();
302}
303
304// --------------------------------------------------------------------------
305//
306// Get i-th average pixel (area number)
307//
308MCalibrationPix &MCalibrationCam::GetAverageArea(UInt_t i)
309{
310 return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
311}
312
313// --------------------------------------------------------------------------
314//
315// Get i-th average pixel (area number)
316//
317const MCalibrationPix &MCalibrationCam::GetAverageArea(UInt_t i) const
318{
319 return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
320}
321
322// --------------------------------------------------------------------------
323//
324// Get i-th average pixel (sector number)
325//
326MCalibrationPix &MCalibrationCam::GetAverageSector(UInt_t i)
327{
328 return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
329}
330
331// --------------------------------------------------------------------------
332//
333// Get i-th average pixel (sector number)
334//
335const MCalibrationPix &MCalibrationCam::GetAverageSector(UInt_t i) const
336{
337 return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
338}
339
340// --------------------------------------------------------------------------
341//
342// Get i-th average pixel (area number)
343//
344MBadPixelsPix &MCalibrationCam::GetAverageBadArea(UInt_t i)
345{
346 return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
347}
348
349// --------------------------------------------------------------------------
350//
351// Get i-th average pixel (area number)
352//
353const MBadPixelsPix &MCalibrationCam::GetAverageBadArea(UInt_t i) const
354{
355 return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
356}
357
358// --------------------------------------------------------------------------
359//
360// Get i-th average pixel (sector number)
361//
362MBadPixelsPix &MCalibrationCam::GetAverageBadSector(UInt_t i)
363{
364 return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
365}
366
367// --------------------------------------------------------------------------
368//
369// Get i-th average pixel (sector number)
370//
371const MBadPixelsPix &MCalibrationCam::GetAverageBadSector(UInt_t i) const
372{
373 return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
374}
375
376
377
378// --------------------------------------------------------------------------
379//
380// Dummy needed for compilation with MCamEvent
381//
382Bool_t MCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
383{
384 return kTRUE;
385}
386
387
388
389// --------------------------------------------------------------------------
390//
391// Calls MCalibrationPix::DrawClone()
392//
393void MCalibrationCam::DrawPixelContent(Int_t idx) const
394{
395 (*this)[idx].DrawClone();
396}
397
398void MCalibrationCam::SetNumUnsuitable( const UInt_t i, const Int_t aidx)
399{
400 if (aidx < 0)
401 return;
402
403 if (aidx < fNumUnsuitable.GetSize())
404 fNumUnsuitable[aidx] = i;
405}
406
407void MCalibrationCam::SetNumUnreliable( const UInt_t i, const Int_t aidx)
408{
409 if (aidx < 0)
410 return;
411 if (aidx < fNumUnreliable.GetSize())
412 fNumUnreliable[aidx] = i;
413}
Note: See TracBrowser for help on using the repository browser.