ATLAS Offline Software
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 
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", "SimplePoolReplica1.root",
24  "EmptyPoolFile.root", "SimplePoolFile2.root", "SimplePoolFile4.root"]
25 flags.Exec.MaxEvents = -1
26 flags.Common.MsgSuppression = False
27 flags.Exec.DebugMessageComponents = ["ReadData", "PoolSvc",
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 #svcMgr.EventSelector.CollectionType = "ExplicitROOT"
48 #svcMgr.EventSelector.CounterTool = "EventSelectorCounterTool/Counter"
49 
50 #Switch Off for TAG - start
51 poolAttribs = acc.getService("AthenaPoolCnvSvc").InputPoolAttributes
52 # Turn on the tree cache for the CollectionTree - tree cache only works for one tree.
53 # Set number of events for learning before turning on cache - default is 5
54 poolAttribs += [ "DatabaseName = '*'; TREE_CACHE_LEARN_EVENTS = '6'" ]
55 # And set tree cache size - default is 10 MB (10 000 000)
56 poolAttribs += [ "DatabaseName = '*'; ContainerName = 'CollectionTree'; TREE_CACHE = '100000'" ]
57 
58 # Print out values - must have PoolSvc in info mode
59 poolAttribs += [ "DatabaseName = '*'; TREE_CACHE_LEARN_EVENTS = 'int'" ]
60 poolAttribs += [ "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.
68 printOpts = acc.getService("AthenaPoolCnvSvc").PrintInputAttrPerEvt
69 printOpts += [ "DatabaseName = '*'; BYTES_READ = 'double'" ]
70 printOpts += [ "DatabaseName = '*'; READ_CALLS = 'int'" ]
71 #Switch Off for TAG - end
72 
73 QueryTag = CompFactory.AthPoolEx.QueryTag("QueryTag", OutputLevel = DEBUG)
74 #svcMgr.EventSelector.HelperTools = [ QueryTag ]
75 
76 # Run
77 import sys
78 sc = acc.run(flags.Exec.MaxEvents)
79 sys.exit(sc.isFailure())
80 
81 
82 
83 
84 
85 
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