StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dipi0.C
1 static const int kNPtBin=6;
2 static const int NCUT=18;
3 static const char* CCUT[NCUT+1]={"Before Mass Cut","Inclusive","Exclusive",
4  "BBCE<3000","3000<BBCE<20000","20000<BBCE<30000",
5  "Abort Gap","Jet Trigger","Double Triggers",
6  "On/Off Mass","Off/On Mass","Off/Off Mass",
7  "SmallBS","LargeBS","Top2",
8  "30000<BBCE<40000","40000<BBCE","NoBBCTOF",
9  "RealPi0"};
10 static const char CBEAM[20];
11 
12 static const double PI=TMath::Pi();
13 static const double twoPI=PI*2.0;
14 
15 const float MassCut0=0.07;
16 const float MassCut1=0.2;
17 const float MassCut2=0.35;
18 static Double_t ZggCut=0.7;
19 static int OPT=4;
20 static int RUN=1;
21 static int RUNpp=16077027;
22 static int RUNpAu=16125053;
23 static TCanvas *c1;
24 static TCanvas *c2;
25 static TCanvas *c3;
26 static TString* FILENAME;
27 TFile* mTFile;
28 
29 float PAR[kNPtBin][kNPtBin][5];
30 
31 double wrapAround(double phi){
32  double res=phi;
33  while(res>=1.5*PI) {res-=twoPI;}
34  while(res<-0.5*PI) {res+=twoPI;}
35  return res;
36 }
37 
38 void mixing(TH1F* h1, TH1F* h2, TH1F* d, TH1F* mix, int sub=1){
39  int t1=h1->GetEntries();
40  int t2=h1->GetEntries();
41  int n1=h1->GetNbinsX();
42  int n2=h2->GetNbinsX();
43  for(int i=1; i<=n1; i++){
44  double p1=h1->GetBinCenter(i);
45  double c1=h1->GetBinContent(i);
46  for(int j=1; j<=n2; j++){
47  double p2=h2->GetBinCenter(j);
48  double c2=h2->GetBinContent(j);
49  double dp=wrapAround(p1-p2+PI/n1/100.0);
50  mix->Fill(dp,c1*c2);
51  }
52  }
53  if(sub==1) mix->Add(d,-1.0);
54  mix->Scale(n1/mix->Integral());
55 }
56 
57 Double_t twoGaus(Double_t *x, Double_t *par){
58  Double_t OP=1.0/sqrt(2.0*PI);
59  Double_t x1 = x[0];
60  while(x1<-PI) x1+=2.0*PI;
61  while(x1>=PI) x1-=2.0*PI;
62  Double_t x2 = x[0]-PI;
63  while(x2<-PI) x2+=2.0*PI;
64  while(x2>=PI) x2-=2.0*PI;
65  Double_t f = par[0]/2.0/PI;
66  f += par[1]*OP/par[2]*exp(-x1*x1/2.0/par[2]/par[2]);
67  f += par[3]*OP/par[4]*exp(-x2*x2/2.0/par[4]/par[4]);
68  return f;
69 }
70 
71 Double_t oneGaus(Double_t *x, Double_t *par){
72  Double_t OP=1.0/sqrt(2.0*PI);
73  Double_t x1 = x[0]+PI;
74  while(x1<-PI) x1+=2.0*PI;
75  while(x1>=PI) x1-=2.0*PI;
76  Double_t f = par[0]/2.0/PI;
77  f += par[1]*OP/par[2]*exp(-x1*x1/2.0/par[2]/par[2]);
78  return f;
79 }
80 
81 void readfile(int opt=-1, int run=-1){
82  char file[100];
83  if(opt<0) opt=OPT;
84  if(run<0) {sprintf(file,"FPS/hist_opt%d/st_fms_%d_raw_merged.dipi0.root",opt,RUN); sprintf(CBEAM,"%d",RUN);}
85  if(run>100) {sprintf(file,"FPS/hist_opt%d/st_fms_%d_raw_merged.dipi0.root",opt,run); sprintf(CBEAM,"%d",run);}
86  if(run==1) {sprintf(file,"FPS/hist_opt%d/st_fms_%d_raw_merged.dipi0.root",opt,RUNpp);sprintf(CBEAM,"%d",RUNpp);}
87  if(run==2) {sprintf(file,"FPS/hist_opt%d/st_fms_%d_raw_merged.dipi0.root",opt,RUNpAu);sprintf(CBEAM,"%d",RUNpAu);}
88  if(run==11) {sprintf(file,"FPS/hist/pptrans/dipi0.root"); sprintf(CBEAM,"pp");}
89  if(run==15) {sprintf(file,"FPS/hist/pAu1/dipi0.root"); sprintf(CBEAM,"pAu1");}
90  if(run==12) {sprintf(file,"FPS/hist/pAu2/dipi0.root"); sprintf(CBEAM,"pAu2");}
91  if(run==13) {sprintf(file,"FPS/hist/pAl/dipi0.root"); sprintf(CBEAM,"pAl");}
92  if(run==20) {sprintf(file,"FPS/hist_pythia6/dipi0.all.root"); sprintf(CBEAM,"pythia");}
93 
94  printf("Reading %s\n",file);
95  mTFile = new TFile(file);
96 }
97 
98 void openCanvas(){
99  c1 = new TCanvas("DiPi0_1","DiPi0_1",0,20,600,700);
100  c2 = new TCanvas("DiPi0_2","DiPi0_2",550,20,600,700);
101  c3 = new TCanvas("DiPi0_3","DiPi0_3",1100,20,600,700);
102  gStyle->SetPalette(1);
103  gStyle->SetStatW(0.4);
104 }
105 
106 void plot1d(TCanvas* c, char* name){
107  TH1F *h;
108  c->Divide(1,3);
109  c->cd(1)->SetLogy();
110  readfile(OPT,11);
111  h = (TH1F*)mTFile->Get(Form("%s",name)); h->Draw(); h->SetLineWidth(2); h->SetMinimum(1.0);
112  h = (TH1F*)mTFile->Get(Form("%sAG",name)); h->Draw("same"); h->SetLineColor(2);h->SetLineWidth(2);
113  t=new TText(0.2, 0.25,"pp collisions"); t->SetNDC(); t->Draw();
114  t=new TText(0.2, 0.20,"pp abort-gap"); t->SetNDC(); t->Draw(); t->SetTextColor(2);
115  c->cd(2)->SetLogy();
116  readfile(OPT,13);
117  h = (TH1F*)mTFile->Get(Form("%s",name)); h->Draw(); h->SetLineWidth(2); h->SetMinimum(1.0);
118  h = (TH1F*)mTFile->Get(Form("%sAG",name)); h->Draw("same"); h->SetLineColor(2);h->SetLineWidth(2);
119  t=new TText(0.2, 0.25,"pAl collisions"); t->SetNDC(); t->Draw();
120  t=new TText(0.2, 0.20,"pAl abort-gap"); t->SetNDC(); t->Draw(); t->SetTextColor(2);
121  c->cd(3)->SetLogy();
122  readfile(OPT,12);
123  h = (TH1F*)mTFile->Get(Form("%s",name)); h->Draw(); h->SetLineWidth(2);h->SetMinimum(1.0);
124  h = (TH1F*)mTFile->Get(Form("%sAG",name)); h->Draw("same"); h->SetLineColor(2); h->SetLineWidth(2);
125  readfile(OPT,15);
126  h = (TH1F*)mTFile->Get(Form("%s",name)); h->Draw("same"); h->SetLineColor(4); h->SetLineWidth(2);
127  h = (TH1F*)mTFile->Get(Form("%sAG",name)); h->Draw("same"); h->SetLineColor(6); h->SetLineWidth(2);
128  t=new TText(0.2, 0.25,"pAu2 collisions"); t->SetNDC(); t->Draw();
129  t=new TText(0.2, 0.20,"pAu2 abort-gap"); t->SetNDC(); t->Draw(); t->SetTextColor(2);
130  t=new TText(0.35, 0.25,"pAu1 collisions"); t->SetNDC(); t->Draw(); t->SetTextColor(4);
131  t=new TText(0.35, 0.20,"pAu1 abort-gap"); t->SetNDC(); t->Draw(); t->SetTextColor(6);
132  c->SaveAs(Form("plot/%s.png",name));
133 }
134 
135 void plot2d(TCanvas* c, char* name){
136  TH2F *h2;
137  c->Divide(2,2);
138  c->cd(1)->SetLogz();
139  readfile(OPT,11);
140  h2 = (TH2F*)mTFile->Get(Form("%s",name));
141  h2->Draw("colz");
142  t=new TText(0.75, 0.15,"pp"); t->SetNDC(); t->Draw();
143  c->cd(2)->SetLogz();
144  readfile(OPT,13);
145  h2 = (TH2F*)mTFile->Get(Form("%s",name));
146  h2->Draw("colz");
147  t=new TText(0.75, 0.15,"pAl"); t->SetNDC(); t->Draw();
148  c->cd(3)->SetLogz();
149  readfile(OPT,15);
150  h2 = (TH2F*)mTFile->Get(Form("%s",name));
151  h2->Draw("colz");
152  t=new TText(0.75, 0.15,"pAu1"); t->SetNDC(); t->Draw();
153  c->cd(4)->SetLogz();
154  readfile(OPT,12);
155  h2 = (TH2F*)mTFile->Get(Form("%s",name));
156  h2->Draw("colz");
157  t=new TText(0.75, 0.15,"pAu2"); t->SetNDC(); t->Draw();
158  c->SaveAs(Form("plot/%s.png",name));
159 }
160 
161 void bbc(int plt=0){
162  gStyle->SetOptStat(0);
163  if(plt==0 || plt==1){
164  plot1d(c1,"BBCE");
165  plot1d(c2,"BBCMult");
166  plot1d(c3,"TOF");
167  }
168  if(plt==0 || plt==2){
169  plot2d(c1,"BBC_BBCMult");
170  plot2d(c2,"BBC_TOF");
171  plot2d(c3,"BBCMult_TOF");
172  }
173  if(plt==0 || plt==3){
174  plot2d(c1,"TOF_TOF");
175  }
176 }
177 
178 TH1F* mix(int run=21, int cut=1, int bin1=3, int bin2=1, int plot=1, int method=1, TH1F* mix0=0, TH1F* mix1=0){
179  readfile(OPT,run);
180  TH1F* h1= (TH1F*)mTFile->Get(Form("phi1_%1d%1d_c%d",bin1,bin2,cut));
181  TH1F* h2= (TH1F*)mTFile->Get(Form("phi2_%1d%1d_c%d",bin1,bin2,cut));
182  TH1F* h3= (TH1F*)mTFile->Get(Form("dphi_%1d%1d_c%d",bin1,bin2,cut));
183  TH1F* h4= (TH1F*)h3->Clone(Form("mix_%1d%1d_c%d",bin1,bin2,cut));
184  TH1F* h5= (TH1F*)h3->Clone(Form("dphi_corr_%1d%1d_c%d",bin1,bin2,cut));
185  h4->Reset();
186  h5->Reset();
187  mixing(h1,h2,h3,h4,1);
188  h5->Divide(h3,h4);
189  mix0=h4;
190 
191  TH1F* h11= (TH1F*)mTFile->Get(Form("phi0_%1d_c%d",bin1,cut));
192  TH1F* h12= (TH1F*)mTFile->Get(Form("phi0_%1d_c%d",bin2,cut));
193  TH1F* h13= (TH1F*)mTFile->Get(Form("dphi_%1d%1d_c%d",bin1,bin2,cut));
194  TH1F* h14= (TH1F*)h3->Clone(Form("mix2_%1d%1d_c%d",bin1,bin2,cut));
195  TH1F* h15= (TH1F*)h3->Clone(Form("dphi_corr2_%1d%1d_c%d",bin1,bin2,cut));
196  h14->Reset();
197  h15->Reset();
198  mixing(h11,h12,h13,h14,0);
199  h15->Divide(h13,h14);
200  mix1=h14;
201 
202  if(plot==1){
203  TText* t;
204  gStyle->SetOptStat(0);
205  c1->Divide(2,2);
206  c1->cd(1); h1->SetMinimum(0); h1->SetLineWidth(2); h1->Draw();
207  h11->Scale(h1->GetEntries()/h11->GetEntries()); h11->SetLineWidth(2); h11->SetLineColor(6); h11->Draw("same");
208  t = new TText(0.2, 0.85,Form("%s %s",CBEAM,CCUT[cut])); t->SetNDC(); t->SetTextSize(0.06); t->SetTextColor(1); t->Draw();
209  c1->cd(2); h2->SetMinimum(0); h2->SetLineWidth(2); h2->Draw();
210  if(h11!=h12)h12->Scale(h2->GetEntries()/h12->GetEntries());
211  h12->SetLineWidth(2); h12->SetLineColor(6); h12->Draw("same");
212  float m4=h4->GetMaximum();
213  c1->cd(4); h4->SetMinimum(0); h4->SetLineWidth(2); h4->SetMaximum(m4*1.1); h4->Draw();
214  h14->SetLineWidth(2); h4->SetLineColor(6); h14->Draw("same");
215  c1->cd(3);
216  h3->Rebin(2); h5->Rebin(2); h15->Rebin(2);
217  float m3=h3->GetBinContent(h3->GetNbinsX()*3/4);
218  h3->SetMinimum(0); h3->SetLineWidth(2); h3->SetMaximum(m3*1.5); h3->SetLineColor(1); h3->Draw();
219  h5->SetLineWidth(2); h5->SetLineColor(2); h5->Draw("same");
220  h15->SetLineWidth(2); h15->SetLineColor(6); h15->Draw("same");
221  t= new TText(0.20, 0.25,"UnCorrected"); t->SetTextSize(0.05); t->SetTextColor(1); t->SetNDC(); t->Draw();
222  t= new TText(0.20, 0.20,"Corrected"); t->SetTextSize(0.05); t->SetTextColor(2); t->SetNDC(); t->Draw();
223  t= new TText(0.20, 0.15,"Corrected2"); t->SetTextSize(0.05); t->SetTextColor(6); t->SetNDC(); t->Draw();
224  c1->SaveAs(Form("plot/mix_%s_%1d%1d_c%d.png",CBEAM,bin1,bin2,cut));
225  }
226 
227  if(method==0) return h5;
228  else return h15;
229 }
230 
231 void plot(char* v, int run, int cut, TCanvas* cvs, int fit=0, int bin1=-1, int bin2=-1, float ymax=0.0, int rebin=0){
232  int bin0=1;
233  char c[100];
234  char c2[100];
235  readfile(OPT,run);
236  gStyle->SetOptStat(0);
237  gStyle->SetOptFit(0);
238  gStyle->SetOptTitle(0);
239  cvs->Clear();
240  int b1=bin1, b2=bin1+1, b3=bin2, b4=b3;
241  if(bin1<0) {cvs->Divide(kNPtBin-bin0,kNPtBin-bin0); b1=bin0; b2=kNPtBin; b3=bin0;}
242  float ptcut[kNPtBin+1]={0.5,1.0,1.5,2.0,2.5,3.0,10.0};
243  memset(PAR,0,sizeof(PAR));
244  TText* t;
245  for(int i=b1; i<b2; i++){
246  if(bin1<0) b4=i;
247  for(int j=b3; j<=b4; j++){
248  int cc=cut;
249  if(cut==99 && (v=="m1" || v=="m2")) cc=0;
250  if(cut==99 && v=="dphi") cc=1;
251  TH1F *h,*h2,*h3,*h4;
252  TH2F *h2d;
253 
254  //get normalizations
255  float norm0=1.0;
256  float norm1=1.0;
257  float norm2=1.0;
258  float norm3=1.0;
259  if(v=="m0" || v=="phi0"){}
260  else{
261  sprintf(c,"m0_%1d_c%d",i,cc);
262  TH1F* h0 = (TH1F*)mTFile->Get(c);
263  norm0 = h0->GetEntries();
264  sprintf(c,"m2_%1d%1d_c%d",i,j,cc);
265  TH1F* h1 = (TH1F*)mTFile->Get(c);
266  norm1 = h1->GetEntries();
267  printf("n0=%d n1=%d\n",norm0,norm1);
268  norm2=norm1/norm0;
269  norm3=norm2/ZggCut;
270  }
271 
272  int opt=1, log=0;
273  if(v=="mix"){
274  h3=mix(run,cc,i,j,0,1,h,h2);
275  h1->SetLineColor(1);
276  h2->SetLineColor(6);
277  }else if(v=="corr"){
278  h = mix(run,cc,i,j,0,1);
279  if(rebin>0) h->Rebin(rebin);
280  if(fit==1) h->GetXaxis()->SetRangeUser(PI/2.0,3.0*PI/2.0);
281  int nbin = h->GetNbinsX();
282  h->Sumw2();
283  if(run<20) {h->Scale(1.0/norm0*nbin/2.0/PI/ZggCut);}
284  else {h->Scale(1.0/norm0*nbin/2.0/PI);}
285  }else if(v=="norm"){
286  sprintf(c,"dphi_%1d%1d_c%d",i,j,cc);
287  h = (TH1F*)mTFile->Get(c);
288  if(rebin>0) h->Rebin(rebin);
289  if(fit==1) h->GetXaxis()->SetRangeUser(PI/2.0,3.0*PI/2.0);
290  int nbin = h->GetNbinsX();
291  h->Sumw2();
292  if(run<20) {h->Scale(1.0/norm0*nbin/2.0/PI/ZggCut);}
293  else {h->Scale(1.0/norm0*nbin/2.0/PI);}
294  }else if(v=="mall"){
295  sprintf(c,"m0_%1d_c%d",i,0);
296  sprintf(c2,"m0_%1d%1d_c%d",i,j,0);
297  h4 = (TH1F*)((TH1F*)mTFile->Get(c))->Clone(c2);
298  float norm4 = h4->Integral(h4->GetXaxis()->FindBin(MassCut0),h4->GetXaxis()->FindBin(MassCut1));
299  h4->Scale(norm1/norm4);
300  h = (TH1F*)((TH1F*)mTFile->Get(c))->Clone(c2);
301  sprintf(c,"m0_%1d_c%d",i,cc);
302  sprintf(c2,"m0_%1d%1d_c%d",i,j,cc);
303  h = (TH1F*)((TH1F*)mTFile->Get(c))->Clone(c2); h->SetLineColor(6);
304  h->Scale(norm2);
305  sprintf(c,"m1_%1d%1d_c%d",i,j,cc);
306  h2 = (TH1F*)mTFile->Get(c); h2->SetLineColor(2);
307  sprintf(c,"m2_%1d%1d_c%d",i,j,cc);
308  h3 = (TH1F*)mTFile->Get(c); h3->SetLineColor(4);
309  }else if(v=="z12"){
310  sprintf(c,"z1_%1d%1d_c%d",i,j,cc);
311  h = (TH1F*)mTFile->Get(c); h->SetLineColor(2);
312  sprintf(c,"z2_%1d%1d_c%d",i,j,cc);
313  h2 = (TH1F*)mTFile->Get(c); h2->SetLineColor(4);
314  }else if(v=="m0" || v=="phi0"){
315  sprintf(c,"%s_%1d_c%d",v,i,cc);
316  printf("%s\n",c);
317  h = (TH1F*)mTFile->Get(c);
318  }else if(v=="bbce"){
319  opt=1;
320  log=1;
321  sprintf(c,"%s_%1d%1d_c%d",v,i,j,cc);
322  printf("%s\n",c);
323  h = (TH1F*)mTFile->Get(c);
324  h->SetMinimum(0.1);
325  }else if(v=="phi1" || v=="phi2"){
326  opt=1;
327  sprintf(c,"%s_%1d%1d_c%d",v,i,j,cc);
328  printf("%s\n",c);
329  h = (TH1F*)mTFile->Get(c);
330  }else if(v=="phi1dphi"){
331  opt=2;
332  sprintf(c,"%s_%1d%1d_c%d",v,i,j,cc);
333  printf("%s\n",c);
334  h = (TH1F*)mTFile->Get(c);
335  }else{
336  sprintf(c,"%s_%1d%1d_c%d",v,i,j,cc);
337  printf("%s\n",c);
338  h = (TH1F*)mTFile->Get(c);
339  }
340  if(bin1<0){
341  TVirtualPad *pad = cvs->cd((i-bin0)*(kNPtBin-bin0)+(j-bin0)+1);
342  pad->SetRightMargin(0.01);
343  pad->SetLeftMargin(0);
344  pad->SetTopMargin(0);
345  pad->SetBottomMargin(0.01);
346  pad->Draw();
347  }
348  h->SetMinimum(0.0);
349  if(ymax>0.0) h->SetMaximum(ymax);
350  if(opt==0) h->Draw("e");
351  if(opt==1) h->Draw();
352  if(opt==2) h->Draw("colz");
353  if(v=="mall"){
354  h4->Draw("same");
355  h2->Draw("same");
356  h3->Draw("same");
357  }
358  if(v=="z12" || v=="mix") h2->Draw("same");
359  TF1* f;
360  if((v=="norm" || v=="corr") && fit==1){
361  f=new TF1("oneGaus",oneGaus,+PI/2.0,+PI*3.0/2.0,3);
362  f->SetParameters(norm3/10.0,norm3/2.0,0.3);
363  f->SetParNames("Const","IntFar","SigFar");
364  f->SetParLimits(0,0.0,1.0);
365  f->SetParLimits(1,0.0,1.0);
366  f->SetParLimits(2,0.0,3.0);
367  f->SetLineColor(2); f->SetLineWidth(1);
368  h->Fit("oneGaus","Q");
369  PAR[i][j][0]=f->GetParameter(0);
370  PAR[i][j][1]=f->GetParameter(1);
371  PAR[i][j][2]=f->GetParameter(2);
372  printf("norm=%8.6f Int=%8.6f IntFar=%8.6 SigFar=%6.3f C=%8.6f\n",
373  norm3,PAR[i][j][1]+PAR[i][j][0],PAR[i][j][1],PAR[i][j][2],PAR[i][j][0]);
374  }
375  if((v=="norm" || v="corr") && fit==2){
376  f=new TF1("twoGaus",twoGaus,-PI/2.0,+PI*3.0/2.0,5);
377  f->SetParameters(norm3/10.0,norm3/2.0,0.3,norm3/2.0,0.3);
378  f->SetParNames("Const","IntNear","SigNear","IntFar","SigFar");
379  f->SetParLimits(0,0.0,1.0);
380  f->SetParLimits(1,0.0,1.0);
381  f->SetParLimits(2,0.0,3.0);
382  f->SetParLimits(3,0.0,1.0);
383  f->SetParLimits(4,0.0,3.0);
384  f->SetLineColor(2); f->SetLineWidth(1);
385  h->Fit("twoGaus","Q");
386  PAR[i][j][0]=f->GetParameter(0);
387  PAR[i][j][1]=f->GetParameter(1);
388  PAR[i][j][2]=f->GetParameter(2);
389  PAR[i][j][3]=f->GetParameter(3);
390  PAR[i][j][4]=f->GetParameter(4);
391  printf("norm=%8.6f Int=%8.6f IntNear=%8.6f IntFar=%8.6f SigNear=%6.3f SigFar=%6.3f C=%8.6f\n",
392  norm3,PAR[i][j][1]+PAR[i][j][3]+PAR[i][j][0],PAR[i][j][1],PAR[i][j][3],
393  PAR[i][j][2],PAR[i][j][4],PAR[i][j][0]);
394  }
395 
396  float xx=0.60, yy=0.85, dy=0.04, size=0.04;
397  if(bin1<0){xx=0.45, yy=0.90, dy=0.08, size=0.08;}
398  if(v=="z12") {xx=0.1; yy=0.35;}
399  t = new TText(xx, yy, Form("pT1=%3.1f-%3.1f",ptcut[i],ptcut[i+1])); t->SetNDC(); t->SetTextSize(size); t->Draw();
400  t = new TText(xx, yy-dy, Form("pT2=%3.1f-%3.1f",ptcut[j],ptcut[j+1])); t->SetNDC(); t->SetTextSize(size); t->Draw();
401  if(norm3>0.0){
402  t = new TText(xx, yy-dy*2, Form("P=%7.5f",norm3)); t->SetNDC(); t->SetTextSize(size); t->Draw();
403  }
404  if((v=="norm" || v="corr") && fit==1){
405  t = new TText(xx, yy-dy*3, Form("PBg=%7.5f", PAR[i][j][0])); t->SetNDC(); t->SetTextSize(size); t->Draw();
406  t = new TText(xx, yy-dy*4, Form("Paway=%7.5f",PAR[i][j][1])); t->SetNDC(); t->SetTextSize(size); t->Draw();
407  t = new TText(xx, yy-dy*5, Form("Saway=%4.2f",PAR[i][j][2])); t->SetNDC(); t->SetTextSize(size); t->Draw();
408  }
409  if((v=="norm" || v="corr") && fit==2){
410  t = new TText(xx, yy-dy*3, Form("Pnear=%7.5f",PAR[i][j][1])); t->SetNDC(); t->SetTextSize(size); t->Draw();
411  t = new TText(xx, yy-dy*4, Form("Paway=%7.5f",PAR[i][j][3])); t->SetNDC(); t->SetTextSize(size); t->Draw();
412  t = new TText(xx, yy-dy*5, Form("PBg=%7.5f", PAR[i][j][0])); t->SetNDC(); t->SetTextSize(size); t->Draw();
413  t = new TText(xx, yy-dy*6, Form("Snear=%4.2f",PAR[i][j][2])); t->SetNDC(); t->SetTextSize(size); t->Draw();
414  t = new TText(xx, yy-dy*7, Form("Saway=%4.2f",PAR[i][j][4])); t->SetNDC(); t->SetTextSize(size); t->Draw();
415  }
416  if(cut==88) h->SetLineColor(2);
417  if(cut==99 && (v=="m1"|| v=="m2")){
418  sprintf(c,"%s_%1d%1d_c%d",v,i,j,1);
419  h = (TH1F*)mTFile->Get(c);
420  h->SetLineColor(4);
421  h->Draw("same");
422  sprintf(c,"%s_%1d%1d_c%d",v,i,j,2);
423  h = (TH1F*)mTFile->Get(c);
424  h->SetLineColor(2);
425  h->Draw("same");
426  }
427  if(cut==99 && v=="dphi"){
428  h->SetLineColor(4);
429  sprintf(c,"%s_%1d%1d_c%d",v,i,j,2);
430  h = (TH1F*)mTFile->Get(c);
431  h->SetLineColor(2);
432  h->Draw("same");
433  }
434  if(bin1>0){
435  t = new TText(0.1, 0.92,Form("%s %s",CBEAM,CCUT[cut])); t->SetNDC(); t->SetTextSize(0.07); t->SetTextColor(1); t->Draw();
436  if (run==1 || run==11) {sprintf(c,"plot/dipi0_pp_%s_c%d_bin%d%d.png",v,cut,i,j);}
437  else if(run==5 || run==15) {sprintf(c,"plot/dipi0_pau1_%s_c%d_bin%d%d.png",v,cut,i,j);}
438  else if(run==2 || run==12) {sprintf(c,"plot/dipi0_pau2_%s_c%d_bin%d%d.png",v,cut,i,j);}
439  else if(run==3 || run==13) {sprintf(c,"plot/dipi0_pal_%s_c%d_bin%d%d.png",v,cut,i,j);}
440  else {sprintf(c,"plot/dipi0_%d_%s_c%d_bin%d%d.png",run,v,cut,i,j);}
441  printf("Saving %s\n",c);
442  cvs->SaveAs(c);
443  }
444  }
445  }
446  if(bin1<0){
447  cvs->cd(2);
448  t = new TText(0.0, 0.85,Form("%s %s",CBEAM,CCUT[cut])); t->SetNDC(); t->SetTextSize(0.12); t->SetTextColor(1); t->Draw();
449  }
450  if(v=="mall"){
451  t = new TText(0.05, 0.65,"M1(no mass, scaled)"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(1); t->Draw();
452  t = new TText(0.05, 0.55,"M1(without M2)/P"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(6); t->Draw();
453  t = new TText(0.05, 0.45,"M1(with M2)"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(2); t->Draw();
454  t = new TText(0.05, 0.35,"M2"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(4); t->Draw();
455  }
456  if(v=="z12"){
457  t = new TText(0.05, 0.65,"Zgg1"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(2); t->Draw();
458  t = new TText(0.05, 0.55,"Zgg2"); t->SetNDC(); t->SetTextSize(0.10); t->SetTextColor(4); t->Draw();
459  }
460  if(cut==99) {
461  t = new TText(0.0, 0.65, "Inclusive Pair"); t->SetNDC(); t->SetTextSize(0.12); t->SetTextColor(4); t->Draw();
462  t = new TText(0.0, 0.45, "Exclusive Pair"); t->SetNDC(); t->SetTextSize(0.12); t->SetTextColor(2); t->Draw();
463  }
464  if(bin1<0){
465  if (run==1 || run==11) {sprintf(c,"plot/dipi0_pp_%s_c%d.png",v,cut);}
466  else if(run==5 || run==15) {sprintf(c,"plot/dipi0_pau1_%s_c%d.png",v,cut);}
467  else if(run==2 || run==12) {sprintf(c,"plot/dipi0_pau2_%s_c%d.png",v,cut);}
468  else if(run==3 || run==13) {sprintf(c,"plot/dipi0_pal_%s_c%d.png",v,cut);}
469  else {sprintf(c,"plot/dipi0_%d_%s_c%d.png",run,v,cut);}
470  printf("Saving %s\n",c);
471  cvs->SaveAs(c);
472  }
473 }
474 
475 void comp(int run, int pt1, int pt2, TCanvas* cvs, int fit=0){
476  int bin0=1;
477  char c[100];
478  char c2[100];
479  readfile(OPT,run);
480  gStyle->SetOptStat(0);
481  gStyle->SetOptFit(0);
482  gStyle->SetOptTitle(0);
483  cvs->Clear();
484  float ptcut[kNPtBin+1]={0.5,1.0,1.5,2.0,2.5,3.0,10.0};
485  float col[NCUT+1]={0,1,4,3,4,38,6,9,8,kGreen+3,kOrange,kPink+9,kOrange+7,kGreen+3,3,2,1,2};
486  memset(PAR,0,sizeof(PAR));
487  TText* t;
488  int cmax=NCUT;
489  if(run==20) cmax++;
490  int iy=0;
491  for(int cc=1; cc<cmax; cc++){
492  TH1F *h,*h2,*h3,*h4;
493  if(run==11 && cc==5) continue;
494  if(run==11 && cc>14) continue;
495  //if(run==20 && cc!=2 && cc!=9 && cc!=10 && cc!=11 && cc!=cmax-3) continue;
496  if(run==20 && cc!=2 && cc!=14 && cc!=cmax-3) continue;
497  //get normalizations
498  sprintf(c,"m0_%1d_c%d",pt1,cc);
499  TH1F* h0 = (TH1F*)mTFile->Get(c);
500  float norm0 = h0->GetEntries();
501  sprintf(c,"m1_%1d%1d_c%d",pt1,pt2,cc);
502  TH1F* h1 = (TH1F*)mTFile->Get(c);
503  float norm1 = h1->GetEntries();
504  float norm2=norm1/norm0;
505  float norm3=norm2/ZggCut;
506  printf("cut=%2d n0=%d n1=%d n2=%f\n",cc,norm0,norm1,norm2);
507 
508  sprintf(c,"dphi_%1d%1d_c%d",pt1,pt2,cc);
509  h = (TH1F*)mTFile->Get(c);
510  int nbin = h->GetNbinsX();
511  if(cc==cmax-3){
512  h->Scale(1.0/norm0*nbin/2.0/PI);
513  }else{
514  h->Scale(1.0/norm0*nbin/2.0/PI/ZggCut);
515  }
516  h->SetLineColor(col[cc]);
517  h->SetLineWidth(2);
518  h->SetMinimum(0.0);
519  if(iy==0) {
520  h->SetMaximum(h->GetMaximum()*1.5);
521  h->Draw("l");
522  }else{
523  h->Draw("lsame");
524  }
525  if(run==20 && cc==cmax-3) cc=cmax-1;
526  t = new TText(0.7, 0.85-iy*0.03,CCUT[cc]); t->SetNDC(); t->SetTextSize(0.02); t->SetTextColor(col[cc]); t->Draw();
527  iy++;
528  }
529  float xx=0.45, yy=0.80, dy=0.03;
530  t = new TText(xx, yy, Form("pT1=%3.1f-%3.1f",ptcut[pt1],ptcut[pt1+1])); t->SetNDC(); t->SetTextSize(0.03); t->Draw();
531  t = new TText(xx, yy-dy, Form("pT2=%3.1f-%3.1f",ptcut[pt2],ptcut[pt2+1])); t->SetNDC(); t->SetTextSize(0.03); t->Draw();
532 
533  if (run==1 || run==11) {sprintf(c,"plot/dipi0_pp_compdphi.png");}
534  else if(run==2 || run==12) {sprintf(c,"plot/dipi0_pau_compdphi.png");}
535  else if(run==3 || run==13) {sprintf(c,"plot/dipi0_pal_compdphi.png");}
536  else if(run==20) {sprintf(c,"plot/dipi0_pythia_compdphi.png");}
537  else {sprintf(c,"plot/dipi0_%d_compdphi.png",run);}
538  printf("Saving %s\n",c);
539  cvs->SaveAs(c);
540 }
541 
542 void dipi0(int plt=0, int cut=2, int run=1, int opt=4){
543  printf("plt=%d cut=%d run=%d opt=%d\n",plt,cut,run,opt);
544  OPT=opt;
545  RUN=run;
546  openCanvas();
547  if(plt==1 || plt==0) bbc(1);
548  if(plt==2 || plt==0) bbc(2);
549  if(plt==3 || plt==0) bbc(3);
550  if(plt==4 || plt==0) {plot("bbce",11,cut,c1); plot("bbce",13,cut,c2); plot("bbce",12,cut,c3);}
551  if(plt==5 || plt==0) {plot("m0",11,cut,c1); plot("m0",13,cut,c2); plot("m0",12,cut,c3);}
552  if(plt==6 || plt==0) {plot("m1",11,cut,c1); plot("m1",13,cut,c2); plot("m1",12,cut,c3);}
553  if(plt==7 || plt==0) {plot("m2",11,cut,c1); plot("m2",13,cut,c2); plot("m2",12,cut,c3);}
554  if(plt==8 || plt==0) {plot("z1",11,cut,c1); plot("z1",13,cut,c2); plot("z1",12,cut,c3);}
555  if(plt==9 || plt==0) {plot("z2",11,cut,c1); plot("z2",13,cut,c2); plot("z2",12,cut,c3);}
556  if(plt==10|| plt==0) {plot("phi0",11,cut,c1); plot("phi0",13,cut,c2);plot("phi0",12,cut,c3);}
557  if(plt==11|| plt==0) {plot("phi1",11,cut,c1); plot("phi1",13,cut,c2);plot("phi1",12,cut,c3);}
558  if(plt==12|| plt==0) {plot("phi2",11,cut,c1); plot("phi2",13,cut,c2);plot("phi2",12,cut,c3);}
559  if(plt==13|| plt==0) {plot("eta1",11,cut,c1); plot("eta1",13,cut,c2);plot("eta1",12,cut,c3);}
560  if(plt==14|| plt==0) {plot("eta2",11,cut,c1); plot("eta2",13,cut,c2);plot("eta2",12,cut,c3);}
561  if(plt==15|| plt==0) {plot("dphi",11,cut,c1); plot("dphi",13,cut,c2);plot("dphi",12,cut,c3);}
562  if(plt==16|| plt==0) {plot("phi1dphi",11,cut,c1); plot("phi1dphi",13,cut,c2);plot("phi1dphi",12,cut,c3);}
563  if(plt==17|| plt==0) {plot("mix",11,cut,c1); plot("mix",13,cut,c2);plot("mix",12,cut,c3);}
564 
565  if(plt==20 || plt==0){plot("mall",11,cut,c1); plot("mall",13,cut,c2); plot("mall",12,cut,c3);}
566  if(plt==21 || plt==0){plot("z12",11,cut,c1); plot("z12",13,cut,c2); plot("z12",12,cut,c3);}
567 
568  if(plt==30|| plt==0){comp(11,4,2,c1); comp(13,4,2,c2); comp(12,4,2,c3);}
569  if(plt==31|| plt==0){comp(20,2,1,c1);}
570 
571  if(plt==40 || plt==0) {plot("norm",11,cut,c1,2); plot("norm",13,cut,c2,2); plot("norm",12,cut,c3,2);}
572  if(plt==41 || plt==0) {
573  plot("norm",11,cut,c1,1,-1,-1,0.00,4);
574  plot("norm",13,cut,c2,1,-1,-1,0.00,4);
575  plot("norm",12,cut,c3,1,-1,-1,0.00,4);
576  }
577  if(plt==42 || plt==0) {
578  plot("corr",11,cut,c1,1,-1,-1,0.00,4);
579  plot("corr",13,cut,c2,1,-1,-1,0.00,4);
580  plot("corr",12,cut,c3,1,-1,-1,0.00,4);
581  }
582 
583  if(plt==50) mix(run,cut,3,1);
584  if(plt==51) mix(11,12,4,2);
585  if(plt==52) mix(12,16,2,0);
586  if(plt==53) mix(11,2,3,1);
587  if(plt==54) mix(12,16,3,1);
588  if(plt==55) mix(13,16,3,1);
589  if(plt==56) mix(13,2,2,2);
590 
591 
592  if(plt==100 || plt==0){
593  plot("norm",11,2,c1,1,2,0,0.1);
594  plot("norm",12,2,c2,1,2,0,0.1);
595  plot("norm",12,3,c2,1,2,0,0.1);
596  plot("norm",12,4,c2,1,2,0,0.1);
597  plot("norm",12,5,c2,1,2,0,0.1);
598  plot("norm",12,15,c2,1,2,0,0.1);
599  plot("norm",12,16,c2,1,2,0,0.1);
600  }
601  if(plt==101 || plt==0){
602  plot("norm",11,2,c1,1,3,1,0.012);
603  plot("norm",11,3,c1,1,3,1,0.012);
604  plot("norm",11,4,c1,1,3,1,0.012);
605  plot("norm",11,5,c1,1,3,1,0.012);
606  plot("norm",11,15,c1,1,3,1,0.012);
607  plot("norm",12,2,c2,1,3,1,0.012);
608  plot("norm",12,3,c2,1,3,1,0.012);
609  plot("norm",12,4,c2,1,3,1,0.012);
610  plot("norm",12,5,c2,1,3,1,0.012);
611  plot("norm",12,15,c2,1,3,1,0.012);
612  plot("norm",12,16,c2,1,3,1,0.012);
613  plot("norm",13,2,c2,1,3,1,0.012);
614  plot("norm",13,3,c2,1,3,1,0.012);
615  plot("norm",13,4,c2,1,3,1,0.012);
616  plot("norm",13,5,c2,1,3,1,0.012);
617  plot("norm",13,15,c2,1,3,1,0.012);
618  plot("norm",13,16,c2,1,3,1,0.012);
619  }
620  if(plt==102 || plt==0){
621  plot("norm",11,2,c1,1,4,2,0.002);
622  plot("norm",12,2,c2,1,4,2,0.002);
623  plot("norm",12,3,c2,1,4,2,0.002);
624  plot("norm",12,4,c2,1,4,2,0.002);
625  plot("norm",12,5,c2,1,4,2,0.002);
626  plot("norm",12,15,c2,1,4,2,0.002);
627  plot("norm",12,16,c2,1,4,2,0.002);
628  }
629  if(plt==103 || plt==0){
630  plot("norm",11,2,c1,1,5,3,0.0005);
631  plot("norm",12,2,c2,1,5,3,0.0005);
632  plot("norm",12,3,c2,1,5,3,0.0005);
633  plot("norm",12,4,c2,1,5,3,0.0005);
634  plot("norm",12,5,c2,1,5,3,0.0005);
635  plot("norm",12,15,c2,1,5,3,0.0005);
636  plot("norm",12,16,c2,1,5,3,0.0005);
637  }
638  if(plt==110 || plt==0){
639  plot("norm",11,2,c1,1,3,1,0.012);
640  plot("norm",11,6,c2,1,3,1,0.012);
641  plot("norm",12,2,c1,1,3,1,0.012);
642  plot("norm",12,6,c2,1,3,1,0.012);
643  plot("norm",15,2,c1,1,3,1,0.012);
644  plot("norm",15,6,c2,1,3,1,0.012);
645  plot("norm",11,2,c1,1,4,2,0.002);
646  plot("norm",11,6,c2,1,4,2,0.002);
647  plot("norm",12,2,c1,1,4,2,0.002);
648  plot("norm",12,6,c2,1,4,2,0.002);
649  plot("norm",15,2,c1,1,4,2,0.002);
650  plot("norm",15,6,c2,1,4,2,0.002);
651  }
652  if(plt==111 || plt==0){
653  plot("norm",11,12,c1,1,3,1,0.012);
654  plot("norm",11,13,c2,1,3,1,0.012);
655  plot("norm",15,12,c1,1,3,1,0.012);
656  plot("norm",15,13,c2,1,3,1,0.012);
657  plot("norm",12,12,c1,1,3,1,0.012);
658  plot("norm",12,13,c2,1,3,1,0.012);
659  plot("norm",11,12,c1,1,4,2,0.002);
660  plot("norm",11,13,c2,1,4,2,0.002);
661  plot("norm",15,12,c1,1,4,2,0.002);
662  plot("norm",15,13,c2,1,4,2,0.002);
663  plot("norm",12,12,c1,1,4,2,0.002);
664  plot("norm",12,13,c2,1,4,2,0.002);
665  }
666  if(plt==112 || plt==0){
667  plot("norm",11,9,c1,1,3,1,0.012);
668  plot("norm",11,10,c2,1,3,1,0.012);
669  plot("norm",11,11,c2,1,3,1,0.012);
670  plot("norm",12,9,c1,1,3,1,0.012);
671  plot("norm",12,10,c2,1,3,1,0.012);
672  plot("norm",12,11,c2,1,3,1,0.012);
673  }
674 
675 
676  if(plt==200){
677  bbc();
678  for(int c=0; c<NCUT; c++){
679  plot("mall",11,c,c1); plot("mall",12,c,c2);
680  plot("z12", 11,c,c1); plot("z12", 12,c,c2);
681  plot("norm",11,c,c1); plot("norm",12,c,c2);
682  }
683  }
684 }