11 FILE* fout=fopen(
"yield.txt",
"w");assert(fout);
12 FILE* fmass=fopen(
"mass.txt",
"w");assert(fout);
16 fprintf(fout,
"ss pt_mean totpi realpi background\n");
17 float fptmin[7]={4.0,5.0,6.0,7.0,8.0,9.0,10.0};
18 float fptmax[7]={5.0,6.0,7.0,8.0,9.0,10.0,25.0};
19 float ffit_x1[7]={0.03,0.03,0.03,0.05,0.05,0.05,0.07};
21 float fpar0[7]={8.0,7.8,7.2,6.4,5.6,4.9,4.9};
22 float fpar1[7]={-8.33,-6.82,-5.15,-4.14,-3.52,-3.0,-2.9};
23 float fpar2[7]={3000,3000,2000,1000,500,400,400};
24 float fpar3[7]={0.1308,0.1356,0.136,0.137,0.138,0.1375,0.1385};
25 float fpar4[7]={0.0208,0.02166,0.0231,0.025,0.027,0.027,0.029};
26 f1[0]=
new TF1(
"ffit",
"exp([0]-8.262*x)+[1]*exp(-0.5*((x-0.1305)/(0.02073*(1.+6.11*(x-0.1305))))**2)",ffit_x1[0],ffit_x2);
27 f1[1]=
new TF1(
"ffit",
"exp([0]-6.752*x)+[1]*exp(-0.5*((x-0.1353)/(0.02164*(1.+6.11*(x-0.1353))))**2)",ffit_x1[1],ffit_x2);
28 f1[2]=
new TF1(
"ffit",
"exp([0]-5.095*x)+[1]*exp(-0.5*((x-0.1359)/(0.02307*(1.+6.11*(x-0.1359))))**2)",ffit_x1[2],ffit_x2);
29 f1[3]=
new TF1(
"ffit",
"exp([0]-4.041*x)+[1]*exp(-0.5*((x-0.1375)/(0.02498*(1.+6.11*(x-0.1375))))**2)",ffit_x1[3],ffit_x2);
30 f1[4]=
new TF1(
"ffit",
"exp([0]-3.37*x)+[1]*exp(-0.5*((x-0.1374)/(0.02666*(1.+6.11*(x-0.1374))))**2)",ffit_x1[4],ffit_x2);
31 f1[5]=
new TF1(
"ffit",
"exp([0]-2.942*x)+[1]*exp(-0.5*((x-0.137)/(0.0266*(1.+6.11*(x-0.137))))**2)",ffit_x1[5],ffit_x2);
32 f1[6]=
new TF1(
"ffit",
"exp([0]-2.668*x)+[1]*exp(-0.5*((x-0.1392)/(0.02792*(1.+6.11*(x-0.1392))))**2)",ffit_x1[6],ffit_x2);
35 const int fnend=int(ffit_x1[i]*100)+1;
38 const int fnend=int(ffit_x1[i]*100);
40 const int fnstart=int(ffit_x2*100);
41 cout<<
"i="<<i<<
" nend="<<fnend<<
" nstart="<<fnstart<<endl;
43 FitPtMass(i, fptmin[i], fptmax[i], ffit_x1[i], ffit_x2, fpar0[i], fpar1[i], fpar2[i], fnend, fnstart);
47 void FitPtMass(
int key,
float ptmin,
float ptmax,
float fit_x1,
float fit_x2,
float par0,
float par1,
float par2,
int nend,
int nstart) {
49 int Realpi=0,backpi=0,totpi=0;
56 char *PlotName[mx]={
"hMassPtUU",
"hMassPtUD",
"hMassPtDU",
"hMassPtDD"};
57 char *fName[mt]={
"allfill.hist"};
60 gStyle->SetPalette(1,0);
63 TString hFile=inPath+fName[i];
65 fd0=
new TFile(hFile); assert(fd0->IsOpen());
69 int channel_yield[mx][40];
70 int channel_pi_yield[mx][40];
71 int channel_bg_yield[mx][40];
72 for(
int cmx=0;cmx<mx;cmx++)
76 channel_yield[cmx][i]=0;
77 channel_pi_yield[cmx][i]=0;
78 channel_bg_yield[cmx][i]=0;
81 for(
int ploti=0;ploti<mx;ploti++)
84 c1=
new TCanvas(
"c1",
"c1",500,500);
90 TH1F* h1=
new TH1F(
"hMassAny",
"diphoton invariant mass",120,0.,1.2 );
91 TH1F* h2=
new TH1F(
"hMassAny",
"diphoton invariant mass",120,0.,1.2 );
92 TH1F* hResidual=
new TH1F(
"hMassAny",
"diphoton invariant mass",120,0.,1.2 );
93 TString hname=PlotName[ploti];
94 printf(
"i= %d =%s=\n",ploti,hname.Data());
95 h0=(TH2F*)fd[0]->Get(hname); assert(h0);
96 minbin=h0->GetYaxis()->FindBin(ptmin);
97 maxbin=h0->GetYaxis()->FindBin(ptmax)-1;
98 h1->Add(h0->ProjectionX(
"htemp",minbin,maxbin,
""));
99 int ent=h1->Integral();
100 cout<<
"entry="<<ent<<endl;
105 for(
int i=minbin;i<=maxbin;i++){
106 ccount+=h0->ProjectionX(
"",i,i,
"")->Integral();
107 sum+=(h0->ProjectionX(
"",i,i,
"")->Integral())*tpt;
108 tpt+=(ptmax-ptmin)/(maxbin+1-minbin);
110 float ptmean=sum/ccount;
111 cout<<
"raw="<<int(h1->Integral(11,19))<<
" ptmean="<<ptmean<<endl;
113 h1->SetMinimum(-ent/100);
115 f1[key]->SetParameters(par0,par2);
116 h1->Fit(f1[key],
"R+",
"",fit_x1,fit_x2);
117 int nx=h1->GetNbinsX();
118 cout<<
"nx="<<nx<<endl;
120 for(
int ix=1;ix<=40;ix++)
122 channel_yield[ploti][ix-1]+=h1->GetBinContent(ix);
124 sumx+=h1->GetBinContent(ix);
127 TF1* f2=
new TF1(
"fit2",
"expo",0.,1.2);
131 hResidual->Add(f1[key],-1);
132 for (
int ix= 1; ix <= nend; ix++) {
133 hResidual->SetBinContent(ix, 0);
135 for (
int ix= nstart; ix <= nx; ix++) {
136 hResidual->SetBinContent(ix, 0);
138 hResidual->SetLineColor(11);
139 hResidual->Draw(
"same");
140 f2->SetParameters(f1[key]->GetParameter(0),par1);
142 for (
int ix= 1; ix <= 8; ix++) {
144 h2->SetBinContent(ix, 0);
149 h2->SetLineColor(kBlue);
150 TF1* f3=
new TF1(
"f3",
"expo(0)",fit_x1,fit_x2);
151 f3->SetParameters(f1[key]->GetParameter(0),par1);
152 cout<<
"p0="<<f1[key]->GetParameter(0)<<endl;
154 Realpi=h2->Integral(11,19);
155 backpi=h1->Integral(11,19)-h2->Integral(11,19);
156 totpi=h1->Integral(11,19);
158 for(
int ix=1;ix<=40;ix++)
160 channel_pi_yield[ploti][ix-1]+=h2->Integral(ix,ix);
162 channel_bg_yield[ploti][ix-1]+=h1->Integral(ix,ix)-h2->Integral(ix,ix);
166 cout<<
"total pi="<<totpi<<
" Real Pi0 integral="<<Realpi<<
" backpi="<<backpi<<endl;
168 fprintf(fout,
"%d %6f %d %d %d\n",ploti,ptmean,totpi,Realpi,backpi);
173 l1=
new TLine(0.135,0.,0.135,7000);
174 l1->SetLineColor(kRed);
176 l2=
new TLine(0.18,0.,0.18,7000);
177 l2->SetLineColor(kGreen);
179 l3=
new TLine(0.1,0.,0.1,7000);
180 l3->SetLineColor(kGreen);
183 TString hMassAny=
"mass";
186 c1->Print(hMassAny+
".gif");
191 for(
int j=0;j<40;j++)
193 int ySame=channel_yield[0][j]+channel_yield[3][j];
194 int yAnti=channel_yield[1][j]+channel_yield[2][j];
195 float ypi=channel_pi_yield[0][j]+channel_pi_yield[1][j]+channel_pi_yield[2][j]+channel_pi_yield[3][j];
197 float ybg=channel_bg_yield[0][j]+channel_bg_yield[1][j]+channel_bg_yield[2][j]+channel_bg_yield[3][j];
206 fprintf(fmass,
"%d %d %d %f\n",j+1,ySame,yAnti,ratio);