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

Last change on this file since 3428 was 3427, checked in by gaug, 21 years ago
*** empty log message ***
File size: 25.8 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//
506Bool_t MCalibrationChargePix::CheckChargeValidity(MBadPixelsPix *bad)
507{
508
509 if (!IsFitted())
510 return kFALSE;
511
512 if (GetMeanCharge() < fChargeLimit*GetPedRms())
513 {
514 *fLog << warn << "WARNING: Fitted Charge is smaller than "
515 << fChargeLimit << " Pedestal RMS in Pixel " << fPixId << endl;
516 if (bad)
517 bad->SetCalcChargePedestal();
518 else
519 return kFALSE;
520 }
521 else
522 if (bad)
523 bad->SetNoCalcChargePedestal();
524
525
526 if (GetMeanChargeErr() < fChargeErrLimit)
527 {
528 *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
529 << fChargeErrLimit << " in Pixel " << fPixId << endl;
530 if (bad)
531 bad->SetNoCalcChargeErrValid();
532 else
533 return kFALSE;
534 }
535 else
536 if (bad)
537 bad->SetCalcChargeErrValid();
538
539 if (GetMeanCharge() < fChargeRelErrLimit*GetMeanChargeErr())
540 {
541 *fLog << warn << "WARNING: Fitted Charge is smaller than "
542 << fChargeRelErrLimit << "* its error in Pixel " << fPixId << endl;
543 if (bad)
544 bad->SetNoCalcChargeRelErrValid();
545 else
546 return kFALSE;
547 }
548 else
549 if (bad)
550 bad->SetCalcChargeRelErrValid();
551
552 if (GetSigmaCharge() < GetPedRms())
553 {
554 *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in Pixel "
555 << fPixId << endl;
556 if (bad)
557 bad->SetNoCalcChargeSigmaValid();
558 else
559 return kFALSE;
560 }
561 else
562 if (bad)
563 bad->SetCalcChargeSigmaValid();
564
565 return kTRUE;
566}
567
568//
569// The check returns kTRUE if:
570//
571// The mean arrival time is at least 1.0 slices from the used edge slices
572//
573Bool_t MCalibrationChargePix::CheckTimeValidity(MBadPixelsPix *bad)
574{
575
576 const Float_t loweredge = IsHiGainSaturation() ? fTimeFirstHiGain : fTimeFirstLoGain;
577 const Float_t upperedge = IsHiGainSaturation() ? fTimeLastHiGain : fTimeLastLoGain;
578
579 if ( fAbsTimeMean < loweredge+1.)
580 {
581 *fLog << warn << "WARNING: Mean ArrivalTime in first extraction bin of the Pixel " << fPixId << endl;
582 if (bad)
583 bad->SetMeanTimeInFirstBin();
584 else
585 return kFALSE;
586 }
587 else
588 bad->SetNoMeanTimeInFirstBin();
589
590 if ( fAbsTimeMean > upperedge-1.)
591 {
592 *fLog << warn << "WARNING: Mean ArrivalTime in last extraction bin of the Pixel " << fPixId << endl;
593 if (bad)
594 bad->SetMeanTimeInLastBin();
595 else
596 return kFALSE;
597 }
598 else
599 bad->SetNoMeanTimeInLastBin();
600
601 return kTRUE;
602}
603
604void MCalibrationChargePix::CalcLoGainPed()
605{
606
607 Float_t pedRmsSquare = fPedRms * fPedRms;
608 Float_t pedRmsSquareErrSquare = fPedErr * fPedErr * pedRmsSquare; // fPedRmsErr = fPedErr/2.
609 Float_t pedRmsSquareErr;
610
611 //
612 // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it
613 // from the HI GAIN (all calculation per slice up to now):
614 //
615 // We extract the pure NSB contribution:
616 //
617 const Float_t elecRmsSquare = fElectronicPedRms * fElectronicPedRms;
618 const Float_t elecRmsSquareErrSquare = 4.*fElectronicPedRmsErr * fElectronicPedRmsErr * elecRmsSquare;
619
620 Float_t nsbSquare = pedRmsSquare - elecRmsSquare;
621 Float_t nsbSquareRelErrSquare = (pedRmsSquareErrSquare + elecRmsSquareErrSquare)
622 / (nsbSquare * nsbSquare) ;
623
624 if (nsbSquare < 0.)
625 nsbSquare = 0.;
626
627 //
628 // Now, we divide the NSB by the conversion factor and
629 // add it quadratically to the electronic noise
630 //
631 const Float_t conversionSquare = fConversionHiLo * fConversionHiLo;
632 const Float_t conversionSquareRelErrSquare = 4.*fConversionHiLoErr * fConversionHiLoErr / conversionSquare;
633
634 const Float_t convertedNsbSquare = nsbSquare / conversionSquare;
635 const Float_t convertedNsbSquareErrSquare = (nsbSquareRelErrSquare + conversionSquareRelErrSquare)
636 * convertedNsbSquare * convertedNsbSquare;
637
638 pedRmsSquare = convertedNsbSquare + elecRmsSquare;
639 pedRmsSquareErr = TMath::Sqrt( convertedNsbSquareErrSquare + elecRmsSquareErrSquare );
640
641 //
642 // Correct also for the conversion to Hi-Gain:
643 //
644 fLoGainPedRms = TMath::Sqrt(pedRmsSquare) * fConversionHiLo;
645 fLoGainPedRmsErr = 0.5 * pedRmsSquareErr / fLoGainPedRms * fConversionHiLo;
646}
647
648Bool_t MCalibrationChargePix::CalcReducedSigma()
649{
650
651 const Float_t sigmaSquare = GetSigmaCharge() * GetSigmaCharge();
652 const Float_t sigmaSquareErrSquare = 4.*GetSigmaChargeErr()* GetSigmaChargeErr() * sigmaSquare;
653
654 Float_t pedRmsSquare;
655 Float_t pedRmsSquareErrSquare;
656
657 if (IsHiGainSaturation())
658 {
659 CalcLoGainPed();
660
661 pedRmsSquare = fLoGainPedRms * fLoGainPedRms;
662 pedRmsSquareErrSquare = 4.* fLoGainPedRmsErr * fLoGainPedRmsErr * pedRmsSquare;
663 } /* if (HiGainSaturation) */
664 else
665 {
666
667 pedRmsSquare = fPedRms * fPedRms;
668 pedRmsSquareErrSquare = fPedErr * fPedErr * pedRmsSquare; // fPedRmsErr = fPedErr/2.
669 }
670 //
671 // Calculate the reduced sigmas
672 //
673 const Float_t rsigmachargesquare = sigmaSquare - pedRmsSquare;
674
675 if (rsigmachargesquare <= 0.)
676 {
677 *fLog << warn
678 << "WARNING: Cannot calculate the reduced sigma: smaller than 0 in pixel "
679 << fPixId << endl;
680 return kFALSE;
681 }
682
683 fRSigmaCharge = TMath::Sqrt(rsigmachargesquare);
684 fRSigmaChargeErr = TMath::Sqrt(sigmaSquareErrSquare + pedRmsSquareErrSquare) / 2. / fRSigmaCharge;
685
686 return kTRUE;
687}
688
689//
690// Calculate the number of photo-electrons after the F-Factor method
691// Calculate the errors of the F-Factor method
692//
693Bool_t MCalibrationChargePix::CalcFFactorMethod()
694{
695
696 if (fRSigmaCharge < 0.)
697 return kFALSE;
698
699 //
700 // Square all variables in order to avoid applications of square root
701 //
702 // First the relative error squares
703 //
704 const Float_t chargeSquare = GetMeanCharge() * GetMeanCharge();
705 const Float_t chargeSquareRelErrSquare = 4.* GetMeanChargeErr() * GetMeanChargeErr() / chargeSquare;
706
707 const Float_t chargeRelErrSquare = GetMeanChargeErr() * GetMeanChargeErr()
708 / (GetMeanCharge() * GetMeanCharge());
709
710 const Float_t ffactorsquare = gkFFactor * gkFFactor;
711 const Float_t ffactorsquareRelErrSquare = 4.*gkFFactorErr * gkFFactorErr / ffactorsquare;
712
713 const Float_t avQERelErrSquare = fAverageQEErr * fAverageQEErr / fAverageQE / fAverageQE;
714
715 const Float_t avQEFFactor = TMath::Sqrt( ( 1. - fAverageQE ) / fAverageQE );
716 const Float_t avQEFFactorErr = 1./ ( 2. * avQEFFactor ) * fAverageQEErr
717 / ( fAverageQE * fAverageQE );
718
719 const Float_t avQEFFactorRelErrSquare = avQEFFactorErr * avQEFFactorErr
720 / ( avQEFFactor * avQEFFactor) ;
721
722 const Float_t rsigmaSquare = fRSigmaCharge * fRSigmaCharge;
723 const Float_t rsigmaSquareRelErrSquare = 4.* fRSigmaChargeErr * fRSigmaChargeErr / rsigmaSquare;
724
725
726 //
727 // Calculate the number of phe's from the F-Factor method
728 // (independent on Hi Gain or Lo Gain)
729 //
730 fPheFFactorMethod = ffactorsquare * chargeSquare / rsigmaSquare;
731
732 if (fPheFFactorMethod < 0.)
733 return kFALSE;
734
735 //
736 // Calculate the Error of Nphe
737 //
738 const Float_t pheFFactorRelErrSquare = ffactorsquareRelErrSquare
739 + chargeSquareRelErrSquare
740 + rsigmaSquareRelErrSquare;
741 fPheFFactorMethodErr = TMath::Sqrt(pheFFactorRelErrSquare) * fPheFFactorMethod;
742
743 //
744 // Calculate the conversion factor between PHOTONS and FADC counts
745 //
746 // Nphot = Nphe / avQE
747 // conv = Nphot / FADC counts
748 //
749 fMeanConversionFFactorMethod = fPheFFactorMethod / fAverageQE / GetMeanCharge();
750
751
752 //
753 // Calculate the error of the mean conversion factor between PHOTONS and FADC counts
754 //
755 const Float_t convRelErrSquare = ( pheFFactorRelErrSquare + chargeRelErrSquare + avQERelErrSquare);
756
757 if (convRelErrSquare < 0.)
758 return kFALSE;
759
760
761 const Float_t convRelErr = TMath::Sqrt(convRelErrSquare);
762 fConversionFFactorMethodErr = convRelErr * fMeanConversionFFactorMethod;
763
764 if (convRelErr < fConvFFactorRelErrLimit)
765 SetFFactorMethodValid();
766
767 //
768 // Calculate the Total F-Factor of the camera (in photons)
769 //
770 fTotalFFactorFFactorMethod = (fRSigmaCharge/GetMeanCharge())*TMath::Sqrt(fPheFFactorMethod);
771 fTotalFFactorFFactorMethod *= avQEFFactor;
772
773 //
774 // Calculate the error of the Total F-Factor of the camera ( in photons )
775 //
776 const Float_t rsigmaChargeRelErrSquare = fRSigmaChargeErr * fRSigmaChargeErr
777 / (fRSigmaCharge * fRSigmaCharge) ;
778
779 fTotalFFactorErrFFactorMethod = TMath::Sqrt( rsigmaChargeRelErrSquare
780 + chargeRelErrSquare
781 + pheFFactorRelErrSquare
782 + avQEFFactorRelErrSquare );
783 fTotalFFactorErrFFactorMethod *= fTotalFFactorFFactorMethod;
784
785 //
786 // Calculate the sigma of the conversion from FADC counts to photons
787 //
788 fSigmaConversionFFactorMethod = GetTotalFFactorFFactorMethod()*TMath::Sqrt(fMeanConversionFFactorMethod);
789
790 return kTRUE;
791}
792
793void MCalibrationChargePix::ApplyLoGainConversion()
794{
795
796 const Float_t chargeRelErrSquare = fLoGainMeanChargeErr * fLoGainMeanChargeErr
797 /( fLoGainMeanCharge * fLoGainMeanCharge );
798 const Float_t sigmaRelErrSquare = fLoGainSigmaChargeErr * fLoGainSigmaChargeErr
799 /( fLoGainSigmaCharge * fLoGainSigmaCharge );
800 const Float_t conversionRelErrSquare = fConversionHiLoErr * fConversionHiLoErr
801 /( fConversionHiLo * fConversionHiLo );
802
803 fLoGainMeanCharge *= fConversionHiLo;
804 fLoGainMeanChargeErr = TMath::Sqrt(chargeRelErrSquare + conversionRelErrSquare) * fLoGainMeanCharge;
805
806 fLoGainSigmaCharge *= fConversionHiLo;
807 fLoGainSigmaChargeErr = TMath::Sqrt(sigmaRelErrSquare + conversionRelErrSquare) * fLoGainSigmaCharge;
808
809 fElectronicPedRms = gkElectronicPedRms * TMath::Sqrt(fNumLoGainSamples);
810 fElectronicPedRmsErr = gkElectronicPedRmsErr * TMath::Sqrt(fNumLoGainSamples);
811
812}
813
Note: See TracBrowser for help on using the repository browser.