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