Changeset 2922 for trunk/MagicSoft/Mars
- Timestamp:
- 01/26/04 20:26:36 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2921 r2922 45 45 fit 46 46 47 * mcalib/MHCalibrationPixel.[h,cc]: 48 * mcalib/MCalibrationPix.cc: 49 * mcalib/MCalibrationPINDiode.cc: 50 - combine FitChargeHiGain and FitChargeLoGain into one function 51 47 52 48 53 2004/01/26: Thomas Bretz -
trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.cc
r2839 r2922 81 81 Bool_t MCalibrationPINDiode::FitCharge() 82 82 { 83 if(!fHist->FitCharge HiGain())83 if(!fHist->FitCharge()) 84 84 return kFALSE; 85 85 -
trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc
r2904 r2922 356 356 // possible remaining cosmics to spoil the fit. 357 357 // 358 if (fPed && fPedRms) 359 fHist->SetLowerFitRange(1.5*fPedRms); 358 // if (fPed && fPedRms) 359 // fHist->SetLowerFitRange(1.5*fPedRms); 360 // else 361 // *fLog << warn << "WARNING: Cannot set lower fit range: Pedestals not available" << endl; 362 363 // 364 // 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram 365 // 366 if (fHist->UseLoGain()) 367 SetHiGainSaturation(); 368 369 // 370 // 4) Fit the Lo Gain histograms with a Gaussian 371 // 372 if(fHist->FitCharge()) 373 { 374 SETBIT(fFlags,kFitted); 375 } 360 376 else 361 *fLog << warn << "WARNING: Cannot set lower fit range: Pedestals not available" << endl; 362 363 // 364 // 3) Decide if the LoGain Histogram is fitted or the HiGain Histogram 365 // 366 if (fHist->UseLoGain()) 367 { 368 369 SetHiGainSaturation(); 370 371 // 372 // 4) Fit the Lo Gain histograms with a Gaussian 373 // 374 if(!fHist->FitChargeLoGain()) 375 { 376 *fLog << warn << "WARNING: Could not fit Lo Gain charges of pixel " << fPixId << endl; 377 // 378 // 5) In case of failure print out the fit results 379 // 380 // fHist->PrintChargeFitResult(); 381 CLRBIT(fFlags,kFitted); 382 } 383 else 384 SETBIT(fFlags,kFitted); 385 } 386 else 387 { 388 // 389 // 4) Fit the Hi Gain histograms with a Gaussian 390 // 391 if(!fHist->FitChargeHiGain()) 392 { 393 *fLog << warn << "WARNING: Could not fit Hi Gain charges of pixel " << fPixId << endl; 394 // 395 // 5) In case of failure print out the fit results 396 // 397 // fHist->PrintChargeFitResult(); 398 CLRBIT(fFlags,kFitted); 399 } 400 else 401 SETBIT(fFlags,kFitted); 402 } 403 377 { 378 *fLog << warn << "WARNING: Could not fit charges of pixel " << fPixId << endl; 379 // 380 // 5) In case of failure print out the fit results 381 // 382 // fHist->PrintChargeFitResult(); 383 CLRBIT(fFlags,kFitted); 384 } 404 385 405 386 // -
trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.cc
r2920 r2922 541 541 // The fit result is accepted under condition that: 542 542 // 1) the Probability is greater than gkProbLimit (default 0.001 == 99.7%) 543 // 2) at least 100 events are in the single Photo-electron peak543 // 2) at least 50 events are in the single Photo-electron peak 544 544 // 545 545 if (fProb < gkProbLimit) … … 551 551 } 552 552 553 if (fProb < 0.01)554 *fLog << warn << "WARNING: Fit Probability " << fProb << " is smaller than 1% " << endl;555 556 553 Float_t contSinglePhe = TMath::Exp(-1.0*fLambda)*fLambda*entries; 557 554 558 if (contSinglePhe < 100.)555 if (contSinglePhe < 50.) 559 556 { 560 557 *fLog << err << "ERROR: Statistics is too low: Only " << contSinglePhe -
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 -
trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.h
r2904 r2922 41 41 TPaveText *fFitLegend; 42 42 43 Axis_t fLowerFitRange;44 43 Axis_t fChargeFirstHiGain; 45 44 Axis_t fChargeLastHiGain; … … 95 94 void SetTimeFitRangesLoGain(Byte_t low, Byte_t up) { fTimeLowerFitRangeLoGain = low, 96 95 fTimeUpperFitRangeLoGain = up ; } 97 98 void SetLowerFitRange(Axis_t min) { fLowerFitRange = min; }99 96 100 97 // Getters … … 152 149 153 150 // Fits 154 Bool_t FitChargeHiGain(Option_t *option="RQ0"); 151 Bool_t FitCharge(Option_t *option="RQ0"); 152 155 153 Bool_t FitTimeHiGain(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0"); 156 157 Bool_t FitChargeLoGain(Option_t *option="RQ0");158 154 Bool_t FitTimeLoGain(Axis_t rmin=0, Axis_t rmax=0, Option_t *option="RQ0"); 159 155
Note:
See TracChangeset
for help on using the changeset viewer.