Logo ROOT   6.14/05
Reference Guide
zdemo.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_graphs
3 /// \notebook
4 /// This macro is an example of graphs in log scales with annotations.
5 ///
6 /// The presented results are predictions of invariant cross-section
7 /// of Direct Photons produced at RHIC energies, based on the universality of
8 /// scaling function H(z).
9 ///
10 /// These Figures were published in JINR preprint E2-98-64, Dubna,
11 /// 1998 and submitted to CPC.
12 ///
13 /// Note that the way greek symbols, super/subscripts are obtained
14 /// illustrate the current limitations of Root in this area.
15 ///
16 /// \macro_image
17 /// \macro_code
18 ///
19 /// \authors Michael Tokarev and Elena Potrebenikova (JINR Dubna)
20 
21 #include "TCanvas.h"
22 #include "TPad.h"
23 #include "TPaveLabel.h"
24 #include "TLatex.h"
25 #include "TGraph.h"
26 #include "TFrame.h"
27 
28 #ifdef HZ
29 #undef HZ
30 #endif
31 
32 const Int_t NMAX = 20;
33 Int_t NLOOP;
34 Float_t Z[NMAX], HZ[NMAX], PT[NMAX], INVSIG[NMAX];
35 
36 void hz_calc(Float_t, Float_t, Float_t, Float_t, Float_t, Float_t);
37 
38 //__________________________________________________________________
39 void zdemo()
40 {
41 
42  Float_t energ;
43  Float_t dens;
44  Float_t tgrad;
45  Float_t ptmin;
46  Float_t ptmax;
47  Float_t delp;
48 
49  // Create a new canvas.
50  TCanvas *c1 = new TCanvas("zdemo",
51  "Monte Carlo Study of Z scaling",10,40,800,600);
52  c1->Range(0,0,25,18);
53  c1->SetFillColor(40);
54 
55  TPaveLabel *pl = new TPaveLabel(1,16.3,24,17.5,"Z-scaling of \
56  Direct Photon Productions in pp Collisions at RHIC Energies","br");
57  pl->SetFillColor(18);
58  pl->SetTextFont(32);
59  pl->SetTextColor(49);
60  pl->Draw();
61 
62  TLatex *t = new TLatex();
63  t->SetTextFont(32);
64  t->SetTextColor(1);
65  t->SetTextSize(0.03);
66  t->SetTextAlign(12);
67  t->DrawLatex(3.1,15.5,"M.Tokarev, E.Potrebenikova ");
68  t->DrawLatex(14.,15.5,"JINR preprint E2-98-64, Dubna, 1998 ");
69 
70  TPad *pad1 = new TPad("pad1","This is pad1",0.02,0.02,0.48,0.83,33);
71  TPad *pad2 = new TPad("pad2","This is pad2",0.52,0.02,0.98,0.83,33);
72 
73  pad1->Draw();
74  pad2->Draw();
75 
76 //
77 // Cross-section of direct photon production in pp collisions
78 // at 500 GeV vs Pt
79 //
80  energ = 63;
81  dens = 1.766;
82  tgrad = 90.;
83  ptmin = 4.;
84  ptmax = 24.;
85  delp = 2.;
86  hz_calc(energ, dens, tgrad, ptmin, ptmax, delp);
87  pad1->cd();
88  pad1->Range(-0.255174,-19.25,2.29657,-6.75);
89  pad1->SetLogx();
90  pad1->SetLogy();
91 
92  // create a 2-d histogram to define the range
93  pad1->DrawFrame(1,1e-18,110,1e-8);
94  pad1->GetFrame()->SetFillColor(19);
95  t = new TLatex();
96  t->SetNDC();
97  t->SetTextFont(62);
98  t->SetTextColor(36);
99  t->SetTextSize(0.08);
100  t->SetTextAlign(12);
101  t->DrawLatex(0.6,0.85,"p - p");
102 
103  t->SetTextSize(0.05);
104  t->DrawLatex(0.6,0.79,"Direct #gamma");
105  t->DrawLatex(0.6,0.75,"#theta = 90^{o}");
106 
107  t->DrawLatex(0.20,0.45,"Ed^{3}#sigma/dq^{3}");
108  t->DrawLatex(0.18,0.40,"(barn/Gev^{2})");
109 
110  t->SetTextSize(0.045);
111  t->SetTextColor(kBlue);
112  t->DrawLatex(0.22,0.260,"#sqrt{s} = 63(GeV)");
113  t->SetTextColor(kRed);
114  t->DrawLatex(0.22,0.205,"#sqrt{s} = 200(GeV)");
115  t->SetTextColor(6);
116  t->DrawLatex(0.22,0.15,"#sqrt{s} = 500(GeV)");
117 
118  t->SetTextSize(0.05);
119  t->SetTextColor(1);
120  t->DrawLatex(0.6,0.06,"q_{T} (Gev/c)");
121 
122  TGraph *gr1 = new TGraph(NLOOP,PT,INVSIG);
123 
124  gr1->SetLineColor(38);
125  gr1->SetMarkerColor(kBlue);
126  gr1->SetMarkerStyle(21);
127  gr1->SetMarkerSize(1.1);
128  gr1->Draw("LP");
129 
130 //
131 // Cross-section of direct photon production in pp collisions
132 // at 200 GeV vs Pt
133 //
134 
135  energ = 200;
136  dens = 2.25;
137  tgrad = 90.;
138  ptmin = 4.;
139  ptmax = 64.;
140  delp = 6.;
141  hz_calc(energ, dens, tgrad, ptmin, ptmax, delp);
142 
143  TGraph *gr2 = new TGraph(NLOOP,PT,INVSIG);
144  gr2->SetLineColor(38);
145  gr2->SetMarkerColor(kRed);
146  gr2->SetMarkerStyle(29);
147  gr2->SetMarkerSize(1.5);
148  gr2->Draw("LP");
149 
150 //
151 // Cross-section of direct photon production in pp collisions
152 // at 500 GeV vs Pt
153 //
154  energ = 500;
155  dens = 2.73;
156  tgrad = 90.;
157  ptmin = 4.;
158  ptmax = 104.;
159  delp = 10.;
160  hz_calc(energ, dens, tgrad, ptmin, ptmax, delp);
161 
162  TGraph *gr3 = new TGraph(NLOOP,PT,INVSIG);
163 
164  gr3->SetLineColor(38);
165  gr3->SetMarkerColor(6);
166  gr3->SetMarkerStyle(8);
167  gr3->SetMarkerSize(1.1);
168  gr3->Draw("LP");
169 
170  Float_t *dum = 0;
171  TGraph *graph = new TGraph(1,dum,dum);
172  graph->SetMarkerColor(kBlue);
173  graph->SetMarkerStyle(21);
174  graph->SetMarkerSize(1.1);
175  graph->SetPoint(0,1.7,1.e-16);
176  graph->Draw("LP");
177 
178  graph = new TGraph(1,dum,dum);
179  graph->SetMarkerColor(kRed);
180  graph->SetMarkerStyle(29);
181  graph->SetMarkerSize(1.5);
182  graph->SetPoint(0,1.7,2.e-17);
183  graph->Draw("LP");
184 
185  graph = new TGraph(1,dum,dum);
186  graph->SetMarkerColor(6);
187  graph->SetMarkerStyle(8);
188  graph->SetMarkerSize(1.1);
189  graph->SetPoint(0,1.7,4.e-18);
190  graph->Draw("LP");
191 
192  pad2->cd();
193  pad2->Range(-0.43642,-23.75,3.92778,-6.25);
194  pad2->SetLogx();
195  pad2->SetLogy();
196 
197  pad2->DrawFrame(1,1e-22,3100,1e-8);
198  pad2->GetFrame()->SetFillColor(19);
199 
200  TGraph *gr = new TGraph(NLOOP,Z,HZ);
201  gr->SetTitle("HZ vs Z");
202  gr->SetFillColor(19);
203  gr->SetLineColor(9);
204  gr->SetMarkerColor(50);
205  gr->SetMarkerStyle(29);
206  gr->SetMarkerSize(1.5);
207  gr->Draw("LP");
208 
209  t = new TLatex();
210  t->SetNDC();
211  t->SetTextFont(62);
212  t->SetTextColor(36);
213  t->SetTextSize(0.08);
214  t->SetTextAlign(12);
215  t->DrawLatex(0.6,0.85,"p - p");
216 
217  t->SetTextSize(0.05);
218  t->DrawLatex(0.6,0.79,"Direct #gamma");
219  t->DrawLatex(0.6,0.75,"#theta = 90^{o}");
220 
221  t->DrawLatex(0.70,0.55,"H(z)");
222  t->DrawLatex(0.68,0.50,"(barn)");
223 
224  t->SetTextSize(0.045);
225  t->SetTextColor(46);
226  t->DrawLatex(0.20,0.30,"#sqrt{s}, GeV");
227  t->DrawLatex(0.22,0.26,"63");
228  t->DrawLatex(0.22,0.22,"200");
229  t->DrawLatex(0.22,0.18,"500");
230 
231  t->SetTextSize(0.05);
232  t->SetTextColor(1);
233  t->DrawLatex(0.88,0.06,"z");
234 
235  c1->Modified();
236  c1->Update();
237 }
238 
239 void hz_calc(Float_t ENERG, Float_t DENS, Float_t TGRAD, Float_t PTMIN,
240  Float_t PTMAX, Float_t DELP)
241 {
242  Int_t I;
243 
244  Float_t GM1 = 0.00001;
245  Float_t GM2 = 0.00001;
246  Float_t A1 = 1.;
247  Float_t A2 = 1.;
248  Float_t ALX = 2.;
249  Float_t BETA = 1.;
250  Float_t KF1 = 8.E-7;
251  Float_t KF2 = 5.215;
252 
253  Float_t MN = 0.9383;
254  Float_t DEGRAD=0.01745329;
255 
256  Float_t EB1, EB2, PB1, PB2, MB1, MB2, M1, M2;
257  Float_t DNDETA;
258 
259  Float_t P1P2, P1P3, P2P3;
260  Float_t Y1, Y2, S, SMIN, SX1, SX2, SX1X2, DELM;
261  Float_t Y1X1, Y1X2, Y2X1, Y2X2, Y2X1X2, Y1X1X2;
262  Float_t KX1, KX2, ZX1, ZX2;
263  Float_t H1;
264 
265  Float_t PTOT, THET, ETOT, X1, X2;
266 
267  DNDETA= DENS;
268  MB1 = MN*A1;
269  MB2 = MN*A2;
270  EB1 = ENERG/2.*A1;
271  EB2 = ENERG/2.*A2;
272  M1 = GM1;
273  M2 = GM2;
274  THET = TGRAD*DEGRAD;
275  NLOOP = (PTMAX-PTMIN)/DELP;
276 
277  for (I=0; I<NLOOP;I++) {
278  PT[I]=PTMIN+I*DELP;
279  PTOT = PT[I]/sin(THET);
280 
281  ETOT = sqrt(M1*M1 + PTOT*PTOT);
282  PB1 = sqrt(EB1*EB1 - MB1*MB1);
283  PB2 = sqrt(EB2*EB2 - MB2*MB2);
284  P2P3 = EB2*ETOT+PB2*PTOT*cos(THET);
285  P1P2 = EB2*EB1+PB2*PB1;
286  P1P3 = EB1*ETOT-PB1*PTOT*cos(THET);
287 
288  X1 = P2P3/P1P2;
289  X2 = P1P3/P1P2;
290  Y1 = X1+sqrt(X1*X2*(1.-X1)/(1.-X2));
291  Y2 = X2+sqrt(X1*X2*(1.-X2)/(1.-X1));
292 
293  S = (MB1*MB1)+2.*P1P2+(MB2*MB2);
294  SMIN = 4.*((MB1*MB1)*(X1*X1) +2.*X1*X2*P1P2+(MB2*MB2)*(X2*X2));
295  SX1 = 4.*( 2*(MB1*MB1)*X1+2*X2*P1P2);
296  SX2 = 4.*( 2*(MB2*MB2)*X2+2*X1*P1P2);
297  SX1X2= 4.*(2*P1P2);
298  DELM = pow((1.-Y1)*(1.-Y2),ALX);
299 
300  Z[I] = sqrt(SMIN)/DELM/pow(DNDETA,BETA);
301 
302  Y1X1 = 1. +X2*(1-2.*X1)/(2.*(Y1-X1)*(1.-X2));
303  Y1X2 = X1*(1-X1)/(2.*(Y1-X1)*(1.-X2)*(1.-X2));
304  Y2X1 = X2*(1-X2)/(2.*(Y2-X2)*(1.-X1)*(1.-X1));
305  Y2X2 = 1. +X1*(1-2.*X2)/(2.*(Y2-X2)*(1.-X1));
306  Y2X1X2= Y2X1*( (1.-2.*X2)/(X2*(1-X2)) -( Y2X2-1.)/(Y2-X2));
307  Y1X1X2= Y1X2*( (1.-2.*X1)/(X1*(1-X1)) -( Y1X1-1.)/(Y1-X1));
308 
309  KX1=-DELM*(Y1X1*ALX/(1.-Y1) + Y2X1*ALX/(1.-Y2));
310  KX2=-DELM*(Y2X2*ALX/(1.-Y2) + Y1X2*ALX/(1.-Y1));
311  ZX1=Z[I]*(SX1/(2.*SMIN)-KX1/DELM);
312  ZX2=Z[I]*(SX2/(2.*SMIN)-KX2/DELM);
313 
314  H1=ZX1*ZX2;
315 
316  HZ[I]=KF1/pow(Z[I],KF2);
317  INVSIG[I]=(HZ[I]*H1*16.)/S;
318 
319  }
320 }
float Float_t
Definition: RtypesCore.h:53
return c1
Definition: legend1.C:41
Definition: Rtypes.h:59
#define DEGRAD
TH1F * DrawFrame(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, const char *title="")
Draw an empty pad frame with X and Y axis.
Definition: TPad.cxx:1566
int Int_t
Definition: RtypesCore.h:41
virtual void SetTitle(const char *title="")
Set graph title.
Definition: TGraph.cxx:2216
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
Definition: TGraph.cxx:745
double cos(double)
Definition: zdemo.py:1
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:45
double sqrt(double)
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:594
TFrame * GetFrame()
Get frame.
Definition: TPad.cxx:2823
To draw Mathematical Formula.
Definition: TLatex.h:18
double pow(double, double)
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:38
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:1914
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Definition: TText.cxx:814
virtual void SetLogx(Int_t value=1)
Set Lin/Log scale for X.
Definition: TPad.cxx:5802
double sin(double)
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
Definition: TPad.cxx:1281
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition: TAttText.h:41
A Pave (see TPave) with a text centered in the Pave.
Definition: TPaveLabel.h:20
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
RooArgSet S(const RooAbsArg &v1)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Set world coordinate system for the pad.
Definition: TPad.cxx:5121
The most important graphics class in the ROOT system.
Definition: TPad.h:29
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition: TAttMarker.h:40
Definition: graph.py:1
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition: TAttMarker.h:41
TGraphErrors * gr
Definition: legend1.C:25
The Canvas class.
Definition: TCanvas.h:31
virtual void Draw(Option_t *option="")
Draw this pavelabel with its current attributes.
Definition: TPaveLabel.cxx:77
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition: TGraph.cxx:2184
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:41
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition: TAttText.h:43
Definition: Rtypes.h:59
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition: TAttText.h:46
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2248
#define I(x, y, z)
void Modified(Bool_t flag=1)
Definition: TPad.h:414
virtual void SetLogy(Int_t value=1)
Set Lin/Log scale for Y.
Definition: TPad.cxx:5816