Fix memory leaks in the global chi2 fitter.
Valgrind finds several memory leaks:
==23584== 86,992 (2,688 direct, 84,304 indirect) bytes in 3 blocks are definitely lost in loss record 131,654 of 132,490
==23584== at 0x4C2AA02: operator new(unsigned long) (vg_replace_malloc.c:344)
==23584== by 0xA3A56789: Trk::GlobalChi2Fitter::makeTrack(Trk::GlobalChi2Fitter::Cache&, Trk::GXFTrajectory&, Trk::ParticleHypothesis) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrkGlobalChi2Fitter.so)
==23584== by 0xA3A58AE8: Trk::GlobalChi2Fitter::myfit(Trk::GlobalChi2Fitter::Cache&, Trk::GXFTrajectory&, Trk::ParametersBase<5, Trk::Charged> const&, bool, Trk::ParticleHypothesis) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrkGlobalChi2Fitter.so)
==23584== by 0xA3A62D87: Trk::GlobalChi2Fitter::fitIm(Trk::GlobalChi2Fitter::Cache&, Trk::Track const&, bool, Trk::ParticleHypothesis) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrkGlobalChi2Fitter.so)
==23584== by 0xA3A63651: Trk::GlobalChi2Fitter::fit(Trk::Track const&, bool, Trk::ParticleHypothesis) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrkGlobalChi2Fitter.so)
==23584== by 0xCAB4B9EE: Muon::MuonTrackCleaner::fitTrack(Trk::Track&, Trk::ParticleHypothesis, bool) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackFinderTools.so)
==23584== by 0xCAB5412A: Muon::MuonTrackCleaner::hitCleaning(std::unique_ptr<Trk::Track, std::default_delete<Trk::Track> >, Muon::MuonTrackCleaner::CleaningState&) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackFinderTools.so)
==23584== by 0xCAB565EC: Muon::MuonTrackCleaner::cleanTrack(Trk::Track*, Muon::MuonTrackCleaner::CleaningState&) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackFinderTools.so)
==23584== by 0xCAB57469: Muon::MuonTrackCleaner::clean(Trk::Track&, std::set<Identifier, std::less<Identifier>, std::allocator<Identifier> > const&) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackFinderTools.so)
==23584== by 0xCAE5B977: Muon::MooTrackFitter::cleanAndEvaluateTrack(Trk::Track&, std::set<Identifier, std::less<Identifier>, std::allocator<Identifier> > const&) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0xCAE6AE5C: Muon::MooTrackFitter::fit(Muon::MuPatCandidateBase const&, Muon::MuPatCandidateBase const&, std::vector<Trk::PrepRawData const*, std::allocator<Trk::PrepRawData const*> > const*) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0xCAE2D44A: Muon::MooTrackBuilder::combine(Muon::MuPatCandidateBase const&, Muon::MuPatCandidateBase const&, std::vector<Trk::PrepRawData const*, std::allocator<Trk::PrepRawData const*> > const*) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0xCAE2EBB9: Muon::MooTrackBuilder::find(Muon::MuPatCandidateBase&, std::vector<Muon::MuPatSegment*, std::allocator<Muon::MuPatSegment*> > const&) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0xCAE9DAC1: Muon::MuonTrackSteering::extendWithLayer(Muon::MuPatTrack&, std::vector<std::vector<Muon::MuPatSegment*, std::allocator<Muon::MuPatSegment*> >, std::allocator<std::vector<Muon::MuPatSegment*, std::allocator<Muon::MuPatSegment*> > > > const&, unsigned int, unsigned int, int) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0xCAE9DEFE: Muon::MuonTrackSteering::findTrackFromSeed(Muon::MuPatSegment&, Muon::MuonTrackSteeringStrategy const&, unsigned int, std::vector<std::vector<Muon::MuPatSegment*, std::allocator<Muon::MuPatSegment*> >, std::allocator<std::vector<Muon::MuPatSegment*, std::allocator<Muon::MuPatSegment*> > > > const&) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0xCAEA3A2A: Muon::MuonTrackSteering::findTracks() const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0xCAEA4AD9: Muon::MuonTrackSteering::find(std::vector<Muon::MuonSegment const*, std::allocator<Muon::MuonSegment const*> > const&) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0x9E03B847: TrigMuonEFStandaloneTrackTool::buildTracks(DataVector<Trk::Segment, DataModel_detail::NoBase> const*, SegmentCache*, TrigMuonEFMSMonVars&, std::vector<TrigTimer*, std::allocator<TrigTimer*> >&, unsigned int) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigMuonEF.so)
==23584== by 0x9E03D45D: TrigMuonEFStandaloneTrackTool::getExtrapolatedTracks(IRoiDescriptor const*, DataVector<MuonCombined::MuonCandidate, DataModel_detail::NoBase>&, DataVector<Trk::Track, DataModel_detail::NoBase>&, SegmentCache*&, TrigMuonEFMonVars&, std::vector<TrigTimer*, std::allocator<TrigTimer*> >&) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigMuonEF.so)
==23584== by 0x9E03D7EB: TrigMuonEFStandaloneTrackTool::getExtrapolatedTracks(IRoiDescriptor const*, DataVector<MuonCombined::MuonCandidate, DataModel_detail::NoBase>&, DataVector<Trk::Track, DataModel_detail::NoBase>&, TrigMuonEFMonVars&, std::vector<TrigTimer*, std::allocator<TrigTimer*> >&) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigMuonEF.so)
==23584== by 0x9DCFBB1D: TrigMuSuperEF::runMSReconstruction(IRoiDescriptor const*, HLT::TriggerElement*, DataVector<MuonCombined::MuonCandidate, DataModel_detail::NoBase>&, std::unique_ptr<DataVector<xAOD::Muon_v1, DataVector<xAOD::IParticle, DataModel_detail::NoBase> >, std::default_delete<DataVector<xAOD::Muon_v1, DataVector<xAOD::IParticle, DataModel_detail::NoBase> > > >&) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigMuSuperEF.so)
==23584== by 0x9DCFC17A: TrigMuSuperEF::runMSCBReconstruction(IRoiDescriptor const*, HLT::TriggerElement*, DataVector<MuonCombined::MuonCandidate, DataModel_detail::NoBase>&, DataVector<MuonCombined::InDetCandidate, DataModel_detail::NoBase>&, std::unique_ptr<DataVector<xAOD::Muon_v1, DataVector<xAOD::IParticle, DataModel_detail::NoBase> >, std::default_delete<DataVector<xAOD::Muon_v1, DataVector<xAOD::IParticle, DataModel_detail::NoBase> > > >&) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigMuSuperEF.so)
==23584== by 0x9DCFC2DB: TrigMuSuperEF::runOutsideInOnly(IRoiDescriptor const*, HLT::TriggerElement*, DataVector<MuonCombined::MuonCandidate, DataModel_detail::NoBase>*, DataVec
and
==23584== at 0x4C2AA02: operator new(unsigned long) (vg_replace_malloc.c:344)
==23584== by 0xA2DE8148: Trk::Extrapolator::extrapolateM(Trk::ParametersBase<5, Trk::Charged> const&, Trk::Surface const&, Trk::PropDirection, Trk::BoundaryCheck, Trk::ParticleHypothesis, Trk::ExtrapolationCache*) const (Extrapolator.cxx:2330)
==23584== by 0xA3A4F408: Trk::GlobalChi2Fitter::addMaterial(Trk::GlobalChi2Fitter::Cache&, Trk::GXFTrajectory&, Trk::ParametersBase<5, Trk::Charged> const*, Trk::ParticleHypothesis) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrkGlobalChi2Fitter.so)
==23584== by 0xA3A57B62: Trk::GlobalChi2Fitter::myfit(Trk::GlobalChi2Fitter::Cache&, Trk::GXFTrajectory&, Trk::ParametersBase<5, Trk::Charged> const&, bool, Trk::ParticleHypothesis) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrkGlobalChi2Fitter.so)
==23584== by 0xA3A64C15: Trk::GlobalChi2Fitter::fit(std::vector<Trk::MeasurementBase const*, std::allocator<Trk::MeasurementBase const*> > const&, Trk::ParametersBase<5, Trk::Charged> const&, bool, Trk::ParticleHypothesis) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrkGlobalChi2Fitter.so)
==23584== by 0xCAE69DFD: Muon::MooTrackFitter::fit(Trk::ParametersT<5, Trk::Charged, Trk::PerigeeSurface> const&, std::vector<Trk::MeasurementBase const*, std::allocator<Trk::MeasurementBase const*> >&, Trk::ParticleHypothesis, bool) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0xCAE6AD8B: Muon::MooTrackFitter::fit(Muon::MuPatCandidateBase const&, Muon::MuPatCandidateBase const&, std::vector<Trk::PrepRawData const*, std::allocator<Trk::PrepRawData const*> > const*) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0xCAE2D44A: Muon::MooTrackBuilder::combine(Muon::MuPatCandidateBase const&, Muon::MuPatCandidateBase const&, std::vector<Trk::PrepRawData const*, std::allocator<Trk::PrepRawData const*> > const*) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0xCAE2EBB9: Muon::MooTrackBuilder::find(Muon::MuPatCandidateBase&, std::vector<Muon::MuPatSegment*, std::allocator<Muon::MuPatSegment*> > const&) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0xCAE9DDFD: Muon::MuonTrackSteering::findTrackFromSeed(Muon::MuPatSegment&, Muon::MuonTrackSteeringStrategy const&, unsigned int, std::vector<std::vector<Muon::MuPatSegment*, std::allocator<Muon::MuPatSegment*> >, std::allocator<std::vector<Muon::MuPatSegment*, std::allocator<Muon::MuPatSegment*> > > > const&) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0xCAEA3A2A: Muon::MuonTrackSteering::findTracks() const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0xCAEA4AD9: Muon::MuonTrackSteering::find(std::vector<Muon::MuonSegment const*, std::allocator<Muon::MuonSegment const*> > const&) const (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libMuonTrackSteeringTools.so)
==23584== by 0x9E03B847: TrigMuonEFStandaloneTrackTool::buildTracks(DataVector<Trk::Segment, DataModel_detail::NoBase> const*, SegmentCache*, TrigMuonEFMSMonVars&, std::vector<TrigTimer*, std::allocator<TrigTimer*> >&, unsigned int) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigMuonEF.so)
==23584== by 0x9E03D45D: TrigMuonEFStandaloneTrackTool::getExtrapolatedTracks(IRoiDescriptor const*, DataVector<MuonCombined::MuonCandidate, DataModel_detail::NoBase>&, DataVector<Trk::Track, DataModel_detail::NoBase>&, SegmentCache*&, TrigMuonEFMonVars&, std::vector<TrigTimer*, std::allocator<TrigTimer*> >&) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigMuonEF.so)
==23584== by 0x9E03D7EB: TrigMuonEFStandaloneTrackTool::getExtrapolatedTracks(IRoiDescriptor const*, DataVector<MuonCombined::MuonCandidate, DataModel_detail::NoBase>&, DataVector<Trk::Track, DataModel_detail::NoBase>&, TrigMuonEFMonVars&, std::vector<TrigTimer*, std::allocator<TrigTimer*> >&) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigMuonEF.so)
==23584== by 0x9DCFBB1D: TrigMuSuperEF::runMSReconstruction(IRoiDescriptor const*, HLT::TriggerElement*, DataVector<MuonCombined::MuonCandidate, DataModel_detail::NoBase>&, std::unique_ptr<DataVector<xAOD::Muon_v1, DataVector<xAOD::IParticle, DataModel_detail::NoBase> >, std::default_delete<DataVector<xAOD::Muon_v1, DataVector<xAOD::IParticle, DataModel_detail::NoBase> > > >&) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigMuSuperEF.so)
==23584== by 0x9DCFC11F: TrigMuSuperEF::runStandAlone(IRoiDescriptor const*, HLT::TriggerElement*, DataVector<MuonCombined::MuonCandidate, DataModel_detail::NoBase>*, std::unique_ptr<DataVector<xAOD::Muon_v1, DataVector<xAOD::IParticle, DataModel_detail::NoBase> >, std::default_delete<DataVector<xAOD::Muon_v1, DataVector<xAOD::IParticle, DataModel_detail::NoBase> > > >&) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigMuSuperEF.so)
==23584== by 0x9DCFF5C6: TrigMuSuperEF::runStandardChain(HLT::TriggerElement const*, HLT::TriggerElement*, std::unique_ptr<DataVector<xAOD::Muon_v1, DataVector<xAOD::IParticle, DataModel_detail::NoBase> >, std::default_delete<DataVector<xAOD::Muon_v1, DataVector<xAOD::IParticle, DataModel_detail::NoBase> > > >&) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigMuSuperEF.so)
==23584== by 0x9DD009BC: TrigMuSuperEF::hltExecute(HLT::TriggerElement const*, HLT::TriggerElement*) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigMuSuperEF.so)
==23584== by 0x4103E0F3: HLT::FexAlgo::plugin_processTE(std::vector<HLT::TriggerElement const*, std::allocator<HLT::TriggerElement const*> >&, HLT::TriggerElement*) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigInterfacesLib.so)
==23584== by 0x410414E4: HLT::TECombineAlgo::createAndProcessTEs(std::vector<unsigned int, std::allocator<unsigned int> >&, unsigned int, std::vector<HLT::TriggerElement*, std::allocator<HLT::TriggerElement*> >&, std::vector<unsigned int, std::allocator<unsigned int> > const&) (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrigInterfacesLib.so)
==23584== by 0x4096C631: HLT::Sequence::execute() (in /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2019-08-11T2129/Athena/22.0.3/InstallArea/x86_64-centos7-gcc8-opt/lib/libTrig
They are due to missing cleanup in the GlobalChi2Fitter.
After these fixes there are still Trk::Tracks leaked which are produced by the GlobalChi2Fitter, but the leak is presumably further down the chain e.g. MooTrackBuilder or below.