Changeset 2922 for trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc
- Timestamp:
- 01/26/04 20:26:36 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc
r2904 r2922 67 67 fHivsLoGain(NULL), 68 68 fFitLegend(NULL), 69 fLowerFitRange(-100.),70 69 fChargeFirstHiGain(-100.5), 71 70 fChargeLastHiGain(1999.5), … … 112 111 Axis_t tfirst = -0.5; 113 112 Axis_t tlast = 15.5; 114 Int_t ntbins = 16;113 Int_t ntbins = 32; 115 114 116 115 fHTimeHiGain = new TH1F("HTimeHiGain","Distribution of Mean Arrival Hi Gain Times Pixel ", … … 695 694 fTimeSigma = fTimeGausFit->GetParameter(2); 696 695 697 if (fTimeChisquare > 20.) // Cannot use Probability because Ndf is sometimes < 1 696 if (TMath::IsNaN(fTimeMean) || TMath::IsNaN(fTimeSigma)) 697 return kFALSE; 698 699 if (TMath::IsNaN(fTimeChisquare) || fTimeChisquare > 20.) // Cannot use Probability because Ndf is sometimes < 1 698 700 return kFALSE; 699 701 … … 758 760 } 759 761 760 Bool_t MHCalibrationPixel::FitCharge HiGain(Option_t *option)762 Bool_t MHCalibrationPixel::FitCharge(Option_t *option) 761 763 { 762 764 … … 767 769 // Get the fitting ranges 768 770 // 769 Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirstHiGain; 770 Axis_t rmax = 0.; 771 Axis_t rmin = fChargeFirstHiGain; 772 if (TESTBIT(fFlags,kUseLoGain)) 773 rmin = fChargeFirstLoGain; 774 775 Axis_t rmax = fChargeLastHiGain; 776 if (TESTBIT(fFlags,kUseLoGain)) 777 rmin = fChargeFirstLoGain; 778 779 TH1F *hist = fHChargeHiGain; 780 if (TESTBIT(fFlags,kUseLoGain)) 781 hist = fHChargeLoGain; 771 782 772 783 // … … 774 785 // otherwise the fit goes gaga because of high number of dimensions ... 775 786 // 776 const Stat_t entries = fHChargeHiGain->Integral();777 const Double_t area_guess = entries/gkSq2Pi;778 const Double_t mu_guess = fHChargeHiGain->GetBinCenter(fHChargeHiGain->GetMaximumBin());787 const Stat_t entries = hist->Integral(); 788 const Double_t area_guess = entries/gkSq2Pi; 789 const Double_t mu_guess = hist->GetBinCenter(hist->GetMaximumBin()); 779 790 const Double_t sigma_guess = mu_guess/15.; 780 791 … … 782 793 name += fPixId; 783 794 784 fChargeGausFit = new TF1(name.Data(),"gaus",rmin, fChargeLastHiGain);795 fChargeGausFit = new TF1(name.Data(),"gaus",rmin,rmax); 785 796 786 797 if (!fChargeGausFit) … … 793 804 fChargeGausFit->SetParNames("Area","#mu","#sigma"); 794 805 fChargeGausFit->SetParLimits(0,0.,entries); 795 fChargeGausFit->SetParLimits(1,rmin,fChargeLastHiGain); 796 fChargeGausFit->SetParLimits(2,0.,fChargeLastHiGain-rmin); 797 fChargeGausFit->SetRange(rmin,fChargeLastHiGain); 798 799 fHChargeHiGain->Fit(fChargeGausFit,option); 800 801 Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.0*fChargeGausFit->GetParameter(2); 802 803 rmin = (rtry < rmin ? rmin : rtry); 804 rmax = fChargeGausFit->GetParameter(1) + 3.5*fChargeGausFit->GetParameter(2); 805 fChargeGausFit->SetRange(rmin,rmax); 806 807 fHChargeHiGain->Fit(fChargeGausFit,option); 808 806 fChargeGausFit->SetParLimits(1,rmin,rmax); 807 fChargeGausFit->SetParLimits(2,0.,rmax-rmin); 808 fChargeGausFit->SetRange(rmin,rmax); 809 810 hist->Fit(fChargeGausFit,option); 811 812 // 813 // If we are not able to fit, try once again 814 // 815 if (fChargeGausFit->GetProb() < gkProbLimit) 816 { 817 818 Axis_t rtry = fChargeGausFit->GetParameter(1) - 3.0*fChargeGausFit->GetParameter(2); 819 rmin = (rtry < rmin ? rmin : rtry); 820 rmax = fChargeGausFit->GetParameter(1) + 3.0*fChargeGausFit->GetParameter(2); 821 fChargeGausFit->SetRange(rmin,rmax); 822 823 fHChargeHiGain->Fit(fChargeGausFit,option); 824 } 825 809 826 fChargeChisquare = fChargeGausFit->GetChisquare(); 810 827 fChargeNdf = fChargeGausFit->GetNDF(); … … 816 833 817 834 // 818 // The fit result is accepted under condition 835 // The fit result is accepted under condition: 836 // The Results are not nan's 819 837 // The Probability is greater than gkProbLimit (default 0.001 == 99.9%) 820 838 // 821 if (fChargeProb < gkProbLimit) 822 { 823 // *fLog << warn << "WARNING: Fit Probability " << fChargeProb 824 // << " is smaller than the allowed value: " << gkProbLimit << endl; 839 if (TMath::IsNaN(fChargeMean) || TMath::IsNaN(fChargeMeanErr)) 840 { 825 841 CLRBIT(fFlags,kFitOK); 826 842 return kFALSE; 827 843 } 828 844 845 if ((fChargeProb < gkProbLimit) || (TMath::IsNaN(fChargeProb))) 846 { 847 CLRBIT(fFlags,kFitOK); 848 return kFALSE; 849 } 850 829 851 SETBIT(fFlags,kFitOK); 830 852 return kTRUE; … … 832 854 833 855 834 Bool_t MHCalibrationPixel::FitChargeLoGain(Option_t *option)835 {836 837 if (fChargeGausFit)838 return kFALSE;839 840 //841 // Get the fitting ranges842 //843 Axis_t rmin = (fLowerFitRange != 0.) ? fLowerFitRange : fChargeFirstLoGain;844 Axis_t rmax = 0.;845 846 //847 // First guesses for the fit (should be as close to reality as possible,848 // otherwise the fit goes gaga because of high number of dimensions ...849 //850 const Stat_t entries = fHChargeLoGain->Integral();851 const Double_t area_guess = entries/gkSq2Pi;852 const Double_t mu_guess = fHChargeLoGain->GetBinCenter(fHChargeLoGain->GetMaximumBin());853 const Double_t sigma_guess = mu_guess/15.;854 855 TString name = TString("ChargeGausFit");856 name += fPixId;857 858 fChargeGausFit = new TF1(name.Data(),"gaus",rmin,fChargeLastLoGain);859 860 if (!fChargeGausFit)861 {862 *fLog << warn << dbginf << "WARNING: Could not create fit function for Charges fit" << endl;863 return kFALSE;864 }865 866 fChargeGausFit->SetParameters(area_guess,mu_guess,sigma_guess);867 fChargeGausFit->SetParNames("Area","#mu","#sigma");868 fChargeGausFit->SetParLimits(0,0.,entries);869 fChargeGausFit->SetParLimits(1,rmin,fChargeLastLoGain);870 fChargeGausFit->SetParLimits(2,0.,fChargeLastLoGain-rmin);871 fChargeGausFit->SetRange(rmin,fChargeLastLoGain);872 873 fHChargeLoGain->Fit(fChargeGausFit,option);874 875 Axis_t rtry = fChargeGausFit->GetParameter(1) - 2.*fChargeGausFit->GetParameter(2);876 877 rmin = (rtry < rmin ? rmin : rtry);878 rmax = fChargeGausFit->GetParameter(1) + 3.5*fChargeGausFit->GetParameter(2);879 fChargeGausFit->SetRange(rmin,rmax);880 881 fHChargeLoGain->Fit(fChargeGausFit,option);882 883 // rmin = fChargeGausFit->GetParameter(1) - 2.5*fChargeGausFit->GetParameter(2);884 // rmax = fChargeGausFit->GetParameter(1) + 2.5*fChargeGausFit->GetParameter(2);885 // fChargeGausFit->SetRange(rmin,rmax);886 887 // fHChargeLoGain->Fit(fChargeGausFit,option);888 889 fChargeChisquare = fChargeGausFit->GetChisquare();890 fChargeNdf = fChargeGausFit->GetNDF();891 fChargeProb = fChargeGausFit->GetProb();892 fChargeMean = fChargeGausFit->GetParameter(1);893 fChargeMeanErr = fChargeGausFit->GetParError(1);894 fChargeSigma = fChargeGausFit->GetParameter(2);895 fChargeSigmaErr = fChargeGausFit->GetParError(2);896 897 //898 // The fit result is accepted under condition899 // The Probability is greater than gkProbLimit (default 0.01 == 99%)900 //901 if (fChargeProb < gkProbLimit)902 {903 // *fLog << warn << "WARNING: Fit Probability " << fChargeProb904 // << " is smaller than the allowed value: " << gkProbLimit << endl;905 CLRBIT(fFlags,kFitOK);906 return kFALSE;907 }908 909 SETBIT(fFlags,kFitOK);910 911 return kTRUE;912 }913 856 914 857
Note:
See TracChangeset
for help on using the changeset viewer.