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

Last change on this file since 3842 was 3700, checked in by gaug, 21 years ago
*** empty log message ***
File size: 10.2 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 : fNumHiGainFADCSlices(0.), fNumLoGainFADCSlices(0.), fPulserColor(kNONE),
91 fPixels(NULL), fAverageAreas(NULL), fAverageSectors(NULL)
92{
93 fName = name ? name : "MCalibrationCam";
94 fTitle = title ? title : "Base class Storage container for Camera Calibration";
95
96 fAverageBadAreas = new TClonesArray("MBadPixelsPix",1);
97 fAverageBadSectors = new TClonesArray("MBadPixelsPix",1);
98
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
172// -------------------------------------------------------------------
173//
174// Calls TClonesArray::ExpandCreate() for fPixels
175//
176void MCalibrationCam::InitSize(const UInt_t i)
177{
178 fPixels->ExpandCreate(i);
179}
180
181// -------------------------------------------------------------------
182//
183// Calls TClonesArray::ExpandCreate() for:
184// - fAverageAreas
185// - fAverageBadAreas
186//
187void MCalibrationCam::InitAverageAreas(const UInt_t i)
188{
189 fAverageAreas->ExpandCreate(i);
190 fAverageBadAreas->ExpandCreate(i);
191}
192
193// -------------------------------------------------------------------
194//
195// Calls TClonesArray::ExpandCreate() for:
196// - fAverageSectors
197// - fAverageBadSectors
198//
199void MCalibrationCam::InitAverageSectors(const UInt_t i)
200{
201 fAverageSectors->ExpandCreate(i);
202 fAverageBadSectors->ExpandCreate(i);
203}
204
205// -------------------------------------------------------------------
206//
207// Calls:
208// - InitSize()
209// - InitAverageAreas()
210// - InitAverageSectors()
211//
212void MCalibrationCam::Init(const MGeomCam &geom)
213{
214 InitSize (geom.GetNumPixels() );
215 InitAverageAreas (geom.GetNumAreas() );
216 InitAverageSectors(geom.GetNumSectors());
217}
218
219// --------------------------------------------------------------------------
220//
221// Returns the current size of the TClonesArray fPixels
222// independently if the MCalibrationPix is filled with values or not.
223//
224const Int_t MCalibrationCam::GetSize() const
225{
226 return fPixels->GetEntriesFast();
227}
228
229// --------------------------------------------------------------------------
230//
231// Returns the current size of the TClonesArray fAverageAreas
232// independently if the MCalibrationPix is filled with values or not.
233//
234const Int_t MCalibrationCam::GetAverageAreas() const
235{
236 return fAverageAreas->GetEntriesFast();
237}
238
239// --------------------------------------------------------------------------
240//
241// Returns the current size of the TClonesArray fAverageSectors
242// independently if the MCalibrationPix is filled with values or not.
243//
244const Int_t MCalibrationCam::GetAverageSectors() const
245{
246 return fAverageSectors->GetEntriesFast();
247}
248
249
250// --------------------------------------------------------------------------
251//
252// Get i-th pixel (pixel number)
253//
254MCalibrationPix &MCalibrationCam::operator[](UInt_t i)
255{
256 return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
257}
258
259// --------------------------------------------------------------------------
260//
261// Get i-th pixel (pixel number)
262//
263const MCalibrationPix &MCalibrationCam::operator[](UInt_t i) const
264{
265 return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
266}
267
268// --------------------------------------------------------------------------
269//
270// Get i-th average pixel (area number)
271//
272MCalibrationPix &MCalibrationCam::GetAverageArea(UInt_t i)
273{
274 return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
275}
276
277// --------------------------------------------------------------------------
278//
279// Get i-th average pixel (area number)
280//
281const MCalibrationPix &MCalibrationCam::GetAverageArea(UInt_t i) const
282{
283 return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
284}
285
286// --------------------------------------------------------------------------
287//
288// Get i-th average pixel (sector number)
289//
290MCalibrationPix &MCalibrationCam::GetAverageSector(UInt_t i)
291{
292 return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
293}
294
295// --------------------------------------------------------------------------
296//
297// Get i-th average pixel (sector number)
298//
299const MCalibrationPix &MCalibrationCam::GetAverageSector(UInt_t i) const
300{
301 return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
302}
303
304// --------------------------------------------------------------------------
305//
306// Get i-th average pixel (area number)
307//
308MBadPixelsPix &MCalibrationCam::GetAverageBadArea(UInt_t i)
309{
310 return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
311}
312
313// --------------------------------------------------------------------------
314//
315// Get i-th average pixel (area number)
316//
317const MBadPixelsPix &MCalibrationCam::GetAverageBadArea(UInt_t i) const
318{
319 return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
320}
321
322// --------------------------------------------------------------------------
323//
324// Get i-th average pixel (sector number)
325//
326MBadPixelsPix &MCalibrationCam::GetAverageBadSector(UInt_t i)
327{
328 return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
329}
330
331// --------------------------------------------------------------------------
332//
333// Get i-th average pixel (sector number)
334//
335const MBadPixelsPix &MCalibrationCam::GetAverageBadSector(UInt_t i) const
336{
337 return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
338}
339
340
341
342// --------------------------------------------------------------------------
343//
344// Dummy needed for compilation with MCamEvent
345//
346Bool_t MCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
347{
348 return kTRUE;
349}
350
351
352
353// --------------------------------------------------------------------------
354//
355// Calls MCalibrationPix::DrawClone()
356//
357void MCalibrationCam::DrawPixelContent(Int_t idx) const
358{
359 (*this)[idx].DrawClone();
360}
361
Note: See TracBrowser for help on using the repository browser.