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