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