ATLAS Offline Software
test_athena_evtstore_root.py
Go to the documentation of this file.
1 from 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  ]
10 import AthenaRootComps.ReadAthenaRoot
11 svcMgr.EventSelector.InputCollections = _cbntfiles
12 svcMgr.EventSelector.TupleName = "CollectionTree"
13 svcMgr.EventSelector.TupleName = "egamma"
14 
15 from AthenaPython import PyAthena
16 StatusCode = 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 
60 from AthenaCommon.AlgSequence import AlgSequence
61 job = AlgSequence()
62 job += MyAlg()
63 
64 activeBranches = [ 'nMC' ] # only 1 branch
65 activeBranches = [ '*' ] # all branches
66 activeBranches = [] # no branch
67 
68 svcMgr.EventSelector.ActiveBranches = activeBranches
69 job.MyAlg.ActiveBranches = activeBranches
70 
71 if not 'EVTMAX' in dir():
72  EVTMAX=-1
73 theApp.EvtMax = EVTMAX
grepfile.info
info
Definition: grepfile.py:38
test_athena_evtstore_root.MyAlg.__init__
def __init__(self, name='MyAlg', **kw)
Definition: test_athena_evtstore_root.py:20
test_athena_evtstore_root.MyAlg.activeBranches
activeBranches
Definition: test_athena_evtstore_root.py:22
python.AlgSequence.AlgSequence
AlgSequence
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py:7
test_athena_evtstore_root.MyAlg
Definition: test_athena_evtstore_root.py:18
test_athena_evtstore_root.MyAlg.evtstore
evtstore
Definition: test_athena_evtstore_root.py:34
PyAthena::Alg::initialize
virtual StatusCode initialize() override
Definition: PyAthenaAlg.cxx:60
PyAthena::Alg::execute
virtual StatusCode execute() override
Definition: PyAthenaAlg.cxx:93
PyAthena::Alg::finalize
virtual StatusCode finalize() override
Definition: PyAthenaAlg.cxx:86
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
beamspotman.dir
string dir
Definition: beamspotman.py:623
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
PyAthena::Alg
Definition: PyAthenaAlg.h:33