ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaPoolExample_WritexAODElectrons.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 = "WritexAODElectrons"
21outputFileName = "SimplePoolFile_xAOD.root"
22
23# Setup flags
24flags = initConfigFlags()
25flags.Input.Files = ["SimplePoolFile3.root"]
26flags.addFlag(f"Output.{streamName}FileName", outputFileName)
27flags.Exec.MaxEvents = -1
28flags.Common.MsgSuppression = False
29flags.Exec.DebugMessageComponents = [outputStreamName(streamName),
30 "PoolSvc", "AthenaPoolCnvSvc","AthenaPoolAddressProviderSvc", "MetaDataSvc"]
31flags.lock()
32
33# Main services
34from AthenaConfiguration.MainServicesConfig import MainServicesCfg
35acc = MainServicesCfg( flags )
36
37# Pool reading and writing
38from AthenaPoolExampleAlgorithms.AthenaPoolExampleConfig import AthenaPoolExampleReadCfg, AthenaPoolExampleWriteCfg
39acc.merge( AthenaPoolExampleReadCfg(flags, readCatalogs = ["file:Catalog1.xml"]) )
40acc.merge( AthenaPoolExampleWriteCfg( flags, streamName,
41 writeCatalog = "file:Catalog1.xml") )
42
43# Create and attach the algorithms
44acc.addEventAlgo( CompFactory.AthPoolEx.ReadData("ReadData", OutputLevel = DEBUG) )
45acc.addEventAlgo( CompFactory.AthPoolEx.WriteExampleElectron("WriteExampleElectron", OutputLevel = DEBUG) )
46
47# ---------------- Output Stream configuration
48streamCA = OutputStreamCfg( flags, streamName, disableEventTag = True,
49 ItemList = [ "ExampleTrackContainer#MyTracks",
50 "xAOD::ExampleElectronContainer#TestContainer",
51 "xAOD::ExampleElectronAuxContainer#TestContainerAux.-decor2"] )
52stream = streamCA.getEventAlgo( outputStreamName( streamName ) )
53acc.merge( streamCA )
54
55#--------------------------------------------------------------
56# Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL)
57#--------------------------------------------------------------
58stream.WritingTool.OutputLevel = 3
59stream.HelperTools[0].OutputLevel = 3
60
61# Run
62import sys
63sc = acc.run(flags.Exec.MaxEvents)
64sys.exit(sc.isFailure())