ATLAS Offline Software
AthenaPoolExample_ReadWrite.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 = "ReWrite"
21 outputFileName = "SimplePoolFile3.root"
22 noTag = True
23 
24 # Setup flags
25 flags = initConfigFlags()
26 flags.Input.Files = ["SimplePoolFile1.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  "PoolSvc", "AthenaPoolCnvSvc","AthenaPoolAddressProviderSvc", "MetaDataSvc"]
32 flags.lock()
33 
34 # Main services
35 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
36 acc = MainServicesCfg( flags )
37 
38 # Pool reading and writing
39 from AthenaPoolExampleAlgorithms.AthenaPoolExampleConfig import AthenaPoolExampleReadCfg, AthenaPoolExampleWriteCfg
40 acc.merge( AthenaPoolExampleReadCfg(flags, readCatalogs = ["file:Catalog1.xml"]) )
41 acc.merge( AthenaPoolExampleWriteCfg( flags, streamName,
42  writeCatalog = "file:Catalog1.xml",
43  disableEventTag = noTag ) )
44 
45 # Create and attach the algorithms
46 acc.addEventAlgo( CompFactory.AthPoolEx.ReadData("ReadData", OutputLevel = DEBUG) )
47 acc.addEventAlgo( CompFactory.AthPoolEx.ReWriteData("ReWriteData", OutputLevel = DEBUG) )
48 
49 # Produce xAOD::EventInfo from EventInfo
50 from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
51 acc.merge( EventInfoCnvAlgCfg(flags, disableBeamSpot = True) )
52 
53 # ---------------- Output Stream configuration
54 streamCA = OutputStreamCfg( flags, streamName, disableEventTag = True,
55  ItemList = [ "ExampleTrackContainer#MyTracks" ] )
56 stream = streamCA.getEventAlgo( outputStreamName( streamName ) )
57 acc.merge( streamCA )
58 
59 #--------------------------------------------------------------
60 # Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL)
61 #--------------------------------------------------------------
62 stream.WritingTool.OutputLevel = 3
63 stream.HelperTools[0].OutputLevel = 3
64 
65 # Run
66 import sys
67 sc = acc.run(flags.Exec.MaxEvents)
68 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:310
Constants
some useful constants -------------------------------------------------—
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.xAODEventInfoCnvConfig.EventInfoCnvAlgCfg
def EventInfoCnvAlgCfg(flags, name="EventInfoCnvAlg", inputKey="McEventInfo", outputKey="EventInfo", disableBeamSpot=False, **kwargs)
Definition: xAODEventInfoCnvConfig.py:11