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