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