Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
AtlasExample.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphics
3/// \notebook -js
4/// \preview
5/// Show how ATLAS Style looks like. It is based on a style file from BaBar.
6///
7/// \macro_image
8/// \macro_code
9///
10/// \author M.Sutton
11
12const Int_t GMAX = 864;
13
14const int nren = 3;
15static const double mur[nren] = {1.0, 0.25, 4.0};
16static const double muf[nren] = {1.0, 0.25, 4.0};
17const unsigned int NUMPDF = 41;
18
22
23void AtlasExample()
24{
25 gROOT->SetStyle("ATLAS");
26
27 Int_t icol1 = 5;
28 Int_t icol2 = 5;
29
30 auto canvas = new TCanvas("canvas", "single inclusive jets", 50, 50, 600, 600);
31 canvas->SetLogy();
32
33 Double_t ymin = 1.e-3;
34 Double_t ymax = 2e7;
35 Double_t xmin = 60.00;
36 Double_t xmax = 3500.;
37 auto frame = canvas->DrawFrame(xmin, ymin, xmax, ymax);
38 frame->SetYTitle("d#sigma_{jet}/dE_{T,jet} [fb/GeV]");
39 frame->SetXTitle("E_{T,jet} [GeV]");
40 frame->GetYaxis()->SetTitleOffset(1.4);
41 frame->GetXaxis()->SetTitleOffset(1.4);
42
43 const Int_t ncut = 1;
45
46 for (Int_t icut = 0; icut < ncut; icut++) { // loop over cuts
48 for (Int_t ir = 0; ir < nren; ir++) { // loop over ren scale
49 g1[ir][icut] = GetGraph(ir, ir, icut, 0);
50 if (!g1[ir][icut]) {
51 cout << " g1 not found " << endl;
52 return;
53 }
54 g1[ir][icut]->SetLineColor(1);
55 g1[ir][icut]->SetMarkerStyle(0);
56 }
57
58 data[icut] = (TGraphErrors *)g1[0][icut]->Clone(TString::Format("data_%d", icut));
59 data[icut]->SetMarkerStyle(20);
60 data[icut]->SetMarkerColor(1);
61
62 // Just invent some data
63 for (Int_t i = 0; i < data[icut]->GetN(); i++) {
64 Double_t x1, y1, e, dx1 = 0.;
65 data[icut]->GetPoint(i, x1, y1);
66 Double_t r1 = 0.4 * (gRandom->Rndm(1) + 2);
67 Double_t r2 = 0.4 * (gRandom->Rndm(1) + 2);
68 Double_t y;
69 if (icut == 0)
70 y = r1 * y1 + r1 * r2 * r2 * x1 / 50000.;
71 else
72 y = r1 * y1;
73 e = sqrt(y * 1000) / 200;
74 data[icut]->SetPoint(i, x1, y);
75 data[icut]->SetPointError(i, dx1, e);
76 }
77
80
81 scale[icut] = MakeBand(g1[0][icut], g1[1][icut], g1[2][icut]);
82 scalepdf[icut] = (TGraphAsymmErrors *)scale[icut]->Clone("scalepdf");
83
85 for (Int_t ipdf = 0; ipdf < NUMPDF; ipdf++) {
86 gpdf[ipdf][icut] = GetGraph(0, 0, icut, ipdf);
87 if (!gpdf[ipdf][icut]) {
88 cout << " gpdf not found " << endl;
89 return;
90 }
91 gpdf[ipdf][icut]->SetLineColor(2);
92 gpdf[ipdf][icut]->SetLineStyle(kSolid);
93 gpdf[ipdf][icut]->SetMarkerStyle(0);
95 }
96
97 scalepdf[icut]->SetFillColor(icol2);
98 scalepdf[icut]->Draw("zE2");
99 scalepdf[icut]->SetLineWidth(3);
100 scale[icut]->SetFillColor(icol1);
101 scale[icut]->Draw("zE2");
102 g1[0][icut]->SetLineWidth(3);
103 g1[0][icut]->Draw("z");
104 data[icut]->Draw("P");
105 }
106
107 TLatex t;
108 t.SetNDC();
109 t.DrawLatex(0.3, 0.85, "#sqrt{s}= 14 TeV");
110 t.DrawLatex(0.57, 0.85, "|#eta_{jet}|<0.5");
111
112 auto l = new TLegend(0.45, 0.65, 0.8, 0.8, "", "NDC");
113 l->SetBorderSize(0.);
114 l->SetTextFont(42);
115 l->AddEntry("data_0", "Data 2009", "ep");
116 l->AddEntry("scalepdf", "NLO QCD", "lf");
117 l->Draw();
118}
119
121{
122 const char *cuts[5] = {"0.0 <= |eta| < 0.5", "0.5 <= |eta| < 1.0", "1.0 <= |eta| < 1.5", "1.5 <= |eta| < 2.0",
123 "2.0 <= |eta| < 3.0"};
124
125 const double mur[] = {1.0, 0.25, 4.0};
126 const double muf[] = {1.0, 0.25, 4.0};
127
129 TFile *file = TFile::Open("http://root.cern/files/AtlasGraphs.root", "CACHEREAD");
130
132
133 if (ipdf >= 0)
134 tname = TString::Format(" E_T (mu_r=%g, mu_f=%g);%s Pdf: %d", mur[ir], muf[ifs], cuts[icut], ipdf);
135 else
136 tname = TString::Format(" E_T %s Ms= %d", cuts[icut], -ipdf);
137
138 TGraphErrors *g1 = 0;
139
140 for (int i = 1; i <= GMAX; i++) {
141 g1 = (TGraphErrors *)file->Get(TString::Format("full_%d", i));
142 if (!g1) {
143 cout << TString::Format("full_%d", i) << " not found " << endl;
144 return nullptr;
145 }
146
147 const char *title = g1->GetTitle();
148
149 if (strcmp(title, tname) == 0)
150 break;
151 g1 = 0;
152 }
153
154 if (!g1)
155 return nullptr;
156 return g1;
157}
158
160{
161
163
164 Double_t x1 = 0., y1 = 0., x2 = 0., y2 = 0., y0 = 0, x3 = 0.;
166 for (Int_t i = 0; i < g1->GetN(); i++) {
167 g0->GetPoint(i, x1, y0);
168 g1->GetPoint(i, x1, y1);
169 g2->GetPoint(i, x1, y2);
170
171 if (i == g1->GetN() - 1)
172 x2 = x1;
173 else
174 g2->GetPoint(i + 1, x2, dum);
175
176 if (i == 0)
177 x3 = x1;
178 else
179 g2->GetPoint(i - 1, x3, dum);
180
182 if (y1 < y2) {
183 y2 = y1;
185 }
186 g3->SetPoint(i, x1, y0);
187
188 Double_t binwl = (x1 - x3) / 2.;
189 Double_t binwh = (x2 - x1) / 2.;
190 if (binwl == 0.)
191 binwl = binwh;
192 if (binwh == 0.)
193 binwh = binwl;
194 g3->SetPointError(i, binwl, binwh, y0 - y2, y1 - y0);
195 }
196 return g3;
197}
198
200{
201
202 Double_t x1 = 0., y1 = 0., y2 = 0., y0 = 0;
203
204 if (g1->GetN() != g2->GetN())
205 cout << " graphs don't have the same number of elements " << endl;
206
207 Double_t *EYhigh = g2->GetEYhigh();
208 Double_t *EYlow = g2->GetEYlow();
209
210 for (Int_t i = 0; i < g1->GetN(); i++) {
211 g1->GetPoint(i, x1, y1);
212 g2->GetPoint(i, x1, y2);
213
214 if (y1 == 0 || y2 == 0)
215 cerr << "check these points very carefully : AddtoBand() : point " << i << endl;
216
217 Double_t eyh = 0., eyl = 0.;
218
219 y0 = y1 - y2;
220 if (y0 != 0) {
221 if (y0 > 0) {
222 eyh = EYhigh[i];
223 eyh = sqrt(eyh * eyh + y0 * y0);
224 g2->SetPointEYhigh(i, eyh);
225 } else {
226 eyl = EYlow[i];
227 eyl = sqrt(eyl * eyl + y0 * y0);
228 g2->SetPointEYlow(i, eyl);
229 }
230 }
231 }
232}
#define e(i)
Definition RSha256.hxx:103
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
@ kSolid
Definition TAttLine.h:52
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
float xmin
float ymin
float xmax
float ymax
#define gROOT
Definition TROOT.h:406
R__EXTERN TRandom * gRandom
Definition TRandom.h:62
The Canvas class.
Definition TCanvas.h:23
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:131
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:4130
static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
Definition TFile.cxx:4673
TGraph with asymmetric error bars.
A TGraphErrors is a TGraph with error bars.
To draw Mathematical Formula.
Definition TLatex.h:18
TLatex * DrawLatex(Double_t x, Double_t y, const char *text)
Make a copy of this object with the new parameters And copy object attributes.
Definition TLatex.cxx:1943
This class displays a legend box (TPaveText) containing several legend entries.
Definition TLegend.h:23
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:292
Double_t Rndm() override
Machine independent random number generator.
Definition TRandom.cxx:559
Basic string class.
Definition TString.h:139
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Definition TText.cxx:823
Double_t y[n]
Definition legend1.C:17
TLine l
Definition textangle.C:4