ATLAS Offline Software
AthenaPoolExample_Write.py
Go to the documentation of this file.
1 #!/env/python
2 
3 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4 
5 
7 
8 
59 
60 
61 from AthenaConfiguration.AllConfigFlags import initConfigFlags
62 from AthenaConfiguration.ComponentFactory import CompFactory
63 from AthenaCommon.Constants import DEBUG
64 from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg, outputStreamName
65 
66 stream1name = "Stream1"
67 file1Name = "ROOTTREE:SimplePoolFile1.root"
68 stream2name = "Stream2"
69 file2Name = "ROOTTREE:SimplePoolFile2.root"
70 stream3name = "Stream3"
71 file3Name = "ROOTTREE:EmptyPoolFile.root"
72 noTag = True
73 
74 # Setup flags
75 flags = initConfigFlags()
76 flags.Common.MsgSuppression = False
77 flags.Exec.MaxEvents = 20
78 flags.Input.Files = []
79 flags.addFlag(f"Output.{stream1name}FileName", file1Name)
80 flags.addFlag(f"Output.{stream2name}FileName", file2Name)
81 flags.addFlag(f"Output.{stream3name}FileName", file3Name)
82 flags.Exec.DebugMessageComponents = [ outputStreamName(stream1name) , "PoolSvc", "AthenaPoolCnvSvc", "WriteData" ]
83 flags.lock()
84 
85 # Main services
86 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
87 acc = MainServicesCfg( flags )
88 
89 from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
90 acc.merge( EventInfoCnvAlgCfg( flags, disableBeamSpot=True ) )
91 
92 # Load CutFlowSvc
93 from EventBookkeeperTools.EventBookkeeperToolsConfig import CutFlowSvcCfg
94 acc.merge( CutFlowSvcCfg( flags ) ) #addMetaDataToAllOutputFiles=True ) )
95 # Ensure proper metadata propagation
96 from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg
97 acc.merge( IOVDbSvcCfg( flags ) )
98 
99 # Pool writing
100 acc.addEventAlgo( CompFactory.AthPoolEx.WriteData("WriteData", OutputLevel = DEBUG) )
101 
102 # ---------------- Output Stream 1 configuration
103 from AthenaPoolExampleAlgorithms.AthenaPoolExampleConfig import AthenaPoolExampleWriteCfg
104 acc.merge( AthenaPoolExampleWriteCfg( flags, stream1name, writeCatalog = "file:Catalog1.xml",
105  disableEventTag = noTag ) )
106 
107 stream1ca = OutputStreamCfg( flags, stream1name, disableEventTag = noTag,
108  ItemList = [
109  'EventInfo#*', 'EventStreamInfo#*',
110  'ExampleHitContainer#MyHits', 'ExampleHitContainer#PetersHits' ] )
111 acc.merge( stream1ca )
112 
113 # ---------------- Output Stream 2 configuration
114 acc.merge( AthenaPoolExampleWriteCfg( flags, stream2name, disableEventTag = noTag ) )
115 stream2ca = OutputStreamCfg(flags, stream2name, disableEventTag = noTag,
116  ItemList = ['EventInfo#*', 'ExampleHitContainer#MyHits'] )
117 acc.merge( stream2ca )
118 
119 # ---------------- Output Stream 3 configuration
120 filterAlg = CompFactory.AthPoolEx.PassNoneFilter("PassNoneFilter", OutputLevel = DEBUG)
121 acc.addEventAlgo( filterAlg )
122 acc.merge( AthenaPoolExampleWriteCfg( flags, stream3name, disableEventTag = noTag ) )
123 stream3ca = OutputStreamCfg(flags, stream3name, disableEventTag = noTag )
124 stream3 = stream3ca.getEventAlgo( outputStreamName( stream3name ) )
125 stream3.RequireAlgs = [ "PassNoneFilter" ]
126 acc.merge( stream3ca )
127 
128 # Run
129 import sys
130 sc = acc.run(flags.Exec.MaxEvents)
131 sys.exit(sc.isFailure())
132 
133 
134 
135 
136 
137 
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=None, MetadataItemList=None, disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, keepProvenanceTagsRegEx=None, AcceptAlgs=None, HelperTools=None)
Definition: OutputStreamConfig.py:13
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.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:310
Constants
some useful constants -------------------------------------------------—
python.IOVDbSvcConfig.IOVDbSvcCfg
def IOVDbSvcCfg(flags, **kwargs)
Definition: IOVDbSvcConfig.py:28
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.xAODEventInfoCnvConfig.EventInfoCnvAlgCfg
def EventInfoCnvAlgCfg(flags, name="EventInfoCnvAlg", inputKey="McEventInfo", outputKey="EventInfo", disableBeamSpot=False, **kwargs)
Definition: xAODEventInfoCnvConfig.py:11
python.EventBookkeeperToolsConfig.CutFlowSvcCfg
def CutFlowSvcCfg(flags, **kwargs)
Definition: EventBookkeeperToolsConfig.py:25