Revision: | 1.5 |
Committed: | Fri Mar 24 09:11:39 2006 UTC (19 years, 1 month ago) by llista |
Content type: | application/msword |
Branch: | MAIN |
CVS Tags: | CMSSW_1_3_6, CMSSW_1_3_1_HLT6, CMSSW_1_3_5, CMSSW_1_3_1_HLT5, CMSSW_1_3_1_HLT4, CMSSW_1_3_1_HLT3, CMSSW_1_3_4, CMSSW_1_3_3, CMSSW_1_3_2, CMSSW_1_2_6, CMSSW_1_2_5, CMSSW_1_3_1, CMSSW_1_2_4, CMSSW_1_3_0, CMSSW_1_3_0_pre7, CMSSW_1_3_0_pre6, CMSSW_1_2_0_4821, CMSSW_1_2_0_g4_82p01, CMSSW_1_3_0_pre5, CMSSW_1_3_0_pre4, CMSSW_1_2_3, CMSSW_1_3_0_pre3, CMSSW_1_2_0_g4_82, CMSSW_1_3_0_SLC4_pre2, CMSSW_1_3_0_pre2, CMSSW_1_2_2, CMSSW_1_2_1, CMSSW_1_3_0_SLC4_pre1, CMSSW_1_3_0_pre1, CMSSW_1_2_0_g4_81, CMSSW_1_2_0_SL4, CMSSW_1_2_0, CMSSW_1_2_0_pre9, CMSSW_1_2_0_pre8_g4_81, CMSSW_1_2_0_pre8, CMSSW_1_1_2, CMSSW_1_2_0_pre7, CMSSW_1_2_0_pre6, CMSSW_1_2_0_pre5, CMSSW_1_2_0_pre4, CMSSW_1_1_1, CMSSW_1_2_0_pre3, CMSSW_1_0_6, CMSSW_1_2_0_pre2, CMSSW_1_0_5, CMSSW_1_1_0, CMSSW_1_2_0_pre1, CMSSW_1_0_4, CMSSW_1_1_0_pre4, CMSSW_1_0_3, CMSSW_1_0_0_g4_81, CMSSW_1_1_0_pre3, CMSSW_1_0_2, CMSSW_1_0_1, CMSSW_1_1_0_pre2, CMSSW_1_0_0, CMSSW_1_0_0_pre5, CMSSW_1_1_0_pre1, CMSSW_0_8_4, CMSSW_1_0_0_pre4, CMSSW_1_0_0_pre3, CMSSW_0_9_2, CMSSW_0_8_3, CMSSW_1_0_0_pre2, CMSSW_0_9_0_pre2_g4_81, CMSSW_1_0_0_pre1, CMSSW_0_9_1, CMSSW_0_8_2, CMSSW_0_9_0, CMSSW_0_9_0_pre3, CMSSW_0_9_0_pre2, CMSSW_0_9_0_pre1, CMSSW_0_8_1, CMSSW_0_8_0, CMSSW_0_8_0_pre5, CMSSW_0_8_0_pre4, CMSSW_0_8_0_pre3, CMSSW_0_7_2, CMSSW_0_8_0_pre2, CMSSW_0_7_1, CMSSW_0_8_0_pre1, CMSSW_0_7_0, CMSSW_0_7_0_pre6, CMSSW_0_7_0_pre5, CMSSW_0_7_0_pre4, CMSSW_0_7_0_pre3, CMSSW_0_6_1, CMSSW_0_7_0_pre2, V00-00-04, CMSSW_0_7_0_pre1, CMSSW_0_6_0, CMSSW_0_6_0_pre7, CMSSW_0_6_0_pre6, CMSSW_0_6_0_pre5, CMSSW_0_6_0_pre4, CMSSW_0_6_0_pre3, CMSSW_0_6_0_pre2, V00-00-03 |
Changes since 1.4: | +3 -1 lines |
Log Message: | fixed documentation |
# | 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 | |||
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 |