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