ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/PhysicsTools/PythonAnalysis/doc/PythonAnalysis.doc
Revision: 1.6
Committed: Sun Oct 15 18:14:15 2006 UTC (18 years, 6 months ago) by hegner
Content type: application/msword
Branch: MAIN
Changes since 1.5: +1 -1 lines
Log Message:
update to doc

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.6 - <b>MCTruth.py</b>: Reads gen event information and prints event number
48 llista 1.2 - <b>trackerHits.py</b>: Reads sim event information and creates the files <tt>histo.root</tt>
49     and <tt>tofhits.jpg</tt>.
50 hegner 1.4 \htmlonly
51     <ol>
52     <li>Prepare the environment and load the cms module:
53     <pre>
54     from cmstools import *
55     from ROOT import *
56     </pre>
57     <li>Open ROOT file and access branch:
58     <pre>
59     file = TFile('simevent.root')
60     events = file.Get('Events')
61     branch = events.GetBranch('PSimHit_r_TrackerHitsTIBLowTof.obj')
62    
63     simHit = std.vector(PSimHit)()
64     branch.SetAddress(simHit)
65     </pre>
66     <li>Prepare histogram and loop over all events to fill it
67     <pre>
68     histo = TH1F('tofhits', 'Tof of hits', 100, -0.5, 50)
69    
70     for ev in all(events):
71     branch.GetEntry(ev)
72     for hit in all(simHit):
73     histo.Fill(hit.timeOfFlight())
74     </pre>
75     <li>Save histogram in a file:
76     <pre>
77     hFile = TFile('histo.root', 'RECREATE')
78     histo.Write()
79     </pre>
80     <li>Plot histogram as a jpg-file:
81     <pre>
82     gROOT.SetBatch()
83     gROOT.SetStyle('Plain')
84    
85     c = TCanvas()
86     histo.Draw()
87     c.SaveAs('tofhits.jpg')
88     </pre>
89     </ol>
90     \endhtmlonly
91    
92 llista 1.2 - <b>howto.txt</b>: short explanation
93 hegner 1.1
94     \section status Status and planned development
95     <!-- e.g. completed, stable, missing features -->
96     Prototype.
97    
98     <hr>
99 hegner 1.4 Last updated: 23-MAR-2006 B. Hegner
100 hegner 1.1 */
101