ATLAS Offline Software
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 
17 from AthenaConfiguration.AllConfigFlags import initConfigFlags
18 from AthenaConfiguration.ComponentFactory import CompFactory
19 from AthenaCommon.Constants import DEBUG
20 
21 # Setup flags
22 flags = initConfigFlags()
23 flags.Input.Files = [ "EmptyPoolFile.root", "SimplePoolFile1.root",
24  "EmptyPoolFile.root", "SimplePoolFile2.root", "SimplePoolFile3.root" ]
25 flags.Exec.MaxEvents = -1
26 flags.Common.MsgSuppression = False
27 flags.Exec.DebugMessageComponents = [ "ReadData", "PoolSvc", "AthenaPoolCnvSvc",
28  "AthenaPoolAddressProviderSvc", "MetaDataSvc", "EventSelector" ]
29 flags.lock()
30 
31 # Main services
32 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
33 acc = MainServicesCfg( flags )
34 
35 # Configure AthenaPool reading
36 from AthenaPoolExampleAlgorithms.AthenaPoolExampleConfig import AthenaPoolExampleReadCfg
37 acc.merge( AthenaPoolExampleReadCfg(flags, readCatalogs = ["file:Catalog1.xml"]) )
38 
39 # Creata and attach the reading algorithm
40 acc.addEventAlgo( CompFactory.AthPoolEx.ReadData("ReadData", OutputLevel = DEBUG) )
41 
42 evSelector = acc.getService("EventSelector")
43 evSelector.SkipEvents = 8 # // skip the first 8 events
44 evSelector.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
49 poolAttribs = 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
52 poolAttribs += [ "DatabaseName = '*'; TREE_CACHE_LEARN_EVENTS = '6'" ]
53 # And set tree cache size - default is 10 MB (10 000 000)
54 poolAttribs += [ "DatabaseName = '*'; ContainerName = 'CollectionTree'; TREE_CACHE = '100000'" ]
55 
56 # Print out values - must have PoolSvc in info mode
57 poolAttribs += [ "DatabaseName = '*'; TREE_CACHE_LEARN_EVENTS = 'int'" ]
58 poolAttribs += [ "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.
66 printOpts = acc.getService("AthenaPoolCnvSvc").PrintInputAttrPerEvt
67 printOpts += [ "DatabaseName = '*'; BYTES_READ = 'double'" ]
68 printOpts += [ "DatabaseName = '*'; READ_CALLS = 'int'" ]
69 #Switch Off for TAG - end
70 
71 # Run
72 import sys
73 sc = acc.run(flags.Exec.MaxEvents)
74 sys.exit(sc.isFailure())
75 
76 
77 
78 
79 
80 
AthenaPoolExampleConfig.AthenaPoolExampleReadCfg
def AthenaPoolExampleReadCfg(flags, readCatalogs=[])
Definition: AthenaPoolExampleConfig.py:6
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:256
Constants
some useful constants -------------------------------------------------—
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19