ATLAS Offline Software
Loading...
Searching...
No Matches
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
15from AthenaConfiguration.AllConfigFlags import initConfigFlags
16from AthenaConfiguration.ComponentFactory import CompFactory
17from AthenaCommon.Constants import DEBUG
18from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg, outputStreamName
19
20streamName = "ReWrite"
21outputFileName = "SimplePoolFile3.root"
22noTag = True
23
24# Setup flags
25flags = initConfigFlags()
26flags.Input.Files = ["SimplePoolFile1.root"]
27flags.addFlag(f"Output.{streamName}FileName", outputFileName)
28flags.Exec.MaxEvents = -1
29flags.Common.MsgSuppression = False
30flags.Exec.DebugMessageComponents = [outputStreamName(streamName),
31 "PoolSvc", "AthenaPoolCnvSvc","AthenaPoolAddressProviderSvc", "MetaDataSvc"]
32
33#Run3 for now
34from AthenaConfiguration.TestDefaults import defaultGeometryTags
35flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
36
37flags.lock()
38
39# Main services
40from AthenaConfiguration.MainServicesConfig import MainServicesCfg
41acc = MainServicesCfg( flags )
42
43# Pool reading and writing
44from AthenaPoolExampleAlgorithms.AthenaPoolExampleConfig import AthenaPoolExampleReadCfg, AthenaPoolExampleWriteCfg
45acc.merge( AthenaPoolExampleReadCfg(flags, readCatalogs = ["file:Catalog1.xml"]) )
46acc.merge( AthenaPoolExampleWriteCfg( flags, streamName,
47 writeCatalog = "file:Catalog1.xml",
48 disableEventTag = noTag ) )
49
50# Create and attach the algorithms
51acc.addEventAlgo( CompFactory.AthPoolEx.ReadData("ReadData", OutputLevel = DEBUG) )
52acc.addEventAlgo( CompFactory.AthPoolEx.ReWriteData("ReWriteData", OutputLevel = DEBUG) )
53
54# Produce xAOD::EventInfo from EventInfo
55from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
56acc.merge( EventInfoCnvAlgCfg(flags, disableBeamSpot = True) )
57
58# ---------------- Output Stream configuration
59streamCA = OutputStreamCfg( flags, streamName, disableEventTag = True,
60 ItemList = [ "ExampleTrackContainer#MyTracks" ] )
61stream = streamCA.getEventAlgo( outputStreamName( streamName ) )
62acc.merge( streamCA )
63
64#--------------------------------------------------------------
65# Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL)
66#--------------------------------------------------------------
67stream.WritingTool.OutputLevel = 3
68stream.HelperTools[0].OutputLevel = 3
69
70# Run
71import sys
72sc = acc.run(flags.Exec.MaxEvents)
73sys.exit(sc.isFailure())