Changeset 3007 for trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc
- Timestamp:
- 02/02/04 22:52:53 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc
r2996 r3007 30 30 // (offset) value of one Pixel (PMT). // 31 31 // // 32 /////////////////////////////////////////////////////////////////////////////33 #include "MCalibrationPix.h"34 #include "MCalibrationConfig.h"35 36 #include "MLog.h"37 #include "MLogManip.h"38 39 ClassImp(MCalibrationPix);40 41 using namespace std;42 43 // --------------------------------------------------------------------------44 //45 // Default Constructor:46 //47 32 // The following values are initialized to meaningful values: 48 33 // … … 54 39 // Error F-Factor = 2.*0.02 = 0.04 55 40 // 41 ///////////////////////////////////////////////////////////////////////////// 42 #include "MCalibrationPix.h" 43 #include "MCalibrationConfig.h" 44 45 #include "MLog.h" 46 #include "MLogManip.h" 47 48 ClassImp(MCalibrationPix); 49 50 using namespace std; 51 52 const Float_t MCalibrationPix::gkElectronicPedRms = 1.5; 53 const Float_t MCalibrationPix::gkErrElectronicPedRms = 0.3; 54 const Float_t MCalibrationPix::gkFFactor = 1.32; 55 const Float_t MCalibrationPix::gkFFactorError = 0.04; 56 const Float_t MCalibrationPix::gkChargeLimit = 3.; 57 const Float_t MCalibrationPix::gkChargeErrLimit = 0.; 58 const Float_t MCalibrationPix::gkChargeRelErrLimit = 1.; 59 const Float_t MCalibrationPix::gkTimeLimit = 1.5; 60 const Float_t MCalibrationPix::gkTimeErrLimit = 3.; 61 62 // -------------------------------------------------------------------------- 63 // 64 // Default Constructor: 65 // 56 66 MCalibrationPix::MCalibrationPix(const char *name, const char *title) 57 67 : fPixId(-1), 58 fElectronicPedRms(1.5),59 fErrElectronicPedRms(0.3),60 fFactor(1.32),61 fFactorError(0.04),62 fChargeLimit(3.),63 fChargeErrLimit(0.),64 fChargeRelErrLimit(1.),65 68 fFlags(0) 66 69 { … … 101 104 CLRBIT(fFlags, kHiGainSaturation); 102 105 CLRBIT(fFlags, kExcluded); 103 CLRBIT(fFlags, kFitValid); 106 CLRBIT(fFlags, kChargeFitValid); 107 CLRBIT(fFlags, kTimeFitValid); 104 108 CLRBIT(fFlags, kFitted); 105 109 CLRBIT(fFlags, kBlindPixelMethodValid); … … 117 121 fErrPedRms = 0.; 118 122 fTime = -1.; 123 fErrTime = -1.; 119 124 fSigmaTime = -1.; 120 fTimeChiSquare = -1.; 125 fTimeProb = -1.; 126 fTimeFirstHiGain = 0 ; 127 fTimeLastHiGain = 0 ; 128 fTimeFirstLoGain = 0 ; 129 fTimeLastLoGain = 0 ; 130 121 131 fPheFFactorMethod = -1.; 122 132 fPheFFactorMethodError = -1.; … … 231 241 // Set the Excluded Bit from outside 232 242 // 233 void MCalibrationPix::SetFitValid(Bool_t b ) 234 { 235 b ? SETBIT(fFlags, kFitValid) : CLRBIT(fFlags, kFitValid); 243 void MCalibrationPix::SetChargeFitValid(Bool_t b ) 244 { 245 b ? SETBIT(fFlags, kChargeFitValid) : CLRBIT(fFlags, kChargeFitValid); 246 } 247 248 // -------------------------------------------------------------------------- 249 // 250 // Set the Excluded Bit from outside 251 // 252 void MCalibrationPix::SetTimeFitValid(Bool_t b ) 253 { 254 b ? SETBIT(fFlags, kTimeFitValid) : CLRBIT(fFlags, kTimeFitValid); 236 255 } 237 256 … … 271 290 b ? SETBIT(fFlags, kPINDiodeMethodValid) : CLRBIT(fFlags, kPINDiodeMethodValid); 272 291 } 292 293 void MCalibrationPix::SetAbsTimeBordersHiGain(Byte_t f, Byte_t l) 294 { 295 296 fTimeFirstHiGain = f; 297 fTimeLastHiGain = l; 298 299 } 300 301 void MCalibrationPix::SetAbsTimeBordersLoGain(Byte_t f, Byte_t l) 302 { 303 304 fTimeFirstLoGain = f; 305 fTimeLastLoGain = l; 306 307 } 308 273 309 274 310 … … 278 314 } 279 315 280 Bool_t MCalibrationPix::IsFitValid() const 281 { 282 return TESTBIT(fFlags, kFitValid); 316 Bool_t MCalibrationPix::IsChargeFitValid() const 317 { 318 return TESTBIT(fFlags, kChargeFitValid); 319 } 320 321 Bool_t MCalibrationPix::IsTimeFitValid() const 322 { 323 return TESTBIT(fFlags, kTimeFitValid); 283 324 } 284 325 … … 342 383 // or if the histogram is empty 343 384 // 344 if (fHist->Is FitOK() || fHist->IsEmpty())385 if (fHist->IsChargeFitOK() || fHist->IsEmpty()) 345 386 return kTRUE; 346 387 … … 386 427 387 428 if (CheckChargeFitValidity()) 388 SETBIT(fFlags,k FitValid);429 SETBIT(fFlags,kChargeFitValid); 389 430 else 390 431 { 391 CLRBIT(fFlags,k FitValid);432 CLRBIT(fFlags,kChargeFitValid); 392 433 return kFALSE; 393 434 } … … 408 449 const Float_t chargeSquareRelErrSquare = 4.*fErrCharge*fErrCharge / chargeSquare; 409 450 410 const Float_t fFactorRelErrSquare = fFactorError * fFactorError / (fFactor * fFactor);451 const Float_t fFactorRelErrSquare = gkFFactorError * gkFFactorError / (gkFFactor * gkFFactor); 411 452 // 412 453 // Now the absolute error squares … … 415 456 const Float_t sigmaSquareErrSquare = 4.*fErrSigmaCharge*fErrSigmaCharge * sigmaSquare; 416 457 417 const Float_t elecRmsSquare = fElectronicPedRms* fElectronicPedRms;418 const Float_t elecRmsSquareErrSquare = 4.* fErrElectronicPedRms*fErrElectronicPedRms * elecRmsSquare;458 const Float_t elecRmsSquare = gkElectronicPedRms* gkElectronicPedRms; 459 const Float_t elecRmsSquareErrSquare = 4.*gkErrElectronicPedRms*gkErrElectronicPedRms * elecRmsSquare; 419 460 420 461 Float_t pedRmsSquare = fPedRms* fPedRms; … … 477 518 // (independent on Hi Gain or Lo Gain) 478 519 // 479 fPheFFactorMethod = fFactor * chargeSquare / fRSigmaSquare;520 fPheFFactorMethod = gkFFactor * chargeSquare / fRSigmaSquare; 480 521 481 522 const Float_t pheFFactorRelErrSquare = fFactorRelErrSquare … … 497 538 * fConversionFFactorMethod * fConversionFFactorMethod; 498 539 499 if ( Is FitValid()&&540 if ( IsChargeFitValid() && 500 541 (fConversionFFactorMethod > 0.) && 501 542 (fConversionErrorFFactorMethod/fConversionFFactorMethod < 0.1) ) … … 525 566 if (TMath::IsNaN(fCharge) 526 567 || TMath::IsNaN(fErrCharge) 527 || TMath::IsNaN(fErrCharge)528 568 || TMath::IsNaN(fSigmaCharge) 529 569 || TMath::IsNaN(fErrSigmaCharge) … … 543 583 equivpedestal /= fConversionHiLo; 544 584 545 if (fCharge < fChargeLimit*equivpedestal)585 if (fCharge < gkChargeLimit*equivpedestal) 546 586 { 547 587 *fLog << warn << "WARNING: Fitted Charge is smaller than " 548 << fChargeLimit << " Pedestal RMS in Pixel " << fPixId << endl;549 return kFALSE; 550 } 551 552 if (fErrCharge < fChargeErrLimit)588 << gkChargeLimit << " Pedestal RMS in Pixel " << fPixId << endl; 589 return kFALSE; 590 } 591 592 if (fErrCharge < gkChargeErrLimit) 553 593 { 554 594 *fLog << warn << "WARNING: Error of Fitted Charge is smaller than " 555 << fChargeErrLimit << " in Pixel " << fPixId << endl;556 return kFALSE; 557 } 558 559 if (fCharge < fChargeRelErrLimit*fErrCharge)595 << gkChargeErrLimit << " in Pixel " << fPixId << endl; 596 return kFALSE; 597 } 598 599 if (fCharge < gkChargeRelErrLimit*fErrCharge) 560 600 { 561 601 *fLog << warn << "WARNING: Fitted Charge is smaller than " 562 << fChargeRelErrLimit << "* its error in Pixel " << fPixId << endl; 563 return kFALSE; 564 } 565 566 if (!fHist->IsFitOK()) 567 { 568 *fLog << warn << "WARNING: Probability of Fitted Charge too low in Pixel " << fPixId << endl; 602 << gkChargeRelErrLimit << "* its error in Pixel " << fPixId << endl; 603 return kFALSE; 604 } 605 606 if (!fHist->IsChargeFitOK()) 607 { 608 *fLog << warn << "WARNING: Probability of Fitted Charge too low in Pixel " 609 << fPixId << endl; 569 610 return kFALSE; 570 611 } … … 572 613 if (fSigmaCharge < equivpedestal) 573 614 { 574 *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in Pixel " << fPixId << endl; 615 *fLog << warn << "WARNING: Sigma of Fitted Charge smaller than Pedestal RMS in Pixel " 616 << fPixId << endl; 575 617 return kFALSE; 576 618 } … … 579 621 580 622 // 581 // The check returns kTRUE if: 582 // 583 // The mean arrival time is at least 1.0 slices from the used edge slices 623 // The check return kTRUE if: 624 // 625 // 0) No value is nan 626 // 1) Pixel has a fitted rel. time smaller than 3*FADC slices 627 // 2) Pixel has a fit error greater than 0. 628 // 4) Pixel has a fit Probability greater than 0.001 629 // 5) The absolute arrival time is at least 1.0 slices from the used edge slices 584 630 // 585 631 Bool_t MCalibrationPix::CheckTimeFitValidity() 586 632 { 587 633 634 if (TMath::IsNaN(fTime) 635 || TMath::IsNaN(fErrTime) 636 || TMath::IsNaN(fSigmaTime) 637 || TMath::IsNaN(fTimeProb)) 638 { 639 *fLog << warn << "WARNING: Some of the time fit values are NAN in Pixel " 640 << fPixId << endl; 641 return kFALSE; 642 } 643 588 644 if (TESTBIT(fFlags,kExcludeQualityCheck)) 589 645 return kTRUE; 590 646 591 Float_t lowerrange; 592 Float_t upperrange; 647 if (TMath::Abs(fTime) > gkTimeLimit) 648 { 649 *fLog << warn << "WARNING: Abs(Fitted Rel. Time) is greater than " 650 << gkTimeLimit << " in Pixel " << fPixId << endl; 651 return kFALSE; 652 } 653 654 if (fErrTime > gkTimeErrLimit) 655 { 656 *fLog << warn << "WARNING: Error of Fitted Time is smaller than " 657 << gkTimeErrLimit << " in Pixel " << fPixId << endl; 658 return kFALSE; 659 } 660 661 if (!fHist->IsTimeFitOK()) 662 { 663 *fLog << warn << "WARNING: Probability of Fitted Time too low in Pixel " 664 << fPixId << endl; 665 return kFALSE; 666 } 667 668 Float_t first; 669 Float_t last; 593 670 594 671 if (TESTBIT(fFlags,kHiGainSaturation)) 595 672 { 596 lowerrange = (Float_t)fHist->GetTimeLowerFitRangeLoGain()+1.; 597 upperrange = (Float_t)fHist->GetTimeUpperFitRangeLoGain()+1.; 673 first = (Float_t)fHist->GetAbsTimeFirstLoGain(); 674 last = (Float_t)fHist->GetAbsTimeLastLoGain(); 675 676 if (first < (Float_t)fTimeFirstLoGain+1) 677 { 678 *fLog << warn 679 << "WARNING: Some absolute times smaller than limit in Pixel " 680 << fPixId << " time: " << first << " Limit: " << fTimeFirstLoGain+1 << endl; 681 return kFALSE; 682 } 683 684 if ((Float_t)fTimeLastLoGain-1 > last) 685 { 686 *fLog << warn 687 << "WARNING: Some absolute times bigger than limit in Pixel " 688 << fPixId << " time: " << last << " Limit: " << fTimeLastLoGain-1 << endl; 689 return kFALSE; 690 } 691 598 692 } 599 693 else 600 694 { 601 lowerrange = (Float_t)fHist->GetTimeLowerFitRangeHiGain()+1.; 602 upperrange = (Float_t)fHist->GetTimeUpperFitRangeHiGain()+1.; 603 } 604 605 606 if (fTime < lowerrange) 607 { 608 *fLog << warn 609 << "WARNING: Mean Fitted Time inside or smaller than first used FADC slice in Pixel " 610 << fPixId << " time: " << fTime << " Range: " << lowerrange << endl; 611 return kFALSE; 612 } 613 614 if (fTime > upperrange) 615 { 616 *fLog << warn 617 << "WARNING: Mean Fitted Time inside or greater than last used FADC slice in Pixel " 618 << fPixId << " time: " << fTime << " Range: " << upperrange << endl; 619 return kFALSE; 620 } 695 first = (Float_t)fHist->GetAbsTimeFirstHiGain(); 696 last = (Float_t)fHist->GetAbsTimeLastHiGain(); 697 698 if (first > ((Float_t)fTimeFirstHiGain+1.)) 699 { 700 *fLog << warn 701 << "WARNING: Some absolute times smaller than limit in Pixel " 702 << fPixId << " time: " << first << " Limit: " << (Float_t)fTimeFirstHiGain+1. << endl; 703 // return kFALSE; 704 } 705 706 if (((Float_t)fTimeLastHiGain-1.) > last) 707 { 708 *fLog << warn 709 << "WARNING: Some absolute times bigger than limit in Pixel " 710 << fPixId << " time: " << last << " Limit: " << (Float_t)fTimeLastHiGain-1. << endl; 711 // return kFALSE; 712 } 713 714 } 715 716 621 717 622 718 return kTRUE; … … 662 758 // 1) Fit the arrival times 663 759 // 2) Retrieve the results 664 // 3) Note that because of the low number of bins, the NDf is sometimes 0, so665 // Root does not give a reasonable Probability, the Chisquare is more significant666 760 // 667 761 // This fit has to be done AFTER the Charges fit, … … 672 766 { 673 767 674 // 675 // Fit the Low Gain 676 // 677 if (TESTBIT(fFlags,kHiGainSaturation)) 678 { 679 if(!fHist->FitTimeLoGain()) 680 { 681 *fLog << warn << "WARNING: Could not fit Lo Gain times of pixel " << fPixId << endl; 682 // fHist->PrintTimeFitResult(); 683 return kFALSE; 684 } 685 } 686 687 // 688 // Fit the High Gain 689 // 768 if(!fHist->FitTime()) 769 { 770 *fLog << warn << "WARNING: Could not fit relative times of pixel " << fPixId << endl; 771 return kFALSE; 772 } 773 774 fTime = fHist->GetRelTimeMean(); 775 fErrTime = fHist->GetRelTimeMeanErr(); 776 fSigmaTime = fHist->GetRelTimeSigma(); 777 fTimeProb = fHist->GetRelTimeProb(); 778 779 if (CheckTimeFitValidity()) 780 SETBIT(fFlags,kTimeFitValid); 690 781 else 691 { 692 if(!fHist->FitTimeHiGain()) 693 { 694 *fLog << warn << "WARNING: Could not fit Hi Gain times of pixel " << fPixId << endl; 695 // fHist->PrintTimeFitResult(); 696 return kFALSE; 697 } 698 } 699 700 fTime = fHist->GetTimeMean(); 701 fSigmaTime = fHist->GetTimeSigma(); 702 fTimeChiSquare = fHist->GetTimeChiSquare(); 703 fTimeProb = fHist->GetTimeProb(); 704 705 if (CheckTimeFitValidity()) 706 SETBIT(fFlags,kFitValid); 707 else 708 CLRBIT(fFlags,kFitValid); 782 CLRBIT(fFlags,kTimeFitValid); 709 783 710 784 return kTRUE;
Note:
See TracChangeset
for help on using the changeset viewer.