StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
prd2009WxSecRatio.C
1 const int mxB=2; //eta bin
2 const int mxErr=3; // stat, +sys, -sys
3 float errA[mxB][mxErr]={{0.7,0.3,-0.3},{0.5,0.2,-0.2}};
4 float ratioA[mxB]={4.3,2.9};
5 
6 const int mxTh=2; //number theory points first is MSTW second is CTEQ
7 float theory[mxTh][mxB]={{4.790,2.949},{5.044,3.071}};
8 float theoryErr[mxTh][mxB]={{0.430,0.236},{0.404,0.227}};
9 //TString theoN[mxTh]={"#splitline{ RHICBOS}{CTEQ5M Resum.}","#splitline{ RHICBOS}{MRST02 Resum.}","#splitline{deFlorian, et al.}{ MRST02 NLO}"};
10 TH1F *hBase;
11 TGraphAsymmErrors *grD;
12 TGraphAsymmErrors *grT[mxTh];
13 TMultiGraph *mg;
14 
15 bool colorPlot;
16 
17 void prd2009WxSecRatio(bool x=false, float canvasScale=1.0) {
18 
19  colorPlot=x;
20 
21  gStyle->SetOptStat(0);
22  gStyle->SetOptDate(0);
23 
24  mg = new TMultiGraph();
25  initTheory();
26  initData();
27 
28  c=new TCanvas("aa","bb",500*canvasScale,300*canvasScale);
29  c->SetTopMargin(0.05); c->SetBottomMargin(0.13);
30  c->SetLeftMargin(0.085); c->SetRightMargin(0.02);
31  gPad->SetGridy(false); gPad->SetGridx(false);
32  if(!colorPlot) c->SetGrayscale();
33  initHisto();
34  hBase->GetXaxis()->SetRangeUser(0.,1.);
35  hBase->GetYaxis()->SetLabelColor(0);
36  hBase->GetYaxis()->SetTitleOffset(0.6);
37  hBase->GetYaxis()->SetTitleSize(0.06);
38  hBase->GetYaxis()->CenterTitle();
39  hBase->GetXaxis()->SetLabelColor(0);
40  hBase->GetXaxis()->SetTitleOffset(0.88);
41  hBase->GetXaxis()->SetTitleSize(0.06);
42  hBase->GetXaxis()->CenterTitle();
43  hBase->Draw();
44  drawTheo();
45  gPad->Modified();
46  mg->SetMinimum(0.001); mg->SetMaximum(5.8);
47  mg->Draw("2 same");
48  mg->GetXaxis()->SetLimits(0.,1.);
49  mg->GetXaxis()->SetNdivisions(5);
50  mg->GetXaxis()->SetLabelSize(0.05);
51  mg->GetXaxis()->SetRangeUser(0.0,1.0);
52  mg->GetYaxis()->SetTitleOffset(2.0);
53  mg->GetYaxis()->SetLabelSize(0.05);
54 
55  drawData();
56 
57  //make legend
58  TLegend *leg;
59  leg=new TLegend(0.15,0.25,0.5,0.5);
60  leg->SetMargin(0.2);
61  leg->SetFillColor(kWhite);
62  leg->SetLineColor(kWhite);
63  leg->SetTextSize(0.04);
64  leg->AddEntry(grD," STAR 2009 Data","pl");
65  leg->AddEntry(grT[0]," FEWZ NLO MSTW 2008","f");
66  leg->AddEntry(grT[1]," FEWZ NLO CTEQ 6.6 ","f");
67  leg->Draw("same");
68 
69  //insert text
70  //TLatex *lat0 = new TLatex(0.13,0.945,"Run 9 STAR #font[52]{p+p} #sqrt{#font[72]{s}}_{ }=_{ }500 GeV");
71  //lat0->SetNDC(); lat0->SetTextSize(0.04); lat0->Draw("same");
72 
73  if(colorPlot) {
74  c->Print("/star/u/stevens4/wAnalysis/xSecPaper/plots/color/xSecRatioColor.png");
75  c->Print("/star/u/stevens4/wAnalysis/xSecPaper/plots/color/xSecRatioColor.eps");
76  }
77  else {
78  c->Print("/star/u/stevens4/wAnalysis/xSecPaper/plots/bw/xSecRatioBW.png");
79  c->Print("/star/u/stevens4/wAnalysis/xSecPaper/plots/bw/xSecRatioBW.eps");
80  }
81 
82 }
83 
84 //------------------------------
85 void initHisto() {
86  char *txt0="h";
87  hBase=new TH1F(txt0, ";|#eta_{e}|; R_{W} ",2,0.,1.);
88 }
89 
90 
91 //----------------------
92 void initData() {
93  float binCenter[mxB]={0.25,0.75};
94  TGraphAsymmErrors *gr=new TGraphAsymmErrors;
95 
96  for(int id=0;id<mxB; id++) {
97  gr->SetMarkerStyle(20);
98  gr->SetMarkerColor(1);
99  gr->SetMarkerSize(1);
100  gr->SetLineWidth(1);
101  gr->SetLineColor(1);
102  gr->SetPoint(id,binCenter[id],ratioA[id]);
103  float a=errA[id][0]; // stat
104  float b=errA[id][1]; // +sys
105  float c=errA[id][2]; // -sys
106  float yu=sqrt(a*a+b*b);
107  float yd=sqrt(a*a+c*c);
108  gr->SetPointError(id,0.25,0.25,yd,yu);
109  }
110  grD=gr;
111 }
112 
113 
114 //---------------------
115 void drawData() {
116  cout<<"drawing data"<<endl;
117  grD->Draw("p e z same");
118 }
119 
120 
121 //put theory points here
122 //----------------------
123 void initTheory() {
124  int color[mxTh]={kBlue,kGreen};
125  for(int itheo=0; itheo<mxTh; itheo++){
126  float binCenter[mxB]={0.25,0.75};
127  TGraphAsymmErrors *gr=new TGraphAsymmErrors;
128  for(int id=0;id<mxB; id++) {
129  gr->SetFillColor(color[itheo]);
130  if(itheo==0) gr->SetFillStyle(3545);
131  else if(itheo==1) gr->SetFillStyle(3554);
132  gr->SetPoint(id,binCenter[id],theory[itheo][id]);
133  gr->SetPointError(id,0.25,0.25,theoryErr[itheo][id],theoryErr[itheo][id]);
134  }
135  grT[itheo]=gr;
136  }
137 }
138 
139 //---------------------
140 void drawTheo() {
141  for(int itheo=0;itheo<mxTh;itheo++) {
142  mg->Add(grT[itheo]);
143  //grT[itheo]->Print();
144  }
145 }
146