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 | // MCalibrationChargePix //
|
---|
28 | // //
|
---|
29 | // Storage container to hold informations about the calibration values //
|
---|
30 | // values of one Pixel (PMT). //
|
---|
31 | // //
|
---|
32 | // The following values are initialized to meaningful values:
|
---|
33 | //
|
---|
34 | // - The Electronic Rms to 1.5 per FADC slice
|
---|
35 | // - The uncertainty about the Electronic RMS to 0.3 per slice
|
---|
36 | // - The F-Factor is assumed to have been measured in Munich to 1.13 - 1.17.
|
---|
37 | // with the Munich definition of the F-Factor, thus:
|
---|
38 | // F = Sigma(Out)/Mean(Out) * Mean(In)/Sigma(In)
|
---|
39 | // Mean F-Factor = 1.15
|
---|
40 | // Error F-Factor = 0.02
|
---|
41 | //
|
---|
42 | // - Average QE: (email David Paneque, 14.2.04):
|
---|
43 | //
|
---|
44 | // The conversion factor that comes purely from QE folded to a Cherenkov
|
---|
45 | // spectrum has to be multiplied by:
|
---|
46 | // * Plexiglass window -->> 0.96 X 0.96
|
---|
47 | // * PMT photoelectron collection efficiency -->> 0.9
|
---|
48 | // * Light guides efficiency -->> 0.94
|
---|
49 | //
|
---|
50 | // Concerning the light guides effiency estimation... Daniel Ferenc
|
---|
51 | // is preparing some work (simulations) to estimate it. Yet so far, he has
|
---|
52 | // been busy with other stuff, and this work is still UNfinished.
|
---|
53 | //
|
---|
54 | // The estimation I did comes from:
|
---|
55 | // 1) Reflectivity of light guide walls is 85 % (aluminum)
|
---|
56 | // 2) At ZERO degree light incidence, 37% of the light hits such walls
|
---|
57 | // (0.15X37%= 5.6% of light lost)
|
---|
58 | // 3) When increasing the light incidence angle, more and more light hits
|
---|
59 | // the walls.
|
---|
60 | //
|
---|
61 | // However, the loses due to larger amount of photons hitting the walls is more
|
---|
62 | // or less counteracted by the fact that more and more photon trajectories cross
|
---|
63 | // the PMT photocathode twice, increasing the effective sensitivity of the PMT.
|
---|
64 | //
|
---|
65 | // Jurgen Gebauer did some quick measurements about this issue. I attach a
|
---|
66 | // plot. You can see that the angular dependence is (more or less) in agreement
|
---|
67 | // with a CosTheta function (below 20-25 degrees),
|
---|
68 | // which is the variation of teh entrance window cross section. So, in
|
---|
69 | // first approximation, no loses when increasing light incidence angle;
|
---|
70 | // and therefore, the factor 0.94.
|
---|
71 | //
|
---|
72 | // So, summarizing... I would propose the following conversion factors
|
---|
73 | // (while working with CT1 cal box) in order to get the final number of photons
|
---|
74 | // from the detected measured size in ADC counts.
|
---|
75 | //
|
---|
76 | // Nph = ADC * FmethodConversionFactor / ConvPhe-PhFactor
|
---|
77 | //
|
---|
78 | // FmethodConversionFactor ; measured for individual pmts
|
---|
79 | //
|
---|
80 | // ConvPhe-PhFactor = 0.98 * 0.23 * 0.90 * 0.94 * 0.96 * 0.96 = 0.18
|
---|
81 | //
|
---|
82 | // I would not apply any smearing of this factor (which we have in nature),
|
---|
83 | // since we might be applying it to PMTs in the totally wrong direction.
|
---|
84 | //
|
---|
85 | //
|
---|
86 | /////////////////////////////////////////////////////////////////////////////
|
---|
87 | #include "MCalibrationChargePix.h"
|
---|
88 |
|
---|
89 | #include "MLog.h"
|
---|
90 | #include "MLogManip.h"
|
---|
91 |
|
---|
92 | #include "MBadPixelsPix.h"
|
---|
93 |
|
---|
94 | ClassImp(MCalibrationChargePix);
|
---|
95 |
|
---|
96 | using namespace std;
|
---|
97 |
|
---|
98 | const Float_t MCalibrationChargePix::gkElectronicPedRms = 1.5;
|
---|
99 | const Float_t MCalibrationChargePix::gkElectronicPedRmsErr = 0.3;
|
---|
100 | const Float_t MCalibrationChargePix::gkFFactor = 1.15;
|
---|
101 | const Float_t MCalibrationChargePix::gkFFactorErr = 0.02;
|
---|
102 |
|
---|
103 | const Float_t MCalibrationChargePix::gkConversionHiLo = 10.;
|
---|
104 | const Float_t MCalibrationChargePix::gkConversionHiLoErr = 2.5;
|
---|
105 |
|
---|
106 | const Float_t MCalibrationChargePix::fgChargeLimit = 3.;
|
---|
107 | const Float_t MCalibrationChargePix::fgChargeErrLimit = 0.;
|
---|
108 | const Float_t MCalibrationChargePix::fgChargeRelErrLimit = 1.;
|
---|
109 | const Float_t MCalibrationChargePix::fgTimeLimit = 1.5;
|
---|
110 | const Float_t MCalibrationChargePix::fgTimeErrLimit = 3.;
|
---|
111 | // --------------------------------------------------------------------------
|
---|
112 | //
|
---|
113 | // Default Constructor:
|
---|
114 | //
|
---|
115 | MCalibrationChargePix::MCalibrationChargePix(const char *name, const char *title)
|
---|
116 | : fPixId(-1),
|
---|
117 | fFlags(0)
|
---|
118 | {
|
---|
119 |
|
---|
120 | fName = name ? name : "MCalibrationChargePix";
|
---|
121 | fTitle = title ? title : "Container of the fit results of MHCalibrationChargePixs ";
|
---|
122 |
|
---|
123 | Clear();
|
---|
124 |
|
---|
125 | //
|
---|
126 | // At the moment, we don't have a database, yet,
|
---|
127 | // so we get it from the configuration file
|
---|
128 | //
|
---|
129 | SetConversionHiLo();
|
---|
130 | SetConversionHiLoErr();
|
---|
131 |
|
---|
132 | SetChargeLimit();
|
---|
133 | SetChargeErrLimit();
|
---|
134 |
|
---|
135 | SetChargeRelErrLimit();
|
---|
136 | SetTimeLimit();
|
---|
137 | SetTimeErrLimit();
|
---|
138 | }
|
---|
139 |
|
---|
140 | // ------------------------------------------------------------------------
|
---|
141 | //
|
---|
142 | // Invalidate values
|
---|
143 | //
|
---|
144 | void MCalibrationChargePix::Clear(Option_t *o)
|
---|
145 | {
|
---|
146 |
|
---|
147 | SetHiGainSaturation ( kFALSE );
|
---|
148 | SetLoGainSaturation ( kFALSE );
|
---|
149 | SetHiGainFitted ( kFALSE );
|
---|
150 | SetLoGainFitted ( kFALSE );
|
---|
151 | SetExcluded ( kFALSE );
|
---|
152 | SetBlindPixelMethodValid ( kFALSE );
|
---|
153 | SetFFactorMethodValid ( kFALSE );
|
---|
154 | SetPINDiodeMethodValid ( kFALSE );
|
---|
155 | SetCombinedMethodValid ( kFALSE );
|
---|
156 |
|
---|
157 | fHiGainMeanCharge = -1.;
|
---|
158 | fHiGainMeanChargeErr = -1.;
|
---|
159 | fHiGainSigmaCharge = -1.;
|
---|
160 | fHiGainSigmaChargeErr = -1.;
|
---|
161 | fHiGainChargeProb = -1.;
|
---|
162 |
|
---|
163 | fLoGainMeanCharge = -1.;
|
---|
164 | fLoGainMeanChargeErr = -1.;
|
---|
165 | fLoGainSigmaCharge = -1.;
|
---|
166 | fLoGainSigmaChargeErr = -1.;
|
---|
167 | fLoGainChargeProb = -1.;
|
---|
168 |
|
---|
169 | fRSigmaCharge = -1.;
|
---|
170 | fRSigmaChargeErr = -1.;
|
---|
171 |
|
---|
172 | fHiGainNumPickup = -1;
|
---|
173 | fLoGainNumPickup = -1;
|
---|
174 |
|
---|
175 | fNumLoGainSamples = -1.;
|
---|
176 |
|
---|
177 | fPed = -1.;
|
---|
178 | fPedRms = -1.;
|
---|
179 | fPedErr = -1.;
|
---|
180 |
|
---|
181 | fLoGainPedRms = -1.;
|
---|
182 | fLoGainPedRmsErr = -1.;
|
---|
183 |
|
---|
184 | fTimeFirstHiGain = 0 ;
|
---|
185 | fTimeLastHiGain = 0 ;
|
---|
186 | fTimeFirstLoGain = 0 ;
|
---|
187 | fTimeLastLoGain = 0 ;
|
---|
188 |
|
---|
189 | fAbsTimeMean = -1.;
|
---|
190 | fAbsTimeRms = -1.;
|
---|
191 |
|
---|
192 | fPheFFactorMethod = -1.;
|
---|
193 | fPheFFactorMethodErr = -1.;
|
---|
194 |
|
---|
195 | fMeanConversionFFactorMethod = -1.;
|
---|
196 | fMeanConversionBlindPixelMethod = -1.;
|
---|
197 | fMeanConversionPINDiodeMethod = -1.;
|
---|
198 | fMeanConversionCombinedMethod = -1.;
|
---|
199 |
|
---|
200 | fConversionFFactorMethodErr = -1.;
|
---|
201 | fConversionBlindPixelMethodErr = -1.;
|
---|
202 | fConversionPINDiodeMethodErr = -1.;
|
---|
203 | fConversionCombinedMethodErr = -1.;
|
---|
204 |
|
---|
205 | fSigmaConversionFFactorMethod = -1.;
|
---|
206 | fSigmaConversionBlindPixelMethod = -1.;
|
---|
207 | fSigmaConversionPINDiodeMethod = -1.;
|
---|
208 | fSigmaConversionCombinedMethod = -1.;
|
---|
209 |
|
---|
210 | fTotalFFactorFFactorMethod = -1.;
|
---|
211 | fTotalFFactorBlindPixelMethod = -1.;
|
---|
212 | fTotalFFactorPINDiodeMethod = -1.;
|
---|
213 | fTotalFFactorCombinedMethod = -1.;
|
---|
214 |
|
---|
215 | }
|
---|
216 |
|
---|
217 |
|
---|
218 | void MCalibrationChargePix::DefinePixId(Int_t i)
|
---|
219 | {
|
---|
220 | fPixId = i;
|
---|
221 | }
|
---|
222 |
|
---|
223 |
|
---|
224 | // --------------------------------------------------------------------------
|
---|
225 | //
|
---|
226 | // Set the pedestals from outside
|
---|
227 | //
|
---|
228 | void MCalibrationChargePix::SetPedestal(const Float_t ped, const Float_t pedrms, const Float_t pederr)
|
---|
229 | {
|
---|
230 |
|
---|
231 | fPed = ped;
|
---|
232 | fPedRms = pedrms;
|
---|
233 | fPedErr = pederr;
|
---|
234 | }
|
---|
235 |
|
---|
236 |
|
---|
237 | void MCalibrationChargePix::SetMeanCharge( const Float_t f )
|
---|
238 | {
|
---|
239 | if (IsHiGainSaturation())
|
---|
240 | fLoGainMeanCharge = f;
|
---|
241 | else
|
---|
242 | fHiGainMeanCharge = f;
|
---|
243 | }
|
---|
244 |
|
---|
245 | void MCalibrationChargePix::SetMeanChargeErr( const Float_t f )
|
---|
246 | {
|
---|
247 | if (IsHiGainSaturation())
|
---|
248 | fLoGainMeanChargeErr = f;
|
---|
249 | else
|
---|
250 | fHiGainMeanChargeErr = f;
|
---|
251 |
|
---|
252 | }
|
---|
253 |
|
---|
254 | void MCalibrationChargePix::SetSigmaCharge( const Float_t f )
|
---|
255 | {
|
---|
256 | if (IsHiGainSaturation())
|
---|
257 | fLoGainSigmaCharge = f;
|
---|
258 | else
|
---|
259 | fHiGainSigmaCharge = f;
|
---|
260 | }
|
---|
261 |
|
---|
262 |
|
---|
263 | void MCalibrationChargePix::SetSigmaChargeErr( const Float_t f )
|
---|
264 | {
|
---|
265 | if (IsHiGainSaturation())
|
---|
266 | fLoGainSigmaChargeErr = f;
|
---|
267 | else
|
---|
268 | fHiGainSigmaChargeErr = f;
|
---|
269 |
|
---|
270 | }
|
---|
271 |
|
---|
272 |
|
---|
273 |
|
---|
274 | // --------------------------------------------------------------------------
|
---|
275 | //
|
---|
276 | // Set the conversion factors from outside (only for MC)
|
---|
277 | //
|
---|
278 | void MCalibrationChargePix::SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig)
|
---|
279 | {
|
---|
280 | fMeanConversionFFactorMethod = c;
|
---|
281 | fConversionFFactorMethodErr = err;
|
---|
282 | fSigmaConversionFFactorMethod = sig;
|
---|
283 | }
|
---|
284 |
|
---|
285 | // --------------------------------------------------------------------------
|
---|
286 | //
|
---|
287 | // Set the conversion factors from outside (only for MC)
|
---|
288 | //
|
---|
289 | void MCalibrationChargePix::SetConversionCombinedMethod(Float_t c, Float_t err, Float_t sig)
|
---|
290 | {
|
---|
291 | fMeanConversionCombinedMethod = c;
|
---|
292 | fConversionCombinedMethodErr = err;
|
---|
293 | fSigmaConversionCombinedMethod = sig;
|
---|
294 | }
|
---|
295 |
|
---|
296 |
|
---|
297 | // --------------------------------------------------------------------------
|
---|
298 | //
|
---|
299 | // Set the conversion factors from outside (only for MC)
|
---|
300 | //
|
---|
301 | void MCalibrationChargePix::SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig)
|
---|
302 | {
|
---|
303 | fMeanConversionBlindPixelMethod = c;
|
---|
304 | fConversionBlindPixelMethodErr = err;
|
---|
305 | fSigmaConversionBlindPixelMethod = sig;
|
---|
306 | }
|
---|
307 |
|
---|
308 | // --------------------------------------------------------------------------
|
---|
309 | //
|
---|
310 | // Set the conversion factors from outside (only for MC)
|
---|
311 | //
|
---|
312 | void MCalibrationChargePix::SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig)
|
---|
313 | {
|
---|
314 | fMeanConversionPINDiodeMethod = c ;
|
---|
315 | fConversionPINDiodeMethodErr = err;
|
---|
316 | fSigmaConversionPINDiodeMethod = sig;
|
---|
317 | }
|
---|
318 |
|
---|
319 | // --------------------------------------------------------------------------
|
---|
320 | //
|
---|
321 | // Set the Hi Gain Saturation Bit from outside
|
---|
322 | //
|
---|
323 | void MCalibrationChargePix::SetHiGainSaturation(Bool_t b)
|
---|
324 | {
|
---|
325 | b ? SETBIT(fFlags, kHiGainSaturation) : CLRBIT(fFlags, kHiGainSaturation);
|
---|
326 | }
|
---|
327 |
|
---|
328 | // --------------------------------------------------------------------------
|
---|
329 | //
|
---|
330 | // Set the Lo Gain Saturation Bit from outside
|
---|
331 | //
|
---|
332 | void MCalibrationChargePix::SetLoGainSaturation(Bool_t b)
|
---|
333 | {
|
---|
334 | b ? SETBIT(fFlags, kLoGainSaturation) : CLRBIT(fFlags, kLoGainSaturation);
|
---|
335 | }
|
---|
336 |
|
---|
337 | // --------------------------------------------------------------------------
|
---|
338 | //
|
---|
339 | // Set the Excluded Bit from outside
|
---|
340 | //
|
---|
341 | void MCalibrationChargePix::SetExcluded(Bool_t b )
|
---|
342 | {
|
---|
343 | b ? SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded);
|
---|
344 | }
|
---|
345 |
|
---|
346 | // --------------------------------------------------------------------------
|
---|
347 | //
|
---|
348 | // Set the Fitted Bit from outside
|
---|
349 | //
|
---|
350 | void MCalibrationChargePix::SetHiGainFitted(Bool_t b )
|
---|
351 | {
|
---|
352 | b ? SETBIT(fFlags, kHiGainFitted) : CLRBIT(fFlags, kHiGainFitted);
|
---|
353 | }
|
---|
354 |
|
---|
355 | // --------------------------------------------------------------------------
|
---|
356 | //
|
---|
357 | // Set the Fitted Bit from outside
|
---|
358 | //
|
---|
359 | void MCalibrationChargePix::SetLoGainFitted(const Bool_t b )
|
---|
360 | {
|
---|
361 | b ? SETBIT(fFlags, kLoGainFitted) : CLRBIT(fFlags, kLoGainFitted);
|
---|
362 | }
|
---|
363 |
|
---|
364 | // --------------------------------------------------------------------------
|
---|
365 | //
|
---|
366 | // Set the Excluded Bit from outside
|
---|
367 | //
|
---|
368 | void MCalibrationChargePix::SetBlindPixelMethodValid(const Bool_t b )
|
---|
369 | {
|
---|
370 | b ? SETBIT(fFlags, kBlindPixelMethodValid) : CLRBIT(fFlags, kBlindPixelMethodValid);
|
---|
371 | }
|
---|
372 |
|
---|
373 | // --------------------------------------------------------------------------
|
---|
374 | //
|
---|
375 | // Set the Excluded Bit from outside
|
---|
376 | //
|
---|
377 | void MCalibrationChargePix::SetFFactorMethodValid(const Bool_t b )
|
---|
378 | {
|
---|
379 | b ? SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid);
|
---|
380 | }
|
---|
381 |
|
---|
382 | // --------------------------------------------------------------------------
|
---|
383 | //
|
---|
384 | // Set the Excluded Bit from outside
|
---|
385 | //
|
---|
386 | void MCalibrationChargePix::SetPINDiodeMethodValid(const Bool_t b )
|
---|
387 | {
|
---|
388 | b ? SETBIT(fFlags, kPINDiodeMethodValid) : CLRBIT(fFlags, kPINDiodeMethodValid);
|
---|
389 | }
|
---|
390 |
|
---|
391 | // --------------------------------------------------------------------------
|
---|
392 | //
|
---|
393 | // Set the Excluded Bit from outside
|
---|
394 | //
|
---|
395 | void MCalibrationChargePix::SetCombinedMethodValid(const Bool_t b )
|
---|
396 | {
|
---|
397 | b ? SETBIT(fFlags, kCombinedMethodValid) : CLRBIT(fFlags, kCombinedMethodValid);
|
---|
398 | }
|
---|
399 |
|
---|
400 | void MCalibrationChargePix::SetAbsTimeBordersHiGain(const Byte_t f, const Byte_t l)
|
---|
401 | {
|
---|
402 |
|
---|
403 | fTimeFirstHiGain = f;
|
---|
404 | fTimeLastHiGain = l;
|
---|
405 |
|
---|
406 | }
|
---|
407 |
|
---|
408 | void MCalibrationChargePix::SetAbsTimeBordersLoGain(const Byte_t f, const Byte_t l)
|
---|
409 | {
|
---|
410 |
|
---|
411 | fTimeFirstLoGain = f;
|
---|
412 | fTimeLastLoGain = l;
|
---|
413 |
|
---|
414 | }
|
---|
415 |
|
---|
416 | Float_t MCalibrationChargePix::GetMeanCharge() const
|
---|
417 | {
|
---|
418 | return IsHiGainSaturation() ? fLoGainMeanCharge : fHiGainMeanCharge ;
|
---|
419 | }
|
---|
420 |
|
---|
421 | Float_t MCalibrationChargePix::GetMeanChargeErr() const
|
---|
422 | {
|
---|
423 | return IsHiGainSaturation() ? fLoGainMeanChargeErr : fHiGainMeanChargeErr ;
|
---|
424 | }
|
---|
425 |
|
---|
426 | Float_t MCalibrationChargePix::GetChargeProb() const
|
---|
427 | {
|
---|
428 | return IsHiGainSaturation() ? fLoGainChargeProb : fHiGainChargeProb ;
|
---|
429 | }
|
---|
430 |
|
---|
431 | Float_t MCalibrationChargePix::GetSigmaCharge() const
|
---|
432 | {
|
---|
433 | return IsHiGainSaturation() ? fLoGainSigmaCharge : fHiGainSigmaCharge ;
|
---|
434 | }
|
---|
435 |
|
---|
436 | Float_t MCalibrationChargePix::GetSigmaChargeErr() const
|
---|
437 | {
|
---|
438 | return IsHiGainSaturation() ? fLoGainSigmaChargeErr : fHiGainSigmaChargeErr ;
|
---|
439 | }
|
---|
440 |
|
---|
441 | Bool_t MCalibrationChargePix::IsFitted() const
|
---|
442 | {
|
---|
443 | return IsHiGainSaturation() ? IsLoGainFitted() : IsHiGainFitted();
|
---|
444 | }
|
---|
445 |
|
---|
446 |
|
---|
447 | Bool_t MCalibrationChargePix::IsExcluded() const
|
---|
448 | {
|
---|
449 | return TESTBIT(fFlags,kExcluded);
|
---|
450 | }
|
---|
451 |
|
---|
452 | Bool_t MCalibrationChargePix::IsHiGainSaturation() const
|
---|
453 | {
|
---|
454 | return TESTBIT(fFlags,kHiGainSaturation);
|
---|
455 | }
|
---|
456 |
|
---|
457 | Bool_t MCalibrationChargePix::IsLoGainSaturation() const
|
---|
458 | {
|
---|
459 | return TESTBIT(fFlags,kLoGainSaturation);
|
---|
460 | }
|
---|
461 |
|
---|
462 | Bool_t MCalibrationChargePix::IsHiGainFitted() const
|
---|
463 | {
|
---|
464 | return TESTBIT(fFlags, kHiGainFitted);
|
---|
465 | }
|
---|
466 |
|
---|
467 | Bool_t MCalibrationChargePix::IsLoGainFitted() const
|
---|
468 | {
|
---|
469 | return TESTBIT(fFlags, kLoGainFitted);
|
---|
470 | }
|
---|
471 |
|
---|
472 | Bool_t MCalibrationChargePix::IsBlindPixelMethodValid() const
|
---|
473 | {
|
---|
474 | return TESTBIT(fFlags, kBlindPixelMethodValid);
|
---|
475 | }
|
---|
476 |
|
---|
477 | Bool_t MCalibrationChargePix::IsFFactorMethodValid() const
|
---|
478 | {
|
---|
479 | return TESTBIT(fFlags, kFFactorMethodValid);
|
---|
480 | }
|
---|
481 |
|
---|
482 | Bool_t MCalibrationChargePix::IsPINDiodeMethodValid() const
|
---|
483 | {
|
---|
484 | return TESTBIT(fFlags, kPINDiodeMethodValid);
|
---|
485 | }
|
---|
486 |
|
---|
487 | Bool_t MCalibrationChargePix::IsCombinedMethodValid() const
|
---|
488 | {
|
---|
489 | return TESTBIT(fFlags, kCombinedMethodValid);
|
---|
490 | }
|
---|
491 |
|
---|
492 |
|
---|
493 | //
|
---|
494 | // The check return kTRUE if:
|
---|
495 | //
|
---|
496 | // 1) Pixel has a fitted charge greater than fChargeLimit*PedRMS
|
---|
497 | // 2) Pixel has a fit error greater than fChargeErrLimit
|
---|
498 | // 3) Pixel has a fitted charge greater its fChargeRelErrLimit times its charge error
|
---|
499 | // 4) Pixel has a charge sigma bigger than its Pedestal RMS
|
---|
500 | //
|
---|
501 | void MCalibrationChargePix::CheckChargeValidity(MBadPixelsPix *bad)
|
---|
502 | {
|
---|
503 |
|
---|
504 | if (GetMeanCharge() < fChargeLimit*GetPedRms())
|
---|
505 | {
|
---|
506 | *fLog << warn << "WARNING: Fitted Charge is smaller than "
|
---|
507 | << fChargeLimit << " Pedestal RMS in Pixel " << fPixId << endl;
|
---|
508 | bad->SetChargeIsPedestal();
|
---|
509 | bad->SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
|
---|
510 | }
|
---|
511 |
|
---|
512 | if (GetMeanChargeErr() < fChargeErrLimit)
|
---|
513 | {
|
---|
514 | *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
|
---|
515 | << fChargeErrLimit << " in Pixel " << fPixId << endl;
|
---|
516 | bad->SetChargeErrNotValid();
|
---|
517 | bad->SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
|
---|
518 | }
|
---|
519 |
|
---|
520 | if (GetMeanCharge() < fChargeRelErrLimit*GetMeanChargeErr())
|
---|
521 | {
|
---|
522 | *fLog << warn << "WARNING: Fitted Charge is smaller than "
|
---|
523 | << fChargeRelErrLimit << "* its error in Pixel " << fPixId << endl;
|
---|
524 | bad->SetChargeRelErrNotValid();
|
---|
525 | bad->SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
|
---|
526 | }
|
---|
527 |
|
---|
528 | if (GetSigmaCharge() < GetPedRms())
|
---|
529 | {
|
---|
530 | *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in Pixel "
|
---|
531 | << fPixId << endl;
|
---|
532 | bad->SetChargeSigmaNotValid();
|
---|
533 | bad->SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
|
---|
534 | }
|
---|
535 |
|
---|
536 | }
|
---|
537 |
|
---|
538 | //
|
---|
539 | // The check returns kTRUE if:
|
---|
540 | //
|
---|
541 | // The mean arrival time is at least 1.0 slices from the used edge slices
|
---|
542 | //
|
---|
543 | void MCalibrationChargePix::CheckTimeValidity(MBadPixelsPix *bad)
|
---|
544 | {
|
---|
545 |
|
---|
546 | const Float_t loweredge = IsHiGainSaturation() ? fTimeFirstHiGain : fTimeFirstLoGain;
|
---|
547 | const Float_t upperedge = IsHiGainSaturation() ? fTimeLastHiGain : fTimeLastLoGain;
|
---|
548 |
|
---|
549 | if ( fAbsTimeMean < loweredge+1.)
|
---|
550 | {
|
---|
551 | *fLog << warn << "WARNING: Mean ArrivalTime in first extraction bin of the Pixel " << fPixId << endl;
|
---|
552 | bad->SetMeanTimeInFirstBin();
|
---|
553 | bad->SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
|
---|
554 | }
|
---|
555 |
|
---|
556 | if ( fAbsTimeMean > upperedge-1.)
|
---|
557 | {
|
---|
558 | *fLog << warn << "WARNING: Mean ArrivalTime in last extraction bin of the Pixel " << fPixId << endl;
|
---|
559 | bad->SetMeanTimeInLastBin();
|
---|
560 | bad->SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
|
---|
561 | }
|
---|
562 | }
|
---|
563 |
|
---|
564 | void MCalibrationChargePix::CalcLoGainPed()
|
---|
565 | {
|
---|
566 |
|
---|
567 | Float_t pedRmsSquare = fPedRms * fPedRms;
|
---|
568 | Float_t pedRmsSquareErrSquare = fPedErr * fPedErr * pedRmsSquare; // fPedRmsErr = fPedErr/2.
|
---|
569 | Float_t pedRmsSquareErr;
|
---|
570 |
|
---|
571 | //
|
---|
572 | // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it
|
---|
573 | // from the HI GAIN (all calculation per slice up to now):
|
---|
574 | //
|
---|
575 | // We extract the pure NSB contribution:
|
---|
576 | //
|
---|
577 | const Float_t elecRmsSquare = fElectronicPedRms * fElectronicPedRms;
|
---|
578 | const Float_t elecRmsSquareErrSquare = 4.*fElectronicPedRmsErr * fElectronicPedRmsErr * elecRmsSquare;
|
---|
579 |
|
---|
580 | Float_t nsbSquare = pedRmsSquare - elecRmsSquare;
|
---|
581 | Float_t nsbSquareRelErrSquare = (pedRmsSquareErrSquare + elecRmsSquareErrSquare)
|
---|
582 | / (nsbSquare * nsbSquare) ;
|
---|
583 |
|
---|
584 | if (nsbSquare < 0.)
|
---|
585 | nsbSquare = 0.;
|
---|
586 |
|
---|
587 | //
|
---|
588 | // Now, we divide the NSB by the conversion factor and
|
---|
589 | // add it quadratically to the electronic noise
|
---|
590 | //
|
---|
591 | const Float_t conversionSquare = fConversionHiLo * fConversionHiLo;
|
---|
592 | const Float_t conversionSquareRelErrSquare = 4.*fConversionHiLoErr * fConversionHiLoErr / conversionSquare;
|
---|
593 |
|
---|
594 | const Float_t convertedNsbSquare = nsbSquare / conversionSquare;
|
---|
595 | const Float_t convertedNsbSquareErrSquare = (nsbSquareRelErrSquare + conversionSquareRelErrSquare)
|
---|
596 | * convertedNsbSquare * convertedNsbSquare;
|
---|
597 |
|
---|
598 | pedRmsSquare = convertedNsbSquare + elecRmsSquare;
|
---|
599 | pedRmsSquareErr = TMath::Sqrt( convertedNsbSquareErrSquare + elecRmsSquareErrSquare );
|
---|
600 |
|
---|
601 | //
|
---|
602 | // Correct also for the conversion to Hi-Gain:
|
---|
603 | //
|
---|
604 | fLoGainPedRms = TMath::Sqrt(pedRmsSquare) * fConversionHiLo;
|
---|
605 | fLoGainPedRmsErr = 0.5 * pedRmsSquareErr / fLoGainPedRms * fConversionHiLo;
|
---|
606 | }
|
---|
607 |
|
---|
608 | Bool_t MCalibrationChargePix::CalcReducedSigma()
|
---|
609 | {
|
---|
610 |
|
---|
611 | const Float_t sigmaSquare = GetSigmaCharge() * GetSigmaCharge();
|
---|
612 | const Float_t sigmaSquareErrSquare = 4.*GetSigmaChargeErr()* GetSigmaChargeErr() * sigmaSquare;
|
---|
613 |
|
---|
614 | Float_t pedRmsSquare;
|
---|
615 | Float_t pedRmsSquareErrSquare;
|
---|
616 |
|
---|
617 | if (IsHiGainSaturation())
|
---|
618 | {
|
---|
619 | CalcLoGainPed();
|
---|
620 |
|
---|
621 | pedRmsSquare = fLoGainPedRms * fLoGainPedRms;
|
---|
622 | pedRmsSquareErrSquare = 4.* fLoGainPedRmsErr * fLoGainPedRmsErr * pedRmsSquare;
|
---|
623 | } /* if (HiGainSaturation) */
|
---|
624 | else
|
---|
625 | {
|
---|
626 |
|
---|
627 | pedRmsSquare = fPedRms * fPedRms;
|
---|
628 | pedRmsSquareErrSquare = fPedErr * fPedErr * pedRmsSquare; // fPedRmsErr = fPedErr/2.
|
---|
629 | }
|
---|
630 | //
|
---|
631 | // Calculate the reduced sigmas
|
---|
632 | //
|
---|
633 | const Float_t rsigmachargesquare = sigmaSquare - pedRmsSquare;
|
---|
634 |
|
---|
635 | if (rsigmachargesquare <= 0.)
|
---|
636 | {
|
---|
637 | *fLog << warn
|
---|
638 | << "WARNING: Cannot calculate the reduced sigma: smaller than 0 in pixel "
|
---|
639 | << fPixId << endl;
|
---|
640 | return kFALSE;
|
---|
641 | }
|
---|
642 |
|
---|
643 | fRSigmaCharge = TMath::Sqrt(rsigmachargesquare);
|
---|
644 | fRSigmaChargeErr = TMath::Sqrt(sigmaSquareErrSquare + pedRmsSquareErrSquare) / 2. / fRSigmaCharge;
|
---|
645 |
|
---|
646 | return kTRUE;
|
---|
647 | }
|
---|
648 |
|
---|
649 | //
|
---|
650 | // Calculate the number of photo-electrons after the F-Factor method
|
---|
651 | // Calculate the errors of the F-Factor method
|
---|
652 | //
|
---|
653 | Bool_t MCalibrationChargePix::CalcFFactorMethod()
|
---|
654 | {
|
---|
655 |
|
---|
656 | if (fRSigmaCharge < 0.)
|
---|
657 | {
|
---|
658 | SetFFactorMethodValid(kFALSE);
|
---|
659 | return kFALSE;
|
---|
660 | }
|
---|
661 |
|
---|
662 | //
|
---|
663 | // Square all variables in order to avoid applications of square root
|
---|
664 | //
|
---|
665 | // First the relative error squares
|
---|
666 | //
|
---|
667 | const Float_t chargeSquare = GetMeanCharge() * GetMeanCharge();
|
---|
668 | const Float_t chargeSquareRelErrSquare = 4.* GetMeanChargeErr() * GetMeanChargeErr() / chargeSquare;
|
---|
669 |
|
---|
670 | const Float_t ffactorsquare = gkFFactor * gkFFactor;
|
---|
671 | const Float_t ffactorsquareRelErrSquare = 4.*gkFFactorErr * gkFFactorErr / ffactorsquare;
|
---|
672 |
|
---|
673 |
|
---|
674 | const Float_t rsigmaSquare = fRSigmaCharge * fRSigmaCharge;
|
---|
675 | const Float_t rsigmaSquareRelErrSquare = 4.* fRSigmaChargeErr * fRSigmaChargeErr / rsigmaSquare;
|
---|
676 |
|
---|
677 |
|
---|
678 | //
|
---|
679 | // Calculate the number of phe's from the F-Factor method
|
---|
680 | // (independent on Hi Gain or Lo Gain)
|
---|
681 | //
|
---|
682 | fPheFFactorMethod = ffactorsquare * chargeSquare / rsigmaSquare;
|
---|
683 |
|
---|
684 | if (fPheFFactorMethod < 0.)
|
---|
685 | {
|
---|
686 | SetFFactorMethodValid(kFALSE);
|
---|
687 | return kFALSE;
|
---|
688 | }
|
---|
689 |
|
---|
690 | //
|
---|
691 | // Calculate the Error of Nphe
|
---|
692 | //
|
---|
693 | const Float_t pheFFactorRelErrSquare = ffactorsquareRelErrSquare
|
---|
694 | + chargeSquareRelErrSquare
|
---|
695 | + rsigmaSquareRelErrSquare;
|
---|
696 | fPheFFactorMethodErr = TMath::Sqrt(pheFFactorRelErrSquare) * fPheFFactorMethod;
|
---|
697 |
|
---|
698 | SetFFactorMethodValid(kTRUE);
|
---|
699 |
|
---|
700 | return kTRUE;
|
---|
701 | }
|
---|
702 |
|
---|
703 |
|
---|
704 | void MCalibrationChargePix::ApplyLoGainConversion()
|
---|
705 | {
|
---|
706 |
|
---|
707 | const Float_t chargeRelErrSquare = fLoGainMeanChargeErr * fLoGainMeanChargeErr
|
---|
708 | /( fLoGainMeanCharge * fLoGainMeanCharge );
|
---|
709 | const Float_t sigmaRelErrSquare = fLoGainSigmaChargeErr * fLoGainSigmaChargeErr
|
---|
710 | /( fLoGainSigmaCharge * fLoGainSigmaCharge );
|
---|
711 | const Float_t conversionRelErrSquare = fConversionHiLoErr * fConversionHiLoErr
|
---|
712 | /( fConversionHiLo * fConversionHiLo );
|
---|
713 |
|
---|
714 | fLoGainMeanCharge *= fConversionHiLo;
|
---|
715 | fLoGainMeanChargeErr = TMath::Sqrt(chargeRelErrSquare + conversionRelErrSquare) * fLoGainMeanCharge;
|
---|
716 |
|
---|
717 | fLoGainSigmaCharge *= fConversionHiLo;
|
---|
718 | fLoGainSigmaChargeErr = TMath::Sqrt(sigmaRelErrSquare + conversionRelErrSquare) * fLoGainSigmaCharge;
|
---|
719 |
|
---|
720 | fElectronicPedRms = gkElectronicPedRms * TMath::Sqrt(fNumLoGainSamples);
|
---|
721 | fElectronicPedRmsErr = gkElectronicPedRmsErr * TMath::Sqrt(fNumLoGainSamples);
|
---|
722 |
|
---|
723 | }
|
---|
724 |
|
---|