ATLAS Offline Software
test_athena_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('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 
58 from AthenaCommon.AlgSequence import AlgSequence
59 job = AlgSequence()
60 job += MyAlg()
61 
62 activeBranches = [ 'nMC' ] # only 1 branch
63 activeBranches = [ '*' ] # all branches
64 activeBranches = [] # no branch
65 
66 svcMgr.EventSelector.ActiveBranches = activeBranches
67 job.MyAlg.ActiveBranches = activeBranches
68 
69 if not 'EVTMAX' in dir():
70  EVTMAX=-1
71 theApp.EvtMax = EVTMAX
grepfile.info
info
Definition: grepfile.py:38
python.AlgSequence.AlgSequence
AlgSequence
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py:7
PyAthena::Alg::initialize
virtual StatusCode initialize() override
Definition: PyAthenaAlg.cxx:60
PyAthena::Alg::execute
virtual StatusCode execute() override
Definition: PyAthenaAlg.cxx:93
test_athena_root.MyAlg.__init__
def __init__(self, name='MyAlg', **kw)
Definition: test_athena_root.py:20
test_athena_root.MyAlg.activeBranches
activeBranches
Definition: test_athena_root.py:22
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
test_athena_root.MyAlg.tree
tree
Definition: test_athena_root.py:36
test_athena_root.MyAlg
Definition: test_athena_root.py:18
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
PyAthena::Alg
Definition: PyAthenaAlg.h:33
error
Definition: IImpactPoint3dEstimator.h:70
test_athena_root.MyAlg.thSvc
thSvc
Definition: test_athena_root.py:31