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.Magic = 24
54 acc.addEventAlgo( MagicWriteTag )
55 
56 # ---------------- Output Stream configuration
57 streamCA = OutputStreamCfg(flags, streamName, disableEventTag = noTag,
58  ItemList = ["EventInfo#*", "ExampleTrackContainer#MyTracks"] )
59 stream = streamCA.getEventAlgo( outputStreamName( streamName ) )
60 stream.WritingTool.AttributeListKey = MagicWriteTag.Key
61 acc.merge( streamCA )
62 
63 #--------------------------------------------------------------
64 # Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL)
65 #--------------------------------------------------------------
66 stream.WritingTool.OutputLevel = 3
67 stream.HelperTools[0].OutputLevel = 3
68 
69 # Run
70 import sys
71 sc = acc.run(flags.Exec.MaxEvents)
72 sys.exit(sc.isFailure())
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=None, MetadataItemList=None, disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, keepProvenanceTagsRegEx=None, AcceptAlgs=None, HelperTools=None)
Definition: OutputStreamConfig.py:13
AthenaPoolExample_WriteCond.outputStreamName
string outputStreamName
Definition: AthenaPoolExample_WriteCond.py:21
AthenaPoolExampleConfig.AthenaPoolExampleWriteCfg
def AthenaPoolExampleWriteCfg(flags, outputStreamName, writeCatalog=None, disableEventTag=True)
Definition: AthenaPoolExampleConfig.py:40
AthenaPoolExampleConfig.AthenaPoolExampleReadCfg
def AthenaPoolExampleReadCfg(flags, readCatalogs=[])
Definition: AthenaPoolExampleConfig.py:6
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:312
Constants
some useful constants -------------------------------------------------—
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19