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 = "ROOTTREE:SimplePoolFile1.root"
71stream2name = "Stream2"
72file2Name = "ROOTTREE:SimplePoolFile2.root"
73stream3name = "Stream3"
74file3Name = "ROOTTREE: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" ]
86flags.lock()
87
88# Main services
89from AthenaConfiguration.MainServicesConfig import MainServicesCfg
90acc = MainServicesCfg( flags )
91
92from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
93acc.merge( EventInfoCnvAlgCfg( flags, disableBeamSpot=True ) )
94
95# Load CutFlowSvc
96from EventBookkeeperTools.EventBookkeeperToolsConfig import CutFlowSvcCfg
97acc.merge( CutFlowSvcCfg( flags ) ) #addMetaDataToAllOutputFiles=True ) )
98# Ensure proper metadata propagation
99from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg
100acc.merge( IOVDbSvcCfg( flags ) )
101
102# Pool writing
103acc.addEventAlgo( CompFactory.AthPoolEx.WriteData("WriteData", OutputLevel = DEBUG) )
104
105# ---------------- Output Stream 1 configuration
106from AthenaPoolExampleAlgorithms.AthenaPoolExampleConfig import AthenaPoolExampleWriteCfg
107acc.merge( AthenaPoolExampleWriteCfg( flags, stream1name, writeCatalog = "file:Catalog1.xml",
108 disableEventTag = noTag ) )
109
110stream1ca = OutputStreamCfg( flags, stream1name, disableEventTag = noTag,
111 ItemList = [
112 'EventInfo#*', 'EventStreamInfo#*',
113 'ExampleHitContainer#MyHits', 'ExampleHitContainer#PetersHits' ] )
114acc.merge( stream1ca )
115
116# ---------------- Output Stream 2 configuration
117acc.merge( AthenaPoolExampleWriteCfg( flags, stream2name, disableEventTag = noTag ) )
118stream2ca = OutputStreamCfg(flags, stream2name, disableEventTag = noTag,
119 ItemList = ['EventInfo#*', 'ExampleHitContainer#MyHits'] )
120acc.merge( stream2ca )
121
122# ---------------- Output Stream 3 configuration
123filterAlg = CompFactory.AthPoolEx.PassNoneFilter("PassNoneFilter", OutputLevel = DEBUG)
124acc.addEventAlgo( filterAlg )
125acc.merge( AthenaPoolExampleWriteCfg( flags, stream3name, disableEventTag = noTag ) )
126stream3ca = OutputStreamCfg(flags, stream3name, disableEventTag = noTag )
127stream3 = stream3ca.getEventAlgo( outputStreamName( stream3name ) )
128stream3.RequireAlgs = [ "PassNoneFilter" ]
129acc.merge( stream3ca )
130
131# Run
132import sys
133sc = acc.run(flags.Exec.MaxEvents)
134sys.exit(sc.isFailure())
135
136
137
138
139
140