Skip to content

WIP: Add DataHandleSet for automatic type deduction of DataHandle inputs

Alex Pearce requested to merge apearce-datahandleset-63 into master

Towards #63, this adds the DataHandleSet class. This is a container of DataHandle objects, which must each represent a unique underlying C++ type (e.g. one Track::v1 and one Track::v2), that can be passed directly as an Algorithm input. The framework will then extract the DataHandle with the type expected by the Algorithm and forward it.

The motivation is to replace the dictionaries of tracks we're currently returning.

Example use case

def make_hlt1_tracks():
    pr = make_hlt1_pr_tracks()
    v1 = convert_pr_v1(pr)
    v2  = convert_pr_v2(pr)
    return DataHandleSet([pr, v1, v2])

def make_muon_id(tracks):
    return MuonIDAlg(InputTracks=tracks)

def hlt1_reconstruction():
    tracks = make_hlt1_tracks()
    muon_id = make_muon_id(tracks)
    # ...

Here, we do not need to worry about what type of track is needed by the muon ID algorithm. If it is in the tracks set, it will be chosen.

Caveats

This is a just a nicer (IMO) wrapper that avoids dictionaries. It won't cover the use-case of returning multiple containers of the same type; each item must have a distinct type (so it probably won't work here for example). I think dictionaries fit that case just fine.

I could be persuaded that this is not needed, because the stuff this MR cleans up should disappear once we've removed the need for converters.

If people think this direction is worthwhile, I can convert dictionary usage to use DataHandleSet in this MR.

Edited by Alex Pearce

Merge request reports

Loading