26def ByteStreamReadCfg(flags, type_names=None):
27 """Set up to read from a bytestream file
28
29 The function adds the components required to read events and metadata from
30 bytestream input. May be used to read events from a secondary input as well
31 primary input file.
32
33 Args:
34 flags: Job configuration flags
35 type_names: (optional) specific type names for address provider to find
36
37 Returns:
38 A component accumulator fragment containing the components required to
39 read from bytestream. Should be merged into main job configuration.
40 """
41 result = ComponentAccumulator()
42
43 bytestream_conversion = CompFactory.ByteStreamCnvSvc(
44 IsSimulation=flags.Input.isMC,
45 )
46 result.addService(bytestream_conversion)
47
48
49 if flags.Input.isMC:
50 mcEventInfoTool = CompFactory.MCEventInfoByteStreamTool(
51 name="MCEventInfoByteStreamTool",
52 ROBIDs=[0x00ff0001],
53 EventInfoReadKey="",
54 )
55 result.addPublicTool(mcEventInfoTool)
56
57 result.merge(SGInputLoaderCfg(flags, [('ByteStreamMetadataContainer', 'InputMetaDataStore+ByteStreamMetadata')]))
58
59 eiName = "EventInfo"
60 if flags.Common.isOnline and not any(flags.Input.Files) and not (flags.Trigger.doHLT or flags.Trigger.doLVL1):
61 bytestream_input = CompFactory.ByteStreamEmonInputSvc("ByteStreamInputSvc")
62 else:
63 eiName = "{}EventInfo".format(flags.Overlay.BkgPrefix if flags.Common.ProductionStep is ProductionStep.MinbiasPreprocessing else "")
64 bytestream_input = CompFactory.ByteStreamEventStorageInputSvc(
65 name="ByteStreamInputSvc",
66 EventInfoKey=eiName)
67 result.addService(bytestream_input)
68
69 if flags.Input.SecondaryFiles:
70 event_selector = CompFactory.EventSelectorByteStream(
71 name="SecondaryEventSelector",
72 IsSecondary=True,
73 Input=flags.Input.SecondaryFiles,
74 SkipEvents=flags.Exec.SkipEvents if flags.Overlay.SkipSecondaryEvents >= 0 else flags.Exec.SkipEvents,
75 ByteStreamInputSvc=bytestream_input.name,
76 )
77 result.addService(event_selector)
78 else:
79 event_selector = CompFactory.EventSelectorByteStream(
80 name="EventSelector",
81 Input=flags.Input.Files,
82 SkipEvents=flags.Exec.SkipEvents,
83 ByteStreamInputSvc=bytestream_input.name,
84 )
85 result.addService(event_selector)
86 result.setAppProperty("EvtSel", event_selector.name)
87
88 event_persistency = CompFactory.EvtPersistencySvc(
89 name="EventPersistencySvc", CnvServices=[bytestream_conversion.name]
90 )
91 result.addService(event_persistency)
92
93 result.addService(CompFactory.ROBDataProviderSvc())
94
95 address_provider = CompFactory.ByteStreamAddressProviderSvc(
96 TypeNames=type_names if type_names else list(),
97 )
98 result.addService(address_provider)
99
100 result.merge(
101 MetaDataSvcCfg(flags, ["IOVDbMetaDataTool", "ByteStreamMetadataTool"])
102 )
103
104 proxy = CompFactory.ProxyProviderSvc(ProviderNames = [address_provider.name])
105 result.addService(proxy)
106
107 result.merge(SGInputLoaderCfg(flags, address_provider.TypeNames,
108 ExtraOutputs=[("xAOD::EventInfo",f"StoreGateSvc+{eiName}"),
109 ("xAOD::EventAuxInfo",f"StoreGateSvc+{eiName}Aux.")]))
110
111 return result
112
113