source: trunk/MagicSoft/Mars/mcalib/MCalibrationIntensityCam.cc@ 4985

Last change on this file since 4985 was 4967, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 10.4 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 TClonesArrays for the following objects:
31// - fCams: Array of classes derived from MCalibrationCam, one entry
32// per calibration camera result. Has to be created
33//
34// See also: MCalibrationIntensityChargeCam, MCalibrationIntensityQECam,
35// MCalibrationIntensityRelTimeCam,
36// MCalibrationCam, MCalibrationPix,
37// MCalibrationQECam, MCalibrationQEPix,
38// MHCalibrationChargePix, MHCalibrationChargeCam
39// MCalibrationChargeBlindPix, MCalibrationChargePINDiode
40//
41//
42/////////////////////////////////////////////////////////////////////////////
43#include "MCalibrationIntensityCam.h"
44
45#include <TClonesArray.h>
46
47#include "MGeomCam.h"
48
49ClassImp(MCalibrationIntensityCam);
50
51using namespace std;
52
53// --------------------------------------------------------------------------
54//
55// Default constructor.
56//
57// Set the following pointer to NULL:
58// - fCams
59//
60MCalibrationIntensityCam::MCalibrationIntensityCam(const char *name, const char *title)
61 : fCams(NULL)
62{
63
64 fName = name ? name : "MCalibrationIntensityCam";
65 fTitle = title ? title : "Base container for the Intensity Calibration";
66
67}
68
69// --------------------------------------------------------------------------
70//
71// Deletes the histograms if they exist
72//
73MCalibrationIntensityCam::~MCalibrationIntensityCam()
74{
75 if (fCams)
76 delete fCams;
77}
78
79// --------------------------------------------------------------------------
80//
81// Add a new MCalibrationCam to fCams, give it the name "name" and initialize
82// it with geom.
83//
84void MCalibrationIntensityCam::AddToList( const char* name, const MGeomCam &geom)
85{
86
87 fCams->ExpandCreate(GetSize()+1);
88
89 GetCam()->SetName(name);
90 GetCam()->Init(geom);
91}
92
93
94
95// --------------------------------------------------------------------------
96//
97// Copy 'constructor'
98//
99void MCalibrationIntensityCam::Copy(TObject& object) const
100{
101
102 MCalibrationIntensityCam &calib = (MCalibrationIntensityCam&)object;
103
104 MParContainer::Copy(calib);
105
106 calib.fOffsets = fOffsets;
107 calib.fSlopes = fSlopes;
108
109 const UInt_t n = GetSize();
110 if (n != 0)
111 {
112 calib.InitSize(n);
113 for (UInt_t i=0; i<n; i++)
114 GetCam(i)->Copy(*(calib.GetCam(i)));
115 }
116
117}
118
119// -----------------------------------------------------
120//
121// Calls Clear() for all entries fCams
122//
123void MCalibrationIntensityCam::Clear(Option_t *o)
124{
125
126 fCams->ForEach(MCalibrationCam, Clear)();
127
128 return;
129}
130
131// -----------------------------------------------------
132//
133// Calls Print(o) for all entries fCams
134//
135void MCalibrationIntensityCam::Print(Option_t *o) const
136{
137 fCams->ForEach(MCalibrationCam, Print)(o);
138}
139
140// -----------------------------------------------------
141//
142// Not yet installed...
143//
144void MCalibrationIntensityCam::DrawHiLoFits()
145{
146
147 /*
148 if (!fOffsets)
149 fOffsets = new TH1D("pp","Offsets of the HiGain LoGain Fit",100,-600.,400.);
150 if (!fSlopes)
151 fSlopes = new TH1D("mm","Slopes of the HiGain LoGain Fit",100,-2.,2.);
152 if (!fOffvsSlope)
153 fOffvsSlope = new TH2D("aa","Slopes vs Offsets of the HiGain LoGain Fit",100,-600.,400.,100,-2.,2.);
154
155 TIter Next(fPixels);
156 MCalibrationPix *pix;
157 MHCalibrationPixel *hist;
158 while ((pix=(MCalibrationPix*)Next()))
159 {
160 hist = pix->GetHist();
161 hist->FitHiGainvsLoGain();
162 fOffsets->Fill(hist->GetOffset(),1.);
163 fSlopes->Fill(hist->GetSlope(),1.);
164 fOffvsSlope->Fill(hist->GetOffset(),hist->GetSlope(),1.);
165 }
166
167 TCanvas *c1 = new TCanvas();
168
169 c1->Divide(1,3);
170 c1->cd(1);
171 fOffsets->Draw();
172 gPad->Modified();
173 gPad->Update();
174
175 c1->cd(2);
176 fSlopes->Draw();
177 gPad->Modified();
178 gPad->Update();
179
180 c1->cd(3);
181 fOffvsSlope->Draw("col1");
182 gPad->Modified();
183 gPad->Update();
184 */
185}
186
187// -------------------------------------------------------------------
188//
189// Calls TClonesArray::ExpandCreate() for fCams
190//
191void MCalibrationIntensityCam::InitSize(const UInt_t n)
192{
193 fCams->ExpandCreate(n);
194}
195
196// -------------------------------------------------------------------
197//
198// If size is still 0, Intialize a first Cam.
199// Calls Init(geom) for all fCams
200//
201void MCalibrationIntensityCam::Init(const MGeomCam &geom)
202{
203 if (GetSize() == 0)
204 InitSize(1);
205 fCams->ForEach(MCalibrationCam,Init)(geom);
206}
207
208
209// --------------------------------------------------------------------------
210//
211// Returns the current size of the TClonesArray fCams
212// independently if the MCalibrationCam is filled with values or not.
213//
214const Int_t MCalibrationIntensityCam::GetSize() const
215{
216 return fCams->GetEntriesFast();
217}
218
219// --------------------------------------------------------------------------
220//
221// Get i-th pixel from current camera
222//
223MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i)
224{
225 return (*GetCam(GetSize()-1))[i];
226}
227
228// --------------------------------------------------------------------------
229//
230// Get i-th pixel from current camera
231//
232const MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i) const
233{
234 return (*GetCam(GetSize()-1))[i];
235}
236
237
238// --------------------------------------------------------------------------
239//
240// Returns the current size of the TObjArray fAverageAreas of the current camera.
241//
242const Int_t MCalibrationIntensityCam::GetAverageAreas() const
243{
244 return GetCam(GetSize()-1)->GetAverageAreas();
245}
246
247// --------------------------------------------------------------------------
248//
249// Get i-th High Gain pixel Area from the current camera
250//
251MCalibrationPix &MCalibrationIntensityCam::GetAverageArea(UInt_t i)
252{
253 return GetCam(GetSize()-1)->GetAverageArea(i);
254}
255
256// --------------------------------------------------------------------------
257//
258// Get i-th High Gain pixel Area from the current camera
259//
260const MCalibrationPix &MCalibrationIntensityCam::GetAverageArea(UInt_t i) const
261{
262 return GetCam(GetSize()-1)->GetAverageArea(i);
263}
264
265// --------------------------------------------------------------------------
266//
267// Get i-th High Gain pixel Area from the current camera
268//
269MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i)
270{
271 return GetCam(GetSize()-1)->GetAverageBadArea(i);
272}
273
274// --------------------------------------------------------------------------
275//
276// Get i-th High Gain pixel Area from the current camera
277//
278const MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i) const
279{
280 return GetCam(GetSize()-1)->GetAverageBadArea(i);
281}
282
283// --------------------------------------------------------------------------
284//
285// Returns the current size of the TObjArray fAverageSectors or the current camera
286//
287const Int_t MCalibrationIntensityCam::GetAverageSectors() const
288{
289 return GetCam(GetSize()-1)->GetAverageSectors();
290}
291
292// --------------------------------------------------------------------------
293//
294// Get i-th High Gain Sector from the current camera
295//
296MCalibrationPix &MCalibrationIntensityCam::GetAverageSector(UInt_t i)
297{
298 return GetCam(GetSize()-1)->GetAverageSector(i);
299}
300
301// --------------------------------------------------------------------------
302//
303// Get i-th High Gain Sector from the current camera
304//
305const MCalibrationPix &MCalibrationIntensityCam::GetAverageSector(UInt_t i) const
306{
307 return GetCam(GetSize()-1)->GetAverageSector(i);
308}
309
310// --------------------------------------------------------------------------
311//
312// Get i-th High Gain Sector from the current camera
313//
314MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i)
315{
316 return GetCam(GetSize()-1)->GetAverageBadSector(i);
317}
318
319// --------------------------------------------------------------------------
320//
321// Get i-th High Gain Sector from the current camera
322//
323const MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i) const
324{
325 return GetCam(GetSize()-1)->GetAverageBadSector(i);
326}
327
328
329// --------------------------------------------------------------------------
330//
331// Get i-th camera
332//
333MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i)
334{
335 return static_cast<MCalibrationCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
336}
337
338// --------------------------------------------------------------------------
339//
340// Get i-th camera
341//
342const MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i) const
343{
344 return static_cast<MCalibrationCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
345}
346
347// --------------------------------------------------------------------------
348//
349// Get camera with name 'name'
350//
351MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name )
352{
353 return static_cast<MCalibrationCam*>(fCams->FindObject(name));
354}
355
356// --------------------------------------------------------------------------
357//
358// Get camera with name 'name'
359//
360const MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name ) const
361{
362 return static_cast<MCalibrationCam*>(fCams->FindObject(name));
363}
364
365// --------------------------------------------------------------------------
366//
367// Calls GetPixelContent for the current entry in fCams
368//
369Bool_t MCalibrationIntensityCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
370{
371 return GetCam()->GetPixelContent(val,idx,cam,type);
372}
373
374// --------------------------------------------------------------------------
375//
376// Calls DrawPixelContent for the current entry in fCams
377//
378void MCalibrationIntensityCam::DrawPixelContent( Int_t num ) const
379{
380 return GetCam()->DrawPixelContent(num);
381}
382
Note: See TracBrowser for help on using the repository browser.