Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
WriteHiveWithMetaData.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
3 import sys
4 from OutputStreamAthenaPool.OutputStreamConfig import (
5  OutputStreamCfg,
6  addToMetaData,
7  outputStreamName,
8 )
9 from AthExHiveAthenaPool.WriteHiveDataObjConfig import WriteHiveDataObjCfg
10 from AthenaConfiguration.MainServicesConfig import MainEvgenServicesCfg
11 from AthenaConfiguration.AllConfigFlags import initConfigFlags
12 from AthenaConfiguration.ComponentFactory import CompFactory
13 
14 if __name__ == "__main__":
15  flags = initConfigFlags()
16  flags.Input.RunNumbers = [284600]
17  flags.Input.TimeStamps = [1] # dummy value
18  # workaround for building xAOD::EventInfo without input files
19  flags.Input.TypedCollections = []
20  flags.Exec.MaxEvents = 20
21 
22  streamName = "TestStream"
23  flags.addFlag(
24  f"Output.{streamName}FileName",
25  f"{streamName}.pool.root",
26  )
27  flags.addFlag(f"Output.doWrite{streamName}", True)
28 
29  flags.fillFromArgs()
30  flags.lock()
31 
32  # The example runs with no input file. We configure it with the McEventSelector
33  cfg = MainEvgenServicesCfg(flags, withSequences=True)
34  cfg.merge(WriteHiveDataObjCfg(flags))
35 
36  # Output stream
37  cfg.merge(
39  flags,
40  streamName=streamName,
41  ItemList=[
42  "xAOD::EventInfo#EventInfo",
43  "xAOD::EventAuxInfo#EventInfoAux.",
44  "HiveDataObj#*",
45  ],
46  )
47  )
48  cfg.merge(
50  flags,
51  streamName=streamName,
52  itemOrList=[
53  f"xAOD::EventFormat#EventFormat{outputStreamName(streamName)}",
54  "xAOD::FileMetaData#FileMetaData",
55  "xAOD::FileMetaDataAuxInfo#FileMetaDataAux.",
56  ],
57  HelperTools=[
58  CompFactory.xAODMaker.EventFormatStreamHelperTool(
59  f"{outputStreamName(streamName)}_EventFormatStreamHelperTool",
60  Key=f"EventFormat{outputStreamName(streamName)}",
61  DataHeaderKey=f"{outputStreamName(streamName)}",
62  TypeNames=["HiveDataObj#*"],
63  ),
64  CompFactory.xAODMaker.FileMetaDataCreatorTool(
65  f"{outputStreamName(streamName)}_FileMetaDataCreatorTool",
66  OutputKey="FileMetaData",
67  StreamName=f"{outputStreamName(streamName)}",
68  ),
69  ],
70  )
71  )
72 
73  # Execute
74  sys.exit(cfg.run().isFailure())
python.OutputStreamConfig.addToMetaData
def addToMetaData(flags, streamName, itemOrList, AcceptAlgs=[], HelperTools=[], **kwargs)
Definition: OutputStreamConfig.py:160
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, keepProvenanceTagsRegEx=None, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:16
python.MainServicesConfig.MainEvgenServicesCfg
def MainEvgenServicesCfg(flags, LoopMgr="AthenaEventLoopMgr", withSequences=True)
Definition: MainServicesConfig.py:353
WriteHiveDataObjConfig.WriteHiveDataObjCfg
def WriteHiveDataObjCfg(flags)
Definition: WriteHiveDataObjConfig.py:6
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19