source: trunk/Mars/mcalib/MCalibConstCam.cc@ 19123

Last change on this file since 19123 was 8408, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 7.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 01/2005 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2007
21!
22\* ======================================================================== */
23
24/////////////////////////////////////////////////////////////////////////////
25//
26// MCalibConstCam
27//
28// Hold the temporary conversion factors for MCalibrateDatara
29//
30// Version 2:
31// ---------
32// - fRunNumber
33//
34//
35/////////////////////////////////////////////////////////////////////////////
36#include "MCalibConstCam.h"
37#include "MCalibConstPix.h"
38
39#include <TClonesArray.h>
40
41#include "MLog.h"
42#include "MLogManip.h"
43
44#include "MGeomCam.h"
45#include "MGeomPix.h"
46
47#include "MBadPixelsCam.h"
48#include "MBadPixelsPix.h"
49
50ClassImp(MCalibConstCam);
51
52using namespace std;
53
54// --------------------------------------------------------------------------
55//
56// Default constructor.
57//
58// Creates a TClonesArray of MCalibConstPix containers, initialized to 1 entry, destinated
59// to hold one container per pixel. Later, a call to MCalibConstCam::InitSize()
60// has to be performed (in MGeomApply).
61//
62// Creates a TClonesArray of MCalibConstPix containers, initialized to 1 entry, destinated
63// to hold one container per pixel AREA. Later, a call to MCalibConstCam::InitAreas()
64// has to be performed (in MGeomApply).
65//
66// Creates a TClonesArray of MCalibConstPix containers, initialized to 1 entry, destinated
67// to hold one container per camera SECTOR. Later, a call to MCalibConstCam::InitSectors()
68// has to be performed (in MGeomApply).
69//
70MCalibConstCam::MCalibConstCam(const char *name, const char *title)
71 : fBadPixels(0)
72{
73 fName = name ? name : "MCalibConstCam";
74 fTitle = title ? title : "Temporary Storage for Calibration Constants";
75
76 fArray = new TClonesArray("MCalibConstPix", 1);
77 fAverageAreas = new TClonesArray("MCalibConstPix", 1);
78 fAverageSectors = new TClonesArray("MCalibConstPix", 1);
79}
80
81// --------------------------------------------------------------------------
82//
83// Deletes the following TClonesArray's of MCalibConstPix containers:
84// - fArray
85// - fAverageAreas
86// - fAverageSectors
87//
88MCalibConstCam::~MCalibConstCam()
89{
90 delete fArray;
91 delete fAverageAreas;
92 delete fAverageSectors;
93}
94
95// --------------------------------------------------------------------------
96//
97// Copy 'constructor'
98//
99void MCalibConstCam::Copy(TObject &obj) const
100{
101
102 MParContainer::Copy(obj);
103
104 MCalibConstCam &cam = (MCalibConstCam&)obj;
105
106 Int_t n = GetSize();
107
108 if (n==0)
109 return;
110
111 cam.InitSize(n);
112 for (int i=0; i<n; i++)
113 (*this)[i].Copy(cam[i]);
114
115 n = GetNumAverageArea();
116 cam.InitAverageAreas(n);
117 for (int i=0; i<n; i++)
118 GetAverageArea(i).Copy(cam.GetAverageArea(i));
119
120 n = GetNumAverageSector();
121 cam.InitAverageSectors(n);
122 for (int i=0; i<n; i++)
123 GetAverageSector(i).Copy(cam.GetAverageSector(i));
124}
125
126
127// -------------------------------------------------------------------
128//
129// Calls:
130// - InitSize()
131// - InitAverageAreas()
132// - InitAverageSectors()
133//
134void MCalibConstCam::Init(const MGeomCam &geom)
135{
136 InitSize (geom.GetNumPixels() );
137 InitAverageAreas (geom.GetNumAreas() );
138 InitAverageSectors(geom.GetNumSectors());
139}
140
141// --------------------------------------------------------------------------
142//
143// This function returns the current size of the TClonesArray
144// independently if the MCalibConstPix is filled with values or not.
145//
146// Get the size of the MCalibConstCam
147//
148Int_t MCalibConstCam::GetSize() const
149{
150 return fArray->GetEntriesFast();
151}
152
153// --------------------------------------------------------------------------
154//
155// Returns the current size of the TClonesArray fAverageAreas
156// independently if the MCalibConstPix is filled with values or not.
157//
158const Int_t MCalibConstCam::GetNumAverageArea() const
159{
160 return fAverageAreas->GetEntriesFast();
161}
162
163// --------------------------------------------------------------------------
164//
165// Returns the current size of the TClonesArray fAverageSectors
166// independently if the MCalibConstPix is filled with values or not.
167//
168const Int_t MCalibConstCam::GetNumAverageSector() const
169{
170 return fAverageSectors->GetEntriesFast();
171}
172
173// --------------------------------------------------------------------------
174//
175// Get i-th pixel (pixel number)
176//
177MCalibConstPix &MCalibConstCam::operator[](Int_t i)
178{
179 return *static_cast<MCalibConstPix*>(fArray->UncheckedAt(i));
180}
181
182// --------------------------------------------------------------------------
183//
184// Get i-th pixel (pixel number)
185//
186const MCalibConstPix &MCalibConstCam::operator[](Int_t i) const
187{
188 return *static_cast<MCalibConstPix*>(fArray->UncheckedAt(i));
189}
190
191// --------------------------------------------------------------------------
192//
193// Get i-th average pixel (area number)
194//
195MCalibConstPix &MCalibConstCam::GetAverageArea(UInt_t i)
196{
197 return *static_cast<MCalibConstPix*>(fAverageAreas->UncheckedAt(i));
198}
199
200// --------------------------------------------------------------------------
201//
202// Get i-th average pixel (area number)
203//
204const MCalibConstPix &MCalibConstCam::GetAverageArea(UInt_t i) const
205{
206 return *static_cast<MCalibConstPix*>(fAverageAreas->UncheckedAt(i));
207}
208
209// --------------------------------------------------------------------------
210//
211// Get i-th average pixel (sector number)
212//
213MCalibConstPix &MCalibConstCam::GetAverageSector(UInt_t i)
214{
215 return *static_cast<MCalibConstPix*>(fAverageSectors->UncheckedAt(i));
216}
217
218// --------------------------------------------------------------------------
219//
220// Get i-th average pixel (sector number)
221//
222const MCalibConstPix &MCalibConstCam::GetAverageSector(UInt_t i) const
223{
224 return *static_cast<MCalibConstPix*>(fAverageSectors->UncheckedAt(i));
225}
226
227// --------------------------------------
228//
229// Calls the ForEach macro for the TClonesArray fArray with the argument Clear()
230//
231// Loops over the fAverageAreas, calling the function Clear() for
232// every entry in fAverageAreas
233//
234// Loops over the fAverageSectors, calling the function Clear() for
235// every entry in fAverageSectors
236//
237void MCalibConstCam::Clear(Option_t *o)
238{
239 { fArray->R__FOR_EACH(TObject, Clear)(); }
240 { fAverageAreas->R__FOR_EACH(TObject, Clear)(); }
241 { fAverageSectors->R__FOR_EACH(TObject, Clear)(); }
242
243}
244
245void MCalibConstCam::Print(Option_t *o) const
246{
247 *fLog << all << GetDescriptor() << ":" << endl;
248 int id = 0;
249
250 TIter Next(fArray);
251 MCalibConstPix *pix;
252 while ((pix=(MCalibConstPix*)Next()))
253 {
254 *fLog << id
255 << Form(": Conversion Factor: %4.3f Global F-Factor: %4.3f",pix->GetCalibConst(),pix->GetCalibFFactor())
256 << endl;
257 id++;
258 }
259}
260
261
262Bool_t MCalibConstCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
263{
264 if (GetSize() <= idx)
265 return kFALSE;
266
267 if (fBadPixels && (*fBadPixels)[idx].IsUnsuitable())
268 return kFALSE;
269
270 switch (type)
271 {
272 case 0:
273 val = (*this)[idx].GetCalibConst();
274 break;
275 case 1:
276 val = (*this)[idx].GetCalibFFactor();
277 break;
278 case 2:
279 val = (*this)[idx].GetCalibConst()*cam.GetPixRatio(idx);
280 break;
281 default:
282 return kFALSE;
283 }
284
285 return val>0.;
286}
287
288void MCalibConstCam::DrawPixelContent(Int_t idx) const
289{
290 *fLog << warn << "MCalibConstCam::DrawPixelContent - not available." << endl;
291}
Note: See TracBrowser for help on using the repository browser.