ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/PhysicsTools/PythonAnalysis/doc/PythonAnalysis.doc
Revision: 1.7
Committed: Sun Oct 15 20:57:26 2006 UTC (18 years, 6 months ago) by hegner
Content type: application/msword
Branch: MAIN
CVS Tags: V00-01-03, V00-01-02
Changes since 1.6: +2 -1 lines
Log Message:
implemented new access method to event tree

File Contents

# User Rev Content
1 hegner 1.1 /*!
2    
3 llista 1.2 \page PhysicsTools_PythonAnalysis Package PhysicsTools/PythonAnalysis
4 hegner 1.1 <center>
5     <small>
6 llista 1.2 <a href=http://cmsdoc.cern.ch/swdev/viewcvs/viewcvs.cgi/CMSSW/PhysicsTools/PythonAnalysis/?cvsroot=CMSSW>CVS head for this package</a> -
7     <a href=http://cmsdoc.cern.ch/swdev/viewcvs/viewcvs.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.1
25     \subsection tests Unit tests and examples
26 hegner 1.4 - <b>interactive use</b>: all libraries are loaded automatically when needed. To start set the environment variable <tt>PYTHONPATH</tt>:
27     \htmlonly
28     <pre>
29     export PYTHONPATH=$CMSSW_BASE/src/PhysicsTools/PythonAnalysis/python:$PYTHONPATH (bash)
30     setenv PYTHONPATH $CMSSW_BASE/src/PhysicsTools/PythonAnalysis/python:$PYTHONPATH (csh)
31 llista 1.5 </pre>
32 hegner 1.4 \endhtmlonly
33     fire up the python interpreter
34     \htmlonly
35     <pre>
36     python
37 llista 1.5 </pre>
38 hegner 1.4 \endhtmlonly
39     and import cmstools and ROOT:
40     \htmlonly
41     <pre>
42     from cmstools import *
43     from ROOT import *
44     </pre>
45     \endhtmlonly
46     That's it.
47 hegner 1.7 - <b>MCTruth.py</b>: Reads gen event information and prints event number (root version)
48     - <b>MCTruth2.py</b>: Reads gen event information and prints event number (using cmstools)
49 llista 1.2 - <b>trackerHits.py</b>: Reads sim event information and creates the files <tt>histo.root</tt>
50     and <tt>tofhits.jpg</tt>.
51 hegner 1.4 \htmlonly
52     <ol>
53     <li>Prepare the environment and load the cms module:
54     <pre>
55     from cmstools import *
56     from ROOT import *
57     </pre>
58     <li>Open ROOT file and access branch:
59     <pre>
60     file = TFile('simevent.root')
61     events = file.Get('Events')
62     branch = events.GetBranch('PSimHit_r_TrackerHitsTIBLowTof.obj')
63    
64     simHit = std.vector(PSimHit)()
65     branch.SetAddress(simHit)
66     </pre>
67     <li>Prepare histogram and loop over all events to fill it
68     <pre>
69     histo = TH1F('tofhits', 'Tof of hits', 100, -0.5, 50)
70    
71     for ev in all(events):
72     branch.GetEntry(ev)
73     for hit in all(simHit):
74     histo.Fill(hit.timeOfFlight())
75     </pre>
76     <li>Save histogram in a file:
77     <pre>
78     hFile = TFile('histo.root', 'RECREATE')
79     histo.Write()
80     </pre>
81     <li>Plot histogram as a jpg-file:
82     <pre>
83     gROOT.SetBatch()
84     gROOT.SetStyle('Plain')
85    
86     c = TCanvas()
87     histo.Draw()
88     c.SaveAs('tofhits.jpg')
89     </pre>
90     </ol>
91     \endhtmlonly
92    
93 llista 1.2 - <b>howto.txt</b>: short explanation
94 hegner 1.1
95     \section status Status and planned development
96     <!-- e.g. completed, stable, missing features -->
97     Prototype.
98    
99     <hr>
100 hegner 1.4 Last updated: 23-MAR-2006 B. Hegner
101 hegner 1.1 */
102