relations table processing for MLServiceAlg
Adds feature of being able to run over (2D) relations tables for MLServiceAlg. Possible usage for flavour tagging and isolation.
goes with Moore!5165 (merged)
Example of usage (see also Moore!5165 (merged))
import Functors as F
from PyConf.Algorithms import MLServiceAlg_Relation1D, ParticleTaggerAlg
# relation table from B particles to related tracks (in Particle form)
relations = ParticleTaggerAlg(Input=b_particles,
TaggingContainer=track_particles).OutputRelations
# processing MVA from this table, able to access both the B candidate and the track particle
FROM = F.FORWARDARG0
TO = F.FORWARDARG1
B_PT = F.VALUE_OR(0) @ F.PT @ FROM
Track_PT = F.VALUE_OR(0) @ F.PT @ TO
mva_inputs = F.GATHER(Inputs=[B_PT,Track_PT])
# MVA evaluation algorithm using ONNX
mva_alg = MLServiceAlg_Relation1D(
MLService="ONNXRuntimeSvc",
InputRelations=relations,
MVAInput=mva_inputs,
ModelFile="file://mymodel.onnx",
)
# example of getting outputs
mva_val_track_0 = F.VALUE_OR(0) @ F.ELEMENT_AT_INDEX(Index=0) @ F.WEIGHT @ F.FRONT @ F.RELATIONS.bind(F.TES(mva_alg.OutputRelations), F.FORWARDARGS)
mva_vals = F.MAP( F.VALUE_OR(0) @ F.ELEMENT_AT_INDEX(Index=0) @ F.WEIGHT ) @ F.RELATIONS.bind(F.TES(mva_alg.OutputRelations), F.FORWARDARGS)
mva_vals_max = F.MAX_ELEMENT @ mva_vals
Edited by Maarten Van Veghel