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 02/2004 <mailto:markus@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 | /////////////////////////////////////////////////////////////////////////////
|
---|
25 | //
|
---|
26 | // MHCalibrationCam
|
---|
27 | //
|
---|
28 | // Base class for camera calibration classes. Incorporates the TObjArray's:
|
---|
29 | // - fHiGainArray (for calibrated High Gains per pixel)
|
---|
30 | // - fLoGainArray (for calibrated Low Gains per pixel)
|
---|
31 | // - fAverageHiGainAreas (for averaged High Gains events per camera area index)
|
---|
32 | // - fAverageLoGainAreas (for averaged High Gains events per camera area index)
|
---|
33 | // - fAverageHiGainSectors (for averaged High Gains events per camera sector )
|
---|
34 | // - fAverageLoGainSectors (for averaged High Gains events per camera sector )
|
---|
35 | // These TObjArray's are called by their default constructors, thus no objects
|
---|
36 | // are created, until the derived class does so.
|
---|
37 | //
|
---|
38 | // The corresponding operators: [],() and the operators GetAverageHiGainArea(),
|
---|
39 | // GetAverageLoGainArea(), GetAverageHiGainSector() and GetAverageLoGainSector()
|
---|
40 | // have to be cast to the corresponding class. It is assumed that all classes
|
---|
41 | // dealing with calibration pixels derive from MHGausEvents.
|
---|
42 | //
|
---|
43 | /////////////////////////////////////////////////////////////////////////////
|
---|
44 | #include "MHCalibrationCam.h"
|
---|
45 |
|
---|
46 | #include <TVirtualPad.h>
|
---|
47 | #include <TCanvas.h>
|
---|
48 | #include <TPad.h>
|
---|
49 | #include <TText.h>
|
---|
50 | #include <TPaveText.h>
|
---|
51 |
|
---|
52 | #include "MLog.h"
|
---|
53 | #include "MLogManip.h"
|
---|
54 |
|
---|
55 | #include "MHGausEvents.h"
|
---|
56 |
|
---|
57 | #include "MGeomCam.h"
|
---|
58 |
|
---|
59 | ClassImp(MHCalibrationCam);
|
---|
60 |
|
---|
61 | using namespace std;
|
---|
62 |
|
---|
63 | const Int_t MHCalibrationCam::fgPulserFrequency = 500;
|
---|
64 | // --------------------------------------------------------------------------
|
---|
65 | //
|
---|
66 | // Default Constructor.
|
---|
67 | //
|
---|
68 | // Initializes and sets owner of:
|
---|
69 | // - fHiGainArray, fLoGainArray
|
---|
70 | // - fAverageHiGainAreas, fAverageLoGainAreas
|
---|
71 | // - fAverageHiGainSectors, fAverageLoGainSectors
|
---|
72 | //
|
---|
73 | // Initializes:
|
---|
74 | // - fPulserFrequency to fgPulserFrequency
|
---|
75 | //
|
---|
76 | MHCalibrationCam::MHCalibrationCam(const char *name, const char *title)
|
---|
77 | {
|
---|
78 | fName = name ? name : "MHCalibrationCam";
|
---|
79 | fTitle = title ? title : "Class to fill the calibration histograms ";
|
---|
80 |
|
---|
81 | fHiGainArray = new TObjArray;
|
---|
82 | fHiGainArray->SetOwner();
|
---|
83 |
|
---|
84 | fLoGainArray = new TObjArray;
|
---|
85 | fLoGainArray->SetOwner();
|
---|
86 |
|
---|
87 | fAverageHiGainAreas = new TObjArray;
|
---|
88 | fAverageHiGainAreas->SetOwner();
|
---|
89 |
|
---|
90 | fAverageLoGainAreas = new TObjArray;
|
---|
91 | fAverageLoGainAreas->SetOwner();
|
---|
92 |
|
---|
93 | fAverageHiGainSectors = new TObjArray;
|
---|
94 | fAverageHiGainSectors->SetOwner();
|
---|
95 |
|
---|
96 | fAverageLoGainSectors = new TObjArray;
|
---|
97 | fAverageLoGainSectors->SetOwner();
|
---|
98 |
|
---|
99 | SetPulserFrequency();
|
---|
100 | }
|
---|
101 |
|
---|
102 | // --------------------------------------------------------------------------
|
---|
103 | //
|
---|
104 | // Deletes the TClonesArray of:
|
---|
105 | // - fHiGainArray, fLoGainArray
|
---|
106 | // - fAverageHiGainAreas, fAverageLoGainAreas
|
---|
107 | // - fAverageHiGainSectors, fAverageLoGainSectors
|
---|
108 | //
|
---|
109 | MHCalibrationCam::~MHCalibrationCam()
|
---|
110 | {
|
---|
111 | delete fHiGainArray;
|
---|
112 | delete fLoGainArray;
|
---|
113 |
|
---|
114 | delete fAverageHiGainAreas;
|
---|
115 | delete fAverageLoGainAreas;
|
---|
116 |
|
---|
117 | delete fAverageHiGainSectors;
|
---|
118 | delete fAverageLoGainSectors;
|
---|
119 | }
|
---|
120 |
|
---|
121 | // --------------------------------------------------------------------------
|
---|
122 | //
|
---|
123 | // Get i-th High Gain pixel (pixel number)
|
---|
124 | //
|
---|
125 | MHGausEvents &MHCalibrationCam::operator[](UInt_t i)
|
---|
126 | {
|
---|
127 | return *static_cast<MHGausEvents*>(fHiGainArray->UncheckedAt(i));
|
---|
128 | }
|
---|
129 |
|
---|
130 | // --------------------------------------------------------------------------
|
---|
131 | //
|
---|
132 | // Get i-th High Gain pixel (pixel number)
|
---|
133 | //
|
---|
134 | const MHGausEvents &MHCalibrationCam::operator[](UInt_t i) const
|
---|
135 | {
|
---|
136 | return *static_cast<MHGausEvents*>(fHiGainArray->UncheckedAt(i));
|
---|
137 | }
|
---|
138 |
|
---|
139 | // --------------------------------------------------------------------------
|
---|
140 | //
|
---|
141 | // Get i-th Low Gain pixel (pixel number)
|
---|
142 | //
|
---|
143 | MHGausEvents &MHCalibrationCam::operator()(UInt_t i)
|
---|
144 | {
|
---|
145 | return *static_cast<MHGausEvents*>(fLoGainArray->UncheckedAt(i));
|
---|
146 | }
|
---|
147 |
|
---|
148 | // --------------------------------------------------------------------------
|
---|
149 | //
|
---|
150 | // Get i-th Low Gain pixel (pixel number)
|
---|
151 | //
|
---|
152 | const MHGausEvents &MHCalibrationCam::operator()(UInt_t i) const
|
---|
153 | {
|
---|
154 | return *static_cast<MHGausEvents*>(fLoGainArray->UncheckedAt(i));
|
---|
155 | }
|
---|
156 |
|
---|
157 | // --------------------------------------------------------------------------
|
---|
158 | //
|
---|
159 | // Get i-th High Gain pixel Area (area number)
|
---|
160 | //
|
---|
161 | MHGausEvents &MHCalibrationCam::GetAverageHiGainArea(UInt_t i)
|
---|
162 | {
|
---|
163 | return *static_cast<MHGausEvents*>(fAverageHiGainAreas->UncheckedAt(i));
|
---|
164 | }
|
---|
165 |
|
---|
166 | // --------------------------------------------------------------------------
|
---|
167 | //
|
---|
168 | // Get i-th High Gain pixel Area (area number)
|
---|
169 | //
|
---|
170 | const MHGausEvents &MHCalibrationCam::GetAverageHiGainArea(UInt_t i) const
|
---|
171 | {
|
---|
172 | return *static_cast<MHGausEvents *>(fAverageHiGainAreas->UncheckedAt(i));
|
---|
173 | }
|
---|
174 |
|
---|
175 | // --------------------------------------------------------------------------
|
---|
176 | //
|
---|
177 | // Get i-th Low Gain pixel Area (area number)
|
---|
178 | //
|
---|
179 | MHGausEvents &MHCalibrationCam::GetAverageLoGainArea(UInt_t i)
|
---|
180 | {
|
---|
181 | return *static_cast<MHGausEvents*>(fAverageLoGainAreas->UncheckedAt(i));
|
---|
182 | }
|
---|
183 |
|
---|
184 | // --------------------------------------------------------------------------
|
---|
185 | //
|
---|
186 | // Get i-th Low Gain pixel Area (area number)
|
---|
187 | //
|
---|
188 | const MHGausEvents &MHCalibrationCam::GetAverageLoGainArea(UInt_t i) const
|
---|
189 | {
|
---|
190 | return *static_cast<MHGausEvents*>(fAverageLoGainAreas->UncheckedAt(i));
|
---|
191 | }
|
---|
192 |
|
---|
193 | // --------------------------------------------------------------------------
|
---|
194 | //
|
---|
195 | // Get i-th High Gain Sector (sector number)
|
---|
196 | //
|
---|
197 | MHGausEvents &MHCalibrationCam::GetAverageHiGainSector(UInt_t i)
|
---|
198 | {
|
---|
199 | return *static_cast<MHGausEvents*>(fAverageHiGainSectors->UncheckedAt(i));
|
---|
200 | }
|
---|
201 |
|
---|
202 | // --------------------------------------------------------------------------
|
---|
203 | //
|
---|
204 | // Get i-th High Gain Sector (sector number)
|
---|
205 | //
|
---|
206 | const MHGausEvents &MHCalibrationCam::GetAverageHiGainSector(UInt_t i) const
|
---|
207 | {
|
---|
208 | return *static_cast<MHGausEvents*>(fAverageHiGainSectors->UncheckedAt(i));
|
---|
209 | }
|
---|
210 |
|
---|
211 | // --------------------------------------------------------------------------
|
---|
212 | //
|
---|
213 | // Get i-th Low Gain Sector (sector number)
|
---|
214 | //
|
---|
215 | MHGausEvents &MHCalibrationCam::GetAverageLoGainSector(UInt_t i)
|
---|
216 | {
|
---|
217 | return *static_cast<MHGausEvents*>(fAverageLoGainSectors->UncheckedAt(i));
|
---|
218 | }
|
---|
219 |
|
---|
220 | // --------------------------------------------------------------------------
|
---|
221 | //
|
---|
222 | // Get i-th Low Gain Sector (sector number)
|
---|
223 | //
|
---|
224 | const MHGausEvents &MHCalibrationCam::GetAverageLoGainSector(UInt_t i) const
|
---|
225 | {
|
---|
226 | return *static_cast<MHGausEvents*>(fAverageLoGainSectors->UncheckedAt(i));
|
---|
227 | }
|
---|
228 |
|
---|
229 |
|
---|
230 | // --------------------------------------------------------------------------
|
---|
231 | //
|
---|
232 | // Our own clone function is necessary since root 3.01/06 or Mars 0.4
|
---|
233 | // I don't know the reason.
|
---|
234 | //
|
---|
235 | // Creates new MHCalibrationCam
|
---|
236 | // Deletes the TObjArray's and Clones them individually
|
---|
237 | // Copies the TArray's
|
---|
238 | // Copies the fPulserFrequency
|
---|
239 | //
|
---|
240 | TObject *MHCalibrationCam::Clone(const char *) const
|
---|
241 | {
|
---|
242 |
|
---|
243 | const Int_t nhi = fHiGainArray->GetEntries();
|
---|
244 | const Int_t nlo = fLoGainArray->GetEntries();
|
---|
245 | const Int_t navhi = fAverageHiGainAreas->GetEntries();
|
---|
246 | const Int_t navlo = fAverageLoGainAreas->GetEntries();
|
---|
247 | const Int_t nsehi = fAverageHiGainSectors->GetEntries();
|
---|
248 | const Int_t nselo = fAverageLoGainSectors->GetEntries();
|
---|
249 |
|
---|
250 | //
|
---|
251 | // FIXME, this might be done faster and more elegant, by direct copy.
|
---|
252 | //
|
---|
253 | MHCalibrationCam *cam = new MHCalibrationCam();
|
---|
254 |
|
---|
255 | cam->fHiGainArray->Expand(nhi);
|
---|
256 | cam->fLoGainArray->Expand(nlo);
|
---|
257 | cam->fAverageHiGainAreas->Expand(navhi);
|
---|
258 | cam->fAverageLoGainAreas->Expand(navlo);
|
---|
259 | cam->fAverageHiGainSectors->Expand(nsehi);
|
---|
260 | cam->fAverageLoGainSectors->Expand(nselo);
|
---|
261 |
|
---|
262 | for (int i=0; i<nhi; i++)
|
---|
263 | {
|
---|
264 | delete (*cam->fHiGainArray)[i];
|
---|
265 | (*cam->fHiGainArray)[i] = (*fHiGainArray)[i]->Clone();
|
---|
266 | }
|
---|
267 | for (int i=0; i<nlo; i++)
|
---|
268 | {
|
---|
269 | delete (*cam->fLoGainArray)[i];
|
---|
270 | (*cam->fLoGainArray)[i] = (*fLoGainArray)[i]->Clone();
|
---|
271 | }
|
---|
272 | for (int i=0; i<navhi; i++)
|
---|
273 | {
|
---|
274 | delete (*cam->fAverageHiGainAreas)[i];
|
---|
275 | (*cam->fAverageHiGainAreas)[i] = (*fAverageHiGainAreas)[i]->Clone();
|
---|
276 | }
|
---|
277 | for (int i=0; i<navlo; i++)
|
---|
278 | {
|
---|
279 | delete (*cam->fAverageLoGainAreas)[i];
|
---|
280 | (*cam->fAverageLoGainAreas)[i] = (*fAverageLoGainAreas)[i]->Clone();
|
---|
281 | }
|
---|
282 | for (int i=0; i<nsehi; i++)
|
---|
283 | {
|
---|
284 | delete (*cam->fAverageHiGainSectors)[i];
|
---|
285 | (*cam->fAverageHiGainSectors)[i] = (*fAverageHiGainSectors)[i]->Clone();
|
---|
286 | }
|
---|
287 | for (int i=0; i<nselo; i++)
|
---|
288 | {
|
---|
289 | delete (*cam->fAverageLoGainSectors)[i];
|
---|
290 | (*cam->fAverageLoGainSectors)[i] = (*fAverageLoGainSectors)[i]->Clone();
|
---|
291 | }
|
---|
292 |
|
---|
293 | cam->fAverageAreaNum = fAverageAreaNum;
|
---|
294 | cam->fAverageAreaSat = fAverageAreaSat;
|
---|
295 | cam->fAverageAreaSigma = fAverageAreaSigma;
|
---|
296 | cam->fAverageAreaSigmaErr = fAverageAreaSigmaErr;
|
---|
297 | cam->fAverageAreaRelSigma = fAverageAreaRelSigma;
|
---|
298 | cam->fAverageAreaRelSigmaErr = fAverageAreaRelSigmaErr;
|
---|
299 | cam->fAverageSectorNum = fAverageSectorNum;
|
---|
300 |
|
---|
301 | cam->fPulserFrequency = fPulserFrequency;
|
---|
302 |
|
---|
303 | return cam;
|
---|
304 | }
|
---|
305 |
|
---|
306 | // --------------------------------------------------------------------------
|
---|
307 | //
|
---|
308 | // Dummy, needed by MCamEvent
|
---|
309 | //
|
---|
310 | Bool_t MHCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
311 | {
|
---|
312 | return kTRUE;
|
---|
313 | }
|
---|
314 |
|
---|
315 | // --------------------------------------------------------------------------
|
---|
316 | //
|
---|
317 | // What MHCamera needs in order to draw an individual pixel in the camera
|
---|
318 | //
|
---|
319 | void MHCalibrationCam::DrawPixelContent(Int_t idx) const
|
---|
320 | {
|
---|
321 | }
|
---|
322 |
|
---|
323 | // -----------------------------------------------------------------------------
|
---|
324 | //
|
---|
325 | // Default draw:
|
---|
326 | //
|
---|
327 | // Displays the averaged areas, both High Gain and Low Gain
|
---|
328 | //
|
---|
329 | // Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
|
---|
330 | //
|
---|
331 | void MHCalibrationCam::Draw(const Option_t *opt)
|
---|
332 | {
|
---|
333 |
|
---|
334 | const Int_t nareas = fAverageHiGainAreas->GetEntries();
|
---|
335 | if (nareas == 0)
|
---|
336 | return;
|
---|
337 |
|
---|
338 | TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
|
---|
339 | pad->SetBorderMode(0);
|
---|
340 |
|
---|
341 | pad->Divide(2,nareas);
|
---|
342 |
|
---|
343 | for (Int_t i=0; i<nareas;i++)
|
---|
344 | {
|
---|
345 | pad->cd(2*(i+1)-1);
|
---|
346 | GetAverageHiGainArea(i).Draw(opt);
|
---|
347 |
|
---|
348 | if (!fAverageAreaSat[i])
|
---|
349 | DrawAverageSigma(fAverageAreaSat[i], i,
|
---|
350 | fAverageAreaSigma[i], fAverageAreaSigmaErr[i],
|
---|
351 | fAverageAreaRelSigma[i], fAverageAreaRelSigmaErr[i]);
|
---|
352 |
|
---|
353 | pad->cd(2*(i+1));
|
---|
354 | GetAverageLoGainArea(i).Draw(opt);
|
---|
355 |
|
---|
356 | if (fAverageAreaSat[i])
|
---|
357 | DrawAverageSigma(fAverageAreaSat[i], i,
|
---|
358 | fAverageAreaSigma[i], fAverageAreaSigmaErr[i],
|
---|
359 | fAverageAreaRelSigma[i], fAverageAreaRelSigmaErr[i]);
|
---|
360 | }
|
---|
361 | }
|
---|
362 |
|
---|
363 | // -----------------------------------------------------------------------------
|
---|
364 | //
|
---|
365 | // Default draw:
|
---|
366 | //
|
---|
367 | // Displays a TPaveText with the re-normalized sigmas of the average area
|
---|
368 | //
|
---|
369 | void MHCalibrationCam::DrawAverageSigma(Bool_t sat, Bool_t inner,
|
---|
370 | Float_t sigma, Float_t sigmaerr,
|
---|
371 | Float_t relsigma, Float_t relsigmaerr) const
|
---|
372 | {
|
---|
373 |
|
---|
374 | if (sigma != 0)
|
---|
375 | {
|
---|
376 |
|
---|
377 | TPad *newpad = new TPad("newpad","transparent",0,0,1,1);
|
---|
378 | newpad->SetFillStyle(4000);
|
---|
379 | newpad->Draw();
|
---|
380 | newpad->cd();
|
---|
381 |
|
---|
382 | TPaveText *text = new TPaveText(sat? 0.1 : 0.35,0.7,sat ? 0.4 : 0.7,1.0);
|
---|
383 | text->SetTextSize(0.07);
|
---|
384 | const TString line1 = Form("%s%s%s",inner ? "Outer" : "Inner",
|
---|
385 | " Pixels ", sat ? "Low Gain" : "High Gain");
|
---|
386 | TText *txt1 = text->AddText(line1.Data());
|
---|
387 | const TString line2 = Form("#sigma per pix: %2.2f #pm %2.2f",sigma,sigmaerr);
|
---|
388 | TText *txt2 = text->AddText(line2.Data());
|
---|
389 | const TString line3 = Form("Rel. #sigma per pix: %2.2f #pm %2.2f",relsigma,relsigmaerr);
|
---|
390 | TText *txt3 = text->AddText(line3.Data());
|
---|
391 | text->Draw("");
|
---|
392 |
|
---|
393 | text->SetBit(kCanDelete);
|
---|
394 | txt1->SetBit(kCanDelete);
|
---|
395 | txt2->SetBit(kCanDelete);
|
---|
396 | txt3->SetBit(kCanDelete);
|
---|
397 | newpad->SetBit(kCanDelete);
|
---|
398 | }
|
---|
399 | }
|
---|
400 |
|
---|