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