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

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