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 |
|
---|
49 | ClassImp(MCalibrationIntensityCam);
|
---|
50 |
|
---|
51 | using namespace std;
|
---|
52 |
|
---|
53 | // --------------------------------------------------------------------------
|
---|
54 | //
|
---|
55 | // Default constructor.
|
---|
56 | //
|
---|
57 | // Set the following pointer to NULL:
|
---|
58 | // - fCams
|
---|
59 | //
|
---|
60 | MCalibrationIntensityCam::MCalibrationIntensityCam(const char *name, const char *title)
|
---|
61 | : fCams(NULL)
|
---|
62 | {
|
---|
63 |
|
---|
64 | fName = name ? name : "MCalibrationIntensityCam";
|
---|
65 | fTitle = title ? title : "Base container for the Intensity Calibration";
|
---|
66 |
|
---|
67 | }
|
---|
68 |
|
---|
69 | // --------------------------------------------------------------------------
|
---|
70 | //
|
---|
71 | // Deletes the histograms if they exist
|
---|
72 | //
|
---|
73 | MCalibrationIntensityCam::~MCalibrationIntensityCam()
|
---|
74 | {
|
---|
75 | if (fCams)
|
---|
76 | delete fCams;
|
---|
77 | }
|
---|
78 |
|
---|
79 | // --------------------------------------------------------------------------
|
---|
80 | //
|
---|
81 | // Add a new MCalibrationCam to fCams, give it the name "name" and initialize
|
---|
82 | // it with geom.
|
---|
83 | //
|
---|
84 | void MCalibrationIntensityCam::AddToList( const char* name, const MGeomCam &geom)
|
---|
85 | {
|
---|
86 |
|
---|
87 | fCams->ExpandCreate(GetSize()+1);
|
---|
88 |
|
---|
89 | GetCam()->SetName(name);
|
---|
90 | GetCam()->Init(geom);
|
---|
91 | }
|
---|
92 |
|
---|
93 |
|
---|
94 |
|
---|
95 | // --------------------------------------------------------------------------
|
---|
96 | //
|
---|
97 | // Copy 'constructor'
|
---|
98 | //
|
---|
99 | void MCalibrationIntensityCam::Copy(TObject& object) const
|
---|
100 | {
|
---|
101 |
|
---|
102 | MCalibrationIntensityCam &calib = (MCalibrationIntensityCam&)object;
|
---|
103 |
|
---|
104 | MParContainer::Copy(calib);
|
---|
105 |
|
---|
106 | calib.fOffsets = fOffsets;
|
---|
107 | calib.fSlopes = fSlopes;
|
---|
108 |
|
---|
109 | const UInt_t n = GetSize();
|
---|
110 | if (n != 0)
|
---|
111 | {
|
---|
112 | calib.InitSize(n);
|
---|
113 | for (UInt_t i=0; i<n; i++)
|
---|
114 | GetCam(i)->Copy(*(calib.GetCam(i)));
|
---|
115 | }
|
---|
116 |
|
---|
117 | }
|
---|
118 |
|
---|
119 | // -----------------------------------------------------
|
---|
120 | //
|
---|
121 | // Calls Clear() for all entries fCams
|
---|
122 | //
|
---|
123 | void MCalibrationIntensityCam::Clear(Option_t *o)
|
---|
124 | {
|
---|
125 |
|
---|
126 | fCams->ForEach(MCalibrationCam, Clear)();
|
---|
127 |
|
---|
128 | return;
|
---|
129 | }
|
---|
130 |
|
---|
131 | // -----------------------------------------------------
|
---|
132 | //
|
---|
133 | // Calls Print(o) for all entries fCams
|
---|
134 | //
|
---|
135 | void MCalibrationIntensityCam::Print(Option_t *o) const
|
---|
136 | {
|
---|
137 | fCams->ForEach(MCalibrationCam, Print)(o);
|
---|
138 | }
|
---|
139 |
|
---|
140 | // -----------------------------------------------------
|
---|
141 | //
|
---|
142 | // Not yet installed...
|
---|
143 | //
|
---|
144 | void MCalibrationIntensityCam::DrawHiLoFits()
|
---|
145 | {
|
---|
146 |
|
---|
147 | /*
|
---|
148 | if (!fOffsets)
|
---|
149 | fOffsets = new TH1D("pp","Offsets of the HiGain LoGain Fit",100,-600.,400.);
|
---|
150 | if (!fSlopes)
|
---|
151 | fSlopes = new TH1D("mm","Slopes of the HiGain LoGain Fit",100,-2.,2.);
|
---|
152 | if (!fOffvsSlope)
|
---|
153 | fOffvsSlope = new TH2D("aa","Slopes vs Offsets of the HiGain LoGain Fit",100,-600.,400.,100,-2.,2.);
|
---|
154 |
|
---|
155 | TIter Next(fPixels);
|
---|
156 | MCalibrationPix *pix;
|
---|
157 | MHCalibrationPixel *hist;
|
---|
158 | while ((pix=(MCalibrationPix*)Next()))
|
---|
159 | {
|
---|
160 | hist = pix->GetHist();
|
---|
161 | hist->FitHiGainvsLoGain();
|
---|
162 | fOffsets->Fill(hist->GetOffset(),1.);
|
---|
163 | fSlopes->Fill(hist->GetSlope(),1.);
|
---|
164 | fOffvsSlope->Fill(hist->GetOffset(),hist->GetSlope(),1.);
|
---|
165 | }
|
---|
166 |
|
---|
167 | TCanvas *c1 = new TCanvas();
|
---|
168 |
|
---|
169 | c1->Divide(1,3);
|
---|
170 | c1->cd(1);
|
---|
171 | fOffsets->Draw();
|
---|
172 | gPad->Modified();
|
---|
173 | gPad->Update();
|
---|
174 |
|
---|
175 | c1->cd(2);
|
---|
176 | fSlopes->Draw();
|
---|
177 | gPad->Modified();
|
---|
178 | gPad->Update();
|
---|
179 |
|
---|
180 | c1->cd(3);
|
---|
181 | fOffvsSlope->Draw("col1");
|
---|
182 | gPad->Modified();
|
---|
183 | gPad->Update();
|
---|
184 | */
|
---|
185 | }
|
---|
186 |
|
---|
187 | // -------------------------------------------------------------------
|
---|
188 | //
|
---|
189 | // Calls TClonesArray::ExpandCreate() for fCams
|
---|
190 | //
|
---|
191 | void MCalibrationIntensityCam::InitSize(const UInt_t n)
|
---|
192 | {
|
---|
193 | fCams->ExpandCreate(n);
|
---|
194 | }
|
---|
195 |
|
---|
196 | // -------------------------------------------------------------------
|
---|
197 | //
|
---|
198 | // If size is still 0, Intialize a first Cam.
|
---|
199 | // Calls Init(geom) for all fCams
|
---|
200 | //
|
---|
201 | void MCalibrationIntensityCam::Init(const MGeomCam &geom)
|
---|
202 | {
|
---|
203 | if (GetSize() == 0)
|
---|
204 | InitSize(1);
|
---|
205 | fCams->ForEach(MCalibrationCam,Init)(geom);
|
---|
206 | }
|
---|
207 |
|
---|
208 |
|
---|
209 | // --------------------------------------------------------------------------
|
---|
210 | //
|
---|
211 | // Returns the current size of the TClonesArray fCams
|
---|
212 | // independently if the MCalibrationCam is filled with values or not.
|
---|
213 | //
|
---|
214 | const Int_t MCalibrationIntensityCam::GetSize() const
|
---|
215 | {
|
---|
216 | return fCams->GetEntriesFast();
|
---|
217 | }
|
---|
218 |
|
---|
219 | // --------------------------------------------------------------------------
|
---|
220 | //
|
---|
221 | // Get i-th pixel from current camera
|
---|
222 | //
|
---|
223 | MCalibrationPix &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 | //
|
---|
232 | const 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 | //
|
---|
242 | const 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 | //
|
---|
251 | MCalibrationPix &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 | //
|
---|
260 | const 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 | //
|
---|
269 | MBadPixelsPix &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 | //
|
---|
278 | const 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 | //
|
---|
287 | const 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 | //
|
---|
296 | MCalibrationPix &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 | //
|
---|
305 | const 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 | //
|
---|
314 | MBadPixelsPix &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 | //
|
---|
323 | const 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 | //
|
---|
333 | MCalibrationCam *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 | //
|
---|
342 | const 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 | //
|
---|
351 | MCalibrationCam *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 | //
|
---|
360 | const 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 | //
|
---|
369 | Bool_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 | //
|
---|
378 | void MCalibrationIntensityCam::DrawPixelContent( Int_t num ) const
|
---|
379 | {
|
---|
380 | return GetCam()->DrawPixelContent(num);
|
---|
381 | }
|
---|
382 |
|
---|