source: trunk/MagicSoft/Mars/mcalib/MCalibrationTestCam.cc@ 4692

Last change on this file since 4692 was 4649, checked in by gaug, 20 years ago
*** empty log message ***
File size: 12.0 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// MCalibrationTestCam
27//
28// Storage container for calibrated photons, with calibration applied on the
29// same calibration run (see MHCalibrationTestCam and MHCalibrationTestPix).
30//
31// Contains TClonesArrays for the following objects:
32// - fPixels: Array of classes derived from MCalibrationTestPix, one entry
33// per pixel.
34// - fAverageAreas: Array of classes derived from MCalibrationTestPix, one entry
35// per pixel AREA.
36// - fAverageSectors: Array of classes derived from MCalibrationTestPix, one entry
37// per camera SECTOR.
38//
39// Averaged values over one whole area index (e.g. inner or outer pixels for
40// the MAGIC camera), can be retrieved via:
41// MCalibrationTestPix &avpix = fTestCam->GetAverageArea(i)
42//
43// Averaged values over one whole camera sector can be retrieved via:
44// MCalibrationTestPix &avpix = fTestCam->GetAverageSector(i)
45//
46// See also: MCalibrationTestPix, MCalibrationTestCalc, MCalibrationQECam
47// MHCalibrationTestPix, MHCalibrationTestCam
48//
49/////////////////////////////////////////////////////////////////////////////
50#include "MCalibrationTestCam.h"
51#include "MCalibrationTestPix.h"
52
53#include <TClonesArray.h>
54
55#include "MLog.h"
56#include "MLogManip.h"
57
58#include "MGeomCam.h"
59#include "MGeomPix.h"
60
61ClassImp(MCalibrationTestCam);
62
63using namespace std;
64// --------------------------------------------------------------------------
65//
66// Default constructor.
67//
68// Sets all pointers to 0
69//
70// Creates a TClonesArray of MCalibrationTestPix containers, initialized to 1 entry, destinated
71// to hold one container per pixel. Later, a call to MCalibrationTestCam::InitSize()
72// has to be performed (in MGeomApply).
73//
74// Creates a TClonesArray of MCalibrationTestPix containers, initialized to 1 entry, destinated
75// to hold one container per pixel AREA. Later, a call to MCalibrationTestCam::InitAreas()
76// has to be performed (in MGeomApply).
77//
78// Creates a TClonesArray of MCalibrationTestPix containers, initialized to 1 entry, destinated
79// to hold one container per camera SECTOR. Later, a call to MCalibrationTestCam::InitSectors()
80// has to be performed (in MGeomApply).
81//
82// Calls:
83// - Clear()
84//
85MCalibrationTestCam::MCalibrationTestCam(const char *name, const char *title)
86{
87
88 fName = name ? name : "MCalibrationTestCam";
89 fTitle = title ? title : "Storage container for the Calibration Test Information in the camera";
90
91 fPixels = new TClonesArray("MCalibrationTestPix",1);
92 fAverageAreas = new TClonesArray("MCalibrationTestPix",1);
93 fAverageSectors = new TClonesArray("MCalibrationTestPix",1);
94
95 Clear();
96}
97
98// --------------------------------------------------------------------------
99//
100// Deletes the following TClonesArray's of MCalibrationPix containers (if exist):
101// - fPixels
102// - fAverageAreas
103// - fAverageSectors
104//
105MCalibrationTestCam::~MCalibrationTestCam()
106{
107
108 delete fPixels;
109 delete fAverageAreas;
110 delete fAverageSectors;
111
112}
113
114// --------------------------------------
115//
116// Sets all variable to 0.
117// Sets all flags to kFALSE
118// Calls MCalibrationCam::Clear()
119//
120void MCalibrationTestCam::Clear(Option_t *o)
121{
122
123 fNumUninterpolatedInMaxCluster = 0;
124
125 { fPixels ->ForEach(TObject, Clear)(); }
126 { fAverageAreas ->ForEach(TObject, Clear)(); }
127 { fAverageSectors->ForEach(TObject, Clear)(); }
128
129 return;
130}
131
132// -------------------------------------------------------------------
133//
134// Calls TClonesArray::ExpandCreate() for fPixels
135//
136void MCalibrationTestCam::InitSize(const UInt_t i)
137{
138 fPixels->ExpandCreate(i);
139}
140
141// -------------------------------------------------------------------
142//
143// Calls TClonesArray::ExpandCreate() for:
144// - fAverageAreas
145//
146void MCalibrationTestCam::InitAverageAreas(const UInt_t i)
147{
148
149 fAverageAreas->ExpandCreate(i);
150
151 for (UInt_t j=0; j<i; j++)
152 GetAverageArea(j).SetPixId(j);
153
154 fNumUninterpolated.Set(i);
155}
156
157// -------------------------------------------------------------------
158//
159// Calls TClonesArray::ExpandCreate() for:
160// - fAverageSectors
161//
162void MCalibrationTestCam::InitAverageSectors(const UInt_t i)
163{
164
165 fAverageSectors->ExpandCreate(i);
166
167 for (UInt_t j=0; j<i; j++)
168 GetAverageSector(j).SetPixId(j);
169
170}
171
172// -------------------------------------------------------------------
173//
174// Calls:
175// - InitSize()
176// - InitAverageAreas()
177// - InitAverageSectors()
178//
179void MCalibrationTestCam::Init(const MGeomCam &geom)
180{
181
182 InitSize (geom.GetNumPixels() );
183 InitAverageAreas (geom.GetNumAreas() );
184 InitAverageSectors(geom.GetNumSectors());
185}
186
187// --------------------------------------------------------------------------
188//
189// Returns the current size of the TClonesArray fAverageAreas
190// independently if the MCalibrationPix is filled with values or not.
191//
192const Int_t MCalibrationTestCam::GetAverageAreas() const
193{
194 return fAverageAreas->GetEntriesFast();
195}
196
197// --------------------------------------------------------------------------
198//
199// Returns the current size of the TClonesArray fAverageSectors
200// independently if the MCalibrationPix is filled with values or not.
201//
202const Int_t MCalibrationTestCam::GetAverageSectors() const
203{
204 return fAverageSectors->GetEntriesFast();
205}
206
207
208// --------------------------------------------------------------------------
209//
210// Get i-th pixel (pixel number)
211//
212MCalibrationTestPix &MCalibrationTestCam::operator[](UInt_t i)
213{
214 return *static_cast<MCalibrationTestPix*>(fPixels->UncheckedAt(i));
215}
216
217// --------------------------------------------------------------------------
218//
219// Get i-th pixel (pixel number)
220//
221const MCalibrationTestPix &MCalibrationTestCam::operator[](UInt_t i) const
222{
223 return *static_cast<MCalibrationTestPix*>(fPixels->UncheckedAt(i));
224}
225
226// --------------------------------------------------------------------------
227//
228// Returns the current size of the TClonesArray fPixels
229// independently if the MCalibrationTestPix is filled with values or not.
230//
231const Int_t MCalibrationTestCam::GetSize() const
232{
233 return fPixels->GetEntriesFast();
234}
235
236// --------------------------------------------------------------------------
237//
238// Get i-th average pixel (area number)
239//
240MCalibrationTestPix &MCalibrationTestCam::GetAverageArea(UInt_t i)
241{
242 return *static_cast<MCalibrationTestPix*>(fAverageAreas->UncheckedAt(i));
243}
244
245// --------------------------------------------------------------------------
246//
247// Get i-th average pixel (area number)
248//
249const MCalibrationTestPix &MCalibrationTestCam::GetAverageArea(UInt_t i) const
250{
251 return *static_cast<MCalibrationTestPix*>(fAverageAreas->UncheckedAt(i));
252}
253
254// --------------------------------------------------------------------------
255//
256// Get i-th average pixel (sector number)
257//
258MCalibrationTestPix &MCalibrationTestCam::GetAverageSector(UInt_t i)
259{
260 return *static_cast<MCalibrationTestPix*>(fAverageSectors->UncheckedAt(i));
261}
262
263// --------------------------------------------------------------------------
264//
265// Get i-th average pixel (sector number)
266//
267const MCalibrationTestPix &MCalibrationTestCam::GetAverageSector(UInt_t i) const
268{
269 return *static_cast<MCalibrationTestPix*>(fAverageSectors->UncheckedAt(i));
270}
271
272// --------------------------------------------------------------------------
273//
274// Print first the well fitted pixels
275// and then the ones which are not FitValid
276//
277void MCalibrationTestCam::Print(Option_t *o) const
278{
279
280 *fLog << all << GetDescriptor() << ":" << endl;
281 int id = 0;
282
283 *fLog << all << "Calibrated (or interpolated) pixels:" << endl;
284 *fLog << all << endl;
285
286 TIter Next(fPixels);
287 MCalibrationTestPix *pix;
288 while ((pix=(MCalibrationTestPix*)Next()))
289 {
290
291 if (!pix->IsExcluded())
292 {
293
294 *fLog << all
295 << Form("%s%3i","Pixel: ",pix->GetPixId())
296 << Form("%s%4.2f%s%4.2f"," Num.Photons: ",pix->GetNumPhotons(),"+-",pix->GetNumPhotonsErr())
297 << Form("%s%4.2f%s%4.2f"," Num.Photons/mm^2: ",pix->GetNumPhotonsPerArea()
298 ,"+-",pix->GetNumPhotonsPerAreaErr())
299 << endl;
300 id++;
301 }
302 }
303
304 *fLog << all << id << " pixels" << endl;
305 id = 0;
306
307
308 *fLog << all << endl;
309 *fLog << all << "Not interpolated pixels:" << endl;
310 *fLog << all << endl;
311
312 id = 0;
313
314 TIter Next4(fPixels);
315 while ((pix=(MCalibrationTestPix*)Next4()))
316 {
317 if (pix->IsExcluded())
318 {
319 *fLog << all << pix->GetPixId() << " ";
320 id++;
321
322 if (!(id % 25))
323 *fLog << endl;
324 }
325 }
326
327 *fLog << endl;
328 *fLog << all << id << " Excluded pixels " << endl;
329 *fLog << endl;
330
331 *fLog << all << endl;
332 *fLog << all << "Averaged Areas:" << endl;
333 *fLog << all << endl;
334
335 TIter Next5(fAverageAreas);
336 while ((pix=(MCalibrationTestPix*)Next5()))
337 {
338 *fLog << all << Form("%s%3i","Area Idx: ",pix->GetPixId())
339 << Form("%s%4.2f%s%4.2f"," Num.Photons: ",pix->GetNumPhotons(),"+-",pix->GetNumPhotonsErr())
340 << Form("%s%4.2f%s%4.2f"," Num.Photons/mm^2: ",pix->GetNumPhotonsPerArea()
341 ,"+-",pix->GetNumPhotonsPerAreaErr())
342 << endl;
343 }
344
345 *fLog << all << endl;
346 *fLog << all << "Averaged Sectors:" << endl;
347 *fLog << all << endl;
348
349 TIter Next6(fAverageSectors);
350 while ((pix=(MCalibrationTestPix*)Next6()))
351 {
352 *fLog << all << Form("%s%3i","Sector: ",pix->GetPixId())
353 << Form("%s%4.2f%s%4.2f"," Num.Photons: ",pix->GetNumPhotons(),"+-",pix->GetNumPhotonsErr())
354 << Form("%s%4.2f%s%4.2f"," Num.Photons/mm^2: ",pix->GetNumPhotonsPerArea()
355 ,"+-",pix->GetNumPhotonsPerAreaErr())
356 << endl;
357 }
358 *fLog << all << endl;
359}
360
361
362// --------------------------------------------------------------------------
363//
364// The types are as follows:
365//
366// 0: Number Photons
367// 1: Error Number Photons
368// 2: Number photons per area
369// 3: Error Number Photons per area
370// 4: Pixels which are not interpolateable
371//
372Bool_t MCalibrationTestCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
373{
374
375 if (idx > GetSize())
376 return kFALSE;
377
378 Float_t area = cam[idx].GetA();
379
380 if (area == 0)
381 return kFALSE;
382
383 MCalibrationTestPix &pix = (MCalibrationTestPix&)(*this)[idx];
384
385 switch (type)
386 {
387 case 0:
388 if (pix.IsExcluded())
389 return kFALSE;
390 val = pix.GetNumPhotons();
391 break;
392 case 1:
393 if (pix.IsExcluded())
394 return kFALSE;
395 val = pix.GetNumPhotonsErr();
396 break;
397 case 2:
398 if (pix.IsExcluded())
399 return kFALSE;
400 val = pix.GetNumPhotonsPerArea();
401 break;
402 case 3:
403 if (pix.IsExcluded())
404 return kFALSE;
405 val = pix.GetNumPhotonsPerAreaErr();
406 break;
407 case 4:
408 if (!pix.IsExcluded())
409 return kFALSE;
410 val = 1;
411 break;
412 default:
413 return kFALSE;
414 }
415
416 return val!=-1.;
417}
418
419void MCalibrationTestCam::SetNumUninterpolated( const UInt_t i, const Int_t aidx )
420{
421
422 if (aidx < 0)
423 return;
424
425 if (aidx < fNumUninterpolated.GetSize())
426 fNumUninterpolated[aidx] = i;
427}
428
Note: See TracBrowser for help on using the repository browser.