Changeset 3455 for trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
- Timestamp:
- 03/10/04 16:50:25 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCam.cc
r3446 r3455 138 138 #include "MCalibrationChargePINDiode.h" 139 139 140 141 140 ClassImp(MCalibrationChargeCam); 142 141 143 142 using namespace std; 144 143 144 const Float_t MCalibrationChargeCam::gkAverageQE = 0.18; 145 const Float_t MCalibrationChargeCam::gkAverageQEErr = 0.02; 146 const Float_t MCalibrationChargeCam::fgConvFFactorRelErrLimit = 0.25; 145 147 // -------------------------------------------------------------------------- 146 148 // … … 171 173 172 174 Clear(); 175 176 SetAverageQE(); 177 SetConvFFactorRelErrLimit(); 173 178 } 174 179 … … 261 266 fAverageOuterBadPix->Clear(); 262 267 263 fNumExcludedPixels = 0; 268 fNumExcludedPixels = 0; 269 fMeanFluxPhesInnerPixel = 0.; 270 fMeanFluxPhesInnerPixelErr = 0.; 271 fMeanFluxPhesOuterPixel = 0.; 272 fMeanFluxPhesOuterPixelErr = 0.; 264 273 265 274 CLRBIT(fFlags,kBlindPixelMethodValid); 275 CLRBIT(fFlags,kFFactorMethodValid); 266 276 CLRBIT(fFlags,kPINDiodeMethodValid); 267 277 268 278 return; 279 } 280 281 void MCalibrationChargeCam::SetFFactorMethodValid(const Bool_t b) 282 { 283 b ? SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid); 269 284 } 270 285 … … 567 582 break; 568 583 case 9: 569 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsFFactorMethodValid()) 584 if ((*this)[idx].IsExcluded() 585 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 586 || !(*this)[idx].IsFFactorMethodValid()) 570 587 return kFALSE; 571 588 val = (*this)[idx].GetPheFFactorMethod(); 572 589 break; 573 590 case 10: 574 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsFFactorMethodValid()) 591 if ((*this)[idx].IsExcluded() 592 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 593 || !(*this)[idx].IsFFactorMethodValid()) 575 594 return kFALSE; 576 595 val = (*this)[idx].GetPheFFactorMethodErr(); 577 596 break; 578 597 case 11: 579 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsFFactorMethodValid()) 598 if ((*this)[idx].IsExcluded() 599 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 600 || !(*this)[idx].IsFFactorMethodValid()) 580 601 return kFALSE; 581 602 val = (*this)[idx].GetMeanConversionFFactorMethod(); 582 603 break; 583 604 case 12: 584 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsFFactorMethodValid()) 605 if ((*this)[idx].IsExcluded() 606 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 607 || !(*this)[idx].IsFFactorMethodValid()) 585 608 return kFALSE; 586 609 val = (*this)[idx].GetConversionFFactorMethodErr(); 587 610 break; 588 611 case 13: 589 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsFFactorMethodValid()) 612 if ((*this)[idx].IsExcluded() 613 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 614 || !(*this)[idx].IsFFactorMethodValid()) 590 615 return kFALSE; 591 616 val = (*this)[idx].GetTotalFFactorFFactorMethod(); 592 617 break; 593 618 case 14: 594 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsFFactorMethodValid()) 619 if ((*this)[idx].IsExcluded() 620 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 621 || !(*this)[idx].IsFFactorMethodValid()) 595 622 return kFALSE; 596 623 val = (*this)[idx].GetTotalFFactorErrFFactorMethod(); 597 624 break; 598 625 case 15: 599 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsBlindPixelMethodValid()) 626 if ((*this)[idx].IsExcluded() 627 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 628 || !(*this)[idx].IsBlindPixelMethodValid()) 600 629 return kFALSE; 601 630 val = fBlindPixel->GetMeanFluxInsidePlexiglass()*area; 602 631 break; 603 632 case 16: 604 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsBlindPixelMethodValid()) 633 if ((*this)[idx].IsExcluded() 634 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 635 || !(*this)[idx].IsBlindPixelMethodValid()) 605 636 return kFALSE; 606 637 val = fBlindPixel->GetMeanFluxErrInsidePlexiglass()*area; 607 638 break; 608 639 case 17: 609 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsBlindPixelMethodValid()) 640 if ((*this)[idx].IsExcluded() 641 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 642 || !(*this)[idx].IsBlindPixelMethodValid()) 610 643 return kFALSE; 611 644 val = (*this)[idx].GetMeanConversionBlindPixelMethod(); 612 645 break; 613 646 case 18: 614 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsBlindPixelMethodValid()) 647 if ((*this)[idx].IsExcluded() 648 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 649 || !(*this)[idx].IsBlindPixelMethodValid()) 615 650 return kFALSE; 616 651 val = (*this)[idx].GetConversionBlindPixelMethodErr(); 617 652 break; 618 653 case 19: 619 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsBlindPixelMethodValid()) 654 if ((*this)[idx].IsExcluded() 655 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 656 || !(*this)[idx].IsBlindPixelMethodValid()) 620 657 return kFALSE; 621 658 val = (*this)[idx].GetTotalFFactorBlindPixelMethod(); 622 659 break; 623 660 case 20: 624 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsBlindPixelMethodValid()) 661 if ((*this)[idx].IsExcluded() 662 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 663 || !(*this)[idx].IsBlindPixelMethodValid()) 625 664 return kFALSE; 626 665 val = (*this)[idx].GetTotalFFactorErrBlindPixelMethod(); 627 666 break; 628 667 case 21: 629 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsPINDiodeMethodValid()) 668 if ((*this)[idx].IsExcluded() 669 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 670 || !(*this)[idx].IsPINDiodeMethodValid()) 630 671 return kFALSE; 631 672 val = fPINDiode->GetMeanFluxOutsidePlexiglass()*area; 632 673 break; 633 674 case 22: 634 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsPINDiodeMethodValid()) 675 if ((*this)[idx].IsExcluded() 676 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 677 || !(*this)[idx].IsPINDiodeMethodValid()) 635 678 return kFALSE; 636 679 val = fPINDiode->GetMeanFluxErrOutsidePlexiglass()*area; 637 680 break; 638 681 case 23: 639 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsPINDiodeMethodValid()) 682 if ((*this)[idx].IsExcluded() 683 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 684 || !(*this)[idx].IsPINDiodeMethodValid()) 640 685 return kFALSE; 641 686 val = (*this)[idx].GetMeanConversionPINDiodeMethod(); 642 687 break; 643 688 case 24: 644 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsPINDiodeMethodValid()) 689 if ((*this)[idx].IsExcluded() 690 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 691 || !(*this)[idx].IsPINDiodeMethodValid()) 645 692 return kFALSE; 646 693 val = (*this)[idx].GetConversionPINDiodeMethodErr(); 647 694 break; 648 695 case 25: 649 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsPINDiodeMethodValid()) 696 if ((*this)[idx].IsExcluded() 697 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 698 || !(*this)[idx].IsPINDiodeMethodValid()) 650 699 return kFALSE; 651 700 val = (*this)[idx].GetTotalFFactorPINDiodeMethod(); 652 701 break; 653 702 case 26: 654 if ((*this)[idx].IsExcluded() || !(*fBadPixels)[idx].IsCalibrationSignalOK() || !(*this)[idx].IsPINDiodeMethodValid()) 703 if ((*this)[idx].IsExcluded() 704 || !(*fBadPixels)[idx].IsCalibrationSignalOK() 705 || !(*this)[idx].IsPINDiodeMethodValid()) 655 706 return kFALSE; 656 707 val = (*this)[idx].GetTotalFFactorErrPINDiodeMethod(); … … 782 833 (*this)[idx].DrawClone(); 783 834 } 835 836 // 837 // Calculate the weighted mean of the phe's of all inner and outer pixels, respectively. 838 // Bad pixels are excluded from the calculation. 839 // 840 Bool_t MCalibrationChargeCam::CalcMeanFluxPhotonsFFactorMethod() 841 { 842 843 const Float_t avQERelErrSquare = fAverageQEErr * fAverageQEErr 844 / (fAverageQE * fAverageQE ); 845 846 Float_t sumweightsinner = 0.; 847 Float_t sumphesinner = 0.; 848 Float_t sumweightsouter = 0.; 849 Float_t sumphesouter = 0.; 850 851 TIter Next(fPixels); 852 MCalibrationChargePix *pix; 853 while ((pix=(MCalibrationChargePix*)Next())) 854 { 855 856 if (!pix->IsFFactorMethodValid()) 857 continue; 858 859 const Int_t idx = pix->GetPixId(); 860 861 if(!(*fBadPixels)[idx].IsCalibrationResultOK()) 862 continue; 863 864 const Float_t nphe = pix->GetPheFFactorMethod(); 865 const Float_t npheerr = pix->GetPheFFactorMethodErr(); 866 const Float_t ratio = fGeomCam->GetPixRatio(idx); 867 868 if (npheerr > 0.) 869 { 870 // 871 // first the inner pixels: 872 // 873 if (ratio == 1.) 874 { 875 const Float_t weight = 1./npheerr/npheerr; 876 sumweightsinner += weight; 877 sumphesinner += weight*nphe; 878 } 879 else 880 { 881 // 882 // now the outers 883 // 884 const Float_t weight = 1./npheerr/npheerr; 885 sumweightsouter += weight; 886 sumphesouter += weight*nphe; 887 } 888 } /* if npheerr != 0 */ 889 } /* while ((pix=(MCalibrationChargePix*)Next())) */ 890 891 if (sumweightsinner <= 0. || sumphesinner <= 0.) 892 { 893 *fLog << warn << " Mean number of phe's from inner pixels cannot be calculated: " 894 << " Sum of weights: " << sumweightsinner 895 << " Sum of weighted phes: " << sumphesinner << endl; 896 return kFALSE; 897 } 898 else 899 { 900 fMeanFluxPhesInnerPixel = sumphesinner/sumweightsinner; 901 fMeanFluxPhesInnerPixelErr = TMath::Sqrt(1./sumweightsinner); 902 903 } 904 905 if (sumweightsouter <= 0. || sumphesouter <= 0.) 906 { 907 *fLog << warn << " Mean number of phe's from outer pixels cannot be calculated: " 908 << " Sum of weights or sum of weighted phes is 0. " << endl; 909 } 910 else 911 { 912 fMeanFluxPhesOuterPixel = sumphesouter/sumweightsouter; 913 fMeanFluxPhesOuterPixelErr = TMath::Sqrt(1./sumweightsouter); 914 } 915 916 917 const Float_t meanFluxPhotonsRelErrSquare = fMeanFluxPhesInnerPixelErr * fMeanFluxPhesInnerPixelErr 918 / (fMeanFluxPhesInnerPixel * fMeanFluxPhesInnerPixel); 919 920 fMeanFluxPhotonsInnerPixel = fMeanFluxPhesInnerPixel/fAverageQE; 921 fMeanFluxPhotonsInnerPixelErr = TMath::Sqrt(meanFluxPhotonsRelErrSquare + avQERelErrSquare) 922 * fMeanFluxPhotonsInnerPixel; 923 924 fMeanFluxPhotonsOuterPixel = 4.*fMeanFluxPhotonsInnerPixel; 925 fMeanFluxPhotonsOuterPixelErr = 4.*fMeanFluxPhotonsInnerPixelErr; 926 927 *fLog << inf << " Mean number of photo-electrons from inner pixels (F-Factor Method): " 928 << fMeanFluxPhesInnerPixel << " +- " << fMeanFluxPhesInnerPixelErr << endl; 929 930 *fLog << inf << " Mean number of photons from inner pixels (F-Factor Method): " 931 << fMeanFluxPhotonsInnerPixel << " +- " << fMeanFluxPhotonsInnerPixelErr << endl; 932 933 934 935 return kTRUE; 936 } 937 938 void MCalibrationChargeCam::ApplyFFactorCalibration() 939 { 940 941 const Float_t meanphotRelErrSquare = fMeanFluxPhotonsInnerPixelErr * fMeanFluxPhotonsInnerPixelErr 942 /( fMeanFluxPhotonsInnerPixel * fMeanFluxPhotonsInnerPixel ); 943 944 TIter Next(fPixels); 945 MCalibrationChargePix *pix; 946 while ((pix=(MCalibrationChargePix*)Next())) 947 { 948 949 if (!pix->IsFFactorMethodValid()) 950 continue; 951 952 const Int_t idx = pix->GetPixId(); 953 954 if(!(*fBadPixels)[idx].IsCalibrationResultOK()) 955 continue; 956 957 const Float_t ratio = fGeomCam->GetPixRatio(idx); 958 // 959 // Calculate the conversion factor between PHOTONS and FADC counts 960 // 961 // Nphot = Nphe / avQE 962 // conv = Nphot / FADC counts 963 // 964 Float_t conv; 965 966 if (ratio == 1.) 967 conv = fMeanFluxPhotonsInnerPixel / pix->GetMeanCharge(); 968 else 969 conv = fMeanFluxPhotonsOuterPixel / pix->GetMeanCharge(); 970 971 if (conv <= 0.) 972 { 973 pix->SetFFactorMethodValid(kFALSE); 974 continue; 975 } 976 977 const Float_t chargeRelErrSquare = pix->GetMeanChargeErr() * pix->GetMeanChargeErr() 978 / ( pix->GetMeanCharge() * pix->GetMeanCharge()); 979 const Float_t rsigmaChargeRelErrSquare = pix->GetRSigmaChargeErr() * pix->GetRSigmaChargeErr() 980 / (pix->GetRSigmaCharge() * pix->GetRSigmaCharge()) ; 981 982 const Float_t convrelerr = TMath::Sqrt(meanphotRelErrSquare + chargeRelErrSquare); 983 984 if (convrelerr > fConvFFactorRelErrLimit) 985 { 986 *fLog << warn << GetDescriptor() << ": Conversion Factor F-Factor Method Rel. Error: " 987 << convrelerr << " above limit of: " << fConvFFactorRelErrLimit 988 << " in pixel: " << idx << endl; 989 pix->SetFFactorMethodValid(kFALSE); 990 continue; 991 } 992 993 // 994 // Calculate the Total F-Factor of the camera (in photons) 995 // 996 const Float_t totalFFactor = (pix->GetRSigmaCharge()/pix->GetMeanCharge()) 997 *TMath::Sqrt(fMeanFluxPhotonsInnerPixel); 998 999 // 1000 // Calculate the error of the Total F-Factor of the camera ( in photons ) 1001 // 1002 const Float_t totalFFactorErr = TMath::Sqrt( rsigmaChargeRelErrSquare 1003 + chargeRelErrSquare 1004 + meanphotRelErrSquare ); 1005 1006 pix->SetConversionFFactorMethod(conv, 1007 convrelerr*conv, 1008 totalFFactor*TMath::Sqrt(conv)); 1009 1010 pix->SetTotalFFactorFFactorMethod( totalFFactor ); 1011 pix->SetTotalFFactorErrFFactorMethod(totalFFactorErr); 1012 pix->SetFFactorMethodValid(); 1013 } 1014 } 1015 1016 784 1017 785 1018 void MCalibrationChargeCam::ApplyBlindPixelCalibration()
Note:
See TracChangeset
for help on using the changeset viewer.