ATLAS Offline Software
Loading...
Searching...
No Matches
test_athena_evtstore_root.py
Go to the documentation of this file.
1from glob import glob
2#_cbntfiles = glob('/tmp/binet/data/cbnt_aod.aan.*.root')
3#_cbntfiles = glob('/tmp/binet/data/NTUP_TOP.*.root*')
4#_cbntfiles = glob('/tmp/binet/data/mini*.root*')
5#_cbntfiles = glob('/tmp/binet/data/ntuple*.root*')
6_cbntfiles = [
7 'root://eosatlas.cern.ch//eos/atlas/user/b/binet/utests/utests/filter-d3pd/ntuple.0.root',
8 'root://eosatlas.cern.ch//eos/atlas/user/b/binet/utests/utests/filter-d3pd/ntuple.1.root',
9 ]
10import AthenaRootComps.ReadAthenaRoot
11svcMgr.EventSelector.InputCollections = _cbntfiles
12svcMgr.EventSelector.TupleName = "CollectionTree"
13svcMgr.EventSelector.TupleName = "egamma"
14
15from AthenaPython import PyAthena
16StatusCode = PyAthena.StatusCode
17
19
20 def __init__(self, name='MyAlg', **kw):
21 kw['name'] = name
22 self.activeBranches = kw.get(
23 'activeBranches',
24 ['RunNumber',
25 'EventNumber',
26 'el_n',
27 'el_eta',
28 'el_jetcone_dr',
29 ])
30 super(MyAlg, self).__init__(**kw)
31 return
32
33 def initialize(self):
34 self.evtstore = PyAthena.py_svc('StoreGateSvc')
35
36 return StatusCode.Success
37
38 def execute(self):
39 self.msg.info('running execute...')
40 #keys = self.evtstore.keys()
41 for br in self.activeBranches:
42 try:
43 o = self.evtstore[br]
44 if hasattr(o, 'at'):
45 o = list(o)
46 for i,v in enumerate(o):
47 if hasattr(v, 'at') and not isinstance(v, (basestring,)):
48 o[i] = list(v)
49 self.msg.info('%s: %r', br, o)
50 except Exception, err:
51 self.msg.info(' --> err for [%s]: %s' % (br, err))
52 pass
53 return StatusCode.Success
54
55 def finalize(self):
56 return StatusCode.Success
57
58 pass # MyAlg
59
60from AthenaCommon.AlgSequence import AlgSequence
61job = AlgSequence()
62job += MyAlg()
63
64activeBranches = [ 'nMC' ] # only 1 branch
65activeBranches = [ '*' ] # all branches
66activeBranches = [] # no branch
67
68svcMgr.EventSelector.ActiveBranches = activeBranches
69job.MyAlg.ActiveBranches = activeBranches
70
71if not 'EVTMAX' in dir():
72 EVTMAX=-1
73theApp.EvtMax = EVTMAX
MsgStream & msg() const
virtual StatusCode execute() override
virtual StatusCode finalize() override
virtual StatusCode initialize() override