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 | // MCalibrationIntensityCam
|
---|
27 | //
|
---|
28 | // Base class for intensity calibration results
|
---|
29 | //
|
---|
30 | // Contains TOrdCollections for the following objects:
|
---|
31 | // - fCams: Array of classes derived from MCalibrationCam, one entry
|
---|
32 | // per calibration camera result.
|
---|
33 | // - fHists: Array of classes derived from MHCalibrationPix, one entry
|
---|
34 | // per calibration camera result and area index
|
---|
35 | //
|
---|
36 | // See also: MCalibrationIntensityChargeCam, MCalibrationIntensityQECam,
|
---|
37 | // MCalibrationIntensityRelTimeCam,
|
---|
38 | // MCalibrationCam, MCalibrationPix,
|
---|
39 | // MCalibrationQECam, MCalibrationQEPix,
|
---|
40 | // MHCalibrationChargePix, MHCalibrationChargeCam
|
---|
41 | // MCalibrationChargeBlindPix, MCalibrationChargePINDiode
|
---|
42 | //
|
---|
43 | // Inline Functions:
|
---|
44 | // -----------------
|
---|
45 | //
|
---|
46 | // GetSize(): Returns the current size of the TOrdCollection fCams
|
---|
47 | // independently if the MCalibrationCam is filled with values or not.
|
---|
48 | //
|
---|
49 | // GetAverageAreas(): Returns the current size of the TOrdCollection
|
---|
50 | // fAverageAreas of the current camera.
|
---|
51 | //
|
---|
52 | // GetAverageArea(UInt_t i): Get i-th High Gain pixel Area from the
|
---|
53 | // current camera
|
---|
54 | //
|
---|
55 | // GetAverageArea(UInt_t i): Get i-th High Gain pixel Area from the
|
---|
56 | // current camera
|
---|
57 | //
|
---|
58 | // GetAverageBadArea(UInt_t i): Get i-th High Gain pixel Area from the
|
---|
59 | // current camera
|
---|
60 | //
|
---|
61 | // GetAverageBadArea(UInt_t i): Get i-th High Gain pixel Area from the
|
---|
62 | // current camera
|
---|
63 | //
|
---|
64 | // GetAverageSectors(): Returns the current size of the TOrdCollection
|
---|
65 | // fAverageSectors or the current camera
|
---|
66 | //
|
---|
67 | // GetAverageSector(UInt_t i): Get i-th High Gain Sector from the
|
---|
68 | // current camera
|
---|
69 | //
|
---|
70 | // GetAverageSector(UInt_t i): Get i-th High Gain Sector from the current
|
---|
71 | // camera
|
---|
72 | //
|
---|
73 | // GetAverageBadSector(UInt_t i): Get i-th High Gain Sector from the
|
---|
74 | // current camera
|
---|
75 | //
|
---|
76 | // GetAverageBadSector(UInt_t i): Get i-th High Gain Sector from the
|
---|
77 | // current camera
|
---|
78 | //
|
---|
79 | //
|
---|
80 | // ClassVersion 2:
|
---|
81 | // + fHists
|
---|
82 | //
|
---|
83 | // ClassVersion 3:
|
---|
84 | // - MArrayD fOffsets; //! Arrays of Higain-vs-LoGain fit result Offsets
|
---|
85 | // - MArrayD fSlopes; //! Arrays of Higain-vs-LoGain fit result Slopes
|
---|
86 | //
|
---|
87 | /////////////////////////////////////////////////////////////////////////////
|
---|
88 | #include "MCalibrationIntensityCam.h"
|
---|
89 |
|
---|
90 | #include <TOrdCollection.h>
|
---|
91 |
|
---|
92 | #include "MLog.h"
|
---|
93 | #include "MLogManip.h"
|
---|
94 |
|
---|
95 | #include "MGeomCam.h"
|
---|
96 | #include "MHCalibrationCam.h"
|
---|
97 |
|
---|
98 | ClassImp(MCalibrationIntensityCam);
|
---|
99 |
|
---|
100 | using namespace std;
|
---|
101 |
|
---|
102 | // --------------------------------------------------------------------------
|
---|
103 | //
|
---|
104 | // Default constructor.
|
---|
105 | //
|
---|
106 | // Set the following pointer to NULL:
|
---|
107 | // - fCams
|
---|
108 | // - fHists
|
---|
109 | //
|
---|
110 | MCalibrationIntensityCam::MCalibrationIntensityCam(const char *name, const char *title)
|
---|
111 | {
|
---|
112 |
|
---|
113 | fName = name ? name : "MCalibrationIntensityCam";
|
---|
114 | fTitle = title ? title : "Base container for the Intensity Calibration";
|
---|
115 |
|
---|
116 | fCams = new TOrdCollection;
|
---|
117 | fCams->SetOwner();
|
---|
118 |
|
---|
119 | fHists = new TOrdCollection;
|
---|
120 | fHists->SetOwner();
|
---|
121 | }
|
---|
122 |
|
---|
123 |
|
---|
124 | // --------------------------------------------------------------------------
|
---|
125 | //
|
---|
126 | // Deletes the histograms if they exist
|
---|
127 | //
|
---|
128 | MCalibrationIntensityCam::~MCalibrationIntensityCam()
|
---|
129 | {
|
---|
130 | delete fCams;
|
---|
131 | delete fHists;
|
---|
132 | }
|
---|
133 |
|
---|
134 | // --------------------------------------------------------------------------
|
---|
135 | //
|
---|
136 | // Add a new MHCalibrationCam to fHists
|
---|
137 | //
|
---|
138 | void MCalibrationIntensityCam::AddHist( const MHCalibrationCam *cam)
|
---|
139 | {
|
---|
140 | const Int_t size = fHists->GetSize();
|
---|
141 | fHists->AddAt((TObject*)cam,size);
|
---|
142 |
|
---|
143 | if (size != GetSize()-1)
|
---|
144 | *fLog << warn << "Histogram Cams and Calibration Cams size mismatch! " << endl;
|
---|
145 | }
|
---|
146 |
|
---|
147 | // --------------------------------------------------------------------------
|
---|
148 | //
|
---|
149 | // Add a new MCalibrationCam to fCams, give it the name "name" and initialize
|
---|
150 | // it with geom.
|
---|
151 | //
|
---|
152 | void MCalibrationIntensityCam::AddToList( const char* name, const MGeomCam &geom)
|
---|
153 | {
|
---|
154 | InitSize(GetSize()+1);
|
---|
155 | GetCam()->SetName(name);
|
---|
156 | GetCam()->Init(geom);
|
---|
157 | }
|
---|
158 |
|
---|
159 |
|
---|
160 |
|
---|
161 | // --------------------------------------------------------------------------
|
---|
162 | //
|
---|
163 | // Copy 'constructor'
|
---|
164 | //
|
---|
165 | void MCalibrationIntensityCam::Copy(TObject& object) const
|
---|
166 | {
|
---|
167 | MCalibrationIntensityCam &calib = (MCalibrationIntensityCam&)object;
|
---|
168 |
|
---|
169 | MParContainer::Copy(calib);
|
---|
170 |
|
---|
171 | const UInt_t n = GetSize();
|
---|
172 | if (n != 0)
|
---|
173 | {
|
---|
174 | calib.InitSize(n);
|
---|
175 | for (UInt_t i=0; i<n; i++)
|
---|
176 | {
|
---|
177 | GetCam(i)->Copy(*(calib.GetCam(i)));
|
---|
178 | GetHist(i)->Copy(*(calib.GetHist(i)));
|
---|
179 | }
|
---|
180 | }
|
---|
181 | }
|
---|
182 |
|
---|
183 | // -----------------------------------------------------
|
---|
184 | //
|
---|
185 | // Calls Clear() for all entries fCams
|
---|
186 | //
|
---|
187 | void MCalibrationIntensityCam::Clear(Option_t *o)
|
---|
188 | {
|
---|
189 | fCams->R__FOR_EACH(MCalibrationCam, Clear)();
|
---|
190 | fHists->R__FOR_EACH(MHCalibrationCam, Clear)();
|
---|
191 | }
|
---|
192 |
|
---|
193 | // -----------------------------------------------------
|
---|
194 | //
|
---|
195 | // Calls Print(o) for all entries fCams
|
---|
196 | //
|
---|
197 | void MCalibrationIntensityCam::Print(Option_t *o) const
|
---|
198 | {
|
---|
199 | fCams->R__FOR_EACH(MCalibrationCam, Print)(o);
|
---|
200 | fHists->R__FOR_EACH(MHCalibrationCam, Print)(o);
|
---|
201 | }
|
---|
202 |
|
---|
203 | // -------------------------------------------------------------------
|
---|
204 | //
|
---|
205 | // Initialize the objects inside the TOrdCollection using the
|
---|
206 | // virtual function Add().
|
---|
207 | //
|
---|
208 | // InitSize can only increase the size, but not shrink.
|
---|
209 | //
|
---|
210 | // It can be called more than one time. New Containers are
|
---|
211 | // added only from the current size to the argument i.
|
---|
212 | //
|
---|
213 | void MCalibrationIntensityCam::InitSize(const UInt_t i)
|
---|
214 | {
|
---|
215 |
|
---|
216 | const UInt_t save = GetSize();
|
---|
217 |
|
---|
218 | if (i==save)
|
---|
219 | return;
|
---|
220 |
|
---|
221 | if (i>save)
|
---|
222 | Add(save,i);
|
---|
223 | }
|
---|
224 |
|
---|
225 | // -------------------------------------------------------------------
|
---|
226 | //
|
---|
227 | // Add MCalibrationCams in the ranges from - to. In order to initialize
|
---|
228 | // from MCalibrationCam derived containers, overwrite this function
|
---|
229 | //
|
---|
230 | void MCalibrationIntensityCam::Add(const UInt_t from, const UInt_t to)
|
---|
231 | {
|
---|
232 | for (UInt_t i=from; i<to; i++)
|
---|
233 | fCams->AddAt(new MCalibrationCam,i);
|
---|
234 | }
|
---|
235 |
|
---|
236 | // -------------------------------------------------------------------
|
---|
237 | //
|
---|
238 | // If size is still 0, Intialize a first Cam.
|
---|
239 | // Calls Init(geom) for all fCams
|
---|
240 | //
|
---|
241 | void MCalibrationIntensityCam::Init(const MGeomCam &geom)
|
---|
242 | {
|
---|
243 | if (GetSize() == 0)
|
---|
244 | InitSize(1);
|
---|
245 |
|
---|
246 | fCams->R__FOR_EACH(MCalibrationCam,Init)(geom);
|
---|
247 | }
|
---|
248 |
|
---|
249 | // --------------------------------------------------------------------------
|
---|
250 | //
|
---|
251 | Int_t MCalibrationIntensityCam::CountNumEntries(const MCalibrationCam::PulserColor_t col) const
|
---|
252 | {
|
---|
253 |
|
---|
254 | Int_t size = 0;
|
---|
255 |
|
---|
256 | if (col == MCalibrationCam::kNONE)
|
---|
257 | return GetSize();
|
---|
258 | else
|
---|
259 | for (Int_t i=0;i<GetSize();i++)
|
---|
260 | {
|
---|
261 | const MCalibrationCam *cam = GetCam(i);
|
---|
262 | if (cam->GetPulserColor() == col)
|
---|
263 | size++;
|
---|
264 | }
|
---|
265 |
|
---|
266 | return size;
|
---|
267 | }
|
---|
268 |
|
---|
269 | // --------------------------------------------------------------------------
|
---|
270 | //
|
---|
271 | // Get i-th pixel from current camera
|
---|
272 | //
|
---|
273 | MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i)
|
---|
274 | {
|
---|
275 | return (*GetCam())[i];
|
---|
276 | }
|
---|
277 |
|
---|
278 | // --------------------------------------------------------------------------
|
---|
279 | //
|
---|
280 | // Get i-th pixel from current camera
|
---|
281 | //
|
---|
282 | const MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i) const
|
---|
283 | {
|
---|
284 | return (*GetCam())[i];
|
---|
285 | }
|
---|
286 |
|
---|
287 | // --------------------------------------------------------------------------
|
---|
288 | //
|
---|
289 | // Get camera with name 'name'
|
---|
290 | //
|
---|
291 | /*
|
---|
292 | MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name)
|
---|
293 | {
|
---|
294 | return static_cast<MCalibrationCam*>(fCams->FindObject(name));
|
---|
295 | }
|
---|
296 |
|
---|
297 | // --------------------------------------------------------------------------
|
---|
298 | //
|
---|
299 | // Get camera with name 'name'
|
---|
300 | //
|
---|
301 | const MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name) const
|
---|
302 | {
|
---|
303 | return static_cast<MCalibrationCam*>(fCams->FindObject(name));
|
---|
304 | }
|
---|
305 | */
|
---|
306 | // --------------------------------------------------------------------------
|
---|
307 | //
|
---|
308 | // Get i-th histogram class
|
---|
309 | //
|
---|
310 | MHCalibrationCam *MCalibrationIntensityCam::GetHist(Int_t i)
|
---|
311 | {
|
---|
312 | return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
|
---|
313 | }
|
---|
314 |
|
---|
315 | // --------------------------------------------------------------------------
|
---|
316 | //
|
---|
317 | // Get i-th histogram class
|
---|
318 | //
|
---|
319 | const MHCalibrationCam *MCalibrationIntensityCam::GetHist(Int_t i) const
|
---|
320 | {
|
---|
321 | return static_cast<MHCalibrationCam*>(i==-1 ? fHists->Last() : fHists->At(i));
|
---|
322 | }
|
---|
323 |
|
---|
324 | // --------------------------------------------------------------------------
|
---|
325 | //
|
---|
326 | // Get histogram class with name 'name'
|
---|
327 | //
|
---|
328 | MHCalibrationCam *MCalibrationIntensityCam::GetHist(const char *name )
|
---|
329 | {
|
---|
330 | return static_cast<MHCalibrationCam*>(fHists->FindObject(name));
|
---|
331 | }
|
---|
332 |
|
---|
333 | // --------------------------------------------------------------------------
|
---|
334 | //
|
---|
335 | // Get histogram class with name 'name'
|
---|
336 | //
|
---|
337 | const MHCalibrationCam *MCalibrationIntensityCam::GetHist(const char *name ) const
|
---|
338 | {
|
---|
339 | return static_cast<MHCalibrationCam*>(fHists->FindObject(name));
|
---|
340 | }
|
---|
341 |
|
---|
342 | // --------------------------------------------------------------------------
|
---|
343 | //
|
---|
344 | // Calls DrawPixelContent for the current entry in fCams
|
---|
345 | //
|
---|
346 | void MCalibrationIntensityCam::DrawPixelContent( Int_t num ) const
|
---|
347 | {
|
---|
348 | return GetCam()->DrawPixelContent(num);
|
---|
349 | }
|
---|