8 #include "GaudiKernel/MsgStream.h"
17 m_selectionTool(
"InDet::InDetAmbiTrackSelectionTool/InDetAmbiTrackSelectionTool")
19 declareInterface<ITrackAmbiguityProcessorTool>(
this);
34 return StatusCode::FAILURE;
36 ATH_CHECK( m_assoMapName.initialize(!m_assoMapName.key().empty()));
41 ATH_CHECK(m_clusterSplitProbContainerIn.initialize(!m_clusterSplitProbContainerIn.key().empty()));
42 ATH_CHECK(m_clusterSplitProbContainerOut.initialize(!m_clusterSplitProbContainerOut.key().empty()));
44 if (m_disableSorting)
ATH_MSG_DEBUG(
"Internal sorting disabled, using external ordering!" );
64 std::vector<const Track*> tracks;
65 tracks.reserve(tracksCol->
size());
66 for(
const auto *
e: *tracksCol){
70 std::unique_ptr<Trk::PRDtoTrackMap> tmpPrdToTrackMap;
71 if (!pPrdToTrackMap) {
72 tmpPrdToTrackMap = m_assoTool->createPRDtoTrackMap();
73 if (!m_assoMapName.key().empty()) {
76 ATH_MSG_ERROR(
"Failed to retrieve prd to track map " << m_assoMapName.key() );
78 *tmpPrdToTrackMap = *inputPrdMap;
81 pPrdToTrackMap = tmpPrdToTrackMap.get();
85 addNewTracks(trackScoreTrackMap,*pPrdToTrackMap, tracks);
93 return result.release()->asDataVector();
101 const std::vector<const Track*> &tracks)
const{
102 ATH_MSG_DEBUG (
"Number of tracks at Input: "<<tracks.size());
105 for (
const Track*a_track : tracks ) {
106 if(m_disableSorting) {
108 trackScoreTrackMap.insert( std::make_pair(itrack,
TrackPtr(a_track)) );
120 const std::vector<const Trk::PrepRawData*> & prds = m_assoTool->getPrdsOnTrack(prdToTrackMap, *a_track);
123 prdSig.insert( prds.begin(),prds.end() );
125 if ( !(prdSigSet.insert(prdSig)).second ) {
136 trackScoreTrackMap.insert( std::make_pair(-
score,
TrackPtr(a_track) ) );
139 ATH_MSG_DEBUG (
"Number of tracks in map:"<<trackScoreTrackMap.size());
149 const EventContext& ctx = Gaudi::Hive::currentContext();
151 if (!m_clusterSplitProbContainerIn.key().empty()) {
152 splitProbContainerIn =
SG::ReadHandle( m_clusterSplitProbContainerIn, ctx);
153 if (!splitProbContainerIn.
isValid()) {
154 ATH_MSG_ERROR(
"Failed to get input cluster split probability container " << m_clusterSplitProbContainerIn.key());
157 std::unique_ptr<Trk::ClusterSplitProbabilityContainer> splitProbContainerCleanup(!m_clusterSplitProbContainerIn.key().empty()
158 ? std::make_unique<ClusterSplitProbabilityContainer>(*splitProbContainerIn)
159 : std::make_unique<ClusterSplitProbabilityContainer>());
162 if (!m_clusterSplitProbContainerOut.key().empty()) {
164 if (splitProbContainerHandle.
record(std::move(splitProbContainerCleanup)).isFailure()) {
165 ATH_MSG_FATAL(
"Failed to record output cluster split probability container " << m_clusterSplitProbContainerOut.key());
167 splitProbContainer=splitProbContainerHandle.
ptr();
170 splitProbContainer=splitProbContainerCleanup.get();
175 while ( !trackScoreTrackMap.empty() ) {
177 TrackPtr atrack( std::move(itnext->second) );
179 trackScoreTrackMap.erase(itnext);
181 std::unique_ptr<Trk::Track> cleanedTrack;
182 const auto &[cleanedTrack_tmp, keepOriginal] = m_selectionTool->getCleanedOutTrack( atrack.
track() , -(ascore), *splitProbContainer, prdToTrackMap, -1, -1);
183 cleanedTrack.reset(cleanedTrack_tmp);
188 StatusCode sc = m_assoTool->addPRDs(prdToTrackMap,*atrack);
193 }
else if ( !cleanedTrack ) {
195 ATH_MSG_DEBUG (
"Track "<< atrack.
track() <<
" doesn't meet the cuts of the AmbiTrack Selection tool");
198 cleanedTrack.reset();
200 ATH_MSG_DEBUG(
"Selection tool returned a new track, cannot handle memory management of new track, deleting it. Check you configuration ");
216 for (;
it != itEnd ; ++
it){