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 | // MCalibrationChargePix
|
---|
27 | //
|
---|
28 | // Storage container of the calibrated Charge of one pixel.
|
---|
29 | //
|
---|
30 | // The following values are initialized to meaningful values:
|
---|
31 | //
|
---|
32 | // - The Electronic Rms to 1.5 per FADC slice
|
---|
33 | // - The uncertainty about the Electronic RMS to 0.3 per slice
|
---|
34 | // - The F-Factor is assumed to have been measured in Munich to 1.13 - 1.17.
|
---|
35 | // with the Munich definition of the F-Factor, thus:
|
---|
36 | // F = Sigma(Out)/Mean(Out) * Mean(In)/Sigma(In)
|
---|
37 | // Mean F-Factor (gkFFactor) = 1.15
|
---|
38 | // Error F-Factor (gkFFactorErr) = 0.02
|
---|
39 | //
|
---|
40 | // The following variables are calculated inside this class:
|
---|
41 | // - fLoGainPedRmsSquare and fLoGainPedRmsSquareVar (see CalcLoGainPedestal())
|
---|
42 | // - fRSigmaSquare and fRSigmaSquareVar (see CalcReducedSigma() )
|
---|
43 | // - fPheFFactorMethod and fPheFFactorMethodVar (see CalcFFactor() )
|
---|
44 | // - fMeanConvFADC2Phe and fMeanConvFADC2PheVar (see CalcConvFFactor() )
|
---|
45 | //
|
---|
46 | // The following variables are set by MHCalibrationChargeCam:
|
---|
47 | // - fAbsTimeMean and fAbsTimeRms
|
---|
48 | // - all variables in MCalibrationPix
|
---|
49 | //
|
---|
50 | // The following variables are set by MCalibrationChargeCalc:
|
---|
51 | // - fPed, fPedVar and fPedRms
|
---|
52 | // - fMeanConvFADC2Phe
|
---|
53 | // - fConvFADC2PheVar
|
---|
54 | // - fSigmaConvFADC2Phe
|
---|
55 | // - fTotalFFactorFFactorMethod
|
---|
56 | // - fTotalFFactorFFactorMethodVar
|
---|
57 | //
|
---|
58 | // The following variables are not yet implemented:
|
---|
59 | // - fConversionHiLo and fConversionHiLoVar (now set fixed to 10. +- 2.5)
|
---|
60 | //
|
---|
61 | // Error of all variables are calculated by error-propagation. Note that internally,
|
---|
62 | // all error variables contain Variances in order to save the CPU-intensive square rooting
|
---|
63 | //
|
---|
64 | // Low-Gain variables are stored internally unconverted, i.e. directly from the summed
|
---|
65 | // FADC slices extraction results, but can be retrieved converted to High-Gain amplifications
|
---|
66 | // by calls to: GetConvertedMean() or GetConvertedSigma()
|
---|
67 | //
|
---|
68 | // See also: MCalibrationChargeCam, MCalibrationChargeCalc,
|
---|
69 | // MHCalibrationChargeCam, MHCalibrationChargePix
|
---|
70 | //
|
---|
71 | //
|
---|
72 | // ClassVersion 3:
|
---|
73 | // + fNumSaturated
|
---|
74 | //
|
---|
75 | /////////////////////////////////////////////////////////////////////////////
|
---|
76 | #include "MCalibrationChargePix.h"
|
---|
77 |
|
---|
78 | #include "MLog.h"
|
---|
79 | #include "MLogManip.h"
|
---|
80 |
|
---|
81 | #include "MBadPixelsPix.h"
|
---|
82 |
|
---|
83 | ClassImp(MCalibrationChargePix);
|
---|
84 |
|
---|
85 | using namespace std;
|
---|
86 |
|
---|
87 | const Float_t MCalibrationChargePix::gkElectronicPedRms = 1.0;
|
---|
88 | const Float_t MCalibrationChargePix::gkElectronicPedRmsErr = 0.35;
|
---|
89 | const Float_t MCalibrationChargePix::gkFFactor = 1.15;
|
---|
90 | const Float_t MCalibrationChargePix::gkFFactorErr = 0.02;
|
---|
91 |
|
---|
92 | const Float_t MCalibrationChargePix::fgConversionHiLo = 10.;
|
---|
93 | const Float_t MCalibrationChargePix::fgConversionHiLoErr = 2.5;
|
---|
94 | const Float_t MCalibrationChargePix::fgPheFFactorMethodLimit = 1.;
|
---|
95 | const Float_t MCalibrationChargePix::fgConvFFactorRelErrLimit = 0.85;
|
---|
96 |
|
---|
97 | // --------------------------------------------------------------------------
|
---|
98 | //
|
---|
99 | // Default Constructor:
|
---|
100 | //
|
---|
101 | // Sets:
|
---|
102 | // - fCalibFlags to 0
|
---|
103 | // - fConversionHiLo to fgConversionHiLo
|
---|
104 | // - fConversionHiLoVar to square of fgConversionHiLoErr
|
---|
105 | // - fConvFFactorelErrLimit to fgConvFFactorRelErrLimit*fgConvFFactorelErrLimit
|
---|
106 | // - fPheFFactorLimit to fgPheFFactorLimit
|
---|
107 | //
|
---|
108 | // Calls:
|
---|
109 | // - Clear()
|
---|
110 | //
|
---|
111 | MCalibrationChargePix::MCalibrationChargePix(const char *name, const char *title)
|
---|
112 | : fCalibFlags(0), fNumSaturated(0)
|
---|
113 | {
|
---|
114 |
|
---|
115 | fName = name ? name : "MCalibrationChargePix";
|
---|
116 | fTitle = title ? title : "Container of the fit results of MHCalibrationChargePixs ";
|
---|
117 |
|
---|
118 | //
|
---|
119 | // At the moment, we don't have a database, yet,
|
---|
120 | // so we get it from the configuration file
|
---|
121 | //
|
---|
122 | SetConversionHiLo();
|
---|
123 | SetConversionHiLoErr();
|
---|
124 |
|
---|
125 | SetPheFFactorMethodLimit();
|
---|
126 | SetConvFFactorRelErrLimit();
|
---|
127 |
|
---|
128 | Clear();
|
---|
129 | }
|
---|
130 |
|
---|
131 | // ------------------------------------------------------------------------
|
---|
132 | //
|
---|
133 | // Sets:
|
---|
134 | // - all flags to kFALSE
|
---|
135 | // - all variables to -1.
|
---|
136 | //
|
---|
137 | // Calls:
|
---|
138 | // - MCalibrationPix::Clear()
|
---|
139 | //
|
---|
140 | void MCalibrationChargePix::Clear(Option_t *o)
|
---|
141 | {
|
---|
142 |
|
---|
143 | SetFFactorMethodValid ( kFALSE );
|
---|
144 |
|
---|
145 | fRSigmaSquare = -1.;
|
---|
146 | fRSigmaSquareVar = -1.;
|
---|
147 |
|
---|
148 | fPed = -1.;
|
---|
149 | fPedRms = -1.;
|
---|
150 | fPedVar = -1.;
|
---|
151 |
|
---|
152 | fLoGainPedRmsSquare = -1.;
|
---|
153 | fLoGainPedRmsSquareVar = -1.;
|
---|
154 |
|
---|
155 | fAbsTimeMean = -1.;
|
---|
156 | fAbsTimeRms = -1.;
|
---|
157 |
|
---|
158 | fPheFFactorMethod = -1.;
|
---|
159 | fPheFFactorMethodVar = -1.;
|
---|
160 |
|
---|
161 | fMeanConvFADC2Phe = -1.;
|
---|
162 | fMeanConvFADC2PheVar = -1.;
|
---|
163 | fMeanFFactorFADC2Phot = -1.;
|
---|
164 | fMeanFFactorFADC2PhotVar = -1.;
|
---|
165 |
|
---|
166 | fNumSaturated = 0;
|
---|
167 |
|
---|
168 | MCalibrationPix::Clear();
|
---|
169 | }
|
---|
170 |
|
---|
171 |
|
---|
172 | // --------------------------------------------------------------------------
|
---|
173 | //
|
---|
174 | // Set F-Factor Method Validity Bit from outside
|
---|
175 | //
|
---|
176 | void MCalibrationChargePix::SetFFactorMethodValid(const Bool_t b )
|
---|
177 | {
|
---|
178 | b ? SETBIT(fCalibFlags, kFFactorMethodValid) : CLRBIT(fCalibFlags, kFFactorMethodValid);
|
---|
179 | }
|
---|
180 |
|
---|
181 | // --------------------------------------------------------------------------
|
---|
182 | //
|
---|
183 | // Set pedestals from outside (done by MCalibrationChargeCalc)
|
---|
184 | //
|
---|
185 | void MCalibrationChargePix::SetPedestal(const Float_t ped, const Float_t pedrms, const Float_t pederr)
|
---|
186 | {
|
---|
187 |
|
---|
188 | fPed = ped;
|
---|
189 | fPedRms = pedrms;
|
---|
190 | fPedVar = pederr*pederr;
|
---|
191 | }
|
---|
192 |
|
---|
193 | // --------------------------------------------------------------------------
|
---|
194 | //
|
---|
195 | // Set pedestals from outside (done by MCalibrationChargeCalc)
|
---|
196 | //
|
---|
197 | void MCalibrationChargePix::SetPed(const Float_t ped, const Float_t pederr)
|
---|
198 | {
|
---|
199 |
|
---|
200 | fPed = ped;
|
---|
201 | fPedVar = pederr*pederr;
|
---|
202 | }
|
---|
203 |
|
---|
204 | // --------------------------------------------------------------------------
|
---|
205 | //
|
---|
206 | // Set pedestals RMS from outside (done by MHCalibrationChargeCam)
|
---|
207 | //
|
---|
208 | void MCalibrationChargePix::SetPedRMS( const Float_t pedrms, const Float_t pedrmserr)
|
---|
209 | {
|
---|
210 |
|
---|
211 | fPedRms = pedrms;
|
---|
212 | fPedRmsVar = pedrmserr*pedrmserr;
|
---|
213 |
|
---|
214 | }
|
---|
215 |
|
---|
216 |
|
---|
217 | // -------------------------------------------------------------------------------
|
---|
218 | //
|
---|
219 | // Get the conversion Error Hi-Gain to Low-Gain:
|
---|
220 | // - If fConversionHiLoVar is smaller than 0 (i.e. has not yet been set), return -1.
|
---|
221 | //
|
---|
222 | Float_t MCalibrationChargePix::GetConversionHiLoErr() const
|
---|
223 | {
|
---|
224 | if (fConversionHiLoVar < 0.)
|
---|
225 | return -1.;
|
---|
226 |
|
---|
227 | return TMath::Sqrt(fConversionHiLoVar);
|
---|
228 | }
|
---|
229 |
|
---|
230 | // --------------------------------------------------------------------------
|
---|
231 | //
|
---|
232 | // Get the relative variance of the conversion factor between higain and logain:
|
---|
233 | // - If fConversionHiLo is 0, return -1.
|
---|
234 | // - If fConversionHiLoVar is smaller than 0, return -1.
|
---|
235 | // - Else returns: fConversionHiLoVar / fConversionHiLo^2
|
---|
236 | //
|
---|
237 | const Float_t MCalibrationChargePix::GetConversionHiLoRelVar() const
|
---|
238 | {
|
---|
239 |
|
---|
240 | if (fConversionHiLoVar < 0.)
|
---|
241 | return -1.;
|
---|
242 |
|
---|
243 | if (fConversionHiLo == 0.)
|
---|
244 | return -1.;
|
---|
245 |
|
---|
246 | return fConversionHiLoVar / (fConversionHiLo * fConversionHiLo);
|
---|
247 | }
|
---|
248 |
|
---|
249 | // --------------------------------------------------------------------------
|
---|
250 | //
|
---|
251 | // Get the relative variance of the electronics pedestal RMS
|
---|
252 | // - returns rel. variance of gkElectronicPedRms
|
---|
253 | //
|
---|
254 | const Float_t MCalibrationChargePix::GetElectronicPedRmsRelVar() const
|
---|
255 | {
|
---|
256 | return gkElectronicPedRmsErr * gkElectronicPedRmsErr / gkElectronicPedRms / gkElectronicPedRms;
|
---|
257 | }
|
---|
258 |
|
---|
259 |
|
---|
260 | // --------------------------------------------------------------------------
|
---|
261 | //
|
---|
262 | // Get the relative variance of the conversion factor between higain and logain:
|
---|
263 | // - If gkFFactor is 0, return -1.
|
---|
264 | // - If gkFFactorErr is smaller than 0, return -1.
|
---|
265 | // - Else returns: gkFFactorErr^2 / gkFFactor*^2
|
---|
266 | //
|
---|
267 | const Float_t MCalibrationChargePix::GetFFactorRelVar() const
|
---|
268 | {
|
---|
269 |
|
---|
270 | if (gkFFactorErr < 0.)
|
---|
271 | return -1.;
|
---|
272 |
|
---|
273 | if (gkFFactor == 0.)
|
---|
274 | return -1.;
|
---|
275 |
|
---|
276 | return gkFFactorErr * gkFFactorErr / (gkFFactor * gkFFactor);
|
---|
277 | }
|
---|
278 |
|
---|
279 |
|
---|
280 | // --------------------------------------------------------------------------
|
---|
281 | //
|
---|
282 | // Get the pedestals RMS:
|
---|
283 | // - Test bit kHiGainSaturation:
|
---|
284 | // If yes, return square root of fLoGainPedRmsSquare (if greater than 0, otherwise -1.),
|
---|
285 | // If no, return fPedRms
|
---|
286 | //
|
---|
287 | Float_t MCalibrationChargePix::GetPedRms() const
|
---|
288 | {
|
---|
289 |
|
---|
290 | if (IsHiGainSaturation())
|
---|
291 | if (fLoGainPedRmsSquare < 0.)
|
---|
292 | return -1.;
|
---|
293 | else
|
---|
294 | return TMath::Sqrt(fLoGainPedRmsSquare);
|
---|
295 |
|
---|
296 | return fPedRms;
|
---|
297 | }
|
---|
298 |
|
---|
299 | // --------------------------------------------------------------------------
|
---|
300 | //
|
---|
301 | // Get the Error of the pedestals RMS:
|
---|
302 | // - Test bit kHiGainSaturation:
|
---|
303 | // If yes, return square root of (0.25*fLoGainPedRmsSquareVar/ fLoGainPedRmsSquare) (if greater than 0, otherwise -1.)
|
---|
304 | // If no , return square root of (fPedVar) (if greater than 0, otherwise -1.), divided by 2.
|
---|
305 | //
|
---|
306 | Float_t MCalibrationChargePix::GetPedRmsErr() const
|
---|
307 | {
|
---|
308 | if (IsHiGainSaturation())
|
---|
309 | if (fLoGainPedRmsSquareVar < 0.)
|
---|
310 | return -1.;
|
---|
311 | else
|
---|
312 | return TMath::Sqrt(0.25*fLoGainPedRmsSquareVar/fLoGainPedRmsSquare);
|
---|
313 | else
|
---|
314 | if (fPedVar < 0.)
|
---|
315 | return -1.;
|
---|
316 | else
|
---|
317 | return TMath::Sqrt(fPedVar)/2.;
|
---|
318 | }
|
---|
319 |
|
---|
320 |
|
---|
321 | // --------------------------------------------------------------------------
|
---|
322 | //
|
---|
323 | // Get the Low Gain Mean Charge converted to High Gain amplification:
|
---|
324 | // Returns fLoGainMean multiplied with fConversionHiLo if IsHiGainSaturation(),
|
---|
325 | // else return fHiGainMean
|
---|
326 | //
|
---|
327 | Float_t MCalibrationChargePix::GetConvertedMean() const
|
---|
328 | {
|
---|
329 |
|
---|
330 | if (IsHiGainSaturation())
|
---|
331 | return fLoGainMean * fConversionHiLo;
|
---|
332 |
|
---|
333 | return fHiGainMean;
|
---|
334 | }
|
---|
335 |
|
---|
336 | // --------------------------------------------------------------------------
|
---|
337 | //
|
---|
338 | // Get the Error of the converted Low Gain Mean:
|
---|
339 | //
|
---|
340 | // Returns -1 if the variable fLoGainMean or fLoGainMeanVar are smaller than 0.
|
---|
341 | //
|
---|
342 | // Returns the square root of the quadratic sum of the relative variances of
|
---|
343 | // the fLoGainMean and fConversionHiLo, mulitplied with GetConvertedMean()
|
---|
344 | // in case of HiGain Saturation,
|
---|
345 | // else return GetMeanErr()
|
---|
346 | //
|
---|
347 | Float_t MCalibrationChargePix::GetConvertedMeanErr() const
|
---|
348 | {
|
---|
349 |
|
---|
350 | if (IsHiGainSaturation())
|
---|
351 | {
|
---|
352 | const Float_t logainrelvar = GetLoGainMeanRelVar();
|
---|
353 |
|
---|
354 | if (logainrelvar < 0.)
|
---|
355 | return -1.;
|
---|
356 |
|
---|
357 | return TMath::Sqrt(logainrelvar + GetConversionHiLoRelVar()) * GetConvertedMean();
|
---|
358 | }
|
---|
359 | else
|
---|
360 | return GetMeanErr();
|
---|
361 |
|
---|
362 | }
|
---|
363 |
|
---|
364 | // --------------------------------------------------------------------------
|
---|
365 | //
|
---|
366 | // Get the Low Gain Sigma converted to High Gain amplification:
|
---|
367 | // Returns fLoGainSigma multiplied with fConversionHiLo if IsHiGainSaturation()
|
---|
368 | // else return fHiGainSigma
|
---|
369 | //
|
---|
370 | Float_t MCalibrationChargePix::GetConvertedSigma() const
|
---|
371 | {
|
---|
372 |
|
---|
373 | if (IsHiGainSaturation())
|
---|
374 | return fLoGainSigma * fConversionHiLo;
|
---|
375 | else
|
---|
376 | return fHiGainSigma;
|
---|
377 | }
|
---|
378 |
|
---|
379 | // --------------------------------------------------------------------------
|
---|
380 | //
|
---|
381 | // Get the Error of the converted Sigma:
|
---|
382 | //
|
---|
383 | // Returns -1 if the variable fLoGainSigma or fLoGainSigmaVar are smaller than 0.
|
---|
384 | //
|
---|
385 | // if IsHiGainSaturatio()
|
---|
386 | // returns the square root of the quadratic sum of the relative variances of
|
---|
387 | // the fLoGainSigma and fConversionHiLo, mulitplied with GetConvertedSigma()
|
---|
388 | // else returns GetSigmaErr()
|
---|
389 | //
|
---|
390 | Float_t MCalibrationChargePix::GetConvertedSigmaErr() const
|
---|
391 | {
|
---|
392 |
|
---|
393 | if (IsHiGainSaturation())
|
---|
394 | {
|
---|
395 | if (fLoGainSigmaVar < 0.)
|
---|
396 | return -1.;
|
---|
397 |
|
---|
398 | if (fLoGainSigma < 0.)
|
---|
399 | return -1.;
|
---|
400 |
|
---|
401 | const Float_t sigmaRelVar = fLoGainSigmaVar
|
---|
402 | /( fLoGainSigma * fLoGainSigma );
|
---|
403 |
|
---|
404 | return TMath::Sqrt(sigmaRelVar+GetConversionHiLoRelVar()) * GetConvertedSigma();
|
---|
405 | }
|
---|
406 | else
|
---|
407 | return GetSigmaErr();
|
---|
408 |
|
---|
409 |
|
---|
410 | }
|
---|
411 |
|
---|
412 | // --------------------------------------------------------------------------
|
---|
413 | //
|
---|
414 | // Get the converted reduced Sigma:
|
---|
415 | // - If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
|
---|
416 | // - Test bit kHiGainSaturation:
|
---|
417 | // If yes, return square root of fRSigmaSquare, multiplied with fConversionHiLo,
|
---|
418 | // If no , return square root of fRSigmaSquare
|
---|
419 | //
|
---|
420 | Float_t MCalibrationChargePix::GetConvertedRSigma() const
|
---|
421 | {
|
---|
422 | if (fRSigmaSquare < 0)
|
---|
423 | return -1;
|
---|
424 |
|
---|
425 | const Float_t rsigma = TMath::Sqrt(fRSigmaSquare);
|
---|
426 |
|
---|
427 | return IsHiGainSaturation() ? rsigma*fConversionHiLo : rsigma ;
|
---|
428 | }
|
---|
429 |
|
---|
430 | // --------------------------------------------------------------------------
|
---|
431 | //
|
---|
432 | // Get the error of the converted reduced Sigma:
|
---|
433 | // - If fRSigmaSquareVar is smaller than 0 (i.e. has not yet been set), return -1.
|
---|
434 | // - Calculate the absolute variance of the reduced sigma with the formula:
|
---|
435 | // reduced sigma variance = 0.25 * fRSigmaSquareVar / fRSigmaSquare
|
---|
436 | // - Test bit kHiGainSaturation:
|
---|
437 | // If yes, returns the square root of the quadratic sum of the relative variances of the
|
---|
438 | // reduced sigma and fConversionHiLo, mulitplied with GetRSigma()
|
---|
439 | // Else returns the square root of rel. (0.25*fRSigmaSquareVar / fRSigmaSquare)
|
---|
440 | //
|
---|
441 | Float_t MCalibrationChargePix::GetConvertedRSigmaErr() const
|
---|
442 | {
|
---|
443 |
|
---|
444 | if (fRSigmaSquareVar < 0)
|
---|
445 | return -1;
|
---|
446 |
|
---|
447 | //
|
---|
448 | // SigmaSquareVar = 4. * Sigma * Sigma * Var(sigma)
|
---|
449 | // ==> Var(sigma) = 0.25 * SigmaSquareVar / (Sigma * Sigma)
|
---|
450 | //
|
---|
451 | const Float_t rsigmaVar = 0.25 * fRSigmaSquareVar / fRSigmaSquare;
|
---|
452 |
|
---|
453 | if (IsHiGainSaturation())
|
---|
454 | return TMath::Sqrt(rsigmaVar/fRSigmaSquare + GetConversionHiLoRelVar()) * GetRSigma();
|
---|
455 | else
|
---|
456 | return TMath::Sqrt(rsigmaVar);
|
---|
457 |
|
---|
458 | }
|
---|
459 |
|
---|
460 | // --------------------------------------------------------------------------
|
---|
461 | //
|
---|
462 | // Get the reduced Sigma:
|
---|
463 | // - If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
|
---|
464 | //
|
---|
465 | Float_t MCalibrationChargePix::GetRSigma() const
|
---|
466 | {
|
---|
467 | if (fRSigmaSquare < 0)
|
---|
468 | return -1;
|
---|
469 |
|
---|
470 | return TMath::Sqrt(fRSigmaSquare);
|
---|
471 |
|
---|
472 | }
|
---|
473 |
|
---|
474 | // --------------------------------------------------------------------------
|
---|
475 | //
|
---|
476 | // Get the error of the reduced Sigma:
|
---|
477 | // - If fRSigmaSquareVar is smaller than 0 (i.e. has not yet been set), return -1.
|
---|
478 | // - Calculate the absolute variance of the reduced sigma with the formula:
|
---|
479 | // reduced sigma variance = 0.25 * fRSigmaSquareVar / fRSigmaSquare
|
---|
480 | //
|
---|
481 | Float_t MCalibrationChargePix::GetRSigmaErr() const
|
---|
482 | {
|
---|
483 |
|
---|
484 | if (fRSigmaSquareVar < 0)
|
---|
485 | return -1;
|
---|
486 |
|
---|
487 | //
|
---|
488 | // SigmaSquareVar = 4. * Sigma * Sigma * Var(sigma)
|
---|
489 | // ==> Var(sigma) = 0.25 * SigmaSquareVar / (Sigma * Sigma)
|
---|
490 | //
|
---|
491 | return TMath::Sqrt(0.25 * fRSigmaSquareVar / fRSigmaSquare);
|
---|
492 |
|
---|
493 | }
|
---|
494 |
|
---|
495 | // --------------------------------------------------------------------------
|
---|
496 | //
|
---|
497 | // Get the reduced Sigma per Charge:
|
---|
498 | // - If GetRSigma() is smaller or equal 0. (i.e. has not yet been set), return -1.
|
---|
499 | // - If GetMean() is 0. or -1. (i.e. has not yet been set), return -1.
|
---|
500 | // - Return GetRSigma() / GetMean()
|
---|
501 | //
|
---|
502 | Float_t MCalibrationChargePix::GetRSigmaPerCharge() const
|
---|
503 | {
|
---|
504 |
|
---|
505 | const Float_t rsigma = GetRSigma();
|
---|
506 |
|
---|
507 | if (rsigma <= 0)
|
---|
508 | return -1.;
|
---|
509 |
|
---|
510 |
|
---|
511 | const Float_t mean = GetMean();
|
---|
512 |
|
---|
513 | if (mean == 0. || mean == -1.)
|
---|
514 | return -1.;
|
---|
515 |
|
---|
516 | return rsigma / mean;
|
---|
517 | }
|
---|
518 |
|
---|
519 |
|
---|
520 | // --------------------------------------------------------------------------
|
---|
521 | //
|
---|
522 | // Get the error of the reduced Sigma per Charge:
|
---|
523 | // - If GetRSigmaRelVar() is smaller or equal 0. (i.e. has not yet been set), return -1.
|
---|
524 | // - If GetMeanRelVar() is smaller or equal 0. (i.e. has not yet been set), return -1.
|
---|
525 | // - Return the propagated error of GetRSigmaPerCharge()
|
---|
526 | //
|
---|
527 | Float_t MCalibrationChargePix::GetRSigmaPerChargeErr() const
|
---|
528 | {
|
---|
529 |
|
---|
530 | const Float_t rsigmarelvar = GetRSigmaRelVar();
|
---|
531 |
|
---|
532 | if (rsigmarelvar <= 0)
|
---|
533 | return -1.;
|
---|
534 |
|
---|
535 |
|
---|
536 | const Float_t meanrelvar = GetMeanRelVar();
|
---|
537 |
|
---|
538 | if (meanrelvar <= 0.)
|
---|
539 | return -1.;
|
---|
540 |
|
---|
541 | return TMath::Sqrt(rsigmarelvar + meanrelvar) * GetRSigmaPerCharge();
|
---|
542 | }
|
---|
543 |
|
---|
544 | // --------------------------------------------------------------------------
|
---|
545 | //
|
---|
546 | // Get the reduced Sigma Square:
|
---|
547 | // - If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
|
---|
548 | // - Test bit kHiGainSaturation:
|
---|
549 | // If yes, return fRSigmaSquare, multiplied with fConversionHiLo^2,
|
---|
550 | // If no , return fRSigmaSquare
|
---|
551 | //
|
---|
552 | Float_t MCalibrationChargePix::GetConvertedRSigmaSquare() const
|
---|
553 | {
|
---|
554 | if (fRSigmaSquare < 0)
|
---|
555 | return -1;
|
---|
556 |
|
---|
557 | return IsHiGainSaturation() ? fRSigmaSquare*fConversionHiLo*fConversionHiLo : fRSigmaSquare ;
|
---|
558 | }
|
---|
559 |
|
---|
560 | // --------------------------------------------------------------------------
|
---|
561 | //
|
---|
562 | // Get the relative variance of the reduced Sigma:
|
---|
563 | // - If fRSigmaSquareVar is smaller than 0 (i.e. has not yet been set), return -1.
|
---|
564 | // - Calculate the relative variance of the reduced sigma squares with the formula:
|
---|
565 | // reduced sigma rel. variance = 0.25 * fRSigmaSquareVar / fRSigmaSquare / fRSigmaSquare
|
---|
566 | // - Test bit kHiGainSaturation:
|
---|
567 | // If yes, returns the sum of the relative variances of the reduced sigma and fConversionHiLo
|
---|
568 | // Else returns the relative variance of the reduced sigma
|
---|
569 | //
|
---|
570 | Float_t MCalibrationChargePix::GetRSigmaRelVar() const
|
---|
571 | {
|
---|
572 |
|
---|
573 | if (fRSigmaSquareVar < 0)
|
---|
574 | return -1;
|
---|
575 |
|
---|
576 | //
|
---|
577 | // SigmaSquareVar = 4. * Sigma * Sigma * Var(sigma)
|
---|
578 | // ==> Var(sigma) = 0.25 * SigmaSquareVar / (Sigma * Sigma)
|
---|
579 | //
|
---|
580 | return 0.25 * fRSigmaSquareVar / ( fRSigmaSquare * fRSigmaSquare );
|
---|
581 |
|
---|
582 | }
|
---|
583 |
|
---|
584 | // --------------------------------------------------------------------------
|
---|
585 | //
|
---|
586 | // Get the error on the number of photo-electrons (F-Factor Method):
|
---|
587 | // - If fPheFFactorMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
|
---|
588 | // - Else returns the square root of fPheFFactorMethodVar
|
---|
589 | //
|
---|
590 | Float_t MCalibrationChargePix::GetPheFFactorMethodErr() const
|
---|
591 | {
|
---|
592 | if (fPheFFactorMethodVar < 0.)
|
---|
593 | return -1.;
|
---|
594 | return TMath::Sqrt(fPheFFactorMethodVar);
|
---|
595 | }
|
---|
596 |
|
---|
597 | // --------------------------------------------------------------------------
|
---|
598 | //
|
---|
599 | // Get the error on the mean total F-Factor of the signal readout (F-Factor Method):
|
---|
600 | // - If fMeanFFactorFADC2PhotVar is smaller than 0 (i.e. has not yet been set), return -1.
|
---|
601 | // - Else returns the square root of fMeanFFactorFADC2PhotVar
|
---|
602 | //
|
---|
603 | Float_t MCalibrationChargePix::GetMeanFFactorFADC2PhotErr() const
|
---|
604 | {
|
---|
605 | if (fMeanFFactorFADC2PhotVar < 0.)
|
---|
606 | return -1.;
|
---|
607 | return TMath::Sqrt(fMeanFFactorFADC2PhotVar);
|
---|
608 | }
|
---|
609 |
|
---|
610 | // --------------------------------------------------------------------------
|
---|
611 | //
|
---|
612 | // Get the relative variance on the number of photo-electrons (F-Factor Method):
|
---|
613 | // - If fPheFFactorMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
|
---|
614 | // - If fPheFFactorMethod is 0, return -1.
|
---|
615 | // - Else returns fPheFFactorMethodVar / fPheFFactorMethod^2
|
---|
616 | //
|
---|
617 | Float_t MCalibrationChargePix::GetPheFFactorMethodRelVar() const
|
---|
618 | {
|
---|
619 | if (fPheFFactorMethodVar < 0.)
|
---|
620 | return -1.;
|
---|
621 | if (fPheFFactorMethod == 0.)
|
---|
622 | return -1.;
|
---|
623 |
|
---|
624 | return fPheFFactorMethodVar / (fPheFFactorMethod * fPheFFactorMethod);
|
---|
625 | }
|
---|
626 |
|
---|
627 |
|
---|
628 | // --------------------------------------------------------------------------
|
---|
629 | //
|
---|
630 | // Get the error on the mean conversion factor (FFactor Method):
|
---|
631 | // - If fMeanConvFADC2PheVar is smaller than 0 (i.e. has not yet been set), return -1.
|
---|
632 | // - Else returns the square root of fMeanConvFADC2PheVar
|
---|
633 | //
|
---|
634 | Float_t MCalibrationChargePix::GetMeanConvFADC2PheErr() const
|
---|
635 | {
|
---|
636 | if (fMeanConvFADC2PheVar < 0.)
|
---|
637 | return -1.;
|
---|
638 | return TMath::Sqrt(fMeanConvFADC2PheVar);
|
---|
639 | }
|
---|
640 |
|
---|
641 | // --------------------------------------------------------------------------
|
---|
642 | //
|
---|
643 | // Test bit kFFactorMethodValid
|
---|
644 | //
|
---|
645 | Bool_t MCalibrationChargePix::IsFFactorMethodValid() const
|
---|
646 | {
|
---|
647 | return TESTBIT(fCalibFlags, kFFactorMethodValid);
|
---|
648 | }
|
---|
649 |
|
---|
650 |
|
---|
651 | // ----------------------------------------------------------------------------
|
---|
652 | //
|
---|
653 | // - If fSigma is smaller than 0 (i.e. has not yet been set), return kFALSE
|
---|
654 | // - If fPedRms is smaller than 0 (i.e. has not yet been set), return kFALSE
|
---|
655 | //
|
---|
656 | // Calculate the reduced sigma of the low-Gain FADC slices:
|
---|
657 | // - Test bit IsHiGainSaturation() for the Sigma:
|
---|
658 | // If yes, take fLoGainSigma and fLoGainSigmaVar
|
---|
659 | // If no , take fHiGainSigma and fHiGainSigmaVar
|
---|
660 | //
|
---|
661 | // - Test bit IsHiGainSaturation() for the pedRMS:
|
---|
662 | // If yes, take fLoGainPedRmsSquare and fLoGainPedRmsSquareVar
|
---|
663 | // If no , take fPedRms and fPedVar
|
---|
664 | //
|
---|
665 | // - Calculate the reduced sigma with the formula:
|
---|
666 | // fRSigmaSquare = Sigma*Sigma - pedRMS*pedRMS
|
---|
667 | //
|
---|
668 | // - If fRSigmaSquare is smaller than 0, give a warning and return kFALSE
|
---|
669 | //
|
---|
670 | // - Calculate the variance of the reduced sigma with the formula:
|
---|
671 | // fRSigmaSquareVar = 4.* (sigmaVar*Sigma*Sigma + pedRmsVar*pedRMS*pedRMS)
|
---|
672 | //
|
---|
673 | // A back-transformation to the corr. amplification factor of the High-Gain is done
|
---|
674 | // in GetRSigma() and GetRSigmaErr()
|
---|
675 | //
|
---|
676 | Bool_t MCalibrationChargePix::CalcReducedSigma(const Float_t extractorres)
|
---|
677 | {
|
---|
678 |
|
---|
679 | if (GetSigma() < 0.)
|
---|
680 | return kFALSE;
|
---|
681 |
|
---|
682 | if (GetPedRms() < 0.)
|
---|
683 | return kFALSE;
|
---|
684 |
|
---|
685 | const Float_t sigma = IsHiGainSaturation() ? fLoGainSigma : fHiGainSigma ;
|
---|
686 | const Float_t sigmavar = IsHiGainSaturation() ? fLoGainSigmaVar : fHiGainSigmaVar;
|
---|
687 | const Float_t pedRmsSquare = IsHiGainSaturation() ? fLoGainPedRmsSquare : fPedRms*fPedRms;
|
---|
688 | const Float_t pedRmsSquareVar = IsHiGainSaturation() ? fLoGainPedRmsSquareVar : 0.25*fPedVar*pedRmsSquare;
|
---|
689 | const Float_t extractorresVar = extractorres * extractorres;
|
---|
690 |
|
---|
691 | if (IsDebug())
|
---|
692 | {
|
---|
693 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
694 | << " HiGainSaturation: " << IsHiGainSaturation()
|
---|
695 | << " Sigma: " << sigma
|
---|
696 | << " Var.Sigma: " << sigmavar
|
---|
697 | << " PedRmsSquare: " << pedRmsSquare
|
---|
698 | << " pedRmsSquareVar: " << pedRmsSquareVar
|
---|
699 | << " extractorresVar: " << extractorresVar
|
---|
700 | << endl;
|
---|
701 | }
|
---|
702 |
|
---|
703 | const Float_t sigmaSquare = sigma * sigma;
|
---|
704 | const Float_t sigmaSquareVar = 4. * sigmavar * sigmaSquare;
|
---|
705 |
|
---|
706 | //
|
---|
707 | // Calculate the reduced sigmas
|
---|
708 | //
|
---|
709 | fRSigmaSquare = sigmaSquare - pedRmsSquare - extractorresVar;
|
---|
710 |
|
---|
711 | if (IsDebug())
|
---|
712 | {
|
---|
713 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
714 | << " Red.Sigma Square: " << fRSigmaSquare
|
---|
715 | << endl;
|
---|
716 | }
|
---|
717 |
|
---|
718 | if (fRSigmaSquare <= 0.)
|
---|
719 | {
|
---|
720 | if (IsDebug())
|
---|
721 | *fLog << warn
|
---|
722 | << "WARNING: Cannot calculate the reduced sigma: smaller than 0 in pixel "
|
---|
723 | << fPixId << endl;
|
---|
724 | return kFALSE;
|
---|
725 | }
|
---|
726 |
|
---|
727 |
|
---|
728 | fRSigmaSquareVar = 4. * (sigmaSquareVar + pedRmsSquareVar);
|
---|
729 |
|
---|
730 | if (IsDebug())
|
---|
731 | {
|
---|
732 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
733 | << " Var.Red.Sigma Square: " << fRSigmaSquareVar
|
---|
734 | << endl;
|
---|
735 | }
|
---|
736 |
|
---|
737 | return kTRUE;
|
---|
738 | }
|
---|
739 |
|
---|
740 | // ------------------------------------------------------------------
|
---|
741 | //
|
---|
742 | // If fRSigmaSquare is smaller than 0 (i.e. has not yet been set),
|
---|
743 | // return kFALSE
|
---|
744 | //
|
---|
745 | // Calculate the number of photo-electrons with the F-Factor method:
|
---|
746 | // - Test bit IsHiGainSaturation() for the Mean Sum of FADC slices:
|
---|
747 | // If yes, take fLoGainMean and fLoGainMeanVar
|
---|
748 | // If no , take fHiGainMean and fHiGainMeanVar
|
---|
749 | //
|
---|
750 | // - Test bit IsHiGainSaturation() for the pedRMS:
|
---|
751 | // If yes, take fLoGainPedRmsSquare and fLoGainPedRmsSquareVar
|
---|
752 | // If no , take fPedRms and fPedVar
|
---|
753 | //
|
---|
754 | // - Calculate the number of photo-electrons with the formula:
|
---|
755 | // fPheFFactorMethod = gkFFactor*gkFFactor * Mean * Mean / fRSigmaSquare
|
---|
756 | //
|
---|
757 | // - Calculate the Variance on the photo-electrons with the formula:
|
---|
758 | // fPheFFactorMethodVar = ( 4. * gkFFactorErr * gkFFactorErr / ( gkFFactor * gkFFactor )
|
---|
759 | // + 4. * Mean Var. / ( Mean * Mean )
|
---|
760 | // + fRSigmaSquareVar / fRSigmaSquare
|
---|
761 | // ) * fPheFFactorMethod * fPheFFactorMethod
|
---|
762 | //
|
---|
763 | // - If fPheFFactorMethod is less than fPheFFactorMethodLimit,
|
---|
764 | // set kFFactorMethodValid to kFALSE and return kFALSE
|
---|
765 | //
|
---|
766 | Bool_t MCalibrationChargePix::CalcFFactor()
|
---|
767 | {
|
---|
768 | SetFFactorMethodValid(kFALSE);
|
---|
769 |
|
---|
770 | if (fRSigmaSquare < 0.)
|
---|
771 | return kFALSE;
|
---|
772 |
|
---|
773 | //
|
---|
774 | // Square all variables in order to avoid applications of square root
|
---|
775 | //
|
---|
776 | const Float_t meanSquare = GetMean() * GetMean();
|
---|
777 | const Float_t meanSquareRelVar = 4.* GetMeanRelVar();
|
---|
778 |
|
---|
779 | const Float_t ffactorsquare = gkFFactor * gkFFactor;
|
---|
780 | const Float_t ffactorsquareRelVar = 4.* GetFFactorRelVar();
|
---|
781 |
|
---|
782 | const Float_t rsigmaSquareRelVar = fRSigmaSquareVar / fRSigmaSquare / fRSigmaSquare;
|
---|
783 | //
|
---|
784 | // Calculate the number of phe's from the F-Factor method
|
---|
785 | // (independent on Hi Gain or Lo Gain)
|
---|
786 | //
|
---|
787 | fPheFFactorMethod = ffactorsquare * meanSquare / fRSigmaSquare;
|
---|
788 |
|
---|
789 | if (IsDebug())
|
---|
790 | {
|
---|
791 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
792 | << " F-Factor Square: " << ffactorsquare
|
---|
793 | << " Mean Square: " << meanSquare
|
---|
794 | << " Red.Sigma Square: " << fRSigmaSquare
|
---|
795 | << " Photo-electrons: " << fPheFFactorMethod
|
---|
796 | << endl;
|
---|
797 | }
|
---|
798 |
|
---|
799 | if (fPheFFactorMethod < fPheFFactorMethodLimit)
|
---|
800 | return kFALSE;
|
---|
801 |
|
---|
802 | //
|
---|
803 | // Calculate the Error of Nphe
|
---|
804 | //
|
---|
805 | const Float_t pheRelVar = ffactorsquareRelVar + meanSquareRelVar + rsigmaSquareRelVar;
|
---|
806 | fPheFFactorMethodVar = pheRelVar * fPheFFactorMethod * fPheFFactorMethod;
|
---|
807 |
|
---|
808 | if (IsDebug())
|
---|
809 | {
|
---|
810 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
811 | << " Rel.Var.F-Factor Square: " << ffactorsquareRelVar
|
---|
812 | << " Rel.Var. Mean Square: " << meanSquareRelVar
|
---|
813 | << " Rel.Var. Red.Sigma Square: " << rsigmaSquareRelVar
|
---|
814 | << " Rel.Var. Photo-electrons: " << pheRelVar
|
---|
815 | << endl;
|
---|
816 | }
|
---|
817 |
|
---|
818 | if (fPheFFactorMethodVar < 0. )
|
---|
819 | return kFALSE;
|
---|
820 |
|
---|
821 | return kTRUE;
|
---|
822 | }
|
---|
823 |
|
---|
824 | // ------------------------------------------------------------------
|
---|
825 | //
|
---|
826 | // If fPheFFactorMethod is smaller than 0 (i.e. has not yet been set),
|
---|
827 | // return kFALSE
|
---|
828 | //
|
---|
829 | // If GetCovertedMean() is smaller than 0 (i.e. has not yet been set),
|
---|
830 | // return kFALSE
|
---|
831 | //
|
---|
832 | // Calculate fMeanConvFADC2Phe with the following formula:
|
---|
833 | //
|
---|
834 | // fMeanConvFADC2Phe = fPheFFactorMethod / GetConvMean();
|
---|
835 | //
|
---|
836 | // Calculate the rel. variance of fMeanConvFADC2Phe, taking into account that
|
---|
837 | // in the calculation of the number of phe's one mean square has already been used.
|
---|
838 | // Now, dividing by another mean, one mean calcels out, one cannot directly propagate
|
---|
839 | // the errors, but instead havs to take into account this cancellation:
|
---|
840 | //
|
---|
841 | // convrelvar = ffactorsquareRelVar + GetMeanRelVar() + rsigmaSquareRelVar;
|
---|
842 | //
|
---|
843 | // If confrelvar is smaller than 0. or greater than fConvFFactorRelVarLimit,
|
---|
844 | // return kFALSE
|
---|
845 | //
|
---|
846 | // Calculate the variance of fMeanConvFADC2Phe with the formula:
|
---|
847 | //
|
---|
848 | // fMeanConvFADC2PheVar = convrelvar * fMeanConvFADC2Phe * fMeanConvFADC2Phe;
|
---|
849 | //
|
---|
850 | // Set kFFactorMethodValid to kTRUE and
|
---|
851 | // return kTRUE
|
---|
852 | //
|
---|
853 | Bool_t MCalibrationChargePix::CalcConvFFactor()
|
---|
854 | {
|
---|
855 |
|
---|
856 | if (fPheFFactorMethod <= 0.)
|
---|
857 | return kFALSE;
|
---|
858 |
|
---|
859 | const Float_t convmean = GetConvertedMean();
|
---|
860 |
|
---|
861 | if (convmean <= 0.)
|
---|
862 | return kFALSE;
|
---|
863 |
|
---|
864 | fMeanConvFADC2Phe = fPheFFactorMethod / convmean;
|
---|
865 |
|
---|
866 | if (IsDebug())
|
---|
867 | {
|
---|
868 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
869 | << " Converted Mean: " << convmean
|
---|
870 | << " Conversion FADC2Phe: " << fMeanConvFADC2Phe
|
---|
871 | << endl;
|
---|
872 | }
|
---|
873 |
|
---|
874 | const Float_t ffactorsquareRelVar = 4.* GetFFactorRelVar();
|
---|
875 | const Float_t rsigmaSquareRelVar = fRSigmaSquareVar / fRSigmaSquare / fRSigmaSquare;
|
---|
876 | //
|
---|
877 | // In the calculation of the number of phe's one mean square has already been used.
|
---|
878 | // Now, we divide by another mean, so one mean calcels out, we cannot directly propagate
|
---|
879 | // the errors, but have to take account of this cancellation:
|
---|
880 | //
|
---|
881 | Float_t convrelvar = ffactorsquareRelVar + GetMeanRelVar() + rsigmaSquareRelVar;
|
---|
882 | const Float_t limit = IsHiGainSaturation() ? fConvFFactorRelVarLimit * 4. : fConvFFactorRelVarLimit;
|
---|
883 |
|
---|
884 | //
|
---|
885 | // Also have to take into account the pixels labelled MBadPixelsPix::kChargeSigmaNotValid which do not
|
---|
886 | // have a fRSigmaSquareVar, calculate their error directly!
|
---|
887 | //
|
---|
888 | if (fRSigmaSquareVar < 0.)
|
---|
889 | convrelvar = GetMeanRelVar() + GetPheFFactorMethodRelVar();
|
---|
890 |
|
---|
891 | if (IsDebug())
|
---|
892 | {
|
---|
893 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
894 | << " Rel.Var.Red.Sigma: " << rsigmaSquareRelVar
|
---|
895 | << " Rel.Var.Mean: " << GetMeanRelVar()
|
---|
896 | << " Rel.Var.F-Factor: " << ffactorsquareRelVar
|
---|
897 | << " Rel.Var.Conversion FADC2Phe: " << convrelvar
|
---|
898 | << endl;
|
---|
899 | }
|
---|
900 |
|
---|
901 | if (convrelvar > limit || convrelvar < 0.)
|
---|
902 | {
|
---|
903 | *fLog << warn << GetDescriptor() << ": Conv. F-Factor Method Rel. Var.: "
|
---|
904 | << Form("%4.3f out of limits: [0,%3.2f] in pixel:%4i",convrelvar,limit,fPixId) << endl;
|
---|
905 | return kFALSE;
|
---|
906 | }
|
---|
907 |
|
---|
908 | fMeanConvFADC2PheVar = convrelvar * fMeanConvFADC2Phe * fMeanConvFADC2Phe;
|
---|
909 |
|
---|
910 | SetFFactorMethodValid(kTRUE);
|
---|
911 | return kTRUE;
|
---|
912 | }
|
---|
913 |
|
---|
914 | // ----------------------------------------------------------------------------------
|
---|
915 | //
|
---|
916 | // If photflux is smaller or equal 0, return kFALSE
|
---|
917 | //
|
---|
918 | // Calculate the total F-Factor with the formula:
|
---|
919 | // fMeanFFactorFADC2Phot = Sqrt ( fRSigmaSquare ) / GetMean() * sqrt(nphotons)
|
---|
920 | //
|
---|
921 | // Calculate the error of the total F-Factor
|
---|
922 | //
|
---|
923 | Bool_t MCalibrationChargePix::CalcMeanFFactor( const Float_t nphotons, const Float_t nphotonsrelvar )
|
---|
924 | {
|
---|
925 |
|
---|
926 |
|
---|
927 | if (IsDebug())
|
---|
928 | {
|
---|
929 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
930 | << " Number photons: " << nphotons
|
---|
931 | << " Rel.Var.Number photons: " << nphotonsrelvar
|
---|
932 | << " Red.Sigma Square: " << fRSigmaSquare
|
---|
933 | << " Mean: " << GetMean()
|
---|
934 | << endl;
|
---|
935 | }
|
---|
936 |
|
---|
937 |
|
---|
938 | if (nphotons <= 0.)
|
---|
939 | {
|
---|
940 | *fLog << warn << GetDescriptor() << ": Assumed photon flux is smaller or equal 0." << endl;
|
---|
941 | return kFALSE;
|
---|
942 | }
|
---|
943 |
|
---|
944 | if (nphotonsrelvar < 0.)
|
---|
945 | {
|
---|
946 | *fLog << warn << GetDescriptor() << ": Assumed photon flux variance is smaller than 0." << endl;
|
---|
947 | return kFALSE;
|
---|
948 | }
|
---|
949 |
|
---|
950 | fMeanFFactorFADC2Phot = TMath::Sqrt(fRSigmaSquare * nphotons) / GetMean() ;
|
---|
951 |
|
---|
952 | if (IsDebug())
|
---|
953 | {
|
---|
954 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
955 | << " F-Factor FADC2Phot: " << fMeanFFactorFADC2Phot
|
---|
956 | << endl;
|
---|
957 | }
|
---|
958 |
|
---|
959 | if (fMeanFFactorFADC2Phot < 0.)
|
---|
960 | {
|
---|
961 | *fLog << warn << GetDescriptor() << ": F-Factor photons to FADC counts smaller than 0." << endl;
|
---|
962 | return kFALSE;
|
---|
963 | }
|
---|
964 |
|
---|
965 | const Float_t ffactorrelvar = 0.25 * fRSigmaSquareVar / ( fRSigmaSquare * fRSigmaSquare)
|
---|
966 | + GetMeanRelVar()
|
---|
967 | + 0.25 * nphotonsrelvar;
|
---|
968 |
|
---|
969 | fMeanFFactorFADC2PhotVar = ffactorrelvar * fMeanFFactorFADC2Phot * fMeanFFactorFADC2Phot;
|
---|
970 |
|
---|
971 | if (IsDebug())
|
---|
972 | {
|
---|
973 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
974 | << " Rel.Var.Red.Sigma: " << 0.25 * fRSigmaSquareVar / ( fRSigmaSquare * fRSigmaSquare)
|
---|
975 | << " Rel.Var.Mean: " << GetMeanRelVar()
|
---|
976 | << " Rel.Var.photons: " << 0.25 * nphotonsrelvar
|
---|
977 | << " Rel.Var.F-Factor FADC2Phot: " << ffactorrelvar
|
---|
978 | << endl;
|
---|
979 | }
|
---|
980 |
|
---|
981 | return kTRUE;
|
---|
982 | }
|
---|
983 |
|
---|
984 |
|
---|
985 | // ----------------------------------------------------------------------------
|
---|
986 | //
|
---|
987 | // - If fPed is smaller than 0 (i.e. has not yet been set), return.
|
---|
988 | // - If fPedVar is smaller than 0 (i.e. has not yet been set), return.
|
---|
989 | //
|
---|
990 | // Calculate the electronic pedestal RMS with the formula:
|
---|
991 | // - elec. pedestal = gkElectronicPedRms * sqrt(logainsamples)
|
---|
992 | //
|
---|
993 | // Calculate the night sky background ped. RMS contribution ("NSB") in the high-gain
|
---|
994 | // from the high gain Pedestal RMS with the formula:
|
---|
995 | // - HiGain NSB square = fPedRms * fPedRms - elec.ped.* elec.ped.
|
---|
996 | // - Var(HiGain NSB square) = fPedVar * fPedRms * fPedRms + 4.*elecPedRmsVar * elec.ped.* elec.ped.
|
---|
997 | //
|
---|
998 | // If HiGain NSB square is smaller than 0., set it to zero. (but not the error!)
|
---|
999 | //
|
---|
1000 | // Convert the NSB ped. RMS contribution to the low-gain with the formula:
|
---|
1001 | // - LoGain NSB square = HiGain NSB square / (fConversionHiLo*fConversionHiLo)
|
---|
1002 | // - Var(LoGain NSB square) = ( Var(HiGain NSB square) / (HiGain NSB square * HiGain NSB square)
|
---|
1003 | // + GetConversionHiLoRelVar()
|
---|
1004 | // ) * LoGain NSB square * LoGain NSB square
|
---|
1005 | //
|
---|
1006 | // - Low Gain Ped RMS Square = LoGain NSB square + elec.ped. square
|
---|
1007 | // Var (Low Gain Ped RMS Square) = Var(LoGain NSB square) + Var(elec.ped. square)
|
---|
1008 | //
|
---|
1009 | void MCalibrationChargePix::CalcLoGainPedestal(Float_t logainsamples)
|
---|
1010 | {
|
---|
1011 |
|
---|
1012 | if (fPedRms < 0.)
|
---|
1013 | return;
|
---|
1014 |
|
---|
1015 | if (fPedVar < 0.)
|
---|
1016 | return;
|
---|
1017 |
|
---|
1018 | const Float_t elecPedRms = gkElectronicPedRms * TMath::Sqrt(logainsamples);
|
---|
1019 | const Float_t elecPedRmsVar = GetElectronicPedRmsRelVar() * elecPedRms * elecPedRms;
|
---|
1020 |
|
---|
1021 | Float_t pedRmsSquare = fPedRms * fPedRms;
|
---|
1022 | Float_t pedRmsSquareVar = fPedVar * pedRmsSquare; // fPedRmsErr = fPedErr/2.
|
---|
1023 |
|
---|
1024 | //
|
---|
1025 | // We do not know the Low Gain Pedestal RMS, so we have to retrieve it
|
---|
1026 | // from the High Gain:
|
---|
1027 | //
|
---|
1028 | // We extract the pure NSB contribution:
|
---|
1029 | //
|
---|
1030 | const Float_t elecRmsSquare = elecPedRms * elecPedRms;
|
---|
1031 | const Float_t elecRmsSquareVar = 4.*elecPedRmsVar * elecRmsSquare;
|
---|
1032 |
|
---|
1033 | if (IsDebug())
|
---|
1034 | {
|
---|
1035 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
1036 | << " Ped.Rms Square: " << pedRmsSquare
|
---|
1037 | << " Elec.Rms Square: " << elecRmsSquare
|
---|
1038 | << " Ped.Rms.Square Var.: " << pedRmsSquareVar
|
---|
1039 | << " Elec.Rms Square Var.: " << elecRmsSquareVar
|
---|
1040 | << endl;
|
---|
1041 | }
|
---|
1042 |
|
---|
1043 |
|
---|
1044 | Float_t higainNsbSquare = pedRmsSquare - elecRmsSquare;
|
---|
1045 | Float_t higainNsbSquareVar = (pedRmsSquareVar + elecRmsSquareVar);
|
---|
1046 |
|
---|
1047 | if (higainNsbSquare < 0.001)
|
---|
1048 | higainNsbSquare = 0.;
|
---|
1049 |
|
---|
1050 | if (IsDebug())
|
---|
1051 | {
|
---|
1052 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
1053 | << " HiGain NSB Square: " << higainNsbSquare
|
---|
1054 | << " Var.HiGain NSB Square: " << higainNsbSquareVar
|
---|
1055 | << endl;
|
---|
1056 | }
|
---|
1057 |
|
---|
1058 | //
|
---|
1059 | // Now, we divide the NSB by the conversion factor and
|
---|
1060 | // add it quadratically to the electronic noise
|
---|
1061 | //
|
---|
1062 | const Float_t conversionSquare = fConversionHiLo * fConversionHiLo;
|
---|
1063 | const Float_t conversionSquareRelVar = 4.* GetConversionHiLoRelVar();
|
---|
1064 |
|
---|
1065 | const Float_t logainNsbSquare = higainNsbSquare / conversionSquare;
|
---|
1066 | //
|
---|
1067 | // Calculation of variance of: c = a/b
|
---|
1068 | // Delta(c)^2 = ( Delta(a)^2 + a^2/b^2*(Delta(b)^2 ) / b^2
|
---|
1069 | //
|
---|
1070 | const Float_t logainNsbSquareVar = ( higainNsbSquareVar
|
---|
1071 | + conversionSquareRelVar * higainNsbSquare * higainNsbSquare )
|
---|
1072 | / conversionSquare / conversionSquare;
|
---|
1073 |
|
---|
1074 | fLoGainPedRmsSquare = logainNsbSquare + elecRmsSquare;
|
---|
1075 | fLoGainPedRmsSquareVar = logainNsbSquareVar + elecRmsSquareVar;
|
---|
1076 |
|
---|
1077 | if (IsDebug())
|
---|
1078 | {
|
---|
1079 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
1080 | << " LoGain Ped Rms Square: " << fLoGainPedRmsSquare
|
---|
1081 | << " Var.Ped Rms Square: " << fLoGainPedRmsSquareVar
|
---|
1082 | << endl;
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 |
|
---|
1086 | }
|
---|
1087 |
|
---|