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

Last change on this file since 3056 was 3056, 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, kChargeFitValid);
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::SetChargeFitValid(Bool_t b )
261{
262 b ? SETBIT(fFlags, kChargeFitValid) : CLRBIT(fFlags, kChargeFitValid);
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 return (fRSigmaCharge/fCharge)*TMath::Sqrt(fPheFFactorMethod);
353}
354
355Float_t MCalibrationPix::GetTotalFFactorErrorFFactorMethod()
356{
357
358 if (!fFactorCalculated)
359 CalcFFactorMethod();
360
361 const Float_t rsigmaChargeRelErrSquare = fErrRSigmaCharge * fErrRSigmaCharge
362 / (fRSigmaCharge * fRSigmaCharge) ;
363 const Float_t rChargeRelErrSquare = fErrCharge * fErrCharge
364 / (fCharge * fCharge) ;
365 const Float_t rPheRelErrSquare = fPheFFactorMethodError * fPheFFactorMethodError
366 / (fPheFFactorMethod * fPheFFactorMethod) ;
367
368 return TMath::Sqrt(rsigmaChargeRelErrSquare+rChargeRelErrSquare+rPheRelErrSquare);
369}
370
371
372Float_t MCalibrationPix::GetTotalFFactorBlindPixelMethod()
373{
374 return 1.;
375}
376
377Float_t MCalibrationPix::GetTotalFFactorErrorBlindPixelMethod()
378{
379
380 return 1.;
381}
382
383Float_t MCalibrationPix::GetTotalFFactorPINDiodeMethod()
384{
385 return 1.;
386}
387
388Float_t MCalibrationPix::GetTotalFFactorErrorPINDiodeMethod()
389{
390
391 return 1.;
392}
393
394
395
396Float_t MCalibrationPix::GetMeanConversionFFactorMethod()
397{
398
399 if (!fFactorCalculated)
400 CalcFFactorMethod();
401
402 return fMeanConversionFFactorMethod;
403
404}
405
406Float_t MCalibrationPix::GetErrorConversionFFactorMethod()
407{
408
409 if (!fFactorCalculated)
410 CalcFFactorMethod();
411
412 return fErrorConversionFFactorMethod;
413
414}
415
416Float_t MCalibrationPix::GetSigmaConversionFFactorMethod()
417{
418
419 if (!fFactorCalculated)
420 CalcFFactorMethod();
421
422 return fSigmaConversionFFactorMethod;
423
424}
425
426
427Bool_t MCalibrationPix::IsExcluded() const
428 {
429 return TESTBIT(fFlags,kExcluded);
430 }
431
432Bool_t MCalibrationPix::IsExcludeQualityCheck() const
433 {
434 return TESTBIT(fFlags,kExcludeQualityCheck);
435 }
436
437Bool_t MCalibrationPix::IsHiGainSaturation() const
438 {
439 return TESTBIT(fFlags,kHiGainSaturation);
440 }
441
442Bool_t MCalibrationPix::IsChargeFitValid() const
443{
444 return TESTBIT(fFlags, kChargeFitValid);
445}
446
447Bool_t MCalibrationPix::IsFitted() const
448{
449 return TESTBIT(fFlags, kFitted);
450}
451
452Bool_t MCalibrationPix::IsOscillating()
453{
454
455 if (TESTBIT(fFlags, kOscillating))
456 return kTRUE;
457
458 if (fHist->CheckOscillations())
459 {
460 SETBIT(fFlags,kOscillating);
461 return kTRUE;
462 }
463
464 return kFALSE;
465}
466
467Bool_t MCalibrationPix::IsBlindPixelMethodValid() const
468{
469 return TESTBIT(fFlags, kBlindPixelMethodValid);
470}
471
472Bool_t MCalibrationPix::IsFFactorMethodValid()
473{
474
475 if (!fFactorCalculated)
476 CalcFFactorMethod();
477
478 return TESTBIT(fFlags, kFFactorMethodValid);
479}
480
481Bool_t MCalibrationPix::IsPINDiodeMethodValid() const
482{
483 return TESTBIT(fFlags, kPINDiodeMethodValid);
484}
485
486
487// --------------------------------------------------------------------------
488//
489// 1) Return if the charge distribution is already succesfully fitted
490// or if the histogram is empty
491// 2) Set a lower Fit range according to 1.5 Pedestal RMS in order to avoid
492// possible remaining cosmics to spoil the fit.
493// 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
494// 4) Fit the histograms with a Gaussian
495// 5) In case of failure set the bit kFitted to false
496// 6) Retrieve the results and store them in this class
497// 7) Calculate the number of photo-electrons after the F-Factor method
498// 8) Calculate the errors of the F-Factor method
499//
500// The fits are declared valid (fFitValid = kTRUE), if:
501//
502// 1) Pixel has a fitted charge greater than 3*PedRMS
503// 2) Pixel has a fit error greater than 0.
504// 3) Pixel has a fit Probability greater than 0.0001
505// 4) Pixel has a charge sigma bigger than its Pedestal RMS
506// 5) If FitTimes is used,
507// the mean arrival time is at least 1.0 slices from the used edge slices
508// (this stage is only performed in the times fit)
509//
510// If the histogram is empty, all values are set to -1.
511//
512// The conversion factor after the F-Factor method is declared valid, if:
513//
514// 1) fFitValid is kTRUE
515// 2) Conversion Factor is bigger than 0.
516// 3) The error of the conversion factor is smaller than 10%
517//
518Bool_t MCalibrationPix::FitCharge()
519{
520
521 //
522 // 1) Return if the charge distribution is already succesfully fitted
523 // or if the histogram is empty
524 //
525 if (fHist->IsChargeFitOK() || fHist->IsEmpty())
526 return kTRUE;
527
528 //
529 // 2) Set a lower Fit range according to 1.5 Pedestal RMS in order to avoid
530 // possible remaining cosmics to spoil the fit.
531 //
532 // if (fPed && fPedRms)
533 // fHist->SetLowerFitRange(1.5*fPedRms);
534 // else
535 // *fLog << warn << "WARNING: Cannot set lower fit range: Pedestals not available" << endl;
536
537 //
538 // 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram
539 //
540 if (fHist->UseLoGain())
541 SetHiGainSaturation();
542
543 //
544 // 4) Fit the Lo Gain histograms with a Gaussian
545 //
546 if (fHist->FitCharge())
547 SETBIT(fFlags,kFitted);
548 else
549 {
550 *fLog << warn << "WARNING: Could not fit charges of pixel " << fPixId << endl;
551 //
552 // 5) In case of failure set the bit kFitted to false
553 //
554 CLRBIT(fFlags,kFitted);
555 }
556
557 //
558 // 6) Retrieve the results and store them in this class
559 // If fFitted is false, we get the means and RMS of the histogram!!
560 //
561 fCharge = fHist->GetChargeMean();
562 fErrCharge = fHist->GetChargeMeanErr();
563 fSigmaCharge = fHist->GetChargeSigma();
564 fErrSigmaCharge = fHist->GetChargeSigmaErr();
565 fChargeProb = fHist->GetChargeProb();
566
567
568 fAbsTimeMean = fHist->GetAbsTimeMean();
569 fAbsTimeMeanErr = fHist->GetAbsTimeMeanErr();
570 fAbsTimeRms = fHist->GetAbsTimeRms();
571
572 if (CheckTimeFitValidity())
573 SETBIT(fFlags,kTimeFitValid);
574 else
575 CLRBIT(fFlags,kTimeFitValid);
576
577 //
578 // Calculate the conversion factors
579 //
580 if (IsHiGainSaturation())
581 ApplyLoGainConversion();
582
583 if (CheckChargeFitValidity())
584 SETBIT(fFlags,kChargeFitValid);
585 else
586 {
587 CLRBIT(fFlags,kChargeFitValid);
588 return kFALSE;
589 }
590
591 return kTRUE;
592
593}
594
595//
596// Calculate the number of photo-electrons after the F-Factor method
597// Calculate the errors of the F-Factor method
598//
599Bool_t MCalibrationPix::CalcFFactorMethod()
600{
601
602 if ( (fCharge == -1.)
603 || (fErrCharge < 0.)
604 || (fSigmaCharge < 0.)
605 || (fPedRms < 0.) )
606 {
607 *fLog << warn << GetDescriptor() << "Cannot calculate the FFactor Method! "
608 << "Some of the needed parameters are not available ";
609 CLRBIT(fFlags,kFFactorMethodValid);
610 return kFALSE;
611 }
612
613 //
614 // Square all variables in order to avoid applications of square root
615 //
616 // First the relative error squares
617 //
618 const Float_t chargeSquare = fCharge* fCharge;
619 const Float_t chargeSquareRelErrSquare = 4.*fErrCharge*fErrCharge / chargeSquare;
620
621 const Float_t ffactorsquare = gkFFactor * gkFFactor;
622 const Float_t ffactorsquareRelErrSquare = 4.*gkFFactorError * gkFFactorError / ffactorsquare;
623 //
624 // Now the absolute error squares
625 //
626 const Float_t sigmaSquare = fSigmaCharge*fSigmaCharge;
627 const Float_t sigmaSquareErrSquare = 4.*fErrSigmaCharge*fErrSigmaCharge * sigmaSquare;
628
629 Float_t pedRmsSquare = fPedRms* fPedRms;
630 Float_t pedRmsSquareErrSquare = 4.*fErrPedRms*fErrPedRms * pedRmsSquare;
631
632 if (!IsHiGainSaturation())
633 { /* HiGain */
634
635 pedRmsSquare *= fNumHiGainSamples;
636 pedRmsSquareErrSquare *= fNumHiGainSamples*fNumHiGainSamples;
637 }
638 else
639 { /* LoGain */
640
641 //
642 // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it
643 // from the HI GAIN (all calculation per slice up to now):
644 //
645 // We extract the pure NSB contribution:
646 //
647 const Float_t elecRmsSquare = gkElectronicPedRms *gkElectronicPedRms;
648 const Float_t elecRmsSquareErrSquare = 4.*gkErrElectronicPedRms*gkErrElectronicPedRms * elecRmsSquare;
649
650 Float_t nsbSquare = pedRmsSquare - elecRmsSquare;
651 Float_t nsbSquareRelErrSquare = (pedRmsSquareErrSquare + elecRmsSquareErrSquare)
652 / (nsbSquare * nsbSquare) ;
653
654 if (nsbSquare < 0.)
655 nsbSquare = 0.;
656
657 //
658 // Now, we divide the NSB by the conversion factor and
659 // add it quadratically to the electronic noise
660 //
661 const Float_t conversionSquare = fConversionHiLo *fConversionHiLo;
662 const Float_t conversionSquareRelErrSquare = 4.*fConversionHiLoError*fConversionHiLoError/conversionSquare;
663
664 const Float_t convertedNsbSquare = nsbSquare / conversionSquare;
665 const Float_t convertedNsbSquareErrSquare = (nsbSquareRelErrSquare + conversionSquareRelErrSquare)
666 * convertedNsbSquare * convertedNsbSquare;
667
668 pedRmsSquare = convertedNsbSquare + elecRmsSquare;
669 pedRmsSquareErrSquare = convertedNsbSquareErrSquare + elecRmsSquareErrSquare;
670
671 //
672 // Now, correct for the number of used FADC slices in the LoGain:
673 //
674 pedRmsSquare *= fNumLoGainSamples;
675 pedRmsSquareErrSquare *= fNumLoGainSamples*fNumLoGainSamples;
676 //
677 // Correct also for the conversion to Hi-Gain:
678 //
679 pedRmsSquare *= fConversionHiLo*fConversionHiLo;
680 pedRmsSquareErrSquare *= fConversionHiLo*fConversionHiLo*fConversionHiLo*fConversionHiLo;
681
682 } /* if (HiGainSaturation) */
683
684 //
685 // Calculate the reduced sigmas
686 //
687 const Float_t rsigmachargesquare = sigmaSquare - pedRmsSquare;
688 if (rsigmachargesquare <= 0.)
689 {
690 *fLog << warn
691 << "WARNING: Cannot apply F-Factor calibration: Reduced Sigma smaller than 0 in pixel "
692 << fPixId << endl;
693 CLRBIT(fFlags,kFFactorMethodValid);
694 fFactorCalculated = kTRUE;
695 return kFALSE;
696 }
697
698 const Float_t rSigmaSquareRelErrSquare = (sigmaSquareErrSquare + pedRmsSquareErrSquare)
699 / (rsigmachargesquare * rsigmachargesquare) ;
700
701 fRSigmaCharge = TMath::Sqrt(rsigmachargesquare);
702 fErrRSigmaCharge = TMath::Sqrt(sigmaSquareErrSquare + pedRmsSquareErrSquare);
703
704
705 //
706 // Calculate the number of phe's from the F-Factor method
707 // (independent on Hi Gain or Lo Gain)
708 //
709 fPheFFactorMethod = ffactorsquare * chargeSquare / rsigmachargesquare;
710
711 const Float_t pheFFactorRelErrSquare = ffactorsquareRelErrSquare
712 + chargeSquareRelErrSquare
713 + rSigmaSquareRelErrSquare ;
714
715 fPheFFactorMethodError = TMath::Sqrt(pheFFactorRelErrSquare) * fPheFFactorMethod;
716
717 const Float_t chargeRelErrSquare = fErrCharge*fErrCharge / (fCharge * fCharge);
718
719 fMeanConversionFFactorMethod = fPheFFactorMethod / fCharge ;
720 fErrorConversionFFactorMethod = ( pheFFactorRelErrSquare + chargeRelErrSquare )
721 * fMeanConversionFFactorMethod * fMeanConversionFFactorMethod;
722
723 const Float_t convrelerror = fErrorConversionFFactorMethod/fMeanConversionFFactorMethod;
724
725 if ( (fMeanConversionFFactorMethod > 0.) && (convrelerror < gkConvFFactorRelErrorLimit))
726 SETBIT(fFlags,kFFactorMethodValid);
727
728 fFactorCalculated = kTRUE;
729
730 fSigmaConversionFFactorMethod = GetTotalFFactorFFactorMethod()*TMath::Sqrt(fMeanConversionFFactorMethod);
731
732 return kTRUE;
733}
734
735
736//
737// The check returns kTRUE if:
738//
739// 0) Pixel has BIT fitted set:
740// This means:
741// a) No result is a nan
742// b) The NDF is not smaller than fNDFLimit (5)
743// c) The Probability is greater than gkProbLimit (default 0.001 == 99.9%)
744// 1) Pixel has a fitted charge greater than 3*PedRMS
745// 2) Pixel has a fit error greater than 0.
746// 3) Pixel has a fitted charge greater its charge error
747// 4) Pixel has a fit Probability greater than 0.0001
748// 5) Pixel has a charge sigma bigger than its Pedestal RMS
749//
750Bool_t MCalibrationPix::CheckChargeFitValidity()
751{
752
753 if (!IsFitted())
754 return kFALSE;
755
756 if (IsExcludeQualityCheck())
757 return kTRUE;
758
759 Float_t pedestal;
760
761 if (!IsHiGainSaturation()) /* higain */
762 pedestal = GetPedRms()*TMath::Sqrt(fNumHiGainSamples);
763 else /* logain */
764 pedestal = GetPedRms()*TMath::Sqrt(fNumLoGainSamples);
765
766
767 if (fCharge < gkChargeLimit*pedestal)
768 {
769 *fLog << warn << "WARNING: Fitted Charge is smaller than "
770 << gkChargeLimit << " Pedestal RMS in Pixel " << fPixId << endl;
771 return kFALSE;
772 }
773
774 if (fErrCharge < gkChargeErrLimit)
775 {
776 *fLog << warn << "WARNING: Error of Fitted Charge is smaller than "
777 << gkChargeErrLimit << " in Pixel " << fPixId << endl;
778 return kFALSE;
779 }
780
781 if (fCharge < gkChargeRelErrLimit*fErrCharge)
782 {
783 *fLog << warn << "WARNING: Fitted Charge is smaller than "
784 << gkChargeRelErrLimit << "* its error in Pixel " << fPixId << endl;
785 return kFALSE;
786 }
787
788 if (!fHist->IsChargeFitOK())
789 {
790 *fLog << warn << "WARNING: Probability of Fitted Charge too low in Pixel "
791 << fPixId << endl;
792 return kFALSE;
793 }
794
795 if (fSigmaCharge < pedestal)
796 {
797 *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in Pixel "
798 << fPixId << endl;
799 return kFALSE;
800 }
801 return kTRUE;
802}
803
804//
805// The check return kTRUE if:
806//
807// 0) No value is nan
808// 1) Pixel has a fitted rel. time smaller than 3*FADC slices
809// 2) Pixel has a fit error greater than 0.
810// 4) Pixel has a fit Probability greater than 0.001
811// 5) The absolute arrival time is at least 1.0 slices from the used edge slices
812//
813Bool_t MCalibrationPix::CheckTimeFitValidity()
814{
815
816
817 if (IsExcludeQualityCheck())
818 return kTRUE;
819
820 if (IsHiGainSaturation())
821 {
822
823 if (fAbsTimeMean < (Float_t)fTimeFirstLoGain+1)
824 {
825 *fLog << warn
826 << "WARNING: Some absolute times smaller than limit in Pixel "
827 << fPixId << " time: " << fAbsTimeMean
828 << " Limit: " << (Float_t)fTimeFirstLoGain+1. << endl;
829 return kFALSE;
830 }
831
832 if (fAbsTimeMean > (Float_t)fTimeLastLoGain-1)
833 {
834 *fLog << warn
835 << "WARNING: Some absolute times bigger than limit in Pixel "
836 << fPixId << " time: " << fAbsTimeMean
837 << " Limit: " << (Float_t)fTimeLastLoGain-1. << endl;
838 return kFALSE;
839 }
840
841 }
842 else
843 {
844
845 if (fAbsTimeMean < (Float_t)fTimeFirstHiGain+1.)
846 {
847 *fLog << warn
848 << "WARNING: Some absolute times smaller than limit in Pixel "
849 << fPixId << " time: " << fAbsTimeMean
850 << " Limit: " << (Float_t)fTimeFirstHiGain+1. << endl;
851 // return kFALSE;
852 }
853
854 if (fAbsTimeMean > (Float_t)fTimeLastHiGain-1.)
855 {
856 *fLog << warn
857 << "WARNING: Some absolute times bigger than limit in Pixel "
858 << fPixId << " time: " << fAbsTimeMean
859 << " Limit: " << (Float_t)fTimeLastHiGain-1. << endl;
860 // return kFALSE;
861 }
862
863 }
864
865
866
867 return kTRUE;
868}
869
870
871void MCalibrationPix::CheckOscillations()
872{
873 fHist->CheckOscillations();
874}
875
876void MCalibrationPix::ApplyLoGainConversion()
877{
878
879 const Float_t chargeRelErrSquare = fErrCharge*fErrCharge
880 /( fCharge * fCharge);
881 const Float_t sigmaRelErrSquare = fErrSigmaCharge*fErrSigmaCharge
882 /( fSigmaCharge * fSigmaCharge);
883 const Float_t conversionRelErrSquare = fConversionHiLoError*fConversionHiLoError
884 /(fConversionHiLo * fConversionHiLo);
885
886 fCharge *= fConversionHiLo;
887 fErrCharge = TMath::Sqrt(chargeRelErrSquare + conversionRelErrSquare) * fCharge;
888
889 fSigmaCharge *= fConversionHiLo;
890 fErrSigmaCharge = TMath::Sqrt(sigmaRelErrSquare + conversionRelErrSquare) * fSigmaCharge;
891
892}
893
Note: See TracBrowser for help on using the repository browser.