1 | <html> |
---|
2 | <head> |
---|
3 | <title>ROOT usage</title> |
---|
4 | <link rel="stylesheet" type="text/css" href="pythia.css"/> |
---|
5 | <link rel="shortcut icon" href="pythia32.gif"/> |
---|
6 | </head> |
---|
7 | <body> |
---|
8 | |
---|
9 | <script language=javascript type=text/javascript> |
---|
10 | function stopRKey(evt) { |
---|
11 | var evt = (evt) ? evt : ((event) ? event : null); |
---|
12 | var node = (evt.target) ? evt.target :((evt.srcElement) ? evt.srcElement : null); |
---|
13 | if ((evt.keyCode == 13) && (node.type=="text")) |
---|
14 | {return false;} |
---|
15 | } |
---|
16 | |
---|
17 | document.onkeypress = stopRKey; |
---|
18 | </script> |
---|
19 | <?php |
---|
20 | if($_POST['saved'] == 1) { |
---|
21 | if($_POST['filepath'] != "files/") { |
---|
22 | echo "<font color='red'>SETTINGS SAVED TO FILE</font><br/><br/>"; } |
---|
23 | else { |
---|
24 | echo "<font color='red'>NO FILE SELECTED YET.. PLEASE DO SO </font><a href='SaveSettings.php'>HERE</a><br/><br/>"; } |
---|
25 | } |
---|
26 | ?> |
---|
27 | |
---|
28 | <form method='post' action='ROOTusage.php'> |
---|
29 | |
---|
30 | <h2>ROOT usage</h2> |
---|
31 | |
---|
32 | Many PYTHIA users wish to use <a href="http://root.cern.ch/">ROOT</a> |
---|
33 | to produce histograms, or even to run PYTHIA as a plugin to ROOT. |
---|
34 | This is possible. It is not a task supported by the PYTHIA team, |
---|
35 | however. All issues involving ROOT usage should be directed to the |
---|
36 | ROOT team, or to the local support team of your collaboration. |
---|
37 | Below some helpful hints have been collected. The text is based on |
---|
38 | contributions by Rene Brun, Andreas Morsch and Axel Naumann. |
---|
39 | Another example may be found in the |
---|
40 | <a href="http://home.fnal.gov/~skands/vincia/">VINCIA</a> |
---|
41 | add-on program for parton showers, but this should also work for |
---|
42 | a PYTHIA standalone run. |
---|
43 | <br/><br/> |
---|
44 | Note that in all that follows, a Linux-type system with a Bash shell |
---|
45 | and GNU Make is assumed. In particular, for Mac OS X, the |
---|
46 | <code>LD_LIBRARY_PATH</code> should be replaced with |
---|
47 | <code>DYLD_LIBRARY_PATH</code> and the extension for shared libraries |
---|
48 | <code>.so</code> should be replaced with <code>.dylib</code>. |
---|
49 | |
---|
50 | <br/><br/><hr/> |
---|
51 | <h3>Standalone usage</h3> |
---|
52 | |
---|
53 | One can perform the generation and analysis of events in a completely |
---|
54 | standalone fashion, and only use ROOT to process the completed events. |
---|
55 | Some example programs are provided in the <code>rootexamples</code> |
---|
56 | directory, with details provided below and in the <code>README</code> |
---|
57 | file. |
---|
58 | |
---|
59 | The examples assume that you have already compiled the PYTHIA library, |
---|
60 | ROOT is installed, and that all paths have been setup correctly (e.g. |
---|
61 | PATH and LD_LIBRARY_PATH). If these paths are not already set, ROOT |
---|
62 | typically comes with a shell script to set these paths, which can be |
---|
63 | run with |
---|
64 | <pre> |
---|
65 | source /path_to_ROOT_installation/bin/thisroot.sh |
---|
66 | </pre> |
---|
67 | |
---|
68 | <h4>Histogramming with ROOT</h4> |
---|
69 | |
---|
70 | An example of histogramming with ROOT is provided in |
---|
71 | <code>rootexamples/hist.cc</code>. It may be compiled and run |
---|
72 | with the following commands |
---|
73 | <pre> |
---|
74 | make hist |
---|
75 | ./hist.exe |
---|
76 | </pre> |
---|
77 | After PYTHIA has run, a ROOT histogram of the charged multiplicity in |
---|
78 | the events will be shown. This is now stored in the |
---|
79 | <code>hist.root</code> file. |
---|
80 | |
---|
81 | <h4>Storing PYTHIA events in ROOT trees</h4> |
---|
82 | |
---|
83 | Instead of only generating histograms, it is possible to store entire |
---|
84 | PYTHIA events in ROOT trees. The <code>tree</code> example in the |
---|
85 | <code>rootexamples</code> subdirectory provides an example of this and |
---|
86 | is comprised of the following files |
---|
87 | <ul> |
---|
88 | <li><code>tree.cc</code> is the main example program showing how |
---|
89 | PYTHIA events can be stored in ROOT trees.</li> |
---|
90 | <li><code>pythiaLinkdef.h</code> is used by Makefile to generate the |
---|
91 | dictionary for all PYTHIA classes involved in the IO, as needed for |
---|
92 | the example.</li> |
---|
93 | <li><code>pythiaROOT.h</code> is a small include declaring the |
---|
94 | <code>Pythia8</code> namespace as default.</li> |
---|
95 | </ul> |
---|
96 | |
---|
97 | <br/> |
---|
98 | The example may be compiled and run with |
---|
99 | <pre> |
---|
100 | make tree |
---|
101 | ./tree.exe |
---|
102 | </pre> |
---|
103 | After the example has run, the <code>pytree.root</code> file will now |
---|
104 | be present containing the PYTHIA events. Note that files can become |
---|
105 | quite large when many events are generated. |
---|
106 | |
---|
107 | <br/><br/><hr/> |
---|
108 | <h3>PYTHIA as a plugin to ROOT</h3> |
---|
109 | |
---|
110 | In more ROOT-centric applications, PYTHIA can be run as a ROOT plug-in. |
---|
111 | This requires a version of ROOT that has been |
---|
112 | <a href="http://root.cern.ch/drupal/content/installing-root-source"> |
---|
113 | installed from source</a>. The reason is that the interfaces depend on |
---|
114 | PYTHIA header files that are not distributed with ROOT. Installing ROOT |
---|
115 | is not more difficult than the PYTHIA installation, and some |
---|
116 | guidelines are provided below. |
---|
117 | |
---|
118 | <h4>Installation</h4> |
---|
119 | |
---|
120 | To be run as a plugin, PYTHIA must be compiled as a shared library. |
---|
121 | This is achieved by running the PYTHIA <code>configure</code> script |
---|
122 | with the <code>--enable-shared</code> option before <code>make</code> |
---|
123 | is run.<br/><br/> |
---|
124 | |
---|
125 | Define an environment variable for the path to your |
---|
126 | PYTHIA installation directory |
---|
127 | <pre> |
---|
128 | export PYTHIA8=path_to_PYTHIA8_installation |
---|
129 | </pre> |
---|
130 | Before compiling ROOT, |
---|
131 | <a href="http://root.cern.ch/drupal/content/installing-root-source"> |
---|
132 | configure ROOT</a> by running the <code>configure</code> command |
---|
133 | including the following options |
---|
134 | <pre> |
---|
135 | --enable-pythia8 |
---|
136 | --with-pythia8-incdir=$PYTHIA8/include |
---|
137 | --with-pythia8-libdir=$PYTHIA8/lib |
---|
138 | </pre> |
---|
139 | In case ROOT has already been compiled before, it will only recompile |
---|
140 | the PYTHIA module and build the library <code>libEGPythia8</code>. |
---|
141 | |
---|
142 | <h4>Interfaces</h4> |
---|
143 | |
---|
144 | When running PYTHIA as a plugin, the exact interface structure becomes |
---|
145 | very relevant. ROOT provides two simple interfaces (wrappers) for |
---|
146 | PYTHIA 8. The code for these interfaces are located in |
---|
147 | <pre> |
---|
148 | path_to_ROOT_source/montecarlo/pythia8 |
---|
149 | </pre> |
---|
150 | <br/> |
---|
151 | The two interfaces are |
---|
152 | <ul> |
---|
153 | <li><a href="http://root.cern.ch/root/html/TPythia8.html"> |
---|
154 | <code>TPythia8</code></a> is an implementation of the |
---|
155 | <a href="http://root.cern.ch/root/html/TGenerator.html"> |
---|
156 | <code>TGenerator</code></a> interface for PYTHIA 8.<br/> |
---|
157 | It allows you to use PYTHIA within a ROOT macro or as a plug-in |
---|
158 | for a general-purpose particle generator based on this interface. The |
---|
159 | main methods of the interface are |
---|
160 | <ul> |
---|
161 | <li><code>GenerateEvent()</code> which triggers the |
---|
162 | generation of the next event, and </li> |
---|
163 | <li><code>ImportParticles(TClonesArray* particles)</code> |
---|
164 | which copies the native PYTHIA stack into a |
---|
165 | <a href="http://root.cern.ch/root/html/TClonesArray.html"> |
---|
166 | <code>TClonesArray</code></a> of |
---|
167 | <a href="http://root.cern.ch/root/html/TParticle.html"> |
---|
168 | <code>TParticles</code></a>. |
---|
169 | </ul> |
---|
170 | |
---|
171 | In addition, some methods that are directly related to corresponding |
---|
172 | PYTHIA methods are implemented |
---|
173 | <ul> |
---|
174 | <li><code>ReadString(const char* string)</code> -> |
---|
175 | <code>readString(...)</code></li> |
---|
176 | <li><code>ReadConfigFile(const char* string)</code> -> |
---|
177 | <code>readFile(...)</code></li> |
---|
178 | <li><code>Initialize(int idAin, int idBin, double ecms)</code> -> |
---|
179 | <code>init(...)</code></li> |
---|
180 | <li><code>EventListing()</code> -> |
---|
181 | <code>event.list()</code></li> |
---|
182 | <li><code>PrintStatistic()</code> -> |
---|
183 | <code>statistics()</code></li> |
---|
184 | </ul> |
---|
185 | |
---|
186 | These methods provide already the basic PYTHIA functionality |
---|
187 | interactively from the ROOT command line. However, this does not mean |
---|
188 | that the usage of PYTHIA from within ROOT is restricted to these methods. |
---|
189 | In compiled code, one can always obtain a pointer to the |
---|
190 | <code>Pythia</code> instance e.g. |
---|
191 | <pre> |
---|
192 | TPythia8 *tp = new TPythia8(); |
---|
193 | Pythia8::Pythia *p = tp->Pythia8();</pre> |
---|
194 | giving access to the full PYTHIA functionality. To access this |
---|
195 | functionality in the CINT interpreter see the "Advanced usage" |
---|
196 | section below.</li> |
---|
197 | |
---|
198 | <li><a href="http://root.cern.ch/root/html/TPythia8Decayer.html"> |
---|
199 | <code>TPythia8Decayer</code></a> is an implementation of the |
---|
200 | <a href="http://root.cern.ch/root/html/TVirtualMCDecayer.html"> |
---|
201 | <code>TVirtualMCDecayer</code></a> interface.<br/> |
---|
202 | It allows you to use PYTHIA as a plug-in decayer for simulation |
---|
203 | frameworks based on the Virtual Monte Carlo |
---|
204 | (<a href="http://root.cern.ch/drupal/content/vmc">VMC</a>) interface |
---|
205 | classes. The main methods of the interface are |
---|
206 | <ul> |
---|
207 | <li><code>TPythia8Decayer::Init()</code> for initialisation,</li> |
---|
208 | <li><code>TPythia8Decayer::Decay(Int_t pdg, TLorentzVector* p)</code> |
---|
209 | to decay a particle with PDG code <code>pdg</code> and |
---|
210 | <a href="http://root.cern.ch/root/html/TLorentzVector.html"> |
---|
211 | 4-momentum</a> <code>p</code>, and </li> |
---|
212 | <li><code>ImportParticles(TClonesArray* particles)</code> |
---|
213 | to retrieve the decay products as |
---|
214 | <a href="http://root.cern.ch/root/html/TParticle.html"> |
---|
215 | <code>TParticles</code></a> in the |
---|
216 | <code><a href="http://root.cern.ch/root/html/TClonesArray.html"> |
---|
217 | TClonesArray</a> particles</code>.</li> |
---|
218 | </ul></li> |
---|
219 | </ul> |
---|
220 | |
---|
221 | <h4>An example</h4> |
---|
222 | |
---|
223 | A <a href="http://root.cern.ch/root/html/tutorials/pythia/pythia8.C.html"> |
---|
224 | basic example</a> for generating minimum-bias events with PYTHIA 8 inside |
---|
225 | a ROOT macro, and filling some histograms with the kinematics of the |
---|
226 | final-state particles is provided in either of the locations below |
---|
227 | <pre> |
---|
228 | /path_to_ROOT_source/tutorials/pythia/pythia8.C |
---|
229 | /path_to_ROOT_installation/share/doc/root/tutorials/pythia/pythia8.C |
---|
230 | </pre> |
---|
231 | <br/> |
---|
232 | Note that before executing this script |
---|
233 | <ul> |
---|
234 | <li>the environment variables <code>PYTHIA8</code> and |
---|
235 | <code>PYTHIA8DATA</code> must be setup correctly e.g. |
---|
236 | <pre> |
---|
237 | export PYTHIA8=/path_to_PYTHIA_installation |
---|
238 | export PYTHIA8DATA=$PYTHIA8/xmldoc |
---|
239 | <pre></li> |
---|
240 | <li>your LD_LIBRARY_PATH must contain the location of the |
---|
241 | PYTHIA 8 shared library, e.g. |
---|
242 | <pre> |
---|
243 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:path_to_PYTHIA8_installation/lib |
---|
244 | </pre> |
---|
245 | </li> |
---|
246 | </ul> |
---|
247 | The script can then be run with ROOT |
---|
248 | <pre> |
---|
249 | root pythia8.C |
---|
250 | </pre> |
---|
251 | After execution, ROOT will display some histograms from the event |
---|
252 | generation. |
---|
253 | |
---|
254 | <h4>Advanced usage</h4> |
---|
255 | |
---|
256 | To access the full PYTHIA functionality from the CINT interpreter, |
---|
257 | a ROOT dictionary must be created. An example of creating this |
---|
258 | dictionary is contained in the <code>rootexamples</code> directory. |
---|
259 | The <code>pythiaDict.so</code> library may be created by running |
---|
260 | <pre> |
---|
261 | make dict |
---|
262 | </pre> |
---|
263 | |
---|
264 | This may then be loaded in ROOT giving full access to the full PYTHIA 8 |
---|
265 | functionality, e.g. in an interactive session |
---|
266 | <pre> |
---|
267 | gSystem->Load("path_to_PYTHIA8_installation/rootexamples/pythiaDict"); |
---|
268 | Pythia8::Pythia *p = new Pythia8::Pythia(); |
---|
269 | p->readString("SoftQCD:minBias = on"); |
---|
270 | </pre> |
---|
271 | |
---|
272 | </body> |
---|
273 | </html> |
---|
274 | |
---|
275 | <!-- Copyright (C) 2012 Torbjorn Sjostrand --> |
---|