StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
plWAL_APS.C
1 const int mxTheo=4, mxPN=2;
2 TString theoNameA[mxTheo]={"dns_k", "dns_kkp","dssv08","dssv08/mrst02"};
3 TString pnS[mxPN]={"+","-"};
4 TString pnL[mxPN]={"p","n"};
5 TH1F *hTheoA[mxPN][mxTheo];
6 int theoCol[mxTheo]={kBlue,kRed, 8,kMagenta};
7 TGraphErrors *grP[mxPN]; // STAR data point(s)
8 TString iPath="asyWALfinalAPS/";
9 
10 int justTheo=0; // defalut=0: show theory& data, 2 theory w/ sacel error
11 
12 void plWAL_APS() {
13  gStyle->SetOptStat(0);
14 
15 
16  c=new TCanvas("aa","aa",500,700);
17  c->SetFillColor(kWhite); c->SetFrameBorderMode(0);
18  gPad->SetLeftMargin(0.10); gPad->SetRightMargin(0.05);
19 
20  h0=new TH1F("bb", "; lepton #eta ",10,-2,2);
21  h0->SetMaximum(0.59); h0->SetMinimum(-0.59);h0->Draw();
22  h0->GetXaxis()->SetNdivisions(5); h0->GetXaxis()->SetTickLength(0.02);
23  if(justTheo){
24  ln=new TLine(-1,-0.59,-1,0.3); ln->Draw(); ln->SetLineStyle(3);
25  ln=new TLine(1,-0.59,1,0.4); ln->Draw(); ln->SetLineStyle(3);
26  }
27  uploadData();
28 
29 
30  uploadTheoryRhicbos();
31  uploadTheoryDeFlor();
32  plotTheory();
33  if(!justTheo) plotSysErr();
34  if(!justTheo) plotData();
35  plotMiscText();
36 
37 }
38 
39 
40 //====================================================
41 //====================================================
42 //====================================================
43 
44 void plotMiscText() {
45 
46  // STAR description
47  float x0=0.14, y0=0.86;
48  tlx=new TLatex(x0,y0,"STAR Preliminary Run9 #sqrt{s}=500 GeV"); tlx->SetNDC(); tlx->SetTextSize(0.048);
49  if(!justTheo) tlx->Draw();
50 
51  tlx=new TLatex(x0+0.05,y0-0.05,"#vec{p}+p #rightarrow W^{#\pm} #rightarrow e^{#\pm} + #nu"); tlx->Draw(); tlx->SetNDC(); tlx->SetTextSize(0.05);
52 
53  tlx=new TLatex(x0+0.05,y0-0.1,"E_{T}^{e} >25 GeV"); tlx->Draw(); tlx->SetNDC(); tlx->SetTextSize(0.045);
54 
55  // Ws labels
56  tlx=new TLatex(0.4,0.68,"W^{ -}"); tlx->Draw(); tlx->SetNDC(); tlx->SetTextSize(0.06);
57  tlx=new TLatex(0.4,0.22,"W^{+}"); tlx->Draw(); tlx->SetNDC(); tlx->SetTextSize(0.06);
58 
59  // Yaxis labels
60  tlx=new TLatex(0.025,.85,"A_{L}"); tlx->Draw(); tlx->SetNDC(); tlx->SetTextSize(0.06);
61 
62  // Yaxis labels
63  tlx=new TLatex(0.73,.53,"A_{L}= #frac{#sigma_{+} - #sigma_{-}}{#sigma_{+} + #sigma_{-}}"); tlx->Draw(); tlx->SetNDC(); tlx->SetTextSize(0.04);
64 
65 
66 
67  //........
68  if(justTheo==2) {
69  TLatex *lat3 = new TLatex(0.25,0.87,"Theory scaled by #pm 4.7%, #sqrt{s}=500 GeV");
70  lat3->SetNDC(); lat3->Draw("same"); lat3->SetTextSize(0.035); lat3->SetTextColor(12);
71  }
72 
73  return; // no printing date
74  TDatime dt;
75  tx=new TText(-2,-0.72,dt.AsString()); tx->SetTextSize(0.035);
76  if(!justTheo) tx->Draw();
77 }
78 
79 //---------------------------------------------------
80 //---------------------------------------------------
81 //---------------------------------------------------
82 
83 
84 void plotTheory() {
85 
86  float x0=0.68, y0=0.46;
87  tlx=new TLatex(x0,y0,"W- W+ RHICBOS"); tlx->Draw(); tlx->SetNDC(); tlx->SetTextSize(0.03);
88  TLegend *thLg[mxPN*2];
89  float x,y,dy=0.117;
90  x=x0+0.06; y=y0-0.08;
91  thLg[0]=new TLegend(x,y,x+0.27,y+0.07);
92  thLg[2]=new TLegend(x,y0-dy,x+0.27,y0-dy); //deFlor W+
93  x=x-0.07; thLg[1]=new TLegend(x,y,x+0.27,y+0.07);
94  thLg[3]=new TLegend(x,y0-dy,x+0.27,y0-dy); //deFlor W-
95 
96  for( int iPN=0; iPN<mxPN*2;iPN++) {
97  TLegend *lg=thLg[iPN];
98  lg->SetFillColor(kWhite);lg->SetLineColor(kWhite); lg->SetTextSize(0.03);
99  }
100 
101  char *theoL[mxTheo]={"DNS-K","DNS-KKP","DSSV08","DSSV08"};
102  for( int iPN=0; iPN<mxPN;iPN++) {
103  for (int ith=0;ith<mxTheo; ith++){
104  TH1F *hTheo=hTheoA[iPN][ith];
105  if(justTheo==2) plotOneBandTheory(hTheo,ith);// add scaling of theory
106  hTheo->Draw("same");
107  int ko=0; if(ith==3) ko=2;
108  if(iPN==0)
109  thLg[iPN+ko]->AddEntry(hTheo,theoL[ith],"l");
110  else
111  thLg[iPN+ko]->AddEntry(hTheo," ","l");
112  // break;
113  }
114  gPad->SetGrid(0,0);
115  }
116  thLg[1]->Draw();
117  thLg[0]->Draw();
118  thLg[3]->Draw();
119  thLg[2]->Draw();
120  tlx=new TLatex(x0,y0-dy+0.015," deFlorian & Vogelsang"); tlx->Draw(); tlx->SetNDC(); tlx->SetTextSize(0.025);
121 
122  // fix the right edge
123  ln=new TLine(2,-0.4,2,0); ln->Draw();
124  // add box for legende
125  tb=new TBox(0.62,-0.26,1.96,-0.01); tb->Draw();
126  tb->SetFillStyle(0); tb->SetLineColor(12);
127 
128 }
129 
130 //---------------------------------------------------
131 //---------------------------------------------------
132 //---------------------------------------------------
133 void uploadData() {
134 // read data
135 
136  TString inpCore="run9setP1234";
137  TString fullInpName=iPath; fullInpName+=inpCore;
138  fullInpName+=".wasy.hist.root";
139  fdd=new TFile(fullInpName);
140  if(! fdd->IsOpen()) {
141  printf("EROR: input histo file not found, quit\n",fullInpName.Data());
142  return;
143  } else {
144  printf("Opened: %s\n",fullInpName.Data());
145  }
146 
147 
148  for(int iq=0;iq<mxPN;iq++) {
149  TGraphErrors *gr=new TGraphErrors;
150  gr->SetMarkerStyle(21-iq);
151  gr->SetMarkerSize(1.5);
152  gr->SetMarkerColor(kBlack);
153  gr->SetLineWidth(3);
154  gr->SetLineColor(kBlack);
155 
156  char *tt1="hAsyP";
157  if(iq==1) tt1="hAsyN";
158  TH1F *hAsy=(TH1F *)fdd->Get(tt1); assert( hAsy);
159 
160  double asy=hAsy->GetBinContent(3);
161  double asyEr=hAsy->GetBinError(3);
162  printf("W %s AL=%.3f +/- %.3f nSig=%.1f\n", pnS[iq].Data(),asy,asyEr,asy/asyEr);
163  gr->Clear();
164  gr->SetPoint(0,0,asy);
165  gr->SetPointError(0,1.,asyEr);
166 
167  grP[iq]=gr;
168 
169  }
170 }
171 
172 //---------------------------------------------------
173 //---------------------------------------------------
174 //---------------------------------------------------
175 void plotData(){
176 
177  for(int iq=0;iq<mxPN;iq++) {
178  grP[iq]->Draw("p");
179 
180  }
181 
182 
183 
184 }
185 //---------------------------------------------------
186 //---------------------------------------------------
187 //---------------------------------------------------
188 void plotSysErr() {
189 
190 
191  float dx=0.08;
192  for(int iq=0;iq<mxPN;iq++) {
193  float x=grP[iq]->GetX()[0];
194  float y=grP[iq]->GetY()[0];
195 
196 
197  float facYup=0.89, facYdw=1.13; // W+ , hardcoded
198  if(iq==1) facYup=1.21, facYdw=0.83; // W- , hardcoded
199 
200  bx=new TBox(x-dx,y*facYdw,x+dx,y*facYup);
201  bx->Draw(); bx->SetFillColor(kBlack);
202  bx->SetFillStyle(3001);
203  }
204 
205  float x0=-1.8,y0=-0.57;
206  bx=new TBox(x0,y0,x0+2*dx,y0+0.08);
207  bx->Draw(); bx->SetFillColor(kBlack);
208  bx->SetFillStyle(3001);
209  tlx=new TLatex(x0+0.2,y0+.045,"Syst. uncertainty due to abs. "); tlx->Draw(); tlx->SetTextSize(0.03);
210  tlx=new TLatex(x0+0.2,y0+.01,"polarization and background"); tlx->Draw(); tlx->SetTextSize(0.03);
211 
212 }
213 
214 //---------------------------------------------------
215 //---------------------------------------------------
216 //---------------------------------------------------
217 
218 
219 
220 //======================
221 void uploadTheoryRhicbos(){
222  for( int iPN=0; iPN<mxPN;iPN++) {
223  TString nameUn="rb400_w"+pnL[iPN]+"_unp_ct5m_pt25.root";
224  funp=new TFile( iPath+nameUn); assert(funp->IsOpen());
225  hunp= (TH1F*)funp->Get("h3"); assert(hunp);
226 
227 
228  for (int ith=0;ith<mxTheo-1; ith++){
229  TString namePol="rb400_w"+pnL[iPN]+"_pol_"+theoNameA[ith]+"_pt25.root";
230 
231  fpol=new TFile( iPath+namePol); assert(fpol->IsOpen());
232  TH1F* hpol=(TH1F*) fpol->Get("h3"); assert(hpol);
233 
234  hal=(TH1F*) hpol->Clone();
235  hal->Divide(hunp);
236  TString hName="w"+pnL[iPN]+"_"+theoNameA[ith];
237  TString hTitle="W"+pnS[iPN]+" "+theoNameA[ith]+"; lepton #eta";
238 
239  hal->SetNameTitle(hName,hTitle);
240 
241 
242  hTheoA[iPN][ith]=hal;
243  hal->SetLineColor( theoCol[ith]);
244  if(iPN) hal->SetLineStyle(2);
245  hal->SetLineWidth(2);
246 
247 
248  continue;
249 
250  c=new TCanvas();
251  c->Divide(2,2);
252  c->cd(1);hunp->Draw();
253  c->cd(2);hpol->Draw();
254 
255  c->cd(3);hal->Draw(); hal->SetLineColor(kRed);;
256  hal->SetMaximum(0.6); hal->SetMinimum(-0.6);
257 
258  }
259  }
260  return;
261 }
262 
263 
264 
265 
266 //======================
267 void uploadTheoryDeFlor(){
268  for( int iPN=0; iPN<mxPN;iPN++) {
269  TString nameUn="deFlor_w"+pnL[iPN]+"_unp_mrst02_pt25_full.root";
270  funp=new TFile( iPath+nameUn); assert(funp->IsOpen());
271  hunp= (TH1F*)funp->Get("h3"); assert(hunp);
272 
273  char * theoName="dssv08";
274  int ith=mxTheo-1;
275  TString namePol="deFlor_w"+pnL[iPN]+"_pol_"+theoName+"_pt25_full.root";
276  fpol=new TFile( iPath+namePol); assert(fpol->IsOpen());
277  TH1F* hpol=(TH1F*) fpol->Get("h3"); assert(hpol);
278 
279  hal=(TH1F*) hpol->Clone();
280  hal->Divide(hunp);
281  TString hName="w"+pnL[iPN]+"_deFlor_dssv";
282  TString hTitle="W"+pnS[iPN]+" deFlor dssv; lepton #eta";
283 
284  hal->SetNameTitle(hName,hTitle);
285 
286 
287  hTheoA[iPN][ith]=hal;
288  hal->SetLineColor( theoCol[ith]);
289  if(iPN) hal->SetLineStyle(2);
290  hal->SetLineWidth(2);
291  // hal->Draw(); break;
292  }
293 }
294 
295 
296 //---------------------------------------------------
297 //---------------------------------------------------
298 //---------------------------------------------------
299 
300 
301 void plotOneBandTheory(TH1F*hIn , int it) {
302  //if(iq)return;
303  float sysErr=.047;
304  for(int ib=0;ib<2;ib++){
305  TH1F * hu=(TH1F*) hIn->Clone();
306  // hu->SetLineColor(0);
307  hu->Draw("same e3");
308  TAxis *ax=hu->GetXaxis();
309  for(ib=1;ib<=ax->GetNbins();ib++){
310  float y= hu->GetBinContent(ib);
311  hu->SetBinError(ib,y*sysErr);
312  }
313  hu->SetFillStyle(3003+it);
314 
315  hu->SetFillColor( hu->GetLineColor());
316  }
317 }
318 /*
319 ln -s ../Prelim/ct5m/histo/rb400.w+unp_ct5m.ye.-1.1.pte25.rz rb400_wp_unp_ct5m_y1_pt25.rz
320 ln -s ../Prelim/dssv08/histo/rb400.w+pola_dssv08.ye.-1.1.pte25.rz rb400_wp_pol_dssv08_y1_pt25.rz
321 */