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

Last change on this file since 5019 was 5018, checked in by gaug, 20 years ago
*** empty log message ***
File size: 14.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 TObjArrays 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 TObjArrays 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 <TObjArray.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 TObjArray of MBadPixelsPix containers for the TObjArray'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{
92
93 fPixels = new TObjArray;
94 fPixels->SetOwner();
95
96 fAverageAreas = new TObjArray;
97 fAverageAreas->SetOwner();
98
99 fAverageSectors = new TObjArray;
100 fAverageSectors->SetOwner();
101
102 fAverageBadAreas = new TObjArray;
103 fAverageBadAreas->SetOwner();
104
105 fAverageBadSectors = new TObjArray;
106 fAverageBadSectors->SetOwner();
107
108
109 fNumHiGainFADCSlices.Set(1);
110 fNumLoGainFADCSlices.Set(1);
111}
112
113// --------------------------------------------------------------------------
114//
115// Deletes the following TObjArray's of MCalibrationPix containers (if exist):
116// - fPixels
117// - fAverageAreas
118// - fAverageSectors
119//
120// Deletes the following TObjArray's of MBadPixelsPix containers (if exist):
121// - fAverageBadAreas
122// - fAverageBadSectors
123//
124MCalibrationCam::~MCalibrationCam()
125{
126
127 //
128 // delete fPixels should delete all Objects stored inside
129 //
130 if (fPixels)
131 delete fPixels;
132
133 if (fAverageAreas)
134 delete fAverageAreas;
135
136 if (fAverageSectors)
137 delete fAverageSectors;
138
139 if (fAverageBadAreas)
140 delete fAverageBadAreas;
141
142 if (fAverageBadSectors)
143 delete fAverageBadSectors;
144
145}
146
147// --------------------------------------
148//
149// Calls the ForEach macro for the TObjArray fPixels with the argument Clear()
150//
151// Loops over the fAverageAreas, calling the function Clear() for
152// every entry in:
153// - fAverageAreas
154// - fAverageBadAreas
155//
156// Loops over the fAverageSectors, calling the function Clear() for
157// every entry in:
158// - fAverageSectors
159// - fAverageBadSectors
160//
161void MCalibrationCam::Clear(Option_t *o)
162{
163
164 { fPixels ->ForEach(TObject, Clear)(); }
165 { fAverageAreas ->ForEach(TObject, Clear)(); }
166 { fAverageSectors->ForEach(TObject, Clear)(); }
167
168 return;
169}
170
171// --------------------------------------------------------------------------
172//
173// Copy 'constructor'
174//
175void MCalibrationCam::Copy(TObject& object) const
176{
177
178 MCalibrationCam &calib = (MCalibrationCam&)object;
179
180 MParContainer::Copy(calib);
181
182 calib.fPulserColor = fPulserColor;
183
184 const Int_t n3 = GetSize();
185 if (n3 != 0)
186 {
187 calib.InitSize(n3);
188 for (int i=0; i<n3; i++)
189 (*this)[i].Copy(calib[i]);
190 }
191
192 const Int_t n4 = GetAverageAreas();
193 if (n4 != 0)
194 {
195 calib.InitAverageAreas(n4);
196 for (int i=0; i<n4; i++)
197 {
198 GetAverageArea (i).Copy(calib.GetAverageArea(i));
199 GetAverageBadArea(i).Copy(calib.GetAverageBadArea(i));
200 calib.fNumUnsuitable [i] = fNumUnsuitable[i];
201 calib.fNumUnreliable [i] = fNumUnreliable[i];
202 calib.fNumHiGainFADCSlices[i] = fNumHiGainFADCSlices[i];
203 calib.fNumLoGainFADCSlices[i] = fNumLoGainFADCSlices[i];
204 }
205 }
206
207 const Int_t n5 = GetAverageSectors();
208 if (n5 != 0)
209 {
210 calib.InitAverageSectors(n5);
211 for (int i=0; i<n5; i++)
212 {
213 GetAverageSector (i).Copy(calib.GetAverageSector(i));
214 GetAverageBadSector(i).Copy(calib.GetAverageBadSector(i));
215 }
216 }
217}
218
219// -------------------------------------------------------------------
220//
221// Calls TObjArray::ExpandCreate() for fPixels
222//
223void MCalibrationCam::InitSize(const UInt_t i)
224{
225
226 const UInt_t save = GetSize();
227
228 if (i==save)
229 return;
230
231 fPixels->Expand(i);
232
233 if (i>save)
234 Add(save,i);
235}
236
237void MCalibrationCam::Add(const UInt_t a, const UInt_t b)
238{
239 for (UInt_t i=a; i<b; i++)
240 (*fPixels)[i] = new MCalibrationPix;
241}
242
243void MCalibrationCam::AddArea(const UInt_t a, const UInt_t b)
244{
245 for (UInt_t i=a; i<b; i++)
246 (*fAverageAreas)[i] = new MCalibrationPix;
247}
248
249void MCalibrationCam::AddSector(const UInt_t a, const UInt_t b)
250{
251 for (UInt_t i=a; i<b; i++)
252 (*fAverageSectors)[i] = new MCalibrationPix;
253}
254
255
256// -------------------------------------------------------------------
257//
258// Calls TObjArray::ExpandCreate() for:
259// - fAverageAreas
260// - fAverageBadAreas
261//
262void MCalibrationCam::InitAverageAreas(const UInt_t i)
263{
264
265 const UInt_t save = GetAverageAreas();
266
267 if (i==save)
268 return;
269
270 fAverageAreas->Expand(i);
271 fAverageBadAreas->Expand(i);
272
273 fNumUnsuitable.Set(i);
274 fNumUnreliable.Set(i);
275 fNumHiGainFADCSlices.Set(i);
276 fNumLoGainFADCSlices.Set(i);
277
278 if (i < save)
279 return;
280
281 for (UInt_t j=save; j<i; j++)
282 (*fAverageBadAreas)[j] = new MBadPixelsPix;
283
284 AddArea(save,i);
285
286 for (UInt_t j=save; j<i; j++)
287 GetAverageArea(j).SetPixId(j);
288
289}
290
291// -------------------------------------------------------------------
292//
293// Calls TObjArray::ExpandCreate() for:
294// - fAverageSectors
295// - fAverageBadSectors
296//
297void MCalibrationCam::InitAverageSectors(const UInt_t i)
298{
299
300 const UInt_t save = GetAverageSectors();
301
302 if (i==save)
303 return;
304
305 fAverageSectors->Expand(i);
306 fAverageBadSectors->Expand(i);
307
308 if (i < save)
309 return;
310
311 for (UInt_t j=save; j<i; j++)
312 (*fAverageBadSectors)[j] = new MBadPixelsPix;
313
314 AddSector(save,i);
315
316 for (UInt_t j=save; j<i; j++)
317 GetAverageSector(j).SetPixId(j);
318}
319
320// -------------------------------------------------------------------
321//
322// Calls:
323// - InitSize()
324// - InitAverageAreas()
325// - InitAverageSectors()
326//
327void MCalibrationCam::Init(const MGeomCam &geom)
328{
329 InitSize (geom.GetNumPixels() );
330 InitAverageAreas (geom.GetNumAreas() );
331 InitAverageSectors(geom.GetNumSectors());
332}
333
334// --------------------------------------------------------------------------
335//
336// Returns the number of un-suitable pixels per area index and -1 if
337// the area index exceeds the initialized array.
338//
339const Int_t MCalibrationCam::GetNumUnsuitable( const Int_t aidx ) const
340{
341 if (aidx < 0)
342 {
343 Int_t num = 0;
344 for (Int_t i=0;i<fNumUnsuitable.GetSize();i++)
345 num += fNumUnsuitable[i];
346 return num;
347 }
348
349 return aidx > fNumUnsuitable.GetSize() ? -1 : fNumUnsuitable[aidx];
350}
351
352// --------------------------------------------------------------------------
353//
354// Returns the number of un-reliable pixels per area index and -1 if
355// the area index exceeds the initialized array.
356//
357const Int_t MCalibrationCam::GetNumUnreliable( const Int_t aidx ) const
358{
359 if (aidx < 0)
360 {
361 Int_t num = 0;
362 for (Int_t i=0;i<fNumUnreliable.GetSize();i++)
363 num += fNumUnreliable[i];
364 return num;
365 }
366
367 return aidx > fNumUnreliable.GetSize() ? -1 : fNumUnreliable[aidx];
368}
369
370// --------------------------------------------------------------------------
371//
372// Returns the mean number of High-Gain FADC slices per area index and -1 if
373// the area index exceeds the initialized array.
374//
375const Float_t MCalibrationCam::GetNumHiGainFADCSlices( const Int_t aidx ) const
376{
377 if (aidx < 0)
378 return -1;
379
380 return aidx > fNumHiGainFADCSlices.GetSize() ? -1 : fNumHiGainFADCSlices[aidx];
381}
382
383// --------------------------------------------------------------------------
384//
385// Returns the mean number of Low-Gain FADC slices per area index and -1 if
386// the area index exceeds the initialized array.
387//
388const Float_t MCalibrationCam::GetNumLoGainFADCSlices( const Int_t aidx ) const
389{
390 if (aidx < 0)
391 return -1;
392
393 return aidx > fNumLoGainFADCSlices.GetSize() ? -1 : fNumLoGainFADCSlices[aidx];
394}
395
396
397
398// --------------------------------------------------------------------------
399//
400// Returns the current size of the TObjArray fAverageAreas
401// independently if the MCalibrationPix is filled with values or not.
402//
403const Int_t MCalibrationCam::GetAverageAreas() const
404{
405 return fAverageAreas->GetEntriesFast();
406}
407
408// --------------------------------------------------------------------------
409//
410// Returns the current size of the TObjArray fAverageSectors
411// independently if the MCalibrationPix is filled with values or not.
412//
413const Int_t MCalibrationCam::GetAverageSectors() const
414{
415 return fAverageSectors->GetEntriesFast();
416}
417
418
419// --------------------------------------------------------------------------
420//
421// Get i-th pixel (pixel number)
422//
423MCalibrationPix &MCalibrationCam::operator[](UInt_t i)
424{
425 return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
426}
427
428// --------------------------------------------------------------------------
429//
430// Get i-th pixel (pixel number)
431//
432const MCalibrationPix &MCalibrationCam::operator[](UInt_t i) const
433{
434 return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
435}
436
437// --------------------------------------------------------------------------
438//
439// Returns the current size of the TObjArray fPixels
440// independently if the MCalibrationPix is filled with values or not.
441//
442const Int_t MCalibrationCam::GetSize() const
443{
444 return fPixels->GetEntries();
445}
446
447// --------------------------------------------------------------------------
448//
449// Get i-th average pixel (area number)
450//
451MCalibrationPix &MCalibrationCam::GetAverageArea(const UInt_t i)
452{
453 return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
454}
455
456// --------------------------------------------------------------------------
457//
458// Get i-th average pixel (area number)
459//
460const MCalibrationPix &MCalibrationCam::GetAverageArea(const UInt_t i) const
461{
462 return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
463}
464
465// --------------------------------------------------------------------------
466//
467// Get i-th average pixel (sector number)
468//
469MCalibrationPix &MCalibrationCam::GetAverageSector(const UInt_t i)
470{
471 return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
472}
473
474// --------------------------------------------------------------------------
475//
476// Get i-th average pixel (sector number)
477//
478const MCalibrationPix &MCalibrationCam::GetAverageSector(const UInt_t i) const
479{
480 return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
481}
482
483// --------------------------------------------------------------------------
484//
485// Get i-th average pixel (area number)
486//
487MBadPixelsPix &MCalibrationCam::GetAverageBadArea(const UInt_t i)
488{
489 return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
490}
491
492// --------------------------------------------------------------------------
493//
494// Get i-th average pixel (area number)
495//
496const MBadPixelsPix &MCalibrationCam::GetAverageBadArea(const UInt_t i) const
497{
498 return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
499}
500
501// --------------------------------------------------------------------------
502//
503// Get i-th average pixel (sector number)
504//
505MBadPixelsPix &MCalibrationCam::GetAverageBadSector(const UInt_t i)
506{
507 return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
508}
509
510// --------------------------------------------------------------------------
511//
512// Get i-th average pixel (sector number)
513//
514const MBadPixelsPix &MCalibrationCam::GetAverageBadSector(const UInt_t i) const
515{
516 return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
517}
518
519
520
521// --------------------------------------------------------------------------
522//
523// Dummy needed for compilation with MCamEvent
524//
525Bool_t MCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
526{
527 return kTRUE;
528}
529
530
531
532// --------------------------------------------------------------------------
533//
534// Calls MCalibrationPix::DrawClone()
535//
536void MCalibrationCam::DrawPixelContent(Int_t idx) const
537{
538 (*this)[idx].DrawClone();
539}
540
541void MCalibrationCam::SetNumHiGainFADCSlices( const Float_t i, const Int_t aidx)
542{
543 if (aidx < 0)
544 return;
545
546 if (aidx < fNumHiGainFADCSlices.GetSize())
547 fNumHiGainFADCSlices[aidx] = i;
548}
549
550void MCalibrationCam::SetNumLoGainFADCSlices( const Float_t i, const Int_t aidx)
551{
552 if (aidx < 0)
553 return;
554 if (aidx < fNumLoGainFADCSlices.GetSize())
555 fNumLoGainFADCSlices[aidx] = i;
556}
557
558void MCalibrationCam::SetNumUnsuitable( const UInt_t i, const Int_t aidx)
559{
560 if (aidx < 0)
561 return;
562
563 if (aidx < fNumUnsuitable.GetSize())
564 fNumUnsuitable[aidx] = i;
565}
566
567void MCalibrationCam::SetNumUnreliable( const UInt_t i, const Int_t aidx)
568{
569 if (aidx < 0)
570 return;
571 if (aidx < fNumUnreliable.GetSize())
572 fNumUnreliable[aidx] = i;
573}
Note: See TracBrowser for help on using the repository browser.