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

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