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 MHCalibrationPix.
|
---|
42 | //
|
---|
43 | // The following flag can be set:
|
---|
44 | // - SetAverageing() for calculating the event-by-event averages.
|
---|
45 | // - SetDebug() for debug output.
|
---|
46 | // - SetLoGain() for the case that low-gain slices are available, but
|
---|
47 | // MRawRunHeader::GetNumLoGainSlices() gives still 0.
|
---|
48 | // - SetCheckSize() for testing the sizes of the f*Arrays in ReInit() if they
|
---|
49 | // are coinciding with the equiv. sizes in MGeomCam
|
---|
50 | //
|
---|
51 | // The flag kLoGain steers if the low-gain signal is treated at all or not.
|
---|
52 | // The flag kAverageing steers if the event-by-event averages are treated at all.
|
---|
53 | //
|
---|
54 | /////////////////////////////////////////////////////////////////////////////
|
---|
55 | #include "MHCalibrationCam.h"
|
---|
56 | #include "MHCalibrationPix.h"
|
---|
57 |
|
---|
58 | #include <TVirtualPad.h>
|
---|
59 | #include <TCanvas.h>
|
---|
60 | #include <TPad.h>
|
---|
61 | #include <TText.h>
|
---|
62 | #include <TPaveText.h>
|
---|
63 |
|
---|
64 | #include "MLog.h"
|
---|
65 | #include "MLogManip.h"
|
---|
66 |
|
---|
67 | #include "MCalibrationIntensityCam.h"
|
---|
68 | #include "MCalibrationCam.h"
|
---|
69 | #include "MCalibrationPix.h"
|
---|
70 |
|
---|
71 | #include "MBadPixelsIntensityCam.h"
|
---|
72 | #include "MBadPixelsCam.h"
|
---|
73 | #include "MBadPixelsPix.h"
|
---|
74 |
|
---|
75 | #include "MGeomCam.h"
|
---|
76 | #include "MGeomPix.h"
|
---|
77 |
|
---|
78 | #include "MParList.h"
|
---|
79 |
|
---|
80 | #include "MRawRunHeader.h"
|
---|
81 |
|
---|
82 | ClassImp(MHCalibrationCam);
|
---|
83 |
|
---|
84 | using namespace std;
|
---|
85 |
|
---|
86 | const Int_t MHCalibrationCam::fgPulserFrequency = 500;
|
---|
87 | const TString MHCalibrationCam::gsHistName = "Hist";
|
---|
88 | const TString MHCalibrationCam::gsHistTitle = "";
|
---|
89 | const TString MHCalibrationCam::gsHistXTitle = "";
|
---|
90 | const TString MHCalibrationCam::gsHistYTitle = "Nr. events";
|
---|
91 | // --------------------------------------------------------------------------
|
---|
92 | //
|
---|
93 | // Default Constructor.
|
---|
94 | //
|
---|
95 | // Sets:
|
---|
96 | // - all pointers to NULL
|
---|
97 | //
|
---|
98 | // Initializes and sets owner of:
|
---|
99 | // - fHiGainArray, fLoGainArray
|
---|
100 | // - fAverageHiGainAreas, fAverageLoGainAreas
|
---|
101 | // - fAverageHiGainSectors, fAverageLoGainSectors
|
---|
102 | //
|
---|
103 | // Initializes:
|
---|
104 | // - fPulserFrequency to fgPulserFrequency
|
---|
105 | //
|
---|
106 | // - SetAveregeing (kTRUE);
|
---|
107 | // - SetDebug (kFALSE);
|
---|
108 | // - SetLoGain (kTRUE);
|
---|
109 | //- SetOscillations(kTRUE);
|
---|
110 | //- SetSizeCheck (kTRUE);
|
---|
111 | //
|
---|
112 | MHCalibrationCam::MHCalibrationCam(const char *name, const char *title)
|
---|
113 | : fHistName(gsHistName),fHistTitle(gsHistTitle),
|
---|
114 | fHistXTitle(gsHistXTitle),fHistYTitle(gsHistYTitle),
|
---|
115 | fColor(MCalibrationCam::kNONE), fIntensBad(NULL),
|
---|
116 | fBadPixels(NULL), fIntensCam(NULL), fCam(NULL), fGeom(NULL), fRunHeader(NULL)
|
---|
117 | {
|
---|
118 |
|
---|
119 | fHiGainArray = new TObjArray;
|
---|
120 | fHiGainArray->SetOwner();
|
---|
121 |
|
---|
122 | fLoGainArray = new TObjArray;
|
---|
123 | fLoGainArray->SetOwner();
|
---|
124 |
|
---|
125 | fAverageHiGainAreas = new TObjArray;
|
---|
126 | fAverageHiGainAreas->SetOwner();
|
---|
127 |
|
---|
128 | fAverageLoGainAreas = new TObjArray;
|
---|
129 | fAverageLoGainAreas->SetOwner();
|
---|
130 |
|
---|
131 | fAverageHiGainSectors = new TObjArray;
|
---|
132 | fAverageHiGainSectors->SetOwner();
|
---|
133 |
|
---|
134 | fAverageLoGainSectors = new TObjArray;
|
---|
135 | fAverageLoGainSectors->SetOwner();
|
---|
136 |
|
---|
137 | SetPulserFrequency();
|
---|
138 |
|
---|
139 | SetAverageing (kTRUE);
|
---|
140 | SetDebug (kFALSE);
|
---|
141 | SetLoGain (kTRUE);
|
---|
142 | SetOscillations(kTRUE);
|
---|
143 | SetSizeCheck (kTRUE);
|
---|
144 | }
|
---|
145 |
|
---|
146 | // --------------------------------------------------------------------------
|
---|
147 | //
|
---|
148 | // Returns size of fHiGainArray
|
---|
149 | //
|
---|
150 | const Int_t MHCalibrationCam::GetSize() const
|
---|
151 | {
|
---|
152 | return fHiGainArray->GetSize();
|
---|
153 | }
|
---|
154 |
|
---|
155 | // --------------------------------------------------------------------------
|
---|
156 | //
|
---|
157 | // Deletes the TClonesArray of:
|
---|
158 | // - fHiGainArray, fLoGainArray
|
---|
159 | // - fAverageHiGainAreas, fAverageLoGainAreas
|
---|
160 | // - fAverageHiGainSectors, fAverageLoGainSectors
|
---|
161 | //
|
---|
162 | MHCalibrationCam::~MHCalibrationCam()
|
---|
163 | {
|
---|
164 |
|
---|
165 | delete fHiGainArray;
|
---|
166 | delete fLoGainArray;
|
---|
167 |
|
---|
168 | delete fAverageHiGainAreas;
|
---|
169 | delete fAverageLoGainAreas;
|
---|
170 |
|
---|
171 | delete fAverageHiGainSectors;
|
---|
172 | delete fAverageLoGainSectors;
|
---|
173 | }
|
---|
174 |
|
---|
175 | // --------------------------------------------------------------------------
|
---|
176 | //
|
---|
177 | // Calls Reset() for each entry in:
|
---|
178 | // - fHiGainArray, fLoGainArray
|
---|
179 | // - fAverageHiGainAreas, fAverageLoGainAreas
|
---|
180 | // - fAverageHiGainSectors, fAverageLoGainSectors
|
---|
181 | //
|
---|
182 | void MHCalibrationCam::ResetHists()
|
---|
183 | {
|
---|
184 |
|
---|
185 | if (fHiGainArray)
|
---|
186 | { fHiGainArray->ForEach(MHCalibrationPix,Reset)(); }
|
---|
187 | if (IsAverageing())
|
---|
188 | {
|
---|
189 | if (fAverageHiGainAreas)
|
---|
190 | { fAverageHiGainAreas->ForEach(MHCalibrationPix,Reset)(); }
|
---|
191 | if (fAverageHiGainSectors)
|
---|
192 | { fAverageHiGainSectors->ForEach(MHCalibrationPix,Reset)(); }
|
---|
193 | }
|
---|
194 |
|
---|
195 | if (!IsLoGain())
|
---|
196 | return;
|
---|
197 |
|
---|
198 | if (fLoGainArray)
|
---|
199 | { fLoGainArray->ForEach(MHCalibrationPix,Reset)(); }
|
---|
200 | if (IsAverageing())
|
---|
201 | {
|
---|
202 | if (fAverageLoGainAreas)
|
---|
203 | { fAverageLoGainAreas->ForEach(MHCalibrationPix,Reset)(); }
|
---|
204 | if (fAverageLoGainSectors)
|
---|
205 | { fAverageLoGainSectors->ForEach(MHCalibrationPix,Reset)(); }
|
---|
206 | }
|
---|
207 | }
|
---|
208 |
|
---|
209 | // --------------------------------------------------------------------------
|
---|
210 | //
|
---|
211 | // Get i-th High Gain pixel (pixel number)
|
---|
212 | //
|
---|
213 | MHCalibrationPix &MHCalibrationCam::operator[](UInt_t i)
|
---|
214 | {
|
---|
215 | return *static_cast<MHCalibrationPix*>(fHiGainArray->UncheckedAt(i));
|
---|
216 | }
|
---|
217 |
|
---|
218 | // --------------------------------------------------------------------------
|
---|
219 | //
|
---|
220 | // Get i-th High Gain pixel (pixel number)
|
---|
221 | //
|
---|
222 | const MHCalibrationPix &MHCalibrationCam::operator[](UInt_t i) const
|
---|
223 | {
|
---|
224 | return *static_cast<MHCalibrationPix*>(fHiGainArray->UncheckedAt(i));
|
---|
225 | }
|
---|
226 |
|
---|
227 | // --------------------------------------------------------------------------
|
---|
228 | //
|
---|
229 | // Get i-th Low Gain pixel (pixel number)
|
---|
230 | //
|
---|
231 | MHCalibrationPix &MHCalibrationCam::operator()(UInt_t i)
|
---|
232 | {
|
---|
233 | return *static_cast<MHCalibrationPix*>(fLoGainArray->UncheckedAt(i));
|
---|
234 | }
|
---|
235 |
|
---|
236 | // --------------------------------------------------------------------------
|
---|
237 | //
|
---|
238 | // Get i-th Low Gain pixel (pixel number)
|
---|
239 | //
|
---|
240 | const MHCalibrationPix &MHCalibrationCam::operator()(UInt_t i) const
|
---|
241 | {
|
---|
242 | return *static_cast<MHCalibrationPix*>(fLoGainArray->UncheckedAt(i));
|
---|
243 | }
|
---|
244 |
|
---|
245 | // --------------------------------------------------------------------------
|
---|
246 | //
|
---|
247 | // Returns the current size of the TObjArray fAverageHiGainAreas
|
---|
248 | // independently if the MHCalibrationPix is filled with values or not.
|
---|
249 | //
|
---|
250 | const Int_t MHCalibrationCam::GetAverageAreas() const
|
---|
251 | {
|
---|
252 | return fAverageHiGainAreas->GetEntries();
|
---|
253 | }
|
---|
254 |
|
---|
255 | // --------------------------------------------------------------------------
|
---|
256 | //
|
---|
257 | // Get i-th High Gain pixel Area (area number)
|
---|
258 | //
|
---|
259 | MHCalibrationPix &MHCalibrationCam::GetAverageHiGainArea(UInt_t i)
|
---|
260 | {
|
---|
261 | return *static_cast<MHCalibrationPix*>(fAverageHiGainAreas->UncheckedAt(i));
|
---|
262 | }
|
---|
263 |
|
---|
264 | // --------------------------------------------------------------------------
|
---|
265 | //
|
---|
266 | // Get i-th High Gain pixel Area (area number)
|
---|
267 | //
|
---|
268 | const MHCalibrationPix &MHCalibrationCam::GetAverageHiGainArea(UInt_t i) const
|
---|
269 | {
|
---|
270 | return *static_cast<MHCalibrationPix *>(fAverageHiGainAreas->UncheckedAt(i));
|
---|
271 | }
|
---|
272 |
|
---|
273 | // --------------------------------------------------------------------------
|
---|
274 | //
|
---|
275 | // Get i-th Low Gain pixel Area (area number)
|
---|
276 | //
|
---|
277 | MHCalibrationPix &MHCalibrationCam::GetAverageLoGainArea(UInt_t i)
|
---|
278 | {
|
---|
279 | return *static_cast<MHCalibrationPix*>(fAverageLoGainAreas->UncheckedAt(i));
|
---|
280 | }
|
---|
281 |
|
---|
282 | // --------------------------------------------------------------------------
|
---|
283 | //
|
---|
284 | // Get i-th Low Gain pixel Area (area number)
|
---|
285 | //
|
---|
286 | const MHCalibrationPix &MHCalibrationCam::GetAverageLoGainArea(UInt_t i) const
|
---|
287 | {
|
---|
288 | return *static_cast<MHCalibrationPix*>(fAverageLoGainAreas->UncheckedAt(i));
|
---|
289 | }
|
---|
290 |
|
---|
291 | // --------------------------------------------------------------------------
|
---|
292 | //
|
---|
293 | // Returns the current size of the TObjArray fAverageHiGainSectors
|
---|
294 | // independently if the MHCalibrationPix is filled with values or not.
|
---|
295 | //
|
---|
296 | const Int_t MHCalibrationCam::GetAverageSectors() const
|
---|
297 | {
|
---|
298 | return fAverageHiGainSectors->GetEntries();
|
---|
299 | }
|
---|
300 |
|
---|
301 | // --------------------------------------------------------------------------
|
---|
302 | //
|
---|
303 | // Get i-th High Gain Sector (sector number)
|
---|
304 | //
|
---|
305 | MHCalibrationPix &MHCalibrationCam::GetAverageHiGainSector(UInt_t i)
|
---|
306 | {
|
---|
307 | return *static_cast<MHCalibrationPix*>(fAverageHiGainSectors->UncheckedAt(i));
|
---|
308 | }
|
---|
309 |
|
---|
310 | // --------------------------------------------------------------------------
|
---|
311 | //
|
---|
312 | // Get i-th High Gain Sector (sector number)
|
---|
313 | //
|
---|
314 | const MHCalibrationPix &MHCalibrationCam::GetAverageHiGainSector(UInt_t i) const
|
---|
315 | {
|
---|
316 | return *static_cast<MHCalibrationPix*>(fAverageHiGainSectors->UncheckedAt(i));
|
---|
317 | }
|
---|
318 |
|
---|
319 | // --------------------------------------------------------------------------
|
---|
320 | //
|
---|
321 | // Get i-th Low Gain Sector (sector number)
|
---|
322 | //
|
---|
323 | MHCalibrationPix &MHCalibrationCam::GetAverageLoGainSector(UInt_t i)
|
---|
324 | {
|
---|
325 | return *static_cast<MHCalibrationPix*>(fAverageLoGainSectors->UncheckedAt(i));
|
---|
326 | }
|
---|
327 |
|
---|
328 | // --------------------------------------------------------------------------
|
---|
329 | //
|
---|
330 | // Get i-th Low Gain Sector (sector number)
|
---|
331 | //
|
---|
332 | const MHCalibrationPix &MHCalibrationCam::GetAverageLoGainSector(UInt_t i) const
|
---|
333 | {
|
---|
334 | return *static_cast<MHCalibrationPix*>(fAverageLoGainSectors->UncheckedAt(i));
|
---|
335 | }
|
---|
336 |
|
---|
337 | // --------------------------------------------------------------------------
|
---|
338 | //
|
---|
339 | // Gets the pointers to:
|
---|
340 | // - MGeomCam
|
---|
341 | //
|
---|
342 | // Calls SetupHists(const MParList *pList)
|
---|
343 | //
|
---|
344 | // Calls Delete-Function of:
|
---|
345 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
---|
346 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
---|
347 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
---|
348 | //
|
---|
349 | Bool_t MHCalibrationCam::SetupFill(const MParList *pList)
|
---|
350 | {
|
---|
351 |
|
---|
352 | fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
|
---|
353 | if (!fGeom)
|
---|
354 | {
|
---|
355 | *fLog << err << GetDescriptor()
|
---|
356 | << ": MGeomCam not found... aborting." << endl;
|
---|
357 | return kFALSE;
|
---|
358 | }
|
---|
359 |
|
---|
360 | fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
361 | if (!fRunHeader)
|
---|
362 | {
|
---|
363 | *fLog << warn << GetDescriptor()
|
---|
364 | << ": MRawRunHeader not found... will not store run numbers." << endl;
|
---|
365 | }
|
---|
366 |
|
---|
367 | /* not needed -> Class is never used twice
|
---|
368 | fHiGainArray->Delete();
|
---|
369 | fLoGainArray->Delete();
|
---|
370 |
|
---|
371 | fAverageHiGainAreas->Delete();
|
---|
372 | fAverageLoGainAreas->Delete();
|
---|
373 |
|
---|
374 | fAverageHiGainSectors->Delete();
|
---|
375 | fAverageLoGainSectors->Delete();
|
---|
376 | */
|
---|
377 |
|
---|
378 | return SetupHists(pList);
|
---|
379 | }
|
---|
380 |
|
---|
381 |
|
---|
382 | // --------------------------------------------------------------------------
|
---|
383 | //
|
---|
384 | // Gets or creates the pointers to:
|
---|
385 | // - MBadPixelsIntensityCam
|
---|
386 | // - MBadPixelsCam
|
---|
387 | //
|
---|
388 | // Searches pointer to:
|
---|
389 | // - MArrivalTimeCam
|
---|
390 | //
|
---|
391 | // Initializes, if empty to MArrivalTimeCam::GetSize() for:
|
---|
392 | // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
|
---|
393 | //
|
---|
394 | // Initializes, if empty to MGeomCam::GetNumAreas() for:
|
---|
395 | // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
|
---|
396 | //
|
---|
397 | // Initializes, if empty to MGeomCam::GetNumSectors() for:
|
---|
398 | // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
|
---|
399 | //
|
---|
400 | // Initializes TArray's to MGeomCam::GetNumAreas and MGeomCam::GetNumSectors, respectively
|
---|
401 | // Fills with number of valid pixels (if !MBadPixelsPix::IsBad()):
|
---|
402 | // - MHCalibrationCam::fAverageAreaNum[area index]
|
---|
403 | // - MHCalibrationCam::fAverageSectorNum[area index]
|
---|
404 | //
|
---|
405 | // Calls InitializeHists() for every entry in:
|
---|
406 | // - MHCalibrationCam::fHiGainArray
|
---|
407 | // - MHCalibrationCam::fAverageHiGainAreas
|
---|
408 | // - MHCalibrationCam::fAverageHiGainSectors
|
---|
409 | //
|
---|
410 | // Sets Titles and Names for the Histograms
|
---|
411 | // - MHCalibrationCam::fAverageHiGainAreas
|
---|
412 | // - MHCalibrationCam::fAverageHiGainSectors
|
---|
413 | //
|
---|
414 | // Retrieves the run numbers from MRawRunHeader and stores them in fRunNumbers
|
---|
415 | //
|
---|
416 | Bool_t MHCalibrationCam::ReInit(MParList *pList)
|
---|
417 | {
|
---|
418 |
|
---|
419 | const Int_t npixels = fGeom->GetNumPixels();
|
---|
420 | const Int_t nsectors = fGeom->GetNumSectors();
|
---|
421 | const Int_t nareas = fGeom->GetNumAreas();
|
---|
422 |
|
---|
423 | fIntensBad = (MBadPixelsIntensityCam*)pList->FindObject(AddSerialNumber("MBadPixelsIntensityCam"));
|
---|
424 | if (fIntensBad)
|
---|
425 | *fLog << inf << "Found MBadPixelsIntensityCam ... " << endl;
|
---|
426 | else
|
---|
427 | {
|
---|
428 | fBadPixels = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
|
---|
429 | if (!fBadPixels)
|
---|
430 | {
|
---|
431 |
|
---|
432 | fBadPixels = (MBadPixelsCam*)pList->FindCreateObj(AddSerialNumber("MBadPixelsCam"));
|
---|
433 | if (!fBadPixels)
|
---|
434 | {
|
---|
435 | *fLog << err << "Cannot find nor create MBadPixelsCam ... abort." << endl;
|
---|
436 | return kFALSE;
|
---|
437 | }
|
---|
438 | else
|
---|
439 | fBadPixels->InitSize(npixels);
|
---|
440 | }
|
---|
441 | }
|
---|
442 |
|
---|
443 | if (IsAverageing())
|
---|
444 | {
|
---|
445 | //
|
---|
446 | // The function TArrayF::Set() already sets all entries to 0.
|
---|
447 | //
|
---|
448 | fAverageAreaNum. Set(nareas);
|
---|
449 | fAverageAreaSat. Set(nareas);
|
---|
450 | fAverageAreaSigma. Set(nareas);
|
---|
451 | fAverageAreaSigmaVar. Set(nareas);
|
---|
452 | fAverageAreaRelSigma. Set(nareas);
|
---|
453 | fAverageAreaRelSigmaVar.Set(nareas);
|
---|
454 | fAverageSectorNum. Set(nsectors);
|
---|
455 |
|
---|
456 | for (Int_t aidx=0; aidx<nareas; aidx++)
|
---|
457 | fAverageAreaNum[aidx] = 0;
|
---|
458 |
|
---|
459 | for (Int_t sector=0; sector<nsectors; sector++)
|
---|
460 | fAverageSectorNum[sector] = 0;
|
---|
461 |
|
---|
462 | for (Int_t i=0; i<npixels; i++)
|
---|
463 | {
|
---|
464 |
|
---|
465 | MBadPixelsPix &bad = fIntensBad ? (*fIntensBad)[i] : (*fBadPixels)[i];
|
---|
466 | if (bad.IsBad())
|
---|
467 | continue;
|
---|
468 |
|
---|
469 | fAverageAreaNum [(*fGeom)[i].GetAidx() ]++;
|
---|
470 | fAverageSectorNum[(*fGeom)[i].GetSector()]++;
|
---|
471 | }
|
---|
472 | }
|
---|
473 |
|
---|
474 | //
|
---|
475 | // Because ReInit has been called, a new run number is added
|
---|
476 | //
|
---|
477 | fRunNumbers.Set(fRunNumbers.GetSize()+1);
|
---|
478 |
|
---|
479 | if (fRunHeader)
|
---|
480 | {
|
---|
481 | fRunNumbers[fRunNumbers.GetSize()-1] = fRunHeader->GetRunNumber();
|
---|
482 | if (IsLoGain())
|
---|
483 | SetLoGain(fRunHeader->GetNumSamplesLoGain());
|
---|
484 | }
|
---|
485 |
|
---|
486 | if (!ReInitHists(pList))
|
---|
487 | return kFALSE;
|
---|
488 |
|
---|
489 | if (!fRunHeader)
|
---|
490 | return kTRUE;
|
---|
491 |
|
---|
492 | for (Int_t i=0; i<fHiGainArray->GetEntries(); i++)
|
---|
493 | {
|
---|
494 | TH1F *h = (*this)[i].GetHGausHist();
|
---|
495 | h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
|
---|
496 | }
|
---|
497 |
|
---|
498 | if (IsLoGain())
|
---|
499 | for (Int_t i=0; i<fLoGainArray->GetEntries(); i++)
|
---|
500 | {
|
---|
501 | TH1F *h = (*this)(i).GetHGausHist();
|
---|
502 | h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
|
---|
503 | }
|
---|
504 |
|
---|
505 | if (!IsAverageing())
|
---|
506 | return kTRUE;
|
---|
507 |
|
---|
508 | for (Int_t j=0; j<nareas; j++)
|
---|
509 | {
|
---|
510 | TH1F *h = GetAverageHiGainArea(j).GetHGausHist();
|
---|
511 | h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
|
---|
512 | }
|
---|
513 |
|
---|
514 | if (IsLoGain())
|
---|
515 | for (Int_t j=0; j<nareas; j++)
|
---|
516 | {
|
---|
517 | TH1F *h = GetAverageLoGainArea(j).GetHGausHist();
|
---|
518 | h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
|
---|
519 | }
|
---|
520 |
|
---|
521 | for (Int_t j=0; j<nsectors; j++)
|
---|
522 | {
|
---|
523 | TH1F *h = GetAverageHiGainSector(j).GetHGausHist();
|
---|
524 | h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
|
---|
525 | }
|
---|
526 |
|
---|
527 | if (IsLoGain())
|
---|
528 | for (Int_t j=0; j<nsectors; j++)
|
---|
529 | {
|
---|
530 | TH1F *h = GetAverageLoGainSector(j).GetHGausHist();
|
---|
531 | h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
|
---|
532 | }
|
---|
533 |
|
---|
534 | return kTRUE;
|
---|
535 | }
|
---|
536 |
|
---|
537 | //--------------------------------------------------------------------------------------
|
---|
538 | //
|
---|
539 | // Initializes the High Gain Arrays:
|
---|
540 | //
|
---|
541 | // - Expand fHiGainArrays to npixels
|
---|
542 | // - Expand fAverageHiGainAreas to nareas
|
---|
543 | // - Expand fAverageHiGainSectors to nsectors
|
---|
544 | //
|
---|
545 | // - For every entry in the expanded arrays:
|
---|
546 | // * Initialize an MHCalibrationPix
|
---|
547 | // * Set Binning from fNbins, fFirst and fLast
|
---|
548 | // * Set Histgram names and titles from fHistName and fHistTitle
|
---|
549 | // * Set X-axis and Y-axis titles with fHistXTitle and fHistYTitle
|
---|
550 | // * Call InitHists
|
---|
551 | //
|
---|
552 | void MHCalibrationCam::InitHiGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
|
---|
553 | {
|
---|
554 |
|
---|
555 | if (fHiGainArray->GetEntries()==0)
|
---|
556 | {
|
---|
557 | fHiGainArray->Expand(npixels);
|
---|
558 | for (Int_t i=0; i<npixels; i++)
|
---|
559 | {
|
---|
560 | (*fHiGainArray)[i] = new MHCalibrationPix(Form("%s%s",fHistName.Data(),"HiGainPix"),
|
---|
561 | Form("%s%s",fHistTitle.Data()," High Gain Pixel"));
|
---|
562 |
|
---|
563 | MHCalibrationPix &pix = (*this)[i];
|
---|
564 | pix.SetNbins(fNbins);
|
---|
565 | pix.SetFirst(fFirst);
|
---|
566 | pix.SetLast (fLast);
|
---|
567 |
|
---|
568 | TH1F *h = pix.GetHGausHist();
|
---|
569 |
|
---|
570 | h->SetName (Form("%s%s%s","H",fHistName.Data(),"HiGainPix"));
|
---|
571 | h->SetTitle(Form("%s%s",fHistTitle.Data()," High Gain Pixel "));
|
---|
572 | h->SetXTitle(fHistXTitle.Data());
|
---|
573 | h->SetYTitle(fHistYTitle.Data());
|
---|
574 |
|
---|
575 | MBadPixelsPix &bad = fIntensBad ? (*fIntensBad)[i] : (*fBadPixels)[i];
|
---|
576 | InitHists(pix,bad,i);
|
---|
577 | }
|
---|
578 | }
|
---|
579 |
|
---|
580 | if (!IsAverageing())
|
---|
581 | return;
|
---|
582 |
|
---|
583 | if (fAverageHiGainAreas->GetEntries()==0)
|
---|
584 | {
|
---|
585 | fAverageHiGainAreas->Expand(nareas);
|
---|
586 |
|
---|
587 | for (Int_t j=0; j<nareas; j++)
|
---|
588 | {
|
---|
589 | (*fAverageHiGainAreas)[j] = new MHCalibrationPix(Form("%s%s",fHistName.Data(),"HiGainArea"),
|
---|
590 | Form("%s%s",fHistTitle.Data()," High Gain Area Idx "));
|
---|
591 |
|
---|
592 | MHCalibrationPix &pix = GetAverageHiGainArea(j);
|
---|
593 |
|
---|
594 | pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
|
---|
595 | pix.SetFirst(fFirst);
|
---|
596 | pix.SetLast (fLast);
|
---|
597 |
|
---|
598 | TH1F *h = pix.GetHGausHist();
|
---|
599 |
|
---|
600 | h->SetName (Form("%s%s%s","H",fHistName.Data(),"HiGainArea"));
|
---|
601 | h->SetXTitle(fHistXTitle.Data());
|
---|
602 | h->SetYTitle(fHistYTitle.Data());
|
---|
603 |
|
---|
604 | if (fGeom && fGeom->InheritsFrom("MGeomCamMagic"))
|
---|
605 | {
|
---|
606 | h->SetTitle(Form("%s%s%s%s",fHistTitle.Data()," averaged on event-by-event basis ",
|
---|
607 | j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
|
---|
608 | pix.InitBins();
|
---|
609 | pix.SetEventFrequency(fPulserFrequency);
|
---|
610 | }
|
---|
611 | else
|
---|
612 | {
|
---|
613 | h->SetTitle(Form("%s%s",fHistTitle.Data()," averaged on event-by-event basis High Gain Area Idx "));
|
---|
614 | InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
|
---|
615 | }
|
---|
616 | }
|
---|
617 | }
|
---|
618 |
|
---|
619 | if (fAverageHiGainSectors->GetEntries()==0)
|
---|
620 | {
|
---|
621 | fAverageHiGainSectors->Expand(nsectors);
|
---|
622 |
|
---|
623 | for (Int_t j=0; j<nsectors; j++)
|
---|
624 | {
|
---|
625 | (*fAverageHiGainSectors)[j] = new MHCalibrationPix(Form("%s%s",fHistName.Data(),"HiGainSector"),
|
---|
626 | Form("%s%s",fHistTitle.Data()," High Gain Sector "));
|
---|
627 | MHCalibrationPix &pix = GetAverageHiGainSector(j);
|
---|
628 |
|
---|
629 | pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nsectors));
|
---|
630 | pix.SetFirst(fFirst);
|
---|
631 | pix.SetLast (fLast);
|
---|
632 |
|
---|
633 | TH1F *h = pix.GetHGausHist();
|
---|
634 |
|
---|
635 | h->SetName (Form("%s%s%s","H",fHistName.Data(),"HiGainSector"));
|
---|
636 | h->SetTitle(Form("%s%s",fHistTitle.Data()," High Gain Sector "));
|
---|
637 | h->SetXTitle(fHistXTitle.Data());
|
---|
638 | h->SetYTitle(fHistYTitle.Data());
|
---|
639 |
|
---|
640 | InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
|
---|
641 | }
|
---|
642 | }
|
---|
643 | }
|
---|
644 |
|
---|
645 | //--------------------------------------------------------------------------------------
|
---|
646 | //
|
---|
647 | // Return, if IsLoGain() is kFALSE
|
---|
648 | //
|
---|
649 | // Initializes the Low Gain Arrays:
|
---|
650 | //
|
---|
651 | // - Expand fLoGainArrays to npixels
|
---|
652 | // - Expand fAverageLoGainAreas to nareas
|
---|
653 | // - Expand fAverageLoGainSectors to nsectors
|
---|
654 | //
|
---|
655 | // - For every entry in the expanded arrays:
|
---|
656 | // * Initialize an MHCalibrationPix
|
---|
657 | // * Set Binning from fNbins, fFirst and fLast
|
---|
658 | // * Set Histgram names and titles from fHistName and fHistTitle
|
---|
659 | // * Set X-axis and Y-axis titles with fHistXTitle and fHistYTitle
|
---|
660 | // * Call InitHists
|
---|
661 | //
|
---|
662 | void MHCalibrationCam::InitLoGainArrays(const Int_t npixels, const Int_t nareas, const Int_t nsectors)
|
---|
663 | {
|
---|
664 |
|
---|
665 | if (!IsLoGain())
|
---|
666 | return;
|
---|
667 |
|
---|
668 | if (fLoGainArray->GetEntries()==0)
|
---|
669 | {
|
---|
670 | fLoGainArray->Expand(npixels);
|
---|
671 | for (Int_t i=0; i<npixels; i++)
|
---|
672 | {
|
---|
673 | (*fLoGainArray)[i] = new MHCalibrationPix(Form("%s%s",fHistName.Data(),"LoGainPix"),
|
---|
674 | Form("%s%s",fHistTitle.Data()," Low Gain Pixel"));
|
---|
675 |
|
---|
676 | MHCalibrationPix &pix = (*this)[i];
|
---|
677 | pix.SetNbins(fNbins);
|
---|
678 | pix.SetFirst(fFirst);
|
---|
679 | pix.SetLast (fLast);
|
---|
680 |
|
---|
681 | TH1F *h = pix.GetHGausHist();
|
---|
682 |
|
---|
683 | h->SetName (Form("%s%s%s","H",fHistName.Data(),"LoGainPix"));
|
---|
684 | h->SetTitle(Form("%s%s",fHistTitle.Data()," Low Gain Pixel "));
|
---|
685 | h->SetXTitle(fHistXTitle.Data());
|
---|
686 | h->SetYTitle(fHistYTitle.Data());
|
---|
687 |
|
---|
688 | MBadPixelsPix &bad = fIntensBad ? (*fIntensBad)[i] : (*fBadPixels)[i];
|
---|
689 | InitHists(pix,bad,i);
|
---|
690 | }
|
---|
691 | }
|
---|
692 |
|
---|
693 | if (!IsAverageing())
|
---|
694 | return;
|
---|
695 |
|
---|
696 | if (fAverageLoGainAreas->GetEntries()==0)
|
---|
697 | {
|
---|
698 | fAverageLoGainAreas->Expand(nareas);
|
---|
699 |
|
---|
700 | for (Int_t j=0; j<nareas; j++)
|
---|
701 | {
|
---|
702 | (*fAverageLoGainAreas)[j] = new MHCalibrationPix(Form("%s%s",fHistName.Data(),"LoGainArea"),
|
---|
703 | Form("%s%s",fHistTitle.Data()," Low Gain Area Idx "));
|
---|
704 |
|
---|
705 | MHCalibrationPix &pix = GetAverageLoGainArea(j);
|
---|
706 |
|
---|
707 | pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nareas));
|
---|
708 | pix.SetFirst(fFirst);
|
---|
709 | pix.SetLast (fLast);
|
---|
710 |
|
---|
711 | TH1F *h = pix.GetHGausHist();
|
---|
712 |
|
---|
713 | h->SetName (Form("%s%s%s","H",fHistName.Data(),"LoGainArea"));
|
---|
714 | h->SetXTitle(fHistXTitle.Data());
|
---|
715 | h->SetYTitle(fHistYTitle.Data());
|
---|
716 |
|
---|
717 | if (fGeom && fGeom->InheritsFrom("MGeomCamMagic"))
|
---|
718 | {
|
---|
719 | h->SetTitle(Form("%s%s%s%s",fHistTitle.Data()," averaged on event-by-event basis ",
|
---|
720 | j==0 ? "Inner Pixels " : "Outer Pixels ","Low Gain Runs: "));
|
---|
721 | pix.InitBins();
|
---|
722 | pix.SetEventFrequency(fPulserFrequency);
|
---|
723 | }
|
---|
724 | else
|
---|
725 | {
|
---|
726 | h->SetTitle(Form("%s%s",fHistTitle.Data()," averaged on event-by-event basis Low Gain Area Idx "));
|
---|
727 | InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadArea(j) : fCam->GetAverageBadArea(j),j);
|
---|
728 | }
|
---|
729 | }
|
---|
730 | }
|
---|
731 |
|
---|
732 | if (fAverageLoGainSectors->GetEntries()==0)
|
---|
733 | {
|
---|
734 | fAverageLoGainSectors->Expand(nsectors);
|
---|
735 |
|
---|
736 | for (Int_t j=0; j<nsectors; j++)
|
---|
737 | {
|
---|
738 | (*fAverageLoGainSectors)[j] = new MHCalibrationPix(Form("%s%s",fHistName.Data(),"LoGainSector"),
|
---|
739 | Form("%s%s",fHistTitle.Data()," Low Gain Sector "));
|
---|
740 | MHCalibrationPix &pix = GetAverageLoGainSector(j);
|
---|
741 |
|
---|
742 | pix.SetNbins(fNbins*(Int_t)TMath::Sqrt((Float_t)npixels/nsectors));
|
---|
743 | pix.SetFirst(fFirst);
|
---|
744 | pix.SetLast (fLast);
|
---|
745 |
|
---|
746 | TH1F *h = pix.GetHGausHist();
|
---|
747 |
|
---|
748 | h->SetName (Form("%s%s%s","H",fHistName.Data(),"LoGainSector"));
|
---|
749 | h->SetTitle(Form("%s%s",fHistTitle.Data()," Low Gain Sector "));
|
---|
750 | h->SetXTitle(fHistXTitle.Data());
|
---|
751 | h->SetYTitle(fHistYTitle.Data());
|
---|
752 |
|
---|
753 | InitHists(pix,fIntensCam ? fIntensCam->GetAverageBadSector(j) : fCam->GetAverageBadSector(j),j);
|
---|
754 | }
|
---|
755 | }
|
---|
756 | }
|
---|
757 |
|
---|
758 | //--------------------------------------------------------------------------------
|
---|
759 | //
|
---|
760 | // Retrieves from MGeomCam:
|
---|
761 | // - number of pixels
|
---|
762 | // - number of pixel areas
|
---|
763 | // - number of sectors
|
---|
764 | //
|
---|
765 | // Return kFALSE, if sizes of the TObjArrays do not match npixels, nareas or nsectors
|
---|
766 | //
|
---|
767 | // Call FillHists()
|
---|
768 | //
|
---|
769 | Bool_t MHCalibrationCam::Fill(const MParContainer *par, const Stat_t w)
|
---|
770 | {
|
---|
771 |
|
---|
772 | if (!IsSizeCheck())
|
---|
773 | return FillHists(par,w);
|
---|
774 |
|
---|
775 | const Int_t npixels = fGeom->GetNumPixels();
|
---|
776 | const Int_t nareas = fGeom->GetNumAreas();
|
---|
777 | const Int_t nsectors = fGeom->GetNumSectors();
|
---|
778 |
|
---|
779 | //
|
---|
780 | // Hi-Gain ObjArrays
|
---|
781 | //
|
---|
782 | if (fHiGainArray->GetEntries() != npixels)
|
---|
783 | {
|
---|
784 | *fLog << err << "ERROR - Size mismatch in number of pixels... abort." << endl;
|
---|
785 | return kFALSE;
|
---|
786 | }
|
---|
787 |
|
---|
788 | if (IsLoGain())
|
---|
789 | {
|
---|
790 | if (fLoGainArray->GetEntries() != npixels)
|
---|
791 | {
|
---|
792 | *fLog << err << "ERROR - Size mismatch in number of pixels... abort." << endl;
|
---|
793 | return kFALSE;
|
---|
794 | }
|
---|
795 | }
|
---|
796 |
|
---|
797 | if (!IsAverageing())
|
---|
798 | return FillHists(par,w);
|
---|
799 |
|
---|
800 | if (fAverageHiGainAreas->GetEntries() != nareas)
|
---|
801 | {
|
---|
802 | *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
|
---|
803 | return kFALSE;
|
---|
804 | }
|
---|
805 |
|
---|
806 | if (fAverageHiGainSectors->GetEntries() != nsectors)
|
---|
807 | {
|
---|
808 | *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
|
---|
809 | return kFALSE;
|
---|
810 | }
|
---|
811 |
|
---|
812 | if (IsLoGain())
|
---|
813 | {
|
---|
814 |
|
---|
815 | if (fAverageLoGainAreas->GetEntries() != nareas)
|
---|
816 | {
|
---|
817 | *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
|
---|
818 | return kFALSE;
|
---|
819 | }
|
---|
820 |
|
---|
821 | if (fAverageLoGainSectors->GetEntries() != nsectors)
|
---|
822 | {
|
---|
823 | *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
|
---|
824 | return kFALSE;
|
---|
825 | }
|
---|
826 | }
|
---|
827 |
|
---|
828 | return FillHists(par, w);
|
---|
829 | }
|
---|
830 |
|
---|
831 | // --------------------------------------------------------------------------
|
---|
832 | //
|
---|
833 | // 0) Ask if fHiGainArray and fLoGainArray have been initialized,
|
---|
834 | // otherwise return kFALSE.
|
---|
835 | // 1) FinalizeHists()
|
---|
836 | // 2) FinalizeBadPixels()
|
---|
837 | // 3) CalcAverageSigma()
|
---|
838 | //
|
---|
839 | Bool_t MHCalibrationCam::Finalize()
|
---|
840 | {
|
---|
841 |
|
---|
842 | if (fHiGainArray->GetEntries() == 0 && fLoGainArray->GetEntries() == 0)
|
---|
843 | {
|
---|
844 | *fLog << err << GetDescriptor()
|
---|
845 | << ": ERROR: Both (HiGain and LoGain) histogram arrays have not been initialized... abort." << endl;
|
---|
846 | return kFALSE;
|
---|
847 | }
|
---|
848 |
|
---|
849 | if (!FinalizeHists())
|
---|
850 | return kFALSE;
|
---|
851 |
|
---|
852 | FinalizeBadPixels();
|
---|
853 | CalcAverageSigma();
|
---|
854 |
|
---|
855 | return kTRUE;
|
---|
856 | }
|
---|
857 |
|
---|
858 | // -------------------------------------------------------------
|
---|
859 | //
|
---|
860 | // If MBadPixelsPix::IsBad():
|
---|
861 | // - calls MHCalibrationPix::SetExcluded()
|
---|
862 | //
|
---|
863 | // Calls:
|
---|
864 | // - MHGausEvents::InitBins()
|
---|
865 | // - MHCalibrationPix::ChangeHistId(i)
|
---|
866 | // - MHCalibrationPix::SetEventFrequency(fPulserFrequency)
|
---|
867 | //
|
---|
868 | void MHCalibrationCam::InitHists(MHCalibrationPix &hist, MBadPixelsPix &bad, const Int_t i)
|
---|
869 | {
|
---|
870 |
|
---|
871 | if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
---|
872 | hist.SetExcluded();
|
---|
873 |
|
---|
874 | hist.InitBins();
|
---|
875 | hist.ChangeHistId(i);
|
---|
876 | hist.SetEventFrequency(fPulserFrequency);
|
---|
877 |
|
---|
878 | TH1F *h = hist.GetHGausHist();
|
---|
879 | h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
|
---|
880 | }
|
---|
881 |
|
---|
882 | // --------------------------------------------------------------------------
|
---|
883 | //
|
---|
884 | // Calls FitHiGainHists for every entry in:
|
---|
885 | // - fHiGainArray
|
---|
886 | // - fAverageHiGainAreas
|
---|
887 | // - fAverageHiGainSectors
|
---|
888 | //
|
---|
889 | void MHCalibrationCam::FitHiGainArrays(MCalibrationCam &calcam, MBadPixelsCam &badcam,
|
---|
890 | MBadPixelsPix::UncalibratedType_t fittyp,
|
---|
891 | MBadPixelsPix::UncalibratedType_t osctyp)
|
---|
892 | {
|
---|
893 |
|
---|
894 | for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
|
---|
895 | {
|
---|
896 |
|
---|
897 | MHCalibrationPix &hist = (*this)[i];
|
---|
898 |
|
---|
899 | if (hist.IsExcluded())
|
---|
900 | continue;
|
---|
901 |
|
---|
902 | MCalibrationPix &pix = calcam[i];
|
---|
903 | MBadPixelsPix &bad = badcam[i];
|
---|
904 |
|
---|
905 | FitHiGainHists(hist,pix,bad,fittyp,osctyp);
|
---|
906 |
|
---|
907 | }
|
---|
908 |
|
---|
909 | if (!IsAverageing())
|
---|
910 | return;
|
---|
911 |
|
---|
912 | for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
|
---|
913 | {
|
---|
914 |
|
---|
915 | MHCalibrationPix &hist = GetAverageHiGainArea(j);
|
---|
916 | MCalibrationPix &pix = calcam.GetAverageArea(j);
|
---|
917 | MBadPixelsPix &bad = calcam.GetAverageBadArea(j);
|
---|
918 |
|
---|
919 | FitHiGainHists(hist,pix,bad,fittyp,osctyp);
|
---|
920 | }
|
---|
921 |
|
---|
922 |
|
---|
923 | for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
|
---|
924 | {
|
---|
925 |
|
---|
926 | MHCalibrationPix &hist = GetAverageHiGainSector(j);
|
---|
927 | MCalibrationPix &pix = calcam.GetAverageSector(j);
|
---|
928 | MBadPixelsPix &bad = calcam.GetAverageBadSector(j);
|
---|
929 |
|
---|
930 | FitHiGainHists(hist,pix,bad,fittyp,osctyp);
|
---|
931 | }
|
---|
932 |
|
---|
933 | }
|
---|
934 |
|
---|
935 | // --------------------------------------------------------------------------
|
---|
936 | //
|
---|
937 | // Calls FitLoGainHists for every entry in:
|
---|
938 | // - fLoGainArray
|
---|
939 | // - fAverageLoGainAreas
|
---|
940 | // - fAverageLoGainSectors
|
---|
941 | //
|
---|
942 | void MHCalibrationCam::FitLoGainArrays(MCalibrationCam &calcam, MBadPixelsCam &badcam,
|
---|
943 | MBadPixelsPix::UncalibratedType_t fittyp,
|
---|
944 | MBadPixelsPix::UncalibratedType_t osctyp)
|
---|
945 | {
|
---|
946 |
|
---|
947 | if (!IsLoGain())
|
---|
948 | return;
|
---|
949 |
|
---|
950 | for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
|
---|
951 | {
|
---|
952 |
|
---|
953 | MHCalibrationPix &hist = (*this)(i);
|
---|
954 |
|
---|
955 | if (hist.IsExcluded())
|
---|
956 | continue;
|
---|
957 |
|
---|
958 | MCalibrationPix &pix = calcam[i];
|
---|
959 | MBadPixelsPix &bad = badcam[i];
|
---|
960 |
|
---|
961 | FitLoGainHists(hist,pix,bad,fittyp,osctyp);
|
---|
962 |
|
---|
963 | }
|
---|
964 |
|
---|
965 | if (!IsAverageing())
|
---|
966 | return;
|
---|
967 |
|
---|
968 | for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
|
---|
969 | {
|
---|
970 |
|
---|
971 | MHCalibrationPix &hist = GetAverageLoGainArea(j);
|
---|
972 | MCalibrationPix &pix = calcam.GetAverageArea(j);
|
---|
973 | MBadPixelsPix &bad = calcam.GetAverageBadArea(j);
|
---|
974 |
|
---|
975 | FitLoGainHists(hist,pix,bad,fittyp,osctyp);
|
---|
976 | }
|
---|
977 |
|
---|
978 |
|
---|
979 | for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
|
---|
980 | {
|
---|
981 |
|
---|
982 | MHCalibrationPix &hist = GetAverageLoGainSector(j);
|
---|
983 | MCalibrationPix &pix = calcam.GetAverageSector(j);
|
---|
984 | MBadPixelsPix &bad = calcam.GetAverageBadSector(j);
|
---|
985 |
|
---|
986 | FitLoGainHists(hist,pix,bad,fittyp,osctyp);
|
---|
987 | }
|
---|
988 | }
|
---|
989 |
|
---|
990 | //------------------------------------------------------------
|
---|
991 | //
|
---|
992 | // For all averaged areas, the fitted sigma is multiplied with the square root of
|
---|
993 | // the number involved pixels
|
---|
994 | //
|
---|
995 | void MHCalibrationCam::CalcAverageSigma()
|
---|
996 | {
|
---|
997 |
|
---|
998 | if (!fCam)
|
---|
999 | return;
|
---|
1000 |
|
---|
1001 | if (!IsAverageing())
|
---|
1002 | return;
|
---|
1003 |
|
---|
1004 | for (UInt_t j=0; j<fGeom->GetNumAreas(); j++)
|
---|
1005 | {
|
---|
1006 |
|
---|
1007 | MCalibrationPix &pix = fCam->GetAverageArea(j);
|
---|
1008 |
|
---|
1009 | const Float_t numsqr = TMath::Sqrt((Float_t)fAverageAreaNum[j]);
|
---|
1010 | fAverageAreaSigma[j] = pix.GetSigma () * numsqr;
|
---|
1011 | fAverageAreaSigmaVar[j] = pix.GetSigmaErr () * pix.GetSigmaErr() * numsqr;
|
---|
1012 |
|
---|
1013 | pix.SetSigma (fAverageAreaSigma[j]);
|
---|
1014 | pix.SetSigmaVar(fAverageAreaSigmaVar[j]);
|
---|
1015 |
|
---|
1016 | fAverageAreaRelSigma [j] = fAverageAreaSigma[j] / pix.GetMean();
|
---|
1017 | fAverageAreaRelSigmaVar[j] = fAverageAreaSigmaVar[j] / (fAverageAreaSigma[j]*fAverageAreaSigma[j]);
|
---|
1018 | fAverageAreaRelSigmaVar[j] += pix.GetMeanRelVar();
|
---|
1019 | fAverageAreaRelSigmaVar[j] *= fAverageAreaRelSigma[j];
|
---|
1020 | }
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | // ---------------------------------------------------------------------------
|
---|
1024 | //
|
---|
1025 | // Returns if the histogram is empty and sets the following flag:
|
---|
1026 | // - MBadPixelsPix::SetUnsuitable(MBadPixelsPix::kUnsuitableRun)
|
---|
1027 | //
|
---|
1028 | // Fits the histograms with a Gaussian, in case of failure
|
---|
1029 | // calls MHCalibrationPix::RepeatFit(), in case of repeated failure
|
---|
1030 | // calls MHCalibrationPix::BypassFit() and sets the following flags:
|
---|
1031 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t fittyp )
|
---|
1032 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
1033 | //
|
---|
1034 | // Creates the fourier spectrum and tests MHGausEvents::IsFourierSpectrumOK().
|
---|
1035 | // In case no, sets the following flags:
|
---|
1036 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t osctyp )
|
---|
1037 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
1038 | //
|
---|
1039 | // Retrieves the results and store them in MCalibrationPix
|
---|
1040 | //
|
---|
1041 | void MHCalibrationCam::FitHiGainHists(MHCalibrationPix &hist,
|
---|
1042 | MCalibrationPix &pix,
|
---|
1043 | MBadPixelsPix &bad,
|
---|
1044 | MBadPixelsPix::UncalibratedType_t fittyp,
|
---|
1045 | MBadPixelsPix::UncalibratedType_t osctyp)
|
---|
1046 | {
|
---|
1047 |
|
---|
1048 |
|
---|
1049 | if (hist.IsEmpty() || hist.IsOnlyOverflow() || hist.IsOnlyUnderflow())
|
---|
1050 | return;
|
---|
1051 |
|
---|
1052 | //
|
---|
1053 | // 2) Fit the Hi Gain histograms with a Gaussian
|
---|
1054 | //
|
---|
1055 | if (!hist.FitGaus())
|
---|
1056 | //
|
---|
1057 | // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
|
---|
1058 | //
|
---|
1059 | if (!hist.RepeatFit())
|
---|
1060 | {
|
---|
1061 | hist.BypassFit();
|
---|
1062 | bad.SetUncalibrated( fittyp );
|
---|
1063 | }
|
---|
1064 |
|
---|
1065 | hist.Renorm();
|
---|
1066 | //
|
---|
1067 | // 4) Check for oscillations
|
---|
1068 | //
|
---|
1069 | if (IsOscillations())
|
---|
1070 | {
|
---|
1071 | hist.CreateFourierSpectrum();
|
---|
1072 |
|
---|
1073 | if (!hist.IsFourierSpectrumOK())
|
---|
1074 | bad.SetUncalibrated( osctyp );
|
---|
1075 | }
|
---|
1076 |
|
---|
1077 | //
|
---|
1078 | // 5) Retrieve the results and store them in this class
|
---|
1079 | //
|
---|
1080 | pix.SetHiGainMean ( hist.GetMean() );
|
---|
1081 | pix.SetHiGainMeanVar ( hist.GetMeanErr() * hist.GetMeanErr() );
|
---|
1082 | pix.SetHiGainSigma ( hist.GetSigma() );
|
---|
1083 | pix.SetHiGainSigmaVar ( hist.GetSigmaErr()* hist.GetSigmaErr() );
|
---|
1084 | pix.SetHiGainProb ( hist.GetProb() );
|
---|
1085 | pix.SetHiGainNumBlackout( hist.GetBlackout() );
|
---|
1086 | pix.SetHiGainNumPickup ( hist.GetPickup() );
|
---|
1087 |
|
---|
1088 | if (IsDebug())
|
---|
1089 | {
|
---|
1090 | *fLog << dbginf << GetDescriptor() << ": ID " << hist.GetPixId()
|
---|
1091 | << " HiGainSaturation: " << pix.IsHiGainSaturation()
|
---|
1092 | << " HiGainMean: " << hist.GetMean ()
|
---|
1093 | << " HiGainMeanErr: " << hist.GetMeanErr ()
|
---|
1094 | << " HiGainMeanSigma: " << hist.GetSigma ()
|
---|
1095 | << " HiGainMeanSigmaErr: " << hist.GetSigmaErr()
|
---|
1096 | << " HiGainMeanProb: " << hist.GetProb ()
|
---|
1097 | << " HiGainNumBlackout: " << hist.GetBlackout()
|
---|
1098 | << " HiGainNumPickup : " << hist.GetPickup ()
|
---|
1099 | << endl;
|
---|
1100 | }
|
---|
1101 |
|
---|
1102 | }
|
---|
1103 |
|
---|
1104 |
|
---|
1105 | // ---------------------------------------------------------------------------
|
---|
1106 | //
|
---|
1107 | // Returns if the histogram is empty and sets the following flag:
|
---|
1108 | // - MBadPixelsPix::SetUnsuitable(MBadPixelsPix::kUnsuitableRun)
|
---|
1109 | //
|
---|
1110 | // Fits the histograms with a Gaussian, in case of failure
|
---|
1111 | // calls MHCalibrationPix::RepeatFit(), in case of repeated failure
|
---|
1112 | // calls MHCalibrationPix::BypassFit() and sets the following flags:
|
---|
1113 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t fittyp )
|
---|
1114 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
1115 | //
|
---|
1116 | // Creates the fourier spectrum and tests MHGausEvents::IsFourierSpectrumOK().
|
---|
1117 | // In case no, sets the following flags:
|
---|
1118 | // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t osctyp )
|
---|
1119 | // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )
|
---|
1120 | //
|
---|
1121 | // Retrieves the results and store them in MCalibrationPix
|
---|
1122 | //
|
---|
1123 | void MHCalibrationCam::FitLoGainHists(MHCalibrationPix &hist,
|
---|
1124 | MCalibrationPix &pix,
|
---|
1125 | MBadPixelsPix &bad,
|
---|
1126 | MBadPixelsPix::UncalibratedType_t fittyp,
|
---|
1127 | MBadPixelsPix::UncalibratedType_t osctyp)
|
---|
1128 | {
|
---|
1129 |
|
---|
1130 | if (hist.IsEmpty() || hist.IsOnlyOverflow() || hist.IsOnlyUnderflow())
|
---|
1131 | return;
|
---|
1132 |
|
---|
1133 |
|
---|
1134 | //
|
---|
1135 | // 2) Fit the Hi Gain histograms with a Gaussian
|
---|
1136 | //
|
---|
1137 | if (!hist.FitGaus())
|
---|
1138 | //
|
---|
1139 | // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
|
---|
1140 | //
|
---|
1141 | if (!hist.RepeatFit())
|
---|
1142 | {
|
---|
1143 | hist.BypassFit();
|
---|
1144 | if (pix.IsHiGainSaturation())
|
---|
1145 | bad.SetUncalibrated( fittyp );
|
---|
1146 | }
|
---|
1147 |
|
---|
1148 | //
|
---|
1149 | // 4) Check for oscillations
|
---|
1150 | //
|
---|
1151 | if (IsOscillations())
|
---|
1152 | {
|
---|
1153 | hist.CreateFourierSpectrum();
|
---|
1154 |
|
---|
1155 | if (!hist.IsFourierSpectrumOK())
|
---|
1156 | bad.SetUncalibrated( osctyp );
|
---|
1157 | }
|
---|
1158 |
|
---|
1159 | //
|
---|
1160 | // 5) Retrieve the results and store them in this class
|
---|
1161 | //
|
---|
1162 | pix.SetLoGainMean ( hist.GetMean() );
|
---|
1163 | pix.SetLoGainMeanVar ( hist.GetMeanErr() * hist.GetMeanErr() );
|
---|
1164 | pix.SetLoGainSigma ( hist.GetSigma() );
|
---|
1165 | pix.SetLoGainSigmaVar ( hist.GetSigmaErr() * hist.GetSigmaErr() );
|
---|
1166 | pix.SetLoGainProb ( hist.GetProb() );
|
---|
1167 | pix.SetLoGainNumBlackout( hist.GetBlackout() );
|
---|
1168 | pix.SetLoGainNumPickup ( hist.GetPickup() );
|
---|
1169 |
|
---|
1170 | if (IsDebug())
|
---|
1171 | {
|
---|
1172 | *fLog << dbginf << GetDescriptor() << "ID: " << hist.GetPixId()
|
---|
1173 | << " HiGainSaturation: " << pix.IsHiGainSaturation()
|
---|
1174 | << " LoGainMean: " << hist.GetMean ()
|
---|
1175 | << " LoGainMeanErr: " << hist.GetMeanErr ()
|
---|
1176 | << " LoGainMeanSigma: " << hist.GetSigma ()
|
---|
1177 | << " LoGainMeanSigmaErr: " << hist.GetSigmaErr()
|
---|
1178 | << " LoGainMeanProb: " << hist.GetProb ()
|
---|
1179 | << " LoGainNumBlackout: " << hist.GetBlackout()
|
---|
1180 | << " LoGainNumPickup : " << hist.GetPickup ()
|
---|
1181 | << endl;
|
---|
1182 | }
|
---|
1183 |
|
---|
1184 | }
|
---|
1185 |
|
---|
1186 |
|
---|
1187 |
|
---|
1188 | // -----------------------------------------------------------------------------
|
---|
1189 | //
|
---|
1190 | // Default draw:
|
---|
1191 | //
|
---|
1192 | // Displays the averaged areas, both High Gain and Low Gain
|
---|
1193 | //
|
---|
1194 | // Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
|
---|
1195 | //
|
---|
1196 | void MHCalibrationCam::Draw(const Option_t *opt)
|
---|
1197 | {
|
---|
1198 |
|
---|
1199 | if (!IsAverageing())
|
---|
1200 | return;
|
---|
1201 |
|
---|
1202 | const Int_t nareas = fAverageHiGainAreas->GetEntries();
|
---|
1203 | if (nareas == 0)
|
---|
1204 | return;
|
---|
1205 |
|
---|
1206 | TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
|
---|
1207 | pad->SetBorderMode(0);
|
---|
1208 |
|
---|
1209 | pad->Divide(IsLoGain() ? 2 : 1,nareas);
|
---|
1210 |
|
---|
1211 | for (Int_t i=0; i<nareas;i++)
|
---|
1212 | {
|
---|
1213 |
|
---|
1214 | pad->cd(IsLoGain() ? 2*(i+1)-1 : i+1);
|
---|
1215 | GetAverageHiGainArea(i).Draw(opt);
|
---|
1216 |
|
---|
1217 | if (!fAverageAreaSat[i])
|
---|
1218 | DrawAverageSigma(fAverageAreaSat[i], i,
|
---|
1219 | fAverageAreaSigma[i], fAverageAreaSigmaVar[i],
|
---|
1220 | fAverageAreaRelSigma[i], fAverageAreaRelSigmaVar[i]);
|
---|
1221 |
|
---|
1222 | if (IsLoGain())
|
---|
1223 | {
|
---|
1224 | pad->cd(2*(i+1));
|
---|
1225 | GetAverageLoGainArea(i).Draw(opt);
|
---|
1226 | }
|
---|
1227 |
|
---|
1228 | if (fAverageAreaSat[i])
|
---|
1229 | DrawAverageSigma(fAverageAreaSat[i], i,
|
---|
1230 | fAverageAreaSigma[i], fAverageAreaSigmaVar[i],
|
---|
1231 | fAverageAreaRelSigma[i], fAverageAreaRelSigmaVar[i]);
|
---|
1232 | }
|
---|
1233 |
|
---|
1234 | }
|
---|
1235 |
|
---|
1236 | // -----------------------------------------------------------------------------
|
---|
1237 | //
|
---|
1238 | // Default draw:
|
---|
1239 | //
|
---|
1240 | // Displays a TPaveText with the re-normalized sigmas of the average area
|
---|
1241 | //
|
---|
1242 | void MHCalibrationCam::DrawAverageSigma(Bool_t sat, Bool_t inner,
|
---|
1243 | Float_t sigma, Float_t sigmavar,
|
---|
1244 | Float_t relsigma, Float_t relsigmavar) const
|
---|
1245 | {
|
---|
1246 |
|
---|
1247 | if (sigma != 0 && sigmavar >= 0 && relsigmavar >= 0.)
|
---|
1248 | {
|
---|
1249 |
|
---|
1250 | TPad *newpad = new TPad("newpad","transparent",0,0,1,1);
|
---|
1251 | newpad->SetFillStyle(4000);
|
---|
1252 | newpad->Draw();
|
---|
1253 | newpad->cd();
|
---|
1254 |
|
---|
1255 | TPaveText *text = new TPaveText(sat? 0.1 : 0.35,0.7,sat ? 0.4 : 0.7,1.0);
|
---|
1256 | text->SetTextSize(0.07);
|
---|
1257 | const TString line1 = Form("%s%s%s",inner ? "Outer" : "Inner",
|
---|
1258 | " Pixels ", sat ? "Low Gain" : "High Gain");
|
---|
1259 | TText *txt1 = text->AddText(line1.Data());
|
---|
1260 | const TString line2 = Form("#sigma per pix: %2.2f #pm %2.2f",sigma,TMath::Sqrt(sigmavar));
|
---|
1261 | TText *txt2 = text->AddText(line2.Data());
|
---|
1262 | const TString line3 = Form("Rel. #sigma per pix: %2.2f #pm %2.2f",relsigma,TMath::Sqrt(relsigmavar));
|
---|
1263 | TText *txt3 = text->AddText(line3.Data());
|
---|
1264 | text->Draw("");
|
---|
1265 |
|
---|
1266 | text->SetBit(kCanDelete);
|
---|
1267 | txt1->SetBit(kCanDelete);
|
---|
1268 | txt2->SetBit(kCanDelete);
|
---|
1269 | txt3->SetBit(kCanDelete);
|
---|
1270 | newpad->SetBit(kCanDelete);
|
---|
1271 | }
|
---|
1272 | }
|
---|
1273 |
|
---|
1274 | Int_t MHCalibrationCam::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
---|
1275 | {
|
---|
1276 |
|
---|
1277 | Bool_t rc = kFALSE;
|
---|
1278 | if (IsEnvDefined(env, prefix, "Debug", print))
|
---|
1279 | {
|
---|
1280 | SetDebug(GetEnvValue(env, prefix, "Debug", IsDebug()));
|
---|
1281 | rc = kTRUE;
|
---|
1282 | }
|
---|
1283 | if (IsEnvDefined(env, prefix, "LoGain", print))
|
---|
1284 | {
|
---|
1285 | SetDebug(GetEnvValue(env, prefix, "LoGain", IsLoGain()));
|
---|
1286 | rc = kTRUE;
|
---|
1287 | }
|
---|
1288 | if (IsEnvDefined(env, prefix, "Oscillations", print))
|
---|
1289 | {
|
---|
1290 | SetOscillations(GetEnvValue(env, prefix, "Oscillations", IsOscillations()));
|
---|
1291 | rc = kTRUE;
|
---|
1292 | }
|
---|
1293 | if (IsEnvDefined(env, prefix, "SizeCheck", print))
|
---|
1294 | {
|
---|
1295 | SetSizeCheck(GetEnvValue(env, prefix, "SizeCheck", IsSizeCheck()));
|
---|
1296 | rc = kTRUE;
|
---|
1297 | }
|
---|
1298 | if (IsEnvDefined(env, prefix, "Averageing", print))
|
---|
1299 | {
|
---|
1300 | SetAverageing(GetEnvValue(env, prefix, "Averageing", IsAverageing()));
|
---|
1301 | rc = kTRUE;
|
---|
1302 | }
|
---|
1303 |
|
---|
1304 | if (IsEnvDefined(env, prefix, "Nbins", print))
|
---|
1305 | {
|
---|
1306 | SetNbins(GetEnvValue(env, prefix, "Nbins", fNbins));
|
---|
1307 | rc = kTRUE;
|
---|
1308 | }
|
---|
1309 | if (IsEnvDefined(env, prefix, "First", print))
|
---|
1310 | {
|
---|
1311 | SetFirst(GetEnvValue(env, prefix, "First", fFirst));
|
---|
1312 | rc = kTRUE;
|
---|
1313 | }
|
---|
1314 | if (IsEnvDefined(env, prefix, "Last", print))
|
---|
1315 | {
|
---|
1316 | SetLast(GetEnvValue(env, prefix, "Last", fLast));
|
---|
1317 | rc = kTRUE;
|
---|
1318 | }
|
---|
1319 |
|
---|
1320 | return rc;
|
---|
1321 | }
|
---|