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 result.addService(bytestream_conversion)
45
46 eiName = "EventInfo"
47 if flags.Common.isOnline and not any(flags.Input.Files) and not (flags.Trigger.doHLT or flags.Trigger.doLVL1):
48 bytestream_input = CompFactory.ByteStreamEmonInputSvc("ByteStreamInputSvc")
49 else:
50 eiName = "{}EventInfo".format(flags.Overlay.BkgPrefix if flags.Common.ProductionStep is ProductionStep.MinbiasPreprocessing else "")
51 bytestream_input = CompFactory.ByteStreamEventStorageInputSvc(
52 name="ByteStreamInputSvc",
53 EventInfoKey=eiName)
54 result.addService(bytestream_input)
55
56 if flags.Input.SecondaryFiles:
57 event_selector = CompFactory.EventSelectorByteStream(
58 name="SecondaryEventSelector",
59 IsSecondary=True,
60 Input=flags.Input.SecondaryFiles,
61 SkipEvents=flags.Exec.SkipEvents if flags.Overlay.SkipSecondaryEvents >= 0 else flags.Exec.SkipEvents,
62 ByteStreamInputSvc=bytestream_input.name,
63 )
64 result.addService(event_selector)
65 else:
66 event_selector = CompFactory.EventSelectorByteStream(
67 name="EventSelector",
68 Input=flags.Input.Files,
69 SkipEvents=flags.Exec.SkipEvents,
70 ByteStreamInputSvc=bytestream_input.name,
71 )
72 result.addService(event_selector)
73 result.setAppProperty("EvtSel", event_selector.name)
74
75 event_persistency = CompFactory.EvtPersistencySvc(
76 name="EventPersistencySvc", CnvServices=[bytestream_conversion.name]
77 )
78 result.addService(event_persistency)
79
80 result.addService(CompFactory.ROBDataProviderSvc())
81
82 address_provider = CompFactory.ByteStreamAddressProviderSvc(
83 TypeNames=type_names if type_names else list(),
84 )
85 result.addService(address_provider)
86
87 result.merge(
88 MetaDataSvcCfg(flags, ["IOVDbMetaDataTool", "ByteStreamMetadataTool"])
89 )
90
91 proxy = CompFactory.ProxyProviderSvc(ProviderNames = [address_provider.name])
92 result.addService(proxy)
93
94 result.merge(SGInputLoaderCfg(flags, address_provider.TypeNames,
95 ExtraOutputs=[("xAOD::EventInfo",f"StoreGateSvc+{eiName}"),
96 ("xAOD::EventAuxInfo",f"StoreGateSvc+{eiName}Aux.")]))
97
98 return result
99
100