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 | //
|
---|
27 | // MCalibrationChargeCalc
|
---|
28 | //
|
---|
29 | // Task to calculate the calibration conversion factors from the FADC
|
---|
30 | // time slices. The integrated time slices have to be delivered by an
|
---|
31 | // MExtractedSignalCam. The pedestals by an MPedestalCam.
|
---|
32 | //
|
---|
33 | // The output container MCalibrationCam holds one entry of type MCalibrationChargePix
|
---|
34 | // for every pixel. It is filled in the following way:
|
---|
35 | //
|
---|
36 | // ProProcess: Initialize MCalibrationCam
|
---|
37 | // Initialize pulser light wavelength
|
---|
38 | //
|
---|
39 | // ReInit: MCalibrationCam::InitSize(NumPixels) is called from MGeomApply (which allocates
|
---|
40 | // memory in a TClonesArray of type MCalibrationChargePix)
|
---|
41 | // Initializes pointer to MBadPixelsCam
|
---|
42 | //
|
---|
43 | // Process: Nothing done by this class, histograms are filled by
|
---|
44 | // MHCalibrationChargeCam
|
---|
45 | //
|
---|
46 | // PostProcess: Fit results from MHCalibrationChargeCam are retrieved
|
---|
47 | // and used for the calculation of the reduced sigma,
|
---|
48 | // the F-Factor method, the blind pixel method (photon flux
|
---|
49 | // inside plexiglass) and
|
---|
50 | // the PINDiode method (photon flux
|
---|
51 | // outside plexiglass)
|
---|
52 | //
|
---|
53 | // Hi-Gain vs. Lo-Gain Calibration (very memory-intensive)
|
---|
54 | // can be skipped with the command:
|
---|
55 | // MalibrationCam::SkipHiLoGainCalibration()
|
---|
56 | //
|
---|
57 | // Input Containers:
|
---|
58 | // MRawEvtData
|
---|
59 | // MPedestalCam
|
---|
60 | // MBadPixelsCam
|
---|
61 | //
|
---|
62 | // Output Containers:
|
---|
63 | // MCalibrationCam
|
---|
64 | // MCalibrationQECam
|
---|
65 | // MBadPixelsCam
|
---|
66 | //
|
---|
67 | //
|
---|
68 | // Preliminary description of the calibration in photons (email from 12/02/04)
|
---|
69 | //
|
---|
70 | // Why calibrating in photons:
|
---|
71 | // ===========================
|
---|
72 | //
|
---|
73 | // At the Barcelona meeting in 2002, we decided to calibrate the camera in
|
---|
74 | // photons. This for the following reasons:
|
---|
75 | //
|
---|
76 | // * The physical quantity arriving at the camera are photons. This is
|
---|
77 | // the direct physical information from the air shower. The photons
|
---|
78 | // have a flux and a spectrum.
|
---|
79 | //
|
---|
80 | // * The photon fluxes depend mostly on the shower energy (with
|
---|
81 | // corrections deriving from the observation conditions), while the photon
|
---|
82 | // spectra depend mostly on the observation conditions: zenith angle,
|
---|
83 | // quality of the air, also the impact parameter of the shower.
|
---|
84 | //
|
---|
85 | // * The photomultiplier, in turn, has different response properties
|
---|
86 | // (quantum efficiencies) for photons of different colour. (Moreover,
|
---|
87 | // different pixels have slightly different quantum efficiencies).
|
---|
88 | // The resulting number of photo-electrons is then amplified (linearly)
|
---|
89 | // with respect to the photo-electron flux.
|
---|
90 | //
|
---|
91 | // * In the ideal case, one would like to disentagle the effects
|
---|
92 | // of the observation conditions from the primary particle energy (which
|
---|
93 | // one likes to measure). To do so, one needs:
|
---|
94 | //
|
---|
95 | // 1) A reliable calibration relating the FADC counts to the photo-electron
|
---|
96 | // flux -> This is accomplished with the F-Factor method.
|
---|
97 | //
|
---|
98 | // 2) A reliable calibration of the wavelength-dependent quantum efficiency
|
---|
99 | // -> This is accomplished with the combination of the three methods,
|
---|
100 | // together with QE-measurements performed by David in order to do
|
---|
101 | // the interpolation.
|
---|
102 | //
|
---|
103 | // 3) A reliable calibration of the observation conditions. This means:
|
---|
104 | // - Tracing the atmospheric conditions -> LIDAR
|
---|
105 | // - Tracing the observation zenith angle -> Drive System
|
---|
106 | // 4) Some knowlegde about the impact parameter:
|
---|
107 | // - This is the only part which cannot be accomplished well with a
|
---|
108 | // single telescope. We would thus need to convolute the spectrum
|
---|
109 | // over the distribution of impact parameters.
|
---|
110 | //
|
---|
111 | //
|
---|
112 | // How an ideal calibration would look like:
|
---|
113 | // =========================================
|
---|
114 | //
|
---|
115 | // We know from the combined PIN-Diode and Blind-Pixel Method the response of
|
---|
116 | // each pixel to well-measured light fluxes in three representative
|
---|
117 | // wavelengths (green, blue, UV). We also know the response to these light
|
---|
118 | // fluxes in photo-electrons. Thus, we can derive:
|
---|
119 | //
|
---|
120 | // - conversion factors to photo-electrons
|
---|
121 | // - conversion factors to photons in three wavelengths.
|
---|
122 | //
|
---|
123 | // Together with David's measurements and some MC-simulation, we should be
|
---|
124 | // able to derive tables for typical Cherenkov-photon spectra - convoluted
|
---|
125 | // with the impact parameters and depending on the athmospheric conditions
|
---|
126 | // and the zenith angle (the "outer parameters").
|
---|
127 | //
|
---|
128 | // From these tables we can create "calibration tables" containing some
|
---|
129 | // effective quantum efficiency depending on these outer parameters and which
|
---|
130 | // are different for each pixel.
|
---|
131 | //
|
---|
132 | // In an ideal MCalibrate, one would thus have to convert first the FADC
|
---|
133 | // slices to Photo-electrons and then, depending on the outer parameters,
|
---|
134 | // look up the effective quantum efficiency and get the mean number of
|
---|
135 | // photons which is then used for the further analysis.
|
---|
136 | //
|
---|
137 | // How the (first) MAGIC calibration should look like:
|
---|
138 | // ===================================================
|
---|
139 | //
|
---|
140 | // For the moment, we have only one reliable calibration method, although
|
---|
141 | // with very large systematic errors. This is the F-Factor method. Knowing
|
---|
142 | // that the light is uniform over the whole camera (which I would not at all
|
---|
143 | // guarantee in the case of the CT1 pulser), one could in principle already
|
---|
144 | // perform a relative calibration of the quantum efficiencies in the UV.
|
---|
145 | // However, the spread in QE at UV is about 10-15% (according to the plot
|
---|
146 | // that Abelardo sent around last time. The spread in photo-electrons is 15%
|
---|
147 | // for the inner pixels, but much larger (40%) for the outer ones.
|
---|
148 | //
|
---|
149 | // I'm not sure if we can already say that we have measured the relative
|
---|
150 | // difference in quantum efficiency for the inner pixels and produce a first
|
---|
151 | // QE-table for each pixel. To so, I would rather check in other wavelengths
|
---|
152 | // (which we can do in about one-two weeks when the optical transmission of
|
---|
153 | // the calibration trigger is installed).
|
---|
154 | //
|
---|
155 | // Thus, for the moment being, I would join Thomas proposal to calibrate in
|
---|
156 | // photo-electrons and apply one stupid average quantum efficiency for all
|
---|
157 | // pixels. This keeping in mind that we will have much preciser information
|
---|
158 | // in about one to two weeks.
|
---|
159 | //
|
---|
160 | //
|
---|
161 | // What MCalibrate should calculate and what should be stored:
|
---|
162 | // ===========================================================
|
---|
163 | //
|
---|
164 | // It is clear that in the end, MCerPhotEvt will store photons.
|
---|
165 | // MCalibrationCam stores the conversionfactors to photo-electrons and also
|
---|
166 | // some tables of how to apply the conversion to photons, given the outer
|
---|
167 | // parameters. This is not yet implemented and not even discussed.
|
---|
168 | //
|
---|
169 | // To start, I would suggest that we define the "average quantum efficiency"
|
---|
170 | // (maybe something like 25+-3%) and apply them equally to all
|
---|
171 | // photo-electrons. Later, this average factor can be easily replaced by a
|
---|
172 | // pixel-dependent factor and later by a (pixel-dependent) table.
|
---|
173 | //
|
---|
174 | //
|
---|
175 | //
|
---|
176 | //////////////////////////////////////////////////////////////////////////////
|
---|
177 | #include "MCalibrationChargeCalc.h"
|
---|
178 |
|
---|
179 | #include <TSystem.h>
|
---|
180 | #include <TH1.h>
|
---|
181 |
|
---|
182 | #include "MLog.h"
|
---|
183 | #include "MLogManip.h"
|
---|
184 |
|
---|
185 | #include "MParList.h"
|
---|
186 |
|
---|
187 | #include "MGeomCam.h"
|
---|
188 | #include "MRawRunHeader.h"
|
---|
189 | #include "MRawEvtPixelIter.h"
|
---|
190 |
|
---|
191 | #include "MPedestalCam.h"
|
---|
192 | #include "MPedestalPix.h"
|
---|
193 |
|
---|
194 | #include "MCalibrationChargeCam.h"
|
---|
195 | #include "MCalibrationChargePix.h"
|
---|
196 | #include "MCalibrationChargePINDiode.h"
|
---|
197 | #include "MCalibrationChargeBlindPix.h"
|
---|
198 |
|
---|
199 | #include "MExtractedSignalCam.h"
|
---|
200 | #include "MExtractedSignalPix.h"
|
---|
201 |
|
---|
202 | #include "MBadPixelsCam.h"
|
---|
203 | #include "MBadPixelsPix.h"
|
---|
204 |
|
---|
205 | #include "MCalibrationQECam.h"
|
---|
206 | #include "MCalibrationQEPix.h"
|
---|
207 |
|
---|
208 |
|
---|
209 | ClassImp(MCalibrationChargeCalc);
|
---|
210 |
|
---|
211 | using namespace std;
|
---|
212 |
|
---|
213 | // --------------------------------------------------------------------------
|
---|
214 | //
|
---|
215 | // Default constructor.
|
---|
216 | //
|
---|
217 | MCalibrationChargeCalc::MCalibrationChargeCalc(const char *name, const char *title)
|
---|
218 | : fPedestals(NULL), fCam(NULL), fQECam(NULL),
|
---|
219 | fRawEvt(NULL), fRunHeader(NULL), fGeom(NULL),
|
---|
220 | fBadPixels(NULL), fEvtTime(NULL),
|
---|
221 | fSignals(NULL), fPINDiode(NULL), fBlindPixel(NULL)
|
---|
222 | {
|
---|
223 |
|
---|
224 | fName = name ? name : "MCalibrationChargeCalc";
|
---|
225 | fTitle = title ? title : "Task to calculate the calibration constants and MCalibrationCam ";
|
---|
226 |
|
---|
227 | AddToBranchList("MRawEvtData.fHiGainPixId");
|
---|
228 | AddToBranchList("MRawEvtData.fLoGainPixId");
|
---|
229 | AddToBranchList("MRawEvtData.fHiGainFadcSamples");
|
---|
230 | AddToBranchList("MRawEvtData.fLoGainFadcSamples");
|
---|
231 |
|
---|
232 | Clear();
|
---|
233 | }
|
---|
234 |
|
---|
235 | void MCalibrationChargeCalc::Clear(const Option_t *o)
|
---|
236 | {
|
---|
237 |
|
---|
238 | SETBIT(fFlags, kUseQualityChecks);
|
---|
239 | SETBIT(fFlags, kHiLoGainCalibration);
|
---|
240 |
|
---|
241 | fNumHiGainSamples = 0.;
|
---|
242 | fNumLoGainSamples = 0.;
|
---|
243 | fSqrtHiGainSamples = 0.;
|
---|
244 | fSqrtLoGainSamples = 0.;
|
---|
245 | fConversionHiLo = 0;
|
---|
246 | SkipQualityChecks ( kFALSE );
|
---|
247 | SkipHiLoGainCalibration( kFALSE );
|
---|
248 |
|
---|
249 | }
|
---|
250 |
|
---|
251 |
|
---|
252 | // --------------------------------------------------------------------------
|
---|
253 | //
|
---|
254 | // The PreProcess searches for the following input containers:
|
---|
255 | // - MRawEvtData
|
---|
256 | // - MPedestalCam
|
---|
257 | //
|
---|
258 | // The following output containers are also searched and created if
|
---|
259 | // they were not found:
|
---|
260 | //
|
---|
261 | // - MCalibrationCam
|
---|
262 | // - MCalibrationQECam
|
---|
263 | //
|
---|
264 | // The following output containers are only searched, but not created
|
---|
265 | //
|
---|
266 | // - MTime
|
---|
267 | //
|
---|
268 | Int_t MCalibrationChargeCalc::PreProcess(MParList *pList)
|
---|
269 | {
|
---|
270 |
|
---|
271 | fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
|
---|
272 | if (!fRawEvt)
|
---|
273 | {
|
---|
274 | *fLog << err << "MRawEvtData not found... aborting." << endl;
|
---|
275 | return kFALSE;
|
---|
276 | }
|
---|
277 |
|
---|
278 | fCam = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam");
|
---|
279 | if (!fCam)
|
---|
280 | return kFALSE;
|
---|
281 |
|
---|
282 | fQECam = (MCalibrationQECam*)pList->FindCreateObj("MCalibrationQECam");
|
---|
283 | if (!fQECam)
|
---|
284 | return kFALSE;
|
---|
285 |
|
---|
286 | fPINDiode = (MCalibrationChargePINDiode*)pList->FindCreateObj("MCalibrationChargePINDiode");
|
---|
287 | if (!fPINDiode)
|
---|
288 | return kFALSE;
|
---|
289 |
|
---|
290 | fBlindPixel = (MCalibrationChargeBlindPix*)pList->FindCreateObj("MCalibrationChargeBlindPix");
|
---|
291 | if (!fBlindPixel)
|
---|
292 | return kFALSE;
|
---|
293 |
|
---|
294 | fEvtTime = (MTime*)pList->FindObject("MTime");
|
---|
295 |
|
---|
296 | fPedestals = (MPedestalCam*)pList->FindObject("MPedestalCam");
|
---|
297 | if (!fPedestals)
|
---|
298 | {
|
---|
299 | *fLog << err << "MPedestalCam not found... aborting" << endl;
|
---|
300 | return kFALSE;
|
---|
301 | }
|
---|
302 |
|
---|
303 | fSignals = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
|
---|
304 | if (!fSignals)
|
---|
305 | {
|
---|
306 | *fLog << err << "MExtractedSignalCam not found... aborting" << endl;
|
---|
307 | return kFALSE;
|
---|
308 | }
|
---|
309 |
|
---|
310 | return kTRUE;
|
---|
311 | }
|
---|
312 |
|
---|
313 |
|
---|
314 | // --------------------------------------------------------------------------
|
---|
315 | //
|
---|
316 | // The ReInit searches for the following input containers:
|
---|
317 | // - MRawRunHeader
|
---|
318 | // - MGeomCam
|
---|
319 | // - MBadPixelsCam
|
---|
320 | //
|
---|
321 | // It retrieves the following variables from MExtractedSignalCam:
|
---|
322 | //
|
---|
323 | // fNumHiGainSamples
|
---|
324 | // fNumLoGainSamples
|
---|
325 | //
|
---|
326 | // fFirstUsedSliceHiGain
|
---|
327 | // fLastUsedSliceHiGain
|
---|
328 | // fFirstUsedSliceLoGain
|
---|
329 | // fLastUsedSliceLoGain
|
---|
330 | //
|
---|
331 | // It defines the PixId of every pixel in MCalibrationChargeCam and MCalibrationQECam
|
---|
332 | // It sets all pixels excluded which have the flag fBadBixelsPix::IsBad() set.
|
---|
333 | //
|
---|
334 | Bool_t MCalibrationChargeCalc::ReInit(MParList *pList )
|
---|
335 | {
|
---|
336 |
|
---|
337 | fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
---|
338 | if (!fRunHeader)
|
---|
339 | {
|
---|
340 | *fLog << err << "MRawRunHeader not found... aborting." << endl;
|
---|
341 | return kFALSE;
|
---|
342 | }
|
---|
343 |
|
---|
344 | fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
|
---|
345 | if (!fGeom)
|
---|
346 | {
|
---|
347 | *fLog << err << "No MGeomCam found... aborting." << endl;
|
---|
348 | return kFALSE;
|
---|
349 | }
|
---|
350 |
|
---|
351 | fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
|
---|
352 | if (!fBadPixels)
|
---|
353 | {
|
---|
354 | *fLog << err << "Could not find or create MBadPixelsCam ... aborting." << endl;
|
---|
355 | return kFALSE;
|
---|
356 | }
|
---|
357 |
|
---|
358 | fNumHiGainSamples = fSignals->GetNumUsedHiGainFADCSlices();
|
---|
359 | fNumLoGainSamples = fSignals->GetNumUsedLoGainFADCSlices();
|
---|
360 | fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
|
---|
361 | fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
|
---|
362 |
|
---|
363 | UInt_t npixels = fGeom->GetNumPixels();
|
---|
364 |
|
---|
365 | for (UInt_t i=0; i<npixels; i++)
|
---|
366 | {
|
---|
367 |
|
---|
368 | MCalibrationChargePix &pix = (*fCam) [i];
|
---|
369 | MCalibrationQEPix &pqe = (*fQECam) [i];
|
---|
370 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
371 |
|
---|
372 | pix.SetPixId(i);
|
---|
373 | pqe.SetPixId(i);
|
---|
374 |
|
---|
375 | if (bad.IsBad())
|
---|
376 | {
|
---|
377 | pix.SetExcluded();
|
---|
378 | pqe.SetExcluded();
|
---|
379 | continue;
|
---|
380 | }
|
---|
381 |
|
---|
382 | pix.SetAbsTimeBordersHiGain(fSignals->GetFirstUsedSliceHiGain(),
|
---|
383 | fSignals->GetLastUsedSliceHiGain());
|
---|
384 | pix.SetAbsTimeBordersLoGain(fSignals->GetFirstUsedSliceLoGain(),
|
---|
385 | fSignals->GetLastUsedSliceLoGain());
|
---|
386 | }
|
---|
387 |
|
---|
388 | return kTRUE;
|
---|
389 | }
|
---|
390 |
|
---|
391 |
|
---|
392 | Int_t MCalibrationChargeCalc::Process()
|
---|
393 | {
|
---|
394 | return kTRUE;
|
---|
395 | }
|
---|
396 |
|
---|
397 | // --------------------------------------------------------------------------
|
---|
398 | //
|
---|
399 | // Finalize pedestals:
|
---|
400 | //
|
---|
401 | // * Retrieve pedestal and pedestal RMS from MPedestalPix
|
---|
402 | // * Retrieve total entries from MPedestalCam
|
---|
403 | // * sum up pedestal and pedestalRMS for the average pixel
|
---|
404 | // * set pedestal*number of used samples in MCalibrationChargePix
|
---|
405 | // * set pedestal RMS * sqrt of number of used samples in MCalibrationChargePix
|
---|
406 | //
|
---|
407 | //
|
---|
408 | void MCalibrationChargeCalc::FinalizePedestals(const MPedestalPix &ped, MCalibrationChargePix &cal,
|
---|
409 | Float_t &avped, Float_t &avrms)
|
---|
410 | {
|
---|
411 |
|
---|
412 | //
|
---|
413 | // get the pedestals
|
---|
414 | //
|
---|
415 | const Float_t pedes = ped.GetPedestal();
|
---|
416 | const Float_t prms = ped.GetPedestalRms();
|
---|
417 | const Float_t num = TMath::Sqrt((Float_t)fPedestals->GetTotalEntries());
|
---|
418 |
|
---|
419 | //
|
---|
420 | // Calculate the average pedestal
|
---|
421 | //
|
---|
422 | avped += pedes;
|
---|
423 | avrms += prms;
|
---|
424 |
|
---|
425 | //
|
---|
426 | // set them in the calibration camera
|
---|
427 | //
|
---|
428 | if (cal.IsHiGainSaturation())
|
---|
429 | {
|
---|
430 | cal.SetPedestal(pedes* fNumLoGainSamples,
|
---|
431 | prms * fSqrtLoGainSamples,
|
---|
432 | prms * fNumLoGainSamples / num);
|
---|
433 | cal.CalcLoGainPedestal((Float_t)fNumLoGainSamples);
|
---|
434 | }
|
---|
435 | else
|
---|
436 | {
|
---|
437 | cal.SetPedestal(pedes* fNumHiGainSamples,
|
---|
438 | prms * fSqrtHiGainSamples,
|
---|
439 | prms * fNumHiGainSamples / num);
|
---|
440 | }
|
---|
441 |
|
---|
442 | }
|
---|
443 |
|
---|
444 | void MCalibrationChargeCalc::FinalizeAvPedestals(MCalibrationChargePix &cal,
|
---|
445 | Float_t avped, Float_t avrms, Int_t avnum)
|
---|
446 | {
|
---|
447 |
|
---|
448 | //
|
---|
449 | // set the pedestans in the calibration camera
|
---|
450 | //
|
---|
451 | if (cal.IsHiGainSaturation())
|
---|
452 | {
|
---|
453 | cal.SetPedestal(avped/avnum * fNumLoGainSamples,
|
---|
454 | avrms/avnum * fSqrtLoGainSamples,
|
---|
455 | avrms/avnum * fSqrtLoGainSamples/avnum);
|
---|
456 | cal.CalcLoGainPedestal((Float_t)fNumLoGainSamples);
|
---|
457 | }
|
---|
458 | else
|
---|
459 | {
|
---|
460 | cal.SetPedestal(avped/avnum * fNumHiGainSamples,
|
---|
461 | avrms/avnum * fSqrtHiGainSamples,
|
---|
462 | avrms/avnum * fSqrtHiGainSamples/avnum);
|
---|
463 | }
|
---|
464 | }
|
---|
465 |
|
---|
466 | //
|
---|
467 | // Finalize charges per pixel:
|
---|
468 | // * Check chage validity
|
---|
469 | // * check absolute time validity
|
---|
470 | // * calculate the reduced sigma
|
---|
471 | // * caluclate the number of photo-electrons
|
---|
472 | //
|
---|
473 | //
|
---|
474 | Bool_t MCalibrationChargeCalc::FinalizeCharges(MCalibrationChargePix &cal, MBadPixelsPix &bad)
|
---|
475 | {
|
---|
476 |
|
---|
477 | cal.CheckChargeValidity (&bad);
|
---|
478 | cal.CheckTimeValidity (&bad);
|
---|
479 |
|
---|
480 | if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
---|
481 | return kFALSE;
|
---|
482 |
|
---|
483 | if (!cal.CalcReducedSigma())
|
---|
484 | {
|
---|
485 | *fLog << warn << GetDescriptor()
|
---|
486 | << ": Could not calculate reduced sigmas of pixel: " << cal.GetPixId() << endl;
|
---|
487 | bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
|
---|
488 | return kFALSE;
|
---|
489 | }
|
---|
490 |
|
---|
491 | if (!cal.CalcFFactorMethod())
|
---|
492 | {
|
---|
493 | *fLog << warn << GetDescriptor()
|
---|
494 | << ": Could not calculate F-Factor of pixel: " << cal.GetPixId() << endl;
|
---|
495 | bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
|
---|
496 | return kFALSE;
|
---|
497 | }
|
---|
498 | return kTRUE;
|
---|
499 | }
|
---|
500 |
|
---|
501 | //
|
---|
502 | // * Finalize the pedestals
|
---|
503 | // * Do the quality checks
|
---|
504 | // * Calculate the reduced sigma
|
---|
505 | // * Calculate the F-Factor Method
|
---|
506 | //
|
---|
507 | Int_t MCalibrationChargeCalc::PostProcess()
|
---|
508 | {
|
---|
509 |
|
---|
510 | if (GetNumExecutions()==0)
|
---|
511 | return kFALSE;
|
---|
512 |
|
---|
513 | //
|
---|
514 | // loop over the pedestal events and check if we have calibration
|
---|
515 | //
|
---|
516 | Int_t nvalid = 0;
|
---|
517 | Float_t avinnerped = 0.;
|
---|
518 | Float_t avinnerprms = 0.;
|
---|
519 | Int_t avinnernum = 0;
|
---|
520 | Float_t avouterped = 0.;
|
---|
521 | Float_t avouterprms = 0.;
|
---|
522 | Int_t avouternum = 0;
|
---|
523 |
|
---|
524 | for (Int_t pixid=0; pixid<fPedestals->GetSize(); pixid++)
|
---|
525 | {
|
---|
526 |
|
---|
527 | MCalibrationChargePix &pix = (*fCam)[pixid];
|
---|
528 | //
|
---|
529 | // Check if the pixel has been excluded from the fits
|
---|
530 | //
|
---|
531 | if (pix.IsExcluded())
|
---|
532 | continue;
|
---|
533 |
|
---|
534 | MPedestalPix &ped = (*fPedestals)[pixid];
|
---|
535 | MBadPixelsPix &bad = (*fBadPixels)[pixid];
|
---|
536 |
|
---|
537 | if (fGeom->GetPixRatio(pixid) == 1.)
|
---|
538 | {
|
---|
539 | FinalizePedestals(ped,pix,avinnerped,avinnerprms);
|
---|
540 | avinnernum++;
|
---|
541 | }
|
---|
542 | else
|
---|
543 | {
|
---|
544 | FinalizePedestals(ped,pix,avouterped,avouterprms);
|
---|
545 | avouternum++;
|
---|
546 | }
|
---|
547 |
|
---|
548 | if (FinalizeCharges(pix,bad))
|
---|
549 | nvalid++;
|
---|
550 | }
|
---|
551 |
|
---|
552 | //
|
---|
553 | // The Michele check ...
|
---|
554 | //
|
---|
555 | if (nvalid == 0)
|
---|
556 | {
|
---|
557 | *fLog << err << GetDescriptor() << ": All pixels have non-valid calibration. "
|
---|
558 | << "Did you forget to fill the histograms "
|
---|
559 | << "(filling MHCalibrationChargeCam from MExtractedSignalCam using MFillH) ? " << endl;
|
---|
560 | *fLog << err << GetDescriptor() << ": Or, maybe, you have used a pedestal run "
|
---|
561 | << "instead of a calibration run " << endl;
|
---|
562 | return kFALSE;
|
---|
563 | }
|
---|
564 |
|
---|
565 | FinalizeAvPedestals(*fCam->GetAverageInnerPix(), avinnerped, avinnerprms,avinnernum);
|
---|
566 | FinalizeAvPedestals(*fCam->GetAverageOuterPix(), avouterped, avouterprms,avouternum);
|
---|
567 |
|
---|
568 | FinalizeCharges(*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
|
---|
569 | FinalizeCharges(*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix());
|
---|
570 |
|
---|
571 | //
|
---|
572 | // F-Factor calibration
|
---|
573 | //
|
---|
574 | if (fCam->CalcMeanFluxPhotonsFFactorMethod(*fGeom, *fBadPixels))
|
---|
575 | {
|
---|
576 | fCam->ApplyFFactorCalibration(*fGeom,*fBadPixels);
|
---|
577 | fCam->SetFFactorMethodValid(kTRUE);
|
---|
578 | }
|
---|
579 | else
|
---|
580 | {
|
---|
581 | *fLog << warn << "Could not calculate the flux of photo-electrons from the F-Factor method, " << endl;
|
---|
582 | fCam->SetFFactorMethodValid(kFALSE);
|
---|
583 | }
|
---|
584 |
|
---|
585 | //
|
---|
586 | // Blind Pixel calibration
|
---|
587 | //
|
---|
588 | if (!fBlindPixel->CheckChargeFitValidity())
|
---|
589 | {
|
---|
590 | *fLog << warn << "Could not calculate the flux of photons from the Blind Pixel, "
|
---|
591 | << "charge fit not valid " << endl;
|
---|
592 | fCam->SetBlindPixelMethodValid(kFALSE);
|
---|
593 | }
|
---|
594 | else
|
---|
595 | {
|
---|
596 | if (!fBlindPixel->CalcFluxInsidePlexiglass())
|
---|
597 | {
|
---|
598 | *fLog << warn << "Could not calculate the flux of photons from the Blind Pixel, "
|
---|
599 | << "will skip PIN Diode Calibration " << endl;
|
---|
600 | fCam->SetBlindPixelMethodValid(kFALSE);
|
---|
601 | }
|
---|
602 | else
|
---|
603 | {
|
---|
604 | fCam->SetBlindPixelMethodValid(kTRUE);
|
---|
605 | fCam->ApplyBlindPixelCalibration(*fGeom,*fBadPixels, *fBlindPixel);
|
---|
606 | }
|
---|
607 | }
|
---|
608 |
|
---|
609 | //
|
---|
610 | // PIN Diode calibration
|
---|
611 | //
|
---|
612 | if (!fPINDiode->CheckChargeFitValidity() || !fPINDiode->CheckTimeFitValidity())
|
---|
613 | {
|
---|
614 | *fLog << warn << "Could not calculate the flux of photons from the PIN Diode, "
|
---|
615 | << "charge fit not valid " << endl;
|
---|
616 | fCam->SetPINDiodeMethodValid(kFALSE);
|
---|
617 | }
|
---|
618 | else
|
---|
619 | {
|
---|
620 | if (!fPINDiode->CalcFluxOutsidePlexiglass())
|
---|
621 | {
|
---|
622 | *fLog << warn << "Could not calculate the flux of photons from the PIN Diode, "
|
---|
623 | << "will skip PIN Diode Calibration " << endl;
|
---|
624 | fCam->SetPINDiodeMethodValid(kFALSE);
|
---|
625 | }
|
---|
626 | else
|
---|
627 | {
|
---|
628 | fCam->SetPINDiodeMethodValid(kTRUE);
|
---|
629 | fCam->ApplyPINDiodeCalibration(*fGeom,*fBadPixels, *fPINDiode);
|
---|
630 | }
|
---|
631 | }
|
---|
632 |
|
---|
633 | fCam->SetReadyToSave();
|
---|
634 |
|
---|
635 | PrintInfo();
|
---|
636 |
|
---|
637 | return kTRUE;
|
---|
638 | }
|
---|
639 |
|
---|
640 | void MCalibrationChargeCalc::PrintInfo()
|
---|
641 | {
|
---|
642 |
|
---|
643 | *fLog << inf << endl;
|
---|
644 | *fLog << GetDescriptor() << ": Calibration statistics:" << endl;
|
---|
645 | *fLog << dec << setfill(' ');
|
---|
646 |
|
---|
647 | UInt_t countinner = 0;
|
---|
648 | UInt_t countouter = 0;
|
---|
649 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
650 | {
|
---|
651 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
652 | if (bad.IsOK())
|
---|
653 | {
|
---|
654 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
655 | countinner++;
|
---|
656 | else
|
---|
657 | countouter++;
|
---|
658 | }
|
---|
659 | }
|
---|
660 |
|
---|
661 | *fLog << " " << setw(7) << "Successfully calibrated Pixels: "
|
---|
662 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
663 |
|
---|
664 | countinner = 0;
|
---|
665 | countouter = 0;
|
---|
666 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
667 | {
|
---|
668 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
669 | if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
---|
670 | {
|
---|
671 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
672 | countinner++;
|
---|
673 | else
|
---|
674 | countouter++;
|
---|
675 | }
|
---|
676 | }
|
---|
677 |
|
---|
678 | *fLog << " " << setw(7) << "Bad Pixels: "
|
---|
679 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
680 |
|
---|
681 | countinner = 0;
|
---|
682 | countouter = 0;
|
---|
683 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
684 | {
|
---|
685 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
686 | if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
|
---|
687 | {
|
---|
688 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
689 | countinner++;
|
---|
690 | else
|
---|
691 | countouter++;
|
---|
692 | }
|
---|
693 | }
|
---|
694 |
|
---|
695 | *fLog << " " << setw(7) << "Unreliable Pixels: "
|
---|
696 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
697 |
|
---|
698 | *fLog << inf << endl;
|
---|
699 | *fLog << GetDescriptor() << ": Errors statistics:" << endl;
|
---|
700 |
|
---|
701 | countinner = 0;
|
---|
702 | countouter = 0;
|
---|
703 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
704 | {
|
---|
705 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
706 | if (bad.IsChargeIsPedestal())
|
---|
707 | {
|
---|
708 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
709 | countinner++;
|
---|
710 | else
|
---|
711 | countouter++;
|
---|
712 | }
|
---|
713 | }
|
---|
714 |
|
---|
715 | *fLog << " " << setw(7) << "Signal less than 3 Pedestal RMS: "
|
---|
716 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
717 |
|
---|
718 | countinner = 0;
|
---|
719 | countouter = 0;
|
---|
720 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
721 | {
|
---|
722 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
723 | if (bad.IsChargeErrNotValid())
|
---|
724 | {
|
---|
725 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
726 | countinner++;
|
---|
727 | else
|
---|
728 | countouter++;
|
---|
729 | }
|
---|
730 | }
|
---|
731 |
|
---|
732 | *fLog << " " << setw(7) << "Signal Error smaller than 0: "
|
---|
733 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
734 |
|
---|
735 | countinner = 0;
|
---|
736 | countouter = 0;
|
---|
737 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
738 | {
|
---|
739 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
740 | if (bad.IsChargeRelErrNotValid())
|
---|
741 | {
|
---|
742 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
743 | countinner++;
|
---|
744 | else
|
---|
745 | countouter++;
|
---|
746 | }
|
---|
747 | }
|
---|
748 |
|
---|
749 | *fLog << " " << setw(7) << "Signal Error bigger than Mean Signal: "
|
---|
750 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
751 |
|
---|
752 | countinner = 0;
|
---|
753 | countouter = 0;
|
---|
754 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
755 | {
|
---|
756 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
757 | if (bad.IsChargeSigmaNotValid())
|
---|
758 | {
|
---|
759 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
760 | countinner++;
|
---|
761 | else
|
---|
762 | countouter++;
|
---|
763 | }
|
---|
764 | }
|
---|
765 |
|
---|
766 | *fLog << " " << setw(7) << "Signal Sigma smaller than Pedestal RMS: "
|
---|
767 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
768 |
|
---|
769 | countinner = 0;
|
---|
770 | countouter = 0;
|
---|
771 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
772 | {
|
---|
773 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
774 | if (bad.IsLoGainSaturation())
|
---|
775 | {
|
---|
776 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
777 | countinner++;
|
---|
778 | else
|
---|
779 | countouter++;
|
---|
780 | }
|
---|
781 | }
|
---|
782 |
|
---|
783 | *fLog << " " << setw(7) << "Pixels with Low Gain Saturation: "
|
---|
784 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
785 |
|
---|
786 | countinner = 0;
|
---|
787 | countouter = 0;
|
---|
788 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
789 | {
|
---|
790 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
791 | if (bad.IsMeanTimeInFirstBin())
|
---|
792 | {
|
---|
793 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
794 | countinner++;
|
---|
795 | else
|
---|
796 | countouter++;
|
---|
797 | }
|
---|
798 | }
|
---|
799 |
|
---|
800 | *fLog << " " << setw(7) << "Pixels with Mean Abs. Arr. Time in First Bin: "
|
---|
801 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
802 |
|
---|
803 | countinner = 0;
|
---|
804 | countouter = 0;
|
---|
805 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
806 | {
|
---|
807 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
808 | if (bad.IsMeanTimeInLastBin())
|
---|
809 | {
|
---|
810 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
811 | countinner++;
|
---|
812 | else
|
---|
813 | countouter++;
|
---|
814 | }
|
---|
815 | }
|
---|
816 |
|
---|
817 | *fLog << " " << setw(7) << "Pixels with Mean Abs. Arr. Time in Last 2 Bins: "
|
---|
818 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
819 |
|
---|
820 | countinner = 0;
|
---|
821 | countouter = 0;
|
---|
822 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
823 | {
|
---|
824 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
825 | if (bad.IsHiGainOscillating())
|
---|
826 | {
|
---|
827 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
828 | countinner++;
|
---|
829 | else
|
---|
830 | countouter++;
|
---|
831 | }
|
---|
832 | }
|
---|
833 |
|
---|
834 | *fLog << " " << setw(7) << "Pixels with changing Hi Gain signal over time: "
|
---|
835 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
836 |
|
---|
837 | countinner = 0;
|
---|
838 | countouter = 0;
|
---|
839 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
840 | {
|
---|
841 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
842 | if (bad.IsLoGainOscillating())
|
---|
843 | {
|
---|
844 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
845 | countinner++;
|
---|
846 | else
|
---|
847 | countouter++;
|
---|
848 | }
|
---|
849 | }
|
---|
850 |
|
---|
851 | *fLog << " " << setw(7) << "Pixels with changing Lo Gain signal over time: "
|
---|
852 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
853 |
|
---|
854 | countinner = 0;
|
---|
855 | countouter = 0;
|
---|
856 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
857 | {
|
---|
858 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
859 | if (!bad.IsCalibrationFitOK())
|
---|
860 | {
|
---|
861 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
862 | countinner++;
|
---|
863 | else
|
---|
864 | countouter++;
|
---|
865 | }
|
---|
866 | }
|
---|
867 |
|
---|
868 | *fLog << " " << setw(7) << "Pixels with unsuccessful signal fit: "
|
---|
869 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
870 |
|
---|
871 | countinner = 0;
|
---|
872 | countouter = 0;
|
---|
873 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
874 | {
|
---|
875 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
876 | if (bad.IsDeviatingNumPhes())
|
---|
877 | {
|
---|
878 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
879 | countinner++;
|
---|
880 | else
|
---|
881 | countouter++;
|
---|
882 | }
|
---|
883 | }
|
---|
884 |
|
---|
885 | *fLog << " " << setw(7) << "Pixels with deviating number of phes: "
|
---|
886 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
887 |
|
---|
888 | }
|
---|