/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
PhysicsTools/PythonAnalysis/examples/MCTruth.py
35 строк
992 B
Shahzad Malik Muzaffar
[ANALYSIS] py2/3 compatibility:drop use of __future__
22 ноя 2024, 20:16
22 ноя 2024, 20:16
8d027cc
Код
Авторство
О чём код?
from PhysicsTools.PythonAnalysis import * import ROOT from ROOT import gSystem, TFile # prepare the FWLite autoloading mechanism gSystem.Load("libFWCoreFWLite.so") ROOT.FWLiteEnabler.enable() # load the file with the generator output theFile = TFile("generatorOutput.root") events = theFile.Get("Events") # Needed for SetAddress to work right events.GetEntry() # set the buffers for the branches you want to access # 1) create a buffer # 2) open the root branch # 3) connect buffer and branch # example: generator particles source = edm.HepMCProduct() sourceBranch = events.GetBranch(events.GetAlias("source")) sourceBranch.SetAddress(source) # now loop over the events for index in all(events): # update all branches - the buffers are filled automatically # Hint: put all you branches in a list and loop over it sourceBranch.GetEntry(index) events.GetEntry(index,0) # do something with the data genEvent = source.GetEvent(); print(genEvent.event_number())