source: trunk/MagicSoft/Mars/mbadpixels/MBadPixelsIntensityCam.cc@ 6091

Last change on this file since 6091 was 5052, checked in by gaug, 20 years ago
*** empty log message ***
File size: 7.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// MBadPixelsIntensityCam
27//
28// Base class for intensity calibration results
29//
30// Contains TClonesArrays for the following objects:
31// - fCams: Array of classes derived from MBadPixelsCam, one entry
32// per calibration camera result. Has to be created
33//
34// See also: MCalibrationIntensityChargeCam, MCalibrationIntensityQECam,
35// MCalibrationIntensityRelTimeCam,
36// MCalibrationCam, MCalibrationPix,
37// MCalibrationQECam, MCalibrationQEPix,
38// MHCalibrationChargePix, MHCalibrationChargeCam
39// MCalibrationChargeBlindPix, MCalibrationChargePINDiode
40//
41//
42/////////////////////////////////////////////////////////////////////////////
43#include "MBadPixelsIntensityCam.h"
44
45#include <TOrdCollection.h>
46
47#include "MGeomCam.h"
48
49ClassImp(MBadPixelsIntensityCam);
50
51using namespace std;
52// --------------------------------------------------------------------------
53//
54// Default constructor.
55//
56// Initializes and sets owner of:
57// - fCams
58// - Initializes fCams to entry
59//
60MBadPixelsIntensityCam::MBadPixelsIntensityCam(const char *name, const char *title)
61{
62
63 fName = name ? name : "MBadPixelsIntensityCam";
64 fTitle = title ? title : "Base container for the Intensity Calibration";
65
66 fCams = new TOrdCollection;
67 fCams->SetOwner();
68
69 InitSize(1);
70}
71
72// --------------------------------------------------------------------------
73//
74// Deletes the cameras if they exist
75//
76MBadPixelsIntensityCam::~MBadPixelsIntensityCam()
77{
78 if (fCams)
79 delete fCams;
80}
81
82// --------------------------------------------------------------------------
83//
84// Add a new MBadPixelsCam to fCams, give it the name "name" and initialize
85// it with geom.
86//
87void MBadPixelsIntensityCam::AddToList( const char* name, const MGeomCam &geom)
88{
89 InitSize(GetSize()+1);
90 GetCam()->SetName(name);
91 GetCam()->Init(geom);
92}
93
94
95
96// --------------------------------------------------------------------------
97//
98// Copy 'constructor'
99//
100void MBadPixelsIntensityCam::Copy(TObject& object) const
101{
102
103 MBadPixelsIntensityCam &calib = (MBadPixelsIntensityCam&)object;
104
105 MParContainer::Copy(calib);
106
107 const UInt_t n = GetSize();
108 if (n != 0)
109 {
110 calib.InitSize(n);
111 for (UInt_t i=0; i<n; i++)
112 GetCam(i)->Copy(*(calib.GetCam(i)));
113 }
114
115}
116
117// -----------------------------------------------------
118//
119// Calls Clear() for all entries fCams
120//
121void MBadPixelsIntensityCam::Clear(Option_t *o)
122{
123
124 fCams->ForEach(MBadPixelsCam, Clear)();
125
126 return;
127}
128
129// -----------------------------------------------------
130//
131// Calls Print(o) for all entries fCams
132//
133void MBadPixelsIntensityCam::Print(Option_t *o) const
134{
135 fCams->ForEach(MBadPixelsCam, Print)(o);
136}
137
138
139// -------------------------------------------------------------------
140//
141// Initialize the objects inside the TOrdCollection using the
142// function Add().
143//
144// InitSize can only increase the size, but not shrink.
145//
146// It can be called more than one time. New Containers are
147// added only from the current size to the argument i.
148//
149void MBadPixelsIntensityCam::InitSize(const UInt_t i)
150{
151
152 const UInt_t save = GetSize();
153
154 if (i==save)
155 return;
156
157 if (i>save)
158 Add(save,i);
159}
160
161// -------------------------------------------------------------------
162//
163// Add MBadPixelsCams in the ranges from - to. In order to initialize
164// from MBadPixelsCam derived containers, overwrite this function
165//
166void MBadPixelsIntensityCam::Add(const UInt_t from, const UInt_t to)
167{
168 for (UInt_t i=from; i<to; i++)
169 fCams->AddAt(new MBadPixelsCam,i);
170}
171
172
173// -------------------------------------------------------------------
174//
175// If size is still 0, Intialize a first Cam.
176// Calls Init(geom) for all fCams
177//
178void MBadPixelsIntensityCam::Init(const MGeomCam &geom)
179{
180 if (GetSize() == 0)
181 InitSize(1);
182
183 fCams->ForEach(MBadPixelsCam,Init)(geom);
184}
185
186
187// --------------------------------------------------------------------------
188//
189// Returns the current size of the TOrdCollection fCams
190// independently if the MBadPixelsCam is filled with values or not.
191//
192Int_t MBadPixelsIntensityCam::GetSize() const
193{
194 return fCams->GetSize();
195}
196
197// --------------------------------------------------------------------------
198//
199// Get i-th pixel from current camera
200//
201MBadPixelsPix &MBadPixelsIntensityCam::operator[](Int_t i)
202{
203 return (*GetCam())[i];
204}
205
206// --------------------------------------------------------------------------
207//
208// Get i-th pixel from current camera
209//
210const MBadPixelsPix &MBadPixelsIntensityCam::operator[](Int_t i) const
211{
212 return (*GetCam())[i];
213}
214
215
216// --------------------------------------------------------------------------
217//
218// Get i-th camera
219//
220MBadPixelsCam *MBadPixelsIntensityCam::GetCam(Int_t i)
221{
222 return static_cast<MBadPixelsCam*>(i==-1 ? fCams->Last() : fCams->At(i));
223}
224
225// --------------------------------------------------------------------------
226//
227// Get i-th camera
228//
229const MBadPixelsCam *MBadPixelsIntensityCam::GetCam(Int_t i) const
230{
231 return static_cast<MBadPixelsCam*>(i==-1 ? fCams->Last() : fCams->At(i));
232}
233
234// --------------------------------------------------------------------------
235//
236// Get camera with name 'name'
237//
238MBadPixelsCam *MBadPixelsIntensityCam::GetCam(const char *name )
239{
240 return static_cast<MBadPixelsCam*>(fCams->FindObject(name));
241}
242
243// --------------------------------------------------------------------------
244//
245// Get camera with name 'name'
246//
247const MBadPixelsCam *MBadPixelsIntensityCam::GetCam(const char *name ) const
248{
249 return static_cast<MBadPixelsCam*>(fCams->FindObject(name));
250}
251
252// --------------------------------------------------------------------------
253//
254// Calls GetPixelContent for the current entry in fCams
255//
256Bool_t MBadPixelsIntensityCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
257{
258 return GetCam()->GetPixelContent(val,idx,cam,type);
259}
260
261// --------------------------------------------------------------------------
262//
263// Calls DrawPixelContent for the current entry in fCams
264//
265void MBadPixelsIntensityCam::DrawPixelContent( Int_t num ) const
266{
267 return GetCam()->DrawPixelContent(num);
268}
269
Note: See TracBrowser for help on using the repository browser.