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