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"]
32flags.lock()
33
34# Main services
35from AthenaConfiguration.MainServicesConfig import MainServicesCfg
36acc = MainServicesCfg( flags )
37
38# Pool reading and writing
39from AthenaPoolExampleAlgorithms.AthenaPoolExampleConfig import AthenaPoolExampleReadCfg, AthenaPoolExampleWriteCfg
40acc.merge( AthenaPoolExampleReadCfg(flags, readCatalogs = ["file:Catalog1.xml"]) )
41acc.merge( AthenaPoolExampleWriteCfg( flags, streamName,
42 writeCatalog = "file:Catalog1.xml",
43 disableEventTag = noTag ) )
44
45# Create and attach the algorithms
46acc.addEventAlgo( CompFactory.AthPoolEx.ReadData("ReadData", OutputLevel = DEBUG) )
47acc.addEventAlgo( CompFactory.AthPoolEx.ReWriteData("ReWriteData", OutputLevel = DEBUG) )
48
49# Produce xAOD::EventInfo from EventInfo
50from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
51acc.merge( EventInfoCnvAlgCfg(flags, disableBeamSpot = True) )
52
53# ---------------- Output Stream configuration
54streamCA = OutputStreamCfg( flags, streamName, disableEventTag = True,
55 ItemList = [ "ExampleTrackContainer#MyTracks" ] )
56stream = streamCA.getEventAlgo( outputStreamName( streamName ) )
57acc.merge( streamCA )
58
59#--------------------------------------------------------------
60# Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL)
61#--------------------------------------------------------------
62stream.WritingTool.OutputLevel = 3
63stream.HelperTools[0].OutputLevel = 3
64
65# Run
66import sys
67sc = acc.run(flags.Exec.MaxEvents)
68sys.exit(sc.isFailure())