source: HiSusy/trunk/Pythia8/pythia8170/phpdoc/ROOTusage.php @ 1

Last change on this file since 1 was 1, checked in by zerwas, 11 years ago

first import of structure, PYTHIA8 and DELPHES

File size: 10.0 KB
Line 
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>
10function stopRKey(evt) {
11var evt = (evt) ? evt : ((event) ? event : null);
12var node = (evt.target) ? evt.target :((evt.srcElement) ? evt.srcElement : null);
13if ((evt.keyCode == 13) && (node.type=="text"))
14{return false;}
15}
16
17document.onkeypress = stopRKey;
18</script>
19<?php
20if($_POST['saved'] == 1) {
21if($_POST['filepath'] != "files/") {
22echo "<font color='red'>SETTINGS SAVED TO FILE</font><br/><br/>"; }
23else {
24echo "<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
32Many PYTHIA users wish to use <a href="http://root.cern.ch/">ROOT</a>
33to produce histograms, or even to run PYTHIA as a plugin to ROOT.
34This is possible. It is not a task supported by the PYTHIA team,
35however. All issues involving ROOT usage should be directed to the
36ROOT team, or to the local support team of your collaboration.
37Below some helpful hints have been collected. The text is based on
38contributions by Rene Brun, Andreas Morsch and Axel Naumann.
39Another example may be found in the
40<a href="http://home.fnal.gov/~skands/vincia/">VINCIA</a> 
41add-on program for parton showers, but this should also work for
42a PYTHIA standalone run.
43<br/><br/>
44Note that in all that follows, a Linux-type system with a Bash shell
45and 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
53One can perform the generation and analysis of events in a completely
54standalone fashion, and only use ROOT to process the completed events.
55Some example programs are provided in the <code>rootexamples</code>
56directory, with details provided below and in the <code>README</code>
57file.
58
59The examples assume that you have already compiled the PYTHIA library,
60ROOT is installed, and that all paths have been setup correctly (e.g.
61PATH and LD_LIBRARY_PATH). If these paths are not already set, ROOT
62typically comes with a shell script to set these paths, which can be
63run with
64<pre>
65    source /path_to_ROOT_installation/bin/thisroot.sh
66</pre>
67
68<h4>Histogramming with ROOT</h4>
69
70An example of histogramming with ROOT is provided in
71<code>rootexamples/hist.cc</code>. It may be compiled and run
72with the following commands
73<pre>
74    make hist
75    ./hist.exe
76</pre>
77After PYTHIA has run, a ROOT histogram of the charged multiplicity in
78the 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
83Instead of only generating histograms, it is possible to store entire
84PYTHIA events in ROOT trees. The <code>tree</code> example in the
85<code>rootexamples</code> subdirectory provides an example of this and
86is 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/>
98The example may be compiled and run with
99<pre>
100    make tree
101    ./tree.exe
102</pre>
103After the example has run, the <code>pytree.root</code> file will now
104be present containing the PYTHIA events. Note that files can become
105quite large when many events are generated.
106
107<br/><br/><hr/>
108<h3>PYTHIA as a plugin to ROOT</h3>
109
110In more ROOT-centric applications, PYTHIA can be run as a ROOT plug-in.
111This requires a version of ROOT that has been
112<a href="http://root.cern.ch/drupal/content/installing-root-source">
113installed from source</a>. The reason is that the interfaces depend on
114PYTHIA header files that are not distributed with ROOT. Installing ROOT
115is not more difficult than the PYTHIA installation, and some
116guidelines are provided below.
117
118<h4>Installation</h4>
119
120To be run as a plugin, PYTHIA must be compiled as a shared library.
121This is achieved by running the PYTHIA <code>configure</code> script
122with the <code>--enable-shared</code> option before <code>make</code>
123is run.<br/><br/>
124
125Define an environment variable for the path to your
126PYTHIA installation directory
127<pre>
128    export PYTHIA8=path_to_PYTHIA8_installation
129</pre>
130Before compiling ROOT,
131<a href="http://root.cern.ch/drupal/content/installing-root-source">
132configure ROOT</a> by running the <code>configure</code> command
133including the following options
134<pre>
135    --enable-pythia8
136    --with-pythia8-incdir=$PYTHIA8/include
137    --with-pythia8-libdir=$PYTHIA8/lib
138</pre>
139In case ROOT has already been compiled before, it will only recompile
140the PYTHIA module and build the library <code>libEGPythia8</code>.
141
142<h4>Interfaces</h4>
143
144When running PYTHIA as a plugin, the exact interface structure becomes
145very relevant. ROOT provides two simple interfaces (wrappers) for
146PYTHIA 8. The code for these interfaces are located in
147<pre>
148    path_to_ROOT_source/montecarlo/pythia8
149</pre>
150<br/>
151The 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
223A <a href="http://root.cern.ch/root/html/tutorials/pythia/pythia8.C.html">
224basic example</a> for generating minimum-bias events with PYTHIA 8 inside
225a ROOT macro, and filling some histograms with the kinematics of the
226final-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/>
232Note 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>
247The script can then be run with ROOT
248<pre>
249    root pythia8.C
250</pre>
251After execution, ROOT will display some histograms from the event
252generation.
253
254<h4>Advanced usage</h4>
255
256To access the full PYTHIA functionality from the CINT interpreter,
257a ROOT dictionary must be created. An example of creating this
258dictionary is contained in the <code>rootexamples</code> directory.
259The <code>pythiaDict.so</code> library may be created by running
260<pre>
261    make dict
262</pre>
263
264This may then be loaded in ROOT giving full access to the full PYTHIA 8
265functionality, 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 -->
Note: See TracBrowser for help on using the repository browser.