source: trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc@ 3077

Last change on this file since 3077 was 3065, checked in by gaug, 21 years ago
*** empty log message ***
File size: 25.5 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 11/2003 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MCalibrationPix //
28// //
29// This is the storage container to hold informations about the pedestal //
30// (offset) value 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/////////////////////////////////////////////////////////////////////////////
43#include "MCalibrationPix.h"
44#include "MCalibrationConfig.h"
45
46#include "MLog.h"
47#include "MLogManip.h"
48
49ClassImp(MCalibrationPix);
50
51using namespace std;
52
53const Float_t MCalibrationPix::gkElectronicPedRms = 1.5;
54const Float_t MCalibrationPix::gkErrElectronicPedRms = 0.3;
55const Float_t MCalibrationPix::gkFFactor = 1.15;
56const Float_t MCalibrationPix::gkFFactorError = 0.02;
57const Float_t MCalibrationPix::gkChargeLimit = 3.;
58const Float_t MCalibrationPix::gkChargeErrLimit = 0.;
59const Float_t MCalibrationPix::gkChargeRelErrLimit = 1.;
60const Float_t MCalibrationPix::gkTimeLimit = 1.5;
61const Float_t MCalibrationPix::gkTimeErrLimit = 3.;
62const Float_t MCalibrationPix::gkConvFFactorRelErrorLimit = 0.1;
63
64// --------------------------------------------------------------------------
65//
66// Default Constructor:
67//
68MCalibrationPix::MCalibrationPix(const char *name, const char *title)
69 : fPixId(-1),
70 fFlags(0)
71{
72
73 fName = name ? name : "MCalibrationPixel";
74 fTitle = title ? title : "Container of the MHCalibrationPixels and the fit results";
75
76 //
77 // At the moment, we don't have a database, yet,
78 // so we get it from the configuration file
79 //
80 fConversionHiLo = gkConversionHiLo;
81 fConversionHiLoError = gkConversionHiLoError;
82
83 fHist = new MHCalibrationPixel("MHCalibrationPixel","Calibration Histograms Pixel ");
84
85 if (!fHist)
86 *fLog << warn << dbginf << " Could not create MHCalibrationPixel " << endl;
87
88 Clear();
89}
90
91MCalibrationPix::~MCalibrationPix()
92{
93 delete fHist;
94}
95
96
97// ------------------------------------------------------------------------
98//
99// Invalidate values
100//
101void MCalibrationPix::Clear(Option_t *o)
102{
103
104 fHist->Reset();
105
106 CLRBIT(fFlags, kHiGainSaturation);
107 CLRBIT(fFlags, kExcluded);
108 CLRBIT(fFlags, kExcludeQualityCheck);
109 CLRBIT(fFlags, kChargeValid);
110 CLRBIT(fFlags, kFitted);
111 CLRBIT(fFlags, kOscillating);
112 CLRBIT(fFlags, kBlindPixelMethodValid);
113 CLRBIT(fFlags, kFFactorMethodValid);
114 CLRBIT(fFlags, kPINDiodeMethodValid);
115
116 fCharge = -1.;
117 fErrCharge = -1.;
118 fSigmaCharge = -1.;
119 fErrSigmaCharge = -1.;
120 fRSigmaCharge = -1.;
121 fErrRSigmaCharge = -1.;
122
123 fChargeProb = -1.;
124 fPed = -1.;
125 fPedRms = -1.;
126 fErrPedRms = 0.;
127
128 fNumHiGainSamples = -1.;
129 fNumLoGainSamples = -1.;
130
131 fTimeFirstHiGain = 0 ;
132 fTimeLastHiGain = 0 ;
133 fTimeFirstLoGain = 0 ;
134 fTimeLastLoGain = 0 ;
135
136 fAbsTimeMean = -1.;
137 fAbsTimeRms = -1.;
138
139 fPheFFactorMethod = -1.;
140 fPheFFactorMethodError = -1.;
141
142 fMeanConversionFFactorMethod = -1.;
143 fMeanConversionBlindPixelMethod = -1.;
144 fMeanConversionPINDiodeMethod = -1.;
145
146 fErrorConversionFFactorMethod = -1.;
147 fErrorConversionBlindPixelMethod = -1.;
148 fErrorConversionPINDiodeMethod = -1.;
149
150 fSigmaConversionFFactorMethod = -1.;
151 fSigmaConversionBlindPixelMethod = -1.;
152 fSigmaConversionPINDiodeMethod = -1.;
153
154 fFactorCalculated = kFALSE;
155
156}
157
158
159void MCalibrationPix::DefinePixId(Int_t i)
160{
161
162 fPixId = i;
163 fHist->ChangeHistId(i);
164
165}
166
167
168// --------------------------------------------------------------------------
169//
170// Set the pedestals from outside
171//
172void MCalibrationPix::SetPedestal(const Float_t ped, const Float_t pedrms,
173 const Float_t higainsamp, const Float_t logainsamp )
174{
175
176 fPed = ped;
177 fPedRms = pedrms;
178
179 fNumHiGainSamples = higainsamp;
180 fNumLoGainSamples = logainsamp;
181
182}
183
184// --------------------------------------------------------------------------
185//
186// Set the conversion factors from outside (only for MC)
187//
188void MCalibrationPix::SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig)
189{
190 fMeanConversionFFactorMethod = c;
191 fErrorConversionFFactorMethod = err;
192 fSigmaConversionFFactorMethod = sig;
193}
194
195
196// --------------------------------------------------------------------------
197//
198// Set the conversion factors from outside (only for MC)
199//
200void MCalibrationPix::SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig)
201{
202 fMeanConversionBlindPixelMethod = c;
203 fErrorConversionBlindPixelMethod = err;
204 fSigmaConversionBlindPixelMethod = sig;
205}
206
207// --------------------------------------------------------------------------
208//
209// Set the conversion factors from outside (only for MC)
210//
211void MCalibrationPix::SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig)
212{
213 fMeanConversionPINDiodeMethod = c ;
214 fErrorConversionPINDiodeMethod = err;
215 fSigmaConversionPINDiodeMethod = sig;
216}
217
218// --------------------------------------------------------------------------
219//
220// Set the Hi Gain Saturation Bit from outside (only for MC)
221//
222void MCalibrationPix::SetHiGainSaturation(Bool_t b)
223{
224
225 if (b)
226 {
227 SETBIT(fFlags, kHiGainSaturation);
228 fHist->SetUseLoGain(1);
229 }
230 else
231 {
232 CLRBIT(fFlags, kHiGainSaturation);
233 fHist->SetUseLoGain(0);
234 }
235}
236
237// --------------------------------------------------------------------------
238//
239// Set the Excluded Bit from outside
240//
241void MCalibrationPix::SetExcluded(Bool_t b )
242{
243 b ? SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded);
244}
245
246
247// --------------------------------------------------------------------------
248//
249// Set the Excluded Bit from outside
250//
251void MCalibrationPix::SetExcludeQualityCheck(Bool_t b )
252{
253 b ? SETBIT(fFlags, kExcludeQualityCheck) : CLRBIT(fFlags, kExcludeQualityCheck);
254}
255
256// --------------------------------------------------------------------------
257//
258// Set the Excluded Bit from outside
259//
260void MCalibrationPix::SetChargeValid(Bool_t b )
261{
262 b ? SETBIT(fFlags, kChargeValid) : CLRBIT(fFlags, kChargeValid);
263}
264
265// --------------------------------------------------------------------------
266//
267// Set the Excluded Bit from outside
268//
269void MCalibrationPix::SetFitted(Bool_t b )
270{
271 b ? SETBIT(fFlags, kFitted) : CLRBIT(fFlags, kFitted);
272}
273
274// --------------------------------------------------------------------------
275//
276// Set the Excluded Bit from outside
277//
278void MCalibrationPix::SetOscillating(Bool_t b )
279{
280 b ? SETBIT(fFlags, kOscillating) : CLRBIT(fFlags, kOscillating);
281}
282
283// --------------------------------------------------------------------------
284//
285// Set the Excluded Bit from outside
286//
287void MCalibrationPix::SetBlindPixelMethodValid(Bool_t b )
288{
289 b ? SETBIT(fFlags, kBlindPixelMethodValid) : CLRBIT(fFlags, kBlindPixelMethodValid);
290}
291
292// --------------------------------------------------------------------------
293//
294// Set the Excluded Bit from outside
295//
296void MCalibrationPix::SetFFactorMethodValid(Bool_t b )
297{
298 b ? SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid);
299}
300
301// --------------------------------------------------------------------------
302//
303// Set the Excluded Bit from outside
304//
305void MCalibrationPix::SetPINDiodeMethodValid(Bool_t b )
306{
307 b ? SETBIT(fFlags, kPINDiodeMethodValid) : CLRBIT(fFlags, kPINDiodeMethodValid);
308}
309
310void MCalibrationPix::SetAbsTimeBordersHiGain(Byte_t f, Byte_t l)
311{
312
313 fTimeFirstHiGain = f;
314 fTimeLastHiGain = l;
315
316}
317
318void MCalibrationPix::SetAbsTimeBordersLoGain(Byte_t f, Byte_t l)
319{
320
321 fTimeFirstLoGain = f;
322 fTimeLastLoGain = l;
323
324}
325
326Float_t MCalibrationPix::GetPheFFactorMethod()
327{
328
329 if (!fFactorCalculated)
330 CalcFFactorMethod();
331
332 return fPheFFactorMethod;
333
334}
335
336Float_t MCalibrationPix::GetPheFFactorMethodError()
337{
338
339 if (!fFactorCalculated)
340 CalcFFactorMethod();
341
342 return fPheFFactorMethodError;
343
344}
345
346
347Float_t MCalibrationPix::GetTotalFFactorFFactorMethod()
348{
349 if (!fFactorCalculated)
350 CalcFFactorMethod();
351
352 if (fPheFFactorMethod > 0)
353 return (fRSigmaCharge/fCharge)*TMath::Sqrt(fPheFFactorMethod);
354 else
355 return -1.;
356}
357
358Float_t MCalibrationPix::GetTotalFFactorErrorFFactorMethod()
359{
360
361 if (!fFactorCalculated)
362 CalcFFactorMethod();
363
364 const Float_t rsigmaChargeRelErrSquare = fErrRSigmaCharge * fErrRSigmaCharge
365 / (fRSigmaCharge * fRSigmaCharge) ;
366 const Float_t rChargeRelErrSquare = fErrCharge * fErrCharge
367 / (fCharge * fCharge) ;
368 const Float_t rPheRelErrSquare = fPheFFactorMethodError * fPheFFactorMethodError
369 / (fPheFFactorMethod * fPheFFactorMethod) ;
370
371 return TMath::Sqrt(rsigmaChargeRelErrSquare+rChargeRelErrSquare+rPheRelErrSquare);
372}
373
374
375Float_t MCalibrationPix::GetTotalFFactorBlindPixelMethod()
376{
377 return 1.;
378}
379
380Float_t MCalibrationPix::GetTotalFFactorErrorBlindPixelMethod()
381{
382
383 return 1.;
384}
385
386Float_t MCalibrationPix::GetTotalFFactorPINDiodeMethod()
387{
388 return 1.;
389}
390
391Float_t MCalibrationPix::GetTotalFFactorErrorPINDiodeMethod()
392{
393
394 return 1.;
395}
396
397
398
399Float_t MCalibrationPix::GetMeanConversionFFactorMethod()
400{
401
402 if (!fFactorCalculated)
403 CalcFFactorMethod();
404
405 return fMeanConversionFFactorMethod;
406
407}
408
409Float_t MCalibrationPix::GetErrorConversionFFactorMethod()
410{
411
412 if (!fFactorCalculated)
413 CalcFFactorMethod();
414
415 return fErrorConversionFFactorMethod;
416
417}
418
419Float_t MCalibrationPix::GetSigmaConversionFFactorMethod()
420{
421
422 if (!fFactorCalculated)
423 CalcFFactorMethod();
424
425 return fSigmaConversionFFactorMethod;
426
427}
428
429
430Bool_t MCalibrationPix::IsExcluded() const
431 {
432 return TESTBIT(fFlags,kExcluded);
433 }
434
435Bool_t MCalibrationPix::IsExcludeQualityCheck() const
436 {
437 return TESTBIT(fFlags,kExcludeQualityCheck);
438 }
439
440Bool_t MCalibrationPix::IsHiGainSaturation() const
441 {
442 return TESTBIT(fFlags,kHiGainSaturation);
443 }
444
445Bool_t MCalibrationPix::IsChargeValid() const
446{
447 return TESTBIT(fFlags, kChargeValid);
448}
449
450Bool_t MCalibrationPix::IsFitted() const
451{
452 return TESTBIT(fFlags, kFitted);
453}
454
455Bool_t MCalibrationPix::IsOscillating()
456{
457
458 if (TESTBIT(fFlags, kOscillating))
459 return kTRUE;
460
461 if (fHist->CheckOscillations())
462 {
463 SETBIT(fFlags,kOscillating);
464 return kTRUE;
465 }
466
467 return kFALSE;
468}
469
470Bool_t MCalibrationPix::IsBlindPixelMethodValid() const
471{
472 return TESTBIT(fFlags, kBlindPixelMethodValid);
473}
474
475Bool_t MCalibrationPix::IsFFactorMethodValid()
476{
477
478 if (!fFactorCalculated)
479 CalcFFactorMethod();
480
481 return TESTBIT(fFlags, kFFactorMethodValid);
482}
483
484Bool_t MCalibrationPix::IsPINDiodeMethodValid() const
485{
486 return TESTBIT(fFlags, kPINDiodeMethodValid);
487}
488
489
490// --------------------------------------------------------------------------
491//
492// 1) Return if the charge distribution is already succesfully fitted
493// or if the histogram is empty
494// 2) Set a lower Fit range according to 1.5 Pedestal RMS in order to avoid
495// possible remaining cosmics to spoil the fit.
496// 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
497// 4) Fit the histograms with a Gaussian
498// 5) In case of failure set the bit kFitted to false
499// 6) Retrieve the results and store them in this class
500// 7) Calculate the number of photo-electrons after the F-Factor method
501// 8) Calculate the errors of the F-Factor method
502//
503// The fits are declared valid (fFitValid = kTRUE), if:
504//
505// 1) Pixel has a fitted charge greater than 3*PedRMS
506// 2) Pixel has a fit error greater than 0.
507// 3) Pixel has a fit Probability greater than 0.0001
508// 4) Pixel has a charge sigma bigger than its Pedestal RMS
509// 5) If FitTimes is used,
510// the mean arrival time is at least 1.0 slices from the used edge slices
511// (this stage is only performed in the times fit)
512//
513// If the histogram is empty, all values are set to -1.
514//
515// The conversion factor after the F-Factor method is declared valid, if:
516//
517// 1) fFitValid is kTRUE
518// 2) Conversion Factor is bigger than 0.
519// 3) The error of the conversion factor is smaller than 10%
520//
521Bool_t MCalibrationPix::FitCharge()
522{
523
524 //
525 // 1) Return if the charge distribution is already succesfully fitted
526 // or if the histogram is empty
527 //
528 if (fHist->IsChargeFitOK() || fHist->IsEmpty())
529 return kTRUE;
530
531 //
532 // 2) Set a lower Fit range according to 1.5 Pedestal RMS in order to avoid
533 // possible remaining cosmics to spoil the fit.
534 //
535 // if (fPed && fPedRms)
536 // fHist->SetLowerFitRange(1.5*fPedRms);
537 // else
538 // *fLog << warn << "WARNING: Cannot set lower fit range: Pedestals not available" << endl;
539
540 //
541 // 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
542 //
543 if (fHist->UseLoGain())
544 SetHiGainSaturation();
545
546 //
547 // 4) Fit the Lo Gain histograms with a Gaussian
548 //
549 if (fHist->FitCharge())
550 SETBIT(fFlags,kFitted);
551 else
552 {
553 *fLog << warn << "WARNING: Could not fit charges of pixel " << fPixId << endl;
554 //
555 // 5) In case of failure set the bit kFitted to false
556 //
557 CLRBIT(fFlags,kFitted);
558 }
559
560 //
561 // 6) Retrieve the results and store them in this class
562 // If fFitted is false, we get the means and RMS of the histogram!!
563 //
564 fCharge = fHist->GetChargeMean();
565 fErrCharge = fHist->GetChargeMeanErr();
566 fSigmaCharge = fHist->GetChargeSigma();
567 fErrSigmaCharge = fHist->GetChargeSigmaErr();
568 fChargeProb = fHist->GetChargeProb();
569
570
571 fAbsTimeMean = fHist->GetAbsTimeMean();
572 fAbsTimeMeanErr = fHist->GetAbsTimeMeanErr();
573 fAbsTimeRms = fHist->GetAbsTimeRms();
574
575 if (CheckTimeFitValidity())
576 SETBIT(fFlags,kTimeFitValid);
577 else
578 CLRBIT(fFlags,kTimeFitValid);
579
580 //
581 // Calculate the conversion factors
582 //
583 if (IsHiGainSaturation())
584 ApplyLoGainConversion();
585
586 if (CheckChargeValidity())
587 SETBIT(fFlags,kChargeValid);
588 else
589 {
590 CLRBIT(fFlags,kChargeValid);
591 return kFALSE;
592 }
593
594 return kTRUE;
595
596}
597
598//
599// Calculate the number of photo-electrons after the F-Factor method
600// Calculate the errors of the F-Factor method
601//
602Bool_t MCalibrationPix::CalcFFactorMethod()
603{
604
605 if ( (fCharge == -1.)
606 || (fErrCharge < 0.)
607 || (fSigmaCharge < 0.)
608 || (fPedRms < 0.) )
609 {
610 *fLog << warn << GetDescriptor() << "Cannot calculate the FFactor Method! "
611 << "Some of the needed parameters are not available ";
612 CLRBIT(fFlags,kFFactorMethodValid);
613 return kFALSE;
614 }
615
616 //
617 // Square all variables in order to avoid applications of square root
618 //
619 // First the relative error squares
620 //
621 const Float_t chargeSquare = fCharge* fCharge;
622 const Float_t chargeSquareRelErrSquare = 4.*fErrCharge*fErrCharge / chargeSquare;
623
624 const Float_t ffactorsquare = gkFFactor * gkFFactor;
625 const Float_t ffactorsquareRelErrSquare = 4.*gkFFactorError * gkFFactorError / ffactorsquare;
626 //
627 // Now the absolute error squares
628 //
629 const Float_t sigmaSquare = fSigmaCharge*fSigmaCharge;
630 const Float_t sigmaSquareErrSquare = 4.*fErrSigmaCharge*fErrSigmaCharge * sigmaSquare;
631
632 Float_t pedRmsSquare = fPedRms* fPedRms;
633 Float_t pedRmsSquareErrSquare = 4.*fErrPedRms*fErrPedRms * pedRmsSquare;
634
635 if (!IsHiGainSaturation())
636 { /* HiGain */
637
638 pedRmsSquare *= fNumHiGainSamples;
639 pedRmsSquareErrSquare *= fNumHiGainSamples*fNumHiGainSamples;
640 }
641 else
642 { /* LoGain */
643
644 //
645 // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it
646 // from the HI GAIN (all calculation per slice up to now):
647 //
648 // We extract the pure NSB contribution:
649 //
650 const Float_t elecRmsSquare = gkElectronicPedRms *gkElectronicPedRms;
651 const Float_t elecRmsSquareErrSquare = 4.*gkErrElectronicPedRms*gkErrElectronicPedRms * elecRmsSquare;
652
653 Float_t nsbSquare = pedRmsSquare - elecRmsSquare;
654 Float_t nsbSquareRelErrSquare = (pedRmsSquareErrSquare + elecRmsSquareErrSquare)
655 / (nsbSquare * nsbSquare) ;
656
657 if (nsbSquare < 0.)
658 nsbSquare = 0.;
659
660 //
661 // Now, we divide the NSB by the conversion factor and
662 // add it quadratically to the electronic noise
663 //
664 const Float_t conversionSquare = fConversionHiLo *fConversionHiLo;
665 const Float_t conversionSquareRelErrSquare = 4.*fConversionHiLoError*fConversionHiLoError/conversionSquare;
666
667 const Float_t convertedNsbSquare = nsbSquare / conversionSquare;
668 const Float_t convertedNsbSquareErrSquare = (nsbSquareRelErrSquare + conversionSquareRelErrSquare)
669 * convertedNsbSquare * convertedNsbSquare;
670
671 pedRmsSquare = convertedNsbSquare + elecRmsSquare;
672 pedRmsSquareErrSquare = convertedNsbSquareErrSquare + elecRmsSquareErrSquare;
673
674 //
675 // Now, correct for the number of used FADC slices in the LoGain:
676 //
677 pedRmsSquare *= fNumLoGainSamples;
678 pedRmsSquareErrSquare *= fNumLoGainSamples*fNumLoGainSamples;
679 //
680 // Correct also for the conversion to Hi-Gain:
681 //
682 pedRmsSquare *= fConversionHiLo*fConversionHiLo;
683 pedRmsSquareErrSquare *= fConversionHiLo*fConversionHiLo*fConversionHiLo*fConversionHiLo;
684
685 } /* if (HiGainSaturation) */
686
687 //
688 // Calculate the reduced sigmas
689 //
690 const Float_t rsigmachargesquare = sigmaSquare - pedRmsSquare;
691 if (rsigmachargesquare <= 0.)
692 {
693 *fLog << warn
694 << "WARNING: Cannot apply F-Factor calibration: Reduced Sigma smaller than 0 in pixel "
695 << fPixId << endl;
696 CLRBIT(fFlags,kFFactorMethodValid);
697 fFactorCalculated = kTRUE;
698 return kFALSE;
699 }
700
701 const Float_t rSigmaSquareRelErrSquare = (sigmaSquareErrSquare + pedRmsSquareErrSquare)
702 / (rsigmachargesquare * rsigmachargesquare) ;
703
704 fRSigmaCharge = TMath::Sqrt(rsigmachargesquare);
705 fErrRSigmaCharge = TMath::Sqrt(sigmaSquareErrSquare + pedRmsSquareErrSquare);
706
707
708 //
709 // Calculate the number of phe's from the F-Factor method
710 // (independent on Hi Gain or Lo Gain)
711 //
712 fPheFFactorMethod = ffactorsquare * chargeSquare / rsigmachargesquare;
713
714 const Float_t pheFFactorRelErrSquare = ffactorsquareRelErrSquare
715 + chargeSquareRelErrSquare
716 + rSigmaSquareRelErrSquare ;
717
718 fPheFFactorMethodError = TMath::Sqrt(pheFFactorRelErrSquare) * fPheFFactorMethod;
719
720 const Float_t chargeRelErrSquare = fErrCharge*fErrCharge / (fCharge * fCharge);
721
722 fMeanConversionFFactorMethod = fPheFFactorMethod / fCharge ;
723 fErrorConversionFFactorMethod = ( pheFFactorRelErrSquare + chargeRelErrSquare )
724 * fMeanConversionFFactorMethod * fMeanConversionFFactorMethod;
725
726 const Float_t convrelerror = fErrorConversionFFactorMethod/fMeanConversionFFactorMethod;
727
728 if ( (fMeanConversionFFactorMethod > 0.) && (convrelerror < gkConvFFactorRelErrorLimit))
729 SETBIT(fFlags,kFFactorMethodValid);
730
731 fFactorCalculated = kTRUE;
732
733 fSigmaConversionFFactorMethod = GetTotalFFactorFFactorMethod()*TMath::Sqrt(fMeanConversionFFactorMethod);
734
735 return kTRUE;
736}
737
738
739//
740// The check returns kTRUE if:
741//
742// 0) Pixel has BIT fitted set:
743// This means:
744// a) No result is a nan
745// b) The NDF is not smaller than fNDFLimit (5)
746// c) The Probability is greater than gkProbLimit (default 0.001 == 99.9%)
747// 1) Pixel has a fitted charge greater than 3*PedRMS
748// 2) Pixel has a fit error greater than 0.
749// 3) Pixel has a fitted charge greater its charge error
750// 4) Pixel has a fit Probability greater than 0.0001
751// 5) Pixel has a charge sigma bigger than its Pedestal RMS
752//
753Bool_t MCalibrationPix::CheckChargeValidity()
754{
755
756 if (!IsFitted())
757 return kFALSE;
758
759 if (IsExcludeQualityCheck())
760 return kTRUE;
761
762 Float_t pedestal;
763
764 if (!IsHiGainSaturation()) /* higain */
765 pedestal = GetPedRms()*TMath::Sqrt(fNumHiGainSamples);
766 else /* logain */
767 pedestal = GetPedRms()*TMath::Sqrt(fNumLoGainSamples);
768
769
770 if (fCharge < gkChargeLimit*pedestal)
771 {
772 *fLog << warn << "WARNING: Fitted Charge is smaller than "
773 << gkChargeLimit << " Pedestal RMS in Pixel " << fPixId << endl;
774 return kFALSE;
775 }
776
777 if (fErrCharge < gkChargeErrLimit)
778 {
779 *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
780 << gkChargeErrLimit << " in Pixel " << fPixId << endl;
781 return kFALSE;
782 }
783
784 if (fCharge < gkChargeRelErrLimit*fErrCharge)
785 {
786 *fLog << warn << "WARNING: Fitted Charge is smaller than "
787 << gkChargeRelErrLimit << "* its error in Pixel " << fPixId << endl;
788 return kFALSE;
789 }
790
791 if (!fHist->IsChargeFitOK())
792 {
793 *fLog << warn << "WARNING: Probability of Fitted Charge too low in Pixel "
794 << fPixId << endl;
795 return kFALSE;
796 }
797
798 if (fSigmaCharge < pedestal)
799 {
800 *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in Pixel "
801 << fPixId << endl;
802 return kFALSE;
803 }
804 return kTRUE;
805}
806
807//
808// The check return kTRUE if:
809//
810// 0) No value is nan
811// 1) Pixel has a fitted rel. time smaller than 3*FADC slices
812// 2) Pixel has a fit error greater than 0.
813// 4) Pixel has a fit Probability greater than 0.001
814// 5) The absolute arrival time is at least 1.0 slices from the used edge slices
815//
816Bool_t MCalibrationPix::CheckTimeFitValidity()
817{
818
819
820 if (IsExcludeQualityCheck())
821 return kTRUE;
822
823 if (IsHiGainSaturation())
824 {
825
826 if (fAbsTimeMean < (Float_t)fTimeFirstLoGain+1)
827 {
828 *fLog << warn
829 << "WARNING: Some absolute times smaller than limit in Pixel "
830 << fPixId << " time: " << fAbsTimeMean
831 << " Limit: " << (Float_t)fTimeFirstLoGain+1. << endl;
832 return kFALSE;
833 }
834
835 if (fAbsTimeMean > (Float_t)fTimeLastLoGain-1)
836 {
837 *fLog << warn
838 << "WARNING: Some absolute times bigger than limit in Pixel "
839 << fPixId << " time: " << fAbsTimeMean
840 << " Limit: " << (Float_t)fTimeLastLoGain-1. << endl;
841 return kFALSE;
842 }
843
844 }
845 else
846 {
847
848 if (fAbsTimeMean < (Float_t)fTimeFirstHiGain+1.)
849 {
850 *fLog << warn
851 << "WARNING: Some absolute times smaller than limit in Pixel "
852 << fPixId << " time: " << fAbsTimeMean
853 << " Limit: " << (Float_t)fTimeFirstHiGain+1. << endl;
854 // return kFALSE;
855 }
856
857 if (fAbsTimeMean > (Float_t)fTimeLastHiGain-1.)
858 {
859 *fLog << warn
860 << "WARNING: Some absolute times bigger than limit in Pixel "
861 << fPixId << " time: " << fAbsTimeMean
862 << " Limit: " << (Float_t)fTimeLastHiGain-1. << endl;
863 // return kFALSE;
864 }
865
866 }
867
868
869
870 return kTRUE;
871}
872
873
874void MCalibrationPix::CheckOscillations()
875{
876 fHist->CheckOscillations();
877}
878
879void MCalibrationPix::ApplyLoGainConversion()
880{
881
882 const Float_t chargeRelErrSquare = fErrCharge*fErrCharge
883 /( fCharge * fCharge);
884 const Float_t sigmaRelErrSquare = fErrSigmaCharge*fErrSigmaCharge
885 /( fSigmaCharge * fSigmaCharge);
886 const Float_t conversionRelErrSquare = fConversionHiLoError*fConversionHiLoError
887 /(fConversionHiLo * fConversionHiLo);
888
889 fCharge *= fConversionHiLo;
890 fErrCharge = TMath::Sqrt(chargeRelErrSquare + conversionRelErrSquare) * fCharge;
891
892 fSigmaCharge *= fConversionHiLo;
893 fErrSigmaCharge = TMath::Sqrt(sigmaRelErrSquare + conversionRelErrSquare) * fSigmaCharge;
894
895}
Note: See TracBrowser for help on using the repository browser.