CombinedMuonTrackBuilder::addIDMSerrors try to write it in a way that is clear we do not alias between unique pointers.
CombinedMuonTrackBuilder::addIDMSerrors try to write it in a way that
- Is obvious we do not modify the input,
- and we get a new track or nullptr in case of failure.
- In case of nullptr we do not update anything, in case of non nullptr we might want to eventually update the combined Track.
@sroe, @jojungge , @emoyse please take a look.
I am somehow convinced that the previous kind of worked but it was expressed in a bit round about way.
It allowed 2 unique_ptr to alias (Which is principle we do not want).
And then was checking if they do alias as a way to determine if the newTrack makes sense otherwise was taking some cleanup action.
Seems simpler
A. to pass the input by const
(stays untouched so why use non-const)
B. return nullptr
as failure rather than a newTrack that alias the input in case of "error" (nothing happened).
As this also should be easier to check.
As a side note we should look at the alignment tools and see if can pass get const ref rather than const ptr.