source: trunk/Mars/mcalib/MCalibrationIntensityCam.cc@ 20104

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