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