12 float ptmin=7.0,ptmax=8.0;
13 float fit_x1=0.07,fit_x2=0.4;
14 const int nend=int(fit_x1/0.01);
15 const int nstart=int(fit_x2/0.01);
16 cout<<
"nend="<<nend<<
" nstart="<<nstart<<endl;
18 TH1F* h1=
new TH1F(
"hMassAny",
"diphoton invariant mass",120,0.,1.2 );
19 TH1F* h2=
new TH1F(
"hMassAny",
"diphoton invariant mass",120,0.,1.2 );
20 TH1F* hResidual=
new TH1F(
"hMassAny",
"diphoton invariant mass",120,0.,1.2 );
21 FILE* fout=fopen(
"mass.txt",
"w");assert(fout);
22 fprintf(fout,
"Bin# Entry\n");
23 char *PlotName[mx]={
"hPTAny"};
24 char *fName[mt]={
"allruns.hist"};
26 c1=
new TCanvas(
"tmp",
"tmp",700,600);
27 gStyle->SetPalette(1,0);
30 TString hFile=inPath+fName[i];
32 fd0=
new TFile(hFile); assert(fd0->IsOpen());
43 TString hname=PlotName[i];
44 printf(
"=%s=\n",hname.Data());
45 h0=(TH2F*)fd[0]->Get(hname); assert(h0);
46 minbin=h0->GetYaxis()->FindBin(ptmin);
47 maxbin=h0->GetYaxis()->FindBin(ptmax)-1;
48 h1->Add(h0->ProjectionX(
"htemp",minbin,maxbin,
""));
49 int ent=h1->Integral();
50 cout<<
"entry="<<ent<<endl;
55 for(
int i=minbin;i<=maxbin;i++){
56 ccount+=h0->ProjectionX(
"",i,i,
"")->Integral();
57 sum+=(h0->ProjectionX(
"",i,i,
"")->Integral())*tpt;
58 tpt+=(ptmax-ptmin)/(maxbin+1-minbin);
60 float ptmean=sum/ccount;
61 cout<<
"raw="<<int(h1->Integral(11,19))<<
" ptmean="<<ptmean<<endl;
63 h1->SetMinimum(-ent/100);
64 TF1* f1=
new TF1(
"ffit",
"exp([0]+[1]*x)+[2]*exp(-0.5*((x-[3])/([4]*(1.0+6.11*(x-[3]))))**2)",fit_x1,fit_x2);
66 f1->SetParameters(9.0,-8.0,10000,0.135,0.02);
71 h1->Fit(f1,
"R+",
"",fit_x1,fit_x2);
72 int nx=h1->GetNbinsX();
75 for(
int ix=1;ix<=nx;ix++)
77 fprintf(fout,
"%d %d\n",ix,h1->GetBinContent(ix));
78 sumx+=h1->GetBinContent(ix);
83 TF1* f2=
new TF1(
"fit2",
"exp([0]+[1]*x+[2]/x)",0.,1.2);
87 hResidual->Add(f1,-1);
88 for (
int ix= 1; ix <= nend; ix++) {
89 hResidual->SetBinContent(ix, 0);
91 for (
int ix= nstart; ix <= nx; ix++) {
92 hResidual->SetBinContent(ix, 0);
94 hResidual->SetLineColor(11);
95 hResidual->Draw(
"same");
96 f2->SetParameters(f1->GetParameter(0),f1->GetParameter(1));
98 for (
int ix= 1; ix <= 8; ix++) {
99 h2->SetBinContent(ix, 0);
104 h2->SetLineColor(kBlue);
105 TF1* f3=
new TF1(
"f3",
"exp([0]+[1]*x+[2]/x)",fit_x1,fit_x2);
106 f3->SetParameters(f1->GetParameter(0),f1->GetParameter(1));
107 cout<<
"p0="<<f1->GetParameter(0)<<endl;
109 int Realpi=h2->Integral(11,19);
110 int backpi=h1->Integral(11,19)-h2->Integral(11,19);
111 int totpi=h1->Integral(11,19);
112 cout<<
"total pi="<<totpi<<
" Real Pi0 integral="<<Realpi<<
" backpi="<<backpi<<endl;
117 l1=
new TLine(0.135,0.,0.135,7000);
118 l1->SetLineColor(kRed);
120 l2=
new TLine(0.18,0.,0.18,7000);
121 l2->SetLineColor(kGreen);
123 l3=
new TLine(0.1,0.,0.1,7000);
124 l3->SetLineColor(kGreen);
127 c1->Print(
"hMassAny.gif");