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

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