Main Page
Namespaces
Classes
Package Documentation
PhysicsTools
PythonAnalysis
examples
MCTruth.py
Go to the documentation of this file.
1
from
PhysicsTools.PythonAnalysis
import
*
2
from
ROOT
import
*
3
# prepare the FWLite autoloading mechanism
4
gSystem.Load(
"libFWCoreFWLite.so"
)
5
FWLiteEnabler::
enable
()
6
7
# load the file with the generator output
8
theFile = TFile(
"generatorOutput.root"
)
9
10
events = theFile.Get(
"Events"
)
11
12
# Needed for SetAddress to work right
13
events.GetEntry()
14
15
# set the buffers for the branches you want to access
16
# 1) create a buffer
17
# 2) open the root branch
18
# 3) connect buffer and branch
19
# example: generator particles
20
source =
edm.HepMCProduct
()
21
sourceBranch = events.GetBranch(events.GetAlias(
"source"
))
22
sourceBranch.SetAddress(source)
23
24
# now loop over the events
25
for
index
in
all
(events):
26
27
# update all branches - the buffers are filled automatically
28
# Hint: put all you branches in a list and loop over it
29
sourceBranch.GetEntry(index)
30
events.GetEntry(index,0)
31
32
# do something with the data
33
genEvent = source.GetEvent();
34
print
genEvent.event_number()
Vispa.Plugins.EdmBrowser.EdmDataAccessor.all
def all(container)
Definition:
EdmDataAccessor.py:18
edm::HepMCProduct
Definition:
HepMCProduct.h:18
Reconstruction_hiPF_cff.enable
enable
Definition:
Reconstruction_hiPF_cff.py:80
PythonAnalysis
Generated for CMSSW Reference Manual by
1.8.11