File indexing completed on 2025-08-05 08:10:54
0001
0002 #include <fstream>
0003 #include <iostream>
0004 #include "stdio.h"
0005
0006 #include <TChain.h>
0007 #include <TFile.h>
0008 #include <TGraphAsymmErrors.h>
0009 #include <TGraphErrors.h>
0010 #include <TLatex.h>
0011 #include <TLegend.h>
0012 #include <TLine.h>
0013 #include <TMath.h>
0014 #include <TROOT.h>
0015 #include <TString.h>
0016 #include <TTree.h>
0017 #include <TVectorD.h>
0018 #include <TVirtualFitter.h>
0019 #include <cassert>
0020 #include <cmath>
0021 #include <vector>
0022
0023 #include "SaveCanvas.C"
0024 #include "sPhenixStyle.C"
0025
0026 const double pp_inelastic_crosssec = 42e-3;
0027 const double pp_rec_3year = 6.2e12;
0028 const double pp_rec_5year = pp_rec_3year + 80e12;
0029 const double pp_beam_pol = 0.57;
0030
0031 TGraphErrors *GraphShiftScaling(TGraphErrors *gr_src, const double x_shift, const double err_scaling)
0032 {
0033 assert(gr_src);
0034
0035 const int npoint = gr_src->GetN();
0036
0037 TVectorD vx(npoint);
0038 TVectorD vy(npoint);
0039 TVectorD vex(npoint);
0040 TVectorD vey(npoint);
0041
0042 int nfilled = 0;
0043 for (int i = 0; i < npoint; ++i)
0044 {
0045 const double &x = gr_src->GetX()[i];
0046
0047
0048 vx[nfilled] = x + x_shift;
0049 vy[nfilled] = gr_src->GetY()[i];
0050 vex[nfilled] = gr_src->GetEX()[i];
0051 vey[nfilled] = gr_src->GetEY()[i] * err_scaling;
0052
0053 ++nfilled;
0054 }
0055
0056 TGraphErrors *gr = new TGraphErrors(nfilled, vx.GetMatrixArray(), vy.GetMatrixArray(),
0057 vex.GetMatrixArray(), vey.GetMatrixArray());
0058
0059 gr->SetMarkerColor(gr_src->GetMarkerColor());
0060 gr->SetMarkerStyle(gr_src->GetMarkerStyle());
0061 gr->SetMarkerSize(gr_src->GetMarkerSize());
0062 gr->SetLineWidth(gr_src->GetLineWidth());
0063 gr->SetLineColor(gr_src->GetLineColor());
0064
0065 return gr;
0066 }
0067
0068 void draw_phenix(float an)
0069 {
0070 const int nn = 1;
0071 float xx[nn] = {4.4};
0072 float sx[nn] = {2.6};
0073 float yy[nn] = {3.14e-2};
0074
0075 float sy[nn] = {0.37e-2};
0076
0077 yy[0] = an;
0078
0079 TGraphErrors *gr = new TGraphErrors(nn, xx, yy, sx, sy);
0080 gr->SetFillColor(3);
0081 gr->SetFillStyle(3001);
0082
0083
0084
0085 int icol = 29;
0086 int iw = 10;
0087 float wa = 0.025;
0088 TArrow *arx = new TArrow(xx[0] - sx[0], yy[0], xx[0] + sx[0], yy[0], wa, "<|>");
0089 arx->SetLineWidth(iw);
0090 arx->SetLineColor(icol);
0091 arx->SetFillColor(icol);
0092 arx->Draw();
0093
0094 TArrow *ary = new TArrow(xx[0], yy[0] - sy[0], xx[0], yy[0] + sy[0], wa, "<|>");
0095 ary->SetLineWidth(iw);
0096 ary->SetLineColor(icol);
0097 ary->SetFillColor(icol);
0098 ary->Draw();
0099 }
0100
0101 void han_BUP2020()
0102 {
0103 SetsPhenixStyle();
0104
0105 const double ref_Lum = 10e12;
0106 const double err_scale = sqrt(ref_Lum / pp_rec_3year);
0107
0108 const int nxf = 20;
0109 TFile *f = new TFile("han.root");
0110 TGraphErrors *gan[nxf];
0111
0112 const float dy = 0.01;
0113
0114 char hname[100];
0115 for (int ix = 0; ix < nxf; ix++)
0116 {
0117 sprintf(hname, "gan%d", ix);
0118 gan[ix] =
0119 GraphShiftScaling((TGraphErrors *) f->Get(hname), 0, err_scale);
0120 }
0121
0122
0123 TCanvas *c1 = new TCanvas("sphenix_han", "sphenix_han", 1100, 800);
0124
0125
0126
0127 c1->Divide(1, 1);
0128 int idx = 1;
0129 TPad *p;
0130
0131 p = (TPad *) c1->cd(idx++);
0132 c1->Update();
0133
0134 p->DrawFrame(0, -0., 12, 0.065)->SetTitle(";#it{p}_{T} [GeV];A_{N}");
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145 draw_phenix(0.025);
0146 TLatex *tex = new TLatex();
0147 tex->SetTextSize(0.035);
0148 char str[100];
0149 float xfbin = 1. / float(nxf);
0150 for (int i = 1; i <= 4; i++)
0151 {
0152 gan[i]->SetMarkerStyle(20);
0153 gan[i]->SetMarkerColor(kRed + 1);
0154 gan[i]->SetLineColor(kRed + 1);
0155 gan[i]->SetMarkerSize(2);
0156 gan[i]->SetLineWidth(4);
0157
0158 gan[i]->Draw("P");
0159 sprintf(str, "x_{F}=%4.2f-%4.2f", xfbin * i, xfbin * (i + 1));
0160 tex->DrawLatex(9.5, dy * i - 0.0003, str);
0161 }
0162
0163
0164
0165
0166
0167 tex->DrawLatex(0.4, 0.0025, "Shown only points with #delta(A_{N}) <~ 1%");
0168
0169 TLegend *leg = new TLegend(.0, .75, .83, .9);
0170 leg->SetFillStyle(0);
0171
0172 leg->AddEntry("", Form("#it{#bf{sPHENIX}} Projection, Years 1-3"), "");
0173 leg->AddEntry("", Form("%.1f pb^{-1} str. #it{p}^{#uparrow}+#it{p}#rightarrow h^{+} + X, P=%.2f", pp_rec_3year / 1e12, pp_beam_pol), "");
0174 leg->Draw();
0175
0176 SaveCanvas(c1, TString(c1->GetName()), kTRUE);
0177
0178 }