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

Last change on this file since 3667 was 3667, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 9.8 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
66// --------------------------------------------------------------------------
67//
68// Default constructor.
69//
70// Set the following pointer to NULL:
71// - fPixels
72// - fAverageAreas
73// - fAverageSectors
74//
75// Creates a TClonesArray of MBadPixelsPix containers for the TClonesArray's:
76// - fAverageBadAreas
77// - fAverageBadSectors
78// all initialized to 1 entry
79//
80// Later, a call to InitAverageAreas() and InitAverageSectors() has to be performed in order
81// to get the dimension correctly.
82//
83MCalibrationCam::MCalibrationCam(const char *name, const char *title)
84 : fPixels(NULL), fAverageAreas(NULL), fAverageSectors(NULL)
85{
86 fName = name ? name : "MCalibrationCam";
87 fTitle = title ? title : "Base class Storage container for Camera Calibration";
88
89 fAverageBadAreas = new TClonesArray("MBadPixelsPix",1);
90 fAverageBadSectors = new TClonesArray("MBadPixelsPix",1);
91
92}
93
94// --------------------------------------------------------------------------
95//
96// Deletes the following TClonesArray's of MCalibrationPix containers (if exist):
97// - fPixels
98// - fAverageAreas
99// - fAverageSectors
100//
101// Deletes the following TClonesArray's of MBadPixelsPix containers (if exist):
102// - fAverageBadAreas
103// - fAverageBadSectors
104//
105MCalibrationCam::~MCalibrationCam()
106{
107
108 //
109 // delete fPixels should delete all Objects stored inside
110 //
111 if (fPixels)
112 delete fPixels;
113
114 if (fAverageAreas)
115 delete fAverageAreas;
116
117 if (fAverageSectors)
118 delete fAverageSectors;
119
120 delete fAverageBadAreas;
121 delete fAverageBadSectors;
122
123}
124
125// --------------------------------------
126//
127// Calls the ForEach macro for the TClonesArray fPixels with the argument Clear()
128//
129// Loops over the fAverageAreas, calling the function Clear() for
130// every entry in:
131// - fAverageAreas
132// - fAverageBadAreas
133//
134// Loops over the fAverageSectors, calling the function Clear() for
135// every entry in:
136// - fAverageSectors
137// - fAverageBadSectors
138//
139void MCalibrationCam::Clear(Option_t *o)
140{
141
142 fPixels->ForEach(TObject, Clear)();
143
144 //
145 // another ForEach does not compile, thus have to do the loop ourselves:
146 //
147 for (Int_t i=0;i<GetAverageAreas();i++)
148 {
149 fAverageAreas[i].Clear();
150 fAverageBadAreas[i].Clear();
151 }
152
153 //
154 // another ForEach does not compile, thus have to do the loop ourselves:
155 //
156 for (Int_t i=0;i<GetAverageSectors();i++)
157 {
158 fAverageSectors[i].Clear();
159 fAverageBadSectors[i].Clear();
160 }
161
162 return;
163}
164
165// -------------------------------------------------------------------
166//
167// Calls TClonesArray::ExpandCreate() for fPixels
168//
169void MCalibrationCam::InitSize(const UInt_t i)
170{
171 fPixels->ExpandCreate(i);
172}
173
174// -------------------------------------------------------------------
175//
176// Calls TClonesArray::ExpandCreate() for:
177// - fAverageAreas
178// - fAverageBadAreas
179//
180void MCalibrationCam::InitAverageAreas(const UInt_t i)
181{
182 fAverageAreas->ExpandCreate(i);
183 fAverageBadAreas->ExpandCreate(i);
184}
185
186// -------------------------------------------------------------------
187//
188// Calls TClonesArray::ExpandCreate() for:
189// - fAverageSectors
190// - fAverageBadSectors
191//
192void MCalibrationCam::InitAverageSectors(const UInt_t i)
193{
194 fAverageSectors->ExpandCreate(i);
195 fAverageBadSectors->ExpandCreate(i);
196}
197
198void MCalibrationCam::Init(const MGeomCam &geom)
199{
200 InitSize (geom.GetNumPixels() );
201 InitAverageAreas (geom.GetNumAreas() );
202 InitAverageSectors(geom.GetNumSectors());
203}
204
205// --------------------------------------------------------------------------
206//
207// Returns the current size of the TClonesArray fPixels
208// independently if the MCalibrationPix is filled with values or not.
209//
210Int_t MCalibrationCam::GetSize() const
211{
212 return fPixels->GetEntriesFast();
213}
214
215// --------------------------------------------------------------------------
216//
217// Returns the current size of the TClonesArray fAverageAreas
218// independently if the MCalibrationPix is filled with values or not.
219//
220Int_t MCalibrationCam::GetAverageAreas() const
221{
222 return fAverageAreas->GetEntriesFast();
223}
224
225// --------------------------------------------------------------------------
226//
227// Returns the current size of the TClonesArray fAverageSectors
228// independently if the MCalibrationPix is filled with values or not.
229//
230Int_t MCalibrationCam::GetAverageSectors() const
231{
232 return fAverageSectors->GetEntriesFast();
233}
234
235
236// --------------------------------------------------------------------------
237//
238// Get i-th pixel (pixel number)
239//
240MCalibrationPix &MCalibrationCam::operator[](UInt_t i)
241{
242 return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
243}
244
245// --------------------------------------------------------------------------
246//
247// Get i-th pixel (pixel number)
248//
249const MCalibrationPix &MCalibrationCam::operator[](UInt_t i) const
250{
251 return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
252}
253
254// --------------------------------------------------------------------------
255//
256// Get i-th average pixel (area number)
257//
258MCalibrationPix &MCalibrationCam::GetAverageArea(UInt_t i)
259{
260 return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
261}
262
263// --------------------------------------------------------------------------
264//
265// Get i-th average pixel (area number)
266//
267const MCalibrationPix &MCalibrationCam::GetAverageArea(UInt_t i) const
268{
269 return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
270}
271
272// --------------------------------------------------------------------------
273//
274// Get i-th average pixel (sector number)
275//
276MCalibrationPix &MCalibrationCam::GetAverageSector(UInt_t i)
277{
278 return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
279}
280
281// --------------------------------------------------------------------------
282//
283// Get i-th average pixel (sector number)
284//
285const MCalibrationPix &MCalibrationCam::GetAverageSector(UInt_t i) const
286{
287 return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
288}
289
290// --------------------------------------------------------------------------
291//
292// Get i-th average pixel (area number)
293//
294MBadPixelsPix &MCalibrationCam::GetAverageBadArea(UInt_t i)
295{
296 return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
297}
298
299// --------------------------------------------------------------------------
300//
301// Get i-th average pixel (area number)
302//
303const MBadPixelsPix &MCalibrationCam::GetAverageBadArea(UInt_t i) const
304{
305 return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
306}
307
308// --------------------------------------------------------------------------
309//
310// Get i-th average pixel (sector number)
311//
312MBadPixelsPix &MCalibrationCam::GetAverageBadSector(UInt_t i)
313{
314 return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
315}
316
317// --------------------------------------------------------------------------
318//
319// Get i-th average pixel (sector number)
320//
321const MBadPixelsPix &MCalibrationCam::GetAverageBadSector(UInt_t i) const
322{
323 return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
324}
325
326
327
328// --------------------------------------------------------------------------
329//
330// Dummy needed for compilation with MCamEvent
331//
332Bool_t MCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
333{
334 return kTRUE;
335}
336
337
338
339// --------------------------------------------------------------------------
340//
341// Calls MCalibrationPix::DrawClone()
342//
343void MCalibrationCam::DrawPixelContent(Int_t idx) const
344{
345 (*this)[idx].DrawClone();
346}
347
Note: See TracBrowser for help on using the repository browser.