ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaPoolExample_Write.py
Go to the documentation of this file.
1#!/env/python
2
3# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
4
5
7
8
59
60
61import os
62os.system ('rm -f *.root Catalog1.xml')
63
64from AthenaConfiguration.AllConfigFlags import initConfigFlags
65from AthenaConfiguration.ComponentFactory import CompFactory
66from AthenaCommon.Constants import DEBUG
67from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg, outputStreamName
68
69stream1name = "Stream1"
70file1Name = "SimplePoolFile1.root"
71stream2name = "Stream2"
72file2Name = "SimplePoolFile2.root"
73stream3name = "Stream3"
74file3Name = "EmptyPoolFile.root"
75noTag = True
76
77# Setup flags
78flags = initConfigFlags()
79flags.Common.MsgSuppression = False
80flags.Exec.MaxEvents = 20
81flags.Input.Files = []
82flags.addFlag(f"Output.{stream1name}FileName", file1Name)
83flags.addFlag(f"Output.{stream2name}FileName", file2Name)
84flags.addFlag(f"Output.{stream3name}FileName", file3Name)
85flags.Exec.DebugMessageComponents = [ outputStreamName(stream1name) , "PoolSvc", "AthenaPoolCnvSvc", "WriteData" ]
86
87#Run3 for now
88from AthenaConfiguration.TestDefaults import defaultGeometryTags
89flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
90
91flags.lock()
92
93# Main services
94from AthenaConfiguration.MainServicesConfig import MainServicesCfg
95acc = MainServicesCfg( flags )
96
97from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
98acc.merge( EventInfoCnvAlgCfg( flags, disableBeamSpot=True ) )
99
100# Load CutFlowSvc
101from EventBookkeeperTools.EventBookkeeperToolsConfig import CutFlowSvcCfg
102acc.merge( CutFlowSvcCfg( flags ) ) #addMetaDataToAllOutputFiles=True ) )
103# Ensure proper metadata propagation
104from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg
105acc.merge( IOVDbSvcCfg( flags ) )
106
107# Pool writing
108acc.addEventAlgo( CompFactory.AthPoolEx.WriteData("WriteData", OutputLevel = DEBUG) )
109
110# ---------------- Output Stream 1 configuration
111from AthenaPoolExampleAlgorithms.AthenaPoolExampleConfig import AthenaPoolExampleWriteCfg
112acc.merge( AthenaPoolExampleWriteCfg( flags, stream1name, writeCatalog = "file:Catalog1.xml",
113 disableEventTag = noTag ) )
114
115stream1ca = OutputStreamCfg( flags, stream1name, disableEventTag = noTag,
116 ItemList = [
117 'EventInfo#*', 'EventStreamInfo#*',
118 'ExampleHitContainer#MyHits', 'ExampleHitContainer#PetersHits' ] )
119acc.merge( stream1ca )
120
121# ---------------- Output Stream 2 configuration
122acc.merge( AthenaPoolExampleWriteCfg( flags, stream2name, disableEventTag = noTag ) )
123stream2ca = OutputStreamCfg(flags, stream2name, disableEventTag = noTag,
124 ItemList = ['EventInfo#*', 'ExampleHitContainer#MyHits'] )
125acc.merge( stream2ca )
126
127# ---------------- Output Stream 3 configuration
128filterAlg = CompFactory.AthPoolEx.PassNoneFilter("PassNoneFilter", OutputLevel = DEBUG)
129acc.addEventAlgo( filterAlg )
130acc.merge( AthenaPoolExampleWriteCfg( flags, stream3name, disableEventTag = noTag ) )
131stream3ca = OutputStreamCfg(flags, stream3name, disableEventTag = noTag )
132stream3 = stream3ca.getEventAlgo( outputStreamName( stream3name ) )
133stream3.RequireAlgs = [ "PassNoneFilter" ]
134acc.merge( stream3ca )
135
136# Run
137import sys
138sc = acc.run(flags.Exec.MaxEvents)
139sys.exit(sc.isFailure())
140
141
142
143
144
145