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" ]
29flags.lock()
30
31# Main services
32from AthenaConfiguration.MainServicesConfig import MainServicesCfg
33acc = MainServicesCfg( flags )
34
35# Configure AthenaPool reading
36from AthenaPoolExampleAlgorithms.AthenaPoolExampleConfig import AthenaPoolExampleReadCfg
37acc.merge( AthenaPoolExampleReadCfg(flags, readCatalogs = ["file:Catalog1.xml"]) )
38
39# Create and attach the reading algorithm
40acc.addEventAlgo( CompFactory.AthPoolEx.ReadData("ReadData", OutputLevel = DEBUG) )
41
42evSelector = acc.getService("EventSelector")
43evSelector.SkipEvents = 8 # // skip the first 8 events
44evSelector.SkipEventSequence = [ 9, 10 ] # // skip two more events
45#evSelector.SkipEventSequence = " 4-6,7 , 8 , 9 - 10 "; # // skip seven more events
46#evSelector.ProcessEventSequence = "11, 12, 13,14,15, 16-20, 21 - 25 , 26- 100"; # // skip two more events
47
48#Switch Off for TAG - start
49poolAttribs = acc.getService("AthenaPoolCnvSvc").InputPoolAttributes
50# Turn on the tree cache for the CollectionTree - tree cache only works for one tree.
51# Set number of events for learning before turning on cache - default is 5
52poolAttribs += [ "DatabaseName = '*'; TREE_CACHE_LEARN_EVENTS = '6'" ]
53# And set tree cache size - default is 10 MB (10 000 000)
54poolAttribs += [ "DatabaseName = '*'; ContainerName = 'CollectionTree'; TREE_CACHE = '100000'" ]
55
56# Print out values - must have PoolSvc in info mode
57poolAttribs += [ "DatabaseName = '*'; TREE_CACHE_LEARN_EVENTS = 'int'" ]
58poolAttribs += [ "DatabaseName = '*'; TREE_CACHE_SIZE = 'int'" ]
59
60# Print out for each event the number of bytes read and the number of
61# read calls. With the tree cache, one should see jumps in the bytes
62# read by the cache size, i.e. the bytes read should not change each
63# event. However, the cache only works on one tree - the main event
64# tree (CollectionTree) - and we read some things from other trees, so
65# one does see a small increase event-by-event.
66printOpts = acc.getService("AthenaPoolCnvSvc").PrintInputAttrPerEvt
67printOpts += [ "DatabaseName = '*'; BYTES_READ = 'double'" ]
68printOpts += [ "DatabaseName = '*'; READ_CALLS = 'int'" ]
69#Switch Off for TAG - end
70
71# Run
72import sys
73sc = acc.run(flags.Exec.MaxEvents)
74sys.exit(sc.isFailure())