source: trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc@ 3444

Last change on this file since 3444 was 3435, checked in by gaug, 21 years ago
*** empty log message ***
File size: 25.0 KB
Line 
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
94ClassImp(MCalibrationChargePix);
95
96using namespace std;
97
98const Float_t MCalibrationChargePix::gkElectronicPedRms = 1.5;
99const Float_t MCalibrationChargePix::gkElectronicPedRmsErr = 0.3;
100const Float_t MCalibrationChargePix::gkFFactor = 1.15;
101const Float_t MCalibrationChargePix::gkFFactorErr = 0.02;
102
103const Float_t MCalibrationChargePix::gkAverageQE = 0.18;
104const Float_t MCalibrationChargePix::gkAverageQEErr = 0.02;
105const Float_t MCalibrationChargePix::gkConversionHiLo = 10.;
106const Float_t MCalibrationChargePix::gkConversionHiLoErr = 2.5;
107
108const Float_t MCalibrationChargePix::fgChargeLimit = 3.;
109const Float_t MCalibrationChargePix::fgChargeErrLimit = 0.;
110const Float_t MCalibrationChargePix::fgChargeRelErrLimit = 1.;
111const Float_t MCalibrationChargePix::fgTimeLimit = 1.5;
112const Float_t MCalibrationChargePix::fgTimeErrLimit = 3.;
113const Float_t MCalibrationChargePix::fgConvFFactorRelErrLimit = 0.25;
114// --------------------------------------------------------------------------
115//
116// Default Constructor:
117//
118MCalibrationChargePix::MCalibrationChargePix(const char *name, const char *title)
119 : fPixId(-1),
120 fFlags(0)
121{
122
123 fName = name ? name : "MCalibrationChargePix";
124 fTitle = title ? title : "Container of the fit results of MHCalibrationChargePixs ";
125
126 Clear();
127
128 //
129 // At the moment, we don't have a database, yet,
130 // so we get it from the configuration file
131 //
132 SetConversionHiLo();
133 SetConversionHiLoErr();
134
135 SetAverageQE();
136 SetChargeLimit();
137 SetChargeErrLimit();
138
139 SetChargeRelErrLimit();
140 SetTimeLimit();
141 SetTimeErrLimit();
142 SetConvFFactorRelErrLimit();
143}
144
145// ------------------------------------------------------------------------
146//
147// Invalidate values
148//
149void MCalibrationChargePix::Clear(Option_t *o)
150{
151
152 SetHiGainSaturation ( kFALSE );
153 SetLoGainSaturation ( kFALSE );
154 SetHiGainFitted ( kFALSE );
155 SetLoGainFitted ( kFALSE );
156 SetExcluded ( kFALSE );
157 SetBlindPixelMethodValid ( kFALSE );
158 SetFFactorMethodValid ( kFALSE );
159 SetPINDiodeMethodValid ( kFALSE );
160 SetCombinedMethodValid ( kFALSE );
161
162 fHiGainMeanCharge = -1.;
163 fHiGainMeanChargeErr = -1.;
164 fHiGainSigmaCharge = -1.;
165 fHiGainSigmaChargeErr = -1.;
166 fHiGainChargeProb = -1.;
167
168 fLoGainMeanCharge = -1.;
169 fLoGainMeanChargeErr = -1.;
170 fLoGainSigmaCharge = -1.;
171 fLoGainSigmaChargeErr = -1.;
172 fLoGainChargeProb = -1.;
173
174 fRSigmaCharge = -1.;
175 fRSigmaChargeErr = -1.;
176
177 fHiGainNumPickup = -1;
178 fLoGainNumPickup = -1;
179
180 fNumLoGainSamples = -1.;
181
182 fPed = -1.;
183 fPedRms = -1.;
184 fPedErr = -1.;
185
186 fLoGainPedRms = -1.;
187 fLoGainPedRmsErr = -1.;
188
189 fTimeFirstHiGain = 0 ;
190 fTimeLastHiGain = 0 ;
191 fTimeFirstLoGain = 0 ;
192 fTimeLastLoGain = 0 ;
193
194 fAbsTimeMean = -1.;
195 fAbsTimeRms = -1.;
196
197 fPheFFactorMethod = -1.;
198 fPheFFactorMethodErr = -1.;
199
200 fMeanConversionFFactorMethod = -1.;
201 fMeanConversionBlindPixelMethod = -1.;
202 fMeanConversionPINDiodeMethod = -1.;
203 fMeanConversionCombinedMethod = -1.;
204
205 fConversionFFactorMethodErr = -1.;
206 fConversionBlindPixelMethodErr = -1.;
207 fConversionPINDiodeMethodErr = -1.;
208 fConversionCombinedMethodErr = -1.;
209
210 fSigmaConversionFFactorMethod = -1.;
211 fSigmaConversionBlindPixelMethod = -1.;
212 fSigmaConversionPINDiodeMethod = -1.;
213 fSigmaConversionCombinedMethod = -1.;
214
215 fTotalFFactorFFactorMethod = -1.;
216 fTotalFFactorBlindPixelMethod = -1.;
217 fTotalFFactorPINDiodeMethod = -1.;
218 fTotalFFactorCombinedMethod = -1.;
219
220}
221
222
223void MCalibrationChargePix::DefinePixId(Int_t i)
224{
225 fPixId = i;
226}
227
228
229// --------------------------------------------------------------------------
230//
231// Set the pedestals from outside
232//
233void MCalibrationChargePix::SetPedestal(const Float_t ped, const Float_t pedrms, const Float_t pederr)
234{
235
236 fPed = ped;
237 fPedRms = pedrms;
238 fPedErr = pederr;
239}
240
241
242void MCalibrationChargePix::SetMeanCharge( const Float_t f )
243{
244 if (IsHiGainSaturation())
245 fLoGainMeanCharge = f;
246 else
247 fHiGainMeanCharge = f;
248}
249
250void MCalibrationChargePix::SetMeanChargeErr( const Float_t f )
251{
252 if (IsHiGainSaturation())
253 fLoGainMeanChargeErr = f;
254 else
255 fHiGainMeanChargeErr = f;
256
257}
258
259void MCalibrationChargePix::SetSigmaCharge( const Float_t f )
260{
261 if (IsHiGainSaturation())
262 fLoGainSigmaCharge = f;
263 else
264 fHiGainSigmaCharge = f;
265}
266
267
268void MCalibrationChargePix::SetSigmaChargeErr( const Float_t f )
269{
270 if (IsHiGainSaturation())
271 fLoGainSigmaChargeErr = f;
272 else
273 fHiGainSigmaChargeErr = f;
274
275}
276
277
278
279// --------------------------------------------------------------------------
280//
281// Set the conversion factors from outside (only for MC)
282//
283void MCalibrationChargePix::SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig)
284{
285 fMeanConversionFFactorMethod = c;
286 fConversionFFactorMethodErr = err;
287 fSigmaConversionFFactorMethod = sig;
288}
289
290// --------------------------------------------------------------------------
291//
292// Set the conversion factors from outside (only for MC)
293//
294void MCalibrationChargePix::SetConversionCombinedMethod(Float_t c, Float_t err, Float_t sig)
295{
296 fMeanConversionCombinedMethod = c;
297 fConversionCombinedMethodErr = err;
298 fSigmaConversionCombinedMethod = sig;
299}
300
301
302// --------------------------------------------------------------------------
303//
304// Set the conversion factors from outside (only for MC)
305//
306void MCalibrationChargePix::SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig)
307{
308 fMeanConversionBlindPixelMethod = c;
309 fConversionBlindPixelMethodErr = err;
310 fSigmaConversionBlindPixelMethod = sig;
311}
312
313// --------------------------------------------------------------------------
314//
315// Set the conversion factors from outside (only for MC)
316//
317void MCalibrationChargePix::SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig)
318{
319 fMeanConversionPINDiodeMethod = c ;
320 fConversionPINDiodeMethodErr = err;
321 fSigmaConversionPINDiodeMethod = sig;
322}
323
324// --------------------------------------------------------------------------
325//
326// Set the Hi Gain Saturation Bit from outside
327//
328void MCalibrationChargePix::SetHiGainSaturation(Bool_t b)
329{
330 b ? SETBIT(fFlags, kHiGainSaturation) : CLRBIT(fFlags, kHiGainSaturation);
331}
332
333// --------------------------------------------------------------------------
334//
335// Set the Lo Gain Saturation Bit from outside
336//
337void MCalibrationChargePix::SetLoGainSaturation(Bool_t b)
338{
339 b ? SETBIT(fFlags, kLoGainSaturation) : CLRBIT(fFlags, kLoGainSaturation);
340}
341
342// --------------------------------------------------------------------------
343//
344// Set the Excluded Bit from outside
345//
346void MCalibrationChargePix::SetExcluded(Bool_t b )
347{
348 b ? SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded);
349}
350
351// --------------------------------------------------------------------------
352//
353// Set the Fitted Bit from outside
354//
355void MCalibrationChargePix::SetHiGainFitted(Bool_t b )
356{
357 b ? SETBIT(fFlags, kHiGainFitted) : CLRBIT(fFlags, kHiGainFitted);
358}
359
360// --------------------------------------------------------------------------
361//
362// Set the Fitted Bit from outside
363//
364void MCalibrationChargePix::SetLoGainFitted(const Bool_t b )
365{
366 b ? SETBIT(fFlags, kLoGainFitted) : CLRBIT(fFlags, kLoGainFitted);
367}
368
369// --------------------------------------------------------------------------
370//
371// Set the Excluded Bit from outside
372//
373void MCalibrationChargePix::SetBlindPixelMethodValid(const Bool_t b )
374{
375 b ? SETBIT(fFlags, kBlindPixelMethodValid) : CLRBIT(fFlags, kBlindPixelMethodValid);
376}
377
378// --------------------------------------------------------------------------
379//
380// Set the Excluded Bit from outside
381//
382void MCalibrationChargePix::SetFFactorMethodValid(const Bool_t b )
383{
384 b ? SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid);
385}
386
387// --------------------------------------------------------------------------
388//
389// Set the Excluded Bit from outside
390//
391void MCalibrationChargePix::SetPINDiodeMethodValid(const Bool_t b )
392{
393 b ? SETBIT(fFlags, kPINDiodeMethodValid) : CLRBIT(fFlags, kPINDiodeMethodValid);
394}
395
396// --------------------------------------------------------------------------
397//
398// Set the Excluded Bit from outside
399//
400void MCalibrationChargePix::SetCombinedMethodValid(const Bool_t b )
401{
402 b ? SETBIT(fFlags, kCombinedMethodValid) : CLRBIT(fFlags, kCombinedMethodValid);
403}
404
405void MCalibrationChargePix::SetAbsTimeBordersHiGain(const Byte_t f, const Byte_t l)
406{
407
408 fTimeFirstHiGain = f;
409 fTimeLastHiGain = l;
410
411}
412
413void MCalibrationChargePix::SetAbsTimeBordersLoGain(const Byte_t f, const Byte_t l)
414{
415
416 fTimeFirstLoGain = f;
417 fTimeLastLoGain = l;
418
419}
420
421Float_t MCalibrationChargePix::GetMeanCharge() const
422{
423 return IsHiGainSaturation() ? fLoGainMeanCharge : fHiGainMeanCharge ;
424}
425
426Float_t MCalibrationChargePix::GetMeanChargeErr() const
427{
428 return IsHiGainSaturation() ? fLoGainMeanChargeErr : fHiGainMeanChargeErr ;
429}
430
431Float_t MCalibrationChargePix::GetChargeProb() const
432{
433 return IsHiGainSaturation() ? fLoGainChargeProb : fHiGainChargeProb ;
434}
435
436Float_t MCalibrationChargePix::GetSigmaCharge() const
437{
438 return IsHiGainSaturation() ? fLoGainSigmaCharge : fHiGainSigmaCharge ;
439}
440
441Float_t MCalibrationChargePix::GetSigmaChargeErr() const
442{
443 return IsHiGainSaturation() ? fLoGainSigmaChargeErr : fHiGainSigmaChargeErr ;
444}
445
446Bool_t MCalibrationChargePix::IsFitted() const
447{
448 return IsHiGainSaturation() ? IsLoGainFitted() : IsHiGainFitted();
449}
450
451
452Bool_t MCalibrationChargePix::IsExcluded() const
453{
454 return TESTBIT(fFlags,kExcluded);
455}
456
457Bool_t MCalibrationChargePix::IsHiGainSaturation() const
458{
459 return TESTBIT(fFlags,kHiGainSaturation);
460}
461
462Bool_t MCalibrationChargePix::IsLoGainSaturation() const
463{
464 return TESTBIT(fFlags,kLoGainSaturation);
465}
466
467Bool_t MCalibrationChargePix::IsHiGainFitted() const
468{
469 return TESTBIT(fFlags, kHiGainFitted);
470}
471
472Bool_t MCalibrationChargePix::IsLoGainFitted() const
473{
474 return TESTBIT(fFlags, kLoGainFitted);
475}
476
477Bool_t MCalibrationChargePix::IsBlindPixelMethodValid() const
478{
479 return TESTBIT(fFlags, kBlindPixelMethodValid);
480}
481
482Bool_t MCalibrationChargePix::IsFFactorMethodValid() const
483{
484 return TESTBIT(fFlags, kFFactorMethodValid);
485}
486
487Bool_t MCalibrationChargePix::IsPINDiodeMethodValid() const
488{
489 return TESTBIT(fFlags, kPINDiodeMethodValid);
490}
491
492Bool_t MCalibrationChargePix::IsCombinedMethodValid() const
493{
494 return TESTBIT(fFlags, kCombinedMethodValid);
495}
496
497
498//
499// The check return kTRUE if:
500//
501// 1) Pixel has a fitted charge greater than fChargeLimit*PedRMS
502// 2) Pixel has a fit error greater than fChargeErrLimit
503// 3) Pixel has a fitted charge greater its fChargeRelErrLimit times its charge error
504// 4) Pixel has a charge sigma bigger than its Pedestal RMS
505//
506void MCalibrationChargePix::CheckChargeValidity(MBadPixelsPix *bad)
507{
508
509 if (GetMeanCharge() < fChargeLimit*GetPedRms())
510 {
511 *fLog << warn << "WARNING: Fitted Charge is smaller than "
512 << fChargeLimit << " Pedestal RMS in Pixel " << fPixId << endl;
513 bad->SetChargeIsPedestal();
514 }
515
516 if (GetMeanChargeErr() < fChargeErrLimit)
517 {
518 *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
519 << fChargeErrLimit << " in Pixel " << fPixId << endl;
520 bad->SetChargeErrNotValid();
521 }
522
523 if (GetMeanCharge() < fChargeRelErrLimit*GetMeanChargeErr())
524 {
525 *fLog << warn << "WARNING: Fitted Charge is smaller than "
526 << fChargeRelErrLimit << "* its error in Pixel " << fPixId << endl;
527 bad->SetChargeRelErrNotValid();
528 }
529
530 if (GetSigmaCharge() < GetPedRms())
531 {
532 *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in Pixel "
533 << fPixId << endl;
534 bad->SetChargeSigmaNotValid();
535 }
536
537}
538
539//
540// The check returns kTRUE if:
541//
542// The mean arrival time is at least 1.0 slices from the used edge slices
543//
544void MCalibrationChargePix::CheckTimeValidity(MBadPixelsPix *bad)
545{
546
547 const Float_t loweredge = IsHiGainSaturation() ? fTimeFirstHiGain : fTimeFirstLoGain;
548 const Float_t upperedge = IsHiGainSaturation() ? fTimeLastHiGain : fTimeLastLoGain;
549
550 if ( fAbsTimeMean < loweredge+1.)
551 {
552 *fLog << warn << "WARNING: Mean ArrivalTime in first extraction bin of the Pixel " << fPixId << endl;
553 bad->SetMeanTimeInFirstBin();
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 }
561
562}
563
564void 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
608Bool_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//
653Bool_t MCalibrationChargePix::CalcFFactorMethod()
654{
655
656 if (fRSigmaCharge < 0.)
657 return kFALSE;
658
659 //
660 // Square all variables in order to avoid applications of square root
661 //
662 // First the relative error squares
663 //
664 const Float_t chargeSquare = GetMeanCharge() * GetMeanCharge();
665 const Float_t chargeSquareRelErrSquare = 4.* GetMeanChargeErr() * GetMeanChargeErr() / chargeSquare;
666
667 const Float_t chargeRelErrSquare = GetMeanChargeErr() * GetMeanChargeErr()
668 / (GetMeanCharge() * GetMeanCharge());
669
670 const Float_t ffactorsquare = gkFFactor * gkFFactor;
671 const Float_t ffactorsquareRelErrSquare = 4.*gkFFactorErr * gkFFactorErr / ffactorsquare;
672
673 const Float_t avQERelErrSquare = fAverageQEErr * fAverageQEErr / fAverageQE / fAverageQE;
674
675 const Float_t avQEFFactor = TMath::Sqrt( ( 1. - fAverageQE ) / fAverageQE );
676 const Float_t avQEFFactorErr = 1./ ( 2. * avQEFFactor ) * fAverageQEErr
677 / ( fAverageQE * fAverageQE );
678
679 const Float_t avQEFFactorRelErrSquare = avQEFFactorErr * avQEFFactorErr
680 / ( avQEFFactor * avQEFFactor) ;
681
682 const Float_t rsigmaSquare = fRSigmaCharge * fRSigmaCharge;
683 const Float_t rsigmaSquareRelErrSquare = 4.* fRSigmaChargeErr * fRSigmaChargeErr / rsigmaSquare;
684
685
686 //
687 // Calculate the number of phe's from the F-Factor method
688 // (independent on Hi Gain or Lo Gain)
689 //
690 fPheFFactorMethod = ffactorsquare * chargeSquare / rsigmaSquare;
691
692 if (fPheFFactorMethod < 0.)
693 return kFALSE;
694
695 //
696 // Calculate the Error of Nphe
697 //
698 const Float_t pheFFactorRelErrSquare = ffactorsquareRelErrSquare
699 + chargeSquareRelErrSquare
700 + rsigmaSquareRelErrSquare;
701 fPheFFactorMethodErr = TMath::Sqrt(pheFFactorRelErrSquare) * fPheFFactorMethod;
702
703 //
704 // Calculate the conversion factor between PHOTONS and FADC counts
705 //
706 // Nphot = Nphe / avQE
707 // conv = Nphot / FADC counts
708 //
709 fMeanConversionFFactorMethod = fPheFFactorMethod / fAverageQE / GetMeanCharge();
710
711
712 //
713 // Calculate the error of the mean conversion factor between PHOTONS and FADC counts
714 //
715 const Float_t convRelErrSquare = ( pheFFactorRelErrSquare + chargeRelErrSquare + avQERelErrSquare);
716
717 if (convRelErrSquare < 0.)
718 return kFALSE;
719
720
721 const Float_t convRelErr = TMath::Sqrt(convRelErrSquare);
722 fConversionFFactorMethodErr = convRelErr * fMeanConversionFFactorMethod;
723
724 if (convRelErr < fConvFFactorRelErrLimit)
725 SetFFactorMethodValid();
726
727 //
728 // Calculate the Total F-Factor of the camera (in photons)
729 //
730 fTotalFFactorFFactorMethod = (fRSigmaCharge/GetMeanCharge())*TMath::Sqrt(fPheFFactorMethod);
731 fTotalFFactorFFactorMethod *= avQEFFactor;
732
733 //
734 // Calculate the error of the Total F-Factor of the camera ( in photons )
735 //
736 const Float_t rsigmaChargeRelErrSquare = fRSigmaChargeErr * fRSigmaChargeErr
737 / (fRSigmaCharge * fRSigmaCharge) ;
738
739 fTotalFFactorErrFFactorMethod = TMath::Sqrt( rsigmaChargeRelErrSquare
740 + chargeRelErrSquare
741 + pheFFactorRelErrSquare
742 + avQEFFactorRelErrSquare );
743 fTotalFFactorErrFFactorMethod *= fTotalFFactorFFactorMethod;
744
745 //
746 // Calculate the sigma of the conversion from FADC counts to photons
747 //
748 fSigmaConversionFFactorMethod = GetTotalFFactorFFactorMethod()*TMath::Sqrt(fMeanConversionFFactorMethod);
749
750 return kTRUE;
751}
752
753void MCalibrationChargePix::ApplyLoGainConversion()
754{
755
756 const Float_t chargeRelErrSquare = fLoGainMeanChargeErr * fLoGainMeanChargeErr
757 /( fLoGainMeanCharge * fLoGainMeanCharge );
758 const Float_t sigmaRelErrSquare = fLoGainSigmaChargeErr * fLoGainSigmaChargeErr
759 /( fLoGainSigmaCharge * fLoGainSigmaCharge );
760 const Float_t conversionRelErrSquare = fConversionHiLoErr * fConversionHiLoErr
761 /( fConversionHiLo * fConversionHiLo );
762
763 fLoGainMeanCharge *= fConversionHiLo;
764 fLoGainMeanChargeErr = TMath::Sqrt(chargeRelErrSquare + conversionRelErrSquare) * fLoGainMeanCharge;
765
766 fLoGainSigmaCharge *= fConversionHiLo;
767 fLoGainSigmaChargeErr = TMath::Sqrt(sigmaRelErrSquare + conversionRelErrSquare) * fLoGainSigmaCharge;
768
769 fElectronicPedRms = gkElectronicPedRms * TMath::Sqrt(fNumLoGainSamples);
770 fElectronicPedRmsErr = gkElectronicPedRmsErr * TMath::Sqrt(fNumLoGainSamples);
771
772}
773
Note: See TracBrowser for help on using the repository browser.