There are two main sets of fixes here, apologies that they ended up being consolidated into a single MR.
First is an attempt to clean up memory management and reduce the number of const_casts in the main segment reconstrution algorithms. Primarily this occurs by passing pointers to the collections to be written out to the segment-finding tools responsible for filling them. As the segment-finding can also be run to create segments most or all of which will not be stored, the capability to return a vector of pointers to segments rather than filling them into the collection directly was retained. Additionally, segment overlap removal was being done separately on segments found from clusters and segments found from MDTs. Currently this makes no difference, as cluster-based segment finding is turned off, but the goal is to have it working for Run-3. So segment overlap removal was moved to the top-level algorithms, and is now carried out on the Trk::SegmentCollection the algorithm is writing to SG. Finally, MuonPatternSegmentMaker was modified to take vectors of PRD collections, rather than PRD containers, so that it has no need to retrieve the latter separately.
Additionally, DCMathSegmentMaker is rewritten to remove almost all of its mutable class members. (The exception is the ToolHandle for the AdjustableT0Tool, which will have to be treated separately later on.) While this was tedious, it was mostly not particularly difficult, as previous authors appear to have simply used mutable data members to avoid passing variables between the class's methods. As a large number of variables must now be passed to DCMathSegmentMaker::createSegment, the segmentCreationInfo struct was created to hold them.