ATLAS Offline Software
AthenaPoolExample_ReadWriteNext.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 
14 
15 from AthenaConfiguration.AllConfigFlags import initConfigFlags
16 from AthenaConfiguration.ComponentFactory import CompFactory
17 from AthenaCommon.Constants import DEBUG
18 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg, outputStreamName
19 
20 streamName = "Stream1"
21 outputFileName = "SimplePoolFile4.root"
22 noTag = True
23 
24 # Setup flags
25 flags = initConfigFlags()
26 flags.Input.Files = ["SimplePoolFile3.root"]
27 flags.addFlag(f"Output.{streamName}FileName", outputFileName)
28 flags.Exec.MaxEvents = -1
29 flags.Common.MsgSuppression = False
30 flags.Exec.DebugMessageComponents = [outputStreamName(streamName),
31  "ReadData", "ReWriteData",
32  "PoolSvc", "AthenaPoolCnvSvc","AthenaPoolAddressProviderSvc", "MetaDataSvc"]
33 flags.lock()
34 
35 # Main services
36 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
37 acc = MainServicesCfg( flags )
38 
39 # Pool reading and writing
40 from AthenaPoolExampleAlgorithms.AthenaPoolExampleConfig import AthenaPoolExampleReadCfg, AthenaPoolExampleWriteCfg
41 acc.merge( AthenaPoolExampleReadCfg(flags, readCatalogs = ["file:Catalog1.xml"]) )
42 acc.merge( AthenaPoolExampleWriteCfg(flags, streamName,
43  writeCatalog = "file:Catalog1.xml",
44  disableEventTag = noTag) )
45 
46 # Creata and attach the algorithms
47 acc.addEventAlgo( CompFactory.AthPoolEx.ReadData("ReadData", OutputLevel = DEBUG) )
48 acc.addEventAlgo( CompFactory.AthPoolEx.ReWriteData("ReWriteData", ExampleHitKey="", OutputLevel = DEBUG) )
49 acc.addEventAlgo( CompFactory.AthPoolEx.WriteTag("WriteTag", OutputLevel = DEBUG) )
50 
51 MagicWriteTag = CompFactory.AthPoolEx.WriteTag("MagicWriteTag", OutputLevel = DEBUG)
52 MagicWriteTag.Key = "MagicTag"
53 MagicWriteTag.TagKey = "MagicTag"
54 MagicWriteTag.Magic = 24
55 acc.addEventAlgo( MagicWriteTag )
56 
57 # ---------------- Output Stream configuration
58 streamCA = OutputStreamCfg(flags, streamName, disableEventTag = noTag,
59  ItemList = ["EventInfo#*", "ExampleTrackContainer#MyTracks"] )
60 stream = streamCA.getEventAlgo( outputStreamName( streamName ) )
61 stream.WritingTool.AttributeListKey = MagicWriteTag.Key
62 acc.merge( streamCA )
63 
64 #--------------------------------------------------------------
65 # Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL)
66 #--------------------------------------------------------------
67 stream.WritingTool.OutputLevel = 3
68 stream.HelperTools[0].OutputLevel = 3
69 
70 # Run
71 import sys
72 sc = acc.run(flags.Exec.MaxEvents)
73 sys.exit(sc.isFailure())
AthenaPoolExample_WriteCond.outputStreamName
string outputStreamName
Definition: AthenaPoolExample_WriteCond.py:21
AthenaPoolExampleConfig.AthenaPoolExampleWriteCfg
def AthenaPoolExampleWriteCfg(flags, outputStreamName, writeCatalog=None, disableEventTag=True)
Definition: AthenaPoolExampleConfig.py:40
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
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