Logo ROOT   6.08/07
Reference Guide
zdemo.py
Go to the documentation of this file.
1 ## \file
2 ## \ingroup tutorial_pyroot
3 ## \notebook
4 ## This macro is an example of graphs in log scales with annotations.
5 ##
6 ## The presented results
7 ## are predictions of invariant cross-section of Direct Photons produced
8 ## at RHIC energies, based on the universality of scaling function H(z).
9 ##
10 ##
11 ## These Figures were published in JINR preprint E2-98-64, Dubna,
12 ## 1998 and submitted to CPC.
13 ##
14 ## \macro_image
15 ## \macro_code
16 ##
17 ## \authors Michael Tokarev, Elena Potrebenikova (JINR Dubna)
18 
19 import ROOT
20 from array import array
21 from math import *
22 
23 NMAX = 20
24 Z = array( 'f', [0.]*NMAX )
25 HZ = array( 'f', [0.]*NMAX )
26 PT = array( 'f', [0.]*NMAX )
27 INVSIG = array( 'f', [0.]*NMAX )
28 
29 NLOOP = 0
30 saves = {}
31 
32 #_______________________________________________________________________________
33 def hz_calc( ENERG, DENS, TGRAD, PTMIN, PTMAX, DELP ):
34  global NLOOP
35  global Z, HZ, PT, INVSIG
36 
37  CSEFT= 1.
38  GM1 = 0.00001
39  GM2 = 0.00001
40  A1 = 1.
41  A2 = 1.
42  ALX = 2.
43  BETA = 1.
44  KF1 = 8.E-7
45  KF2 = 5.215
46 
47  MN = 0.9383
48  DEGRAD=0.01745329
49 
50  # print 'ENR= %f DENS= %f PTMIN= %f PTMAX= %f DELP= %f ' % (ENERG,DENS,PTMIN,PTMAX,DELP)
51 
52  DNDETA= DENS
53  MB1 = MN*A1
54  MB2 = MN*A2
55  EB1 = ENERG/2.*A1
56  EB2 = ENERG/2.*A2
57  M1 = GM1
58  M2 = GM2
59  THET = TGRAD*DEGRAD
60  NLOOP = int((PTMAX-PTMIN)/DELP)
61 
62  for I in range(NLOOP):
63  PT[I]=PTMIN+I*DELP
64  PTOT = PT[I]/sin(THET)
65 
66  ETOT = sqrt(M1*M1 + PTOT*PTOT)
67  PB1 = sqrt(EB1*EB1 - MB1*MB1)
68  PB2 = sqrt(EB2*EB2 - M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[I]*H1*16.)/S
103 
104 
105 #_______________________________________________________________________________
106 def zdemo():
107  global NLOOP
108  global Z, HZ, PT, INVSIG
109  global saves
110 
111  # Create a new canvas.
112  c1 = ROOT.TCanvas( 'zdemo', 'Monte Carlo Study of Z scaling', 10, 40, 800, 600 )
113  c1.Range( 0, 0, 25, 18 )
114  c1.SetFillColor( 40 )
115  saves[ 'c1' ] = c1 # prevent deteletion at end of zdemo
116 
117  pl = ROOT.TPaveLabel( 1, 16.3, 24, 17.5,
118  'Z-scaling of Direct Photon Productions in pp Collisions at RHIC Energies', 'br' )
119  pl.SetFillColor(18)
120  pl.SetTextFont(32)
121  pl.SetTextColor(49)
122  pl.Draw()
123  saves[ 'pl' ] = pl
124 
125  t = ROOT.TLatex()
126  t.SetTextFont(32)
127  t.SetTextColor(1)
128  t.SetTextSize(0.03)
129  t.SetTextAlign(12)
130  t.DrawLatex( 3.1, 15.5, 'M.Tokarev, E.Potrebenikova ')
131  t.DrawLatex( 14., 15.5, 'JINR preprint E2-98-64, Dubna, 1998 ')
132  saves[ 't' ] = t
133 
134  pad1 = ROOT.TPad( 'pad1', 'This is pad1', 0.02, 0.02, 0.48, 0.83, 33 )
135  pad2 = ROOT.TPad( 'pad2', 'This is pad2', 0.52, 0.02, 0.98, 0.83, 33 )
136 
137  pad1.Draw()
138  pad2.Draw()
139 
140  saves[ 'pad1' ] = pad1; saves[ 'pad2' ] = pad2
141 
142  #
143  # Cross-section of direct photon production in pp collisions at 500 GeV vs Pt
144  #
145  energ = 63
146  dens = 1.766
147  tgrad = 90.
148  ptmin = 4.
149  ptmax = 24.
150  delp = 2.
151  hz_calc( energ, dens, tgrad, ptmin, ptmax, delp )
152  pad1.cd()
153  pad1.Range( -0.255174, -19.25, 2.29657, -6.75 )
154  pad1.SetLogx()
155  pad1.SetLogy()
156 
157  # create a 2-d histogram to define the range
158  pad1.DrawFrame( 1, 1e-18, 110, 1e-8 )
159  pad1.GetFrame().SetFillColor( 19 )
160  t = ROOT.TLatex()
161  t.SetNDC()
162  t.SetTextFont( 62 )
163  t.SetTextColor( 36 )
164  t.SetTextSize( 0.08 )
165  t.SetTextAlign( 12 )
166  t.DrawLatex( 0.6, 0.85, 'p - p' )
167 
168  t.SetTextSize( 0.05 )
169  t.DrawLatex( 0.6, 0.79, 'Direct #gamma' )
170  t.DrawLatex( 0.6, 0.75, '#theta = 90^{o}' )
171 
172  t.DrawLatex( 0.20, 0.45, 'Ed^{3}#sigma/dq^{3}' )
173  t.DrawLatex( 0.18, 0.40, '(barn/Gev^{2})' )
174 
175  t.SetTextSize( 0.045 )
176  t.SetTextColor( ROOT.kBlue )
177  t.DrawLatex( 0.22, 0.260, '#sqrt{s} = 63(GeV)' )
178  t.SetTextColor( ROOT.kRed )
179  t.DrawLatex( 0.22, 0.205,'#sqrt{s} = 200(GeV)' )
180  t.SetTextColor( 6 )
181  t.DrawLatex( 0.22, 0.15, '#sqrt{s} = 500(GeV)' )
182 
183  t.SetTextSize( 0.05 )
184  t.SetTextColor( 1 )
185  t.DrawLatex( 0.6, 0.06, 'q_{T} (Gev/c)' )
186  saves[ 't2' ] = t # note the label that is used!
187 
188  gr1 = ROOT.TGraph( NLOOP, PT, INVSIG )
189 
190  gr1.SetLineColor( 38 )
191  gr1.SetMarkerColor( ROOT.kBlue )
192  gr1.SetMarkerStyle( 21 )
193  gr1.SetMarkerSize( 1.1 )
194  gr1.Draw( 'LP' )
195  saves[ 'gr1' ] = gr1
196 
197  #
198  # Cross-section of direct photon production in pp collisions at 200 GeV vs Pt
199  #
200 
201  energ = 200
202  dens = 2.25
203  tgrad = 90.
204  ptmin = 4.
205  ptmax = 64.
206  delp = 6.
207  hz_calc( energ, dens, tgrad, ptmin, ptmax, delp )
208 
209  gr2 = ROOT.TGraph( NLOOP, PT, INVSIG )
210  gr2.SetLineColor( 38 )
211  gr2.SetMarkerColor( ROOT.kRed )
212  gr2.SetMarkerStyle( 29 )
213  gr2.SetMarkerSize( 1.5 )
214  gr2.Draw( 'LP' )
215  saves[ 'gr2' ] = gr2
216 
217  #
218  # Cross-section of direct photon production in pp collisions at 500 GeV vs Pt
219  #
220  energ = 500
221  dens = 2.73
222  tgrad = 90.
223  ptmin = 4.
224  ptmax = 104.
225  delp = 10.
226  hz_calc( energ, dens, tgrad, ptmin, ptmax, delp )
227 
228  gr3 = ROOT.TGraph( NLOOP, PT, INVSIG )
229 
230  gr3.SetLineColor( 38 )
231  gr3.SetMarkerColor( 6 )
232  gr3.SetMarkerStyle( 8 )
233  gr3.SetMarkerSize( 1.1 )
234  gr3.Draw( 'LP' )
235  saves[ 'gr3' ] = gr3
236 
237  dum = array( 'f', [0.] )
238  graph = ROOT.TGraph( 1, dum, dum )
239  graph.SetMarkerColor( ROOT.kBlue )
240  graph.SetMarkerStyle( 21 )
241  graph.SetMarkerSize( 1.1 )
242  graph.SetPoint( 0, 1.7, 1.e-16 )
243  graph.Draw( 'LP' )
244  saves[ 'graph' ] = graph
245 
246  graph = ROOT.TGraph( 1, dum, dum )
247  graph.SetMarkerColor( ROOT.kRed )
248  graph.SetMarkerStyle( 29 )
249  graph.SetMarkerSize( 1.5 )
250  graph.SetPoint( 0, 1.7, 2.e-17 )
251  graph.Draw( 'LP' )
252  saves[ 'graph2' ] = graph # note the label that is used!
253 
254  graph = ROOT.TGraph( 1, dum, dum )
255  graph.SetMarkerColor( 6 )
256  graph.SetMarkerStyle( 8 )
257  graph.SetMarkerSize( 1.1 )
258  graph.SetPoint( 0, 1.7, 4.e-18)
259  graph.Draw( 'LP' )
260  saves[ 'graph3' ] = graph # note the label that is used!
261 
262  pad2.cd()
263  pad2.Range( -0.43642, -23.75, 3.92778, -6.25 )
264  pad2.SetLogx()
265  pad2.SetLogy()
266 
267  pad2.DrawFrame( 1, 1e-22, 3100, 1e-8 )
268  pad2.GetFrame().SetFillColor( 19 )
269 
270  gr = ROOT.TGraph( NLOOP, Z, HZ )
271  gr.SetTitle( 'HZ vs Z' )
272  gr.SetFillColor( 19 )
273  gr.SetLineColor( 9 )
274  gr.SetMarkerColor( 50 )
275  gr.SetMarkerStyle( 29 )
276  gr.SetMarkerSize( 1.5 )
277  gr.Draw( 'LP' )
278  saves[ 'gr' ] = gr
279 
280  t = ROOT.TLatex()
281  t.SetNDC()
282  t.SetTextFont( 62 )
283  t.SetTextColor( 36 )
284  t.SetTextSize( 0.08 )
285  t.SetTextAlign( 12 )
286  t.DrawLatex( 0.6, 0.85, 'p - p' )
287 
288  t.SetTextSize( 0.05 )
289  t.DrawLatex( 0.6, 0.79, 'Direct #gamma' )
290  t.DrawLatex( 0.6, 0.75, '#theta = 90^{o}' )
291 
292  t.DrawLatex( 0.70, 0.55, 'H(z)' )
293  t.DrawLatex( 0.68, 0.50, '(barn)' )
294 
295  t.SetTextSize( 0.045 )
296  t.SetTextColor( 46 )
297  t.DrawLatex( 0.20, 0.30, '#sqrt{s}, GeV' )
298  t.DrawLatex( 0.22, 0.26, '63' )
299  t.DrawLatex( 0.22, 0.22, '200' )
300  t.DrawLatex( 0.22, 0.18, '500' )
301 
302  t.SetTextSize( 0.05 )
303  t.SetTextColor( 1 )
304  t.DrawLatex( 0.88, 0.06, 'z' )
305  saves[ 't3' ] = t # note the label that is used!
306 
307  c1.Modified()
308  c1.Update()
309 
310 
311 if __name__ == '__main__': # run if loaded as script
312  zdemo()
double cos(double)
Definition: zdemo.py:1
double sqrt(double)
double pow(double, double)
double sin(double)
h1 SetFillColor(kGreen)