ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaPoolExample_Read.py
Go to the documentation of this file.
1#!/env/python
2
3# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4
5
16
17from AthenaConfiguration.AllConfigFlags import initConfigFlags
18from AthenaConfiguration.ComponentFactory import CompFactory
19from AthenaCommon.Constants import DEBUG
20
21# Setup flags
22flags = initConfigFlags()
23flags.Input.Files = [ "EmptyPoolFile.root", "SimplePoolFile1.root",
24 "EmptyPoolFile.root", "SimplePoolFile2.root", "SimplePoolFile3.root"]
25flags.Exec.MaxEvents = -1
26flags.Common.MsgSuppression = False
27flags.Exec.DebugMessageComponents = [ "ReadData", "PoolSvc", "AthenaPoolCnvSvc",
28 "AthenaPoolAddressProviderSvc", "MetaDataSvc", "EventSelector" ]
29
30#Run3 for now
31from AthenaConfiguration.TestDefaults import defaultGeometryTags
32flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
33
34flags.lock()
35
36# Main services
37from AthenaConfiguration.MainServicesConfig import MainServicesCfg
38acc = MainServicesCfg( flags )
39
40# Configure AthenaPool reading
41from AthenaPoolExampleAlgorithms.AthenaPoolExampleConfig import AthenaPoolExampleReadCfg
42acc.merge( AthenaPoolExampleReadCfg(flags, readCatalogs = ["file:Catalog1.xml"]) )
43
44# Create and attach the reading algorithm
45acc.addEventAlgo( CompFactory.AthPoolEx.ReadData("ReadData", OutputLevel = DEBUG) )
46
47evSelector = acc.getService("EventSelector")
48evSelector.SkipEvents = 8 # // skip the first 8 events
49evSelector.SkipEventSequence = [ 9, 10 ] # // skip two more events
50#evSelector.SkipEventSequence = " 4-6,7 , 8 , 9 - 10 "; # // skip seven more events
51#evSelector.ProcessEventSequence = "11, 12, 13,14,15, 16-20, 21 - 25 , 26- 100"; # // skip two more events
52
53#Switch Off for TAG - start
54poolAttribs = acc.getService("AthenaPoolCnvSvc").InputPoolAttributes
55# Turn on the tree cache for the CollectionTree - tree cache only works for one tree.
56# And set tree cache size - default is 10 MB (10 000 000)
57poolAttribs += [ "DatabaseName = '*'; ContainerName = 'CollectionTree'; TREE_CACHE = '100000'" ]
58
59# Print out values - must have PoolSvc in info mode
60poolAttribs += [ "DatabaseName = '*'; TREE_CACHE_SIZE = 'int'" ]
61
62# Print out for each event the number of bytes read and the number of
63# read calls. With the tree cache, one should see jumps in the bytes
64# read by the cache size, i.e. the bytes read should not change each
65# event. However, the cache only works on one tree - the main event
66# tree (CollectionTree) - and we read some things from other trees, so
67# one does see a small increase event-by-event.
68printOpts = acc.getService("AthenaPoolCnvSvc").PrintInputAttrPerEvt
69printOpts += [ "DatabaseName = '*'; BYTES_READ = 'double'" ]
70printOpts += [ "DatabaseName = '*'; READ_CALLS = 'int'" ]
71#Switch Off for TAG - end
72
73# Run
74import sys
75sc = acc.run(flags.Exec.MaxEvents)
76sys.exit(sc.isFailure())