diff --git a/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonNtuple.cxx b/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonNtuple.cxx index 5f61e61409791d893229867ddc409de7dedaffc8..57922b976c974e61d9e8d0b071501a488910b30e 100644 --- a/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonNtuple.cxx +++ b/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonNtuple.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // ********************************************************************** @@ -889,7 +889,7 @@ const Trk::TrackParameters* IDAlignMonNtuple::getUnbiasedTrackParameters(const T tsos->measurementOnTrack()->associatedSurface(), Trk::anyDirection, false, *TempField, - Trk::nonInteracting); + Trk::nonInteracting).release(); if(msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "After other side unbiased propagation" << endmsg; delete OtherSideUnbiasedTrackParams; diff --git a/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonResiduals.cxx b/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonResiduals.cxx index 2cf31f6da2da4a224464f9732a8e6d5dd2b7162d..0b6c25048a853446f50fd158ae042a70069e1854 100755 --- a/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonResiduals.cxx +++ b/InnerDetector/InDetMonitoring/InDetAlignmentMonitoring/src/IDAlignMonResiduals.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // *************************************************************************************** @@ -2914,7 +2914,7 @@ const Trk::TrackParameters* IDAlignMonResiduals::getUnbiasedTrackParameters(cons tsos->measurementOnTrack()->associatedSurface(), Trk::anyDirection, false, *TempField, - Trk::nonInteracting); + Trk::nonInteracting).release(); } else { diff --git a/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/src/TRT_DetElementsRoadMaker_xk.cxx b/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/src/TRT_DetElementsRoadMaker_xk.cxx index 5e2a20811d9612dd91ddc5bafeac883f36f76e2b..531ab813b76d6c5731f709a42f05774be45ea1bf 100755 --- a/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/src/TRT_DetElementsRoadMaker_xk.cxx +++ b/InnerDetector/InDetRecTools/TRT_DetElementsRoadTool_xk/src/TRT_DetElementsRoadMaker_xk.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -342,22 +342,23 @@ void InDet::TRT_DetElementsRoadMaker_xk::detElementsRoad Trk::MagneticFieldMode fieldModeEnum(m_fieldModeEnum); if(!fieldCache.solenoidOn()) fieldModeEnum = Trk::NoField; Trk::MagneticFieldProperties fieldprop(fieldModeEnum); - + //give up ownership to the vector const Trk::TrackParameters* tp0 = - m_proptool->propagate(ctx, Tp,(*r)->surface(),D,false,fieldprop,Trk::pion); + m_proptool->propagate(ctx, Tp,(*r)->surface(),D,false,fieldprop,Trk::pion).release(); if(!tp0) return; std::pair<const InDetDD::TRT_BaseElement*,const Trk::TrackParameters*> EP0((*r),tp0); R.push_back(EP0); for(++r; r!=re; ++r) { - + //give up ownership to the vector const Trk::TrackParameters* tp = - m_proptool->propagate(ctx, (*tp0),(*r)->surface(),D,false,fieldprop,Trk::pion); + m_proptool->propagate(ctx, (*tp0),(*r)->surface(),D,false,fieldprop,Trk::pion).release(); if(!tp) return; - + //ownership of tp given to the vector std::pair<const InDetDD::TRT_BaseElement*,const Trk::TrackParameters*> EP((*r),tp); - R.push_back(EP); tp0=tp; + R.push_back(EP); + tp0=tp; } } diff --git a/InnerDetector/InDetRecTools/TRT_SeededTrackFinderTool/src/TRT_SeededTrackFinder_ATL.cxx b/InnerDetector/InDetRecTools/TRT_SeededTrackFinderTool/src/TRT_SeededTrackFinder_ATL.cxx index ad9c5f3869c996bd34588ac043f5622b7008d4ae..f43903d7d75f157fd54da24e9af12619ba1d1715 100755 --- a/InnerDetector/InDetRecTools/TRT_SeededTrackFinderTool/src/TRT_SeededTrackFinder_ATL.cxx +++ b/InnerDetector/InDetRecTools/TRT_SeededTrackFinderTool/src/TRT_SeededTrackFinder_ATL.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -651,10 +651,12 @@ std::list<Trk::Track*> InDet::TRT_SeededTrackFinder_ATL::findTrack const Trk::PerigeeSurface persurf (Amg::Vector3D(0,0,0)); //Get track parameters at the end of SCT to start backwards propagation - const Trk::TrackParameters* per = m_proptool->propagate(*upTP,persurf,Trk::oppositeMomentum,false,m_fieldprop,Trk::nonInteracting); //Propagate + auto per = m_proptool->propagate(*upTP,persurf,Trk::oppositeMomentum,false,m_fieldprop,Trk::nonInteracting); //Propagate if(!per){ if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG)<<"No extrapolated track parameters!"<<endmsg; - delete niTP; delete upTP; continue; + delete niTP; + delete upTP; + continue; } if(msgLvl(MSG::VERBOSE)) { @@ -665,10 +667,12 @@ std::list<Trk::Track*> InDet::TRT_SeededTrackFinder_ATL::findTrack //Get list of InDet Elements std::list<const InDetDD::SiDetectorElement*> DE; m_roadmaker->detElementsRoad(ctx, fieldCache, *per,Trk::alongMomentum,DE,event_data.roadMakerData()); - delete per; + //delete per; if( int(DE.size()) < m_nclusmin){ //Not enough detector elements to satisfy the minimum number of clusters requirement. Stop if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Too few detector elements, not expected" << endmsg; - delete niTP; delete upTP; continue; + delete niTP; + delete upTP; + continue; } // @@ -697,10 +701,14 @@ std::list<Trk::Track*> InDet::TRT_SeededTrackFinder_ATL::findTrack if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Initial Track Parameters at 1st SP created and scaled from TRT segment, " << endmsg; if(msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << (*mesTP) << endmsg; }else{ - delete niTP; delete upTP; continue; + delete niTP; + delete upTP; + continue; } }else{ - delete niTP; delete upTP; continue; + delete niTP; + delete upTP; + continue; } // @@ -746,14 +754,14 @@ InDet::TRT_SeededTrackFinder_ATL::getTP(MagField::AtlasFieldCache& fieldCache, c bool& outl, InDet::TRT_SeededTrackFinder_ATL::EventData &event_data) const { - const Trk::TrackParameters* iTP = 0; + const Trk::TrackParameters* iTP = nullptr; outl = false; const Trk::Surface& surf = SP->associatedSurface(); //Get the associated surface Trk::PropDirection dir = Trk::oppositeMomentum; //Propagate backwards i.e. opposite momentum when filtering Trk::ParticleHypothesis part = Trk::nonInteracting; //Choose a non interacting particle - const Trk::TrackParameters* eTP = m_proptool->propagate(*startTP,surf,dir,false,m_fieldprop,part); //Propagate + auto eTP = m_proptool->propagate(*startTP,surf,dir,false,m_fieldprop,part); //Propagate if(!eTP){ @@ -779,9 +787,9 @@ InDet::TRT_SeededTrackFinder_ATL::getTP(MagField::AtlasFieldCache& fieldCache, c double covPola=event_data.noise().covariancePola(); double covIMom=event_data.noise().covarianceIMom(); double corIMom=event_data.noise().correctionIMom(); - iTP = addNoise(covAzim,covPola,covIMom,corIMom,eTP,0); + iTP = addNoise(covAzim,covPola,covIMom,corIMom,eTP.get(),0); if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG)<<"The updator failed! Count an outlier "<<endmsg; - delete eTP; + //delete eTP; //if (uTP) {delete uTP; delete sct_fitChi2;} outl = true; @@ -804,12 +812,14 @@ InDet::TRT_SeededTrackFinder_ATL::getTP(MagField::AtlasFieldCache& fieldCache, c double covPola=event_data.noise().covariancePola(); double covIMom=event_data.noise().covarianceIMom(); double corIMom=event_data.noise().correctionIMom(); - iTP = addNoise(covAzim,covPola,covIMom,corIMom,eTP,0); + iTP = addNoise(covAzim,covPola,covIMom,corIMom,eTP.get(),0); outl = true; } // Clean up - delete eTP; delete uTP; delete sct_fitChi2; + //delete eTP; + delete uTP; + delete sct_fitChi2; } } return iTP; diff --git a/InnerDetector/InDetRecTools/TRT_TrackExtensionTool_DAF/src/TRT_TrackExtensionTool_DAF.cxx b/InnerDetector/InDetRecTools/TRT_TrackExtensionTool_DAF/src/TRT_TrackExtensionTool_DAF.cxx index e20184407d0e0c4882400153f1074625c2970a61..1474a4acf7d6d3048c49ab963cde33cb52b95b84 100755 --- a/InnerDetector/InDetRecTools/TRT_TrackExtensionTool_DAF/src/TRT_TrackExtensionTool_DAF.cxx +++ b/InnerDetector/InDetRecTools/TRT_TrackExtensionTool_DAF/src/TRT_TrackExtensionTool_DAF.cxx @@ -283,12 +283,12 @@ InDet::TRT_TrackExtensionTool_DAF::extendTrack(const EventContext& ctx, } for(; detElIter!=detElements.end(); ++detElIter) { // propagate without boundary checks to detElement - const Trk::TrackParameters* nextTrkPar = m_propagator->propagateParameters(*previousTrkPar, (*detElIter)->surface(), Trk::alongMomentum, false, m_fieldprop, Trk::nonInteracting); + const Trk::TrackParameters* nextTrkPar = m_propagator->propagateParameters(*previousTrkPar, (*detElIter)->surface(), Trk::alongMomentum, false, m_fieldprop, Trk::nonInteracting).release(); if(!nextTrkPar) { // propagate directly to this detElement and hope that the Fitter will do a better job: ATH_MSG_DEBUG("step by step propagation of track parameters to TRT detector element failed: Try direct propagation (this may cause problems for the Fitter)"); ATH_MSG_DEBUG("Problem was in " << (*detElIter)->type() <<" at (" << (*detElIter)->center().x() <<", "<< (*detElIter)->center().y() <<", "<< (*detElIter)->center().z() << ")" ); - nextTrkPar = m_propagator->propagateParameters(*event_data.m_siliconTrkParams, (*detElIter)->surface(), Trk::alongMomentum, false, m_fieldprop, Trk::nonInteracting); + nextTrkPar = m_propagator->propagateParameters(*event_data.m_siliconTrkParams, (*detElIter)->surface(), Trk::alongMomentum, false, m_fieldprop, Trk::nonInteracting).release(); if (!nextTrkPar) { ATH_MSG_WARNING("direct propagation of track parameters to TRT detector element failed:"); ATH_MSG_WARNING(" this detector element will be dropped and RIOs on the road may be lost!"); @@ -726,7 +726,7 @@ InDet::TRT_TrackExtensionTool_DAF::groupedBarrelExtension(int beginIndex, // get StraightLineSurface of the RIO closest to the prediction const Trk::Surface& RIOsurface = minDistanceRIO[groupIndex]->detectorElement()->surface(minDistanceRIO[groupIndex]->identify()); // propagate to this surface - const Trk::TrackParameters* TrkPar = m_propagator->propagateParameters(*event_data.m_siliconTrkParams, RIOsurface, Trk::alongMomentum, false, m_fieldprop, Trk::nonInteracting); + auto TrkPar = m_propagator->propagateParameters(*event_data.m_siliconTrkParams, RIOsurface, Trk::alongMomentum, false, m_fieldprop, Trk::nonInteracting); if (!TrkPar) { ATH_MSG_WARNING("propagation of track parameters to the RIO surface failed:"); ATH_MSG_WARNING(" this group of RIOs will skipped!"); @@ -739,7 +739,7 @@ InDet::TRT_TrackExtensionTool_DAF::groupedBarrelExtension(int beginIndex, ATH_MSG_WARNING("current CompetingTRT_DriftCirclesOnTrack could not be created:"); ATH_MSG_WARNING(" this group of RIOs will skipped!"); // delete the trkParameters - delete TrkPar; + //delete TrkPar; continue; } // --------------- @@ -747,7 +747,7 @@ InDet::TRT_TrackExtensionTool_DAF::groupedBarrelExtension(int beginIndex, // first we have to cast to the base class? event_data.m_measurement.push_back(compROT); // delete the propagated trkParams - delete TrkPar; + //delete TrkPar; usedGroupCounter++; } // end for (loop over RIO groups) ATH_MSG_DEBUG("Used " << usedGroupCounter << " from at total " << groupedRIOs.size() << " groups, should be used "<< createdGroupCounter); diff --git a/InnerDetector/InDetTrigRecAlgs/InDetTrigTrackResidualMonitor/src/TrigTrackResidualMonitor.cxx b/InnerDetector/InDetTrigRecAlgs/InDetTrigTrackResidualMonitor/src/TrigTrackResidualMonitor.cxx index 99bcf295dc47f66634b5cb052d5600bebff93b93..f549adb20b4506cde9503b1915145f5c43f58388 100644 --- a/InnerDetector/InDetTrigRecAlgs/InDetTrigTrackResidualMonitor/src/TrigTrackResidualMonitor.cxx +++ b/InnerDetector/InDetTrigRecAlgs/InDetTrigTrackResidualMonitor/src/TrigTrackResidualMonitor.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "InDetTrigTrackResidualMonitor/TrigTrackResidualMonitor.h" @@ -503,7 +503,7 @@ namespace InDet tsos->measurementOnTrack()->associatedSurface(), Trk::anyDirection, false, *TempField, - m_ParticleHypothesis); + m_ParticleHypothesis).release(); delete OtherSideUnbiasedTrackParams; @@ -561,7 +561,7 @@ namespace InDet tsos->measurementOnTrack()->associatedSurface(), Trk::anyDirection, false, *TempFieldPixel, - m_ParticleHypothesis); + m_ParticleHypothesis).release(); delete PropagatedPixelUnbiasedTrackParams; if (PixelUnbiasedTrackParams) { diff --git a/MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeAlg/src/ExtraTreeMuonFillerTool.cxx b/MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeAlg/src/ExtraTreeMuonFillerTool.cxx index 086752dc6933965c0cf6a5d28ea293ee45985cfe..aa85f4e414416aa6b938a5795483b751019d792d 100644 --- a/MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeAlg/src/ExtraTreeMuonFillerTool.cxx +++ b/MuonSpectrometer/MuonCalib/MuonCalibExtraTree/MuonCalibExtraTreeAlg/src/ExtraTreeMuonFillerTool.cxx @@ -183,9 +183,9 @@ inline Trk::Track* ExtraTreeMuonFillerTool::createTaggedMuonTrack( const xAOD::M std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern(0); typePattern.set(Trk::TrackStateOnSurface::Measurement); - + //ownership: assume the TSoS is taking care of this const Trk::TrackParameters *exPars = m_propagator->propagateParameters(*pars,meas.associatedSurface(), - Trk::anyDirection, false, Trk::MagneticFieldProperties()); + Trk::anyDirection, false, Trk::MagneticFieldProperties()).release(); if(!exPars){ ATH_MSG_VERBOSE("Could not propagate Track to segment surface"); } diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonSegmentFittingTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonSegmentFittingTool.cxx index 5bcaf0e6c495bb69dd2651b99296c746125a74d6..8dd088208a221d91e4ccbd25c641db17df402f95 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonSegmentFittingTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/MuonSegmentFittingTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "MuonSegmentFittingTool.h" @@ -62,7 +62,7 @@ MuonSegmentFittingTool::fit(const Amg::Vector3D& gpos, const Amg::Vector3D& gDir // extrapolate segment parameters to first measurements const Trk::MeasurementBase* firstMeas = rioVec.front(); const Trk::TrackParameters* exPars = m_slPropagator->propagate(segPars, firstMeas->associatedSurface(), - Trk::anyDirection, false, m_magFieldProperties); + Trk::anyDirection, false, m_magFieldProperties).release(); if (!exPars) { ATH_MSG_DEBUG(" Propagation failed!! "); return 0; @@ -165,7 +165,7 @@ MuonSegmentFittingTool::updateSegmentParameters(const Trk::Track& track, const T } const Trk::TrackParameters* exPars = - m_slPropagator->propagate(*pp, surf, Trk::anyDirection, false, m_magFieldProperties); + m_slPropagator->propagate(*pp, surf, Trk::anyDirection, false, m_magFieldProperties).release(); if (!exPars) { ATH_MSG_WARNING(" extrapolation failed, this should not happen "); return; diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMatchingTools/src/MuonSegmentInOverlapResolvingTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMatchingTools/src/MuonSegmentInOverlapResolvingTool.cxx index 0ab94d7900dd607a90d1555cc144cd6b45399182..ec771ceccdd437c7c2c4af559a027150b3b52974 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMatchingTools/src/MuonSegmentInOverlapResolvingTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMatchingTools/src/MuonSegmentInOverlapResolvingTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "MuonSegmentInOverlapResolvingTool.h" @@ -534,7 +534,7 @@ MuonSegmentInOverlapResolvingTool::checkPhiHitConsistency(const Muon::MuonSegmen const Trk::Surface& measSurf = (**mit).associatedSurface(); // propagate station parameters to segment - const Trk::TrackParameters* exPars = + auto exPars = m_propagator->propagate(segPars, measSurf, Trk::anyDirection, false, m_magFieldProperties); if (!exPars) { ATH_MSG_WARNING(" Failed to propagate parameter to segment surface" << std::endl @@ -543,10 +543,10 @@ MuonSegmentInOverlapResolvingTool::checkPhiHitConsistency(const Muon::MuonSegmen } else { const Trk::ResidualPull* resPull = - m_pullCalculator->residualPull(*mit, exPars, Trk::ResidualPull::Unbiased); + m_pullCalculator->residualPull(*mit, exPars.get(), Trk::ResidualPull::Unbiased); if (!resPull) { ATH_MSG_DEBUG(" calculation of residual/pull failed !!!!! "); - delete exPars; + //delete exPars; continue; } @@ -554,7 +554,7 @@ MuonSegmentInOverlapResolvingTool::checkPhiHitConsistency(const Muon::MuonSegmen if (resPull->pull().size() != 1) { ATH_MSG_WARNING(" ResidualPull with empty pull vector for channel " << m_idHelperSvc->toString(id)); delete resPull; - delete exPars; + //delete exPars; continue; } @@ -563,7 +563,7 @@ MuonSegmentInOverlapResolvingTool::checkPhiHitConsistency(const Muon::MuonSegmen averagePull += pull; ++nphiMeas; delete resPull; - delete exPars; + //delete exPars; } } if (nphiMeas != 0) averagePull /= nphiMeas; diff --git a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMomentum/src/MuonSegmentMomentumFromField.cxx b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMomentum/src/MuonSegmentMomentumFromField.cxx index 876c063c79113019cd359607653a6b255a6083ff..7d6ae9972380348ed5930163e1450edc4538a056 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMomentum/src/MuonSegmentMomentumFromField.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/MuonSegmentMomentum/src/MuonSegmentMomentumFromField.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "MuonSegmentMomentumFromField.h" @@ -191,10 +191,10 @@ void MuonSegmentMomentumFromField::fitMomentum2Segments( const Muon::MuonSegment Trk::TransportJacobian *jac=0; Trk::AtaPlane startpar(bestseg->globalPosition(),bestseg->globalDirection().phi(), bestseg->globalDirection().theta(),1/signedMomentum,bestseg->associatedSurface()); - const Trk::TrackParameters *par=m_propagator->propagateParameters(startpar,worstseg->associatedSurface(), + auto par=m_propagator->propagateParameters(startpar,worstseg->associatedSurface(), (bestseg==myseg1) ? Trk::alongMomentum : Trk::oppositeMomentum,false, Trk::MagneticFieldProperties(Trk::FullField),jac,Trk::nonInteracting); - ATH_MSG_DEBUG("par: " << par << " jac: " << jac ); + ATH_MSG_DEBUG("par: " << par.get() << " jac: " << jac ); if (par && jac && (*jac)(1,4)!=0){ residual = worstseg->localParameters()[Trk::locY] - par->parameters()[Trk::locY]; resi[i] = residual; @@ -228,7 +228,7 @@ void MuonSegmentMomentumFromField::fitMomentum2Segments( const Muon::MuonSegment // do not change momentum beyond last iteration if(i<3) signedMomentum = signedMomentum_updated; } - delete par; + //delete par; delete jac; if (std::abs(residual)<1) break; } @@ -346,7 +346,7 @@ void MuonSegmentMomentumFromField::fitMomentum2Segments_old( const Muon::MuonSeg Trk::AtaPlane startpar(bestseg->globalPosition(),bestseg->globalDirection().phi(),bestseg->globalDirection().theta(), 1/signedMomentum,bestseg->associatedSurface()); Trk::TransportJacobian *jac=0; - const Trk::TrackParameters *par=m_propagator->propagateParameters(startpar,worstseg->associatedSurface(), + auto par=m_propagator->propagateParameters(startpar,worstseg->associatedSurface(), (bestseg==myseg1) ? Trk::alongMomentum : Trk::oppositeMomentum,false, Trk::MagneticFieldProperties(Trk::FullField),jac,Trk::nonInteracting); if (par && jac && (*jac)(1,4)!=0){ @@ -354,7 +354,7 @@ void MuonSegmentMomentumFromField::fitMomentum2Segments_old( const Muon::MuonSeg double delta_qoverp=residual/(*jac)(1,4); signedMomentum=1/(1/signedMomentum+delta_qoverp); ATH_MSG_DEBUG("residual: " << residual << " jac " << (*jac)(1,4) << " dp " << delta_qoverp << " signedmomentum: " << signedMomentum); - delete par; + // delete par; delete jac; if (std::abs(residual)<1) break; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.cxx index fd7f7566a6cc7a1c388e6fe145fed67840990ea5..44a136e775c640f9fd882b3f45c136163f06a693 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonSeededSegmentFinder.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "MuonSeededSegmentFinder.h" @@ -475,7 +475,8 @@ namespace Muon { const Trk::StraightLineSurface& surf = detEl.surface(id); // propagate segment parameters to first measurement - const Trk::TrackParameters* exPars = m_propagator->propagate(pars, surf, Trk::anyDirection, false, m_magFieldProperties); + //retain ownership; this code deleted the exPars before + auto exPars = m_propagator->propagate(pars, surf, Trk::anyDirection, false, m_magFieldProperties); if ( !exPars ) { ATH_MSG_DEBUG(" Propagation failed!! "); return 0; @@ -515,7 +516,7 @@ namespace Muon { //if( fabs(distanceToWire) > roadWidthR || fabs(posAlongWire) > halfTubeLength + roadWidthZ ){ if (nSigmaFromTrack > m_maxSigma || fabs(posAlongWire) > halfTubeLength + roadWidthZ ) { if ( msgLvl(MSG::VERBOSE) ) msg() << " --- dropped" << endmsg; - delete exPars; + //delete exPars; return 0; } @@ -530,7 +531,7 @@ namespace Muon { const MdtDriftCircleOnTrack* mdtROT = m_mdtRotCreator->createRIO_OnTrack(mdtPrd, exPars->position(), &momentum); // clean up pointers - delete exPars; + //delete exPars; // check whether ROT is created if ( !mdtROT ) { diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackToSegmentTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackToSegmentTool.cxx index 78cb83fc01b081f8057fb625d9ae9eca8051af7a..508d646a51c249a1a92c19bd18d52ce706a84f9f 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackToSegmentTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackFinderTools/src/MuonTrackToSegmentTool.cxx @@ -163,13 +163,13 @@ namespace Muon { double surfDim = 500.; Trk::PlaneSurface* surf = new Trk::PlaneSurface( transform, surfDim, surfDim ); delete surfaceTransformToBeDeleted; - - const Trk::TrackParameters* exPars = m_propagator->propagate(*closestPars,*surf, minDist > 0 ? Trk::oppositeMomentum : Trk::alongMomentum , + //lifetime of exPars is managed in this scope + auto exPars = m_propagator->propagate(*closestPars,*surf, minDist > 0 ? Trk::oppositeMomentum : Trk::alongMomentum , false,Trk::MagneticFieldProperties(Trk::NoField)); if( !exPars || !exPars->covariance() ){ ATH_MSG_DEBUG(" propagation failed!!! "); if( !surf->associatedDetectorElement() ) delete surf; - delete exPars; // it is save to delete a NULL pointer + //delete exPars; // it is save to delete a NULL pointer delete rots; return 0; } @@ -178,7 +178,7 @@ namespace Muon { if( !surf->globalToLocal(exPars->position(),exPars->momentum(),locPos) ){ ATH_MSG_WARNING(" localToGlobal failed!!! "); if( !surf->associatedDetectorElement() ) delete surf; - delete exPars; + //delete exPars; delete rots; return 0; } @@ -221,7 +221,7 @@ namespace Muon { quality = new Trk::FitQuality( fq->chiSquared(), fq->numberDoF() ); } MuonSegment* seg = new MuonSegment(locPos,locDir,cov,surf,rots,quality); - delete exPars; + //delete exPars; return seg; } diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.cxx index e5678875f5e794b7a196e5b1c0476965a514015e..6f61c52886b2f086a21f66c73075e5c6648f88a2 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackBuilder.cxx @@ -968,8 +968,9 @@ namespace Muon { if( etaCompRot->associatedSurface() == pars->associatedSurface() ){ etaPars = pars->clone(); }else{ + //ownership relinquished, should be treated in createMeasTSOS etaPars = m_propagator->propagate(*pars,etaCompRot->associatedSurface(),Trk::anyDirection, - false,m_magFieldProperties); + false,m_magFieldProperties).release(); } if( !etaPars ){ ATH_MSG_WARNING( " Failed to calculate TrackParameters for eta hits! " ); @@ -992,8 +993,9 @@ namespace Muon { if(phiCompRot->associatedSurface() == pars->associatedSurface() ){ phiPars = pars->clone(); }else{ + //ownership relinquished, handled in createMeasTSOS phiPars = m_propagator->propagate(*pars,phiCompRot->associatedSurface(),Trk::anyDirection, - false,m_magFieldProperties); + false,m_magFieldProperties).release(); } if( !phiPars ){ ATH_MSG_WARNING( " Failed to calculate TrackParameters for phi hits! " ); @@ -1411,15 +1413,15 @@ namespace Muon { continue; } if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << m_idHelperSvc->toString(id); - - const Trk::TrackParameters* impactPars = m_propagator->propagate(*closestPars,meas->associatedSurface(),Trk::anyDirection, + //unique ptr ownership retained. Original code deleted impactPars + auto impactPars = m_propagator->propagate(*closestPars,meas->associatedSurface(),Trk::anyDirection, false,m_magFieldProperties); if( impactPars ) { double residual = 1e10; double pull = 1e10; // pointer to resPull - const Trk::ResidualPull* resPull = m_pullCalculator->residualPull( meas, impactPars, Trk::ResidualPull::Unbiased ); + const Trk::ResidualPull* resPull = m_pullCalculator->residualPull( meas, impactPars.get(), Trk::ResidualPull::Unbiased ); if( resPull && resPull->pull().size() == 1 ) { if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " residual " << m_printer->print(*resPull); residual = resPull->residual().front(); @@ -1432,7 +1434,7 @@ namespace Muon { bool inBounds = false; Amg::Vector2D locPos; bool ok = meas->associatedSurface().globalToLocal(impactPars->position(),impactPars->momentum(),locPos); - delete impactPars; + //delete impactPars; if( ok ){ if( msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << " lpos (" << locPos[Trk::locX] << "," << locPos[Trk::locY] << ")"; double tol1 = 50.; diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackFitter.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackFitter.cxx index 1480f0210dc5f2647925bbfc8fc81fb304b31984..42bccfc0061c88ef6ed2a660932186aea5c905fd 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackFitter.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MooTrackFitter.cxx @@ -664,12 +664,13 @@ bool MooTrackFitter::extractData( const MuPatCandidateBase& entry1, const MuPatC double locy1 = segInfo1->segment->localParameters().contains(Trk::locY) ? segInfo1->segment->localParameters()[Trk::locY] : 0.; Trk::AtaPlane segPars1(locx1,locy1,result.phiResult.segmentDirection1.phi(),result.phiResult.segmentDirection1.theta(), 0.,segInfo1->segment->associatedSurface()); - const Trk::TrackParameters* exPars1 = m_propagator->propagate(segPars1,fitterData.measurements.front()->associatedSurface(), + //ownership retained, original code deleted exPars1 + auto exPars1 = m_propagator->propagate(segPars1,fitterData.measurements.front()->associatedSurface(), Trk::anyDirection,false,m_magFieldProperties); if( exPars1 ){ Amg::Vector3D position = exPars1->position(); const Trk::MeasurementBase* fake = createFakePhiForMeasurement(*fitterData.measurements.front(),&position,0,10.,garbage); - delete exPars1; + //delete exPars1; if( fake ) { fitterData.phiHits.push_back(fake); fitterData.measurements.insert(fitterData.measurements.begin(),fake); @@ -677,18 +678,19 @@ bool MooTrackFitter::extractData( const MuPatCandidateBase& entry1, const MuPatC } }else{ ATH_MSG_WARNING(" failed to create fake for first segment " ); - return false; + return false; } double locx2 = result.segmentResult2.positionInTube1; double locy2 = segInfo2->segment->localParameters().contains(Trk::locY) ? segInfo2->segment->localParameters()[Trk::locY] : 0.; Trk::AtaPlane segPars2(locx2,locy2,result.phiResult.segmentDirection2.phi(),result.phiResult.segmentDirection2.theta(), 0.,segInfo2->segment->associatedSurface()); - const Trk::TrackParameters* exPars2 = m_propagator->propagate(segPars2,fitterData.measurements.back()->associatedSurface(), + //ownership retained + auto exPars2 = m_propagator->propagate(segPars2,fitterData.measurements.back()->associatedSurface(), Trk::anyDirection,false,m_magFieldProperties); if( exPars2 ){ Amg::Vector3D position = exPars2->position(); const Trk::MeasurementBase* fake = createFakePhiForMeasurement(*fitterData.measurements.back(),&position,0,10.,garbage); - delete exPars2; + //delete exPars2; if( fake ){ fitterData.phiHits.push_back(fake); fitterData.measurements.push_back(fake); @@ -829,16 +831,16 @@ bool MooTrackFitter::extractData( const MuPatCandidateBase& entry1, const MuPatC ATH_MSG_VERBOSE(" Adding fake at last hit: dist first phi/first eta " << distFirstEtaPhi << " dist last phi/last eta " << distLastEtaPhi); if (fitterData.secondEntry->hasSLOverlap() || phifromextrapolation) { - - const Trk::TrackParameters *mdtpar=0; - if (fitterData.secondEntry->hasSLOverlap()) mdtpar=lastmdtpar->clone(); + //this scope manages lifetime of mdtpar + std::unique_ptr<Trk::TrackParameters> mdtpar{}; + if (fitterData.secondEntry->hasSLOverlap()) mdtpar.reset(lastmdtpar->clone()); else mdtpar=m_propagator->propagateParameters(*startpar,*lastmdtsurf,Trk::alongMomentum,false,m_magFieldProperties); if (mdtpar){ Amg::MatrixX cov(1,1); cov(0,0) = 100.; fake = new Trk::PseudoMeasurementOnTrack(Trk::LocalParameters(Trk::DefinedParameter(mdtpar->parameters()[Trk::locY],Trk::locY)), cov,mdtpar->associatedSurface()); - delete mdtpar; + //delete mdtpar; garbage.measurementsToBeDeleted.push_back(fake); } } @@ -855,14 +857,15 @@ bool MooTrackFitter::extractData( const MuPatCandidateBase& entry1, const MuPatC ATH_MSG_VERBOSE(" Adding fake at first hit: dist first phi/first eta " << distFirstEtaPhi << " dist last phi/last eta " << distLastEtaPhi); if (phifromextrapolation) { - const Trk::TrackParameters *mdtpar=m_propagator->propagateParameters(*startpar,*firstmdtsurf,Trk::oppositeMomentum,false,m_magFieldProperties); + //lifetime of mdtpar managed here + auto mdtpar=m_propagator->propagateParameters(*startpar,*firstmdtsurf,Trk::oppositeMomentum,false,m_magFieldProperties); if (mdtpar) { Amg::MatrixX cov(1,1); cov(0,0) = 100.; fake = new Trk::PseudoMeasurementOnTrack(Trk::LocalParameters(Trk::DefinedParameter(mdtpar->parameters()[Trk::locY],Trk::locY)), cov,mdtpar->associatedSurface()); garbage.measurementsToBeDeleted.push_back(fake); - delete mdtpar; + //delete mdtpar; } } else fake = createFakePhiForMeasurement(*fitterData.measurements.front(),overlapPos,phiPos,100.,garbage); @@ -1772,11 +1775,11 @@ bool MooTrackFitter::extractData( const MuPatCandidateBase& entry1, const MuPatC const Trk::TrackParameters* garbage = 0; double shift = 1.; if( m_seedAtStartOfTrack ){ - - exPars = m_propagator->propagate(firstPars,firstMeas.associatedSurface(),Trk::anyDirection,false,m_magFieldProperties); + //not sure whats going on with ownership here, so let this code take care of it + exPars = m_propagator->propagate(firstPars,firstMeas.associatedSurface(),Trk::anyDirection,false,m_magFieldProperties).release(); if( !exPars ) { - ATH_MSG_DEBUG(" Propagation failed in createPerigee!! " ); - return 0; + ATH_MSG_DEBUG(" Propagation failed in createPerigee!! " ); + return 0; } garbage = exPars; shift = 100.; diff --git a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MuPatHitTool.cxx b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MuPatHitTool.cxx index 4db6dca865ec798da00644aa4928632900c2581c..7d7a39e5fafe03939eb1b469a92e750ffb7b48a8 100644 --- a/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MuPatHitTool.cxx +++ b/MuonSpectrometer/MuonReconstruction/MuonTrackMakers/MuonTrackMakerTools/MuonTrackSteeringTools/src/MuPatHitTool.cxx @@ -135,8 +135,11 @@ MuPatHitTool::create(const Trk::TrackParameters& pars, const std::vector<const T exPars.reset (pars.clone()); ATH_MSG_VERBOSE(" start parameters and measurement expressed at same surface, cloning parameters "); } else { - exPars.reset - (m_propagator->propagate(pars, meas.associatedSurface(), Trk::anyDirection, false, m_magFieldProperties)); + + //this code does its own manual garbage collection which can probably be omitted now + exPars = + std::move(m_propagator->propagate(pars, meas.associatedSurface(), Trk::anyDirection, false, m_magFieldProperties)); + if (!exPars) { if (!wasPrinted) { ATH_MSG_WARNING(" extrapolation of segment failed, cannot calculate residual "); @@ -301,8 +304,11 @@ MuPatHitTool::merge(const MuPatHitList& hitList1, MuPatHitList& hitList2) const exPars.reset (stPars.clone()); } else { // redo propagation - exPars.reset (m_propagator->propagate(stPars, meas.associatedSurface(), Trk::anyDirection, false, - m_magFieldProperties)); + + //this code does its own garbage collection, but this can prob. be simplified now + exPars = std::move(m_propagator->propagate(stPars, meas.associatedSurface(), Trk::anyDirection, false, + m_magFieldProperties)); + // if failed keep old parameters if (!exPars) { ATH_MSG_DEBUG(" extrapolation failed, cannot insert hit " diff --git a/PhysicsAnalysis/D3PDMaker/MuonD3PDMaker/src/MuonSegmentLocationFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/MuonD3PDMaker/src/MuonSegmentLocationFillerTool.cxx index 2620c80af5e7d03aa53f65ffdda0a8d745b4c360..feb10163aaa7006ee0dcdfa04293fc2e3baaa6ab 100644 --- a/PhysicsAnalysis/D3PDMaker/MuonD3PDMaker/src/MuonSegmentLocationFillerTool.cxx +++ b/PhysicsAnalysis/D3PDMaker/MuonD3PDMaker/src/MuonSegmentLocationFillerTool.cxx @@ -169,7 +169,7 @@ StatusCode MuonSegmentLocationFillerTool::fill (const Trk::Segment& ts) { *m_npadHits = npadHits; *m_npseudoHits = npseudoHits; - const Trk::TrackParameters* exPars = m_slPropagator->propagate(*pars,meas.associatedSurface(),Trk::anyDirection,false,*m_magFieldProperties); + const Trk::TrackParameters* exPars = m_slPropagator->propagate(*pars,meas.associatedSurface(),Trk::anyDirection,false,*m_magFieldProperties).release(); if( !exPars && meas.associatedSurface().isOnSurface(pars->position()) ){ exPars = pars->clone(); } diff --git a/Reconstruction/MuonIdentification/MuidCaloScatteringTools/src/MuidCaloTrackStateOnSurface.cxx b/Reconstruction/MuonIdentification/MuidCaloScatteringTools/src/MuidCaloTrackStateOnSurface.cxx index 09e1a0de736b33c930796803426ea6e72582589e..282c33645fe62353ff516946c89de2d9cf7258b6 100755 --- a/Reconstruction/MuonIdentification/MuidCaloScatteringTools/src/MuidCaloTrackStateOnSurface.cxx +++ b/Reconstruction/MuonIdentification/MuidCaloScatteringTools/src/MuidCaloTrackStateOnSurface.cxx @@ -402,8 +402,9 @@ MuidCaloTrackStateOnSurface::innerParameters(const Trk::TrackParameters& paramet propDirection = oppositeDirection; } } + //tidy up ownership later const Trk::TrackParameters* extrapolation = - m_propagator->propagate(parameters, *surface, propDirection, false, *m_magFieldProperties, Trk::nonInteracting); + m_propagator->propagate(parameters, *surface, propDirection, false, *m_magFieldProperties, Trk::nonInteracting).release(); if (!extrapolation) return nullptr; // phi flip means track has crossed beam-axis (so quit) @@ -440,10 +441,10 @@ MuidCaloTrackStateOnSurface::innerParameters(const Trk::TrackParameters& paramet } else { propDirection = Trk::anyDirection; } - + //tidy up ownership later const Trk::TrackParameters* oldParameters = extrapolation; extrapolation = m_propagator->propagate(*oldParameters, *extrapolatedSurface, propDirection, false, - *m_magFieldProperties, Trk::nonInteracting); + *m_magFieldProperties, Trk::nonInteracting).release(); if (!extrapolation) { // restart from input parameters (if not already done) // trap no solution after restart @@ -529,7 +530,7 @@ MuidCaloTrackStateOnSurface::middleParameters(const Trk::TrackParameters& parame } } const Trk::TrackParameters* extrapolation = - m_propagator->propagate(parameters, *surface, propDirection, false, *m_magFieldProperties, Trk::nonInteracting); + m_propagator->propagate(parameters, *surface, propDirection, false, *m_magFieldProperties, Trk::nonInteracting).release(); if (!extrapolation) return nullptr; // phi flip means track has crossed beam-axis (so quit) @@ -569,7 +570,7 @@ MuidCaloTrackStateOnSurface::middleParameters(const Trk::TrackParameters& parame const Trk::TrackParameters* oldParameters = extrapolation; extrapolation = m_propagator->propagate(*oldParameters, *extrapolatedSurface, propDirection, false, - *m_magFieldProperties, Trk::nonInteracting); + *m_magFieldProperties, Trk::nonInteracting).release(); if (!extrapolation) { // restart from input parameters (if not already done) // trap no solution after restart @@ -655,8 +656,9 @@ MuidCaloTrackStateOnSurface::outerParameters(const Trk::TrackParameters& paramet propDirection = oppositeDirection; } } + //tidy up ownership later const Trk::TrackParameters* extrapolation = - m_propagator->propagate(parameters, *surface, propDirection, false, *m_magFieldProperties, Trk::nonInteracting); + m_propagator->propagate(parameters, *surface, propDirection, false, *m_magFieldProperties, Trk::nonInteracting).release(); if (!extrapolation) return nullptr; // phi flip means track has crossed beam-axis (so quit) @@ -693,10 +695,10 @@ MuidCaloTrackStateOnSurface::outerParameters(const Trk::TrackParameters& paramet } else { propDirection = Trk::anyDirection; } - + //tidy up ownership later const Trk::TrackParameters* oldParameters = extrapolation; extrapolation = m_propagator->propagate(*oldParameters, *extrapolatedSurface, propDirection, false, - *m_magFieldProperties, Trk::nonInteracting); + *m_magFieldProperties, Trk::nonInteracting).release(); if (!extrapolation) { // restart from input parameters (if not already done) // trap no solution after restart diff --git a/Reconstruction/MuonIdentification/MuidTrackBuilder/src/CombinedMuonTrackBuilder.cxx b/Reconstruction/MuonIdentification/MuidTrackBuilder/src/CombinedMuonTrackBuilder.cxx index 290d6c52399cc61f80a0b44166f2cd056500abc3..5ac39971933c9954b8c0ef1fdc00493867387ac1 100755 --- a/Reconstruction/MuonIdentification/MuidTrackBuilder/src/CombinedMuonTrackBuilder.cxx +++ b/Reconstruction/MuonIdentification/MuidTrackBuilder/src/CombinedMuonTrackBuilder.cxx @@ -791,17 +791,19 @@ CombinedMuonTrackBuilder::indetExtension(const Trk::Track& indetTrack, if (innerParameters->associatedSurface() == spectrometerMeasurements.front()->associatedSurface()) { frontParameters = innerParameters->clone(); } else { + //TSoS will own this frontParameters = m_propagator->propagate(*innerParameters, spectrometerMeasurements.front()->associatedSurface(), - Trk::anyDirection, false, m_magFieldProperties, Trk::muon); + Trk::anyDirection, false, m_magFieldProperties, Trk::muon).release(); } } else if (middleParameters) { if (middleParameters->associatedSurface() == spectrometerMeasurements.front()->associatedSurface()) { frontParameters = middleParameters->clone(); } else { + //TSoS will own this frontParameters = m_propagator->propagate(*middleParameters, spectrometerMeasurements.front()->associatedSurface(), - Trk::anyDirection, false, m_magFieldProperties, Trk::muon); + Trk::anyDirection, false, m_magFieldProperties, Trk::muon).release(); } } @@ -809,18 +811,19 @@ CombinedMuonTrackBuilder::indetExtension(const Trk::Track& indetTrack, if (outerParameters->associatedSurface() == spectrometerMeasurements.back()->associatedSurface()) { backParameters = outerParameters->clone(); } else { - + //TSoS will own this backParameters = m_propagator->propagate(*outerParameters, spectrometerMeasurements.back()->associatedSurface(), - Trk::anyDirection, false, m_magFieldProperties, Trk::muon); + Trk::anyDirection, false, m_magFieldProperties, Trk::muon).release(); } } else if (middleParameters) { if (middleParameters->associatedSurface() == spectrometerMeasurements.back()->associatedSurface()) { backParameters = middleParameters->clone(); } else { + //TSoS will own this backParameters = m_propagator->propagate(*middleParameters, spectrometerMeasurements.back()->associatedSurface(), - Trk::anyDirection, false, m_magFieldProperties, Trk::muon); + Trk::anyDirection, false, m_magFieldProperties, Trk::muon).release(); } } @@ -840,9 +843,9 @@ CombinedMuonTrackBuilder::indetExtension(const Trk::Track& indetTrack, previousDistance = distance; } else { if (midDistance - previousDistance < distance - midDistance) --m; - + //TSoS will own this midParameters = m_propagator->propagate(*middleParameters, (**m).associatedSurface(), Trk::anyDirection, - false, m_magFieldProperties, Trk::muon); + false, m_magFieldProperties, Trk::muon).release(); if (midParameters) midMeasurement = *m; break; @@ -1893,7 +1896,7 @@ CombinedMuonTrackBuilder::standaloneRefit(const Trk::Track& combinedTrack, float } else { parameters = m_propagator->propagate(*parameters, middleTSOS->trackParameters()->associatedSurface(), - Trk::oppositeMomentum, false, m_magFieldProperties, Trk::nonInteracting); + Trk::oppositeMomentum, false, m_magFieldProperties, Trk::nonInteracting).release(); } } @@ -1924,7 +1927,7 @@ CombinedMuonTrackBuilder::standaloneRefit(const Trk::Track& combinedTrack, float oldParameters = parameters; parameters = m_propagator->propagate(*parameters, innerTSOS->trackParameters()->associatedSurface(), - Trk::oppositeMomentum, false, m_magFieldProperties, Trk::nonInteracting); + Trk::oppositeMomentum, false, m_magFieldProperties, Trk::nonInteracting).release(); delete oldParameters; @@ -1935,7 +1938,7 @@ CombinedMuonTrackBuilder::standaloneRefit(const Trk::Track& combinedTrack, float const Trk::Perigee* perigee = nullptr; if (parameters) { perigee = dynamic_cast<const Trk::Perigee*>(m_propagator->propagate( - *parameters, *m_perigeeSurface, Trk::oppositeMomentum, false, m_magFieldProperties, Trk::nonInteracting)); + *parameters, *m_perigeeSurface, Trk::oppositeMomentum, false, m_magFieldProperties, Trk::nonInteracting).release()); } delete parameters; @@ -1944,7 +1947,7 @@ CombinedMuonTrackBuilder::standaloneRefit(const Trk::Track& combinedTrack, float // track back out to the 3 calo surfaces applying small correction for non-linearity parameters = m_propagator->propagate(*perigee, innerTSOS->trackParameters()->associatedSurface(), - Trk::alongMomentum, false, m_magFieldProperties, Trk::nonInteracting); + Trk::alongMomentum, false, m_magFieldProperties, Trk::nonInteracting).release(); if (!parameters) { // failed propagation to innerTSOS @@ -1957,7 +1960,7 @@ CombinedMuonTrackBuilder::standaloneRefit(const Trk::Track& combinedTrack, float oldParameters = parameters; parameters = m_propagator->propagate(*parameters, middleParameters->associatedSurface(), Trk::alongMomentum, - false, m_magFieldProperties, Trk::nonInteracting); + false, m_magFieldProperties, Trk::nonInteracting).release(); delete oldParameters; @@ -1969,7 +1972,7 @@ CombinedMuonTrackBuilder::standaloneRefit(const Trk::Track& combinedTrack, float oldParameters = parameters; parameters = m_propagator->propagate(*parameters, outerTSOS->trackParameters()->associatedSurface(), - Trk::alongMomentum, false, m_magFieldProperties, Trk::nonInteracting); + Trk::alongMomentum, false, m_magFieldProperties, Trk::nonInteracting).release(); delete oldParameters; } @@ -3160,12 +3163,12 @@ CombinedMuonTrackBuilder::createExtrapolatedTrack(const Trk::Track& sp if (oldParameters && !oldParameters->covariance()) { ATH_MSG_VERBOSE(" createExtrapolatedTrack: no cov (0)"); } - + //chickened out of sorting out ownership trackParameters = m_propagator->propagate(*oldParameters, *mperigeeSurface, Trk::oppositeMomentum, - false, m_magFieldProperties, Trk::nonInteracting); + false, m_magFieldProperties, Trk::nonInteracting).release(); } else { trackParameters = m_propagatorSL->propagate(parameters, *mperigeeSurface, Trk::oppositeMomentum, false, - m_magFieldProperties, Trk::nonInteracting); + m_magFieldProperties, Trk::nonInteracting).release(); } // only accept when perigee in indet tracking volume @@ -3976,7 +3979,7 @@ CombinedMuonTrackBuilder::extrapolatedParameters(bool& badlyDeterminedCurvature, if (curvatureOK) { const Trk::TrackParameters* perigee = propagator->propagate(*correctedParameters, *mperigeeSurface, Trk::oppositeMomentum, false, - m_magFieldProperties, Trk::nonInteracting); + m_magFieldProperties, Trk::nonInteracting).release(); if (!perigee) { ATH_MSG_DEBUG("standaloneFit: failed back extrapolation to perigee"); @@ -4024,7 +4027,7 @@ CombinedMuonTrackBuilder::extrapolatedParameters(bool& badlyDeterminedCurvature, new AmgSymMatrix(5)(*parameters->covariance())); perigee = propagator->propagate(*correctedParameters, *mperigeeSurface, Trk::oppositeMomentum, false, - m_magFieldProperties, Trk::nonInteracting); + m_magFieldProperties, Trk::nonInteracting).release(); if (perigee) { deltaPhi = 0.; @@ -4053,7 +4056,7 @@ CombinedMuonTrackBuilder::extrapolatedParameters(bool& badlyDeterminedCurvature, new AmgSymMatrix(5)(*parameters->covariance())); perigee = propagator->propagate(*correctedParameters, *mperigeeSurface, Trk::oppositeMomentum, false, - m_magFieldProperties, Trk::nonInteracting); + m_magFieldProperties, Trk::nonInteracting).release(); } if (perigee) { @@ -4116,7 +4119,7 @@ CombinedMuonTrackBuilder::extrapolatedParameters(bool& badlyDeterminedCurvature, Trk::TrackParameters* perigee = new Trk::Perigee(mvertex->position(), momentum, 1., *mperigeeSurface); correctedParameters = m_propagator->propagate(*perigee, perigee->associatedSurface(), Trk::alongMomentum, false, - m_magFieldProperties, Trk::nonInteracting); + m_magFieldProperties, Trk::nonInteracting).release(); delete parameters; delete perigee; diff --git a/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCreatorTool.cxx b/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCreatorTool.cxx index 91840f88c9b545a966046c98ca887c0f8796bce6..0736b5518ba66d570a168a934e821aa122a540e4 100644 --- a/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCreatorTool.cxx +++ b/Reconstruction/MuonIdentification/MuonCombinedBaseTools/src/MuonCreatorTool.cxx @@ -1246,8 +1246,9 @@ namespace MuonCombined { const Trk::MeasurementBase& meas = **mit; std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern(0); typePattern.set(Trk::TrackStateOnSurface::Measurement); - const Trk::TrackParameters* exPars = m_propagator->propagateParameters(*pars,meas.associatedSurface(), - Trk::anyDirection, false, Trk::MagneticFieldProperties(Trk::NoField)); + //TSoS takes ownership + auto exPars = m_propagator->propagateParameters(*pars,meas.associatedSurface(), + Trk::anyDirection, false, Trk::MagneticFieldProperties(Trk::NoField)).release(); if(!exPars){ ATH_MSG_VERBOSE("Could not propagate Track to segment surface"); } diff --git a/Reconstruction/MuonIdentification/MuonSegmentTaggers/MuonSegmentTaggerTools/src/MuTagMatchingTool.cxx b/Reconstruction/MuonIdentification/MuonSegmentTaggers/MuonSegmentTaggerTools/src/MuTagMatchingTool.cxx index ba2889387bcf59201371219a315b9b99c7a27e56..690f3b0b5df8a575c56bf713a6ec7702f6cc4e1c 100644 --- a/Reconstruction/MuonIdentification/MuonSegmentTaggers/MuonSegmentTaggerTools/src/MuTagMatchingTool.cxx +++ b/Reconstruction/MuonIdentification/MuonSegmentTaggers/MuonSegmentTaggerTools/src/MuTagMatchingTool.cxx @@ -877,7 +877,8 @@ MuTagMatchingTool::muTagSegmentInfo(const Trk::Track* track, const Muon::MuonSeg double tubeLen = detEl->getActiveTubeLength(lay, tube); // use SL within station to speed up extrapolation - const Trk::TrackParameters* exP = + //lifetime only in this scope + auto exP = p_propagator->propagate(*exTrack, mdt->associatedSurface(), Trk::anyDirection, false, Trk::NoField); if (!exP) { ATH_MSG_WARNING("Failed to extrapolate to " << m_idHelperSvc->toString(id)); @@ -888,23 +889,24 @@ MuTagMatchingTool::muTagSegmentInfo(const Trk::Track* track, const Muon::MuonSeg double exResidual = std::abs(exP->parameters()[Trk::locZ]) - 0.5 * tubeLen; if (maxResXMdt < exResidual) maxResXMdt = exResidual; if (exResidual > 0.) ATH_MSG_DEBUG("Extrapolated position outside tube, " << exResidual); - delete exP; + //delete exP; } else { // get id and check that it is a muon hit id Identifier id = m_edmHelperSvc->getIdentifier(**mit); if (!id.is_valid() || !m_idHelperSvc->isMuon(id)) continue; if (!m_idHelperSvc->measuresPhi(id)) continue; - const Trk::TrackParameters* exP = + //lifetime only in this scope + auto exP = p_propagator->propagate(*exTrack, (*mit)->associatedSurface(), Trk::anyDirection, false, Trk::NoField); if (!exP) { ATH_MSG_WARNING("Failed to extrapolate to " << m_idHelperSvc->toString(id)); continue; } - const Trk::ResidualPull* resPull = m_pullCalculator->residualPull(*mit, exP, Trk::ResidualPull::Unbiased); + const Trk::ResidualPull* resPull = m_pullCalculator->residualPull(*mit, exP.get(), Trk::ResidualPull::Unbiased); if (!resPull) { ATH_MSG_WARNING(" calculation of residual/pull failed !!!!! "); - delete exP; + //delete exP; continue; } double residual = resPull->residual().front(); @@ -923,7 +925,7 @@ MuTagMatchingTool::muTagSegmentInfo(const Trk::Track* track, const Muon::MuonSeg } ATH_MSG_DEBUG(m_idHelperSvc->toString(id) << " residual " << residual << " pull " << pull); delete resPull; - delete exP; + //delete exP; } } ATH_MSG_DEBUG("Residual phi min " << minResPhi << " max " << maxResPhi << " pull min " << minPullPhi << " max " diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.h index 3e4098af45c61445c4de9adeeb24f35ae3618bbe..6389fb4642c643310b072cd0d0ed5c9f3cd9bd02 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.h @@ -98,6 +98,23 @@ public: double theta, double qop, AmgSymMatrix(5) * cov = nullptr) const override final; + + /** Use the Surface as a ParametersBase constructor, from local parameters - + * charged */ + virtual Surface::ChargedTrackParametersUniquePtr createUniqueTrackParameters( + double l1, + double l2, + double phi, + double theta, + double qop, + AmgSymMatrix(5) * cov = nullptr) const override final; + + virtual Surface::ChargedTrackParametersUniquePtr createUniqueTrackParameters( + const Amg::Vector3D& position, + const Amg::Vector3D& momentum, + double charge, + AmgSymMatrix(5) * cov = nullptr) const override final; + /** Use the Surface as a ParametersBase constructor, from global parameters - * charged*/ diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.icc index 140bd00c53143def72ec5ac24cfd5fde7a816274..2965b98f2b757d2638a04cf777f2f4789c93b846 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/ConeSurface.icc @@ -25,6 +25,31 @@ ConeSurface::createTrackParameters(double l1, l1, l2, phi, theta, qop, *this, cov); } +/** Use the Surface as a ParametersBase constructor, from local parameters - + * charged */ +inline Surface::ChargedTrackParametersUniquePtr +ConeSurface::createUniqueTrackParameters(double l1, + double l2, + double phi, + double theta, + double qop, + AmgSymMatrix(5) * cov) const +{ + return std::make_unique<ParametersT<5, Charged, ConeSurface>>( + l1, l2, phi, theta, qop, *this, cov); +} + +inline Surface::ChargedTrackParametersUniquePtr +ConeSurface::createUniqueTrackParameters( const Amg::Vector3D& position, + const Amg::Vector3D& momentum, + double charge, + AmgSymMatrix(5) * cov) const +{ + return std::make_unique<ParametersT<5, Charged, ConeSurface>>( + position, momentum, charge, *this, cov); +} + + /** Use the Surface as a ParametersBase constructor, from global parameters - * charged*/ inline ParametersT<5, Charged, ConeSurface>* diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.h index 8c9cf5a353e0926deb5eaefc75c1b745e59d6cb8..7787f90d4a147a3cbe9c978568fc851e37c37bd2 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.h @@ -105,6 +105,16 @@ public: /**Implicit Constructor*/ virtual CylinderSurface* clone() const override; + /** Use the Surface as a ParametersBase constructor, from local parameters - + * charged */ + virtual Surface::ChargedTrackParametersUniquePtr createUniqueTrackParameters( + double l1, + double l2, + double phi, + double theta, + double qop, + AmgSymMatrix(5) * cov = nullptr) const override final; + /** Use the Surface as a ParametersBase constructor, from local parameters - * charged */ virtual ParametersT<5, Charged, CylinderSurface>* createTrackParameters( @@ -122,6 +132,12 @@ public: const Amg::Vector3D& momentum, double charge, AmgSymMatrix(5) * cov = nullptr) const override final; + + virtual Surface::ChargedTrackParametersUniquePtr createUniqueTrackParameters( + const Amg::Vector3D& position, + const Amg::Vector3D& momentum, + double charge, + AmgSymMatrix(5) * cov = nullptr) const override final; /** Use the Surface as a ParametersBase constructor, from local parameters - * neutral */ diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.icc index 66eeb816c8a4e8756eb5d8a25e3f61e4bfa17fed..a4d302626cc1d36a75de8371ee845d79d404eba8 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/CylinderSurface.icc @@ -27,6 +27,20 @@ CylinderSurface::createTrackParameters(double l1, l1, l2, phi, theta, qop, *this, cov); } +/** Use the Surface as a ParametersBase constructor, from local parameters - + * charged */ +inline Surface::ChargedTrackParametersUniquePtr +CylinderSurface::createUniqueTrackParameters(double l1, + double l2, + double phi, + double theta, + double qop, + AmgSymMatrix(5) * cov) const +{ + return std::make_unique<ParametersT<5, Charged, CylinderSurface>>( + l1, l2, phi, theta, qop, *this, cov); +} + /** Use the Surface as a ParametersBase constructor, from global parameters - * charged*/ inline ParametersT<5, Charged, CylinderSurface>* @@ -39,6 +53,18 @@ CylinderSurface::createTrackParameters(const Amg::Vector3D& position, position, momentum, charge, *this, cov); } +/** Use the Surface as a ParametersBase constructor, from global parameters - + * charged*/ +inline Surface::ChargedTrackParametersUniquePtr +CylinderSurface::createUniqueTrackParameters(const Amg::Vector3D& position, + const Amg::Vector3D& momentum, + double charge, + AmgSymMatrix(5) * cov) const +{ + return std::make_unique<ParametersT<5, Charged, CylinderSurface>>( + position, momentum, charge, *this, cov); +} + /** Use the Surface as a ParametersBase constructor, from local parameters - * neutral */ inline ParametersT<5, Neutral, CylinderSurface>* diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.h index 67830a4e4a25b93a5e95b317c03de36719983765..5bf415cfdd8ed12b4d078e6280295ff72cae30fe 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.h @@ -115,6 +115,22 @@ public: double theta, double qop, AmgSymMatrix(5) * cov = nullptr) const override final; + +/** Use the Surface as a ParametersBase constructor, from local parameters - + * charged */ + virtual Surface::ChargedTrackParametersUniquePtr createUniqueTrackParameters( + double l1, + double l2, + double phi, + double theta, + double qop, + AmgSymMatrix(5) * cov = nullptr) const override final; + + virtual Surface::ChargedTrackParametersUniquePtr createUniqueTrackParameters( + const Amg::Vector3D& position, + const Amg::Vector3D& momentum, + double charge, + AmgSymMatrix(5) * cov = nullptr) const override final; /** Use the Surface as a ParametersBase constructor, from global parameters - * charged*/ diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.icc index b20240a2e5e59f9bff6e573cff454bf8b7c09fab..a5aaede361a2243934cfdbbeb63e45b872dfa2d9 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/DiscSurface.icc @@ -24,6 +24,31 @@ DiscSurface::createTrackParameters(double l1, l1, l2, phi, theta, qop, *this, cov); } +/* Use the Surface as a ParametersBase constructor, from local parameters - + * charged */ +inline Surface::ChargedTrackParametersUniquePtr +DiscSurface::createUniqueTrackParameters(double l1, + double l2, + double phi, + double theta, + double qop, + AmgSymMatrix(5) * cov) const +{ + return std::make_unique<ParametersT<5, Charged, DiscSurface>>( + l1, l2, phi, theta, qop, *this, cov); +} + +inline Surface::ChargedTrackParametersUniquePtr +DiscSurface::createUniqueTrackParameters(const Amg::Vector3D& position, + const Amg::Vector3D& momentum, + double charge, + AmgSymMatrix(5) * cov) const +{ + return std::make_unique<ParametersT<5, Charged, DiscSurface>>( + position, momentum, charge, *this, cov); +} + + /** Use the Surface as a ParametersBase constructor, from global parameters - * charged*/ inline ParametersT<5, Charged, DiscSurface>* diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h index c90d4c5dccbea1353b2cae25ccd59e69bf1d572e..128dec0091146efbedf98c3f9252b0136dc0d40d 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h @@ -83,6 +83,22 @@ public: double theta, double qop, AmgSymMatrix(5) * cov = nullptr) const override final; + + /** Use the Surface as a ParametersBase constructor, from local parameters - + * charged */ + virtual Surface::ChargedTrackParametersUniquePtr createUniqueTrackParameters( + double l1, + double l2, + double phi, + double theta, + double qop, + AmgSymMatrix(5) * cov = nullptr) const override final; + + virtual Surface::ChargedTrackParametersUniquePtr createUniqueTrackParameters( + const Amg::Vector3D& position, + const Amg::Vector3D& momentum, + double charge, + AmgSymMatrix(5) * cov = nullptr) const override final; /** Use the Surface as a ParametersBase constructor, from global parameters - * charged*/ diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc index 30a2820762ab3e8a92cae38fe8a1c4708b2d4d8c..8f9071b99f552249d2391a586e9429a693d60227 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc @@ -17,6 +17,31 @@ PerigeeSurface::createTrackParameters(double l1, l1, l2, phi, theta, qop, *this, cov); } +/** Use the Surface as a ParametersBase constructor, from local parameters - + * charged */ +inline Surface::ChargedTrackParametersUniquePtr +PerigeeSurface::createUniqueTrackParameters(double l1, + double l2, + double phi, + double theta, + double qop, + AmgSymMatrix(5) * cov) const +{ + return std::make_unique<ParametersT<5, Charged, PerigeeSurface>>( + l1, l2, phi, theta, qop, *this, cov); +} + +inline Surface::ChargedTrackParametersUniquePtr +PerigeeSurface::createUniqueTrackParameters(const Amg::Vector3D& position, + const Amg::Vector3D& momentum, + double charge, + AmgSymMatrix(5) * cov) const +{ + return std::make_unique<ParametersT<5, Charged, PerigeeSurface>>( + position, momentum, charge, *this, cov); +} + + /** Use the Surface as a ParametersBase constructor, from global parameters - * charged*/ inline ParametersT<5, Charged, PerigeeSurface>* diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.h index 3ccd6cf2d7e752f5cb764d6a04ec777409074c2a..ab1239679fb9f89755998f96dea721872a8c8cb5 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.h @@ -156,6 +156,22 @@ public: double theta, double qop, AmgSymMatrix(5) * cov = nullptr) const override final; + + /** Use the Surface as a ParametersBase constructor, from local parameters - + * charged */ + virtual Surface::ChargedTrackParametersUniquePtr createUniqueTrackParameters( + double l1, + double l2, + double phi, + double theta, + double qop, + AmgSymMatrix(5) * cov = nullptr) const override final; + + virtual Surface::ChargedTrackParametersUniquePtr createUniqueTrackParameters( + const Amg::Vector3D& position, + const Amg::Vector3D& momentum, + double charge, + AmgSymMatrix(5) * cov = nullptr) const override final; /** Use the Surface as a ParametersBase constructor, from global parameters - * charged*/ diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.icc index c93b4bfd659324b9acce7a1073fded282b0f51dd..59160d3e374e6dccee5ab8ef1cbaf9ec1141992b 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PlaneSurface.icc @@ -24,6 +24,30 @@ PlaneSurface::createTrackParameters(double l1, l1, l2, phi, theta, qop, *this, cov); } +/** Use the Surface as a ParametersBase constructor, from local parameters - + * charged */ +inline Surface::ChargedTrackParametersUniquePtr +PlaneSurface::createUniqueTrackParameters(double l1, + double l2, + double phi, + double theta, + double qop, + AmgSymMatrix(5) * cov) const +{ + return std::make_unique<ParametersT<5, Charged, PlaneSurface>>( + l1, l2, phi, theta, qop, *this, cov); +} + +inline Surface::ChargedTrackParametersUniquePtr +PlaneSurface::createUniqueTrackParameters(const Amg::Vector3D& position, + const Amg::Vector3D& momentum, + double charge, + AmgSymMatrix(5) * cov) const +{ + return std::make_unique<ParametersT<5, Charged, PlaneSurface>>( + position, momentum, charge, *this, cov); +} + /** Use the Surface as a ParametersBase constructor, from global parameters - * charged*/ inline ParametersT<5, Charged, PlaneSurface>* diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h index a5af92b95e73fe008ec00ca647de3c7c3e3da9e5..4d97f9524b69510ec7d85b1f38bc941d9f0b8cfb 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h @@ -91,6 +91,22 @@ public: double theta, double qop, AmgSymMatrix(5) * cov = nullptr) const override final; + + /** Use the Surface as a ParametersBase constructor, from local parameters - + * charged */ + virtual Surface::ChargedTrackParametersUniquePtr createUniqueTrackParameters( + double l1, + double l2, + double phi, + double theta, + double qop, + AmgSymMatrix(5) * cov = nullptr) const override final; + + virtual Surface::ChargedTrackParametersUniquePtr createUniqueTrackParameters( + const Amg::Vector3D& position, + const Amg::Vector3D& momentum, + double charge, + AmgSymMatrix(5) * cov = nullptr) const override final; /** Use the Surface as a ParametersBase constructor, from global parameters - * charged*/ diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc index 3eefcf7f203a3615fb7e54d974992398e847dc79..0611a2c0990f56d83527659efb675e68f2828209 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc @@ -24,6 +24,30 @@ StraightLineSurface::createTrackParameters(double l1, l1, l2, phi, theta, qop, *this, cov); } +/** Use the Surface as a ParametersBase constructor, from local parameters - + * charged */ +inline Surface::ChargedTrackParametersUniquePtr +StraightLineSurface::createUniqueTrackParameters(double l1, + double l2, + double phi, + double theta, + double qop, + AmgSymMatrix(5) * cov) const +{ + return std::make_unique<ParametersT<5, Charged, StraightLineSurface>>( + l1, l2, phi, theta, qop, *this, cov); +} + +inline Surface::ChargedTrackParametersUniquePtr +StraightLineSurface::createUniqueTrackParameters(const Amg::Vector3D& position, + const Amg::Vector3D& momentum, + double charge, + AmgSymMatrix(5) * cov) const +{ + return std::make_unique<ParametersT<5, Charged, StraightLineSurface>>( + position, momentum, charge, *this, cov); +} + /** Use the Surface as a ParametersBase constructor, from global parameters - * charged*/ inline ParametersT<5, Charged, StraightLineSurface>* diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h index 11d4b9173f6a95d1e0f91337cdb4eca8c21642be..a82b25fad19efa4ec09939a5078953e7498f7da6 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h @@ -33,6 +33,7 @@ #include "CxxUtils/CachedUniquePtr.h" #include "CxxUtils/checker_macros.h" #include <atomic> +#include <memory> //for unique_ptr class MsgStream; class SurfaceCnv_p1; @@ -95,6 +96,10 @@ public: Curvilinear = 6, Other = 7 }; + + /** Unique ptr types**/ + using ChargedTrackParametersUniquePtr = std::unique_ptr<ParametersBase<5, Trk::Charged>>; + using NeutralTrackParametersUniquePtr = std::unique_ptr<ParametersBase<5, Trk::Neutral>>; /**Default Constructor - needed for inherited classes */ @@ -189,6 +194,19 @@ public: double, double, AmgSymMatrix(5) * cov = nullptr) const = 0; + + + /** Use the Surface as a ParametersBase constructor, from local parameters - + * charged. The caller assumes ownership of the returned ptr. + */ + virtual ChargedTrackParametersUniquePtr createUniqueTrackParameters( + double, + double, + double, + double, + double, + AmgSymMatrix(5) * cov = nullptr) const = 0; + /** Use the Surface as a ParametersBase constructor, from global parameters - * charged The caller assumes ownership of the returned ptr @@ -198,6 +216,15 @@ public: const Amg::Vector3D&, double, AmgSymMatrix(5) * cov = nullptr) const = 0; + + /** Use the Surface as a ParametersBase constructor, from global parameters - + * charged The caller assumes ownership of the returned ptr + */ + virtual ChargedTrackParametersUniquePtr createUniqueTrackParameters( + const Amg::Vector3D&, + const Amg::Vector3D&, + double, + AmgSymMatrix(5) * cov = nullptr) const = 0; /** Use the Surface as a ParametersBase constructor, from local parameters - * neutral. The caller assumes ownership of the returned ptr diff --git a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.h b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.h index 82111f7af2287b83bc347f99b32847fbed030ddb..5aed1d0930143ac9e1744743ee80585c8991b083 100644 --- a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.h +++ b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.h @@ -117,6 +117,7 @@ public: /** Virtual clone */ virtual CurvilinearParametersT<DIM, T, S>* clone() const override final; + /** Return the ParametersType enum */ virtual ParametersType type() const override final; diff --git a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.icc b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.icc index 0bef24bdb4dbbe0846c7180101a8e245217bb9f7..9eb13e9bdd654d4b4a874452c458df2bb7203b51 100644 --- a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.icc +++ b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.icc @@ -252,6 +252,8 @@ CurvilinearParametersT<DIM, T, S>::operator==( // return compatibility of base class parts return ParametersBase<DIM, T>::operator==(rhs); } + + /** clone */ template<int DIM, class T, class S> CurvilinearParametersT<DIM, T, S>* diff --git a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersBase.h b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersBase.h index 2988e0fce85fc7cd950a6d767093f858f65781ed..11d0d0f61633694c424e639a9505406fc8aaa460 100644 --- a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersBase.h +++ b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersBase.h @@ -151,7 +151,8 @@ public: /** clone method for polymorphic deep copy @return new object copied from the concrete type of this object.*/ virtual ParametersBase<DIM, T>* clone() const = 0; - + + /** Return the ParametersType enum */ virtual ParametersType type() const = 0; diff --git a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.h b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.h index 6f0b97f87295e6a2a0de74b4a01426efebf12152..fb0510061dddb34f84aa37148d837e9b77a0805b 100644 --- a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.h +++ b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.h @@ -129,6 +129,7 @@ public: /** Virtual clone */ virtual ParametersT<DIM, T, S>* clone() const override final; + /** Return the ParametersType enum */ virtual ParametersType type() const override final; diff --git a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.icc b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.icc index 7a4dae0911bdf2d921a763a1d47a1fbb6031e1f6..4bf1111079a51d8542c8fdbd38d59cf6951da6e5 100644 --- a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.icc +++ b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.icc @@ -262,6 +262,8 @@ ParametersT<DIM, T, S>::clone() const return new ParametersT<DIM, T, S>(*this); } + + /** Return the ParametersType enum */ template<int DIM, class T, class S> ParametersType diff --git a/Tracking/TrkEventCnv/TrkEventCnvTools/TrkEventCnvTools/DetElementSurface.h b/Tracking/TrkEventCnv/TrkEventCnvTools/TrkEventCnvTools/DetElementSurface.h index 28f01753e4e6cb924f8a819d178c10a2b27478fc..1a9e5c49aa7728b8ff1aa65853c66d274933de2a 100644 --- a/Tracking/TrkEventCnv/TrkEventCnvTools/TrkEventCnvTools/DetElementSurface.h +++ b/Tracking/TrkEventCnv/TrkEventCnvTools/TrkEventCnvTools/DetElementSurface.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef TRKEVENTCNVTOOLS_DETELEMENTSURFACE_H @@ -54,6 +54,9 @@ class DetElementSurface : public Surface // A dummy method required for consistency of the package and virtual ParametersBase<5, Trk::Charged>* createTrackParameters(double, double, double, double, double, AmgSymMatrix(5)*) const {return nullptr;} virtual ParametersBase<5, Trk::Charged>* createTrackParameters(const Amg::Vector3D&, const Amg::Vector3D&, double, AmgSymMatrix(5)*) const {return nullptr;} + virtual std::unique_ptr<ParametersBase<5, Trk::Charged>> createUniqueTrackParameters(double, double, double, double, double, AmgSymMatrix(5)*) const {return nullptr;} + virtual std::unique_ptr<ParametersBase<5, Trk::Charged>> createUniqueTrackParameters(const Amg::Vector3D&, const Amg::Vector3D&, double, AmgSymMatrix(5)*) const {return nullptr;} + virtual ParametersBase<5, Trk::Neutral>* createNeutralParameters(double, double, double, double, double, AmgSymMatrix(5)*) const {return nullptr;} virtual ParametersBase<5, Trk::Neutral>* createNeutralParameters(const Amg::Vector3D&, const Amg::Vector3D&, double, AmgSymMatrix(5)*) const {return nullptr;} diff --git a/Tracking/TrkEventCnv/TrkEventTPCnv/test/SurfaceCnv_p2_test.cxx b/Tracking/TrkEventCnv/TrkEventTPCnv/test/SurfaceCnv_p2_test.cxx index 183ea2420cb851c7948e46cbfddded4fe6d1103a..f78116eddfc8486721b99d0f3feef5c5999ce284 100644 --- a/Tracking/TrkEventCnv/TrkEventTPCnv/test/SurfaceCnv_p2_test.cxx +++ b/Tracking/TrkEventCnv/TrkEventTPCnv/test/SurfaceCnv_p2_test.cxx @@ -138,6 +138,7 @@ Identifier TestElement::identify() const void compare (const Trk::Surface& s1, const Trk::Surface& s2) { + //std::cout<<s1.name()<<" == "<<s2.name()<<"\n"; assert (s1.name() == s2.name()); assert (s1.isFree() == s2.isFree()); if (s1.isFree()) { diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorTest.cxx b/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorTest.cxx index 3fead037c0706dcd7f4501b3c1506dc6ee5d93d4..2fd30873492ec5139dc0f1bdd625d2adf6ad75e8 100755 --- a/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorTest.cxx +++ b/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorTest.cxx @@ -202,7 +202,7 @@ void Trk::ExtrapolatorTest::runTest( const Trk::Perigee& initialPerigee ) { const Trk::Surface* destinationSurface = (*surfaceTripleIter)[refSurface]; - const Trk::TrackParameters* destParameters = m_useExtrapolator ? + auto destParameters = m_useExtrapolator ? m_extrapolator->extrapolate(initialPerigee, *destinationSurface, propagationDirection, @@ -213,7 +213,7 @@ void Trk::ExtrapolatorTest::runTest( const Trk::Perigee& initialPerigee ) { propagationDirection, false, *m_magFieldProperties, - (Trk::ParticleHypothesis)m_particleType); + (Trk::ParticleHypothesis)m_particleType).release(); if (destParameters) { // global position parameter @@ -224,8 +224,7 @@ void Trk::ExtrapolatorTest::runTest( const Trk::Perigee& initialPerigee ) { } else if (!destParameters) ATH_MSG_DEBUG(" Extrapolation not successful! " ); - - delete destParameters; + delete destParameters; } } diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/src/RiddersAlgorithm.cxx b/Tracking/TrkExtrapolation/TrkExAlgs/src/RiddersAlgorithm.cxx index d72940c3b7d77558633a897d114aead4e7a57ef6..6d5916c6f66a546f5076baf7e00869b5e3016200 100755 --- a/Tracking/TrkExtrapolation/TrkExAlgs/src/RiddersAlgorithm.cxx +++ b/Tracking/TrkExtrapolation/TrkExAlgs/src/RiddersAlgorithm.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -302,7 +302,7 @@ StatusCode Trk::RiddersAlgorithm::execute() ATH_MSG_VERBOSE( "Cylinder to be intersected : " << estimationCylinder ); - const Trk::TrackParameters* estimationParameters = m_propagator->propagateParameters(startParameters, + auto estimationParameters = m_propagator->propagateParameters(startParameters, estimationCylinder, Trk::alongMomentum, false, @@ -353,7 +353,6 @@ StatusCode Trk::RiddersAlgorithm::execute() rotateTrans); // cleanup for memory reasons - delete estimationParameters; estimationParameters = 0; Trk::PlaneSurface destinationSurface(surfaceTransform,10e5 , 10e5); @@ -364,7 +363,7 @@ StatusCode Trk::RiddersAlgorithm::execute() Trk::TransportJacobian currentStepJacobian(testMatrix); double pathLimit = -1.; - const Trk::TrackParameters* trackParameters = m_propagator->propagate(startParameters, + auto trackParameters = m_propagator->propagate(startParameters, destinationSurface, Trk::alongMomentum, false, @@ -442,62 +441,62 @@ StatusCode Trk::RiddersAlgorithm::execute() Trk::AtaPlane startQopPlus(loc1,loc2,phi,theta,qOverP+m_qOpVariations[istep],startSurface); // the propagations --- 10 times - const Trk::TrackParameters* endLoc1Minus = m_propagator->propagateParameters(startLoc1Minus, + auto endLoc1Minus = m_propagator->propagateParameters(startLoc1Minus, destinationSurface, Trk::alongMomentum, false, *m_magFieldProperties); - const Trk::TrackParameters* endLoc1Plus = m_propagator->propagateParameters(startLoc1Plus, + auto endLoc1Plus = m_propagator->propagateParameters(startLoc1Plus, destinationSurface, Trk::alongMomentum, false, *m_magFieldProperties); - const Trk::TrackParameters* endLoc2Minus = m_propagator->propagateParameters(startLoc2Minus, + auto endLoc2Minus = m_propagator->propagateParameters(startLoc2Minus, destinationSurface, Trk::alongMomentum, false, *m_magFieldProperties); - const Trk::TrackParameters* endLoc2Plus = m_propagator->propagateParameters(startLoc2Plus, + auto endLoc2Plus = m_propagator->propagateParameters(startLoc2Plus, destinationSurface, Trk::alongMomentum, false, *m_magFieldProperties); - const Trk::TrackParameters* endPhiMinus = m_propagator->propagateParameters(startPhiMinus, + auto endPhiMinus = m_propagator->propagateParameters(startPhiMinus, destinationSurface, Trk::alongMomentum, false, *m_magFieldProperties); - const Trk::TrackParameters* endPhiPlus = m_propagator->propagateParameters(startPhiPlus, + auto endPhiPlus = m_propagator->propagateParameters(startPhiPlus, destinationSurface, Trk::alongMomentum, false, *m_magFieldProperties); - const Trk::TrackParameters* endThetaMinus = m_propagator->propagateParameters(startThetaMinus, + auto endThetaMinus = m_propagator->propagateParameters(startThetaMinus, destinationSurface, Trk::alongMomentum, false, *m_magFieldProperties); - const Trk::TrackParameters* endThetaPlus = m_propagator->propagateParameters(startThetaPlus, + auto endThetaPlus = m_propagator->propagateParameters(startThetaPlus, destinationSurface, Trk::alongMomentum, false, *m_magFieldProperties); - const Trk::TrackParameters* endQopMinus = m_propagator->propagateParameters(startQopMinus, + auto endQopMinus = m_propagator->propagateParameters(startQopMinus, destinationSurface, Trk::alongMomentum, false, *m_magFieldProperties); - const Trk::TrackParameters* endQopPlus = m_propagator->propagateParameters(startQopPlus, + auto endQopPlus = m_propagator->propagateParameters(startQopPlus, destinationSurface, Trk::alongMomentum, false, @@ -605,18 +604,6 @@ StatusCode Trk::RiddersAlgorithm::execute() ++recStep; } - - delete endLoc1Minus; endLoc1Minus = 0; - delete endLoc1Plus; endLoc1Plus = 0; - delete endLoc2Minus; endLoc2Minus = 0; - delete endLoc2Plus; endLoc2Plus = 0; - delete endPhiMinus; endPhiMinus = 0; - delete endPhiPlus; endPhiPlus = 0; - delete endThetaMinus; endThetaMinus = 0; - delete endThetaPlus; endThetaPlus = 0; - delete endQopMinus; endQopMinus = 0; - delete endQopPlus; endQopPlus = 0; - } // ------------------------------------------------------------------------------- @@ -889,7 +876,7 @@ StatusCode Trk::RiddersAlgorithm::execute() } // memory cleanup - delete trackParameters; + //delete trackParameters; delete transportJacobian; // Code entered here will be executed once per event diff --git a/Tracking/TrkExtrapolation/TrkExEngine/src/PropagationEngine.cxx b/Tracking/TrkExtrapolation/TrkExEngine/src/PropagationEngine.cxx index 8e5f8305513a4819b5027afe302a32c2a24d815d..4cfa77cc606732d88a8149edcfb4f8c0d515e16b 100644 --- a/Tracking/TrkExtrapolation/TrkExEngine/src/PropagationEngine.cxx +++ b/Tracking/TrkExtrapolation/TrkExEngine/src/PropagationEngine.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -77,15 +77,16 @@ Trk::ExtrapolationCode Trk::PropagationEngine::propagate(Trk::ExCellCharged& eCe Trk::TransportJacobian* tjac = 0; // we need to first fill the propagation parameters in order to be able to updates & fallbacks - const Trk::TrackParameters* pParameters = m_propagator->propagate(*eCell.leadParameters, - sf, - pDir, - bcheck, - eCell.mFieldMode, - tjac, - propLength, - eCell.pHypothesis, - returnCurvilinear); + //release, otherwise need to change the Trk::ExCell code + auto pParameters = m_propagator->propagate(*eCell.leadParameters, + sf, + pDir, + bcheck, + eCell.mFieldMode, + tjac, + propLength, + eCell.pHypothesis, + returnCurvilinear).release(); // set the return type according to how the propagation went if (pParameters){ // cache the last lead parameters, useful in case a navigation error occured diff --git a/Tracking/TrkExtrapolation/TrkExInterfaces/TrkExInterfaces/IPropagator.h b/Tracking/TrkExtrapolation/TrkExInterfaces/TrkExInterfaces/IPropagator.h index 3c7ffea841275bf1047bf332065ddb59ac2dd0b2..dca481680faf13935ffb9a6fdbcd456ed1259be4 100755 --- a/Tracking/TrkExtrapolation/TrkExInterfaces/TrkExInterfaces/IPropagator.h +++ b/Tracking/TrkExtrapolation/TrkExInterfaces/TrkExInterfaces/IPropagator.h @@ -99,7 +99,7 @@ public: The propagation method called by the TrkExtrapolator. The extrapolator is responsible for the underlying logic of which surface to go to. */ - virtual TrackParameters* propagate( + virtual std::unique_ptr<TrackParameters> propagate( const EventContext& ctx, const TrackParameters& parm, const Surface& sf, @@ -115,7 +115,7 @@ public: The propagation method called by the TrkExtrapolator. The propagator finds the closest surface. */ - virtual TrackParameters* propagate( + virtual std::unique_ptr<TrackParameters> propagate( const EventContext& ctx, const TrackParameters& parm, std::vector<DestSurf>& sfs, @@ -133,7 +133,7 @@ public: The propagation method called by the TrkExtrapolator. The propagator finds the closest surface. Timing included. */ - virtual TrackParameters* propagateT( + virtual std::unique_ptr<TrackParameters> propagateT( const EventContext& ctx, const TrackParameters& parm, std::vector<DestSurf>& sfs, @@ -152,7 +152,7 @@ public: The propagation method called by the TrkExtrapolator. The propagator finds the closest surface. Timing included. */ - virtual TrackParameters* propagateT( + virtual std::unique_ptr<TrackParameters> propagateT( const EventContext& ctx, const TrackParameters& parm, TargetSurfaces& sfs, @@ -179,7 +179,7 @@ public: The propagation method with internal material collection. The propagator finds the closest surface. */ - virtual TrackParameters* propagateM( + virtual std::unique_ptr<TrackParameters> propagateM( const EventContext& ctx, const TrackParameters& parm, std::vector<DestSurf>& sfs, @@ -200,7 +200,7 @@ public: The propagation method including the return of the TransportJacobian matrix. */ - virtual TrackParameters* propagate( + virtual std::unique_ptr<TrackParameters> propagate( const EventContext& ctx, const TrackParameters& parm, const Surface& sf, @@ -217,7 +217,7 @@ public: the pathlength has to be returned for eventual following propagateCovariance */ - virtual TrackParameters* propagateParameters( + virtual std::unique_ptr<TrackParameters> propagateParameters( const EventContext& ctx, const TrackParameters& parm, const Surface& sf, @@ -228,7 +228,7 @@ public: bool returnCurv = false, const TrackingVolume* tVol = nullptr) const = 0; - virtual TrackParameters* propagateParameters( + virtual std::unique_ptr<TrackParameters> propagateParameters( const EventContext& ctx, const TrackParameters& parm, const Surface& sf, @@ -307,7 +307,7 @@ public: The propagation method called by the TrkExtrapolator. The extrapolator is responsible for the underlying logic of which surface to go to. */ - TrackParameters* propagate(const TrackParameters& parm, + std::unique_ptr<TrackParameters> propagate(const TrackParameters& parm, const Surface& sf, PropDirection dir, const BoundaryCheck& bcheck, @@ -321,7 +321,7 @@ public: The propagation method called by the TrkExtrapolator. The propagator finds the closest surface. */ - TrackParameters* propagate(const TrackParameters& parm, + std::unique_ptr<TrackParameters> propagate(const TrackParameters& parm, std::vector<DestSurf>& sfs, PropDirection dir, const MagneticFieldProperties& mprop, @@ -337,7 +337,7 @@ public: The propagation method called by the TrkExtrapolator. The propagator finds the closest surface. Timing included. */ - TrackParameters* propagateT(const TrackParameters& parm, + std::unique_ptr<TrackParameters> propagateT(const TrackParameters& parm, std::vector<DestSurf>& sfs, PropDirection dir, const MagneticFieldProperties& mprop, @@ -355,7 +355,7 @@ public: finds the closest surface. Timing included. */ - TrackParameters* propagateT(const TrackParameters& parm, + std::unique_ptr<TrackParameters> propagateT(const TrackParameters& parm, TargetSurfaces& sfs, PropDirection dir, const MagneticFieldProperties& mprop, @@ -378,7 +378,7 @@ public: The propagation method with internal material collection. The propagator finds the closest surface. */ - TrackParameters* propagateM( + std::unique_ptr<TrackParameters> propagateM( const TrackParameters& parm, std::vector<DestSurf>& sfs, PropDirection dir, @@ -398,7 +398,7 @@ public: The propagation method including the return of the TransportJacobian matrix. */ - TrackParameters* propagate(const TrackParameters& parm, + std::unique_ptr<TrackParameters> propagate(const TrackParameters& parm, const Surface& sf, PropDirection dir, const BoundaryCheck& bcheck, @@ -412,7 +412,7 @@ public: /** Propagation interface without Covariance matrix propagation the pathlength has to be returned for eventual following propagateCovariance */ - TrackParameters* propagateParameters( + std::unique_ptr<TrackParameters> propagateParameters( const TrackParameters& parm, const Surface& sf, PropDirection dir, @@ -422,7 +422,7 @@ public: bool returnCurv = false, const TrackingVolume* tVol = nullptr) const; - TrackParameters* propagateParameters( + std::unique_ptr<TrackParameters> propagateParameters( const TrackParameters& parm, const Surface& sf, PropDirection dir, diff --git a/Tracking/TrkExtrapolation/TrkExInterfaces/TrkExInterfaces/IPropagator.icc b/Tracking/TrkExtrapolation/TrkExInterfaces/TrkExInterfaces/IPropagator.icc index 4c205fd3d29a8181528d30ae5851cfa0e158968a..8a039ca70512e98c051e9d0ddad505904c60c210 100644 --- a/Tracking/TrkExtrapolation/TrkExInterfaces/TrkExInterfaces/IPropagator.icc +++ b/Tracking/TrkExtrapolation/TrkExInterfaces/TrkExInterfaces/IPropagator.icc @@ -11,7 +11,7 @@ * We need to check the design for * these. */ -inline Trk::TrackParameters* +inline std::unique_ptr<Trk::TrackParameters> Trk::IPropagator::propagate(const EventContext&, const TrackParameters&, std::vector<DestSurf>&, @@ -27,7 +27,7 @@ Trk::IPropagator::propagate(const EventContext&, return nullptr; } -inline Trk::TrackParameters* +inline std::unique_ptr<Trk::TrackParameters> Trk::IPropagator::propagateT(const EventContext&, const TrackParameters&, std::vector<DestSurf>&, @@ -44,7 +44,7 @@ Trk::IPropagator::propagateT(const EventContext&, return nullptr; } -inline Trk::TrackParameters* +inline std::unique_ptr<Trk::TrackParameters> Trk::IPropagator::propagateT(const EventContext&, const TrackParameters&, Trk::TargetSurfaces&, @@ -69,7 +69,7 @@ Trk::IPropagator::propagate(const EventContext&, return Trk::ExtrapolationCode::FailureConfiguration; } -inline Trk::TrackParameters* +inline std::unique_ptr<Trk::TrackParameters> Trk::IPropagator::propagateM( const EventContext&, const TrackParameters&, @@ -120,7 +120,7 @@ Trk::IPropagator::propagateStep(const EventContext&, // Propagation interface: // The propagation method called by the TrkExtrapolator. The extrapolator // is responsible for the underlying logic of which surface to go to. -inline Trk::TrackParameters* +inline std::unique_ptr<Trk::TrackParameters> Trk::IPropagator::propagate(const Trk::TrackParameters& parm, const Trk::Surface& sf, Trk::PropDirection dir, @@ -145,7 +145,7 @@ Trk::IPropagator::propagate(const Trk::TrackParameters& parm, The propagation method called by the TrkExtrapolator. The propagator finds the closest surface. */ -inline Trk::TrackParameters* +inline std::unique_ptr<Trk::TrackParameters> Trk::IPropagator::propagate(const Trk::TrackParameters& parm, std::vector<Trk::DestSurf>& sfs, Trk::PropDirection dir, @@ -175,7 +175,7 @@ Trk::IPropagator::propagate(const Trk::TrackParameters& parm, The propagation method called by the TrkExtrapolator. The propagator finds the closest surface. Timing included. */ -inline Trk::TrackParameters* +inline std::unique_ptr<Trk::TrackParameters> Trk::IPropagator::propagateT(const Trk::TrackParameters& parm, std::vector<Trk::DestSurf>& sfs, Trk::PropDirection dir, @@ -207,7 +207,7 @@ Trk::IPropagator::propagateT(const Trk::TrackParameters& parm, The propagation method called by the TrkExtrapolator. The propagator finds the closest surface. Timing included. */ -inline Trk::TrackParameters* +inline std::unique_ptr<Trk::TrackParameters> Trk::IPropagator::propagateT(const Trk::TrackParameters& parm, Trk::TargetSurfaces& sfs, Trk::PropDirection dir, @@ -247,7 +247,7 @@ Trk::IPropagator::propagate(Trk::ExCellCharged& eCell, The propagation method with internal material collection. The propagator finds the closest surface. */ -inline Trk::TrackParameters* +inline std::unique_ptr<Trk::TrackParameters> Trk::IPropagator::propagateM( const Trk::TrackParameters& parm, std::vector<Trk::DestSurf>& sfs, @@ -282,7 +282,7 @@ Trk::IPropagator::propagateM( /** Propagation interface: The propagation method including the return of the TransportJacobian matrix. */ -inline Trk::TrackParameters* +inline std::unique_ptr<Trk::TrackParameters> Trk::IPropagator::propagate(const Trk::TrackParameters& parm, const Trk::Surface& sf, Trk::PropDirection dir, @@ -310,7 +310,7 @@ Trk::IPropagator::propagate(const Trk::TrackParameters& parm, /** Propagation interface without Covariance matrix propagation the pathlength has to be returned for eventual following propagateCovariance */ -inline Trk::TrackParameters* +inline std::unique_ptr<Trk::TrackParameters> Trk::IPropagator::propagateParameters(const Trk::TrackParameters& parm, const Trk::Surface& sf, Trk::PropDirection dir, @@ -331,7 +331,7 @@ Trk::IPropagator::propagateParameters(const Trk::TrackParameters& parm, tVol); } -inline Trk::TrackParameters* +inline std::unique_ptr<Trk::TrackParameters> Trk::IPropagator::propagateParameters(const Trk::TrackParameters& parm, const Trk::Surface& sf, Trk::PropDirection dir, diff --git a/Tracking/TrkExtrapolation/TrkExRungeKuttaIntersector/TrkExRungeKuttaIntersector/IntersectorWrapper.h b/Tracking/TrkExtrapolation/TrkExRungeKuttaIntersector/TrkExRungeKuttaIntersector/IntersectorWrapper.h index 21d49044c66425ebb94244d638c8cbb49c77167f..690d3aa6121552503af85ca0a6be9ebbad1f2fe8 100755 --- a/Tracking/TrkExtrapolation/TrkExRungeKuttaIntersector/TrkExRungeKuttaIntersector/IntersectorWrapper.h +++ b/Tracking/TrkExtrapolation/TrkExRungeKuttaIntersector/TrkExRungeKuttaIntersector/IntersectorWrapper.h @@ -57,15 +57,16 @@ class IntersectorWrapper final: public AthAlgTool, is responsible for the underlying logic of which surface to go to. */ /// implemented - virtual TrackParameters* propagate( const EventContext& ctx, - const TrackParameters& parm, - const Surface& sf, - PropDirection dir, - const BoundaryCheck& bcheck, - const MagneticFieldProperties& mprop, - ParticleHypothesis particle, - bool returnCurv, - const TrackingVolume*) const override final; + virtual std::unique_ptr<TrackParameters> + propagate( const EventContext& ctx, + const TrackParameters& parm, + const Surface& sf, + PropDirection dir, + const BoundaryCheck& bcheck, + const MagneticFieldProperties& mprop, + ParticleHypothesis particle, + bool returnCurv, + const TrackingVolume*) const override final; /** Propagation interface: @@ -73,34 +74,36 @@ class IntersectorWrapper final: public AthAlgTool, The propagation method called by the TrkExtrapolator. The propagator finds the closest surface. */ - virtual TrackParameters* propagate( const EventContext&, - const TrackParameters&, - std::vector<DestSurf>&, - PropDirection, - const MagneticFieldProperties&, - ParticleHypothesis, - std::vector<unsigned int>&, - double&, - bool, - bool, - const TrackingVolume*) const override{ return 0; } + virtual std::unique_ptr<TrackParameters> + propagate( const EventContext&, + const TrackParameters&, + std::vector<DestSurf>&, + PropDirection, + const MagneticFieldProperties&, + ParticleHypothesis, + std::vector<unsigned int>&, + double&, + bool, + bool, + const TrackingVolume*) const override{ return 0; } /** Propagation interface: The propagation method called by the TrkExtrapolator. The propagator finds the closest surface. Timing included. */ - virtual TrackParameters* propagateT( const EventContext&, - const TrackParameters&, - std::vector<DestSurf>&, - PropDirection, - const MagneticFieldProperties&, - ParticleHypothesis, - std::vector<unsigned int>&, - PathLimit&, TimeLimit&, - bool, - const TrackingVolume*, - std::vector<Trk::HitInfo>*&) const override{ return 0; } + virtual std::unique_ptr<TrackParameters> + propagateT( const EventContext&, + const TrackParameters&, + std::vector<DestSurf>&, + PropDirection, + const MagneticFieldProperties&, + ParticleHypothesis, + std::vector<unsigned int>&, + PathLimit&, TimeLimit&, + bool, + const TrackingVolume*, + std::vector<Trk::HitInfo>*&) const override{ return 0; } /** Propagation interface: @@ -109,35 +112,38 @@ class IntersectorWrapper final: public AthAlgTool, */ /// implemented - virtual TrackParameters* propagate( const EventContext& ctx, - const TrackParameters&, - const Surface&, - PropDirection, - const BoundaryCheck& , - const MagneticFieldProperties&, - TransportJacobian*&, - double&, - ParticleHypothesis, - bool, - const TrackingVolume*) const override; + virtual std::unique_ptr<TrackParameters> + propagate( const EventContext& ctx, + const TrackParameters&, + const Surface&, + PropDirection, + const BoundaryCheck& , + const MagneticFieldProperties&, + TransportJacobian*&, + double&, + ParticleHypothesis, + bool, + const TrackingVolume*) const override; /** Propagation interface without Covariance matrix propagation the pathlength has to be returned for eventual following propagateCovariance */ /// implemented using Trk::IPropagator::propagateParameters; - virtual TrackParameters* propagateParameters( const EventContext& ctx, - const TrackParameters& parm, - const Surface& sf, - PropDirection dir, - const BoundaryCheck& bcheck, - const MagneticFieldProperties& mprop, - ParticleHypothesis particle = pion, - bool returnCurv = false, - const TrackingVolume* tVol = nullptr) const override; + virtual std::unique_ptr<TrackParameters> + propagateParameters( const EventContext& ctx, + const TrackParameters& parm, + const Surface& sf, + PropDirection dir, + const BoundaryCheck& bcheck, + const MagneticFieldProperties& mprop, + ParticleHypothesis particle = pion, + bool returnCurv = false, + const TrackingVolume* tVol = nullptr) const override; /// implemented - virtual TrackParameters* propagateParameters( const EventContext& ctx, + virtual std::unique_ptr<TrackParameters> + propagateParameters( const EventContext& ctx, const TrackParameters& parm, const Surface& sf, PropDirection dir, @@ -200,7 +206,7 @@ class IntersectorWrapper final: public AthAlgTool, double m_charge; double m_qOverP; std::unique_ptr<const TrackSurfaceIntersection> m_intersection; - TrackParameters* m_parameters; + std::unique_ptr<TrackParameters> m_parameters; Amg::Vector3D m_position; Amg::Vector3D m_momentum; diff --git a/Tracking/TrkExtrapolation/TrkExRungeKuttaIntersector/src/IntersectorWrapper.cxx b/Tracking/TrkExtrapolation/TrkExRungeKuttaIntersector/src/IntersectorWrapper.cxx index 4eb06a0473907dbe8336c6f06612e82e75c35244..3b8d8ad302eb695bca0c4fb8bd2f56934ca95a6a 100755 --- a/Tracking/TrkExtrapolation/TrkExRungeKuttaIntersector/src/IntersectorWrapper.cxx +++ b/Tracking/TrkExtrapolation/TrkExRungeKuttaIntersector/src/IntersectorWrapper.cxx @@ -77,7 +77,7 @@ IntersectorWrapper::propagate (const NeutralParameters& parameters, return m_linePropagator->propagate(parameters,surface,dir,boundsCheck,curvilinear); } -TrackParameters* +std::unique_ptr<TrackParameters> IntersectorWrapper::propagate (const EventContext& /*ctx*/, const TrackParameters& parameters, const Surface& surface, @@ -91,10 +91,10 @@ IntersectorWrapper::propagate (const EventContext& /*ctx*/, Cache cache{}; findIntersection(cache,parameters,surface, dir); createParameters(cache,surface,boundsCheck,curvilinear); - return cache.m_parameters; + return std::move(cache.m_parameters); } -TrackParameters* +std::unique_ptr<TrackParameters> IntersectorWrapper::propagate (const EventContext& /*ctx*/, const TrackParameters& parameters, const Surface& surface, @@ -110,10 +110,10 @@ IntersectorWrapper::propagate (const EventContext& /*ctx*/, Cache cache{}; findIntersection(cache,parameters,surface,dir); createParameters(cache,surface,boundsCheck,curvilinear); - return cache.m_parameters; + return std::move(cache.m_parameters); } -TrackParameters* +std::unique_ptr<TrackParameters> IntersectorWrapper::propagateParameters (const EventContext& /*ctx*/, const TrackParameters& parameters, const Surface& surface, @@ -128,10 +128,10 @@ IntersectorWrapper::propagateParameters (const EventContext& /*ctx* Cache cache{}; findIntersection(cache,parameters,surface,dir); createParameters(cache,surface,boundsCheck,curvilinear); - return cache.m_parameters; + return std::move(cache.m_parameters); } -TrackParameters* +std::unique_ptr<TrackParameters> IntersectorWrapper::propagateParameters (const EventContext& /*ctx*/, const TrackParameters& parameters, const Surface& surface, @@ -146,7 +146,7 @@ IntersectorWrapper::propagateParameters (const EventContext& /*ctx* Cache cache{}; findIntersection(cache,parameters,surface,dir); createParameters(cache,surface,boundsCheck,curvilinear); - return cache.m_parameters; + return std::move(cache.m_parameters); } const IntersectionSolution* @@ -194,14 +194,14 @@ IntersectorWrapper::createParameters (Cache& cache, // curvilinear special (simple) case if (curvilinear) { - cache.m_parameters=new CurvilinearParameters(cache.m_intersection->position(), + cache.m_parameters=std::make_unique<CurvilinearParameters>(cache.m_intersection->position(), cache.m_intersection->direction().phi(), cache.m_intersection->direction().theta(), cache.m_qOverP); return; } - cache.m_parameters=surface.createTrackParameters(cache.m_intersection->position(), + cache.m_parameters=surface.createUniqueTrackParameters(cache.m_intersection->position(), cache.m_intersection->direction(), cache.m_charge,nullptr); // unrecognized Surface diff --git a/Tracking/TrkExtrapolation/TrkExRungeKuttaPropagator/CMakeLists.txt b/Tracking/TrkExtrapolation/TrkExRungeKuttaPropagator/CMakeLists.txt index 5ce2d77bfc8bf3acea00abc1b22ba16bf24f7db0..d3405c54fdd2aeaed22af094d29f8a99b150657a 100644 --- a/Tracking/TrkExtrapolation/TrkExRungeKuttaPropagator/CMakeLists.txt +++ b/Tracking/TrkExtrapolation/TrkExRungeKuttaPropagator/CMakeLists.txt @@ -7,6 +7,6 @@ atlas_subdir( TrkExRungeKuttaPropagator ) atlas_add_component( TrkExRungeKuttaPropagator src/*.cxx src/components/*.cxx - LINK_LIBRARIES AthenaBaseComps GaudiKernel TrkEventPrimitives TrkNeutralParameters - TrkParameters TrkExInterfaces TrkGeometry TrkSurfaces TrkPatternParameters TrkExUtils + LINK_LIBRARIES AthenaBaseComps GaudiKernel TrkParameters TrkSurfaces TrkEventPrimitives TrkNeutralParameters + TrkExInterfaces TrkGeometry TrkPatternParameters TrkExUtils MagFieldElements MagFieldConditions CxxUtils ) diff --git a/Tracking/TrkExtrapolation/TrkExRungeKuttaPropagator/TrkExRungeKuttaPropagator/RungeKuttaPropagator.h b/Tracking/TrkExtrapolation/TrkExRungeKuttaPropagator/TrkExRungeKuttaPropagator/RungeKuttaPropagator.h index a345ca029a8cffc8c4d909e07ac434bbac9f923c..a10e14bb8518d678b7779695d5de3b7acc9f78b7 100755 --- a/Tracking/TrkExtrapolation/TrkExRungeKuttaPropagator/TrkExRungeKuttaPropagator/RungeKuttaPropagator.h +++ b/Tracking/TrkExtrapolation/TrkExRungeKuttaPropagator/TrkExRungeKuttaPropagator/RungeKuttaPropagator.h @@ -141,7 +141,7 @@ namespace Trk { /** AlgTool finalize method */ virtual StatusCode finalize() override final; - /** Main propagation mehtod NeutralParameters */ + /** Main propagation method NeutralParameters */ virtual NeutralParameters* propagate (const NeutralParameters &, @@ -150,9 +150,9 @@ namespace Trk { const BoundaryCheck &, bool ) const override final; - /** Main propagation mehtod without transport jacobian production*/ + /** Main propagation method without transport jacobian production*/ - virtual TrackParameters* propagate + virtual std::unique_ptr<TrackParameters> propagate (const EventContext& ctx, const TrackParameters &, const Surface &, @@ -163,9 +163,9 @@ namespace Trk { bool , const TrackingVolume* ) const override final; - /** Main propagation mehtod with transport jacobian production*/ + /** Main propagation method with transport jacobian production*/ - virtual TrackParameters* propagate + virtual std::unique_ptr<TrackParameters> propagate (const EventContext& ctx, const TrackParameters &, const Surface &, @@ -180,7 +180,7 @@ namespace Trk { /** The propagation method finds the closest surface */ - virtual TrackParameters* propagate + virtual std::unique_ptr<TrackParameters> propagate (const EventContext& ctx, const TrackParameters &, std::vector<DestSurf> &, @@ -193,9 +193,9 @@ namespace Trk { bool , const TrackingVolume* ) const override final; - /** Main propagation mehtod for parameters only without transport jacobian productio*/ + /** Main propagation method for parameters only without transport jacobian productio*/ - virtual TrackParameters* propagateParameters + virtual std::unique_ptr<TrackParameters> propagateParameters (const EventContext& ctx, const TrackParameters &, const Surface &, @@ -207,9 +207,9 @@ namespace Trk { const TrackingVolume* ) const override final; - /** Main propagation mehtod for parameters only with transport jacobian productio*/ + /** Main propagation method for parameters only with transport jacobian productio*/ - virtual TrackParameters* propagateParameters + virtual std::unique_ptr<TrackParameters> propagateParameters (const EventContext& ctx, const TrackParameters &, const Surface &, @@ -258,7 +258,7 @@ namespace Trk { const MagneticFieldProperties &, ParticleHypothesis particle=pion) const override final; - /** Main propagation mehtod with step to surface calculation*/ + /** Main propagation method with step to surface calculation*/ virtual bool propagate (const EventContext& ctx, @@ -270,7 +270,7 @@ namespace Trk { double &, ParticleHypothesis particle=pion) const override final; - /** Main propagation mehtod for parameters only */ + /** Main propagation method for parameters only */ virtual bool propagateParameters (const EventContext& ctx, @@ -281,7 +281,7 @@ namespace Trk { const MagneticFieldProperties &, ParticleHypothesis particle=pion) const override final; - /** Main propagation mehtod for parameters only with step to surface calculation*/ + /** Main propagation method for parameters only with step to surface calculation*/ virtual bool propagateParameters (const EventContext& ctx, PatternTrackParameters &, @@ -352,7 +352,7 @@ namespace Trk { /** Internal RungeKutta propagation method for charge track parameters*/ - TrackParameters* propagateRungeKutta + std::unique_ptr<TrackParameters> propagateRungeKutta (Cache& cache , bool , const TrackParameters &, diff --git a/Tracking/TrkExtrapolation/TrkExRungeKuttaPropagator/src/RungeKuttaPropagator.cxx b/Tracking/TrkExtrapolation/TrkExRungeKuttaPropagator/src/RungeKuttaPropagator.cxx index 3dedcc410f4460909e76558cddfbc530c0f00fa1..07b1a8254e5e0041a61a92924e77b759b404930b 100755 --- a/Tracking/TrkExtrapolation/TrkExRungeKuttaPropagator/src/RungeKuttaPropagator.cxx +++ b/Tracking/TrkExtrapolation/TrkExRungeKuttaPropagator/src/RungeKuttaPropagator.cxx @@ -97,7 +97,7 @@ newCrossPoint(const Trk::CylinderSurface& Su, const double* Ro, const double* P) // Build new track parameters without propagation ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* +std::unique_ptr<Trk::TrackParameters> buildTrackParametersWithoutPropagation( const Trk::TrackParameters& Tp, double* Jac) @@ -106,7 +106,7 @@ buildTrackParametersWithoutPropagation( Jac[1] = Jac[2] = Jac[3] = Jac[4] = Jac[5] = Jac[7] = Jac[8] = Jac[9] = Jac[10] = Jac[11] = Jac[13] = Jac[14] = Jac[15] = Jac[16] = Jac[17] = Jac[19] = 0.; - return Tp.clone(); + return std::unique_ptr<Trk::TrackParameters>(Tp.clone()); } ///////////////////////////////////////////////////////////////////////////////// @@ -129,7 +129,7 @@ buildTrackParametersWithoutPropagation( // Track parameters in cross point preparation ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* +std::unique_ptr<Trk::TrackParameters> crossPoint(const Trk::TrackParameters& Tp, std::vector<Trk::DestSurf>& SU, std::vector<unsigned int>& So, @@ -193,7 +193,7 @@ crossPoint(const Trk::TrackParameters& Tp, Trk::RungeKuttaUtils::transformGlobalToLocal(SU[N].first, useJac, P, p, Jac); if (!useJac) - return SU[N].first->createTrackParameters( + return SU[N].first->createUniqueTrackParameters( p[0], p[1], p[2], p[3], p[4], nullptr); AmgSymMatrix(5)* e = @@ -205,7 +205,7 @@ crossPoint(const Trk::TrackParameters& Tp, delete e; return nullptr; } - return SU[N].first->createTrackParameters(p[0], p[1], p[2], p[3], p[4], e); + return SU[N].first->createUniqueTrackParameters(p[0], p[1], p[2], p[3], p[4], e); } } @@ -285,7 +285,8 @@ Trk::NeutralParameters* Trk::RungeKuttaPropagator::propagate // without transport Jacobian production ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* Trk::RungeKuttaPropagator::propagate +std::unique_ptr<Trk::TrackParameters> +Trk::RungeKuttaPropagator::propagate (const ::EventContext& ctx, const Trk::TrackParameters & Tp, const Trk::Surface & Su, @@ -311,7 +312,8 @@ Trk::TrackParameters* Trk::RungeKuttaPropagator::propagate // with transport Jacobian production ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* Trk::RungeKuttaPropagator::propagate +std::unique_ptr<Trk::TrackParameters> +Trk::RungeKuttaPropagator::propagate (const ::EventContext& ctx, const Trk::TrackParameters & Tp , const Trk::Surface& Su , @@ -331,7 +333,7 @@ Trk::TrackParameters* Trk::RungeKuttaPropagator::propagate getFieldCacheObject(cache, ctx); pathLength < 0. ? cache.m_maxPath = 10000. : cache.m_maxPath = pathLength; - Trk::TrackParameters* Tpn = propagateRungeKutta(cache,true,Tp,Su,D,B,M,J,returnCurv); + auto Tpn = propagateRungeKutta(cache,true,Tp,Su,D,B,M,J,returnCurv); pathLength = cache.m_step; if(Tpn) { @@ -346,7 +348,8 @@ Trk::TrackParameters* Trk::RungeKuttaPropagator::propagate // Main function to finds the closest surface ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* Trk::RungeKuttaPropagator::propagate +std::unique_ptr<Trk::TrackParameters> +Trk::RungeKuttaPropagator::propagate (const ::EventContext& ctx, const TrackParameters & Tp , std::vector<DestSurf> & DS , @@ -416,7 +419,7 @@ Trk::TrackParameters* Trk::RungeKuttaPropagator::propagate double Sl = Smax ; double St = Smax ; bool InS = false; - TrackParameters* To = nullptr ; + //TrackParameters* To = nullptr ; for(int i=0; i!=45; ++i) Pn[i]=Po[i]; @@ -481,7 +484,7 @@ Trk::TrackParameters* Trk::RungeKuttaPropagator::propagate } else { Path = W+SN.first; - if((To = crossPoint(Tp,DS,Sol,Pn,SN))) return To; + if(auto To {crossPoint(Tp,DS,Sol,Pn,SN)};To) return To; Nveto = SN.second; St = Sl; } } @@ -494,7 +497,7 @@ Trk::TrackParameters* Trk::RungeKuttaPropagator::propagate // without transport Jacobian production ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* Trk::RungeKuttaPropagator::propagateParameters +std::unique_ptr<Trk::TrackParameters> Trk::RungeKuttaPropagator::propagateParameters (const ::EventContext& ctx, const Trk::TrackParameters & Tp, const Trk::Surface & Su, @@ -520,7 +523,7 @@ Trk::TrackParameters* Trk::RungeKuttaPropagator::propagateParameters // with transport Jacobian production ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* Trk::RungeKuttaPropagator::propagateParameters +std::unique_ptr<Trk::TrackParameters> Trk::RungeKuttaPropagator::propagateParameters (const ::EventContext& ctx, const Trk::TrackParameters & Tp , const Trk::Surface & Su , @@ -538,7 +541,7 @@ Trk::TrackParameters* Trk::RungeKuttaPropagator::propagateParameters // Get field cache object getFieldCacheObject(cache, ctx); cache.m_maxPath = 10000.; - Trk::TrackParameters* Tpn = propagateRungeKutta (cache,true,Tp,Su,D,B,M,J,returnCurv); + auto Tpn{propagateRungeKutta (cache,true,Tp,Su,D,B,M,J,returnCurv)}; if(Tpn) { J[24]=J[20]; J[23]=0.; J[22]=0.; J[21]=0.; J[20]=0.; @@ -678,7 +681,8 @@ Trk::NeutralParameters* Trk::RungeKuttaPropagator::propagateStraightLine // Main function for charged track parameters propagation with or without jacobian ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* Trk::RungeKuttaPropagator::propagateRungeKutta +std::unique_ptr<Trk::TrackParameters> +Trk::RungeKuttaPropagator::propagateRungeKutta (Cache& cache , bool useJac, const Trk::TrackParameters& Tp , @@ -740,7 +744,8 @@ Trk::TrackParameters* Trk::RungeKuttaPropagator::propagateRungeKutta // For cylinder we do test for next cross point // if(cyl->bounds().halfPhiSector() < 3.1 && newCrossPoint(*cyl,r0,P)) { - s[8] = 0.; if(!propagateWithJacobian(cache,useJac,2,s,P,Step)) return nullptr; + s[8] = 0.; + if(!propagateWithJacobian(cache,useJac,2,s,P,Step)) return nullptr; } } else if (ty == Trk::Surface::Perigee ) { @@ -778,11 +783,11 @@ Trk::TrackParameters* Trk::RungeKuttaPropagator::propagateRungeKutta if(!useJac || !Tp.covariance()) { if(!returnCurv) { - return Su.createTrackParameters(p[0],p[1],p[2],p[3],p[4],nullptr); + return Su.createUniqueTrackParameters(p[0],p[1],p[2],p[3],p[4],nullptr); } else { Amg::Vector3D gp(P[0],P[1],P[2]); - return new Trk::CurvilinearParameters(gp,p[2],p[3],p[4]); + return std::make_unique<Trk::CurvilinearParameters>(gp,p[2],p[3],p[4]); } } @@ -790,15 +795,16 @@ Trk::TrackParameters* Trk::RungeKuttaPropagator::propagateRungeKutta AmgSymMatrix(5)& cv = *e; if(cv(0,0)<=0. || cv(1,1)<=0. || cv(2,2)<=0. || cv(3,3)<=0. || cv(4,4)<=0.) { - delete e; return nullptr; + delete e; + return nullptr; } if(!returnCurv) { - return Su.createTrackParameters(p[0],p[1],p[2],p[3],p[4],e); + return Su.createUniqueTrackParameters(p[0],p[1],p[2],p[3],p[4],e); } else { Amg::Vector3D gp(P[0],P[1],P[2]); - return new Trk::CurvilinearParameters(gp,p[2],p[3],p[4],e); + return std::make_unique<Trk::CurvilinearParameters>(gp,p[2],p[3],p[4],e); } } diff --git a/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/TrkExSTEP_Propagator/STEP_Propagator.h b/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/TrkExSTEP_Propagator/STEP_Propagator.h index 34f894acdbe4b246fb149dc032e8b2807ee4fcfb..49e9ef711d21d3bd07ceb41d11c6f68cd05ce245 100755 --- a/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/TrkExSTEP_Propagator/STEP_Propagator.h +++ b/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/TrkExSTEP_Propagator/STEP_Propagator.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ ///////////////////////////////////////////////////////////////////////////////// @@ -185,7 +185,7 @@ namespace Trk { /** Propagate parameters and covariance without returning the Jacobian */ - virtual Trk::TrackParameters* + virtual std::unique_ptr<Trk::TrackParameters> propagate (const EventContext& ctx, const Trk::TrackParameters& trackParameters, const Trk::Surface& targetSurface, @@ -197,7 +197,7 @@ namespace Trk { const Trk::TrackingVolume* tVol = nullptr) const override final; /** Propagate parameters and covariance with search of closest surface */ - virtual Trk::TrackParameters* + virtual std::unique_ptr<Trk::TrackParameters> propagate (const EventContext& ctx, const Trk::TrackParameters& trackParameters, std::vector<Trk::DestSurf>& targetSurfaces, @@ -211,7 +211,7 @@ namespace Trk { const Trk::TrackingVolume* tVol = nullptr) const override final; /** Propagate parameters and covariance with search of closest surface */ - virtual Trk::TrackParameters* + virtual std::unique_ptr<Trk::TrackParameters> propagateT (const EventContext& ctx, const Trk::TrackParameters& trackParameters, std::vector<Trk::DestSurf>& targetSurfaces, @@ -226,7 +226,7 @@ namespace Trk { std::vector<Trk::HitInfo>*& hitVector) const override final; /** Propagate parameters and covariance with search of closest surface and material collection */ - virtual Trk::TrackParameters* + virtual std::unique_ptr<Trk::TrackParameters> propagateM (const EventContext& ctx, const Trk::TrackParameters& trackParameters, std::vector<Trk::DestSurf>& targetSurfaces, @@ -243,7 +243,7 @@ namespace Trk { Trk::ExtrapolationCache* = nullptr) const override final; /** Propagate parameters and covariance, and return the Jacobian. WARNING: Multiple Scattering is not included in the Jacobian! */ - virtual Trk::TrackParameters* + virtual std::unique_ptr<Trk::TrackParameters> propagate (const EventContext& ctx, const Trk::TrackParameters& trackParameters, const Trk::Surface& targetSurface, @@ -258,7 +258,7 @@ namespace Trk { /** Propagate parameters only */ - virtual Trk::TrackParameters* + virtual std::unique_ptr<Trk::TrackParameters> propagateParameters (const EventContext& ctx, const Trk::TrackParameters& trackParameters, const Trk::Surface& targetSurface, @@ -271,7 +271,7 @@ namespace Trk { /** Propagate parameters and return Jacobian. WARNING: Multiple Scattering is not included in the Jacobian! */ - virtual Trk::TrackParameters* + virtual std::unique_ptr<Trk::TrackParameters> propagateParameters (const EventContext& ctx, const Trk::TrackParameters& trackParameters, const Trk::Surface& targetSurface, @@ -295,12 +295,13 @@ namespace Trk { /** Intersection and propagation: */ - virtual const TrackSurfaceIntersection* intersectSurface(const EventContext& ctx, - const Surface& surface, - const TrackSurfaceIntersection* trackIntersection, - const double qOverP, - const MagneticFieldProperties& mft, - ParticleHypothesis particle) const override final; + virtual const TrackSurfaceIntersection* + intersectSurface(const EventContext& ctx, + const Surface& surface, + const TrackSurfaceIntersection* trackIntersection, + const double qOverP, + const MagneticFieldProperties& mft, + ParticleHypothesis particle) const override final; /** Return a list of positions along the track */ virtual void @@ -379,7 +380,7 @@ namespace Trk { ///////////////////////////////////////////////////////////////////////////////// // Main functions for propagation ///////////////////////////////////////////////////////////////////////////////// - Trk::TrackParameters* + std::unique_ptr<Trk::TrackParameters> propagateRungeKutta (Cache& cache, bool errorPropagation, const Trk::TrackParameters& trackParameters, @@ -395,7 +396,7 @@ namespace Trk { // Main function for propagation // with search of closest surface (ST) ///////////////////////////////////////////////////////////////////////////////// - Trk::TrackParameters* + std::unique_ptr<Trk::TrackParameters> propagateRungeKutta (Cache& cache, bool errorPropagation, const Trk::TrackParameters& trackParameters, @@ -515,7 +516,7 @@ namespace Trk { ///////////////////////////////////////////////////////////////////////////////// // Create straight line in case q/p = 0 ///////////////////////////////////////////////////////////////////////////////// - Trk::TrackParameters* + std::unique_ptr<Trk::TrackParameters> createStraightLine( const Trk::TrackParameters* inputTrackParameters) const; void clearCache(Cache& cache) const; @@ -537,7 +538,7 @@ namespace Trk { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // propagation of neutrals (simulation mode) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Trk::TrackParameters* propagateNeutral(const Trk::TrackParameters& parm, + std::unique_ptr<Trk::TrackParameters> propagateNeutral(const Trk::TrackParameters& parm, std::vector<DestSurf>& targetSurfaces, Trk::PropDirection propagationDirection, std::vector<unsigned int>& solutions, diff --git a/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/src/STEP_Propagator.cxx b/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/src/STEP_Propagator.cxx index 075d4bfb8039079214a120b754df3fb5ad2e21fe..14d7b249cff2aae148aed3551b3daa97ac2d77d1 100755 --- a/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/src/STEP_Propagator.cxx +++ b/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/src/STEP_Propagator.cxx @@ -174,7 +174,7 @@ Trk::STEP_Propagator::propagate (const Trk::NeutralParameters&, // Main function for track parameters and covariance matrix propagation ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* +std::unique_ptr<Trk::TrackParameters> Trk::STEP_Propagator::propagate (const EventContext& ctx, const Trk::TrackParameters& trackParameters, const Trk::Surface& targetSurface, @@ -221,7 +221,7 @@ Trk::STEP_Propagator::propagate (const EventContext& ctx, // with search of closest surface (ST) ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* +std::unique_ptr<Trk::TrackParameters> Trk::STEP_Propagator::propagate (const EventContext& ctx, const Trk::TrackParameters& trackParameters, std::vector<DestSurf>& targetSurfaces, @@ -283,7 +283,7 @@ Trk::STEP_Propagator::propagate (const EventContext& ctx, // with search of closest surface and time info (ST) ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* +std::unique_ptr<Trk::TrackParameters> Trk::STEP_Propagator::propagateT (const EventContext& ctx, const Trk::TrackParameters& trackParameters, std::vector<DestSurf>& targetSurfaces, @@ -355,7 +355,7 @@ Trk::STEP_Propagator::propagateT (const EventContext& ctx, path = 0.; } - Trk::TrackParameters* nextPar = nullptr; + std::unique_ptr<Trk::TrackParameters> nextPar{}; if ( particle==Trk::neutron || particle==Trk::photon || particle==Trk::pi0 || particle==Trk::k0 ){ nextPar = propagateNeutral(trackParameters,targetSurfaces,propagationDirection, @@ -380,7 +380,7 @@ Trk::STEP_Propagator::propagateT (const EventContext& ctx, // with search of closest surface and material collection (ST) ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* +std::unique_ptr<Trk::TrackParameters> Trk::STEP_Propagator::propagateM (const EventContext& ctx, const Trk::TrackParameters& trackParameters, std::vector<DestSurf>& targetSurfaces, @@ -449,7 +449,7 @@ Trk::STEP_Propagator::propagateM (const EventContext& // Main function for track parameters and covariance matrix propagation. ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* +std::unique_ptr<Trk::TrackParameters> Trk::STEP_Propagator::propagate (const EventContext& ctx, const Trk::TrackParameters& trackParameters, const Trk::Surface& targetSurface, @@ -489,7 +489,7 @@ Trk::STEP_Propagator::propagate (const EventContext& ctx, cache.m_matupd_lastpath = 0.; cache.m_matdump_lastpath = 0.; - Trk::TrackParameters* parameters = propagateRungeKutta(cache, true, trackParameters, targetSurface, + std::unique_ptr<Trk::TrackParameters> parameters = propagateRungeKutta(cache, true, trackParameters, targetSurface, propagationDirection,magneticFieldProperties, particle, boundaryCheck, Jacobian, returnCurv); @@ -508,7 +508,7 @@ Trk::STEP_Propagator::propagate (const EventContext& ctx, // Main function for track parameters propagation without covariance matrix ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* +std::unique_ptr<Trk::TrackParameters> Trk::STEP_Propagator::propagateParameters (const EventContext& ctx, const Trk::TrackParameters& trackParameters, const Trk::Surface& targetSurface, @@ -553,7 +553,7 @@ Trk::STEP_Propagator::propagateParameters (const EventContext& c // Main function for track parameters propagation without covariance matrix. ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* +std::unique_ptr<Trk::TrackParameters> Trk::STEP_Propagator::propagateParameters (const EventContext& ctx, const Trk::TrackParameters& trackParameters, const Trk::Surface& targetSurface, @@ -589,7 +589,7 @@ Trk::STEP_Propagator::propagateParameters (const EventContext& c cache.m_extrapolationCache = nullptr; cache.m_hitVector = nullptr; - Trk::TrackParameters* parameters = propagateRungeKutta( cache,true, trackParameters, targetSurface, + std::unique_ptr<Trk::TrackParameters> parameters = propagateRungeKutta( cache,true, trackParameters, targetSurface, propagationDirection,magneticFieldProperties, particle, boundaryCheck, Jacobian, returnCurv); @@ -730,7 +730,7 @@ Trk::STEP_Propagator::intersectSurface(const EventContext& ctx, const Amg::Vector3D& direction = trackIntersection->direction(); PerigeeSurface* perigeeSurface = new PerigeeSurface(origin); - const Trk::TrackParameters* trackParameters = perigeeSurface->createTrackParameters(0.,0., + auto trackParameters = perigeeSurface->createUniqueTrackParameters(0.,0., direction.phi(), direction.theta(),qOverP,nullptr); @@ -741,7 +741,6 @@ Trk::STEP_Propagator::intersectSurface(const EventContext& ctx, mft,particle,nullptr); delete perigeeSurface; - delete trackParameters; if(!solution) return nullptr; Trk::IntersectionSolutionIter output_iter = solution->begin(); @@ -877,7 +876,7 @@ Trk::STEP_Propagator::globalPositions ( const EventContext& ctx, #if defined(__GNUC__) && !defined(__OPTIMIZE__) __attribute__ ((optimize(2))) #endif -Trk::TrackParameters* +std::unique_ptr<Trk::TrackParameters> Trk::STEP_Propagator::propagateRungeKutta (Cache& cache, bool errorPropagation, const Trk::TrackParameters& inputTrackParameters, @@ -893,7 +892,7 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c cache.m_particle = particle; cache.m_charge = inputTrackParameters.charge(); - const Trk::TrackParameters* trackParameters = nullptr; + std::unique_ptr<Trk::TrackParameters> trackParameters{}; // Bfield mode mft.magneticFieldMode() == Trk::FastField ? cache.m_solenoid = true : cache.m_solenoid = false; @@ -910,11 +909,11 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c } } else { - trackParameters = &inputTrackParameters; + //careful here, this is just to avoid a const_cast + trackParameters.reset(inputTrackParameters.clone()); } if (fabs( 1./trackParameters->parameters()[Trk::qOverP]) <= m_momentumCutOff) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } @@ -934,7 +933,6 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c } if (!Trk::RungeKuttaUtils::transformLocalToGlobal( errorPropagation, *trackParameters,cache.m_P)) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } double path = 0.; @@ -949,7 +947,6 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c if(d>=0.) {s[0]= T(0,2); s[1]= T(1,2); s[2]= T(2,2); s[3]= d;} else {s[0]=-T(0,2); s[1]=-T(1,2); s[2]=-T(2,2); s[3]=-d;} if (!propagateWithJacobian(cache,errorPropagation, ty, s, cache.m_P, path)) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } } @@ -958,7 +955,6 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c double s[6] ={T(0,3),T(1,3),T(2,3),T(0,2),T(1,2),T(2,2)}; if (!propagateWithJacobian( cache,errorPropagation, ty, s, cache.m_P, path)) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } } @@ -968,7 +964,6 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c const Trk::CylinderSurface* cyl = static_cast<const Trk::CylinderSurface*>(&targetSurface); double s[9] = {T(0,3),T(1,3),T(2,3),T(0,2),T(1,2),T(2,2),cyl->bounds().r(),(double)propagationDirection,0.}; if (!propagateWithJacobian( cache,errorPropagation, ty, s, cache.m_P, path)) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } } @@ -978,7 +973,6 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c double k = static_cast<const Trk::ConeSurface*>(&targetSurface)->bounds().tanAlpha(); k = k*k+1.; double s[9] = {T(0,3),T(1,3),T(2,3),T(0,2),T(1,2),T(2,2),k,(double)propagationDirection,0.}; if (!propagateWithJacobian(cache, errorPropagation, ty, s, cache.m_P, path)) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } } @@ -987,7 +981,6 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c double s[6] ={T(0,3),T(1,3),T(2,3),0.,0.,1.}; if (!propagateWithJacobian(cache, errorPropagation, ty, s, cache.m_P, path)) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } } @@ -1000,13 +993,11 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c if(d>=0.) {s[0]= T(0,2); s[1]= T(1,2); s[2]= T(2,2); s[3]= d;} else {s[0]=-T(0,2); s[1]=-T(1,2); s[2]=-T(2,2); s[3]=-d;} if (!propagateWithJacobian(cache, errorPropagation, ty, s, cache.m_P, path)) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } } if (propagationDirection * path < 0.) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } @@ -1018,13 +1009,11 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c Amg::Vector3D gp(cache.m_P[0],cache.m_P[1],cache.m_P[2]); if ( boundaryCheck && !targetSurface.isOnSurface(gp) ) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } if ( !errorPropagation || !trackParameters->covariance() ) { - if (trackParameters != &inputTrackParameters) delete trackParameters; - return new Trk::CurvilinearParameters(gp, localp[2], localp[3], localp[4]); + return std::make_unique<Trk::CurvilinearParameters>(gp, localp[2], localp[3], localp[4]); } double useless[2]; @@ -1033,10 +1022,9 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c Jacobian, *trackParameters->covariance()); if (cache.m_matPropOK && (m_multipleScattering || m_straggling) && fabs(path)>0. ) - covarianceContribution( cache,trackParameters, path, fabs( 1./cache.m_P[6]), measurementCovariance); + covarianceContribution( cache,trackParameters.get(), path, fabs( 1./cache.m_P[6]), measurementCovariance); - if (trackParameters != &inputTrackParameters) delete trackParameters; - return new Trk::CurvilinearParameters(gp,localp[2],localp[3],localp[4],measurementCovariance); + return std::make_unique<Trk::CurvilinearParameters>(gp,localp[2],localp[3],localp[4],measurementCovariance); } // Common transformation for all surfaces @@ -1045,16 +1033,14 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c if (boundaryCheck) { Amg::Vector2D localPosition( localp[0], localp[1]); if (!targetSurface.insideBounds( localPosition, 0.)) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } } - Trk::TrackParameters* onTargetSurf = targetSurface.createTrackParameters(localp[0],localp[1],localp[2], + auto onTargetSurf = targetSurface.createUniqueTrackParameters(localp[0],localp[1],localp[2], localp[3],localp[4],nullptr); if ( !errorPropagation || !trackParameters->covariance() ) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return onTargetSurf; } @@ -1064,11 +1050,9 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c //Calculate multiple scattering and straggling covariance contribution. if (cache.m_matPropOK && (m_multipleScattering || m_straggling) && fabs(path)>0. ) - covarianceContribution( cache,trackParameters, path, onTargetSurf, measurementCovariance); - delete onTargetSurf; // the covariance matrix can be just added instead of recreating ? + covarianceContribution( cache,trackParameters.get(), path, onTargetSurf.get(), measurementCovariance); - if (trackParameters != &inputTrackParameters) delete trackParameters; - return targetSurface.createTrackParameters(localp[0],localp[1],localp[2],localp[3],localp[4],measurementCovariance); + return targetSurface.createUniqueTrackParameters(localp[0],localp[1],localp[2],localp[3],localp[4],measurementCovariance); } ///////////////////////////////////////////////////////////////////////////////// @@ -1076,7 +1060,7 @@ Trk::STEP_Propagator::propagateRungeKutta (Cache& c // with search of closest surface ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* +std::unique_ptr<Trk::TrackParameters> Trk::STEP_Propagator::propagateRungeKutta ( Cache& cache, bool errorPropagation, const Trk::TrackParameters& inputTrackParameters, @@ -1093,7 +1077,7 @@ Trk::STEP_Propagator::propagateRungeKutta ( Cache& cache.m_charge = inputTrackParameters.charge(); cache.m_inputThetaVariance = 0.; - const Trk::TrackParameters* trackParameters = nullptr; + std::unique_ptr<Trk::TrackParameters> trackParameters{}; // Bfield mode mft.magneticFieldMode() == Trk::FastField ? cache.m_solenoid = true : cache.m_solenoid = false; @@ -1110,11 +1094,10 @@ Trk::STEP_Propagator::propagateRungeKutta ( Cache& } } else { - trackParameters = &inputTrackParameters; + trackParameters.reset(inputTrackParameters.clone()); } if (fabs( 1./trackParameters->parameters()[Trk::qOverP]) <= m_momentumCutOff) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } @@ -1141,7 +1124,6 @@ Trk::STEP_Propagator::propagateRungeKutta ( Cache& //double P[45]; // Track parameters and jacobian if (!Trk::RungeKuttaUtils::transformLocalToGlobal( errorPropagation, *trackParameters, cache.m_P)) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } @@ -1152,7 +1134,8 @@ Trk::STEP_Propagator::propagateRungeKutta ( Cache& // loop while valid solutions bool validStep = true; - totalPath = 0.; cache.m_timeOfFlight = 0.; + totalPath = 0.; + cache.m_timeOfFlight = 0.; // Common transformation for all surfaces (angles and momentum) double localp[5]; double Jacobian[21]; @@ -1161,21 +1144,19 @@ Trk::STEP_Propagator::propagateRungeKutta ( Cache& validStep = propagateWithJacobian( cache,errorPropagation, targetSurfaces, cache.m_P, propagationDirection, solutions, path, totalPath); if (!validStep) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } if (propagationDirection * path <= 0.) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } totalPath += path; cache.m_timeOfFlight += cache.m_timeStep; if (cache.m_propagateWithPathLimit>1 || cache.m_binMat ) { // make sure that for sliding surfaces the result does not get distorted // return curvilinear parameters - Trk::CurvilinearParameters* cPar = nullptr; + std::unique_ptr< Trk::CurvilinearParameters> cPar = nullptr; Trk::RungeKuttaUtils::transformGlobalToLocal(cache.m_P, localp); if (!errorPropagation) { - cPar = new Trk::CurvilinearParameters(Amg::Vector3D(cache.m_P[0],cache.m_P[1],cache.m_P[2]), + cPar = std::make_unique< Trk::CurvilinearParameters>(Amg::Vector3D(cache.m_P[0],cache.m_P[1],cache.m_P[2]), localp[2],localp[3],localp[4]); } else { double useless[2]; @@ -1184,10 +1165,9 @@ Trk::STEP_Propagator::propagateRungeKutta ( Cache& *trackParameters->covariance()); //Calculate multiple scattering and straggling covariance contribution. if (cache.m_matPropOK && (m_multipleScattering || m_straggling) && fabs(totalPath)>0.) { - covarianceContribution(cache, trackParameters, totalPath, fabs( 1./cache.m_P[6]), measurementCovariance); + covarianceContribution(cache, trackParameters.get(), totalPath, fabs( 1./cache.m_P[6]), measurementCovariance); } - if (trackParameters != &inputTrackParameters) delete trackParameters; - cPar = new Trk::CurvilinearParameters(Amg::Vector3D(cache.m_P[0],cache.m_P[1],cache.m_P[2]), + cPar = std::make_unique< Trk::CurvilinearParameters>(Amg::Vector3D(cache.m_P[0],cache.m_P[1],cache.m_P[2]), localp[2],localp[3],localp[4], measurementCovariance); } @@ -1196,7 +1176,7 @@ Trk::STEP_Propagator::propagateRungeKutta ( Cache& if ( cache.m_binMat && (cache.m_matstates || (errorPropagation && cache.m_extrapolationCache)) && fabs(totalPath-cache.m_matdump_lastpath)>1.) { - dumpMaterialEffects( cache,cPar, totalPath); + dumpMaterialEffects( cache,cPar.get(), totalPath); } return cPar; } @@ -1227,24 +1207,22 @@ Trk::STEP_Propagator::propagateRungeKutta ( Cache& } if (solutions.empty()) { - if (trackParameters != &inputTrackParameters) delete trackParameters; return nullptr; } // simulation mode : smear momentum if (m_simulation && cache.m_matPropOK && m_randomEngine ) { double radDist = totalPath/cache.m_material->x0(); - smear(cache,localp[2],localp[3],trackParameters,radDist); + smear(cache,localp[2],localp[3],trackParameters.get(),radDist); } - Trk::TrackParameters* onTargetSurf = (returnCurv || targetSurfaces[solutions[0]].first->type()==Trk::Surface::Cone) ? - nullptr : targetSurfaces[solutions[0]].first->createTrackParameters(localp[0],localp[1],localp[2],localp[3],localp[4],nullptr); + std::unique_ptr<Trk::TrackParameters> onTargetSurf = (returnCurv || targetSurfaces[solutions[0]].first->type()==Trk::Surface::Cone) ? + nullptr : targetSurfaces[solutions[0]].first->createUniqueTrackParameters(localp[0],localp[1],localp[2],localp[3],localp[4],nullptr); if (!errorPropagation) { - if (trackParameters != &inputTrackParameters) delete trackParameters; if (returnCurv || targetSurfaces[solutions[0]].first->type()==Trk::Surface::Cone) { Amg::Vector3D gp(cache.m_P[0],cache.m_P[1],cache.m_P[2]); - return new Trk::CurvilinearParameters(gp, localp[2], localp[3], localp[4]); + return std::make_unique< Trk::CurvilinearParameters>(gp, localp[2], localp[3], localp[4]); } return onTargetSurf; } @@ -1256,20 +1234,19 @@ Trk::STEP_Propagator::propagateRungeKutta ( Cache& //Calculate multiple scattering and straggling covariance contribution. if (cache.m_matPropOK && (m_multipleScattering || m_straggling) && fabs(totalPath)>0.) { if (returnCurv || targetSurfaces[solutions[0]].first->type()==Trk::Surface::Cone) { - covarianceContribution( cache,trackParameters, totalPath, fabs( 1./cache.m_P[6]), measurementCovariance); + covarianceContribution( cache,trackParameters.get(), totalPath, fabs( 1./cache.m_P[6]), measurementCovariance); } else { - covarianceContribution( cache,trackParameters, totalPath, onTargetSurf, measurementCovariance); + covarianceContribution( cache,trackParameters.get(), totalPath, onTargetSurf.get(), measurementCovariance); } } - if (trackParameters != &inputTrackParameters) delete trackParameters; if (returnCurv || targetSurfaces[solutions[0]].first->type()==Trk::Surface::Cone) { Amg::Vector3D gp(cache.m_P[0],cache.m_P[1],cache.m_P[2]); - return new Trk::CurvilinearParameters(gp, localp[2], localp[3], localp[4], measurementCovariance); + return std::make_unique< Trk::CurvilinearParameters>(gp, localp[2], localp[3], localp[4], measurementCovariance); } - delete onTargetSurf; // the covariance matrix can be just added instead of recreating ? - return targetSurfaces[solutions[0]].first->createTrackParameters(localp[0],localp[1],localp[2],localp[3],localp[4], + //delete onTargetSurf; // the covariance matrix can be just added instead of recreating ? + return targetSurfaces[solutions[0]].first->createUniqueTrackParameters(localp[0],localp[1],localp[2],localp[3],localp[4], measurementCovariance); } @@ -1638,7 +1615,6 @@ Trk::STEP_Propagator::propagateWithJacobian (Cache& cache, cache.m_hitVector->push_back(Trk::HitInfo(cPar->clone(), hitTiming, iMat->second,0.)); } } - delete cPar; cache.m_currentLayerBin = layerBin; binIDMat = iMat; @@ -1662,8 +1638,8 @@ Trk::STEP_Propagator::propagateWithJacobian (Cache& cache, } else if ( dist2next.first < lbu->bins() && std::fabs(distanceToNextBin) < 0.01 && h>0.01 ) { // tolerance 10 microns ? double localp[5]; Trk::RungeKuttaUtils::transformGlobalToLocal(P, localp); - const Trk::CurvilinearParameters* cPar = - new Trk::CurvilinearParameters(Amg::Vector3D(P[0],P[1],P[2]),localp[2],localp[3],localp[4]); + auto cPar = + std::make_unique< Trk::CurvilinearParameters>(Amg::Vector3D(P[0],P[1],P[2]),localp[2],localp[3],localp[4]); const Trk::IdentifiedMaterial* nextMat = binIDMat; // need to know what comes next @@ -1696,7 +1672,6 @@ Trk::STEP_Propagator::propagateWithJacobian (Cache& cache, cache.m_hitVector->push_back(Trk::HitInfo(cPar->clone(), hitTiming, nextMat->second,0.)); } } - delete cPar; cache.m_currentLayerBin = dist2next.first; if (binIDMat!=nextMat) { // change of material triggers update of the cache @@ -2617,7 +2592,8 @@ void Trk::STEP_Propagator::updateMaterialEffects( Cache& cache, // Create straight line in case of q/p = 0 ///////////////////////////////////////////////////////////////////////////////// -Trk::TrackParameters* Trk::STEP_Propagator::createStraightLine( const Trk::TrackParameters* inputTrackParameters) const +std::unique_ptr<Trk::TrackParameters> + Trk::STEP_Propagator::createStraightLine( const Trk::TrackParameters* inputTrackParameters) const { AmgVector(5) lp = inputTrackParameters->parameters(); lp[Trk::qOverP] = 1./1e10; @@ -2625,11 +2601,11 @@ Trk::TrackParameters* Trk::STEP_Propagator::createStraightLine( const Trk::Track // ATH_MSG_VERBOSE("STEP propagator detects invalid input parameters (q/p=0 ), resetting momentum to 1.e10"); if (inputTrackParameters->type()==Trk::Curvilinear) { - return new Trk::CurvilinearParameters(inputTrackParameters->position(), lp[2], lp[3], lp[4], + return std::make_unique<Trk::CurvilinearParameters>(inputTrackParameters->position(), lp[2], lp[3], lp[4], (inputTrackParameters->covariance() ? new AmgSymMatrix(5)(*inputTrackParameters->covariance()) : nullptr ) ); } - return inputTrackParameters->associatedSurface().createTrackParameters(lp[0], lp[1], lp[2], lp[3], lp[4], + return inputTrackParameters->associatedSurface().createUniqueTrackParameters(lp[0], lp[1], lp[2], lp[3], lp[4], (inputTrackParameters->covariance() ? new AmgSymMatrix(5)(*inputTrackParameters->covariance()) : nullptr ) ); @@ -2706,7 +2682,7 @@ void Trk::STEP_Propagator::sampleBrem(Cache& cache, double mom) const cache.m_bremEmitThreshold = mom - rnde*cache.m_bremMom; } -Trk::TrackParameters* +std::unique_ptr<Trk::TrackParameters> Trk::STEP_Propagator::propagateNeutral(const Trk::TrackParameters& parm, std::vector<DestSurf>& targetSurfaces, Trk::PropDirection propDir, @@ -2758,15 +2734,14 @@ Trk::STEP_Propagator::propagateNeutral(const Trk::TrackParameters& parm, if (targetSurfaces[(*oIter).first].first->isOnSurface(xsct, (*oIter).second, 0.001, 0.001) ) { if ( usePathLimit && path>0. && path<((*oIter).second) ) { Amg::Vector3D endpoint = position+propDir*direction*path; - return new Trk::CurvilinearParameters(endpoint,parm.momentum(),parm.charge()); + return std::make_unique< Trk::CurvilinearParameters>(endpoint,parm.momentum(),parm.charge()); } path = (*oIter).second; solutions.push_back((*oIter).first); const Trk::Surface* sf = targetSurfaces[(*oIter).first].first; - if( returnCurv || sf->type()==Trk::Surface::Cone) return new Trk::CurvilinearParameters(xsct,parm.momentum(),parm.charge()); - return sf->createTrackParameters(xsct,parm.momentum(),parm.charge(),nullptr); - + if( returnCurv || sf->type()==Trk::Surface::Cone) return std::make_unique< Trk::CurvilinearParameters>(xsct,parm.momentum(),parm.charge()); + return sf->createUniqueTrackParameters(xsct,parm.momentum(),parm.charge(),nullptr); } } diff --git a/Tracking/TrkExtrapolation/TrkExTools/TrkExTools/Navigator.h b/Tracking/TrkExtrapolation/TrkExTools/TrkExTools/Navigator.h index 80ecaf0e539876b22959bc871acc7df7c80a8004..ff91bf1be59165ea2ef78433e6f0270b8593b51e 100755 --- a/Tracking/TrkExtrapolation/TrkExTools/TrkExTools/Navigator.h +++ b/Tracking/TrkExtrapolation/TrkExTools/TrkExTools/Navigator.h @@ -155,13 +155,7 @@ namespace Trk { double& path) const override final; private: - /* - * Methods to be overriden by the NavigatorValidation - */ - virtual void validationInitialize() {} - virtual void validationFill(const Trk::TrackParameters* trackPar) const{ - (void)trackPar; - } + SG::ReadCondHandleKey<TrackingGeometry> m_trackingGeometryReadKey{ this, diff --git a/Tracking/TrkExtrapolation/TrkExTools/src/Extrapolator.cxx b/Tracking/TrkExtrapolation/TrkExTools/src/Extrapolator.cxx index 51abc695c50fc4dd0ad74de7066c989ba0108767..551731a5efd17782a8567af0010f6252842dbc96 100755 --- a/Tracking/TrkExtrapolation/TrkExTools/src/Extrapolator.cxx +++ b/Tracking/TrkExtrapolation/TrkExTools/src/Extrapolator.cxx @@ -862,19 +862,10 @@ Trk::Extrapolator::extrapolateToNextMaterialLayer(const EventContext& ctx, << "'"); // current static may carry non-trivial material properties, their use is optional; // use highest volume as B field source - // const Trk::TrackParameters* nextPar = - ManagedTrackParmPtr nextPar(ManagedTrackParmPtr::recapture(currPar, - prop.propagate(ctx, - *currPar, - cache.m_navigSurfs, - dir, - m_fieldProperties, - particle, - solutions, - path, - false, - false, - propagVol))); + const Trk::TrackParameters* pNextPar = prop.propagate(ctx,*currPar,cache.m_navigSurfs, + dir,m_fieldProperties,particle,solutions,path,false, + false,propagVol).release(); + ManagedTrackParmPtr nextPar(ManagedTrackParmPtr::recapture(currPar, pNextPar)); if (nextPar) { ATH_MSG_DEBUG(" [+] Position after propagation - at " << positionOutput(nextPar->position())); @@ -1185,8 +1176,7 @@ Trk::Extrapolator::extrapolateToNextMaterialLayer(const EventContext& ctx, ATH_MSG_DEBUG(" [+] " << cache.m_navigSurfs.size() << " target surfaces in '" << cache.m_currentDense->volumeName() << "'."); ManagedTrackParmPtr nextPar( - ManagedTrackParmPtr::recapture(currPar, - prop.propagate(ctx, + ManagedTrackParmPtr::recapture(currPar,prop.propagate(ctx, *currPar, cache.m_navigSurfs, dir, @@ -1196,7 +1186,7 @@ Trk::Extrapolator::extrapolateToNextMaterialLayer(const EventContext& ctx, path, false, false, - cache.m_currentDense))); + cache.m_currentDense).release())); if (nextPar) { ATH_MSG_DEBUG(" [+] Position after propagation - at " << positionOutput(nextPar->position())); @@ -1870,7 +1860,7 @@ Trk::Extrapolator::extrapolateInAlignableTV(const EventContext& ctx, false, false, cache.m_currentDense, - cache.m_extrapolationCache))); + cache.m_extrapolationCache).release())); // does nothing // can be used for debugging to instrument track parameters with some monitoring (e.g. // construction and destruction) @@ -2020,7 +2010,7 @@ Trk::Extrapolator::extrapolateDirectlyImpl(const EventContext& ctx, << "' to destination surface. "); if (currentVolume) { - return prop.propagate(ctx, parm, sf, dir, bcheck, m_fieldProperties, particle); + return prop.propagate(ctx, parm, sf, dir, bcheck, m_fieldProperties, particle).release(); } return nullptr; } @@ -2632,7 +2622,7 @@ Trk::Extrapolator::extrapolateImpl(const EventContext& ctx, m_fieldProperties, particle, false, - previousVolume))); + previousVolume).release())); // set boundary and next parameters cache.m_parametersAtBoundary.boundaryInformation(nextVolume, nextPar, nextPar); nextParameters = cache.m_parametersAtBoundary.nextParameters; @@ -2862,13 +2852,13 @@ Trk::Extrapolator::extrapolateImpl(const EventContext& ctx, m_fieldProperties, particle, false, - lastVolume))); + lastVolume).release())); // desperate try if (!resultParameters) { resultParameters = ManagedTrackParmPtr::recapture( parm, currentPropagator->propagate( - ctx, *parm, sf, dir, bcheck, m_fieldProperties, particle, false, startVolume)); + ctx, *parm, sf, dir, bcheck, m_fieldProperties, particle, false, startVolume).release()); } return resultParameters; } @@ -2922,7 +2912,7 @@ Trk::Extrapolator::extrapolateImpl(const EventContext& ctx, m_fieldProperties, particle, false, - startVolume)); + startVolume).release()); } // return whatever you have return resultParameters; @@ -2964,7 +2954,7 @@ Trk::Extrapolator::extrapolateImpl(const EventContext& ctx, m_fieldProperties, particle, false, - &tvol))); + &tvol).release())); // user might have not calculated well which surfaces are intersected ... break if break if (!nextPar) { return (currPar.index() != parm) @@ -3139,7 +3129,7 @@ Trk::Extrapolator::extrapolateWithinDetachedVolumes(const EventContext& ctx, ManagedTrackParmPtr fwd(ManagedTrackParmPtr::recapture( nextParameters, prop.propagate( - ctx, *nextParameters, sf, dir, bcheck, m_fieldProperties, particle, false, currVol))); + ctx, *nextParameters, sf, dir, bcheck, m_fieldProperties, particle, false, currVol).release())); if (fwd) { return fwd; @@ -3150,7 +3140,7 @@ Trk::Extrapolator::extrapolateWithinDetachedVolumes(const EventContext& ctx, return ManagedTrackParmPtr::recapture( nextParameters, prop.propagate( - ctx, *nextParameters, sf, oppDir, bcheck, m_fieldProperties, particle, false, currVol)); + ctx, *nextParameters, sf, oppDir, bcheck, m_fieldProperties, particle, false, currVol).release()); } @@ -3162,7 +3152,7 @@ Trk::Extrapolator::extrapolateWithinDetachedVolumes(const EventContext& ctx, return ManagedTrackParmPtr::recapture( nextParameters, prop.propagate( - ctx, *nextParameters, sf, dir, bcheck, m_fieldProperties, particle, false, currVol)); + ctx, *nextParameters, sf, dir, bcheck, m_fieldProperties, particle, false, currVol).release()); } Trk::PropDirection oppDir = (dir != Trk::oppositeMomentum) ? Trk::oppositeMomentum : Trk::alongMomentum; @@ -3170,7 +3160,7 @@ Trk::Extrapolator::extrapolateWithinDetachedVolumes(const EventContext& ctx, return ManagedTrackParmPtr::recapture( nextParameters, prop.propagate( - ctx, *nextParameters, sf, oppDir, bcheck, m_fieldProperties, particle, false, currVol)); + ctx, *nextParameters, sf, oppDir, bcheck, m_fieldProperties, particle, false, currVol).release()); } if (dist < 0.) { ATH_MSG_DEBUG(" [!] Initial 3D-distance to the surface negative (" @@ -3211,7 +3201,7 @@ Trk::Extrapolator::extrapolateWithinDetachedVolumes(const EventContext& ctx, << ":distance to the destination surface:" << currentDistance); ManagedTrackParmPtr cParms(ManagedTrackParmPtr::recapture( onNextLayer, - prop.propagate(ctx, *onNextLayer, sf, dir, bchk, m_fieldProperties, particle))); + prop.propagate(ctx, *onNextLayer, sf, dir, bchk, m_fieldProperties, particle).release())); return cParms; } return onNextLayer; @@ -3358,7 +3348,7 @@ Trk::Extrapolator::insideVolumeStaticLayers(const EventContext& ctx, nextParameters = ManagedTrackParmPtr::recapture( parm, prop.propagate( - ctx, *parm, *cache.m_destinationSurface, dir, bcheck, m_fieldProperties, particle)); + ctx, *parm, *cache.m_destinationSurface, dir, bcheck, m_fieldProperties, particle).release()); if (!nextParameters) { nextParameters = ManagedTrackParmPtr::recapture(parm, prop.propagate(ctx, @@ -3367,7 +3357,7 @@ Trk::Extrapolator::insideVolumeStaticLayers(const EventContext& ctx, Trk::anyDirection, bcheck, m_fieldProperties, - particle)); + particle).release()); } return nextParameters; } @@ -3617,7 +3607,7 @@ Trk::Extrapolator::insideVolumeStaticLayers(const EventContext& ctx, dir, bcheck, m_fieldProperties, - particle)); + particle).release()); // job done: cleanup and go home // reset the recallInformation resetRecallInformation(cache); @@ -3897,8 +3887,8 @@ Trk::Extrapolator::extrapolateToDestinationLayer(const EventContext& ctx, parm, cache.m_jacs ? prop.propagate( - ctx, *parm, sf, dir, bcheck, MagneticFieldProperties(), jac, pathLimit, particle) - : prop.propagate(ctx, *parm, sf, dir, bcheck, MagneticFieldProperties(), particle))); + ctx, *parm, sf, dir, bcheck, MagneticFieldProperties(), jac, pathLimit, particle).release() + : prop.propagate(ctx, *parm, sf, dir, bcheck, MagneticFieldProperties(), particle).release())); // fallback to anyDirection // destParameters = destParameters ? destParameters : ( cache.m_jacs ? prop.propagate(parm, sf, @@ -3916,8 +3906,8 @@ Trk::Extrapolator::extrapolateToDestinationLayer(const EventContext& ctx, MagneticFieldProperties(), jac, pathLimit, - particle) - : prop.propagate(ctx, *parm, sf, Trk::anyDirection, bcheck, m_fieldProperties, particle))); + particle).release() + : prop.propagate(ctx, *parm, sf, Trk::anyDirection, bcheck, m_fieldProperties, particle).release())); } // return the pre-updated ones @@ -4002,7 +3992,7 @@ Trk::Extrapolator::extrapolateToIntermediateLayer(const EventContext& ctx, const std::vector<const Surface*> cs = cl->constituentSurfaces(); for (unsigned int i = 0; i < cs.size(); ++i) { parsOnLayer = ManagedTrackParmPtr::recapture( - parm, prop.propagate(ctx, *parm, *(cs[i]), dir, true, m_fieldProperties, particle)); + parm, prop.propagate(ctx, *parm, *(cs[i]), dir, true, m_fieldProperties, particle).release()); if (parsOnLayer) { break; } @@ -4011,13 +4001,13 @@ Trk::Extrapolator::extrapolateToIntermediateLayer(const EventContext& ctx, parsOnLayer = ManagedTrackParmPtr::recapture( parm, prop.propagate( - ctx, *parm, lay.surfaceRepresentation(), dir, true, m_fieldProperties, particle)); + ctx, *parm, lay.surfaceRepresentation(), dir, true, m_fieldProperties, particle).release()); } } else { parsOnLayer = ManagedTrackParmPtr::recapture( parm, prop.propagate( - ctx, *parm, lay.surfaceRepresentation(), dir, true, m_fieldProperties, particle)); + ctx, *parm, lay.surfaceRepresentation(), dir, true, m_fieldProperties, particle).release()); } // return if there is nothing to do @@ -4157,7 +4147,7 @@ Trk::Extrapolator::overlapSearch(const EventContext& ctx, detParameters = parm; } else if (detSurface) { detParameters = ManagedTrackParmPtr::recapture( - parm, prop.propagate(ctx, *parm, *detSurface, dir, false, m_fieldProperties, particle)); + parm, prop.propagate(ctx, *parm, *detSurface, dir, false, m_fieldProperties, particle).release()); } // set the surface hit to true, it is anyway overruled @@ -4219,7 +4209,7 @@ Trk::Extrapolator::overlapSearch(const EventContext& ctx, ManagedTrackParmPtr overlapParameters(ManagedTrackParmPtr::recapture( parm, prop.propagate( - ctx, *parm, *(csf.object), Trk::anyDirection, true, m_fieldProperties, particle))); + ctx, *parm, *(csf.object), Trk::anyDirection, true, m_fieldProperties, particle).release())); if (overlapParameters) { ATH_MSG_VERBOSE(" [+] Overlap surface was hit, checking start/end surface condition."); @@ -4377,7 +4367,7 @@ Trk::Extrapolator::initializeNavigation(const EventContext& ctx, refParameters = ManagedTrackParmPtr::recapture( parm, prop.propagateParameters( - ctx, *parm, sf, dir, false, m_fieldProperties, particle, false, associatedVolume)); + ctx, *parm, sf, dir, false, m_fieldProperties, particle, false, associatedVolume).release()); // chose on projective method if (refParameters) { // check the direction on basis of a vector projection @@ -4429,7 +4419,7 @@ Trk::Extrapolator::initializeNavigation(const EventContext& ctx, refParameters = ManagedTrackParmPtr::recapture( parm, prop.propagateParameters( - ctx, *parm, sf, dir, false, m_fieldProperties, particle, false, associatedVolume)); + ctx, *parm, sf, dir, false, m_fieldProperties, particle, false, associatedVolume).release()); } // get the destination Volume if (refParameters) { @@ -4594,7 +4584,7 @@ Trk::Extrapolator::addMaterialEffectsOnTrack(const EventContext& ctx, parsOnLayer = ManagedTrackParmPtr::recapture( parms, prop.propagateParameters( - ctx, *parms, *(cs[i]), Trk::anyDirection, false, m_fieldProperties)); + ctx, *parms, *(cs[i]), Trk::anyDirection, false, m_fieldProperties).release()); if (parsOnLayer) { break; } @@ -4603,13 +4593,13 @@ Trk::Extrapolator::addMaterialEffectsOnTrack(const EventContext& ctx, parsOnLayer = ManagedTrackParmPtr::recapture( parms, prop.propagateParameters( - ctx, *parms, lay.surfaceRepresentation(), Trk::anyDirection, false, m_fieldProperties)); + ctx, *parms, lay.surfaceRepresentation(), Trk::anyDirection, false, m_fieldProperties).release()); } } else { parsOnLayer = ManagedTrackParmPtr::recapture( parms, prop.propagateParameters( - ctx, *parms, lay.surfaceRepresentation(), Trk::anyDirection, false, m_fieldProperties)); + ctx, *parms, lay.surfaceRepresentation(), Trk::anyDirection, false, m_fieldProperties).release()); } } else { parsOnLayer = parms; @@ -5318,7 +5308,7 @@ Trk::Extrapolator::extrapolateToVolumeWithPathLimit(const EventContext& ctx, path, true, false, - cache.m_currentDense))); + cache.m_currentDense).release())); if (nextPar) { ATH_MSG_DEBUG(" [+] Position after propagation - at " << positionOutput(nextPar->position())); diff --git a/Tracking/TrkExtrapolation/TrkExTools/src/Navigator.cxx b/Tracking/TrkExtrapolation/TrkExTools/src/Navigator.cxx index 591357e4341a1099e1b62e6fc45b847d2f036e39..ae653778293967d1598c142a8617b126839fa670 100755 --- a/Tracking/TrkExtrapolation/TrkExTools/src/Navigator.cxx +++ b/Tracking/TrkExtrapolation/TrkExTools/src/Navigator.cxx @@ -105,9 +105,6 @@ Trk::Navigator::initialize() { ? Trk::MagneticFieldProperties(Trk::FastField) : Trk::MagneticFieldProperties(Trk::FullField); - //This is no-op for the Navigator only relevant for - //derivated Validation for now - validationInitialize(); return StatusCode::SUCCESS; } @@ -175,10 +172,10 @@ Trk::Navigator::nextBoundarySurface(const EventContext& ctx, const Trk::Surface& currentSurface = currentBoundary->surfaceRepresentation(); - const Trk::TrackParameters* trackPar = nullptr; + //const Trk::TrackParameters* trackPar = nullptr; // do either RungeKutta (always after first unsuccessful try) or straight // line - trackPar = + auto trackPar = (!m_useStraightLineApproximation || tryBoundary > 1) ? prop.propagateParameters( ctx, parms, currentSurface, searchDir, true, m_fieldProperties) @@ -188,8 +185,7 @@ Trk::Navigator::nextBoundarySurface(const EventContext& ctx, if (trackPar) { ATH_MSG_VERBOSE( " [N] --> next BoundarySurface found with Parameters: " << *trackPar); - validationFill(trackPar); - delete trackPar; + //delete trackPar; return currentBoundary; } } @@ -284,11 +280,11 @@ Trk::Navigator::nextTrackingVolume(const EventContext& ctx, trackPar = (!m_useStraightLineApproximation || tryBoundary > 1) ? prop.propagateParameters( - ctx, parms, currentSurface, searchDir, true, m_fieldProperties) + ctx, parms, currentSurface, searchDir, true, m_fieldProperties).release() : prop.propagateParameters( - ctx, parms, currentSurface, searchDir, true, s_zeroMagneticField); + ctx, parms, currentSurface, searchDir, true, s_zeroMagneticField).release(); } else { - trackPar = parms.clone(); + trackPar = parms.clone(); //to be revisited } if (trackPar) { // the next volume pointer @@ -310,7 +306,6 @@ Trk::Navigator::nextTrackingVolume(const EventContext& ctx, '\t' << '\t' << (nextVolume ? nextVolume->volumeName() : "None")); } - validationFill(trackPar); return Trk::NavigationCell( nextVolume, trackPar, Trk::BoundarySurfaceFace(surface_id)); } @@ -399,7 +394,7 @@ Trk::Navigator::nextDenseTrackingVolume( path, false, false, - &vol); + &vol).release(); // if (nextPar) throwIntoGarbageBin(nextPar); if (nextPar) { Amg::Vector3D gp = nextPar->position(); diff --git a/Tracking/TrkExtrapolation/TrkExTools/src/TimedExtrapolator.cxx b/Tracking/TrkExtrapolation/TrkExTools/src/TimedExtrapolator.cxx index 361dc3b0aedab8f80f1d88e7e2e7ca14abbf644b..439cfa421f391ac9466359665c41743090a9aa00 100644 --- a/Tracking/TrkExtrapolation/TrkExTools/src/TimedExtrapolator.cxx +++ b/Tracking/TrkExtrapolation/TrkExTools/src/TimedExtrapolator.cxx @@ -814,7 +814,7 @@ Trk::TimedExtrapolator::extrapolateToVolumeWithPathLimit( // m_stepPropagator->propagateT(*currPar,cache.m_navigSurfs,dir,*cache.m_currentDense,particle,solutions,cache.m_path,timeLim,true); const Trk::TrackParameters *nextPar = m_stepPropagator->propagateT(*currPar, cache.m_navigSurfs, dir, m_fieldProperties, particle, solutions, cache.m_path, timeLim, true, - cache.m_currentDense, cache.m_hitVector); + cache.m_currentDense, cache.m_hitVector).release(); ATH_MSG_VERBOSE(" [+] Propagation done. "); if (nextPar) { ATH_MSG_DEBUG(" [+] Position after propagation - at " << positionOutput( @@ -1172,7 +1172,7 @@ Trk::TimedExtrapolator::overlapSearch(Trk::TimedExtrapolator::Cache &cache, detParameters = (&parm); } else if (detSurface) { // detParameters = prop.propagate(parm, *detSurface, dir, false, tvol, particle); - detParameters = prop.propagate(parm, *detSurface, dir, false, m_fieldProperties, particle); + detParameters = prop.propagate(parm, *detSurface, dir, false, m_fieldProperties, particle).release(); } // set the surface hit to true, it is anyway overruled @@ -1232,7 +1232,7 @@ Trk::TimedExtrapolator::overlapSearch(Trk::TimedExtrapolator::Cache &cache, Trk::anyDirection, true, m_fieldProperties, - particle); + particle).release(); if (overlapParameters) { ATH_MSG_VERBOSE(" [+] Overlap surface was hit, checking start/end surface condition."); @@ -2534,7 +2534,7 @@ Trk::TimedExtrapolator::extrapolateInAlignableTV(Trk::TimedExtrapolator::Cache & // curvilinear on return, current TG volume const Trk::TrackParameters *nextPar = m_stepPropagator->propagateT(*currPar, cache.m_navigSurfs, dir, m_fieldProperties, particle, solutions, cache.m_path, timeLim, true, - cache.m_currentDense, cache.m_hitVector); + cache.m_currentDense, cache.m_hitVector).release(); ATH_MSG_VERBOSE(" [+] Propagation done. "); if (nextPar) { ATH_MSG_DEBUG(" [+] Position after propagation - at " << positionOutput(nextPar->position())); diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfExtrapolator.cxx b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfExtrapolator.cxx index 48f106874d756558a64cbdb11e696544199a1a2c..7864fa861e19da354f4812496bd365194efc638b 100644 --- a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfExtrapolator.cxx +++ b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfExtrapolator.cxx @@ -330,7 +330,7 @@ Trk::GsfExtrapolator::extrapolateImpl( // parameters has increased combinedState = currentState->begin()->first.get(); - const TrackParameters* parametersAtDestination = + auto parametersAtDestination = currentPropagator->propagateParameters(ctx, *combinedState, surface, @@ -341,7 +341,7 @@ Trk::GsfExtrapolator::extrapolateImpl( Amg::Vector3D newDestination; if (parametersAtDestination) { newDestination = parametersAtDestination->position(); - delete parametersAtDestination; + //delete parametersAtDestination; } else { ATH_MSG_DEBUG("Distance check propagation Failed. Using surface center"); newDestination = surface.center(); @@ -1334,14 +1334,14 @@ Trk::GsfExtrapolator::multiStatePropagate( "propagated... continuing"); continue; } - Trk::TrackParameters* propagatedParameters = + auto propagatedParameters = propagator.propagate(ctx, *currentParameters, surface, direction, boundaryCheck, m_fieldProperties, - particleHypothesis); + particleHypothesis).release(); if (!propagatedParameters) { ATH_MSG_DEBUG("Propagation of component failed... continuing"); continue; @@ -1463,7 +1463,7 @@ Trk::GsfExtrapolator::initialiseNavigation( referenceParameters = currentVolume ? propagator.propagateParameters( - ctx, *combinedState, surface, direction, false, m_fieldProperties) + ctx, *combinedState, surface, direction, false, m_fieldProperties).release() : nullptr; // These parameters will need to be deleted later. Add to list of garbage to // be collected @@ -1497,7 +1497,7 @@ Trk::GsfExtrapolator::initialiseNavigation( referenceParameters = currentVolume ? propagator.propagateParameters( - ctx, *combinedState, surface, direction, false, m_fieldProperties) + ctx, *combinedState, surface, direction, false, m_fieldProperties).release() : nullptr; // These parameters will need to be deleted later. Add to list of garbage // to be collected @@ -1511,7 +1511,7 @@ Trk::GsfExtrapolator::initialiseNavigation( referenceParameters = currentVolume ? propagator.propagateParameters( - ctx, *combinedState, surface, direction, false, m_fieldProperties) + ctx, *combinedState, surface, direction, false, m_fieldProperties).release() : nullptr; // These parameters will need to be deleted later. Add to list of garbage // to be collected @@ -1641,7 +1641,7 @@ Trk::GsfExtrapolator::radialDirectionCheck( // boundary surface const Trk::Surface& insideSurface = (boundarySurfaces[Trk::tubeInnerCover].get())->surfaceRepresentation(); - const Trk::TrackParameters* parsOnInsideSurface = + auto parsOnInsideSurface = prop.propagateParameters(ctx, *(startParm.begin()->first), insideSurface, @@ -1664,7 +1664,7 @@ Trk::GsfExtrapolator::radialDirectionCheck( } // memory cleanup (no garbage bin, this is faster) - delete parsOnInsideSurface; + //delete parsOnInsideSurface; ATH_MSG_DEBUG(" Check radial direction: distance layer / boundary = " << distToLayer << " / " << distToInsideSurface); // the intersection with the original layer is valid if it is before the diff --git a/Tracking/TrkFitter/TrkGlobalChi2Fitter/src/GlobalChi2Fitter.cxx b/Tracking/TrkFitter/TrkGlobalChi2Fitter/src/GlobalChi2Fitter.cxx index ac86cd8fcdfd39588ead947c025bb89e4800cbc4..3faa795a926bb358dbbdecdf72c84e82dd172ff9 100644 --- a/Tracking/TrkFitter/TrkGlobalChi2Fitter/src/GlobalChi2Fitter.cxx +++ b/Tracking/TrkFitter/TrkGlobalChi2Fitter/src/GlobalChi2Fitter.cxx @@ -690,8 +690,7 @@ namespace Trk { } const Surface *matsurf = &meff->associatedSurface(); - tmppar.reset( - m_propagator->propagateParameters( + tmppar = m_propagator->propagateParameters( ctx, *tp_closestmuon, *matsurf, @@ -699,13 +698,12 @@ namespace Trk { false, trajectory.m_fieldprop, Trk::nonInteracting - ) - ); + ); + if (tmppar == nullptr) { propdir = !firstismuon ? Trk::alongMomentum : oppositeMomentum; - tmppar.reset( - m_propagator->propagateParameters( + tmppar=m_propagator->propagateParameters( ctx, *tp_closestmuon, *matsurf, @@ -713,8 +711,8 @@ namespace Trk { false, trajectory.m_fieldprop, Trk::nonInteracting - ) - ); + ); + } if (tmppar == nullptr) { @@ -826,7 +824,7 @@ namespace Trk { lastidpar = uclone(origlastidpar); } - firstscatpar.reset(m_propagator->propagateParameters( + firstscatpar= m_propagator->propagateParameters( ctx, *(firstismuon ? tp_closestmuon.get() : lastidpar.get()), calomeots[0].associatedSurface(), @@ -834,13 +832,13 @@ namespace Trk { false, trajectory.m_fieldprop, Trk::nonInteracting - )); + ); if (firstscatpar == nullptr) { return nullptr; } - lastscatpar.reset(m_propagator->propagateParameters( + lastscatpar = m_propagator->propagateParameters( ctx, *(firstismuon ? firstidpar : tp_closestmuon), calomeots[2].associatedSurface(), @@ -848,7 +846,7 @@ namespace Trk { false, trajectory.m_fieldprop, Trk::nonInteracting - )); + ); if (lastscatpar == nullptr) { return nullptr; @@ -896,7 +894,7 @@ namespace Trk { PropDirection propdir = !firstismuon ? oppositeMomentum : alongMomentum; TransportJacobian *tmp_jac1 = jac1.get(); - tmpelosspar.reset(m_propagator->propagateParameters( + tmpelosspar = m_propagator->propagateParameters( ctx, *tmppar1, calomeots[1]. @@ -906,7 +904,7 @@ namespace Trk { trajectory.m_fieldprop, tmp_jac1, Trk::nonInteracting - )); + ); if (jac1.get() != tmp_jac1) jac1.reset(tmp_jac1); if (m_numderiv) { @@ -1333,14 +1331,14 @@ namespace Trk { ); if (!firstismuon) { - firstscatpar.reset(m_propagator->propagateParameters( + firstscatpar = m_propagator->propagateParameters( ctx, *lastidpar, calomeots[0].associatedSurface(), Trk::alongMomentum, false, trajectory.m_fieldprop, - Trk::nonInteracting)); + Trk::nonInteracting); if (!firstscatpar) { return nullptr; @@ -1382,21 +1380,20 @@ namespace Trk { ) ); - lastscatpar.reset(m_propagator->propagateParameters( + lastscatpar = m_propagator->propagateParameters( ctx, *elosspar, calomeots[2].associatedSurface(), Trk::alongMomentum, false, trajectory.m_fieldprop, - Trk::nonInteracting)); + Trk::nonInteracting); if (!lastscatpar) { return nullptr; } } else { - lastscatpar.reset( - m_propagator->propagateParameters( + lastscatpar = m_propagator->propagateParameters( ctx, *firstidpar, calomeots[2].associatedSurface(), @@ -1404,15 +1401,13 @@ namespace Trk { false, trajectory.m_fieldprop, Trk::nonInteracting - ) ); if (!lastscatpar) { return nullptr; } - elosspar.reset( - m_propagator->propagateParameters( + elosspar= m_propagator->propagateParameters( ctx, *lastscatpar, calomeots[1].associatedSurface(), @@ -1420,7 +1415,6 @@ namespace Trk { false, trajectory.m_fieldprop, Trk::nonInteracting - ) ); if (!elosspar) { @@ -1440,8 +1434,7 @@ namespace Trk { ) ); - firstscatpar.reset( - m_propagator->propagateParameters( + firstscatpar = m_propagator->propagateParameters( ctx, *tmppar, calomeots[0].associatedSurface(), @@ -1449,7 +1442,6 @@ namespace Trk { false, trajectory.m_fieldprop, Trk::nonInteracting - ) ); if (!firstscatpar) { @@ -1650,8 +1642,7 @@ namespace Trk { if (((*itStates2)->trackParameters() != nullptr) && nphi > 99) { par2.reset((*itStates2)->trackParameters()->clone()); } else { - par2.reset( - m_propagator->propagateParameters( + par2 = m_propagator->propagateParameters( ctx, *secondscatstate->trackParameters(), (*itStates2)->measurementOnTrack()->associatedSurface(), @@ -1659,7 +1650,6 @@ namespace Trk { false, trajectory.m_fieldprop, Trk::nonInteracting - ) ); } @@ -4970,7 +4960,7 @@ namespace Trk { if (tmppar == nullptr) { propdir = (propdir == oppositeMomentum) ? alongMomentum : oppositeMomentum; - tmppar.reset(m_propagator->propagateParameters( + tmppar = m_propagator->propagateParameters( ctx, *nearestpar, *matsurf, @@ -4978,7 +4968,7 @@ namespace Trk { false, trajectory.m_fieldprop, Trk::nonInteracting - )); + ); if (tmppar == nullptr) { cache.m_fittercode = FitterStatusCode::ExtrapolationFailure; @@ -7077,8 +7067,7 @@ namespace Trk { } if (prevpar != nullptr) { - per.reset( - m_propagator->propagate( + per = m_propagator->propagate( ctx, *prevpar, PerigeeSurface(Amg::Vector3D(0, 0, 0)), @@ -7086,7 +7075,6 @@ namespace Trk { false, oldtrajectory.m_fieldprop, nonInteracting - ) ); } @@ -7635,16 +7623,12 @@ namespace Trk { TransportJacobian * jac = nullptr; if (calcderiv && !m_numderiv) { - rv.reset( - m_propagator->propagateParameters( + rv = m_propagator->propagateParameters( ctx, prev, *ts.surface(), propdir, false, bf, jac, Trk::nonInteracting, false - ) ); } else { - rv.reset( - m_propagator->propagateParameters( + rv = m_propagator->propagateParameters( ctx, prev, *ts.surface(), propdir, false, bf, Trk::nonInteracting, false - ) ); if (rv != nullptr && calcderiv) { @@ -8360,7 +8344,7 @@ namespace Trk { (propdir == Trk::alongMomentum) ? Trk::oppositeMomentum : Trk::alongMomentum; if (newparpluseps == nullptr) { - newparpluseps.reset( + newparpluseps = m_propagator->propagateParameters( ctx, *parpluseps, @@ -8369,11 +8353,10 @@ namespace Trk { false, fieldprop, Trk::nonInteracting - ) ); } if (newparminuseps == nullptr) { - newparminuseps.reset( + newparminuseps = m_propagator->propagateParameters( ctx, *parminuseps, @@ -8382,7 +8365,6 @@ namespace Trk { false, fieldprop, Trk::nonInteracting - ) ); } if ((newparpluseps == nullptr) || (newparminuseps == nullptr)) { diff --git a/Tracking/TrkFitter/TrkKalmanFitter/src/ForwardKalmanFitter.cxx b/Tracking/TrkFitter/TrkKalmanFitter/src/ForwardKalmanFitter.cxx index 2cbe1d48344b07286e7ed9f9be219df972c11d73..75da53b5eca7e3e960b994fc2cd39c7774e412be 100755 --- a/Tracking/TrkFitter/TrkKalmanFitter/src/ForwardKalmanFitter.cxx +++ b/Tracking/TrkFitter/TrkKalmanFitter/src/ForwardKalmanFitter.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ ////////////////////////////////////////////////////////////////// diff --git a/Tracking/TrkFitter/TrkKalmanFitter/src/ForwardRefTrackKalmanFitter.cxx b/Tracking/TrkFitter/TrkKalmanFitter/src/ForwardRefTrackKalmanFitter.cxx index 49fe75d0da93af0c0c952c5b7fdba21859c8a4c8..518c583434ff587d6099e3d5c06890f6cedc9669 100755 --- a/Tracking/TrkFitter/TrkKalmanFitter/src/ForwardRefTrackKalmanFitter.cxx +++ b/Tracking/TrkFitter/TrkKalmanFitter/src/ForwardRefTrackKalmanFitter.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ ////////////////////////////////////////////////////////////////// @@ -250,7 +250,7 @@ Trk::ForwardRefTrackKalmanFitter::fit(Trk::Trajectory& trajectory, if (allowRecalibrate && m_recalibrator && it->measurementType() == TrackState::TRT) { const AmgVector(5) x = it->referenceParameters()->parameters()+(*predDiffPar); - const Trk::TrackParameters* param = CREATE_PARAMETERS(*it->referenceParameters(),x,nullptr); + auto param = CREATE_PARAMETERS(*it->referenceParameters(),x,nullptr); Trk::TrackState::CalibrationType oldType = it->calibrationType(); // the replaceMeas.-method does ownership right and detects if the @@ -293,7 +293,7 @@ Trk::ForwardRefTrackKalmanFitter::fit(Trk::Trajectory& trajectory, // allow making of wire-hits for TRT fits with L/R-solving on the fly if ( m_recalibrator && it->measurementType() == TrackState::TRT) { const AmgVector(5) x = it->referenceParameters()->parameters()+(*predDiffPar); - const Trk::TrackParameters* param = CREATE_PARAMETERS(*it->referenceParameters(),x,nullptr); + auto param = CREATE_PARAMETERS(*it->referenceParameters(),x,nullptr); if ( Trk::SensorBoundsCheck::areParamsInside (*fittableMeasurement, param->parameters(), *predDiffCov, 1.0, -1.0)) { Trk::TrackState::CalibrationType oldType = it->calibrationType(); @@ -304,7 +304,8 @@ Trk::ForwardRefTrackKalmanFitter::fit(Trk::Trajectory& trajectory, fittableMeasurement = it->measurement(); ATH_MSG_VERBOSE ("TRT ROT calibration changed, from "<<oldType<<" to broad hit "<< it->calibrationType()<< " instead of outlier"); - delete fitQS; fitQS=nullptr; + delete fitQS; + fitQS=nullptr; updatedDifference.reset( m_updator->updateParameterDifference(*predDiffPar, *predDiffCov, *(it->measurementDifference()), @@ -319,7 +320,7 @@ Trk::ForwardRefTrackKalmanFitter::fit(Trk::Trajectory& trajectory, it->isOutlier(Trk::TrackState::StateOutlier); } } - delete param; + //delete param; } else { ATH_MSG_DEBUG ( "failed Chi2 test, remove measurement from track fit." ); it->isOutlier ( Trk::TrackState::StateOutlier ); @@ -478,14 +479,15 @@ Trk::FitterStatusCode Trk::ForwardRefTrackKalmanFitter::enterSeedIntoTrajectory return FitterStatusCode::BadInput; } - const Trk::TrackParameters* lastPropagatedPar = + auto lastPropagatedPar = CREATE_PARAMETERS((*inputParAtStartSurface), inputParAtStartSurface->parameters(), nullptr); // remove covariance for (auto it=m_utility->firstFittableState ( trajectory ); it!=trajectory.end(); ++it) { if (!it->referenceParameters()) { + //gives up ownership by default, ProtoTrackStateOnSurface takes care of deletion it->checkinReferenceParameters (lastPropagatedPar); } else { - delete lastPropagatedPar; lastPropagatedPar=nullptr; + //delete lastPropagatedPar; lastPropagatedPar=nullptr; // FIXME study this further, whether cov really not needed and how close in param // space the old and new references are. ATH_MSG_VERBOSE("At state T"<<it->positionOnTrajectory()<<" have already reference."); @@ -516,11 +518,11 @@ Trk::FitterStatusCode Trk::ForwardRefTrackKalmanFitter::enterSeedIntoTrajectory Trk::anyDirection, /*bcheck=*/ false, useFullField,jac, pathLimit, - controlledMatEffects.particleType() ); + controlledMatEffects.particleType() ).release(); if (!jac || !lastPropagatedPar) { ATH_MSG_WARNING ("lost reference track while propagating."); delete jac; - delete lastPropagatedPar; + //delete lastPropagatedPar; return FitterStatusCode::BadInput; } it->checkinTransportJacobian(jac,true); @@ -540,7 +542,7 @@ void Trk::ForwardRefTrackKalmanFitter::printGlobalParams(int istate, const std:: const AmgVector(5)& diff) const { const AmgVector(5) x = ref.parameters()+diff; - const Trk::TrackParameters* param = CREATE_PARAMETERS(ref,x,nullptr); + auto param = CREATE_PARAMETERS(ref,x,nullptr); char tt[80]; snprintf(tt,79,"T%.2d",istate); msg(MSG::VERBOSE) << tt << ptype << " GP:" << std::setiosflags(std::ios::fixed | std::ios::showpoint | std::ios::right ) diff --git a/Tracking/TrkFitter/TrkKalmanFitter/src/KalmanSmoother.cxx b/Tracking/TrkFitter/TrkKalmanFitter/src/KalmanSmoother.cxx index b27e172977494f8f732601452482f9fc3f2eda1f..afd06632c399eb4f9a99e5373d9f2880693d8418 100755 --- a/Tracking/TrkFitter/TrkKalmanFitter/src/KalmanSmoother.cxx +++ b/Tracking/TrkFitter/TrkKalmanFitter/src/KalmanSmoother.cxx @@ -345,7 +345,6 @@ Trk::FitterStatusCode Trk::KalmanSmoother::fit(Trk::Trajectory& tra Trk::Trajectory::reverse_iterator stateWithNoise = m_utility->previousFittableState(trajectory, rit); if (kalMec.doDNA() && stateWithNoise!=trajectory.rend()) { - const TrackParameters *predPar_temp=predPar.release(); const TrackParameters *updatedPar_temp=updatedPar.release(); Trk::IDynamicNoiseAdjustor::State state{};