Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
PhysicsTools
PythonAnalysis
examples
interactiveExample.py
Go to the documentation of this file.
1
# has to be called with python -i interactiveExample.py
2
3
from
PhysicsTools.PythonAnalysis
import
*
4
from
ROOT
import
*
5
6
# prepare the FWLite autoloading mechanism
7
gSystem.Load(
"libFWCoreFWLite.so"
)
8
AutoLibraryLoader.enable
()
9
10
# enable support for files > 2 GB
11
gSystem.Load(
"libIOPoolTFileAdaptor"
)
12
ui =
TFileAdaptorUI
()
13
14
15
# load the example file from castor
16
theFile = TFile.Open(
"castor:/castor/cern.ch/cms/store/CSA06/CSA06-106-os-Jets-0/AOD/CMSSW_1_0_6-AODSIM-H15a59ba7b4c3d9e291172f60a399301f/1025/96C3197B-0264-DB11-9A9C-00304885AD72.root"
)
17
18
19
# access the event tree
20
print
"=============================="
21
print
"Loading event tree"
22
events = EventTree(theFile)
23
24
print
"Start looping over some events"
25
for
event
in
events:
26
photons = event.photons
27
print
" Number of photons in event %i: %i"
% (event, len(photons))
28
if
event > 2:
break
# workaround will become obsolete
29
30
31
32
#####################################################
33
# all following commands have been used interactively
34
#
35
## accessing photons
36
# print photon[0]
37
#
38
## looping over the photons. what's there?
39
#for photon in photons:
40
# print photon.energy()
41
#
42
## selecting photons
43
#selectedPhotons = [p for p in photons if p.energy()> 3]
44
#
45
## looking at the results
46
#for photon in selectedPhotons:
47
# print photon.energy()
48
#
49
## how to find out about aliases
50
#for alias in events.getListOfAliases():
51
# print alias
52
#
53
## how to learn about an object
54
#help(photon[0])
55
#
56
## how to leave the session
57
#
58
# Ctrl-D
59
TFileAdaptorUI
Definition:
TFileAdaptor.cc:264
AutoLibraryLoader::enable
static void enable()
enable automatic library loading
Definition:
AutoLibraryLoader.cc:50
PythonAnalysis
Generated for CMSSW Reference Manual by
1.8.5