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

Last change on this file since 4921 was 4911, 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 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// Default constructor.
55//
56// Set the following pointer to NULL:
57// - fCams
58//
59MCalibrationIntensityCam::MCalibrationIntensityCam(const char *name, const char *title)
60 : fCams(NULL)
61{
62
63 fName = name ? name : "MCalibrationIntensityCam";
64 fTitle = title ? title : "Base container for the Intensity Calibration";
65
66}
67
68// --------------------------------------------------------------------------
69//
70// Deletes the histograms if they exist
71//
72MCalibrationIntensityCam::~MCalibrationIntensityCam()
73{
74 if (fCams)
75 delete fCams;
76}
77
78// --------------------------------------------------------------------------
79//
80// Add a new MCalibrationCam to fCams, give it the name "name" and initialize
81// it with geom.
82//
83void MCalibrationIntensityCam::AddToList( const char* name, const MGeomCam &geom)
84{
85
86 fCams->ExpandCreate(GetSize()+1);
87
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 TClonesArray::ExpandCreate() for fCams
189//
190void MCalibrationIntensityCam::InitSize(const UInt_t n)
191{
192 fCams->ExpandCreate(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 fCams->ForEach(MCalibrationCam,Init)(geom);
205}
206
207
208// --------------------------------------------------------------------------
209//
210// Returns the current size of the TClonesArray fCams
211// independently if the MCalibrationCam is filled with values or not.
212//
213const Int_t MCalibrationIntensityCam::GetSize() const
214{
215 return fCams->GetEntriesFast();
216}
217
218// --------------------------------------------------------------------------
219//
220// Get i-th pixel from current camera
221//
222MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i)
223{
224 return (*GetCam(GetSize()-1))[i];
225}
226
227// --------------------------------------------------------------------------
228//
229// Get i-th pixel from current camera
230//
231const MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i) const
232{
233 return (*GetCam(GetSize()-1))[i];
234}
235
236
237// --------------------------------------------------------------------------
238//
239// Returns the current size of the TObjArray fAverageAreas of the current camera.
240//
241const Int_t MCalibrationIntensityCam::GetAverageAreas() const
242{
243 return GetCam(GetSize()-1)->GetAverageAreas();
244}
245
246// --------------------------------------------------------------------------
247//
248// Get i-th High Gain pixel Area from the current camera
249//
250MCalibrationPix &MCalibrationIntensityCam::GetAverageArea(UInt_t i)
251{
252 return GetCam(GetSize()-1)->GetAverageArea(i);
253}
254
255// --------------------------------------------------------------------------
256//
257// Get i-th High Gain pixel Area from the current camera
258//
259const MCalibrationPix &MCalibrationIntensityCam::GetAverageArea(UInt_t i) const
260{
261 return GetCam(GetSize()-1)->GetAverageArea(i);
262}
263
264// --------------------------------------------------------------------------
265//
266// Get i-th High Gain pixel Area from the current camera
267//
268MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i)
269{
270 return GetCam(GetSize()-1)->GetAverageBadArea(i);
271}
272
273// --------------------------------------------------------------------------
274//
275// Get i-th High Gain pixel Area from the current camera
276//
277const MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i) const
278{
279 return GetCam(GetSize()-1)->GetAverageBadArea(i);
280}
281
282// --------------------------------------------------------------------------
283//
284// Returns the current size of the TObjArray fAverageSectors or the current camera
285//
286const Int_t MCalibrationIntensityCam::GetAverageSectors() const
287{
288 return GetCam(GetSize()-1)->GetAverageSectors();
289}
290
291// --------------------------------------------------------------------------
292//
293// Get i-th High Gain Sector from the current camera
294//
295MCalibrationPix &MCalibrationIntensityCam::GetAverageSector(UInt_t i)
296{
297 return GetCam(GetSize()-1)->GetAverageSector(i);
298}
299
300// --------------------------------------------------------------------------
301//
302// Get i-th High Gain Sector from the current camera
303//
304const MCalibrationPix &MCalibrationIntensityCam::GetAverageSector(UInt_t i) const
305{
306 return GetCam(GetSize()-1)->GetAverageSector(i);
307}
308
309// --------------------------------------------------------------------------
310//
311// Get i-th High Gain Sector from the current camera
312//
313MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i)
314{
315 return GetCam(GetSize()-1)->GetAverageBadSector(i);
316}
317
318// --------------------------------------------------------------------------
319//
320// Get i-th High Gain Sector from the current camera
321//
322const MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i) const
323{
324 return GetCam(GetSize()-1)->GetAverageBadSector(i);
325}
326
327
328// --------------------------------------------------------------------------
329//
330// Get i-th camera
331//
332MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i)
333{
334 return static_cast<MCalibrationCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
335}
336
337// --------------------------------------------------------------------------
338//
339// Get i-th camera
340//
341const MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i) const
342{
343 return static_cast<MCalibrationCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
344}
345
346// --------------------------------------------------------------------------
347//
348// Get camera with name 'name'
349//
350MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name )
351{
352 return static_cast<MCalibrationCam*>(fCams->FindObject(name));
353}
354
355// --------------------------------------------------------------------------
356//
357// Get camera with name 'name'
358//
359const MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name ) const
360{
361 return static_cast<MCalibrationCam*>(fCams->FindObject(name));
362}
363
364// --------------------------------------------------------------------------
365//
366// Calls GetPixelContent for the current entry in fCams
367//
368Bool_t MCalibrationIntensityCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
369{
370 return GetCam()->GetPixelContent(val,idx,cam,type);
371}
372
373// --------------------------------------------------------------------------
374//
375// Calls DrawPixelContent for the current entry in fCams
376//
377void MCalibrationIntensityCam::DrawPixelContent( Int_t num ) const
378{
379 return GetCam()->DrawPixelContent(num);
380}
381
Note: See TracBrowser for help on using the repository browser.