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

Last change on this file since 4910 was 4899, checked in by gaug, 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 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// Calls Init(geom) for fCams
198//
199void MCalibrationIntensityCam::Init(const MGeomCam &geom)
200{
201 InitSize(1);
202 fCams->ForEach(MCalibrationCam,Init)(geom);
203}
204
205
206// --------------------------------------------------------------------------
207//
208// Returns the current size of the TClonesArray fCams
209// independently if the MCalibrationCam is filled with values or not.
210//
211const Int_t MCalibrationIntensityCam::GetSize() const
212{
213 return fCams->GetEntriesFast();
214}
215
216// --------------------------------------------------------------------------
217//
218// Get i-th pixel from current camera
219//
220MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i)
221{
222 return (*GetCam(GetSize()-1))[i];
223}
224
225// --------------------------------------------------------------------------
226//
227// Get i-th pixel from current camera
228//
229const MCalibrationPix &MCalibrationIntensityCam::operator[](UInt_t i) const
230{
231 return (*GetCam(GetSize()-1))[i];
232}
233
234
235// --------------------------------------------------------------------------
236//
237// Returns the current size of the TObjArray fAverageAreas of the current camera.
238//
239const Int_t MCalibrationIntensityCam::GetAverageAreas() const
240{
241 return GetCam(GetSize()-1)->GetAverageAreas();
242}
243
244// --------------------------------------------------------------------------
245//
246// Get i-th High Gain pixel Area from the current camera
247//
248MCalibrationPix &MCalibrationIntensityCam::GetAverageArea(UInt_t i)
249{
250 return GetCam(GetSize()-1)->GetAverageArea(i);
251}
252
253// --------------------------------------------------------------------------
254//
255// Get i-th High Gain pixel Area from the current camera
256//
257const MCalibrationPix &MCalibrationIntensityCam::GetAverageArea(UInt_t i) const
258{
259 return GetCam(GetSize()-1)->GetAverageArea(i);
260}
261
262// --------------------------------------------------------------------------
263//
264// Get i-th High Gain pixel Area from the current camera
265//
266MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i)
267{
268 return GetCam(GetSize()-1)->GetAverageBadArea(i);
269}
270
271// --------------------------------------------------------------------------
272//
273// Get i-th High Gain pixel Area from the current camera
274//
275const MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadArea(UInt_t i) const
276{
277 return GetCam(GetSize()-1)->GetAverageBadArea(i);
278}
279
280// --------------------------------------------------------------------------
281//
282// Returns the current size of the TObjArray fAverageSectors or the current camera
283//
284const Int_t MCalibrationIntensityCam::GetAverageSectors() const
285{
286 return GetCam(GetSize()-1)->GetAverageSectors();
287}
288
289// --------------------------------------------------------------------------
290//
291// Get i-th High Gain Sector from the current camera
292//
293MCalibrationPix &MCalibrationIntensityCam::GetAverageSector(UInt_t i)
294{
295 return GetCam(GetSize()-1)->GetAverageSector(i);
296}
297
298// --------------------------------------------------------------------------
299//
300// Get i-th High Gain Sector from the current camera
301//
302const MCalibrationPix &MCalibrationIntensityCam::GetAverageSector(UInt_t i) const
303{
304 return GetCam(GetSize()-1)->GetAverageSector(i);
305}
306
307// --------------------------------------------------------------------------
308//
309// Get i-th High Gain Sector from the current camera
310//
311MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i)
312{
313 return GetCam(GetSize()-1)->GetAverageBadSector(i);
314}
315
316// --------------------------------------------------------------------------
317//
318// Get i-th High Gain Sector from the current camera
319//
320const MBadPixelsPix &MCalibrationIntensityCam::GetAverageBadSector(UInt_t i) const
321{
322 return GetCam(GetSize()-1)->GetAverageBadSector(i);
323}
324
325
326// --------------------------------------------------------------------------
327//
328// Get i-th camera
329//
330MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i)
331{
332 return static_cast<MCalibrationCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
333}
334
335// --------------------------------------------------------------------------
336//
337// Get i-th camera
338//
339const MCalibrationCam *MCalibrationIntensityCam::GetCam(Int_t i) const
340{
341 return static_cast<MCalibrationCam*>(fCams->UncheckedAt(i==-1 ? GetSize()-1 : i));
342}
343
344// --------------------------------------------------------------------------
345//
346// Get camera with name 'name'
347//
348MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name )
349{
350 return static_cast<MCalibrationCam*>(fCams->FindObject(name));
351}
352
353// --------------------------------------------------------------------------
354//
355// Get camera with name 'name'
356//
357const MCalibrationCam *MCalibrationIntensityCam::GetCam(const char *name ) const
358{
359 return static_cast<MCalibrationCam*>(fCams->FindObject(name));
360}
361
362// --------------------------------------------------------------------------
363//
364// Calls GetPixelContent for the current entry in fCams
365//
366Bool_t MCalibrationIntensityCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
367{
368 return GetCam()->GetPixelContent(val,idx,cam,type);
369}
370
371// --------------------------------------------------------------------------
372//
373// Calls DrawPixelContent for the current entry in fCams
374//
375void MCalibrationIntensityCam::DrawPixelContent( Int_t num ) const
376{
377 return GetCam()->DrawPixelContent(num);
378}
379
Note: See TracBrowser for help on using the repository browser.