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