Changeset 14182
- Timestamp:
- 06/18/12 12:11:32 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/marsmacros/singlepe.C
r14181 r14182 736 736 const Double_t ampl = hSum1.GetBinContent(maxbin); 737 737 738 739 738 double fwhm2 = 0; 739 740 //Calculate full width half Maximum 740 741 for (int i=1; i<maxbin; i++) 741 742 if (hSum1.GetBinContent(maxbin-i)+hSum1.GetBinContent(maxbin+i)<ampl*2) … … 744 745 break; 745 746 } 746 747 747 if (fwhm2==0) 748 748 { … … 750 750 } 751 751 752 752 //Set fit parameters 753 753 Double_t par[5] = 754 754 { 755 755 ampl, hSum1.GetBinCenter(maxbin), fwhm2*1.4, 0.1, -10 756 756 }; 757 758 757 func2.SetParameters(par); 759 758 759 //calculate fit range 760 760 const double min = par[1]-fwhm2*1.4; 761 761 const double max = par[1]*5; 762 762 763 //Fit and draw spectrum 763 764 hSum1.Fit(&func2, "NOQS", "", min, max); 764 765 func2.DrawCopy("SAME"); 766 765 767 //-------------------END OF: fit sum spectrum----------------------------- 766 768 767 769 // Draw gain corrected sum specetrum 770 gROOT->SetSelectedPad(0); 768 771 TCanvas &c12 = d->AddTab("GainHist"); 769 772 gPad->SetLogy(); … … 771 774 const Double_t fMaxPos = hSum2.GetBinCenter(maxbin); 772 775 773 //------------------fit gausses to peaks ----------------------- 774 775 UInt_t nfunc = 5; 776 TF1 **gaus = new TF1*[nfunc]; 777 776 //--------fit gausses to peaks of gain corrected sum specetrum ----------- 777 UInt_t nfunc = 5; 778 779 // create array for gaus funtions to fit to peaks of spectrum 780 TF1 **gaus = new TF1*[nfunc]; 781 782 // create histo for height of Maximum amplitudes vs. pe 783 TH1D hMaxHeights("MaxHeights", "peak heights", 784 20, 0, 20); 785 786 // fit gauss functions to spectrum 778 787 for (UInt_t nr = 0; nr<nfunc; nr++) 779 788 { 780 char fname[20]; 781 sprintf(fname,"gaus%d",nr); 782 gaus[nr] = new TF1(fname,"gaus", fMaxPos*(nr+1)-0.6, fMaxPos*(nr+1)+0.6); 783 hSum2.Fit(gaus[nr], "N0QS", "", fMaxPos*(nr+1)-0.6, fMaxPos*(nr+1)+0.6); 789 char fname[20]; 790 sprintf(fname,"gaus%d",nr); 791 792 //create gauss functions 793 gaus[nr] = new TF1( fname,"gaus", 794 fMaxPos*(nr+1)-0.6, fMaxPos*(nr+1)+0.6); 795 //fit and draw gauss functions 796 hSum2.Fit( gaus[nr], "N0QS", "", 797 fMaxPos*(nr+1)-0.6, fMaxPos*(nr+1)+0.6); 784 798 gaus[nr]->DrawCopy("SAME"); 785 // delete gaus[nr]; 786 } 787 799 800 //fill histo for height of Maximum amplitudes vs. pe 801 hMaxHeights.SetBinContent(nr, gaus[nr]->GetParameter(0)); 802 delete gaus[nr]; 803 } 804 delete[] gaus; 788 805 789 806 //------------------fit gain corrected sum spectrum----------------------- … … 792 809 const Double_t binwidth2 = hSum2.GetBinWidth(maxbin); 793 810 const Double_t ampl2 = hSum2.GetBinContent(maxbin); 794 cout << "AMPL: " << ampl2 << endl; 795 811 812 //Calculate full width half Maximum 796 813 fwhm2 = 0; 797 814 for (int i=1; i<maxbin; i++) … … 801 818 break; 802 819 } 803 804 820 if (fwhm2==0) 805 821 { … … 807 823 } 808 824 809 825 //Set fit parameters 810 826 Double_t par2[5] = 811 827 { 812 828 ampl2, hSum2.GetBinCenter(maxbin2), fwhm2*1.4, 0.1, 0 813 829 }; 814 815 cout << "AMPL: " << ampl2 << endl;816 cout << "maxpos: " << hSum2.GetBinCenter(maxbin2) << endl;817 cout << "fwhm: " << fwhm2*1.4 << endl;818 830 819 831 func3.SetParameters(par2); … … 825 837 func3.DrawCopy("SAME"); 826 838 //-------------------END OF: fit sum spectrum----------------------------- 839 840 TCanvas &c15 = d->AddTab("PeakHeights"); 841 gPad->SetLogy(); 842 hMaxHeights.DrawCopy(); 827 843 828 844 TCanvas &c2 = d->AddTab("Result");
Note:
See TracChangeset
for help on using the changeset viewer.