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

Last change on this file was 6457, checked in by tbretz, 20 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// Set the size of the camera
88//
89void MCalibConstCam::InitSize(const UInt_t i)
90{
91 fArray->ExpandCreate(i);
92}
93
94// -------------------------------------------------------------------
95//
96// Calls TClonesArray::ExpandCreate() for:
97// - fAverageAreas
98//
99void MCalibConstCam::InitAverageAreas(const UInt_t i)
100{
101 fAverageAreas->ExpandCreate(i);
102}
103
104// -------------------------------------------------------------------
105//
106// Calls TClonesArray::ExpandCreate() for:
107// - fAverageSectors
108//
109void MCalibConstCam::InitAverageSectors(const UInt_t i)
110{
111 fAverageSectors->ExpandCreate(i);
112}
113
114// -------------------------------------------------------------------
115//
116// Calls:
117// - InitSize()
118// - InitAverageAreas()
119// - InitAverageSectors()
120//
121void MCalibConstCam::Init(const MGeomCam &geom)
122{
123 InitSize (geom.GetNumPixels() );
124 InitAverageAreas (geom.GetNumAreas() );
125 InitAverageSectors(geom.GetNumSectors());
126}
127
128// --------------------------------------------------------------------------
129//
130// This function returns the current size of the TClonesArray
131// independently if the MCalibConstPix is filled with values or not.
132//
133// Get the size of the MCalibConstCam
134//
135Int_t MCalibConstCam::GetSize() const
136{
137 return fArray->GetEntriesFast();
138}
139
140// --------------------------------------------------------------------------
141//
142// Returns the current size of the TClonesArray fAverageAreas
143// independently if the MCalibConstPix is filled with values or not.
144//
145const Int_t MCalibConstCam::GetNumAverageArea() const
146{
147 return fAverageAreas->GetEntriesFast();
148}
149
150// --------------------------------------------------------------------------
151//
152// Returns the current size of the TClonesArray fAverageSectors
153// independently if the MCalibConstPix is filled with values or not.
154//
155const Int_t MCalibConstCam::GetNumAverageSector() const
156{
157 return fAverageSectors->GetEntriesFast();
158}
159
160// --------------------------------------------------------------------------
161//
162// Get i-th pixel (pixel number)
163//
164MCalibConstPix &MCalibConstCam::operator[](Int_t i)
165{
166 return *static_cast<MCalibConstPix*>(fArray->UncheckedAt(i));
167}
168
169// --------------------------------------------------------------------------
170//
171// Get i-th pixel (pixel number)
172//
173const MCalibConstPix &MCalibConstCam::operator[](Int_t i) const
174{
175 return *static_cast<MCalibConstPix*>(fArray->UncheckedAt(i));
176}
177
178// --------------------------------------------------------------------------
179//
180// Get i-th average pixel (area number)
181//
182MCalibConstPix &MCalibConstCam::GetAverageArea(UInt_t i)
183{
184 return *static_cast<MCalibConstPix*>(fAverageAreas->UncheckedAt(i));
185}
186
187// --------------------------------------------------------------------------
188//
189// Get i-th average pixel (area number)
190//
191const MCalibConstPix &MCalibConstCam::GetAverageArea(UInt_t i) const
192{
193 return *static_cast<MCalibConstPix*>(fAverageAreas->UncheckedAt(i));
194}
195
196// --------------------------------------------------------------------------
197//
198// Get i-th average pixel (sector number)
199//
200MCalibConstPix &MCalibConstCam::GetAverageSector(UInt_t i)
201{
202 return *static_cast<MCalibConstPix*>(fAverageSectors->UncheckedAt(i));
203}
204
205// --------------------------------------------------------------------------
206//
207// Get i-th average pixel (sector number)
208//
209const MCalibConstPix &MCalibConstCam::GetAverageSector(UInt_t i) const
210{
211 return *static_cast<MCalibConstPix*>(fAverageSectors->UncheckedAt(i));
212}
213
214// --------------------------------------
215//
216// Calls the ForEach macro for the TClonesArray fArray with the argument Clear()
217//
218// Loops over the fAverageAreas, calling the function Clear() for
219// every entry in fAverageAreas
220//
221// Loops over the fAverageSectors, calling the function Clear() for
222// every entry in fAverageSectors
223//
224void MCalibConstCam::Clear(Option_t *o)
225{
226 { fArray->ForEach(TObject, Clear)(); }
227 { fAverageAreas->ForEach(TObject, Clear)(); }
228 { fAverageSectors->ForEach(TObject, Clear)(); }
229
230}
231
232void MCalibConstCam::Print(Option_t *o) const
233{
234 *fLog << all << GetDescriptor() << ":" << endl;
235 int id = 0;
236
237 TIter Next(fArray);
238 MCalibConstPix *pix;
239 while ((pix=(MCalibConstPix*)Next()))
240 {
241 *fLog << id
242 << Form(": Conversion Factor: %4.3f Global F-Factor: %4.3f",pix->GetCalibConst(),pix->GetCalibFFactor())
243 << endl;
244 id++;
245 }
246}
247
248
249Bool_t MCalibConstCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
250{
251 if (GetSize() <= idx)
252 return kFALSE;
253
254 switch (type)
255 {
256 case 0:
257 val = (*this)[idx].GetCalibConst();
258 break;
259 case 1:
260 val = (*this)[idx].GetCalibFFactor();
261 break;
262 case 2:
263 val = (*this)[idx].GetCalibConst()*cam.GetPixRatio(idx);
264 break;
265 default:
266 return kFALSE;
267 }
268
269 return val>0.;
270}
271
272void MCalibConstCam::DrawPixelContent(Int_t idx) const
273{
274 *fLog << warn << "MCalibConstCam::DrawPixelContent - not available." << endl;
275}
Note: See TracBrowser for help on using the repository browser.