25 declareInterface<Trk::IPRD_TruthTrajectoryBuilder>(
this);
35 ATH_MSG_ERROR (
"Could not get AtlasDetectorID helper. Arborting ...");
36 return StatusCode::FAILURE;
39 if ( !m_idPrdProvider.empty() && m_idPrdProvider.retrieve().isFailure()){
40 ATH_MSG_ERROR (
"Could not get " << m_idPrdProvider <<
". Arborting ..." );
41 return StatusCode::FAILURE;
44 if ( !m_msPrdProvider.empty() && m_msPrdProvider.retrieve().isFailure()){
45 ATH_MSG_ERROR (
"Could not get " << m_msPrdProvider <<
". Arborting ..." );
46 return StatusCode::FAILURE;
49 if ( !m_prdTruthTrajectoryManipulators.empty() && m_prdTruthTrajectoryManipulators.retrieve().isFailure()){
50 ATH_MSG_ERROR (
"Could not get configured " << m_prdTruthTrajectoryManipulators <<
". Arborting ..." );
51 return StatusCode::FAILURE;
54 ATH_CHECK( m_prdMultiTruthCollectionNames.initialize() );
56 return StatusCode::SUCCESS;
61 ATH_MSG_INFO(
"Calling refreshEvent() to reset cache and retrieve collections");
63 m_prdMultiTruthCollections.clear();
64 m_prdMultiTruthCollections.reserve(m_prdMultiTruthCollectionNames.size());
66 for(
const auto& pmtCollNameIter:m_prdMultiTruthCollectionNames){
70 ATH_MSG_WARNING(
"Could not retrieve " << pmtCollNameIter <<
". Ignoring ... ");
73 ATH_MSG_INFO(
"Added " << pmtCollNameIter <<
" to collection list for truth track creation.");
74 m_prdMultiTruthCollections.push_back(curColl.
cptr());
78 return StatusCode::SUCCESS;
87 std::map< HepMC::ConstGenParticlePtr, PRD_TruthTrajectory > gpPrdTruthTrajectories;
91 std::vector<const PRD_MultiTruthCollection*>::const_iterator pmtCollIter = m_prdMultiTruthCollections.begin();
92 std::vector<const PRD_MultiTruthCollection*>::const_iterator pmtCollIterE = m_prdMultiTruthCollections.end();
93 for ( ; pmtCollIter != pmtCollIterE; ++pmtCollIter ){
95 PRD_MultiTruthCollection::const_iterator prdMtCIter = (*pmtCollIter)->begin();
96 PRD_MultiTruthCollection::const_iterator prdMtCIterE = (*pmtCollIter)->end();
97 for ( ; prdMtCIter != prdMtCIterE; ++ prdMtCIter ){
106 Identifier curIdentifier = (*prdMtCIter).first;
108 if ( curGenP->momentum().perp() < m_minPt )
continue;
110 if (!m_geantinos && std::abs(curGenP->pdg_id())==999)
continue;
113 m_idPrdProvider->prdFromIdentifier(curIdentifier,
ndof) : m_msPrdProvider->prdFromIdentifier(curIdentifier,
ndof);
117 auto prdTrajIter = gpPrdTruthTrajectories.find(curGenP);
118 if ( prdTrajIter == gpPrdTruthTrajectories.end() ){
121 newPrdTruthTrajectory.
prds.push_back(prd);
122 newPrdTruthTrajectory.
nDoF =
ndof-5;
126 gpPrdTruthTrajectories[curGenP] = newPrdTruthTrajectory;
130 (prdTrajIter->second).prds.push_back(prd);
131 (prdTrajIter->second).nDoF +=
ndof;
132 ndofTotal = (prdTrajIter->second).nDoF;
134 ATH_MSG_DEBUG(
" Associating PRD with " <<
ndof <<
" degrees of freedom, total N.d.o.F : " << ndofTotal );
135 ATH_MSG_DEBUG(
" Associating Identifier " << curIdentifier <<
" with particle at [ " << curGenP <<
" ]." );
136 std::string prdtype = m_idHelper->is_pixel(curIdentifier) ?
"Pixel" : m_idHelper->is_sct(curIdentifier) ?
"SCT" :
"TRT";
139 std::string prdtype = m_idHelper->is_pixel(curIdentifier) ?
"Pixel" : m_idHelper->is_sct(curIdentifier) ?
"SCT" :
"TRT";
146 auto prdTruthTrajIter = gpPrdTruthTrajectories.begin();
147 auto prdTruthTrajIterE = gpPrdTruthTrajectories.end();
148 for ( ; prdTruthTrajIter != prdTruthTrajIterE; ++prdTruthTrajIter ){
149 if ( !m_prdTruthTrajectoryManipulators.empty() ){
150 ToolHandleArray<IPRD_TruthTrajectoryManipulator>::const_iterator prdTTMIter = m_prdTruthTrajectoryManipulators.begin();
151 ToolHandleArray<IPRD_TruthTrajectoryManipulator>::const_iterator prdTTMIterE = m_prdTruthTrajectoryManipulators.end();
152 for ( ; prdTTMIter != prdTTMIterE; ++prdTTMIter ){
153 if ((*prdTTMIter)->manipulateTruthTrajectory((*prdTruthTrajIter).second))
154 ATH_MSG_DEBUG(
"PRD truth trajectory got manipulated by: " << (*prdTTMIter).name() );
159 return gpPrdTruthTrajectories;
165 m_prdMultiTruthCollections.clear();
166 return StatusCode::SUCCESS;