source: tags/Mars-V0.10.1/mcalib/MCalibConstCam.cc

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