ATLAS Offline Software
Loading...
Searching...
No Matches
test_athena_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('activeBranches',
23 ['EventNumber',
24 'RunNumber',
25 ])
26 super(MyAlg, self).__init__(**kw)
27 return
28
29 def initialize(self):
30
31 self.thSvc = PyAthena.py_svc('THistSvc', iface='ITHistSvc')
32 if not self.thSvc:
33 self.msg.error("Could not retrieve THistSvc !")
34 return StatusCode.Failure
35
36 self.tree = self.thSvc.get('/temp/TTreeStream/egamma',
37 klass='TTree')
38 if not self.tree:
39 self.msg.error('could not retrieve tree from THistSvc')
40 return StatusCode.Failure
41
42 return StatusCode.Success
43
44 def execute(self):
45 self.msg.info('running execute...')
46 for br in self.activeBranches:
47 b = getattr(self.tree, br)
48 if hasattr(b, 'at'):
49 b = list(b)
50 self.msg.info('branch [%s]: %r', br, b)
51 return StatusCode.Success
52
53 def finalize(self):
54 return StatusCode.Success
55
56 pass # MyAlg
57
58from AthenaCommon.AlgSequence import AlgSequence
59job = AlgSequence()
60job += MyAlg()
61
62activeBranches = [ 'nMC' ] # only 1 branch
63activeBranches = [ '*' ] # all branches
64activeBranches = [] # no branch
65
66svcMgr.EventSelector.ActiveBranches = activeBranches
67job.MyAlg.ActiveBranches = activeBranches
68
69if not 'EVTMAX' in dir():
70 EVTMAX=-1
71theApp.EvtMax = EVTMAX
MsgStream & msg() const
virtual StatusCode execute() override
virtual StatusCode finalize() override
virtual StatusCode initialize() override
__init__(self, name='MyAlg', **kw)
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130