1 |
hegner |
1.1 |
/*!
|
2 |
|
|
|
3 |
llista |
1.2 |
\page PhysicsTools_PythonAnalysis Package PhysicsTools/PythonAnalysis
|
4 |
hegner |
1.1 |
<center>
|
5 |
|
|
<small>
|
6 |
hegner |
1.10 |
<a href=http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/PhysicsTools/PythonAnalysis/?cvsroot=CMSSW>CVS head for this package</a> -
|
7 |
|
|
<a href=http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/PhysicsTools/PythonAnalysis/developers?rev=HEAD&cvsroot=CMSSW&content-type=text/vnd.viewcvs-markup>Administrative privileges</a>
|
8 |
hegner |
1.1 |
</small>
|
9 |
|
|
</center>
|
10 |
|
|
|
11 |
|
|
\section desc Description
|
12 |
|
|
<!-- Short description of what this package is supposed to provide -->
|
13 |
hegner |
1.3 |
Examples of using CMSSW in Python.
|
14 |
|
|
Some helper routines for startup, tab completion and shorter syntax.
|
15 |
|
|
|
16 |
hegner |
1.1 |
|
17 |
|
|
\subsection interface Public interface
|
18 |
llista |
1.5 |
- <b>cmstools</b>: public interface to all modules.
|
19 |
hegner |
1.4 |
|
20 |
hegner |
1.1 |
\subsection modules Modules
|
21 |
hegner |
1.3 |
- <b>cmstools.py</b>: prepares environment and defines some commands
|
22 |
|
|
- <b>cmscompleter.py</b>: class for tab completion
|
23 |
|
|
- <b>namespaceDict.py</b>: builds the FWLite namespace (without loading libs)
|
24 |
hegner |
1.9 |
- <b>iterators.py></b>: decorator for adding iterators to some containers
|
25 |
hegner |
1.1 |
|
26 |
|
|
\subsection tests Unit tests and examples
|
27 |
hegner |
1.8 |
- <b>interactive use</b>: all libraries are loaded automatically when needed.
|
28 |
hegner |
1.4 |
fire up the python interpreter
|
29 |
|
|
\htmlonly
|
30 |
|
|
<pre>
|
31 |
|
|
python
|
32 |
llista |
1.5 |
</pre>
|
33 |
hegner |
1.4 |
\endhtmlonly
|
34 |
|
|
and import cmstools and ROOT:
|
35 |
|
|
\htmlonly
|
36 |
|
|
<pre>
|
37 |
hegner |
1.9 |
from PhysicsTools.PythonAnalysis import *
|
38 |
hegner |
1.4 |
from ROOT import *
|
39 |
|
|
</pre>
|
40 |
|
|
\endhtmlonly
|
41 |
|
|
That's it.
|
42 |
hegner |
1.7 |
- <b>MCTruth.py</b>: Reads gen event information and prints event number (root version)
|
43 |
|
|
- <b>MCTruth2.py</b>: Reads gen event information and prints event number (using cmstools)
|
44 |
llista |
1.2 |
- <b>trackerHits.py</b>: Reads sim event information and creates the files <tt>histo.root</tt>
|
45 |
|
|
and <tt>tofhits.jpg</tt>.
|
46 |
hegner |
1.4 |
\htmlonly
|
47 |
|
|
<ol>
|
48 |
|
|
<li>Prepare the environment and load the cms module:
|
49 |
|
|
<pre>
|
50 |
hegner |
1.8 |
from PhysicsTools.PythonAnalysis.cmstools import *
|
51 |
hegner |
1.4 |
from ROOT import *
|
52 |
|
|
</pre>
|
53 |
|
|
<li>Open ROOT file and access branch:
|
54 |
|
|
<pre>
|
55 |
hegner |
1.8 |
events = EventTree.('simevents.root')
|
56 |
hegner |
1.4 |
</pre>
|
57 |
|
|
<li>Prepare histogram and loop over all events to fill it
|
58 |
|
|
<pre>
|
59 |
|
|
histo = TH1F('tofhits', 'Tof of hits', 100, -0.5, 50)
|
60 |
|
|
|
61 |
hegner |
1.8 |
for event in events:
|
62 |
|
|
simHits = event.getProduct('PSimHit_r_TrackerHitsTIBLowTof.obj')
|
63 |
|
|
for hit in simHits:
|
64 |
hegner |
1.4 |
histo.Fill(hit.timeOfFlight())
|
65 |
|
|
</pre>
|
66 |
|
|
<li>Save histogram in a file:
|
67 |
|
|
<pre>
|
68 |
|
|
hFile = TFile('histo.root', 'RECREATE')
|
69 |
|
|
histo.Write()
|
70 |
|
|
</pre>
|
71 |
|
|
<li>Plot histogram as a jpg-file:
|
72 |
|
|
<pre>
|
73 |
|
|
gROOT.SetBatch()
|
74 |
|
|
gROOT.SetStyle('Plain')
|
75 |
|
|
|
76 |
|
|
c = TCanvas()
|
77 |
|
|
histo.Draw()
|
78 |
|
|
c.SaveAs('tofhits.jpg')
|
79 |
|
|
</pre>
|
80 |
|
|
</ol>
|
81 |
|
|
\endhtmlonly
|
82 |
|
|
|
83 |
llista |
1.2 |
- <b>howto.txt</b>: short explanation
|
84 |
hegner |
1.1 |
|
85 |
|
|
\section status Status and planned development
|
86 |
|
|
<!-- e.g. completed, stable, missing features -->
|
87 |
|
|
Prototype.
|
88 |
|
|
|
89 |
|
|
<hr>
|
90 |
hegner |
1.8 |
Last updated: 03-MAR-2007 B. Hegner
|
91 |
hegner |
1.1 |
*/
|
92 |
|
|
|