StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
prd2009xsec.C
1 //init W info and data points
2 const int mxQ=2; // iQ=0=W+, iQ=1=W-
3 const int mxD=4, mxEr=4; // stat, +sys, -sys, lumi
4 float errA[mxD][mxQ][mxEr]={{{5.95,5.93,-5.97.,15.09}{3.46,2.97,-3.07,4.09}},{{21.2,3.4,10.3,21.6}{12.1,10.1,8.2,4.8}},{{260,480,480,690}{220,330,330,470}},{{60,170,170,640}{50,140,140,450}}};
5 float crossA[mxD][mxQ]={{116.05,42.36},{144.1,31.7},{6270,4230},{5860,4090}};
6 //order of x-sec and err is STAR(e), Phenix(e), Atlas(l), CMS(l), CDF(l,1.8), CDF(l,1.96), D0(l,1.8), D0(l,1.96), UA1(l), UA2(e)
7 
8 const int mxColl=2; // pp and ppbar
9 const int mxPt=80; //number of points for curve
10 float theory[mxColl][mxQ][mxPt];
11 TH1F *hBase;
12 TGraphAsymmErrors *grD[mxQ][mxD]; //theory graph*grEx[mxQ][mx];
13 TGraph *grT[mxQ][mxColl];
14 
15 
16 //init Z info and data points
17 const int mxDZ=3, mxErZ=4; // stat, +sys, -sys, lumi
18 float errZ[mxDZ][mxErZ]={{2.14,0.50,-0.50,1.01},{60,50,50,90},{40,60,60,110}};
19 float crossZ[mxDZ]={7.73,820,930};
20 float theoryZ[mxColl][mxPt];
21 TH1F *hBaseZ;
22 TGraphAsymmErrors *grDZ[mxD];
23 TGraph *grTZ[mxColl];
24 
25 bool colorPlot;
26 
27 void prd2009xsec(bool x=false, float canvasScale=1.0){
28 
29  theoryPoints();
30 
31  colorPlot=x;
32 
33  //canvas for plotting
34  TCanvas *c=new TCanvas("aa","bb",500*canvasScale,500*canvasScale);
35 
36  TPad *cT = new TPad("padT","padT",0,0.5,1.,1.); cT->Draw();
37  TPad *cB = new TPad("padB","padB",0,0,1.,0.5); cB->Draw();
38  cT->cd();
39  prd2009Wxsec();
40  cB->cd();
41  prd2009Zxsec();
42 
43  if(colorPlot) {
44  c->Print("/star/u/stevens4/wAnalysis/xSecPaper/plots/color/xsecBRcolor.png");
45  c->Print("/star/u/stevens4/wAnalysis/xSecPaper/plots/color/xsecBRcolor.eps");
46  }
47  else {
48  c->Print("/star/u/stevens4/wAnalysis/xSecPaper/plots/bw/xsecBRbw.png");
49  c->Print("/star/u/stevens4/wAnalysis/xSecPaper/plots/bw/xsecBRbw.eps");
50  }
51 
52  return;
53 }
54 
55 void prd2009Wxsec() {
56  gStyle->SetOptStat(0);
57  gStyle->SetOptDate(0);
58  initData();
59  initTheory();
60 
61  //set up pad
62  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.0);
63  gPad->SetLeftMargin(0.1); gPad->SetRightMargin(0.03);
64  gPad->SetGridy(false); gPad->SetGridx(false);
65  gPad->SetLogy(); gPad->SetLogx();
66  initHisto();
67  hBase->GetYaxis()->SetTitleOffset(0.6);
68  hBase->GetYaxis()->CenterTitle();
69  hBase->GetYaxis()->SetTitleSize(0.07);
70  hBase->GetYaxis()->SetLabelSize(0.06);
71  hBase->SetMinimum(8.0); hBase->SetMaximum(2e4);
72 
73  hBase->Draw();
74  for(int iq=0; iq<mxQ;iq++) {
75  drawTheo(iq);
76  drawData(iq);
77  }
78 
79  //make legend
80  TLegend *leg;
81  leg=new TLegend(0.7,0.2,0.95,0.5);
82  leg->SetNColumns(2);
83  //leg->SetColumnSeparation(0.01);
84  leg->SetEntrySeparation(0.01);
85  leg->SetMargin(0.2);
86  leg->SetFillColor(kWhite);
87  leg->SetLineColor(kWhite);
88  leg->SetTextSize(0.05);
89  leg->AddEntry(grD[0][0]," UA1","pl");
90  leg->AddEntry(grD[0][0]," STAR","pl");
91  leg->AddEntry(grD[0][0]," UA2","pl");
92  leg->AddEntry(grD[0][1]," Phenix","pl");
93  leg->AddEntry(grD[0][0]," CDF","pl");
94  leg->AddEntry(grD[0][2]," Atlas","pl");
95  leg->AddEntry(grD[0][0]," D0","pl");
96  leg->AddEntry(grD[0][3]," CMS","pl");
97  leg->Draw("same");
98 
99  return;
100 
101 }
102 
103 //------------------------------
104 void initHisto() {
105  char *txt0="hW";
106  hBase=new TH1F(txt0, "; #sqrt{s} (GeV); #sigma_{W} #upoint BR(W #rightarrow l #nu) (pb) ", 100, 350,12000);
107 }
108 
109 
110 //----------------------
111 void initData() {
112  float offset[mxD]={-10,10,-250,250};
113  float style[mxD][mxQ]={{29,30},{22,26},{20,24},{21,25}};
114  float color[mxD]={kRed,kBlue,kGreen,kOrange};
115  float size[mxD]={1.2,1.0,1.0,1.0};
116  float roots[mxD]={500,500,7000,7000};
117  for(int iq=0; iq<mxQ;iq++)
118  for(int id=0;id<mxD; id++) {
119  TGraphAsymmErrors *gr=new TGraphAsymmErrors;
120  gr->SetMarkerStyle(style[id][iq]);
121  if(colorPlot) gr->SetMarkerColor(color[id]);
122  gr->SetMarkerSize(size[id]);
123  gr->SetLineWidth(1);
124  gr->SetPoint(0,roots[id]+offset[id],crossA[id][iq]);
125  float a=errA[id][iq][0]; // stat
126  float b=errA[id][iq][1]; // +sys
127  float c=errA[id][iq][2]; // -sys
128  float d=errA[id][iq][3]; // lumi
129  float yu=sqrt(a*a+b*b+d*d);
130  float yd=sqrt(a*a+c*c+d*d);
131  gr->SetPointError(0,0,0,yd,yu);
132  grD[iq][id]=gr;
133  }
134 }
135 
136 
137 //---------------------
138 void drawData(int iq) {
139  for(int id=mxD-1;id>=0; id--) {
140  grD[iq][id]->Draw("e p z same");
141  //grD[iq][id]->Print();
142  }
143 }
144 
145 //----------------------
146 void initTheory() {
147  float xPt[mxPt];
148  for(int j=0; j<mxPt; j++)
149  xPt[j]=100+j*100;
150 
151  int style[mxColl][mxQ]={{1,7},{3,3}};
152  for(int icoll=0; icoll<mxColl; icoll++){
153  for(int iq=0; iq<mxQ;iq++) {
154  TGraph *gr=new TGraph;
155  //gr->SetMarkerColor(color[tb]);
156  gr->SetLineWidth(1);
157  gr->SetLineStyle(style[icoll][iq]);
158  gr->SetMarkerSize(0);
159  for(int i=0; i<mxPt; i++){
160  if(icoll==0) gr->SetPoint(i,xPt[i],theory[icoll][iq][i]);
161  else gr->SetPoint(i,xPt[i],2.*theory[icoll][iq][i]);
162  }
163  grT[iq][icoll]=gr;
164  }
165  }
166 }
167 
168 //---------------------
169 void drawTheo(int iq) {
170  for(int id=0;id<mxColl;id++) {
171  if(id==1 && iq==1) continue;
172  grT[iq][id]->Draw("p c same");
173  //cout<<"draw W theory "<<id<<" "<<iq<<endl;
174  //grT[iq][id]->Print();
175  }
176 }
177 
178 
179 //plot Z x-sec
180 void prd2009Zxsec() {
181 
182  initDataZ();
183  initTheoryZ();
184 
185  //set up pad
186  gPad->SetTopMargin(0.0); gPad->SetBottomMargin(0.15);
187  gPad->SetLeftMargin(0.1); gPad->SetRightMargin(0.03);
188  gPad->SetGridy(false); gPad->SetGridx(false);
189  gPad->SetLogy(); gPad->SetLogx();
190  initHistoZ();
191  hBaseZ->GetXaxis()->SetTitleOffset(0.9);
192  hBaseZ->GetXaxis()->CenterTitle();
193  hBaseZ->GetXaxis()->SetTitleSize(0.07);
194  hBaseZ->GetXaxis()->SetLabelSize(0.06);
195  hBaseZ->GetYaxis()->SetTitleOffset(0.6);
196  hBaseZ->GetYaxis()->CenterTitle();
197  hBaseZ->GetYaxis()->SetTitleSize(0.07);
198  hBaseZ->GetYaxis()->SetLabelSize(0.06);
199 
200  hBaseZ->SetMinimum(1.0); hBaseZ->SetMaximum(2500);
201  hBaseZ->Draw();
202  drawTheoZ();
203  drawDataZ();
204 
205  //make legend
206 
207  TLegend *leg;
208  leg=new TLegend(0.6,0.3,0.95,0.6);
209  leg->SetNColumns(2);
210  leg->SetEntrySeparation(0.01);
211  leg->SetMargin(0.2);
212  leg->SetFillColor(kWhite);
213  leg->SetLineColor(kWhite);
214  leg->SetTextSize(0.05);
215  leg->SetHeader(" FEWZ and MSTW08 NLO PDFs");
216  leg->AddEntry(grT[0][0]," p+p #rightarrow W^{+}","l");
217  leg->AddEntry(grTZ[0]," p+p #rightarrow Z/#gamma*","l");
218  leg->AddEntry(grT[1][0]," p+p #rightarrow W^{-}","l");
219  leg->AddEntry(grTZ[1]," p+#bar{p} #rightarrow Z/#gamma*","l");
220  leg->AddEntry(grT[0][1]," p+#bar{p} #rightarrow W^{+/-}","l");
221  leg->Draw("same");
222 
223  return;
224 }
225 
226 //------------------------------
227 void initHistoZ() {
228  char *txt0="hZ";
229  hBaseZ=new TH1F(txt0, "; #sqrt{s} (GeV); #sigma_{Z/#gamma*} #upoint BR(Z/#gamma* #rightarrow ll) (pb) ", 100, 350,12000);
230 }
231 
232 
233 //----------------------
234 void initDataZ() {
235  float offset[mxDZ]={0,-250,250};
236  float style[mxDZ]={29,20,21};
237  float color[mxDZ]={kRed,kGreen,kOrange};
238  float roots[mxDZ]={500,7000,7000};
239  for(int id=0;id<mxDZ; id++) {
240  TGraphAsymmErrors *gr=new TGraphAsymmErrors;
241  gr->SetMarkerStyle(style[id]);
242  if(colorPlot) gr->SetMarkerColor(color[id]);
243  gr->SetMarkerSize(1.0);
244  gr->SetLineWidth(1);
245  gr->SetPoint(0,roots[id]+offset[id],crossZ[id]);
246  float a=errZ[id][0]; // stat
247  float b=errZ[id][1]; // +sys
248  float c=errZ[id][2]; // -sys
249  float d=errZ[id][3]; // lumi
250  float yu=sqrt(a*a+b*b+d*d);
251  float yd=sqrt(a*a+c*c+d*d);
252  gr->SetPointError(0,0,0,yd,yu);
253  grDZ[id]=gr;
254  }
255 }
256 
257 
258 //---------------------
259 void drawDataZ() {
260  for(int id=mxDZ-1;id>=0; id--) {
261  grDZ[id]->Draw("p e z same");
262  //grDZ[id]->Print();
263  }
264 }
265 
266 
267 //----------------------
268 void initTheoryZ() {
269  float xPt[mxPt];
270  for(int j=0; j<mxPt; j++)
271  xPt[j]=100+j*100;
272 
273  int style[mxColl]={1,3};
274  for(int icoll=0; icoll<mxColl; icoll++){
275  TGraph *gr=new TGraph;
276  //gr->SetMarkerColor(color[tb]);
277  gr->SetLineWidth(1);
278  gr->SetLineStyle(style[icoll]);
279  gr->SetMarkerSize(0);
280  for(int i=0; i<mxPt; i++){
281  if(icoll==0) gr->SetPoint(i,xPt[i],theoryZ[icoll][i]);
282  else gr->SetPoint(i,xPt[i],2.*theoryZ[icoll][i]);
283  grTZ[icoll]=gr;
284  }
285  }
286 }
287 
288 //---------------------
289 void drawTheoZ() {
290  for(int id=0;id<mxColl;id++) {
291  grTZ[id]->Draw("p c same");
292  //grTZ[id]->Print();
293  }
294 }
295 
296 
297 //---------------------
298 void theoryPoints() {
299  //read in theory points from csv viles
300  string path="/star/u/stevens4/wAnalysis/xSecPaper/plots/xSecBR/";
301  string names[6]={"ppWplusRoots.csv","ppWminusRoots.csv","ppbarWplusRoots.csv","ppbarWminusRoots.csv","ppZroots.csv","ppbarZroots.csv"};
302  int coll[6]={0,0,1,1,0,1};
303  int q[6]={0,1,0,1,2,2};
304  for(int ifile=0; ifile<6; ifile++){
305  ifstream file(Form("%s%s",path.data(),names[ifile].data()));
306  string line;
307 
308  int i=0;
309  while(file.good()){
310  getline (file,line);
311  if(line == ""){ //blank last line ie. end of file
312  break;
313  }
314  if(q[ifile]<2) theory[coll[ifile]][q[ifile]][i]=atof(line.data());
315  else theoryZ[coll[ifile]][i]=atof(line.data());
316  i++;
317  }
318  }
319 
320 }