Changeset 14181
- Timestamp:
- 06/15/12 14:59:24 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/marsmacros/singlepe.C
r14176 r14181 593 593 func.SetLineColor(kBlue); 594 594 595 // define fit function for Amplitudespectrum 596 TF1 func2("sum_spektrum", fcn, 0, 2000, 5); 597 func2.SetParNames("Maximum", "Gain", "Sigma", "XtalkProb", "Offset"); 598 func2.SetLineColor(kBlue); 599 600 // define fit function for Amplitudespectrum 601 TF1 func3("gain_sum_spektrum", fcn, 0, 10, 5); 602 func3.SetParNames("Maximum", "Gain", "Sigma", "XtalkProb", "Offset"); 603 func3.SetLineColor(kBlue); 604 605 606 595 607 // Map for which pixel shall be plotted and which not 596 608 TArrayC usePixel(1440); … … 695 707 hist->SetName(Form("Pix%d", pixel)); 696 708 hist->DrawCopy()->SetDirectory(0); 697 //func.DrawCopy("same"); 698 } 709 func.DrawCopy("SAME"); 710 } 711 712 699 713 700 714 count_ok++; … … 702 716 delete hist; 703 717 } 718 719 //------------------fill histograms----------------------- 704 720 705 721 hcam.SetUsed(usePixel); … … 710 726 hcam.DrawCopy(); 711 727 728 gROOT->SetSelectedPad(0); 712 729 TCanvas &c11 = d->AddTab("SumHist"); 713 730 gPad->SetLogy(); 714 731 hSum1.DrawCopy(); 715 732 733 //------------------------fit sum spectrum------------------------------- 734 const Int_t maxbin = hSum1.GetMaximumBin(); 735 const Double_t binwidth = hSum1.GetBinWidth(maxbin); 736 const Double_t ampl = hSum1.GetBinContent(maxbin); 737 738 739 double fwhm2 = 0; 740 for (int i=1; i<maxbin; i++) 741 if (hSum1.GetBinContent(maxbin-i)+hSum1.GetBinContent(maxbin+i)<ampl*2) 742 { 743 fwhm2 = (2*i+1)*binwidth; 744 break; 745 } 746 747 if (fwhm2==0) 748 { 749 cout << "Could not determine start value for sigma." << endl; 750 } 751 752 753 Double_t par[5] = 754 { 755 ampl, hSum1.GetBinCenter(maxbin), fwhm2*1.4, 0.1, -10 756 }; 757 758 func2.SetParameters(par); 759 760 const double min = par[1]-fwhm2*1.4; 761 const double max = par[1]*5; 762 763 hSum1.Fit(&func2, "NOQS", "", min, max); 764 func2.DrawCopy("SAME"); 765 //-------------------END OF: fit sum spectrum----------------------------- 766 767 716 768 TCanvas &c12 = d->AddTab("GainHist"); 717 769 gPad->SetLogy(); 718 770 hSum2.DrawCopy(); 771 const Double_t fMaxPos = hSum2.GetBinCenter(maxbin); 772 773 //------------------fit gausses to peaks ----------------------- 774 775 UInt_t nfunc = 5; 776 TF1 **gaus = new TF1*[nfunc]; 777 778 for (UInt_t nr = 0; nr<nfunc; nr++) 779 { 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); 784 gaus[nr]->DrawCopy("SAME"); 785 // delete gaus[nr]; 786 } 787 788 789 //------------------fit gain corrected sum spectrum----------------------- 790 791 const Int_t maxbin2 = hSum2.GetMaximumBin(); 792 const Double_t binwidth2 = hSum2.GetBinWidth(maxbin); 793 const Double_t ampl2 = hSum2.GetBinContent(maxbin); 794 cout << "AMPL: " << ampl2 << endl; 795 796 fwhm2 = 0; 797 for (int i=1; i<maxbin; i++) 798 if (hSum2.GetBinContent(maxbin2-i)+hSum2.GetBinContent(maxbin2+i)<ampl2*2) 799 { 800 fwhm2 = (2*i+1)*binwidth2; 801 break; 802 } 803 804 if (fwhm2==0) 805 { 806 cout << "Could not determine start value for sigma." << endl; 807 } 808 809 810 Double_t par2[5] = 811 { 812 ampl2, hSum2.GetBinCenter(maxbin2), fwhm2*1.4, 0.1, 0 813 }; 814 815 cout << "AMPL: " << ampl2 << endl; 816 cout << "maxpos: " << hSum2.GetBinCenter(maxbin2) << endl; 817 cout << "fwhm: " << fwhm2*1.4 << endl; 818 819 func3.SetParameters(par2); 820 821 const double min2 = par2[1]-fwhm2*1.4; 822 const double max2 = par2[1]*5; 823 824 hSum2.Fit(&func3, "N0QS", "", min2, max2); 825 func3.DrawCopy("SAME"); 826 //-------------------END OF: fit sum spectrum----------------------------- 719 827 720 828 TCanvas &c2 = d->AddTab("Result"); … … 765 873 766 874 Double_t y = 0; 767 for (int order = 1; order < 5; order++)875 for (int order = 1; order < 14; order++) 768 876 { 769 877 Double_t arg = (x - order*gain - shift)/sigma;
Note:
See TracChangeset
for help on using the changeset viewer.