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 and quantum efficiencies
|
---|
30 | // from the fit results to the summed FADC slice distributions delivered by
|
---|
31 | // MCalibrationChargeCam, MCalibrationChargePix, MCalibrationChargeBlindPix and
|
---|
32 | // MCalibrationChargePINDiode, calculated and filled by MHCalibrationChargeCam,
|
---|
33 | // MHCalibrationChargePix, MHCalibrationChargeBlindPix and MHCalibrationChargePINDiode.
|
---|
34 | //
|
---|
35 | // PreProcess(): Initialize pointers to MCalibrationChargeCam, MCalibrationChargeBlindPix
|
---|
36 | // MCalibrationChargePINDiode and MCalibrationQECam
|
---|
37 | //
|
---|
38 | // Initialize pulser light wavelength
|
---|
39 | //
|
---|
40 | // ReInit(): MCalibrationCam::InitSize(NumPixels) is called from MGeomApply (which allocates
|
---|
41 | // memory in a TClonesArray of type MCalibrationChargePix)
|
---|
42 | // Initializes pointer to MBadPixelsCam
|
---|
43 | //
|
---|
44 | // Process(): Nothing to be done, histograms getting filled by MHCalibrationChargeCam
|
---|
45 | //
|
---|
46 | // PostProcess(): - FinalizePedestals()
|
---|
47 | // - FinalizeAvPedestals()
|
---|
48 | // - FinalizeCharges()
|
---|
49 | // - FinalizeFFactorMethod()
|
---|
50 | // - FinalizeBadPixels()
|
---|
51 | // - FinalizeBlindPixel()
|
---|
52 | // - FinalizePINDiode()
|
---|
53 | // - FinalizeFFactorQECam()
|
---|
54 | // - FinalizeBlindPixelQECam()
|
---|
55 | // - FinalizePINDiodeQECam()
|
---|
56 | //
|
---|
57 | // Input Containers:
|
---|
58 | // MCalibrationChargeCam
|
---|
59 | // MCalibrationChargeBlindPix
|
---|
60 | // MCalibrationChargePINDiode
|
---|
61 | // MCalibrationQECam
|
---|
62 | // MExtractedSignalCam
|
---|
63 | // MExtractedSignalBlindPixel
|
---|
64 | // MExtractedSignalPINDiode
|
---|
65 | // MPedestalCam
|
---|
66 | // MBadPixelsCam
|
---|
67 | // MGeomCam
|
---|
68 | // MTime
|
---|
69 | //
|
---|
70 | // Output Containers:
|
---|
71 | // MCalibrationChargeCam
|
---|
72 | // MCalibrationChargeBlindPix
|
---|
73 | // MCalibrationChargePINDiode
|
---|
74 | // MCalibrationQECam
|
---|
75 | // MBadPixelsCam
|
---|
76 | //
|
---|
77 | //
|
---|
78 | // Preliminary description of the calibration in photons (email from 12/02/04)
|
---|
79 | //
|
---|
80 | // Why calibrating in photons:
|
---|
81 | // ===========================
|
---|
82 | //
|
---|
83 | // At the Barcelona meeting in 2002, we decided to calibrate the camera in
|
---|
84 | // photons. This for the following reasons:
|
---|
85 | //
|
---|
86 | // * The physical quantity arriving at the camera are photons. This is
|
---|
87 | // the direct physical information from the air shower. The photons
|
---|
88 | // have a flux and a spectrum.
|
---|
89 | //
|
---|
90 | // * The photon fluxes depend mostly on the shower energy (with
|
---|
91 | // corrections deriving from the observation conditions), while the photon
|
---|
92 | // spectra depend mostly on the observation conditions: zenith angle,
|
---|
93 | // quality of the air, also the impact parameter of the shower.
|
---|
94 | //
|
---|
95 | // * The photomultiplier, in turn, has different response properties
|
---|
96 | // (quantum efficiencies) for photons of different colour. (Moreover,
|
---|
97 | // different pixels have slightly different quantum efficiencies).
|
---|
98 | // The resulting number of photo-electrons is then amplified (linearly)
|
---|
99 | // with respect to the photo-electron flux.
|
---|
100 | //
|
---|
101 | // * In the ideal case, one would like to disentagle the effects
|
---|
102 | // of the observation conditions from the primary particle energy (which
|
---|
103 | // one likes to measure). To do so, one needs:
|
---|
104 | //
|
---|
105 | // 1) A reliable calibration relating the FADC counts to the photo-electron
|
---|
106 | // flux -> This is accomplished with the F-Factor method.
|
---|
107 | //
|
---|
108 | // 2) A reliable calibration of the wavelength-dependent quantum efficiency
|
---|
109 | // -> This is accomplished with the combination of the three methods,
|
---|
110 | // together with QE-measurements performed by David in order to do
|
---|
111 | // the interpolation.
|
---|
112 | //
|
---|
113 | // 3) A reliable calibration of the observation conditions. This means:
|
---|
114 | // - Tracing the atmospheric conditions -> LIDAR
|
---|
115 | // - Tracing the observation zenith angle -> Drive System
|
---|
116 | //
|
---|
117 | // 4) Some knowlegde about the impact parameter:
|
---|
118 | // - This is the only part which cannot be accomplished well with a
|
---|
119 | // single telescope. We would thus need to convolute the spectrum
|
---|
120 | // over the distribution of impact parameters.
|
---|
121 | //
|
---|
122 | //
|
---|
123 | // How an ideal calibration would look like:
|
---|
124 | // =========================================
|
---|
125 | //
|
---|
126 | // We know from the combined PIN-Diode and Blind-Pixel Method the response of
|
---|
127 | // each pixel to well-measured light fluxes in three representative
|
---|
128 | // wavelengths (green, blue, UV). We also know the response to these light
|
---|
129 | // fluxes in photo-electrons. Thus, we can derive:
|
---|
130 | //
|
---|
131 | // - conversion factors to photo-electrons
|
---|
132 | // - conversion factors to photons in three wavelengths.
|
---|
133 | //
|
---|
134 | // Together with David's measurements and some MC-simulation, we should be
|
---|
135 | // able to derive tables for typical Cherenkov-photon spectra - convoluted
|
---|
136 | // with the impact parameters and depending on the athmospheric conditions
|
---|
137 | // and the zenith angle (the "outer parameters").
|
---|
138 | //
|
---|
139 | // From these tables we can create "calibration tables" containing some
|
---|
140 | // effective quantum efficiency depending on these outer parameters and which
|
---|
141 | // are different for each pixel.
|
---|
142 | //
|
---|
143 | // In an ideal MCalibrate, one would thus have to convert first the FADC
|
---|
144 | // slices to Photo-electrons and then, depending on the outer parameters,
|
---|
145 | // look up the effective quantum efficiency and get the mean number of
|
---|
146 | // photons which is then used for the further analysis.
|
---|
147 | //
|
---|
148 | // How the (first) MAGIC calibration should look like:
|
---|
149 | // ===================================================
|
---|
150 | //
|
---|
151 | // For the moment, we have only one reliable calibration method, although
|
---|
152 | // with very large systematic errors. This is the F-Factor method. Knowing
|
---|
153 | // that the light is uniform over the whole camera (which I would not at all
|
---|
154 | // guarantee in the case of the CT1 pulser), one could in principle already
|
---|
155 | // perform a relative calibration of the quantum efficiencies in the UV.
|
---|
156 | // However, the spread in QE at UV is about 10-15% (according to the plot
|
---|
157 | // that Abelardo sent around last time. The spread in photo-electrons is 15%
|
---|
158 | // for the inner pixels, but much larger (40%) for the outer ones.
|
---|
159 | //
|
---|
160 | // I'm not sure if we can already say that we have measured the relative
|
---|
161 | // difference in quantum efficiency for the inner pixels and produce a first
|
---|
162 | // QE-table for each pixel. To so, I would rather check in other wavelengths
|
---|
163 | // (which we can do in about one-two weeks when the optical transmission of
|
---|
164 | // the calibration trigger is installed).
|
---|
165 | //
|
---|
166 | // Thus, for the moment being, I would join Thomas proposal to calibrate in
|
---|
167 | // photo-electrons and apply one stupid average quantum efficiency for all
|
---|
168 | // pixels. This keeping in mind that we will have much preciser information
|
---|
169 | // in about one to two weeks.
|
---|
170 | //
|
---|
171 | //
|
---|
172 | // What MCalibrate should calculate and what should be stored:
|
---|
173 | // ===========================================================
|
---|
174 | //
|
---|
175 | // It is clear that in the end, MCerPhotEvt will store photons.
|
---|
176 | // MCalibrationCam stores the conversionfactors to photo-electrons and also
|
---|
177 | // some tables of how to apply the conversion to photons, given the outer
|
---|
178 | // parameters. This is not yet implemented and not even discussed.
|
---|
179 | //
|
---|
180 | // To start, I would suggest that we define the "average quantum efficiency"
|
---|
181 | // (maybe something like 25+-3%) and apply them equally to all
|
---|
182 | // photo-electrons. Later, this average factor can be easily replaced by a
|
---|
183 | // pixel-dependent factor and later by a (pixel-dependent) table.
|
---|
184 | //
|
---|
185 | //
|
---|
186 | //
|
---|
187 | //////////////////////////////////////////////////////////////////////////////
|
---|
188 | #include "MCalibrationChargeCalc.h"
|
---|
189 |
|
---|
190 | #include <TSystem.h>
|
---|
191 | #include <TH1.h>
|
---|
192 |
|
---|
193 | #include "MLog.h"
|
---|
194 | #include "MLogManip.h"
|
---|
195 |
|
---|
196 | #include "MParList.h"
|
---|
197 |
|
---|
198 | #include "MRawRunHeader.h"
|
---|
199 | #include "MRawEvtPixelIter.h"
|
---|
200 |
|
---|
201 | #include "MGeomCam.h"
|
---|
202 | #include "MGeomPix.h"
|
---|
203 |
|
---|
204 | #include "MPedestalCam.h"
|
---|
205 | #include "MPedestalPix.h"
|
---|
206 |
|
---|
207 | #include "MCalibrationChargeCam.h"
|
---|
208 | #include "MCalibrationChargePix.h"
|
---|
209 | #include "MCalibrationChargePINDiode.h"
|
---|
210 | #include "MCalibrationChargeBlindPix.h"
|
---|
211 |
|
---|
212 | #include "MExtractedSignalCam.h"
|
---|
213 | #include "MExtractedSignalPix.h"
|
---|
214 | #include "MExtractedSignalBlindPixel.h"
|
---|
215 | #include "MExtractedSignalPINDiode.h"
|
---|
216 |
|
---|
217 | #include "MBadPixelsCam.h"
|
---|
218 | #include "MBadPixelsPix.h"
|
---|
219 |
|
---|
220 | #include "MCalibrationQECam.h"
|
---|
221 | #include "MCalibrationQEPix.h"
|
---|
222 |
|
---|
223 | #include "MCalibrationCam.h"
|
---|
224 |
|
---|
225 | ClassImp(MCalibrationChargeCalc);
|
---|
226 |
|
---|
227 | using namespace std;
|
---|
228 |
|
---|
229 | const Float_t MCalibrationChargeCalc::fgChargeLimit = 3.;
|
---|
230 | const Float_t MCalibrationChargeCalc::fgChargeErrLimit = 0.;
|
---|
231 | const Float_t MCalibrationChargeCalc::fgChargeRelErrLimit = 1.;
|
---|
232 | const Float_t MCalibrationChargeCalc::fgLambdaErrLimit = 0.2;
|
---|
233 | const Float_t MCalibrationChargeCalc::fgLambdaCheckLimit = 0.2;
|
---|
234 | const Float_t MCalibrationChargeCalc::fgPheErrLimit = 5.;
|
---|
235 | // --------------------------------------------------------------------------
|
---|
236 | //
|
---|
237 | // Default constructor.
|
---|
238 | //
|
---|
239 | // Sets all pointers to NULL
|
---|
240 | //
|
---|
241 | // Calls AddToBranchList for:
|
---|
242 | // - MRawEvtData.fHiGainPixId
|
---|
243 | // - MRawEvtData.fLoGainPixId
|
---|
244 | // - MRawEvtData.fHiGainFadcSamples
|
---|
245 | // - MRawEvtData.fLoGainFadcSamples
|
---|
246 | //
|
---|
247 | // Initializes:
|
---|
248 | // - fChargeLimit to fgChargeLimit
|
---|
249 | // - fChargeErrLimit to fgChargeErrLimit
|
---|
250 | // - fChargeRelErrLimit to fgChargeRelErrLimit
|
---|
251 | // - fLambdaCheckLimit to fgLambdaCheckLimit
|
---|
252 | // - fLambdaErrLimit to fgLambdaErrLimit
|
---|
253 | // - fPheErrLimit to fgPheErrLimit
|
---|
254 | // - fPulserColor to MCalibrationCam::kCT1
|
---|
255 | //
|
---|
256 | // Calls:
|
---|
257 | // - Clear()
|
---|
258 | //
|
---|
259 | MCalibrationChargeCalc::MCalibrationChargeCalc(const char *name, const char *title)
|
---|
260 | : fBadPixels(NULL), fCam(NULL), fBlindPixel(NULL), fPINDiode(NULL),
|
---|
261 | fQECam(NULL), fGeom(NULL), fPedestals(NULL), fEvtTime(NULL)
|
---|
262 | {
|
---|
263 |
|
---|
264 | fName = name ? name : "MCalibrationChargeCalc";
|
---|
265 | fTitle = title ? title : "Task to calculate the calibration constants and MCalibrationCam ";
|
---|
266 |
|
---|
267 | AddToBranchList("MRawEvtData.fHiGainPixId");
|
---|
268 | AddToBranchList("MRawEvtData.fLoGainPixId");
|
---|
269 | AddToBranchList("MRawEvtData.fHiGainFadcSamples");
|
---|
270 | AddToBranchList("MRawEvtData.fLoGainFadcSamples");
|
---|
271 |
|
---|
272 | SetChargeLimit();
|
---|
273 | SetChargeErrLimit();
|
---|
274 | SetChargeRelErrLimit();
|
---|
275 | SetLambdaCheckLimit();
|
---|
276 | SetLambdaErrLimit();
|
---|
277 | SetPheErrLimit();
|
---|
278 | SetPulserColor(MCalibrationCam::kCT1);
|
---|
279 |
|
---|
280 | Clear();
|
---|
281 |
|
---|
282 | }
|
---|
283 |
|
---|
284 | // --------------------------------------------------------------------------
|
---|
285 | //
|
---|
286 | // Sets:
|
---|
287 | // - all variables to 0.,
|
---|
288 | // - all flags to kFALSE
|
---|
289 | //
|
---|
290 | void MCalibrationChargeCalc::Clear(const Option_t *o)
|
---|
291 | {
|
---|
292 |
|
---|
293 | fNumHiGainSamples = 0.;
|
---|
294 | fNumLoGainSamples = 0.;
|
---|
295 | fSqrtHiGainSamples = 0.;
|
---|
296 | fSqrtLoGainSamples = 0.;
|
---|
297 | SkipHiLoGainCalibration( kFALSE );
|
---|
298 | }
|
---|
299 |
|
---|
300 |
|
---|
301 | // -----------------------------------------------------------------------------------
|
---|
302 | //
|
---|
303 | // The following container are searched for and execution aborted if not in MParList:
|
---|
304 | // - MPedestalCam
|
---|
305 | //
|
---|
306 | // The following containers are searched and created if they were not found:
|
---|
307 | //
|
---|
308 | // - MCalibrationQECam
|
---|
309 | // - MBadPixelsCam
|
---|
310 | //
|
---|
311 | // The following output containers are only searched, but not created. If they
|
---|
312 | // cannot be found, the corresponding calibration part is only skipped.
|
---|
313 | //
|
---|
314 | // - MTime
|
---|
315 | //
|
---|
316 | Int_t MCalibrationChargeCalc::PreProcess(MParList *pList)
|
---|
317 | {
|
---|
318 |
|
---|
319 | //
|
---|
320 | // Containers that have to be there.
|
---|
321 | //
|
---|
322 | fPedestals = (MPedestalCam*)pList->FindObject("MPedestalCam");
|
---|
323 | if (!fPedestals)
|
---|
324 | {
|
---|
325 | *fLog << err << "MPedestalCam not found... aborting" << endl;
|
---|
326 | return kFALSE;
|
---|
327 | }
|
---|
328 |
|
---|
329 | //
|
---|
330 | // Containers that are created in case that they are not there.
|
---|
331 | //
|
---|
332 | fQECam = (MCalibrationQECam*)pList->FindCreateObj("MCalibrationQECam");
|
---|
333 | if (!fQECam)
|
---|
334 | {
|
---|
335 | *fLog << err << "Cannot find nor create MCalibrationQECam... aborting" << endl;
|
---|
336 | return kFALSE;
|
---|
337 | }
|
---|
338 |
|
---|
339 | fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
|
---|
340 | if (!fBadPixels)
|
---|
341 | {
|
---|
342 | *fLog << err << "Could not find or create MBadPixelsCam ... aborting." << endl;
|
---|
343 | return kFALSE;
|
---|
344 | }
|
---|
345 |
|
---|
346 |
|
---|
347 | fEvtTime = (MTime*)pList->FindObject("MTime");
|
---|
348 |
|
---|
349 | return kTRUE;
|
---|
350 | }
|
---|
351 |
|
---|
352 |
|
---|
353 | // --------------------------------------------------------------------------
|
---|
354 | //
|
---|
355 | // Search for the following input containers and abort if not existing:
|
---|
356 | // - MGeomCam
|
---|
357 | // - MCalibrationChargeCam
|
---|
358 | //
|
---|
359 | // Search for the following input containers and give a warning if not existing:
|
---|
360 | // - MCalibrationChargeBlindPix
|
---|
361 | // - MCalibrationChargePINDiode
|
---|
362 | //
|
---|
363 | // Sets the pulser colour in:
|
---|
364 | //
|
---|
365 | // - MCalibrationChargeCam
|
---|
366 | // - MCalibrationChargeBlindPix (if existing)
|
---|
367 | // - MCalibrationChargePINDiode (if existing)
|
---|
368 | //
|
---|
369 | // It retrieves the following variables from MCalibrationChargeCam:
|
---|
370 | //
|
---|
371 | // - fNumHiGainSamples
|
---|
372 | // - fNumLoGainSamples
|
---|
373 | //
|
---|
374 | // It defines the PixId of every pixel in:
|
---|
375 | //
|
---|
376 | // - MCalibrationChargeCam
|
---|
377 | // - MCalibrationQECam
|
---|
378 | //
|
---|
379 | // It sets all pixels in excluded which have the flag fBadBixelsPix::IsBad() set in:
|
---|
380 | //
|
---|
381 | // - MCalibrationChargePix
|
---|
382 | // - MCalibrationQEPix
|
---|
383 | //
|
---|
384 | // It initializes the pulser color in MCalibrationChargeCam, MCalibrationChargeBlindPix
|
---|
385 | // and MCalibrationChargePINDiode and tests, if it has not changed w.r.t. fPulserColor
|
---|
386 | //
|
---|
387 | Bool_t MCalibrationChargeCalc::ReInit(MParList *pList )
|
---|
388 | {
|
---|
389 |
|
---|
390 | fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
|
---|
391 | if (!fGeom)
|
---|
392 | {
|
---|
393 | *fLog << err << "No MGeomCam found... aborting." << endl;
|
---|
394 | return kFALSE;
|
---|
395 | }
|
---|
396 |
|
---|
397 | fCam = (MCalibrationChargeCam*)pList->FindObject("MCalibrationChargeCam");
|
---|
398 | if (!fCam)
|
---|
399 | {
|
---|
400 | *fLog << err << "Cannot find MCalibrationChargeCam... aborting" << endl;
|
---|
401 | *fLog << err << "Maybe you forget to call an MFillH for the MHCalibrationChargeCam before..." << endl;
|
---|
402 | return kFALSE;
|
---|
403 | }
|
---|
404 |
|
---|
405 | //
|
---|
406 | // Optional Containers
|
---|
407 | //
|
---|
408 | fBlindPixel = (MCalibrationChargeBlindPix*)pList->FindObject("MCalibrationChargeBlindPix");
|
---|
409 | if (!fBlindPixel)
|
---|
410 | *fLog << warn << GetDescriptor()
|
---|
411 | << ": MCalibrationChargeBlindPix not found... no blind pixel method! " << endl;
|
---|
412 |
|
---|
413 | fPINDiode = (MCalibrationChargePINDiode*)pList->FindObject("MCalibrationChargePINDiode");
|
---|
414 | if (!fPINDiode)
|
---|
415 | *fLog << warn << GetDescriptor()
|
---|
416 | << "MCalibrationChargePINDiode not found... no PIN Diode method! " << endl;
|
---|
417 |
|
---|
418 | //
|
---|
419 | // Initialize the pulser colours
|
---|
420 | //
|
---|
421 | if (fCam->GetPulserColor() == MCalibrationCam::kNONE)
|
---|
422 | {
|
---|
423 | fCam->SetPulserColor( fPulserColor );
|
---|
424 |
|
---|
425 | if (fBlindPixel)
|
---|
426 | fBlindPixel->SetColor( fPulserColor );
|
---|
427 |
|
---|
428 | if (fPINDiode)
|
---|
429 | fPINDiode->SetColor( fPulserColor );
|
---|
430 | }
|
---|
431 |
|
---|
432 | if (fPulserColor != fCam->GetPulserColor())
|
---|
433 | {
|
---|
434 | *fLog << err << GetDescriptor()
|
---|
435 | << ": Pulser colour has changed w.r.t. last file in MCalibrationChargeCam" << endl;
|
---|
436 | *fLog << err << "This feature is not yet implemented, sorry ... aborting " << endl;
|
---|
437 | return kFALSE;
|
---|
438 | }
|
---|
439 |
|
---|
440 | if (fBlindPixel)
|
---|
441 | if (fPulserColor != fBlindPixel->GetColor())
|
---|
442 | {
|
---|
443 | *fLog << err << GetDescriptor()
|
---|
444 | << ": Pulser colour has changed w.r.t. last file in MCalibrationChargeBlindPix." << endl;
|
---|
445 | *fLog << err << "This feature is not yet implemented, sorry ... aborting " << endl;
|
---|
446 | return kFALSE;
|
---|
447 | }
|
---|
448 |
|
---|
449 | if (fPINDiode)
|
---|
450 | if (fPulserColor != fPINDiode->GetColor())
|
---|
451 | {
|
---|
452 | *fLog << err << GetDescriptor()
|
---|
453 | << ": Pulser colour has changed w.r.t. last file in MCalibrationChargePINDiode." << endl;
|
---|
454 | *fLog << err << "This feature is not yet implemented, sorry ... aborting " << endl;
|
---|
455 | return kFALSE;
|
---|
456 | }
|
---|
457 |
|
---|
458 |
|
---|
459 | fNumHiGainSamples = fCam->GetNumHiGainFADCSlices();
|
---|
460 | fNumLoGainSamples = fCam->GetNumLoGainFADCSlices();
|
---|
461 | fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
|
---|
462 | fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
|
---|
463 |
|
---|
464 | UInt_t npixels = fGeom->GetNumPixels();
|
---|
465 |
|
---|
466 | for (UInt_t i=0; i<npixels; i++)
|
---|
467 | {
|
---|
468 |
|
---|
469 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam) [i];
|
---|
470 | MCalibrationQEPix &pqe = (MCalibrationQEPix&) (*fQECam)[i];
|
---|
471 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
472 |
|
---|
473 | pix.SetPixId(i);
|
---|
474 | pqe.SetPixId(i);
|
---|
475 |
|
---|
476 | if (bad.IsBad())
|
---|
477 | {
|
---|
478 | pix.SetExcluded();
|
---|
479 | pqe.SetExcluded();
|
---|
480 | continue;
|
---|
481 | }
|
---|
482 |
|
---|
483 | }
|
---|
484 |
|
---|
485 | return kTRUE;
|
---|
486 | }
|
---|
487 |
|
---|
488 | // ----------------------------------------------------------------------------------
|
---|
489 | //
|
---|
490 | // Nothing to be done in Process, but have a look at MHCalibrationChargeCam, instead
|
---|
491 | //
|
---|
492 | Int_t MCalibrationChargeCalc::Process()
|
---|
493 | {
|
---|
494 | return kTRUE;
|
---|
495 | }
|
---|
496 |
|
---|
497 | // ----------------------------------------------------------------------------------
|
---|
498 | //
|
---|
499 | // Retrieves pedestal and pedestal RMS from MPedestalPix
|
---|
500 | // Retrieves total entries from MPedestalCam
|
---|
501 | // Sets pedestal*fNumHiGainSamples and pedestal*fNumLoGainSamples in MCalibrationChargePix
|
---|
502 | // Sets pedRMS *fSqrtHiGainSamples and pedRMS *fSqrtLoGainSamples in MCalibrationChargePix
|
---|
503 | //
|
---|
504 | void MCalibrationChargeCalc::FinalizePedestals(const MPedestalPix &ped, MCalibrationChargePix &cal)
|
---|
505 | {
|
---|
506 |
|
---|
507 | //
|
---|
508 | // get the pedestals
|
---|
509 | //
|
---|
510 | const Float_t pedes = ped.GetPedestal();
|
---|
511 | const Float_t prms = ped.GetPedestalRms();
|
---|
512 | const Float_t num = TMath::Sqrt((Float_t)fPedestals->GetTotalEntries());
|
---|
513 |
|
---|
514 | //
|
---|
515 | // set them in the calibration camera
|
---|
516 | //
|
---|
517 | if (cal.IsHiGainSaturation())
|
---|
518 | {
|
---|
519 | cal.SetPedestal(pedes* fNumLoGainSamples,
|
---|
520 | prms * fSqrtLoGainSamples,
|
---|
521 | prms * fNumLoGainSamples / num);
|
---|
522 | cal.CalcLoGainPedestal((Float_t)fNumLoGainSamples);
|
---|
523 | }
|
---|
524 | else
|
---|
525 | {
|
---|
526 | cal.SetPedestal(pedes* fNumHiGainSamples,
|
---|
527 | prms * fSqrtHiGainSamples,
|
---|
528 | prms * fNumHiGainSamples / num);
|
---|
529 | }
|
---|
530 |
|
---|
531 | }
|
---|
532 |
|
---|
533 | // ---------------------------------------------------------------------
|
---|
534 | //
|
---|
535 | // Finalize charges per pixel:
|
---|
536 | // - Check chage validity
|
---|
537 | // - Calculate the reduced sigma
|
---|
538 | // - Calculate the number of photo-electrons
|
---|
539 | //
|
---|
540 | Bool_t MCalibrationChargeCalc::FinalizeCharges(MCalibrationChargePix &cal, MBadPixelsPix &bad)
|
---|
541 | {
|
---|
542 |
|
---|
543 | //
|
---|
544 | // The check return kTRUE if:
|
---|
545 | //
|
---|
546 | // 1) Pixel has a fitted charge greater than fChargeLimit*PedRMS
|
---|
547 | // 2) Pixel has a fit error greater than fChargeVarLimit
|
---|
548 | // 3) Pixel has a fitted charge greater its fChargeRelVarLimit times its charge error
|
---|
549 | // 4) Pixel has a charge sigma bigger than its Pedestal RMS
|
---|
550 | //
|
---|
551 | if (cal.GetMean() < fChargeLimit*cal.GetPedRms())
|
---|
552 | {
|
---|
553 | *fLog << warn << GetDescriptor() << ": Fitted Charge: " << cal.GetMean() << " is smaller than "
|
---|
554 | << fChargeLimit << " Pedestal RMS: " << cal.GetPedRms() << " in Pixel " << cal.GetPixId() << endl;
|
---|
555 | bad.SetUncalibrated( MBadPixelsPix::kChargeIsPedestal);
|
---|
556 | }
|
---|
557 |
|
---|
558 | if (cal.GetMeanErr() < fChargeErrLimit)
|
---|
559 | {
|
---|
560 | *fLog << warn << GetDescriptor() << ": Error of Fitted Charge: " << cal.GetMeanErr()
|
---|
561 | << " is smaller than " << fChargeErrLimit << " in Pixel " << cal.GetPixId() << endl;
|
---|
562 | bad.SetUncalibrated( MBadPixelsPix::kChargeErrNotValid );
|
---|
563 | }
|
---|
564 |
|
---|
565 | if (cal.GetMean() < fChargeRelErrLimit*cal.GetMeanErr())
|
---|
566 | {
|
---|
567 | *fLog << warn << GetDescriptor() << ": Fitted Charge: " << cal.GetMean() << " is smaller than "
|
---|
568 | << fChargeRelErrLimit << "* its error: " << cal.GetMeanErr()
|
---|
569 | << " in Pixel " << cal.GetPixId() << endl;
|
---|
570 | bad.SetUncalibrated( MBadPixelsPix::kChargeRelErrNotValid );
|
---|
571 | }
|
---|
572 |
|
---|
573 | if (cal.GetSigma() < cal.GetPedRms())
|
---|
574 | {
|
---|
575 | *fLog << warn << GetDescriptor() << ": Sigma of Fitted Charge: " << cal.GetSigma()
|
---|
576 | << " smaller than Pedestal RMS: " << cal.GetPedRms() << " in Pixel " << cal.GetPixId() << endl;
|
---|
577 | bad.SetUncalibrated( MBadPixelsPix::kChargeSigmaNotValid );
|
---|
578 | }
|
---|
579 |
|
---|
580 | if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
---|
581 | return kFALSE;
|
---|
582 |
|
---|
583 | if (!cal.CalcReducedSigma())
|
---|
584 | {
|
---|
585 | *fLog << warn << GetDescriptor()
|
---|
586 | << ": Could not calculate reduced sigmas of pixel: " << cal.GetPixId() << endl;
|
---|
587 | bad.SetUncalibrated(MBadPixelsPix::kChargeIsPedestal);
|
---|
588 | return kFALSE;
|
---|
589 | }
|
---|
590 |
|
---|
591 | if (!cal.CalcFFactorMethod())
|
---|
592 | {
|
---|
593 | *fLog << warn << GetDescriptor()
|
---|
594 | << ": Could not calculate F-Factor of pixel: " << cal.GetPixId() << endl;
|
---|
595 | bad.SetUncalibrated(MBadPixelsPix::kDeviatingNumPhes);
|
---|
596 | return kFALSE;
|
---|
597 | }
|
---|
598 |
|
---|
599 | return kTRUE;
|
---|
600 | }
|
---|
601 |
|
---|
602 | // ------------------------------------------------------------------------
|
---|
603 | //
|
---|
604 | // Returns kFALSE if pointer to MExtractedSignalPINDiode is NULL
|
---|
605 | // Returns kFALSE if pointer to MCalibrationChargePINDiode is NULL
|
---|
606 | //
|
---|
607 | // The check returns kFALSE if:
|
---|
608 | //
|
---|
609 | // 1) PINDiode has a fitted charge smaller than fChargeLimit*PedRMS
|
---|
610 | // 2) PINDiode has a fit error smaller than fChargeErrLimit
|
---|
611 | // 3) PINDiode has a fitted charge smaller its fChargeRelErrLimit times its charge error
|
---|
612 | // 4) PINDiode has a charge sigma smaller than its Pedestal RMS
|
---|
613 | //
|
---|
614 | // Calls:
|
---|
615 | // - MCalibrationChargePINDiode::CalcFluxOutsidePlexiglass()
|
---|
616 | //
|
---|
617 | Bool_t MCalibrationChargeCalc::FinalizePINDiode()
|
---|
618 | {
|
---|
619 |
|
---|
620 | if (!fPINDiode)
|
---|
621 | return kFALSE;
|
---|
622 |
|
---|
623 | if (fPINDiode->GetMean() < fChargeLimit*fPINDiode->GetPedRms())
|
---|
624 | {
|
---|
625 | *fLog << warn << GetDescriptor() << ": Fitted Charge is smaller than "
|
---|
626 | << fChargeLimit << " Pedestal RMS in PINDiode " << endl;
|
---|
627 | return kFALSE;
|
---|
628 | }
|
---|
629 |
|
---|
630 | if (fPINDiode->GetMeanErr() < fChargeErrLimit)
|
---|
631 | {
|
---|
632 | *fLog << warn << GetDescriptor() << ": Error of Fitted Charge is smaller than "
|
---|
633 | << fChargeErrLimit << " in PINDiode " << endl;
|
---|
634 | return kFALSE;
|
---|
635 | }
|
---|
636 |
|
---|
637 | if (fPINDiode->GetMean() < fChargeRelErrLimit*fPINDiode->GetMeanErr())
|
---|
638 | {
|
---|
639 | *fLog << warn << GetDescriptor() << ": Fitted Charge is smaller than "
|
---|
640 | << fChargeRelErrLimit << "* its error in PINDiode " << endl;
|
---|
641 | return kFALSE;
|
---|
642 | }
|
---|
643 |
|
---|
644 | if (fPINDiode->GetSigma() < fPINDiode->GetPedRms())
|
---|
645 | {
|
---|
646 | *fLog << warn << GetDescriptor()
|
---|
647 | << ": Sigma of Fitted Charge smaller than Pedestal RMS in PINDiode " << endl;
|
---|
648 | return kFALSE;
|
---|
649 | }
|
---|
650 |
|
---|
651 |
|
---|
652 | if (!fPINDiode->CalcFluxOutsidePlexiglass())
|
---|
653 | {
|
---|
654 | *fLog << warn << "Could not calculate the flux of photons from the PIN Diode, "
|
---|
655 | << "will skip PIN Diode Calibration " << endl;
|
---|
656 | return kFALSE;
|
---|
657 | }
|
---|
658 |
|
---|
659 | return kTRUE;
|
---|
660 | }
|
---|
661 |
|
---|
662 | // ------------------------------------------------------------------------
|
---|
663 | //
|
---|
664 | // Returns kFALSE if pointer to MExtractedSignalBlindPixel is NULL
|
---|
665 | // Returns kFALSE if pointer to MCalibrationChargeBlindPix is NULL
|
---|
666 | //
|
---|
667 | // The check returns kFALSE if:
|
---|
668 | //
|
---|
669 | // 1) fLambda and fLambdaCheck are separated relatively to each other by more than fLambdaCheckLimit
|
---|
670 | // 2) BlindPixel has an fLambdaErr greater than fLambdaErrLimit
|
---|
671 | //
|
---|
672 | // Calls:
|
---|
673 | // - MCalibrationChargeBlindPix::CalcFluxInsidePlexiglass()
|
---|
674 | //
|
---|
675 | Bool_t MCalibrationChargeCalc::FinalizeBlindPixel()
|
---|
676 | {
|
---|
677 |
|
---|
678 | if (!fBlindPixel)
|
---|
679 | return kFALSE;
|
---|
680 |
|
---|
681 | const Float_t lambda = fBlindPixel->GetLambda();
|
---|
682 | const Float_t lambdaerr = fBlindPixel->GetLambdaErr();
|
---|
683 | const Float_t lambdacheck = fBlindPixel->GetLambdaCheck();
|
---|
684 |
|
---|
685 | if (2.*(lambdacheck-lambda)/(lambdacheck+lambda) < fLambdaCheckLimit)
|
---|
686 | {
|
---|
687 | *fLog << warn << GetDescriptor() << ": Lambda and Lambda-Check differ by more than "
|
---|
688 | << fLambdaCheckLimit << " in the Blind Pixel " << endl;
|
---|
689 | return kFALSE;
|
---|
690 | }
|
---|
691 |
|
---|
692 | if (lambdaerr < fLambdaErrLimit)
|
---|
693 | {
|
---|
694 | *fLog << warn << GetDescriptor() << ": Error of Fitted Lambda is greater than "
|
---|
695 | << fLambdaErrLimit << " in Blind Pixel " << endl;
|
---|
696 | return kFALSE;
|
---|
697 | }
|
---|
698 |
|
---|
699 | if (!fBlindPixel->CalcFluxInsidePlexiglass())
|
---|
700 | {
|
---|
701 | *fLog << warn << "Could not calculate the flux of photons from the Blind Pixel, "
|
---|
702 | << "will skip Blind Pixel Calibration " << endl;
|
---|
703 | return kFALSE;
|
---|
704 | }
|
---|
705 |
|
---|
706 | return kTRUE;
|
---|
707 | }
|
---|
708 |
|
---|
709 | // ------------------------------------------------------------------------
|
---|
710 | //
|
---|
711 | //
|
---|
712 | Bool_t MCalibrationChargeCalc::FinalizeFFactorMethod()
|
---|
713 | {
|
---|
714 |
|
---|
715 | const UInt_t npixels = fGeom->GetNumPixels();
|
---|
716 | const UInt_t nareas = fGeom->GetNumAreas();
|
---|
717 | const UInt_t nsectors = fGeom->GetNumSectors();
|
---|
718 |
|
---|
719 | Float_t lowlim [nareas];
|
---|
720 | Float_t upplim [nareas];
|
---|
721 | Float_t areavars [nareas];
|
---|
722 | Float_t areaweights [nareas], sectorweights [nsectors];
|
---|
723 | Float_t areaphes [nareas], sectorphes [nsectors];
|
---|
724 | Int_t numareavalid[nareas], numsectorvalid[nsectors];
|
---|
725 |
|
---|
726 | memset(lowlim ,0, nareas * sizeof(Float_t));
|
---|
727 | memset(upplim ,0, nareas * sizeof(Float_t));
|
---|
728 | memset(areaphes ,0, nareas * sizeof(Float_t));
|
---|
729 | memset(areavars ,0, nareas * sizeof(Float_t));
|
---|
730 | memset(areaweights ,0, nareas * sizeof(Float_t));
|
---|
731 | memset(numareavalid ,0, nareas * sizeof(Int_t ));
|
---|
732 | memset(sectorweights ,0, nsectors * sizeof(Float_t));
|
---|
733 | memset(sectorphes ,0, nsectors * sizeof(Float_t));
|
---|
734 | memset(numsectorvalid,0, nsectors * sizeof(Int_t ));
|
---|
735 |
|
---|
736 | //
|
---|
737 | // First loop: Get mean number of photo-electrons and the RMS
|
---|
738 | // The loop is only to recognize later pixels with very deviating numbers
|
---|
739 | //
|
---|
740 | for (UInt_t i=0; i<npixels; i++)
|
---|
741 | {
|
---|
742 |
|
---|
743 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam) [i];
|
---|
744 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
745 |
|
---|
746 | if (!pix.IsFFactorMethodValid())
|
---|
747 | continue;
|
---|
748 |
|
---|
749 | if (!bad.IsCalibrationResultOK())
|
---|
750 | {
|
---|
751 | pix.SetFFactorMethodValid(kFALSE);
|
---|
752 | continue;
|
---|
753 | }
|
---|
754 |
|
---|
755 | const Float_t nphe = pix.GetPheFFactorMethod();
|
---|
756 | const Float_t nvar = pix.GetPheFFactorMethodVar();
|
---|
757 | const Int_t aidx = (*fGeom)[i].GetAidx();
|
---|
758 |
|
---|
759 | if (nvar > 0.)
|
---|
760 | {
|
---|
761 | areaphes [aidx] += nphe;
|
---|
762 | areavars [aidx] += nvar;
|
---|
763 | numareavalid[aidx] ++;
|
---|
764 | }
|
---|
765 | }
|
---|
766 |
|
---|
767 | for (UInt_t i=0; i<nareas; i++)
|
---|
768 | {
|
---|
769 | if (numareavalid[i] == 0)
|
---|
770 | {
|
---|
771 | *fLog << warn << GetDescriptor() << ": No pixels with valid number of photo-electrons found "
|
---|
772 | << "in area index: " << i << endl;
|
---|
773 | continue;
|
---|
774 | }
|
---|
775 |
|
---|
776 | areaphes[i] = areaphes[i] / numareavalid[i];
|
---|
777 | areavars[i] = areavars[i] / numareavalid[i];
|
---|
778 | lowlim [i] = areaphes[i] - fPheErrLimit*TMath::Sqrt(areavars[i]);
|
---|
779 | upplim [i] = areaphes[i] + fPheErrLimit*TMath::Sqrt(areavars[i]);
|
---|
780 | }
|
---|
781 |
|
---|
782 | memset(numareavalid,0,nareas*sizeof(Int_t));
|
---|
783 | memset(areaphes ,0,nareas*sizeof(Int_t));
|
---|
784 | memset(areavars ,0,nareas*sizeof(Int_t));
|
---|
785 |
|
---|
786 | //
|
---|
787 | // Second loop: Get weighted mean number of photo-electrons and its RMS excluding
|
---|
788 | // pixels deviating by more than fPheErrLimit sigma.
|
---|
789 | // Set the conversion factor FADC counts to photo-electrons
|
---|
790 | //
|
---|
791 | for (UInt_t i=0; i<npixels; i++)
|
---|
792 | {
|
---|
793 |
|
---|
794 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
|
---|
795 |
|
---|
796 | if (!pix.IsFFactorMethodValid())
|
---|
797 | continue;
|
---|
798 |
|
---|
799 | const Float_t nvar = pix.GetPheFFactorMethodVar();
|
---|
800 |
|
---|
801 | if (nvar <= 0.)
|
---|
802 | {
|
---|
803 | pix.SetFFactorMethodValid(kFALSE);
|
---|
804 | continue;
|
---|
805 | }
|
---|
806 |
|
---|
807 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
808 |
|
---|
809 | const Int_t aidx = (*fGeom)[i].GetAidx();
|
---|
810 | const Int_t sector = (*fGeom)[i].GetSector();
|
---|
811 | const Float_t nphe = pix.GetPheFFactorMethod();
|
---|
812 |
|
---|
813 | if ( nphe < lowlim[aidx] || nphe > upplim[aidx] )
|
---|
814 | {
|
---|
815 | *fLog << warn << GetDescriptor() << ": Deviating number of photo-electrons: "
|
---|
816 | << Form("%4.2f",nphe) << " out of accepted limits: ["
|
---|
817 | << Form("%4.2f%s%4.2f",lowlim[aidx],",",upplim[aidx]) << "] in pixel " << i << endl;
|
---|
818 | bad.SetUncalibrated( MBadPixelsPix::kDeviatingNumPhes );
|
---|
819 | bad.SetUnsuitable ( MBadPixelsPix::kUnreliableRun );
|
---|
820 | continue;
|
---|
821 | }
|
---|
822 |
|
---|
823 | const Float_t weight = 1./nvar;
|
---|
824 |
|
---|
825 | areaweights [aidx] += weight;
|
---|
826 | areaphes [aidx] += weight*nphe;
|
---|
827 | numareavalid [aidx] ++;
|
---|
828 | sectorweights [sector] += weight;
|
---|
829 | sectorphes [sector] += weight*nphe;
|
---|
830 | numsectorvalid[sector] ++;
|
---|
831 | }
|
---|
832 |
|
---|
833 | for (UInt_t aidx=0; aidx<nareas; aidx++)
|
---|
834 | {
|
---|
835 |
|
---|
836 | MCalibrationChargePix &apix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
|
---|
837 |
|
---|
838 | if (areaweights[aidx] <= 0. || areaphes[aidx] <= 0.)
|
---|
839 | {
|
---|
840 | *fLog << warn << " Mean number of phe's from area index " << aidx << " cannot be calculated: "
|
---|
841 | << " Sum of weights: " << areaweights[aidx]
|
---|
842 | << " Sum of weighted phes: " << areaphes[aidx] << endl;
|
---|
843 | apix.SetFFactorMethodValid(kFALSE);
|
---|
844 | continue;
|
---|
845 | }
|
---|
846 |
|
---|
847 | *fLog << inf << "Replacing number photo-electrons of average area idx " << aidx << ": "
|
---|
848 | << Form("%5.3f%s%5.3f",apix.GetPheFFactorMethod()," +- ",apix.GetPheFFactorMethodErr()) << endl;
|
---|
849 | *fLog << inf << " by average number of photo-electrons from area idx " << aidx << ": "
|
---|
850 | << Form("%5.3f%s%5.3f",areaphes[aidx] / areaweights[aidx]," +- ",
|
---|
851 | TMath::Sqrt(1./areaweights[aidx])) << endl;
|
---|
852 |
|
---|
853 | apix.SetPheFFactorMethod ( areaphes[aidx]/ areaweights[aidx] );
|
---|
854 | apix.SetPheFFactorMethodVar( 1. / areaweights[aidx] );
|
---|
855 | apix.SetFFactorMethodValid ( kTRUE );
|
---|
856 |
|
---|
857 | }
|
---|
858 |
|
---|
859 | for (UInt_t sector=0; sector<nsectors; sector++)
|
---|
860 | {
|
---|
861 |
|
---|
862 | MCalibrationChargePix &spix = (MCalibrationChargePix&)fCam->GetAverageSector(sector);
|
---|
863 |
|
---|
864 | if (sectorweights[sector] <= 0. || sectorphes[sector] <= 0.)
|
---|
865 | {
|
---|
866 | *fLog << warn << " Mean number of phe's from sector " << sector << " cannot be calculated: "
|
---|
867 | << " Sum of weights: " << sectorweights[sector]
|
---|
868 | << " Sum of weighted phes: " << sectorphes[sector] << endl;
|
---|
869 | spix.SetFFactorMethodValid(kFALSE);
|
---|
870 | continue;
|
---|
871 | }
|
---|
872 |
|
---|
873 | *fLog << inf << "Replacing number photo-electrons of average sector " << sector << ": "
|
---|
874 | << Form("%5.3f%s%5.3f",spix.GetPheFFactorMethod()," +- ",spix.GetPheFFactorMethodErr()) << endl;
|
---|
875 | *fLog << inf << " by average number photo-electrons from sector " << sector << ": "
|
---|
876 | << Form("%5.3f%s%5.3f",sectorphes[sector]/ sectorweights[sector]," +- ",
|
---|
877 | TMath::Sqrt(1./sectorweights[sector])) << endl;
|
---|
878 |
|
---|
879 | spix.SetPheFFactorMethod ( sectorphes[sector]/ sectorweights[sector] );
|
---|
880 | spix.SetPheFFactorMethodVar( 1. / sectorweights[sector] );
|
---|
881 | spix.SetFFactorMethodValid ( kTRUE );
|
---|
882 |
|
---|
883 | }
|
---|
884 |
|
---|
885 | return kTRUE;
|
---|
886 | }
|
---|
887 |
|
---|
888 |
|
---|
889 | // ----------------------------------------------------------------------
|
---|
890 | //
|
---|
891 | // Sets all pixels to MBadPixelsPix::kUnsuitableRun, if following flags are set:
|
---|
892 | // - MBadPixelsPix::kChargeIsPedestal
|
---|
893 | // - MBadPixelsPix::kChargeErrNotValid
|
---|
894 | // - MBadPixelsPix::kChargeRelErrNotValid
|
---|
895 | // - MBadPixelsPix::kChargeSigmaNotValid
|
---|
896 | // - MBadPixelsPix::kMeanTimeInFirstBin
|
---|
897 | // - MBadPixelsPix::kMeanTimeInLast2Bins
|
---|
898 | //
|
---|
899 | // Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
|
---|
900 | // - MBadPixelsPix::kDeviatingNumPhes
|
---|
901 | //
|
---|
902 | void MCalibrationChargeCalc::FinalizeBadPixels()
|
---|
903 | {
|
---|
904 |
|
---|
905 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
906 | {
|
---|
907 |
|
---|
908 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
909 |
|
---|
910 | if (bad.IsUncalibrated( MBadPixelsPix::kChargeIsPedestal))
|
---|
911 | bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
|
---|
912 |
|
---|
913 | if (bad.IsUncalibrated( MBadPixelsPix::kChargeErrNotValid ))
|
---|
914 | bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
|
---|
915 |
|
---|
916 | if (bad.IsUncalibrated( MBadPixelsPix::kChargeRelErrNotValid ))
|
---|
917 | bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
|
---|
918 |
|
---|
919 | if (bad.IsUncalibrated( MBadPixelsPix::kChargeSigmaNotValid ))
|
---|
920 | bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
|
---|
921 |
|
---|
922 | if (bad.IsUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin ))
|
---|
923 | bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
|
---|
924 |
|
---|
925 | if (bad.IsUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins ))
|
---|
926 | bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );
|
---|
927 |
|
---|
928 | if (bad.IsUncalibrated( MBadPixelsPix::kDeviatingNumPhes ))
|
---|
929 | bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun );
|
---|
930 | }
|
---|
931 | }
|
---|
932 |
|
---|
933 | // ------------------------------------------------------------------------
|
---|
934 | //
|
---|
935 | //
|
---|
936 | void MCalibrationChargeCalc::FinalizeFFactorQECam()
|
---|
937 | {
|
---|
938 |
|
---|
939 | MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCam->GetAverageArea(0);
|
---|
940 | MCalibrationQEPix &qepix = (MCalibrationQEPix&) fQECam->GetAverageArea(0);
|
---|
941 |
|
---|
942 | const Float_t avphotons = avpix.GetPheFFactorMethod()
|
---|
943 | / qepix.GetQEFFactor(fPulserColor)
|
---|
944 | / fQECam->GetPlexiglassQE();
|
---|
945 |
|
---|
946 | const Float_t avphotrelvar = avpix.GetPheFFactorMethodRelVar()
|
---|
947 | + qepix.GetQEFFactorRelVar(fPulserColor)
|
---|
948 | + fQECam->GetPlexiglassQERelVar();
|
---|
949 |
|
---|
950 | const UInt_t npixels = fGeom->GetNumPixels();
|
---|
951 |
|
---|
952 | for (UInt_t i=0; i<npixels; i++)
|
---|
953 | {
|
---|
954 |
|
---|
955 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
|
---|
956 | MCalibrationQEPix &qepix = (MCalibrationQEPix&) (*fQECam)[i];
|
---|
957 |
|
---|
958 | if (!pix.IsFFactorMethodValid())
|
---|
959 | {
|
---|
960 | qepix.SetFFactorMethodValid(kFALSE,fPulserColor);
|
---|
961 | continue;
|
---|
962 | }
|
---|
963 |
|
---|
964 | const Float_t photons = avphotons / fGeom->GetPixRatio(i);
|
---|
965 | const Float_t qe = pix.GetPheFFactorMethod() / photons ;
|
---|
966 |
|
---|
967 | if (!pix.CalcMeanFFactor( photons , avphotrelvar ))
|
---|
968 | {
|
---|
969 | pix.SetFFactorMethodValid(kFALSE);
|
---|
970 | qepix.SetFFactorMethodValid(kFALSE, fPulserColor);
|
---|
971 | (*fBadPixels)[i].SetUncalibrated( MBadPixelsPix::kDeviatingNumPhes );
|
---|
972 | }
|
---|
973 |
|
---|
974 | const Float_t qerelvar = avphotrelvar + pix.GetPheFFactorMethodRelVar();
|
---|
975 |
|
---|
976 | qepix.SetQEFFactor ( qe , fPulserColor );
|
---|
977 | qepix.SetQEFFactorVar ( qerelvar*qe*qe, fPulserColor );
|
---|
978 | qepix.SetFFactorMethodValid( kTRUE , fPulserColor );
|
---|
979 |
|
---|
980 | if (!qepix.UpdateFFactorMethod())
|
---|
981 | *fLog << warn << GetDescriptor() << ": Cannot update Quantum efficiencies with the F-Factor Method" << endl;
|
---|
982 | }
|
---|
983 | }
|
---|
984 |
|
---|
985 | // ------------------------------------------------------------------------
|
---|
986 | //
|
---|
987 | //
|
---|
988 | void MCalibrationChargeCalc::FinalizeBlindPixelQECam()
|
---|
989 | {
|
---|
990 |
|
---|
991 | const UInt_t npixels = fGeom->GetNumPixels();
|
---|
992 |
|
---|
993 | //
|
---|
994 | // With the knowledge of the overall photon flux, calculate the
|
---|
995 | // quantum efficiencies after the Blind Pixel and PIN Diode method
|
---|
996 | //
|
---|
997 | for (UInt_t i=0; i<npixels; i++)
|
---|
998 | {
|
---|
999 |
|
---|
1000 | MCalibrationQEPix &qepix = (MCalibrationQEPix&) (*fQECam)[i];
|
---|
1001 |
|
---|
1002 | if (!fBlindPixel)
|
---|
1003 | {
|
---|
1004 | qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
|
---|
1005 | continue;
|
---|
1006 | }
|
---|
1007 |
|
---|
1008 | if (!fBlindPixel->IsFluxInsidePlexiglassAvailable())
|
---|
1009 | {
|
---|
1010 | qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
|
---|
1011 | continue;
|
---|
1012 | }
|
---|
1013 |
|
---|
1014 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
1015 |
|
---|
1016 | if (!bad.IsUnsuitable (MBadPixelsPix::kUnsuitableRun))
|
---|
1017 | {
|
---|
1018 | qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
|
---|
1019 | continue;
|
---|
1020 | }
|
---|
1021 |
|
---|
1022 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
|
---|
1023 | MGeomPix &geo = (*fGeom)[i];
|
---|
1024 |
|
---|
1025 | const Float_t conv = fBlindPixel->GetFluxInsidePlexiglass()
|
---|
1026 | * geo.GetA()
|
---|
1027 | / fQECam->GetPlexiglassQE()
|
---|
1028 | / pix.GetPheFFactorMethod();
|
---|
1029 |
|
---|
1030 | const Float_t convrelvar = fBlindPixel->GetFluxInsidePlexiglassRelVar()
|
---|
1031 | + fQECam->GetPlexiglassQERelVar()
|
---|
1032 | + pix.GetPheFFactorMethodRelVar();
|
---|
1033 |
|
---|
1034 | qepix.SetQEBlindPixel ( conv , fPulserColor );
|
---|
1035 | qepix.SetQEBlindPixelVar ( convrelvar * conv * conv, fPulserColor );
|
---|
1036 | qepix.UpdateBlindPixelMethod();
|
---|
1037 | }
|
---|
1038 | }
|
---|
1039 |
|
---|
1040 | // ------------------------------------------------------------------------
|
---|
1041 | //
|
---|
1042 | //
|
---|
1043 | void MCalibrationChargeCalc::FinalizePINDiodeQECam()
|
---|
1044 | {
|
---|
1045 |
|
---|
1046 | const UInt_t npixels = fGeom->GetNumPixels();
|
---|
1047 |
|
---|
1048 | //
|
---|
1049 | // With the knowledge of the overall photon flux, calculate the
|
---|
1050 | // quantum efficiencies after the PIN Diode method
|
---|
1051 | //
|
---|
1052 | for (UInt_t i=0; i<npixels; i++)
|
---|
1053 | {
|
---|
1054 |
|
---|
1055 | MCalibrationQEPix &qepix = (MCalibrationQEPix&) (*fQECam)[i];
|
---|
1056 |
|
---|
1057 | if (!fPINDiode)
|
---|
1058 | {
|
---|
1059 | qepix.SetPINDiodeMethodValid(kFALSE, fPulserColor);
|
---|
1060 | continue;
|
---|
1061 | }
|
---|
1062 |
|
---|
1063 | if (!fPINDiode->IsFluxOutsidePlexiglassAvailable())
|
---|
1064 | {
|
---|
1065 | qepix.SetPINDiodeMethodValid(kFALSE, fPulserColor);
|
---|
1066 | continue;
|
---|
1067 | }
|
---|
1068 |
|
---|
1069 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
1070 |
|
---|
1071 | if (!bad.IsUnsuitable (MBadPixelsPix::kUnsuitableRun))
|
---|
1072 | {
|
---|
1073 | qepix.SetPINDiodeMethodValid(kFALSE, fPulserColor);
|
---|
1074 | continue;
|
---|
1075 | }
|
---|
1076 |
|
---|
1077 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
|
---|
1078 | MGeomPix &geo = (*fGeom)[i];
|
---|
1079 |
|
---|
1080 | const Float_t conv = fPINDiode->GetFluxOutsidePlexiglass() * geo.GetA() / pix.GetPheFFactorMethod();
|
---|
1081 | const Float_t convrelvar = fPINDiode->GetFluxOutsidePlexiglassRelVar() + pix.GetPheFFactorMethodRelVar();
|
---|
1082 |
|
---|
1083 | qepix.SetQEPINDiode ( conv , fPulserColor );
|
---|
1084 | qepix.SetQEPINDiodeVar ( convrelvar * conv * conv, fPulserColor );
|
---|
1085 | qepix.UpdateBlindPixelMethod();
|
---|
1086 | }
|
---|
1087 | }
|
---|
1088 |
|
---|
1089 |
|
---|
1090 | // -----------------------------------------------------------------------
|
---|
1091 | //
|
---|
1092 | // - Finalize the pedestals
|
---|
1093 | // - Do the quality checks
|
---|
1094 | // - Calculate the reduced sigma
|
---|
1095 | // - Calculate the F-Factor Method
|
---|
1096 | //
|
---|
1097 | Int_t MCalibrationChargeCalc::PostProcess()
|
---|
1098 | {
|
---|
1099 |
|
---|
1100 | if (GetNumExecutions()==0)
|
---|
1101 | return kFALSE;
|
---|
1102 |
|
---|
1103 | //
|
---|
1104 | // loop over the pedestal events and check if we have calibration
|
---|
1105 | //
|
---|
1106 | Int_t nvalid = 0;
|
---|
1107 |
|
---|
1108 | for (Int_t pixid=0; pixid<fPedestals->GetSize(); pixid++)
|
---|
1109 | {
|
---|
1110 |
|
---|
1111 | MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[pixid];
|
---|
1112 | //
|
---|
1113 | // Check if the pixel has been excluded from the fits
|
---|
1114 | //
|
---|
1115 | if (pix.IsExcluded())
|
---|
1116 | continue;
|
---|
1117 |
|
---|
1118 | MPedestalPix &ped = (*fPedestals)[pixid];
|
---|
1119 | MBadPixelsPix &bad = (*fBadPixels)[pixid];
|
---|
1120 |
|
---|
1121 | FinalizePedestals(ped,pix);
|
---|
1122 |
|
---|
1123 | if (FinalizeCharges(pix,bad))
|
---|
1124 | nvalid++;
|
---|
1125 | }
|
---|
1126 |
|
---|
1127 | //
|
---|
1128 | // The Michele check ...
|
---|
1129 | //
|
---|
1130 | if (nvalid == 0)
|
---|
1131 | {
|
---|
1132 | *fLog << err << GetDescriptor() << ": All pixels have non-valid calibration. "
|
---|
1133 | << "Did you forget to fill the histograms "
|
---|
1134 | << "(filling MHCalibrationChargeCam from MExtractedSignalCam using MFillH) ? " << endl;
|
---|
1135 | *fLog << err << GetDescriptor() << ": Or, maybe, you have used a pedestal run "
|
---|
1136 | << "instead of a calibration run " << endl;
|
---|
1137 | return kFALSE;
|
---|
1138 | }
|
---|
1139 |
|
---|
1140 | for (UInt_t aidx=0; aidx<fGeom->GetNumAreas(); aidx++)
|
---|
1141 | {
|
---|
1142 |
|
---|
1143 | const MPedestalPix &ped = fPedestals->GetAverageArea(aidx);
|
---|
1144 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
|
---|
1145 |
|
---|
1146 | FinalizePedestals(ped,pix);
|
---|
1147 | FinalizeCharges(pix, fCam->GetAverageBadArea(aidx));
|
---|
1148 | }
|
---|
1149 |
|
---|
1150 | for (UInt_t sector=0; sector<fGeom->GetNumSectors(); sector++)
|
---|
1151 | {
|
---|
1152 |
|
---|
1153 | const MPedestalPix &ped = fPedestals->GetAverageSector(sector);
|
---|
1154 | MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(sector);
|
---|
1155 |
|
---|
1156 | FinalizePedestals(ped,pix);
|
---|
1157 | FinalizeCharges(pix, fCam->GetAverageBadSector(sector));
|
---|
1158 | }
|
---|
1159 |
|
---|
1160 | //
|
---|
1161 | // Finalize Bad Pixels
|
---|
1162 | //
|
---|
1163 | FinalizeBadPixels();
|
---|
1164 |
|
---|
1165 | //
|
---|
1166 | // Finalize F-Factor method
|
---|
1167 | //
|
---|
1168 | if (!FinalizeFFactorMethod())
|
---|
1169 | {
|
---|
1170 | *fLog << warn << "Could not calculate the photons flux from the F-Factor method " << endl;
|
---|
1171 | fCam->SetFFactorMethodValid(kFALSE);
|
---|
1172 | return kFALSE;
|
---|
1173 | }
|
---|
1174 | else
|
---|
1175 | fCam->SetFFactorMethodValid(kTRUE);
|
---|
1176 |
|
---|
1177 | //
|
---|
1178 | // Finalize Blind Pixel
|
---|
1179 | //
|
---|
1180 | if (FinalizeBlindPixel())
|
---|
1181 | fQECam->SetBlindPixelMethodValid(kTRUE);
|
---|
1182 | else
|
---|
1183 | fQECam->SetBlindPixelMethodValid(kFALSE);
|
---|
1184 |
|
---|
1185 | //
|
---|
1186 | // Finalize PIN Diode
|
---|
1187 | //
|
---|
1188 | if (FinalizePINDiode())
|
---|
1189 | fQECam->SetPINDiodeMethodValid(kTRUE);
|
---|
1190 | else
|
---|
1191 | fQECam->SetPINDiodeMethodValid(kFALSE);
|
---|
1192 |
|
---|
1193 | //
|
---|
1194 | // Finalize QE Cam
|
---|
1195 | //
|
---|
1196 | FinalizeFFactorQECam();
|
---|
1197 | FinalizeBlindPixelQECam();
|
---|
1198 | FinalizePINDiodeQECam();
|
---|
1199 |
|
---|
1200 | fCam ->SetReadyToSave();
|
---|
1201 | fQECam ->SetReadyToSave();
|
---|
1202 | fBadPixels->SetReadyToSave();
|
---|
1203 |
|
---|
1204 | *fLog << inf << endl;
|
---|
1205 | *fLog << GetDescriptor() << ": Calibration statistics:" << endl;
|
---|
1206 | *fLog << dec << setfill(' ');
|
---|
1207 |
|
---|
1208 | UInt_t countinner = 0;
|
---|
1209 | UInt_t countouter = 0;
|
---|
1210 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
1211 | {
|
---|
1212 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
1213 | if (bad.IsOK())
|
---|
1214 | {
|
---|
1215 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
1216 | countinner++;
|
---|
1217 | else
|
---|
1218 | countouter++;
|
---|
1219 | }
|
---|
1220 | }
|
---|
1221 |
|
---|
1222 | *fLog << " " << setw(7) << "Successfully calibrated Pixels: "
|
---|
1223 | << "Inner: " << countinner << " Outer: " << countouter << endl;
|
---|
1224 |
|
---|
1225 | PrintUnsuitable(MBadPixelsPix::kUnsuitableRun, "Bad Pixels: ");
|
---|
1226 | PrintUnsuitable(MBadPixelsPix::kUnreliableRun, "Unreliable Pixels: ");
|
---|
1227 |
|
---|
1228 | *fLog << inf << endl;
|
---|
1229 | *fLog << GetDescriptor() << ": Errors statistics:" << endl;
|
---|
1230 |
|
---|
1231 | PrintUncalibrated(MBadPixelsPix::kChargeIsPedestal,
|
---|
1232 | Form("%s%2.1f%s","Signal less than ",fChargeLimit," Pedestal RMS: "));
|
---|
1233 | PrintUncalibrated(MBadPixelsPix::kChargeErrNotValid,
|
---|
1234 | Form("%s%2.1f%s","Signal Error smaller than ",fChargeErrLimit,": "));
|
---|
1235 | PrintUncalibrated(MBadPixelsPix::kChargeRelErrNotValid,
|
---|
1236 | Form("%s%2.1f%s","Signal Error bigger than ",fChargeRelErrLimit," times Mean Signal: "));
|
---|
1237 | PrintUncalibrated(MBadPixelsPix::kChargeSigmaNotValid,
|
---|
1238 | "Signal Sigma smaller than Pedestal RMS: ");
|
---|
1239 | PrintUncalibrated(MBadPixelsPix::kLoGainSaturation,
|
---|
1240 | "Pixels with Low Gain Saturation: ");
|
---|
1241 | PrintUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin,
|
---|
1242 | Form("%s%2.1f%s","Mean Abs. Arr. Time in First ",1," Bin(s): "));
|
---|
1243 | PrintUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins,
|
---|
1244 | Form("%s%2.1f%s","Mean Abs. Arr. Time in Last ",2," Bin(s): "));
|
---|
1245 | PrintUncalibrated(MBadPixelsPix::kHiGainOscillating,
|
---|
1246 | "Pixels with changing Hi Gain signal over time: ");
|
---|
1247 | PrintUncalibrated(MBadPixelsPix::kLoGainOscillating,
|
---|
1248 | "Pixels with changing Lo Gain signal over time: ");
|
---|
1249 | PrintUncalibrated(MBadPixelsPix::kDeviatingNumPhes,
|
---|
1250 | "Pixels with deviating number of phes: ");
|
---|
1251 | PrintUncalibrated(MBadPixelsPix::kHiGainNotFitted,
|
---|
1252 | "Pixels with unsuccesful Gauss fit to the Hi Gain: ");
|
---|
1253 | PrintUncalibrated(MBadPixelsPix::kLoGainNotFitted,
|
---|
1254 | "Pixels with unsuccesful Gauss fit to the Lo Gain: ");
|
---|
1255 |
|
---|
1256 | return kTRUE;
|
---|
1257 | }
|
---|
1258 |
|
---|
1259 | void MCalibrationChargeCalc::PrintUnsuitable(MBadPixelsPix::UnsuitableType_t typ, const char *text) const
|
---|
1260 | {
|
---|
1261 |
|
---|
1262 | UInt_t countinner = 0;
|
---|
1263 | UInt_t countouter = 0;
|
---|
1264 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
1265 | {
|
---|
1266 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
1267 | if (bad.IsUnsuitable(typ))
|
---|
1268 | {
|
---|
1269 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
1270 | countinner++;
|
---|
1271 | else
|
---|
1272 | countouter++;
|
---|
1273 | }
|
---|
1274 | }
|
---|
1275 |
|
---|
1276 | *fLog << " " << setw(7) << text
|
---|
1277 | << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
|
---|
1278 | }
|
---|
1279 |
|
---|
1280 | void MCalibrationChargeCalc::PrintUncalibrated(MBadPixelsPix::UncalibratedType_t typ, const char *text) const
|
---|
1281 | {
|
---|
1282 |
|
---|
1283 | UInt_t countinner = 0;
|
---|
1284 | UInt_t countouter = 0;
|
---|
1285 | for (Int_t i=0; i<fBadPixels->GetSize(); i++)
|
---|
1286 | {
|
---|
1287 | MBadPixelsPix &bad = (*fBadPixels)[i];
|
---|
1288 | if (bad.IsUncalibrated(typ))
|
---|
1289 | {
|
---|
1290 | if (fGeom->GetPixRatio(i) == 1.)
|
---|
1291 | countinner++;
|
---|
1292 | else
|
---|
1293 | countouter++;
|
---|
1294 | }
|
---|
1295 | }
|
---|
1296 |
|
---|
1297 | *fLog << " " << setw(7) << text
|
---|
1298 | << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
|
---|
1299 | }
|
---|
1300 |
|
---|