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

Last change on this file since 6905 was 5651, checked in by gaug, 20 years ago
*** empty log message ***
File size: 11.3 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. 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 <TOrdCollection.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 TOrdCollection;
67 fCams->SetOwner();
68
69}
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// Initialize the objects inside the TOrdCollection using the
191// virtual function Add().
192//
193// InitSize can only increase the size, but not shrink.
194//
195// It can be called more than one time. New Containers are
196// added only from the current size to the argument i.
197//
198void MCalibrationIntensityCam::InitSize(const UInt_t i)
199{
200
201 const UInt_t save = GetSize();
202
203 if (i==save)
204 return;
205
206 if (i>save)
207 Add(save,i);
208}
209
210// -------------------------------------------------------------------
211//
212// Add MCalibrationCams in the ranges from - to. In order to initialize
213// from MCalibrationCam derived containers, overwrite this function
214//
215void MCalibrationIntensityCam::Add(const UInt_t from, const UInt_t to)
216{
217 for (UInt_t i=from; i<to; i++)
218 fCams->AddAt(new MCalibrationCam,i);
219}
220
221// -------------------------------------------------------------------
222//
223// If size is still 0, Intialize a first Cam.
224// Calls Init(geom) for all fCams
225//
226void MCalibrationIntensityCam::Init(const MGeomCam &geom)
227{
228 if (GetSize() == 0)
229 InitSize(1);
230
231 fCams->ForEach(MCalibrationCam,Init)(geom);
232}
233
234
235// --------------------------------------------------------------------------
236//
237// Returns the current size of the TOrdCollection fCams
238// independently if the MCalibrationCam is filled with values or not.
239//
240const Int_t MCalibrationIntensityCam::GetSize() const
241{
242 return fCams->GetSize();
243}
244
245// --------------------------------------------------------------------------
246//
247// Get i-th pixel from current camera
248//
249MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i)
250{
251 return (*GetCam())[i];
252}
253
254// --------------------------------------------------------------------------
255//
256// Get i-th pixel from current camera
257//
258const MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i) const
259{
260 return (*GetCam())[i];
261}
262
263
264// --------------------------------------------------------------------------
265//
266// Returns the current size of the TOrdCollection fAverageAreas of the current camera.
267//
268const Int_t MCalibrationIntensityCam::GetAverageAreas() const
269{
270 return GetCam()->GetAverageAreas();
271}
272
273// --------------------------------------------------------------------------
274//
275// Get i-th High Gain pixel Area from the current camera
276//
277MCalibrationPix &MCalibrationIntensityCam::GetAverageArea(UInt_t i)
278{
279 return GetCam()->GetAverageArea(i);
280}
281
282// --------------------------------------------------------------------------
283//
284// Get i-th High Gain pixel Area from the current camera
285//
286const MCalibrationPix &MCalibrationIntensityCam::GetAverageArea(UInt_t i) const
287{
288 return GetCam()->GetAverageArea(i);
289}
290
291// --------------------------------------------------------------------------
292//
293// Get i-th High Gain pixel Area from the current camera
294//
295MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i)
296{
297 return GetCam()->GetAverageBadArea(i);
298}
299
300// --------------------------------------------------------------------------
301//
302// Get i-th High Gain pixel Area from the current camera
303//
304const MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i) const
305{
306 return GetCam()->GetAverageBadArea(i);
307}
308
309// --------------------------------------------------------------------------
310//
311// Returns the current size of the TOrdCollection fAverageSectors or the current camera
312//
313const Int_t MCalibrationIntensityCam::GetAverageSectors() const
314{
315 return GetCam()->GetAverageSectors();
316}
317
318// --------------------------------------------------------------------------
319//
320// Get i-th High Gain Sector from the current camera
321//
322MCalibrationPix &MCalibrationIntensityCam::GetAverageSector(UInt_t i)
323{
324 return GetCam()->GetAverageSector(i);
325}
326
327// --------------------------------------------------------------------------
328//
329// Get i-th High Gain Sector from the current camera
330//
331const MCalibrationPix &MCalibrationIntensityCam::GetAverageSector(UInt_t i) const
332{
333 return GetCam()->GetAverageSector(i);
334}
335
336// --------------------------------------------------------------------------
337//
338// Get i-th High Gain Sector from the current camera
339//
340MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i)
341{
342 return GetCam()->GetAverageBadSector(i);
343}
344
345// --------------------------------------------------------------------------
346//
347// Get i-th High Gain Sector from the current camera
348//
349const MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i) const
350{
351 return GetCam()->GetAverageBadSector(i);
352}
353
354
355// --------------------------------------------------------------------------
356//
357// Get i-th camera
358//
359MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i)
360{
361 return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i));
362}
363
364// --------------------------------------------------------------------------
365//
366// Get i-th camera
367//
368const MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i) const
369{
370 return static_cast<MCalibrationCam*>(i==-1 ? fCams->Last() : fCams->At(i));
371}
372
373// --------------------------------------------------------------------------
374//
375// Get camera with name 'name'
376//
377MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name )
378{
379 return static_cast<MCalibrationCam*>(fCams->FindObject(name));
380}
381
382// --------------------------------------------------------------------------
383//
384// Get camera with name 'name'
385//
386const MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name ) const
387{
388 return static_cast<MCalibrationCam*>(fCams->FindObject(name));
389}
390
391// --------------------------------------------------------------------------
392//
393// Calls GetPixelContent for the current entry in fCams
394//
395Bool_t MCalibrationIntensityCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
396{
397 return GetCam()->GetPixelContent(val,idx,cam,type);
398}
399
400// --------------------------------------------------------------------------
401//
402// Calls DrawPixelContent for the current entry in fCams
403//
404void MCalibrationIntensityCam::DrawPixelContent( Int_t num ) const
405{
406 return GetCam()->DrawPixelContent(num);
407}
408
409Int_t MCalibrationIntensityCam::CountNumEntries(const MCalibrationCam::PulserColor_t col) const
410{
411
412 Int_t size = 0;
413
414 if (col == MCalibrationCam::kNONE)
415 return GetSize();
416 else
417 for (Int_t i=0;i<GetSize();i++)
418 {
419 const MCalibrationCam *cam = GetCam(i);
420 if (cam->GetPulserColor() == col)
421 size++;
422 }
423
424 return size;
425}
Note: See TracBrowser for help on using the repository browser.