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

Last change on this file since 5036 was 5030, checked in by tbretz, 21 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 TObjArrays 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 <TObjArray.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{
62
63 fName = name ? name : "MCalibrationIntensityCam";
64 fTitle = title ? title : "Base container for the Intensity Calibration";
65
66 fCams = new TObjArray;
67 fCams->SetOwner();
68}
69
70// --------------------------------------------------------------------------
71//
72// Deletes the histograms if they exist
73//
74MCalibrationIntensityCam::~MCalibrationIntensityCam()
75{
76 if (fCams)
77 delete fCams;
78}
79
80// --------------------------------------------------------------------------
81//
82// Add a new MCalibrationCam to fCams, give it the name "name" and initialize
83// it with geom.
84//
85void MCalibrationIntensityCam::AddToList( const char* name, const MGeomCam &geom)
86{
87 InitSize(GetSize()+1);
88 GetCam()->SetName(name);
89 GetCam()->Init(geom);
90}
91
92
93
94// --------------------------------------------------------------------------
95//
96// Copy 'constructor'
97//
98void MCalibrationIntensityCam::Copy(TObject& object) const
99{
100
101 MCalibrationIntensityCam &calib = (MCalibrationIntensityCam&)object;
102
103 MParContainer::Copy(calib);
104
105 calib.fOffsets = fOffsets;
106 calib.fSlopes = fSlopes;
107
108 const UInt_t n = GetSize();
109 if (n != 0)
110 {
111 calib.InitSize(n);
112 for (UInt_t i=0; i<n; i++)
113 GetCam(i)->Copy(*(calib.GetCam(i)));
114 }
115
116}
117
118// -----------------------------------------------------
119//
120// Calls Clear() for all entries fCams
121//
122void MCalibrationIntensityCam::Clear(Option_t *o)
123{
124
125 fCams->ForEach(MCalibrationCam, Clear)();
126
127 return;
128}
129
130// -----------------------------------------------------
131//
132// Calls Print(o) for all entries fCams
133//
134void MCalibrationIntensityCam::Print(Option_t *o) const
135{
136 fCams->ForEach(MCalibrationCam, Print)(o);
137}
138
139// -----------------------------------------------------
140//
141// Not yet installed...
142//
143void MCalibrationIntensityCam::DrawHiLoFits()
144{
145
146 /*
147 if (!fOffsets)
148 fOffsets = new TH1D("pp","Offsets of the HiGain LoGain Fit",100,-600.,400.);
149 if (!fSlopes)
150 fSlopes = new TH1D("mm","Slopes of the HiGain LoGain Fit",100,-2.,2.);
151 if (!fOffvsSlope)
152 fOffvsSlope = new TH2D("aa","Slopes vs Offsets of the HiGain LoGain Fit",100,-600.,400.,100,-2.,2.);
153
154 TIter Next(fPixels);
155 MCalibrationPix *pix;
156 MHCalibrationPixel *hist;
157 while ((pix=(MCalibrationPix*)Next()))
158 {
159 hist = pix->GetHist();
160 hist->FitHiGainvsLoGain();
161 fOffsets->Fill(hist->GetOffset(),1.);
162 fSlopes->Fill(hist->GetSlope(),1.);
163 fOffvsSlope->Fill(hist->GetOffset(),hist->GetSlope(),1.);
164 }
165
166 TCanvas *c1 = new TCanvas();
167
168 c1->Divide(1,3);
169 c1->cd(1);
170 fOffsets->Draw();
171 gPad->Modified();
172 gPad->Update();
173
174 c1->cd(2);
175 fSlopes->Draw();
176 gPad->Modified();
177 gPad->Update();
178
179 c1->cd(3);
180 fOffvsSlope->Draw("col1");
181 gPad->Modified();
182 gPad->Update();
183 */
184}
185
186// -------------------------------------------------------------------
187//
188// Calls TObjArray::Expand() for fCams
189//
190void MCalibrationIntensityCam::InitSize(const UInt_t n)
191{
192 fCams->Expand(n);
193}
194
195// -------------------------------------------------------------------
196//
197// If size is still 0, Intialize a first Cam.
198// Calls Init(geom) for all fCams
199//
200void MCalibrationIntensityCam::Init(const MGeomCam &geom)
201{
202 if (GetSize() == 0)
203 InitSize(1);
204
205 fCams->ForEach(MCalibrationCam,Init)(geom);
206}
207
208
209// --------------------------------------------------------------------------
210//
211// Returns the current size of the TObjArray fCams
212// independently if the MCalibrationCam is filled with values or not.
213//
214const Int_t MCalibrationIntensityCam::GetSize() const
215{
216 return fCams->GetEntries();
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.