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