Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
han_BUP2020.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file han_BUP2020.C
1 
2 #include <fstream>
3 #include <iostream>
4 #include "stdio.h"
5 
6 #include <TChain.h>
7 #include <TFile.h>
8 #include <TGraphAsymmErrors.h>
9 #include <TGraphErrors.h>
10 #include <TLatex.h>
11 #include <TLegend.h>
12 #include <TLine.h>
13 #include <TMath.h>
14 #include <TROOT.h>
15 #include <TString.h>
16 #include <TTree.h>
17 #include <TVectorD.h>
18 #include <TVirtualFitter.h>
19 #include <cassert>
20 #include <cmath>
21 #include <vector>
22 
23 #include "SaveCanvas.C"
24 #include "sPhenixStyle.C"
25 
26 const double pp_inelastic_crosssec = 42e-3; // 42 mb [sPH-TRG-000]
27 const double pp_rec_3year = 6.2e12; // BUP2020
28 const double pp_rec_5year = pp_rec_3year + 80e12; // BUP2020
29 const double pp_beam_pol = 0.57;
30 
31 TGraphErrors *GraphShiftScaling(TGraphErrors *gr_src, const double x_shift, const double err_scaling)
32 {
33  assert(gr_src);
34 
35  const int npoint = gr_src->GetN();
36 
37  TVectorD vx(npoint);
38  TVectorD vy(npoint);
39  TVectorD vex(npoint);
40  TVectorD vey(npoint);
41 
42  int nfilled = 0;
43  for (int i = 0; i < npoint; ++i)
44  {
45  const double &x = gr_src->GetX()[i];
46  // if (x<x_min or x>x_max) continue;
47 
48  vx[nfilled] = x + x_shift;
49  vy[nfilled] = gr_src->GetY()[i];
50  vex[nfilled] = gr_src->GetEX()[i];
51  vey[nfilled] = gr_src->GetEY()[i] * err_scaling;
52 
53  ++nfilled;
54  }
55 
56  TGraphErrors *gr = new TGraphErrors(nfilled, vx.GetMatrixArray(), vy.GetMatrixArray(),
57  vex.GetMatrixArray(), vey.GetMatrixArray());
58 
59  gr->SetMarkerColor(gr_src->GetMarkerColor());
60  gr->SetMarkerStyle(gr_src->GetMarkerStyle());
61  gr->SetMarkerSize(gr_src->GetMarkerSize());
62  gr->SetLineWidth(gr_src->GetLineWidth());
63  gr->SetLineColor(gr_src->GetLineColor());
64 
65  return gr;
66 }
67 
68 void draw_phenix(float an)
69 {
70  const int nn = 1;
71  float xx[nn] = {4.4};
72  float sx[nn] = {2.6};
73  float yy[nn] = {3.14e-2};
74  // float yy[nn] = {1e-2};
75  float sy[nn] = {0.37e-2};
76 
77  yy[0] = an;
78 
79  TGraphErrors *gr = new TGraphErrors(nn, xx, yy, sx, sy);
80  gr->SetFillColor(3);
81  gr->SetFillStyle(3001);
82  // gr->Draw("A2");
83  // gr->Draw("P");
84 
85  int icol = 29;
86  int iw = 10; // Line width
87  float wa = 0.025; // Arrow width
88  TArrow *arx = new TArrow(xx[0] - sx[0], yy[0], xx[0] + sx[0], yy[0], wa, "<|>");
89  arx->SetLineWidth(iw);
90  arx->SetLineColor(icol);
91  arx->SetFillColor(icol);
92  arx->Draw();
93 
94  TArrow *ary = new TArrow(xx[0], yy[0] - sy[0], xx[0], yy[0] + sy[0], wa, "<|>");
95  ary->SetLineWidth(iw);
96  ary->SetLineColor(icol);
97  ary->SetFillColor(icol);
98  ary->Draw();
99 }
100 
102 {
103  SetsPhenixStyle();
104 
105  const double ref_Lum = 10e12;
106  const double err_scale = sqrt(ref_Lum / pp_rec_3year);
107 
108  const int nxf = 20;
109  TFile *f = new TFile("han.root");
110  TGraphErrors *gan[nxf];
111 
112  const float dy = 0.01; // to plot different xF bins
113 
114  char hname[100];
115  for (int ix = 0; ix < nxf; ix++)
116  {
117  sprintf(hname, "gan%d", ix);
118  gan[ix] =
119  GraphShiftScaling((TGraphErrors *) f->Get(hname), 0, err_scale);
120  }
121 
122  // gStyle->SetOptStat(0);
123  TCanvas *c1 = new TCanvas("sphenix_han", "sphenix_han", 1100, 800);
124  // c3->Range(0,0,1,1);
125  // pad31 = new TPad("pad31","This is pad1",0.0,0.0,1.0,1.0);
126  // pad31->Draw();
127  c1->Divide(1, 1);
128  int idx = 1;
129  TPad *p;
130 
131  p = (TPad *) c1->cd(idx++);
132  c1->Update();
133 
134  p->DrawFrame(0, -0., 12, 0.065)->SetTitle(";#it{p}_{T} [GeV];A_{N}");
135 
136  // TH1F* h = new TH1F("h"," ",10,0,11);
137  // // h->SetTitle("#pi^{+} #delta(A_{N}) proj.");
138  // h->SetYTitle("A_{N}");
139  // h->SetXTitle("p_{T} (GeV/c)");
140  // h->SetMinimum(0.);
141  // h->SetMaximum(0.053);
142 
143  // pad31->cd();
144  // h->Draw();
145  draw_phenix(0.025);
146  TLatex *tex = new TLatex();
147  tex->SetTextSize(0.035);
148  char str[100];
149  float xfbin = 1. / float(nxf);
150  for (int i = 1; i <= 4; i++)
151  {
152  gan[i]->SetMarkerStyle(20);
153  gan[i]->SetMarkerColor(kRed + 1);
154  gan[i]->SetLineColor(kRed + 1);
155  gan[i]->SetMarkerSize(2);
156  gan[i]->SetLineWidth(4);
157 
158  gan[i]->Draw("P");
159  sprintf(str, "x_{F}=%4.2f-%4.2f", xfbin * i, xfbin * (i + 1));
160  tex->DrawLatex(9.5, dy * i - 0.0003, str);
161  }
162 
163  // tex->DrawLatex(0.4, 0.048, "sPHENIX:");
164  // tex->DrawLatex(0.4, 0.044, "p+p, #sqrt{s}=200 GeV");
165  // tex->DrawLatex(0.4, 0.040, "L=10/pb P=0.57");
166 // tex->DrawLatex(0.4,0.0265,"0<#eta<3");
167  tex->DrawLatex(0.4, 0.0025, "Shown only points with #delta(A_{N}) <~ 1%");
168 
169  TLegend *leg = new TLegend(.0, .75, .83, .9);
170  leg->SetFillStyle(0);
171  // leg->AddEntry("", "#it{#bf{sPHENIX}} Projection", "");
172  leg->AddEntry("", Form("#it{#bf{sPHENIX}} Projection, Years 1-3"), "");
173  leg->AddEntry("", Form("%.1f pb^{-1} str. #it{p}^{#uparrow}+#it{p}#rightarrow h^{+} + X, P=%.2f", pp_rec_3year / 1e12, pp_beam_pol), "");
174  leg->Draw();
175 
176  SaveCanvas(c1, TString(c1->GetName()), kTRUE);
177  // c1->SaveAs("AN_dp_sPHENIX.pdf");
178 }