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()
|
---|
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 |
|
---|
690 | if (IsDebug())
|
---|
691 | {
|
---|
692 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
693 | << " HiGainSaturation: " << IsHiGainSaturation()
|
---|
694 | << " Sigma: " << sigma
|
---|
695 | << " Var.Sigma: " << sigmavar
|
---|
696 | << " PedRmsSquare: " << pedRmsSquare
|
---|
697 | << " pedRmsSquareVar: " << pedRmsSquareVar
|
---|
698 | << endl;
|
---|
699 | }
|
---|
700 |
|
---|
701 | const Float_t sigmaSquare = sigma * sigma;
|
---|
702 | const Float_t sigmaSquareVar = 4. * sigmavar * sigmaSquare;
|
---|
703 |
|
---|
704 | //
|
---|
705 | // Calculate the reduced sigmas
|
---|
706 | //
|
---|
707 | fRSigmaSquare = sigmaSquare - pedRmsSquare;
|
---|
708 |
|
---|
709 | if (IsDebug())
|
---|
710 | {
|
---|
711 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
712 | << " Red.Sigma Square: " << fRSigmaSquare
|
---|
713 | << endl;
|
---|
714 | }
|
---|
715 |
|
---|
716 | if (fRSigmaSquare <= 0.)
|
---|
717 | {
|
---|
718 | if (IsDebug())
|
---|
719 | *fLog << warn
|
---|
720 | << "WARNING: Cannot calculate the reduced sigma: smaller than 0 in pixel "
|
---|
721 | << fPixId << endl;
|
---|
722 | return kFALSE;
|
---|
723 | }
|
---|
724 |
|
---|
725 |
|
---|
726 | fRSigmaSquareVar = 4. * (sigmaSquareVar + pedRmsSquareVar);
|
---|
727 |
|
---|
728 | if (IsDebug())
|
---|
729 | {
|
---|
730 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
731 | << " Var.Red.Sigma Square: " << fRSigmaSquareVar
|
---|
732 | << endl;
|
---|
733 | }
|
---|
734 |
|
---|
735 | return kTRUE;
|
---|
736 | }
|
---|
737 |
|
---|
738 | // ------------------------------------------------------------------
|
---|
739 | //
|
---|
740 | // If fRSigmaSquare is smaller than 0 (i.e. has not yet been set),
|
---|
741 | // return kFALSE
|
---|
742 | //
|
---|
743 | // Calculate the number of photo-electrons with the F-Factor method:
|
---|
744 | // - Test bit IsHiGainSaturation() for the Mean Sum of FADC slices:
|
---|
745 | // If yes, take fLoGainMean and fLoGainMeanVar
|
---|
746 | // If no , take fHiGainMean and fHiGainMeanVar
|
---|
747 | //
|
---|
748 | // - Test bit IsHiGainSaturation() for the pedRMS:
|
---|
749 | // If yes, take fLoGainPedRmsSquare and fLoGainPedRmsSquareVar
|
---|
750 | // If no , take fPedRms and fPedVar
|
---|
751 | //
|
---|
752 | // - Calculate the number of photo-electrons with the formula:
|
---|
753 | // fPheFFactorMethod = gkFFactor*gkFFactor * Mean * Mean / fRSigmaSquare
|
---|
754 | //
|
---|
755 | // - Calculate the Variance on the photo-electrons with the formula:
|
---|
756 | // fPheFFactorMethodVar = ( 4. * gkFFactorErr * gkFFactorErr / ( gkFFactor * gkFFactor )
|
---|
757 | // + 4. * Mean Var. / ( Mean * Mean )
|
---|
758 | // + fRSigmaSquareVar / fRSigmaSquare
|
---|
759 | // ) * fPheFFactorMethod * fPheFFactorMethod
|
---|
760 | //
|
---|
761 | // - If fPheFFactorMethod is less than fPheFFactorMethodLimit,
|
---|
762 | // set kFFactorMethodValid to kFALSE and return kFALSE
|
---|
763 | //
|
---|
764 | Bool_t MCalibrationChargePix::CalcFFactor()
|
---|
765 | {
|
---|
766 |
|
---|
767 | if (fRSigmaSquare < 0.)
|
---|
768 | return kFALSE;
|
---|
769 |
|
---|
770 | //
|
---|
771 | // Square all variables in order to avoid applications of square root
|
---|
772 | //
|
---|
773 | const Float_t meanSquare = GetMean() * GetMean();
|
---|
774 | const Float_t meanSquareRelVar = 4.* GetMeanRelVar();
|
---|
775 |
|
---|
776 | const Float_t ffactorsquare = gkFFactor * gkFFactor;
|
---|
777 | const Float_t ffactorsquareRelVar = 4.* GetFFactorRelVar();
|
---|
778 |
|
---|
779 | const Float_t rsigmaSquareRelVar = fRSigmaSquareVar / fRSigmaSquare / fRSigmaSquare;
|
---|
780 | //
|
---|
781 | // Calculate the number of phe's from the F-Factor method
|
---|
782 | // (independent on Hi Gain or Lo Gain)
|
---|
783 | //
|
---|
784 | fPheFFactorMethod = ffactorsquare * meanSquare / fRSigmaSquare;
|
---|
785 |
|
---|
786 | if (IsDebug())
|
---|
787 | {
|
---|
788 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
789 | << " F-Factor Square: " << ffactorsquare
|
---|
790 | << " Mean Square: " << meanSquare
|
---|
791 | << " Red.Sigma Square: " << fRSigmaSquare
|
---|
792 | << " Photo-electrons: " << fPheFFactorMethod
|
---|
793 | << endl;
|
---|
794 | }
|
---|
795 |
|
---|
796 | if (fPheFFactorMethod < fPheFFactorMethodLimit)
|
---|
797 | return kFALSE;
|
---|
798 |
|
---|
799 | //
|
---|
800 | // Calculate the Error of Nphe
|
---|
801 | //
|
---|
802 | const Float_t pheRelVar = ffactorsquareRelVar + meanSquareRelVar + rsigmaSquareRelVar;
|
---|
803 | fPheFFactorMethodVar = pheRelVar * fPheFFactorMethod * fPheFFactorMethod;
|
---|
804 |
|
---|
805 | if (IsDebug())
|
---|
806 | {
|
---|
807 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
808 | << " Rel.Var.F-Factor Square: " << ffactorsquareRelVar
|
---|
809 | << " Rel.Var. Mean Square: " << meanSquareRelVar
|
---|
810 | << " Rel.Var. Red.Sigma Square: " << rsigmaSquareRelVar
|
---|
811 | << " Rel.Var. Photo-electrons: " << pheRelVar
|
---|
812 | << endl;
|
---|
813 | }
|
---|
814 |
|
---|
815 | if (fPheFFactorMethodVar < 0. )
|
---|
816 | return kFALSE;
|
---|
817 |
|
---|
818 | return kTRUE;
|
---|
819 | }
|
---|
820 |
|
---|
821 | // ------------------------------------------------------------------
|
---|
822 | //
|
---|
823 | // If fPheFFactorMethod is smaller than 0 (i.e. has not yet been set),
|
---|
824 | // return kFALSE
|
---|
825 | //
|
---|
826 | // If GetCovertedMean() is smaller than 0 (i.e. has not yet been set),
|
---|
827 | // return kFALSE
|
---|
828 | //
|
---|
829 | // Calculate fMeanConvFADC2Phe with the following formula:
|
---|
830 | //
|
---|
831 | // fMeanConvFADC2Phe = fPheFFactorMethod / GetConvMean();
|
---|
832 | //
|
---|
833 | // Calculate the rel. variance of fMeanConvFADC2Phe, taking into account that
|
---|
834 | // in the calculation of the number of phe's one mean square has already been used.
|
---|
835 | // Now, dividing by another mean, one mean calcels out, one cannot directly propagate
|
---|
836 | // the errors, but instead havs to take into account this cancellation:
|
---|
837 | //
|
---|
838 | // convrelvar = ffactorsquareRelVar + GetMeanRelVar() + rsigmaSquareRelVar;
|
---|
839 | //
|
---|
840 | // If confrelvar is smaller than 0. or greater than fConvFFactorRelVarLimit,
|
---|
841 | // return kFALSE
|
---|
842 | //
|
---|
843 | // Calculate the variance of fMeanConvFADC2Phe with the formula:
|
---|
844 | //
|
---|
845 | // fMeanConvFADC2PheVar = convrelvar * fMeanConvFADC2Phe * fMeanConvFADC2Phe;
|
---|
846 | //
|
---|
847 | // Set kFFactorMethodValid to kTRUE and
|
---|
848 | // return kTRUE
|
---|
849 | //
|
---|
850 | Bool_t MCalibrationChargePix::CalcConvFFactor()
|
---|
851 | {
|
---|
852 |
|
---|
853 | if (fPheFFactorMethod <= 0.)
|
---|
854 | return kFALSE;
|
---|
855 |
|
---|
856 | const Float_t convmean = GetConvertedMean();
|
---|
857 |
|
---|
858 | if (convmean <= 0.)
|
---|
859 | return kFALSE;
|
---|
860 |
|
---|
861 | fMeanConvFADC2Phe = fPheFFactorMethod / convmean;
|
---|
862 |
|
---|
863 | if (IsDebug())
|
---|
864 | {
|
---|
865 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
866 | << " Converted Mean: " << convmean
|
---|
867 | << " Conversion FADC2Phe: " << fMeanConvFADC2Phe
|
---|
868 | << endl;
|
---|
869 | }
|
---|
870 |
|
---|
871 | const Float_t ffactorsquareRelVar = 4.* GetFFactorRelVar();
|
---|
872 | const Float_t rsigmaSquareRelVar = fRSigmaSquareVar / fRSigmaSquare / fRSigmaSquare;
|
---|
873 | //
|
---|
874 | // In the calculation of the number of phe's one mean square has already been used.
|
---|
875 | // Now, we divide by another mean, so one mean calcels out, we cannot directly propagate
|
---|
876 | // the errors, but have to take account of this cancellation:
|
---|
877 | //
|
---|
878 | Float_t convrelvar = ffactorsquareRelVar + GetMeanRelVar() + rsigmaSquareRelVar;
|
---|
879 | const Float_t limit = IsHiGainSaturation() ? fConvFFactorRelVarLimit * 4. : fConvFFactorRelVarLimit;
|
---|
880 |
|
---|
881 | //
|
---|
882 | // Also have to take into account the pixels labelled MBadPixelsPix::kChargeSigmaNotValid which do not
|
---|
883 | // have a fRSigmaSquareVar, calculate their error directly!
|
---|
884 | //
|
---|
885 | if (fRSigmaSquareVar < 0.)
|
---|
886 | convrelvar = GetMeanRelVar() + GetPheFFactorMethodRelVar();
|
---|
887 |
|
---|
888 | if (IsDebug())
|
---|
889 | {
|
---|
890 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
891 | << " Rel.Var.Red.Sigma: " << rsigmaSquareRelVar
|
---|
892 | << " Rel.Var.Mean: " << GetMeanRelVar()
|
---|
893 | << " Rel.Var.F-Factor: " << ffactorsquareRelVar
|
---|
894 | << " Rel.Var.Conversion FADC2Phe: " << convrelvar
|
---|
895 | << endl;
|
---|
896 | }
|
---|
897 |
|
---|
898 | if (convrelvar > limit || convrelvar < 0.)
|
---|
899 | {
|
---|
900 | *fLog << warn << GetDescriptor() << ": Conv. F-Factor Method Rel. Var.: "
|
---|
901 | << Form("%4.3f out of limits: [0,%3.2f] in pixel:%4i",convrelvar,limit,fPixId) << endl;
|
---|
902 | return kFALSE;
|
---|
903 | }
|
---|
904 |
|
---|
905 | fMeanConvFADC2PheVar = convrelvar * fMeanConvFADC2Phe * fMeanConvFADC2Phe;
|
---|
906 |
|
---|
907 | SetFFactorMethodValid(kTRUE);
|
---|
908 | return kTRUE;
|
---|
909 | }
|
---|
910 |
|
---|
911 | // ----------------------------------------------------------------------------------
|
---|
912 | //
|
---|
913 | // If photflux is smaller or equal 0, return kFALSE
|
---|
914 | //
|
---|
915 | // Calculate the total F-Factor with the formula:
|
---|
916 | // fMeanFFactorFADC2Phot = Sqrt ( fRSigmaSquare ) / GetMean() * sqrt(nphotons)
|
---|
917 | //
|
---|
918 | // Calculate the error of the total F-Factor
|
---|
919 | //
|
---|
920 | Bool_t MCalibrationChargePix::CalcMeanFFactor( const Float_t nphotons, const Float_t nphotonsrelvar )
|
---|
921 | {
|
---|
922 |
|
---|
923 |
|
---|
924 | if (IsDebug())
|
---|
925 | {
|
---|
926 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
927 | << " Number photons: " << nphotons
|
---|
928 | << " Rel.Var.Number photons: " << nphotonsrelvar
|
---|
929 | << " Red.Sigma Square: " << fRSigmaSquare
|
---|
930 | << " Mean: " << GetMean()
|
---|
931 | << endl;
|
---|
932 | }
|
---|
933 |
|
---|
934 |
|
---|
935 | if (nphotons <= 0.)
|
---|
936 | {
|
---|
937 | *fLog << warn << GetDescriptor() << ": Assumed photon flux is smaller or equal 0." << endl;
|
---|
938 | return kFALSE;
|
---|
939 | }
|
---|
940 |
|
---|
941 | if (nphotonsrelvar < 0.)
|
---|
942 | {
|
---|
943 | *fLog << warn << GetDescriptor() << ": Assumed photon flux variance is smaller than 0." << endl;
|
---|
944 | return kFALSE;
|
---|
945 | }
|
---|
946 |
|
---|
947 | fMeanFFactorFADC2Phot = TMath::Sqrt(fRSigmaSquare * nphotons) / GetMean() ;
|
---|
948 |
|
---|
949 | if (IsDebug())
|
---|
950 | {
|
---|
951 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
952 | << " F-Factor FADC2Phot: " << fMeanFFactorFADC2Phot
|
---|
953 | << endl;
|
---|
954 | }
|
---|
955 |
|
---|
956 | if (fMeanFFactorFADC2Phot < 0.)
|
---|
957 | {
|
---|
958 | *fLog << warn << GetDescriptor() << ": F-Factor photons to FADC counts smaller than 0." << endl;
|
---|
959 | return kFALSE;
|
---|
960 | }
|
---|
961 |
|
---|
962 | const Float_t ffactorrelvar = 0.25 * fRSigmaSquareVar / ( fRSigmaSquare * fRSigmaSquare)
|
---|
963 | + GetMeanRelVar()
|
---|
964 | + 0.25 * nphotonsrelvar;
|
---|
965 |
|
---|
966 | fMeanFFactorFADC2PhotVar = ffactorrelvar * fMeanFFactorFADC2Phot * fMeanFFactorFADC2Phot;
|
---|
967 |
|
---|
968 | if (IsDebug())
|
---|
969 | {
|
---|
970 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
971 | << " Rel.Var.Red.Sigma: " << 0.25 * fRSigmaSquareVar / ( fRSigmaSquare * fRSigmaSquare)
|
---|
972 | << " Rel.Var.Mean: " << GetMeanRelVar()
|
---|
973 | << " Rel.Var.photons: " << 0.25 * nphotonsrelvar
|
---|
974 | << " Rel.Var.F-Factor FADC2Phot: " << ffactorrelvar
|
---|
975 | << endl;
|
---|
976 | }
|
---|
977 |
|
---|
978 | return kTRUE;
|
---|
979 | }
|
---|
980 |
|
---|
981 |
|
---|
982 | // ----------------------------------------------------------------------------
|
---|
983 | //
|
---|
984 | // - If fPed is smaller than 0 (i.e. has not yet been set), return.
|
---|
985 | // - If fPedVar is smaller than 0 (i.e. has not yet been set), return.
|
---|
986 | //
|
---|
987 | // Calculate the electronic pedestal RMS with the formula:
|
---|
988 | // - elec. pedestal = gkElectronicPedRms * sqrt(logainsamples)
|
---|
989 | //
|
---|
990 | // Calculate the night sky background ped. RMS contribution ("NSB") in the high-gain
|
---|
991 | // from the high gain Pedestal RMS with the formula:
|
---|
992 | // - HiGain NSB square = fPedRms * fPedRms - elec.ped.* elec.ped.
|
---|
993 | // - Var(HiGain NSB square) = fPedVar * fPedRms * fPedRms + 4.*elecPedRmsVar * elec.ped.* elec.ped.
|
---|
994 | //
|
---|
995 | // If HiGain NSB square is smaller than 0., set it to zero. (but not the error!)
|
---|
996 | //
|
---|
997 | // Convert the NSB ped. RMS contribution to the low-gain with the formula:
|
---|
998 | // - LoGain NSB square = HiGain NSB square / (fConversionHiLo*fConversionHiLo)
|
---|
999 | // - Var(LoGain NSB square) = ( Var(HiGain NSB square) / (HiGain NSB square * HiGain NSB square)
|
---|
1000 | // + GetConversionHiLoRelVar()
|
---|
1001 | // ) * LoGain NSB square * LoGain NSB square
|
---|
1002 | //
|
---|
1003 | // - Low Gain Ped RMS Square = LoGain NSB square + elec.ped. square
|
---|
1004 | // Var (Low Gain Ped RMS Square) = Var(LoGain NSB square) + Var(elec.ped. square)
|
---|
1005 | //
|
---|
1006 | void MCalibrationChargePix::CalcLoGainPedestal(Float_t logainsamples)
|
---|
1007 | {
|
---|
1008 |
|
---|
1009 | if (fPedRms < 0.)
|
---|
1010 | return;
|
---|
1011 |
|
---|
1012 | if (fPedVar < 0.)
|
---|
1013 | return;
|
---|
1014 |
|
---|
1015 | const Float_t elecPedRms = gkElectronicPedRms * TMath::Sqrt(logainsamples);
|
---|
1016 | const Float_t elecPedRmsVar = GetElectronicPedRmsRelVar() * elecPedRms * elecPedRms;
|
---|
1017 |
|
---|
1018 | Float_t pedRmsSquare = fPedRms * fPedRms;
|
---|
1019 | Float_t pedRmsSquareVar = fPedVar * pedRmsSquare; // fPedRmsErr = fPedErr/2.
|
---|
1020 |
|
---|
1021 | //
|
---|
1022 | // We do not know the Low Gain Pedestal RMS, so we have to retrieve it
|
---|
1023 | // from the High Gain:
|
---|
1024 | //
|
---|
1025 | // We extract the pure NSB contribution:
|
---|
1026 | //
|
---|
1027 | const Float_t elecRmsSquare = elecPedRms * elecPedRms;
|
---|
1028 | const Float_t elecRmsSquareVar = 4.*elecPedRmsVar * elecRmsSquare;
|
---|
1029 |
|
---|
1030 | if (IsDebug())
|
---|
1031 | {
|
---|
1032 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
1033 | << " Ped.Rms Square: " << pedRmsSquare
|
---|
1034 | << " Elec.Rms Square: " << elecRmsSquare
|
---|
1035 | << " Ped.Rms.Square Var.: " << pedRmsSquareVar
|
---|
1036 | << " Elec.Rms Square Var.: " << elecRmsSquareVar
|
---|
1037 | << endl;
|
---|
1038 | }
|
---|
1039 |
|
---|
1040 |
|
---|
1041 | Float_t higainNsbSquare = pedRmsSquare - elecRmsSquare;
|
---|
1042 | Float_t higainNsbSquareVar = (pedRmsSquareVar + elecRmsSquareVar);
|
---|
1043 |
|
---|
1044 | if (higainNsbSquare < 0.001)
|
---|
1045 | higainNsbSquare = 0.;
|
---|
1046 |
|
---|
1047 | if (IsDebug())
|
---|
1048 | {
|
---|
1049 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
1050 | << " HiGain NSB Square: " << higainNsbSquare
|
---|
1051 | << " Var.HiGain NSB Square: " << higainNsbSquareVar
|
---|
1052 | << endl;
|
---|
1053 | }
|
---|
1054 |
|
---|
1055 | //
|
---|
1056 | // Now, we divide the NSB by the conversion factor and
|
---|
1057 | // add it quadratically to the electronic noise
|
---|
1058 | //
|
---|
1059 | const Float_t conversionSquare = fConversionHiLo * fConversionHiLo;
|
---|
1060 | const Float_t conversionSquareRelVar = 4.* GetConversionHiLoRelVar();
|
---|
1061 |
|
---|
1062 | const Float_t logainNsbSquare = higainNsbSquare / conversionSquare;
|
---|
1063 | //
|
---|
1064 | // Calculation of variance of: c = a/b
|
---|
1065 | // Delta(c)^2 = ( Delta(a)^2 + a^2/b^2*(Delta(b)^2 ) / b^2
|
---|
1066 | //
|
---|
1067 | const Float_t logainNsbSquareVar = ( higainNsbSquareVar
|
---|
1068 | + conversionSquareRelVar * higainNsbSquare * higainNsbSquare )
|
---|
1069 | / conversionSquare / conversionSquare;
|
---|
1070 |
|
---|
1071 | fLoGainPedRmsSquare = logainNsbSquare + elecRmsSquare;
|
---|
1072 | fLoGainPedRmsSquareVar = logainNsbSquareVar + elecRmsSquareVar;
|
---|
1073 |
|
---|
1074 | if (IsDebug())
|
---|
1075 | {
|
---|
1076 | *fLog << dbginf << "ID: " << GetPixId()
|
---|
1077 | << " LoGain Ped Rms Square: " << fLoGainPedRmsSquare
|
---|
1078 | << " Var.Ped Rms Square: " << fLoGainPedRmsSquareVar
|
---|
1079 | << endl;
|
---|
1080 | }
|
---|
1081 |
|
---|
1082 |
|
---|
1083 | }
|
---|
1084 |
|
---|