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 "MCalibrationPix.h"
|
---|
56 | #include "MCalibrationCam.h"
|
---|
57 |
|
---|
58 | #include "MHGausEvents.h"
|
---|
59 |
|
---|
60 | #include "MBadPixelsPix.h"
|
---|
61 | #include "MBadPixelsCam.h"
|
---|
62 |
|
---|
63 | #include "MGeomCam.h"
|
---|
64 | #include "MGeomPix.h"
|
---|
65 |
|
---|
66 | #include "MParList.h"
|
---|
67 |
|
---|
68 | ClassImp(MHCalibrationCam);
|
---|
69 |
|
---|
70 | using namespace std;
|
---|
71 |
|
---|
72 | const Int_t MHCalibrationCam::fgAverageNbins = 2000;
|
---|
73 | const Int_t MHCalibrationCam::fgPulserFrequency = 500;
|
---|
74 | // --------------------------------------------------------------------------
|
---|
75 | //
|
---|
76 | // Default Constructor.
|
---|
77 | //
|
---|
78 | // Sets:
|
---|
79 | // - all pointers to NULL
|
---|
80 | //
|
---|
81 | // Initializes and sets owner of:
|
---|
82 | // - fHiGainArray, fLoGainArray
|
---|
83 | // - fAverageHiGainAreas, fAverageLoGainAreas
|
---|
84 | // - fAverageHiGainSectors, fAverageLoGainSectors
|
---|
85 | //
|
---|
86 | // Initializes:
|
---|
87 | // - fPulserFrequency to fgPulserFrequency
|
---|
88 | //
|
---|
89 | MHCalibrationCam::MHCalibrationCam(const char *name, const char *title)
|
---|
90 | : fGeom(NULL), fBadPixels(NULL), fCam(NULL)
|
---|
91 | {
|
---|
92 | fName = name ? name : "MHCalibrationCam";
|
---|
93 | fTitle = title ? title : "Class to fill the calibration histograms ";
|
---|
94 |
|
---|
95 | fHiGainArray = new TObjArray;
|
---|
96 | fHiGainArray->SetOwner();
|
---|
97 |
|
---|
98 | fLoGainArray = new TObjArray;
|
---|
99 | fLoGainArray->SetOwner();
|
---|
100 |
|
---|
101 | fAverageHiGainAreas = new TObjArray;
|
---|
102 | fAverageHiGainAreas->SetOwner();
|
---|
103 |
|
---|
104 | fAverageLoGainAreas = new TObjArray;
|
---|
105 | fAverageLoGainAreas->SetOwner();
|
---|
106 |
|
---|
107 | fAverageHiGainSectors = new TObjArray;
|
---|
108 | fAverageHiGainSectors->SetOwner();
|
---|
109 |
|
---|
110 | fAverageLoGainSectors = new TObjArray;
|
---|
111 | fAverageLoGainSectors->SetOwner();
|
---|
112 |
|
---|
113 | SetAverageNbins();
|
---|
114 | SetPulserFrequency();
|
---|
115 | }
|
---|
116 |
|
---|
117 | // --------------------------------------------------------------------------
|
---|
118 | //
|
---|
119 | // Deletes the TClonesArray of:
|
---|
120 | // - fHiGainArray, fLoGainArray
|
---|
121 | // - fAverageHiGainAreas, fAverageLoGainAreas
|
---|
122 | // - fAverageHiGainSectors, fAverageLoGainSectors
|
---|
123 | //
|
---|
124 | MHCalibrationCam::~MHCalibrationCam()
|
---|
125 | {
|
---|
126 | delete fHiGainArray;
|
---|
127 | delete fLoGainArray;
|
---|
128 |
|
---|
129 | delete fAverageHiGainAreas;
|
---|
130 | delete fAverageLoGainAreas;
|
---|
131 |
|
---|
132 | delete fAverageHiGainSectors;
|
---|
133 | delete fAverageLoGainSectors;
|
---|
134 | }
|
---|
135 |
|
---|
136 | // --------------------------------------------------------------------------
|
---|
137 | //
|
---|
138 | // Get i-th High Gain pixel (pixel number)
|
---|
139 | //
|
---|
140 | MHGausEvents &MHCalibrationCam::operator[](UInt_t i)
|
---|
141 | {
|
---|
142 | return *static_cast<MHGausEvents*>(fHiGainArray->UncheckedAt(i));
|
---|
143 | }
|
---|
144 |
|
---|
145 | // --------------------------------------------------------------------------
|
---|
146 | //
|
---|
147 | // Get i-th High Gain pixel (pixel number)
|
---|
148 | //
|
---|
149 | const MHGausEvents &MHCalibrationCam::operator[](UInt_t i) const
|
---|
150 | {
|
---|
151 | return *static_cast<MHGausEvents*>(fHiGainArray->UncheckedAt(i));
|
---|
152 | }
|
---|
153 |
|
---|
154 | // --------------------------------------------------------------------------
|
---|
155 | //
|
---|
156 | // Get i-th Low Gain pixel (pixel number)
|
---|
157 | //
|
---|
158 | MHGausEvents &MHCalibrationCam::operator()(UInt_t i)
|
---|
159 | {
|
---|
160 | return *static_cast<MHGausEvents*>(fLoGainArray->UncheckedAt(i));
|
---|
161 | }
|
---|
162 |
|
---|
163 | // --------------------------------------------------------------------------
|
---|
164 | //
|
---|
165 | // Get i-th Low Gain pixel (pixel number)
|
---|
166 | //
|
---|
167 | const MHGausEvents &MHCalibrationCam::operator()(UInt_t i) const
|
---|
168 | {
|
---|
169 | return *static_cast<MHGausEvents*>(fLoGainArray->UncheckedAt(i));
|
---|
170 | }
|
---|
171 |
|
---|
172 | // --------------------------------------------------------------------------
|
---|
173 | //
|
---|
174 | // Get i-th High Gain pixel Area (area number)
|
---|
175 | //
|
---|
176 | MHGausEvents &MHCalibrationCam::GetAverageHiGainArea(UInt_t i)
|
---|
177 | {
|
---|
178 | return *static_cast<MHGausEvents*>(fAverageHiGainAreas->UncheckedAt(i));
|
---|
179 | }
|
---|
180 |
|
---|
181 | // --------------------------------------------------------------------------
|
---|
182 | //
|
---|
183 | // Get i-th High Gain pixel Area (area number)
|
---|
184 | //
|
---|
185 | const MHGausEvents &MHCalibrationCam::GetAverageHiGainArea(UInt_t i) const
|
---|
186 | {
|
---|
187 | return *static_cast<MHGausEvents *>(fAverageHiGainAreas->UncheckedAt(i));
|
---|
188 | }
|
---|
189 |
|
---|
190 | // --------------------------------------------------------------------------
|
---|
191 | //
|
---|
192 | // Get i-th Low Gain pixel Area (area number)
|
---|
193 | //
|
---|
194 | MHGausEvents &MHCalibrationCam::GetAverageLoGainArea(UInt_t i)
|
---|
195 | {
|
---|
196 | return *static_cast<MHGausEvents*>(fAverageLoGainAreas->UncheckedAt(i));
|
---|
197 | }
|
---|
198 |
|
---|
199 | // --------------------------------------------------------------------------
|
---|
200 | //
|
---|
201 | // Get i-th Low Gain pixel Area (area number)
|
---|
202 | //
|
---|
203 | const MHGausEvents &MHCalibrationCam::GetAverageLoGainArea(UInt_t i) const
|
---|
204 | {
|
---|
205 | return *static_cast<MHGausEvents*>(fAverageLoGainAreas->UncheckedAt(i));
|
---|
206 | }
|
---|
207 |
|
---|
208 | // --------------------------------------------------------------------------
|
---|
209 | //
|
---|
210 | // Get i-th High Gain Sector (sector number)
|
---|
211 | //
|
---|
212 | MHGausEvents &MHCalibrationCam::GetAverageHiGainSector(UInt_t i)
|
---|
213 | {
|
---|
214 | return *static_cast<MHGausEvents*>(fAverageHiGainSectors->UncheckedAt(i));
|
---|
215 | }
|
---|
216 |
|
---|
217 | // --------------------------------------------------------------------------
|
---|
218 | //
|
---|
219 | // Get i-th High Gain Sector (sector number)
|
---|
220 | //
|
---|
221 | const MHGausEvents &MHCalibrationCam::GetAverageHiGainSector(UInt_t i) const
|
---|
222 | {
|
---|
223 | return *static_cast<MHGausEvents*>(fAverageHiGainSectors->UncheckedAt(i));
|
---|
224 | }
|
---|
225 |
|
---|
226 | // --------------------------------------------------------------------------
|
---|
227 | //
|
---|
228 | // Get i-th Low Gain Sector (sector number)
|
---|
229 | //
|
---|
230 | MHGausEvents &MHCalibrationCam::GetAverageLoGainSector(UInt_t i)
|
---|
231 | {
|
---|
232 | return *static_cast<MHGausEvents*>(fAverageLoGainSectors->UncheckedAt(i));
|
---|
233 | }
|
---|
234 |
|
---|
235 | // --------------------------------------------------------------------------
|
---|
236 | //
|
---|
237 | // Get i-th Low Gain Sector (sector number)
|
---|
238 | //
|
---|
239 | const MHGausEvents &MHCalibrationCam::GetAverageLoGainSector(UInt_t i) const
|
---|
240 | {
|
---|
241 | return *static_cast<MHGausEvents*>(fAverageLoGainSectors->UncheckedAt(i));
|
---|
242 | }
|
---|
243 |
|
---|
244 |
|
---|
245 | // --------------------------------------------------------------------------
|
---|
246 | //
|
---|
247 | // Our own clone function is necessary since root 3.01/06 or Mars 0.4
|
---|
248 | // I don't know the reason.
|
---|
249 | //
|
---|
250 | // Creates new MHCalibrationCam
|
---|
251 | // Deletes the TObjArray's and Clones them individually
|
---|
252 | // Copies the TArray's
|
---|
253 | // Copies the fPulserFrequency
|
---|
254 | //
|
---|
255 | TObject *MHCalibrationCam::Clone(const char *) const
|
---|
256 | {
|
---|
257 |
|
---|
258 | const Int_t nhi = fHiGainArray->GetEntries();
|
---|
259 | const Int_t nlo = fLoGainArray->GetEntries();
|
---|
260 | const Int_t navhi = fAverageHiGainAreas->GetEntries();
|
---|
261 | const Int_t navlo = fAverageLoGainAreas->GetEntries();
|
---|
262 | const Int_t nsehi = fAverageHiGainSectors->GetEntries();
|
---|
263 | const Int_t nselo = fAverageLoGainSectors->GetEntries();
|
---|
264 |
|
---|
265 | //
|
---|
266 | // FIXME, this might be done faster and more elegant, by direct copy.
|
---|
267 | //
|
---|
268 | MHCalibrationCam *cam = new MHCalibrationCam();
|
---|
269 |
|
---|
270 | cam->fHiGainArray->Expand(nhi);
|
---|
271 | cam->fLoGainArray->Expand(nlo);
|
---|
272 | cam->fAverageHiGainAreas->Expand(navhi);
|
---|
273 | cam->fAverageLoGainAreas->Expand(navlo);
|
---|
274 | cam->fAverageHiGainSectors->Expand(nsehi);
|
---|
275 | cam->fAverageLoGainSectors->Expand(nselo);
|
---|
276 |
|
---|
277 | for (int i=0; i<nhi; i++)
|
---|
278 | {
|
---|
279 | delete (*cam->fHiGainArray)[i];
|
---|
280 | (*cam->fHiGainArray)[i] = (*fHiGainArray)[i]->Clone();
|
---|
281 | }
|
---|
282 | for (int i=0; i<nlo; i++)
|
---|
283 | {
|
---|
284 | delete (*cam->fLoGainArray)[i];
|
---|
285 | (*cam->fLoGainArray)[i] = (*fLoGainArray)[i]->Clone();
|
---|
286 | }
|
---|
287 | for (int i=0; i<navhi; i++)
|
---|
288 | {
|
---|
289 | delete (*cam->fAverageHiGainAreas)[i];
|
---|
290 | (*cam->fAverageHiGainAreas)[i] = (*fAverageHiGainAreas)[i]->Clone();
|
---|
291 | }
|
---|
292 | for (int i=0; i<navlo; i++)
|
---|
293 | {
|
---|
294 | delete (*cam->fAverageLoGainAreas)[i];
|
---|
295 | (*cam->fAverageLoGainAreas)[i] = (*fAverageLoGainAreas)[i]->Clone();
|
---|
296 | }
|
---|
297 | for (int i=0; i<nsehi; i++)
|
---|
298 | {
|
---|
299 | delete (*cam->fAverageHiGainSectors)[i];
|
---|
300 | (*cam->fAverageHiGainSectors)[i] = (*fAverageHiGainSectors)[i]->Clone();
|
---|
301 | }
|
---|
302 | for (int i=0; i<nselo; i++)
|
---|
303 | {
|
---|
304 | delete (*cam->fAverageLoGainSectors)[i];
|
---|
305 | (*cam->fAverageLoGainSectors)[i] = (*fAverageLoGainSectors)[i]->Clone();
|
---|
306 | }
|
---|
307 |
|
---|
308 | cam->fAverageAreaNum = fAverageAreaNum;
|
---|
309 | cam->fAverageAreaSat = fAverageAreaSat;
|
---|
310 | cam->fAverageAreaSigma = fAverageAreaSigma;
|
---|
311 | cam->fAverageAreaSigmaVar = fAverageAreaSigmaVar;
|
---|
312 | cam->fAverageAreaRelSigma = fAverageAreaRelSigma;
|
---|
313 | cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;
|
---|
314 | cam->fAverageSectorNum = fAverageSectorNum;
|
---|
315 |
|
---|
316 | cam->fPulserFrequency = fPulserFrequency;
|
---|
317 |
|
---|
318 | return cam;
|
---|
319 | }
|
---|
320 |
|
---|
321 | // --------------------------------------------------------------------------
|
---|
322 | //
|
---|
323 | // Gets the pointers to:
|
---|
324 | // - MGeomCam
|
---|
325 | //
|
---|
326 | // Calls SetupHists(const MParList *pList)
|
---|
327 | //
|
---|
328 | // Calls Delete-Function of:
|
---|
329 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
---|
330 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
---|
331 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
---|
332 | //
|
---|
333 | Bool_t MHCalibrationCam::SetupFill(const MParList *pList)
|
---|
334 | {
|
---|
335 |
|
---|
336 | fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
|
---|
337 | if (!fGeom)
|
---|
338 | {
|
---|
339 | *fLog << err << "MGeomCam not found... aborting." << endl;
|
---|
340 | return kFALSE;
|
---|
341 | }
|
---|
342 |
|
---|
343 | fHiGainArray->Delete();
|
---|
344 | fLoGainArray->Delete();
|
---|
345 |
|
---|
346 | fAverageHiGainAreas->Delete();
|
---|
347 | fAverageLoGainAreas->Delete();
|
---|
348 |
|
---|
349 | fAverageHiGainSectors->Delete();
|
---|
350 | fAverageLoGainSectors->Delete();
|
---|
351 |
|
---|
352 | return SetupHists(pList);
|
---|
353 | }
|
---|
354 |
|
---|
355 |
|
---|
356 | Bool_t MHCalibrationCam::SetupHists(const MParList *pList)
|
---|
357 | {
|
---|
358 | return kTRUE;
|
---|
359 | }
|
---|
360 |
|
---|
361 | // --------------------------------------------------------------------------
|
---|
362 | //
|
---|
363 | // Gets or creates the pointers to:
|
---|
364 | // - MBadPixelsCam
|
---|
365 | //
|
---|
366 | // Searches pointer to:
|
---|
367 | // - MArrivalTimeCam
|
---|
368 | //
|
---|
369 | // Initializes, if empty to MArrivalTimeCam::GetSize() for:
|
---|
370 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
---|
371 | //
|
---|
372 | // Initializes, if empty to MGeomCam::GetNumAreas() for:
|
---|
373 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
---|
374 | //
|
---|
375 | // Initializes, if empty to MGeomCam::GetNumSectors() for:
|
---|
376 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
---|
377 | //
|
---|
378 | // Initializes TArray's to MGeomCam::GetNumAreas and MGeomCam::GetNumSectors, respectively
|
---|
379 | // Fills with number of valid pixels (if !MBadPixelsPix::IsBad()):
|
---|
380 | // - MHCalibrationCam::fAverageAreaNum[area index]
|
---|
381 | // - MHCalibrationCam::fAverageSectorNum[area index]
|
---|
382 | //
|
---|
383 | // Calls InitializeHists() for every entry in:
|
---|
384 | // - MHCalibrationCam::fHiGainArray
|
---|
385 | // - MHCalibrationCam::fAverageHiGainAreas
|
---|
386 | // - MHCalibrationCam::fAverageHiGainSectors
|
---|
387 | //
|
---|
388 | // Sets Titles and Names for the Histograms
|
---|
389 | // - MHCalibrationCam::fAverageHiGainAreas
|
---|
390 | // - MHCalibrationCam::fAverageHiGainSectors
|
---|
391 | //
|
---|
392 | Bool_t MHCalibrationCam::ReInit(MParList *pList)
|
---|
393 | {
|
---|
394 |
|
---|
395 | fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
|
---|
396 | if (!fBadPixels)
|
---|
397 | return kFALSE;
|
---|
398 |
|
---|
399 |
|
---|
400 | const Int_t npixels = fGeom->GetNumPixels();
|
---|
401 | const Int_t nsectors = fGeom->GetNumSectors();
|
---|
402 | const Int_t nareas = fGeom->GetNumAreas();
|
---|
403 |
|
---|
404 | //
|
---|
405 | // The function TArrayF::Set() already sets all entries to 0.
|
---|
406 | //
|
---|
407 | fAverageAreaNum. Set(nareas);
|
---|
408 | fAverageAreaSat. Set(nareas);
|
---|
409 | fAverageAreaSigma. Set(nareas);
|
---|
410 | fAverageAreaSigmaVar. Set(nareas);
|
---|
411 | fAverageAreaRelSigma. Set(nareas);
|
---|
412 | fAverageAreaRelSigmaVar.Set(nareas);
|
---|
413 | fAverageSectorNum. Set(nsectors);
|
---|
414 |
|
---|
415 | for (Int_t i=0; i<npixels; i++)
|
---|
416 | {
|
---|
417 |
|
---|
418 | if ((*fBadPixels)[i].IsBad())
|
---|
419 | continue;
|
---|
420 |
|
---|
421 | fAverageAreaNum [(*fGeom)[i].GetAidx() ]++;
|
---|
422 | fAverageSectorNum[(*fGeom)[i].GetSector()]++;
|
---|
423 | }
|
---|
424 |
|
---|
425 | return ReInitHists(pList);
|
---|
426 | }
|
---|
427 |
|
---|
428 |
|
---|
429 | Bool_t MHCalibrationCam::ReInitHists(MParList *pList)
|
---|
430 | {
|
---|
431 | return kTRUE;
|
---|
432 | }
|
---|
433 |
|
---|
434 |
|
---|
435 |
|
---|
436 | //--------------------------------------------------------------------------------
|
---|
437 | //
|
---|
438 | // Retrieves from MGeomCam:
|
---|
439 | // - number of pixels
|
---|
440 | // - number of pixel areas
|
---|
441 | // - number of sectors
|
---|
442 | //
|
---|
443 | // For all TObjArray's (including the averaged ones), the following steps are performed:
|
---|
444 | //
|
---|
445 | // 1) Test size and return kFALSE if not matching
|
---|
446 | // 2)
|
---|
447 | //
|
---|
448 | Bool_t MHCalibrationCam::Fill(const MParContainer *par, const Stat_t w)
|
---|
449 | {
|
---|
450 |
|
---|
451 | const Int_t npixels = fGeom->GetNumPixels();
|
---|
452 | const Int_t nareas = fGeom->GetNumAreas();
|
---|
453 | const Int_t nsectors = fGeom->GetNumSectors();
|
---|
454 |
|
---|
455 | if (fHiGainArray->GetEntries() != npixels)
|
---|
456 | {
|
---|
457 | gLog << err << "ERROR - Size mismatch... abort." << endl;
|
---|
458 | return kFALSE;
|
---|
459 | }
|
---|
460 |
|
---|
461 | if (fLoGainArray->GetEntries() != npixels)
|
---|
462 | {
|
---|
463 | gLog << err << "ERROR - Size mismatch... abort." << endl;
|
---|
464 | return kFALSE;
|
---|
465 | }
|
---|
466 |
|
---|
467 | if (fAverageHiGainAreas->GetEntries() != nareas)
|
---|
468 | {
|
---|
469 | *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
|
---|
470 | return kFALSE;
|
---|
471 | }
|
---|
472 |
|
---|
473 | if (fAverageLoGainAreas->GetEntries() != nareas)
|
---|
474 | {
|
---|
475 | *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
|
---|
476 | return kFALSE;
|
---|
477 | }
|
---|
478 |
|
---|
479 | if (fAverageHiGainSectors->GetEntries() != nsectors)
|
---|
480 | {
|
---|
481 | *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
|
---|
482 | return kFALSE;
|
---|
483 | }
|
---|
484 |
|
---|
485 | if (fAverageLoGainSectors->GetEntries() != nsectors)
|
---|
486 | {
|
---|
487 | *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
|
---|
488 | return kFALSE;
|
---|
489 | }
|
---|
490 |
|
---|
491 | return FillHists(par, w);
|
---|
492 | }
|
---|
493 |
|
---|
494 | Bool_t MHCalibrationCam::FillHists(const MParContainer *par, const Stat_t w)
|
---|
495 | {
|
---|
496 | return kTRUE;
|
---|
497 | }
|
---|
498 |
|
---|
499 | // --------------------------------------------------------------------------
|
---|
500 | //
|
---|
501 | // 1) FinalizeHists()
|
---|
502 | // 2) FinalizeBadPixels()
|
---|
503 | // 3) CalcAverageSigma()
|
---|
504 | //
|
---|
505 | Bool_t MHCalibrationCam::Finalize()
|
---|
506 | {
|
---|
507 | if (!FinalizeHists())
|
---|
508 | return kFALSE;
|
---|
509 |
|
---|
510 | FinalizeBadPixels();
|
---|
511 | CalcAverageSigma();
|
---|
512 |
|
---|
513 | return kTRUE;
|
---|
514 | }
|
---|
515 |
|
---|
516 | Bool_t MHCalibrationCam::FinalizeHists()
|
---|
517 | {
|
---|
518 | return kTRUE;
|
---|
519 | }
|
---|
520 |
|
---|
521 | void MHCalibrationCam::FinalizeBadPixels()
|
---|
522 | {
|
---|
523 | }
|
---|
524 |
|
---|
525 |
|
---|
526 | // -------------------------------------------------------------
|
---|
527 | //
|
---|
528 | // If MBadPixelsPix::IsBad():
|
---|
529 | // - calls MHGausEvents::SetExcluded()
|
---|
530 | //
|
---|
531 | // Calls:
|
---|
532 | // - MHGausEvents::InitBins()
|
---|
533 | // - MHGausEvents::ChangeHistId(i)
|
---|
534 | // - MHGausEvents::SetEventFrequency(fPulserFrequency)
|
---|
535 | //
|
---|
536 | void MHCalibrationCam::InitHists(MHGausEvents &hist, MBadPixelsPix &bad, const Int_t i)
|
---|
537 | {
|
---|
538 |
|
---|
539 | if (bad.IsBad())
|
---|
540 | hist.SetExcluded();
|
---|
541 |
|
---|
542 | hist.InitBins();
|
---|
543 | hist.ChangeHistId(i);
|
---|
544 | hist.SetEventFrequency(fPulserFrequency);
|
---|
545 |
|
---|
546 | }
|
---|
547 |
|
---|
548 | void MHCalibrationCam::FitHiGainArrays(MCalibrationCam &calcam, MBadPixelsCam &badcam,
|
---|
549 | MBadPixelsPix::UncalibratedType_t fittyp,
|
---|
550 | MBadPixelsPix::UncalibratedType_t osctyp)
|
---|
551 | {
|
---|
552 |
|
---|
553 | for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
|
---|
554 | {
|
---|
555 |
|
---|
556 | MHGausEvents &hist = (*this)[i];
|
---|
557 |
|
---|
558 | if (hist.IsExcluded())
|
---|
559 | continue;
|
---|
560 |
|
---|
561 | MCalibrationPix &pix = calcam[i];
|
---|
562 | MBadPixelsPix &bad = badcam[i];
|
---|
563 |
|
---|
564 | FitHiGainHists(hist,pix,bad,fittyp,osctyp);
|
---|
565 |
|
---|
566 | }
|
---|
567 |
|
---|
568 | for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
|
---|
569 | {
|
---|
570 |
|
---|
571 | MHGausEvents &hist = GetAverageHiGainArea(j);
|
---|
572 | MCalibrationPix &pix = calcam.GetAverageArea(j);
|
---|
573 | MBadPixelsPix &bad = calcam.GetAverageBadArea(j);
|
---|
574 |
|
---|
575 | FitHiGainHists(hist,pix,bad,fittyp,osctyp);
|
---|
576 | }
|
---|
577 |
|
---|
578 |
|
---|
579 | for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
|
---|
580 | {
|
---|
581 |
|
---|
582 | MHGausEvents &hist = GetAverageHiGainSector(j);
|
---|
583 | MCalibrationPix &pix = calcam.GetAverageSector(j);
|
---|
584 | MBadPixelsPix &bad = calcam.GetAverageBadSector(j);
|
---|
585 |
|
---|
586 | FitHiGainHists(hist,pix,bad,fittyp,osctyp);
|
---|
587 | }
|
---|
588 |
|
---|
589 | }
|
---|
590 |
|
---|
591 | void MHCalibrationCam::FitLoGainArrays(MCalibrationCam &calcam, MBadPixelsCam &badcam,
|
---|
592 | MBadPixelsPix::UncalibratedType_t fittyp,
|
---|
593 | MBadPixelsPix::UncalibratedType_t osctyp)
|
---|
594 | {
|
---|
595 |
|
---|
596 | for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
|
---|
597 | {
|
---|
598 |
|
---|
599 | MHGausEvents &hist = (*this)(i);
|
---|
600 |
|
---|
601 | if (hist.IsExcluded())
|
---|
602 | continue;
|
---|
603 |
|
---|
604 | MCalibrationPix &pix = calcam[i];
|
---|
605 | MBadPixelsPix &bad = badcam[i];
|
---|
606 |
|
---|
607 | FitLoGainHists(hist,pix,bad,fittyp,osctyp);
|
---|
608 |
|
---|
609 | }
|
---|
610 |
|
---|
611 | for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
|
---|
612 | {
|
---|
613 |
|
---|
614 | MHGausEvents &hist = GetAverageLoGainArea(j);
|
---|
615 | MCalibrationPix &pix = calcam.GetAverageArea(j);
|
---|
616 | MBadPixelsPix &bad = calcam.GetAverageBadArea(j);
|
---|
617 |
|
---|
618 | FitLoGainHists(hist,pix,bad,fittyp,osctyp);
|
---|
619 | }
|
---|
620 |
|
---|
621 |
|
---|
622 | for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
|
---|
623 | {
|
---|
624 |
|
---|
625 | MHGausEvents &hist = GetAverageLoGainSector(j);
|
---|
626 | MCalibrationPix &pix = calcam.GetAverageSector(j);
|
---|
627 | MBadPixelsPix &bad = calcam.GetAverageBadSector(j);
|
---|
628 |
|
---|
629 | FitLoGainHists(hist,pix,bad,fittyp,osctyp);
|
---|
630 | }
|
---|
631 | }
|
---|
632 |
|
---|
633 | //------------------------------------------------------------
|
---|
634 | //
|
---|
635 | // For all averaged areas, the fitted sigma is multiplied with the square root of
|
---|
636 | // the number involved pixels
|
---|
637 | //
|
---|
638 | void MHCalibrationCam::CalcAverageSigma()
|
---|
639 | {
|
---|
640 |
|
---|
641 | for (UInt_t j=0; j<fGeom->GetNumAreas(); j++)
|
---|
642 | {
|
---|
643 |
|
---|
644 | MCalibrationPix &pix = (*fCam).GetAverageArea(j);
|
---|
645 |
|
---|
646 | const Float_t numsqr = TMath::Sqrt((Float_t)fAverageAreaNum[j]);
|
---|
647 | fAverageAreaSigma[j] = pix.GetSigma () * numsqr;
|
---|
648 | fAverageAreaSigmaVar[j] = pix.GetSigmaErr () * pix.GetSigmaErr() * numsqr;
|
---|
649 |
|
---|
650 | pix.SetSigma (fAverageAreaSigma[j]);
|
---|
651 | pix.SetSigmaVar(fAverageAreaSigmaVar[j]);
|
---|
652 |
|
---|
653 | fAverageAreaRelSigma [j] = fAverageAreaSigma[j] / pix.GetMean();
|
---|
654 | fAverageAreaRelSigmaVar[j] = fAverageAreaSigmaVar[j] / (fAverageAreaSigma[j]*fAverageAreaSigma[j]);
|
---|
655 | fAverageAreaRelSigmaVar[j] += pix.GetMeanRelVar();
|
---|
656 | fAverageAreaRelSigmaVar[j] *= fAverageAreaRelSigma[j];
|
---|
657 | }
|
---|
658 | }
|
---|
659 |
|
---|
660 | // ---------------------------------------------------------------------------
|
---|
661 | //
|
---|
662 | // Returns if the histogram is empty and sets the following flag:
|
---|
663 | // - MBadPixelsPix::SetUnsuitable(MBadPixelsPix::kUnsuitableRun)
|
---|
664 | //
|
---|
665 | // Fits the histograms with a Gaussian, in case of failure
|
---|
666 | // calls MHGausEvents::RepeatFit(), in case of repeated failure
|
---|
667 | // calls MHGausEvents::BypassFit() and sets the following flags:
|
---|
668 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t fittyp )
|
---|
669 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
670 | //
|
---|
671 | // Creates the fourier spectrum and tests MHGausEvents::IsFourierSpectrumOK().
|
---|
672 | // In case no, sets the following flags:
|
---|
673 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t osctyp )
|
---|
674 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
675 | //
|
---|
676 | // Retrieves the results and store them in MCalibrationPix
|
---|
677 | //
|
---|
678 | void MHCalibrationCam::FitHiGainHists(MHGausEvents &hist,
|
---|
679 | MCalibrationPix &pix,
|
---|
680 | MBadPixelsPix &bad,
|
---|
681 | MBadPixelsPix::UncalibratedType_t fittyp,
|
---|
682 | MBadPixelsPix::UncalibratedType_t osctyp)
|
---|
683 | {
|
---|
684 |
|
---|
685 | if (hist.IsEmpty())
|
---|
686 | return;
|
---|
687 |
|
---|
688 | //
|
---|
689 | // 2) Fit the Hi Gain histograms with a Gaussian
|
---|
690 | //
|
---|
691 | if (!hist.FitGaus())
|
---|
692 | //
|
---|
693 | // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
|
---|
694 | //
|
---|
695 | if (!hist.RepeatFit())
|
---|
696 | {
|
---|
697 | hist.BypassFit();
|
---|
698 | bad.SetUncalibrated( fittyp );
|
---|
699 | }
|
---|
700 |
|
---|
701 | hist.Renorm();
|
---|
702 |
|
---|
703 | //
|
---|
704 | // 4) Check for oscillations
|
---|
705 | //
|
---|
706 | hist.CreateFourierSpectrum();
|
---|
707 |
|
---|
708 |
|
---|
709 | if (!hist.IsFourierSpectrumOK())
|
---|
710 | bad.SetUncalibrated( osctyp );
|
---|
711 |
|
---|
712 | //
|
---|
713 | // 5) Retrieve the results and store them in this class
|
---|
714 | //
|
---|
715 | pix.SetHiGainMean ( hist.GetMean() );
|
---|
716 | pix.SetHiGainMeanVar ( hist.GetMeanErr() * hist.GetMeanErr() );
|
---|
717 | pix.SetHiGainSigma ( hist.GetSigma() );
|
---|
718 | pix.SetHiGainSigmaVar ( hist.GetSigmaErr()* hist.GetSigmaErr() );
|
---|
719 | pix.SetHiGainProb ( hist.GetProb() );
|
---|
720 | pix.SetHiGainNumBlackout( hist.GetBlackout() );
|
---|
721 | pix.SetHiGainNumPickup ( hist.GetPickup() );
|
---|
722 |
|
---|
723 | }
|
---|
724 |
|
---|
725 |
|
---|
726 | // ---------------------------------------------------------------------------
|
---|
727 | //
|
---|
728 | // Returns if the histogram is empty and sets the following flag:
|
---|
729 | // - MBadPixelsPix::SetUnsuitable(MBadPixelsPix::kUnsuitableRun)
|
---|
730 | //
|
---|
731 | // Fits the histograms with a Gaussian, in case of failure
|
---|
732 | // calls MHGausEvents::RepeatFit(), in case of repeated failure
|
---|
733 | // calls MHGausEvents::BypassFit() and sets the following flags:
|
---|
734 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t fittyp )
|
---|
735 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
736 | //
|
---|
737 | // Creates the fourier spectrum and tests MHGausEvents::IsFourierSpectrumOK().
|
---|
738 | // In case no, sets the following flags:
|
---|
739 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t osctyp )
|
---|
740 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
741 | //
|
---|
742 | // Retrieves the results and store them in MCalibrationPix
|
---|
743 | //
|
---|
744 | void MHCalibrationCam::FitLoGainHists(MHGausEvents &hist,
|
---|
745 | MCalibrationPix &pix,
|
---|
746 | MBadPixelsPix &bad,
|
---|
747 | MBadPixelsPix::UncalibratedType_t fittyp,
|
---|
748 | MBadPixelsPix::UncalibratedType_t osctyp)
|
---|
749 | {
|
---|
750 |
|
---|
751 | if (hist.IsEmpty())
|
---|
752 | return;
|
---|
753 |
|
---|
754 |
|
---|
755 | //
|
---|
756 | // 2) Fit the Hi Gain histograms with a Gaussian
|
---|
757 | //
|
---|
758 | if (!hist.FitGaus())
|
---|
759 | //
|
---|
760 | // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
|
---|
761 | //
|
---|
762 | if (!hist.RepeatFit())
|
---|
763 | {
|
---|
764 | hist.BypassFit();
|
---|
765 | bad.SetUncalibrated( fittyp );
|
---|
766 | }
|
---|
767 |
|
---|
768 | //
|
---|
769 | // 4) Check for oscillations
|
---|
770 | //
|
---|
771 | hist.CreateFourierSpectrum();
|
---|
772 |
|
---|
773 | if (!hist.IsFourierSpectrumOK())
|
---|
774 | bad.SetUncalibrated( osctyp );
|
---|
775 |
|
---|
776 | //
|
---|
777 | // 5) Retrieve the results and store them in this class
|
---|
778 | //
|
---|
779 | pix.SetLoGainMean ( hist.GetMean() );
|
---|
780 | pix.SetLoGainMeanVar ( hist.GetMeanErr() * hist.GetMeanErr() );
|
---|
781 | pix.SetLoGainSigma ( hist.GetSigma() );
|
---|
782 | pix.SetLoGainSigmaVar ( hist.GetSigmaErr() * hist.GetSigmaErr() );
|
---|
783 | pix.SetLoGainProb ( hist.GetProb() );
|
---|
784 | pix.SetLoGainNumBlackout( hist.GetBlackout() );
|
---|
785 | pix.SetLoGainNumPickup ( hist.GetPickup() );
|
---|
786 |
|
---|
787 | }
|
---|
788 |
|
---|
789 |
|
---|
790 |
|
---|
791 | // --------------------------------------------------------------------------
|
---|
792 | //
|
---|
793 | // Dummy, needed by MCamEvent
|
---|
794 | //
|
---|
795 | Bool_t MHCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
|
---|
796 | {
|
---|
797 | return kTRUE;
|
---|
798 | }
|
---|
799 |
|
---|
800 | // --------------------------------------------------------------------------
|
---|
801 | //
|
---|
802 | // What MHCamera needs in order to draw an individual pixel in the camera
|
---|
803 | //
|
---|
804 | void MHCalibrationCam::DrawPixelContent(Int_t idx) const
|
---|
805 | {
|
---|
806 | }
|
---|
807 |
|
---|
808 | // -----------------------------------------------------------------------------
|
---|
809 | //
|
---|
810 | // Default draw:
|
---|
811 | //
|
---|
812 | // Displays the averaged areas, both High Gain and Low Gain
|
---|
813 | //
|
---|
814 | // Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
|
---|
815 | //
|
---|
816 | void MHCalibrationCam::Draw(const Option_t *opt)
|
---|
817 | {
|
---|
818 |
|
---|
819 | const Int_t nareas = fAverageHiGainAreas->GetEntries();
|
---|
820 | if (nareas == 0)
|
---|
821 | return;
|
---|
822 |
|
---|
823 | TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
|
---|
824 | pad->SetBorderMode(0);
|
---|
825 |
|
---|
826 | pad->Divide(2,nareas);
|
---|
827 |
|
---|
828 | for (Int_t i=0; i<nareas;i++)
|
---|
829 | {
|
---|
830 |
|
---|
831 | pad->cd(2*(i+1)-1);
|
---|
832 | GetAverageHiGainArea(i).Draw(opt);
|
---|
833 |
|
---|
834 | if (!fAverageAreaSat[i])
|
---|
835 | DrawAverageSigma(fAverageAreaSat[i], i,
|
---|
836 | fAverageAreaSigma[i], fAverageAreaSigmaVar[i],
|
---|
837 | fAverageAreaRelSigma[i], fAverageAreaRelSigmaVar[i]);
|
---|
838 |
|
---|
839 | pad->cd(2*(i+1));
|
---|
840 | GetAverageLoGainArea(i).Draw(opt);
|
---|
841 |
|
---|
842 | if (fAverageAreaSat[i])
|
---|
843 | DrawAverageSigma(fAverageAreaSat[i], i,
|
---|
844 | fAverageAreaSigma[i], fAverageAreaSigmaVar[i],
|
---|
845 | fAverageAreaRelSigma[i], fAverageAreaRelSigmaVar[i]);
|
---|
846 | }
|
---|
847 | }
|
---|
848 |
|
---|
849 | // -----------------------------------------------------------------------------
|
---|
850 | //
|
---|
851 | // Default draw:
|
---|
852 | //
|
---|
853 | // Displays a TPaveText with the re-normalized sigmas of the average area
|
---|
854 | //
|
---|
855 | void MHCalibrationCam::DrawAverageSigma(Bool_t sat, Bool_t inner,
|
---|
856 | Float_t sigma, Float_t sigmavar,
|
---|
857 | Float_t relsigma, Float_t relsigmavar) const
|
---|
858 | {
|
---|
859 |
|
---|
860 | if (sigma != 0 && sigmavar >= 0 && relsigmavar >= 0.)
|
---|
861 | {
|
---|
862 |
|
---|
863 | TPad *newpad = new TPad("newpad","transparent",0,0,1,1);
|
---|
864 | newpad->SetFillStyle(4000);
|
---|
865 | newpad->Draw();
|
---|
866 | newpad->cd();
|
---|
867 |
|
---|
868 | TPaveText *text = new TPaveText(sat? 0.1 : 0.35,0.7,sat ? 0.4 : 0.7,1.0);
|
---|
869 | text->SetTextSize(0.07);
|
---|
870 | const TString line1 = Form("%s%s%s",inner ? "Outer" : "Inner",
|
---|
871 | " Pixels ", sat ? "Low Gain" : "High Gain");
|
---|
872 | TText *txt1 = text->AddText(line1.Data());
|
---|
873 | const TString line2 = Form("#sigma per pix: %2.2f #pm %2.2f",sigma,TMath::Sqrt(sigmavar));
|
---|
874 | TText *txt2 = text->AddText(line2.Data());
|
---|
875 | const TString line3 = Form("Rel. #sigma per pix: %2.2f #pm %2.2f",relsigma,TMath::Sqrt(relsigmavar));
|
---|
876 | TText *txt3 = text->AddText(line3.Data());
|
---|
877 | text->Draw("");
|
---|
878 |
|
---|
879 | text->SetBit(kCanDelete);
|
---|
880 | txt1->SetBit(kCanDelete);
|
---|
881 | txt2->SetBit(kCanDelete);
|
---|
882 | txt3->SetBit(kCanDelete);
|
---|
883 | newpad->SetBit(kCanDelete);
|
---|
884 | }
|
---|
885 | }
|
---|
886 |
|
---|