source: branches/removing_cpp11_features/mcalib/MCalibrationCam.cc@ 19796

Last change on this file since 19796 was 17783, checked in by tbretz, 11 years ago
Get rid of a few compiler warnings about obsolete const qualifiers.
File size: 16.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 TOrdCollections 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// Previous Class Versions haven't been commented by the author!
45//
46// Class Version 6:
47// ----------------
48// + added fRunNumber
49//
50// All TOrdCollections have to enlarged by the corresponding calls to (e.g. in MGeomApply):
51// - InitSize()
52// - InitAverageAreas()
53// - InitAverageSectors()
54//
55/////////////////////////////////////////////////////////////////////////////
56#include "MCalibrationCam.h"
57
58#include <TOrdCollection.h>
59
60#include "MGeomCam.h"
61#include "MGeom.h"
62
63#include "MBadPixelsCam.h"
64#include "MBadPixelsPix.h"
65
66#include "MCalibrationPix.h"
67
68#include "MLog.h"
69#include "MLogManip.h"
70
71ClassImp(MCalibrationCam);
72
73using namespace std;
74
75const Int_t MCalibrationCam::gkNumPulserColors = 4;
76
77// --------------------------------------------------------------------------
78//
79// Default constructor.
80//
81// Set the following pointer to NULL:
82// - fPixels
83// - fAverageAreas
84// - fAverageSectors
85//
86// Initializes:
87// - fPulserColor to kNONE
88// - fNumHiGainFADCSlices to 0.
89// - fNumLoGainFADCSlices to 0.
90//
91// Creates a TOrdCollection of MBadPixelsPix containers for the TOrdCollection's:
92// - fAverageBadAreas
93// - fAverageBadSectors
94// all initialized to 1 entry
95//
96// Later, a call to InitAverageAreas() and InitAverageSectors() (or Init())
97// has to be performed in order to get the dimension correctly.
98//
99MCalibrationCam::MCalibrationCam(const char *name, const char *title)
100 : fRunNumber(-1), fPulserColor(kNONE)
101{
102
103 fPixels = new TOrdCollection;
104 fPixels->SetOwner();
105
106 fAverageAreas = new TOrdCollection;
107 fAverageAreas->SetOwner();
108
109 fAverageSectors = new TOrdCollection;
110 fAverageSectors->SetOwner();
111
112 fAverageBadAreas = new TOrdCollection;
113 fAverageBadAreas->SetOwner();
114
115 fAverageBadSectors = new TOrdCollection;
116 fAverageBadSectors->SetOwner();
117
118 fNumHiGainFADCSlices.Set(1);
119 fNumLoGainFADCSlices.Set(1);
120}
121
122// --------------------------------------------------------------------------
123//
124// Deletes the following TOrdCollection's of MCalibrationPix containers (if exist):
125// - fPixels
126// - fAverageAreas
127// - fAverageSectors
128//
129// Deletes the following TOrdCollection's of MBadPixelsPix containers (if exist):
130// - fAverageBadAreas
131// - fAverageBadSectors
132//
133MCalibrationCam::~MCalibrationCam()
134{
135
136 //
137 // delete fPixels should delete all Objects stored inside
138 //
139 if (fPixels)
140 delete fPixels;
141
142 if (fAverageAreas)
143 delete fAverageAreas;
144
145 if (fAverageSectors)
146 delete fAverageSectors;
147
148 if (fAverageBadAreas)
149 delete fAverageBadAreas;
150
151 if (fAverageBadSectors)
152 delete fAverageBadSectors;
153
154}
155
156// --------------------------------------
157//
158// Calls the ForEach macro for the TOrdCollection fPixels with the argument Clear()
159//
160// Loops over the fAverageAreas, calling the function Clear() for
161// every entry in:
162// - fAverageAreas
163// - fAverageBadAreas
164//
165// Loops over the fAverageSectors, calling the function Clear() for
166// every entry in:
167// - fAverageSectors
168// - fAverageBadSectors
169//
170void MCalibrationCam::Clear(Option_t *o)
171{
172 { fPixels ->R__FOR_EACH(TObject, Clear)(); }
173 { fAverageAreas ->R__FOR_EACH(TObject, Clear)(); }
174 { fAverageSectors->R__FOR_EACH(TObject, Clear)(); }
175}
176
177// --------------------------------------------------------------------------
178//
179// Copy 'constructor'
180//
181void MCalibrationCam::Copy(TObject& object) const
182{
183
184 MCalibrationCam &calib = (MCalibrationCam&)object;
185
186 MParContainer::Copy(calib);
187
188 calib.fPulserColor = fPulserColor;
189
190 const Int_t n = GetSize();
191 if (n != 0)
192 {
193 calib.InitSize(n);
194 for (int i=0; i<n; i++)
195 (*this)[i].Copy(calib[i]);
196 }
197
198 const Int_t n2 = GetAverageAreas();
199 if (n2 != 0)
200 {
201 calib.InitAverageAreas(n2);
202 for (int i=0; i<n2; i++)
203 {
204 GetAverageArea (i).Copy(calib.GetAverageArea(i));
205 GetAverageBadArea(i).Copy(calib.GetAverageBadArea(i));
206 calib.fNumUnsuitable [i] = fNumUnsuitable[i];
207 calib.fNumUnreliable [i] = fNumUnreliable[i];
208 calib.fNumHiGainFADCSlices[i] = fNumHiGainFADCSlices[i];
209 calib.fNumLoGainFADCSlices[i] = fNumLoGainFADCSlices[i];
210 }
211 }
212
213 const Int_t n3 = GetAverageSectors();
214 if (n3 != 0)
215 {
216 calib.InitAverageSectors(n3);
217 for (int i=0; i<n3; i++)
218 {
219 GetAverageSector (i).Copy(calib.GetAverageSector(i));
220 GetAverageBadSector(i).Copy(calib.GetAverageBadSector(i));
221 }
222 }
223}
224
225// -------------------------------------------------------------------
226//
227// Initialize the objects inside the TOrdCollection using the
228// virtual function Add().
229//
230//
231// InitSize can only increase the size, but not shrink.
232//
233// It can be called more than one time. New Containers are
234// added only from the current size to the argument i.
235//
236void MCalibrationCam::InitSize(const UInt_t i)
237{
238
239 const UInt_t save = GetSize();
240
241 if (i==save)
242 return;
243
244 if (i>save)
245 Add(save,i);
246}
247
248void MCalibrationCam::Add(const UInt_t a, const UInt_t b)
249{
250 for (UInt_t i=a; i<b; i++)
251 fPixels->AddAt(new MCalibrationPix,i);
252}
253
254void MCalibrationCam::AddArea(const UInt_t a, const UInt_t b)
255{
256 for (UInt_t i=a; i<b; i++)
257 fAverageAreas->AddAt(new MCalibrationPix,i);
258}
259
260void MCalibrationCam::AddSector(const UInt_t a, const UInt_t b)
261{
262 for (UInt_t i=a; i<b; i++)
263 fAverageSectors->AddAt(new MCalibrationPix,i);
264}
265
266
267// -------------------------------------------------------------------
268//
269// Initialize the objects inside the TOrdCollections
270// - fAverageAreas
271// - fAverageBadAreas
272// using the virtual function Add().
273//
274// InitSize can only increase the size, but not shrink.
275//
276// It can be called more than one time. New Containers are
277// added only from the current size to the argument i.
278//
279void MCalibrationCam::InitAverageAreas(const UInt_t i)
280{
281
282 const UInt_t save = GetAverageAreas();
283
284 if (i==save)
285 return;
286
287 fNumUnsuitable.Set(i);
288 fNumUnreliable.Set(i);
289 fNumHiGainFADCSlices.Set(i);
290 fNumLoGainFADCSlices.Set(i);
291
292 if (i < save)
293 return;
294
295 for (UInt_t j=save; j<i; j++)
296 fAverageBadAreas->AddAt(new MBadPixelsPix,j);
297
298 AddArea(save,i);
299
300 for (UInt_t j=save; j<i; j++)
301 GetAverageArea(j).SetPixId(j);
302
303}
304
305// -------------------------------------------------------------------
306//
307// Initialize the objects inside the TOrdCollections
308// - fAverageSectors
309// - fAverageBadSectors
310// using the virtual function Add().
311//
312// InitSize can only increase the size, but not shrink.
313//
314// It can be called more than one time. New Containers are
315// added only from the current size to the argument i.
316//
317void MCalibrationCam::InitAverageSectors(const UInt_t i)
318{
319
320 const UInt_t save = GetAverageSectors();
321
322 if (i==save)
323 return;
324
325 if (i < save)
326 return;
327
328 for (UInt_t j=save; j<i; j++)
329 fAverageBadSectors->AddAt(new MBadPixelsPix,j);
330
331 AddSector(save,i);
332
333 for (UInt_t j=save; j<i; j++)
334 GetAverageSector(j).SetPixId(j);
335}
336
337// -------------------------------------------------------------------
338//
339// Calls:
340// - InitSize()
341// - InitAverageAreas()
342// - InitAverageSectors()
343//
344void MCalibrationCam::Init(const MGeomCam &geom)
345{
346 InitSize (geom.GetNumPixels() );
347 InitAverageAreas (geom.GetNumAreas() );
348 InitAverageSectors(geom.GetNumSectors());
349}
350
351// --------------------------------------------------------------------------
352//
353// Returns the number of un-suitable pixels per area index and -1 if
354// the area index exceeds the initialized array.
355//
356Int_t MCalibrationCam::GetNumUnsuitable( const Int_t aidx ) const
357{
358 if (aidx < 0)
359 {
360 Int_t num = 0;
361 for (Int_t i=0;i<fNumUnsuitable.GetSize();i++)
362 num += fNumUnsuitable[i];
363 return num;
364 }
365
366 return aidx > fNumUnsuitable.GetSize() ? -1 : fNumUnsuitable[aidx];
367}
368
369// --------------------------------------------------------------------------
370//
371// Returns the number of un-reliable pixels per area index and -1 if
372// the area index exceeds the initialized array.
373//
374Int_t MCalibrationCam::GetNumUnreliable( const Int_t aidx ) const
375{
376 if (aidx < 0)
377 {
378 Int_t num = 0;
379 for (Int_t i=0;i<fNumUnreliable.GetSize();i++)
380 num += fNumUnreliable[i];
381 return num;
382 }
383
384 return aidx > fNumUnreliable.GetSize() ? -1 : fNumUnreliable[aidx];
385}
386
387// --------------------------------------------------------------------------
388//
389// Returns the mean number of High-Gain FADC slices per area index and -1 if
390// the area index exceeds the initialized array.
391//
392Float_t MCalibrationCam::GetNumHiGainFADCSlices( const Int_t aidx ) const
393{
394 if (aidx < 0)
395 return -1;
396
397 return aidx > fNumHiGainFADCSlices.GetSize() ? -1 : fNumHiGainFADCSlices[aidx];
398}
399
400// --------------------------------------------------------------------------
401//
402// Returns the mean number of Low-Gain FADC slices per area index and -1 if
403// the area index exceeds the initialized array.
404//
405Float_t MCalibrationCam::GetNumLoGainFADCSlices( const Int_t aidx ) const
406{
407 if (aidx < 0)
408 return -1;
409
410 return aidx > fNumLoGainFADCSlices.GetSize() ? -1 : fNumLoGainFADCSlices[aidx];
411}
412
413
414
415// --------------------------------------------------------------------------
416//
417// Returns the current size of the TOrdCollection fAverageAreas
418// independently if the MCalibrationPix is filled with values or not.
419//
420Int_t MCalibrationCam::GetAverageAreas() const
421{
422 return fAverageAreas->GetSize();
423}
424
425// --------------------------------------------------------------------------
426//
427// Returns the current size of the TOrdCollection fAverageSectors
428// independently if the MCalibrationPix is filled with values or not.
429//
430Int_t MCalibrationCam::GetAverageSectors() const
431{
432 return fAverageSectors->GetSize();
433}
434
435
436// --------------------------------------------------------------------------
437//
438// Get i-th pixel (pixel number)
439//
440MCalibrationPix &MCalibrationCam::operator[](UInt_t i)
441{
442 return *static_cast<MCalibrationPix*>(fPixels->At(i));
443}
444
445// --------------------------------------------------------------------------
446//
447// Get i-th pixel (pixel number)
448//
449const MCalibrationPix &MCalibrationCam::operator[](UInt_t i) const
450{
451 return *static_cast<MCalibrationPix*>(fPixels->At(i));
452}
453
454// --------------------------------------------------------------------------
455//
456// Returns the current size of the TOrdCollection fPixels
457// independently if the MCalibrationPix is filled with values or not.
458//
459Int_t MCalibrationCam::GetSize() const
460{
461 return fPixels->GetSize();
462}
463
464// --------------------------------------------------------------------------
465//
466// Get i-th average pixel (area number)
467//
468MCalibrationPix &MCalibrationCam::GetAverageArea(const UInt_t i)
469{
470 return *static_cast<MCalibrationPix*>(fAverageAreas->At(i));
471}
472
473// --------------------------------------------------------------------------
474//
475// Get i-th average pixel (area number)
476//
477const MCalibrationPix &MCalibrationCam::GetAverageArea(const UInt_t i) const
478{
479 return *static_cast<MCalibrationPix*>(fAverageAreas->At(i));
480}
481
482// --------------------------------------------------------------------------
483//
484// Get i-th average pixel (sector number)
485//
486MCalibrationPix &MCalibrationCam::GetAverageSector(const UInt_t i)
487{
488 return *static_cast<MCalibrationPix*>(fAverageSectors->At(i));
489}
490
491// --------------------------------------------------------------------------
492//
493// Get i-th average pixel (sector number)
494//
495const MCalibrationPix &MCalibrationCam::GetAverageSector(const UInt_t i) const
496{
497 return *static_cast<MCalibrationPix*>(fAverageSectors->At(i));
498}
499
500// --------------------------------------------------------------------------
501//
502// Get i-th average pixel (area number)
503//
504MBadPixelsPix &MCalibrationCam::GetAverageBadArea(const UInt_t i)
505{
506 return *static_cast<MBadPixelsPix*>(fAverageBadAreas->At(i));
507}
508
509// --------------------------------------------------------------------------
510//
511// Get i-th average pixel (area number)
512//
513const MBadPixelsPix &MCalibrationCam::GetAverageBadArea(const UInt_t i) const
514{
515 return *static_cast<MBadPixelsPix*>(fAverageBadAreas->At(i));
516}
517
518// --------------------------------------------------------------------------
519//
520// Get i-th average pixel (sector number)
521//
522MBadPixelsPix &MCalibrationCam::GetAverageBadSector(const UInt_t i)
523{
524 return *static_cast<MBadPixelsPix*>(fAverageBadSectors->At(i));
525}
526
527// --------------------------------------------------------------------------
528//
529// Get i-th average pixel (sector number)
530//
531const MBadPixelsPix &MCalibrationCam::GetAverageBadSector(const UInt_t i) const
532{
533 return *static_cast<MBadPixelsPix*>(fAverageBadSectors->At(i));
534}
535
536
537
538// --------------------------------------------------------------------------
539//
540Bool_t MCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
541{
542 if (idx > GetSize())
543 return kFALSE;
544
545 const Float_t area = cam[idx].GetA();
546
547 if (area == 0)
548 return kFALSE;
549
550 if ((*this)[idx].IsExcluded())
551 return kFALSE;
552
553 switch (type)
554 {
555 case 0:
556 val = (*this)[idx].GetHiGainMean();
557 break;
558 case 1:
559 val = (*this)[idx].GetHiGainMeanErr();
560 break;
561 case 2:
562 val = (*this)[idx].GetHiGainSigma();
563 break;
564 case 3:
565 val = (*this)[idx].GetHiGainSigmaErr();
566 break;
567 case 4:
568 val = (*this)[idx].GetHiGainProb();
569 break;
570 case 5:
571 val = (*this)[idx].GetLoGainMean();
572 break;
573 case 6:
574 val = (*this)[idx].GetLoGainMeanErr();
575 break;
576 case 7:
577 val = (*this)[idx].GetLoGainSigma();
578 break;
579 case 8:
580 val = (*this)[idx].GetLoGainSigmaErr();
581 break;
582 default:
583 return kFALSE;
584 }
585
586 return val!=-1.;
587}
588
589// --------------------------------------------------------------------------
590//
591// Calls MCalibrationPix::DrawClone()
592//
593void MCalibrationCam::DrawPixelContent(Int_t idx) const
594{
595 (*this)[idx].DrawClone();
596}
597
598void MCalibrationCam::SetNumHiGainFADCSlices( const Float_t i, const Int_t aidx)
599{
600 if (aidx < 0)
601 return;
602
603 if (aidx < fNumHiGainFADCSlices.GetSize())
604 fNumHiGainFADCSlices[aidx] = i;
605}
606
607void MCalibrationCam::SetNumLoGainFADCSlices( const Float_t i, const Int_t aidx)
608{
609 if (aidx < 0)
610 return;
611 if (aidx < fNumLoGainFADCSlices.GetSize())
612 fNumLoGainFADCSlices[aidx] = i;
613}
614
615void MCalibrationCam::SetNumUnsuitable( const UInt_t i, const Int_t aidx)
616{
617 if (aidx < 0)
618 return;
619
620 if (aidx < fNumUnsuitable.GetSize())
621 fNumUnsuitable[aidx] = i;
622}
623
624void MCalibrationCam::SetNumUnreliable( const UInt_t i, const Int_t aidx)
625{
626 if (aidx < 0)
627 return;
628 if (aidx < fNumUnreliable.GetSize())
629 fNumUnreliable[aidx] = i;
630}
631
632TString MCalibrationCam::GetPulserColorStr(PulserColor_t col)
633{
634 TString str;
635 switch (col)
636 {
637 case kCT1: str += "CT1"; break;
638 case kGREEN: str += "Green"; break;
639 case kBLUE: str += "Blue"; break;
640 case kUV: str += "UV"; break;
641 case kNONE: str += "None"; break;
642 default: str += "Unknown"; break;
643 }
644 str += " (";
645 str += (int)col;
646 str += ")";
647 return str;
648}
Note: See TracBrowser for help on using the repository browser.