51 ATH_CHECK ( m_entryLayerTool.retrieve() );
54 ATH_CHECK ( m_orderingTool.retrieve( DisableTool{m_orderingTool.empty()} ) );
59 m_geoIDSvcQuick = &(*m_geoIDSvc);
62 if (m_doSelectorCPUMon) {
63 if (!m_benchPDGCode) {
72 if ( m_validationOutput) {
75 ATH_CHECK( registerPosValTree(
"push_position",
76 "push() particle positions",
78 ATH_CHECK( registerPosValTree(
"caloEntry_pos",
79 "CaloEntryLayer positions",
81 ATH_CHECK( registerPosValTree(
"muonEntry_pos",
82 "MuonEntryLayer positions",
84 ATH_CHECK( registerPosValTree(
"muonExit_pos",
85 "MuonExitLayer positions",
90 return StatusCode::SUCCESS;
98 if ( simSelectorTools.retrieve().isFailure() ) {
99 ATH_MSG_FATAL( m_screenOutputPrefix <<
"Could not retrieve SimulatorSelector Tool Array. Abort.");
100 return StatusCode::FAILURE;
104 m_simSelector[geoID].reserve ( simSelectorTools.size());
110 for ( ; fSimSelIter != fSimSelIterEnd; ++fSimSelIter ) {
115 m_simSelector[geoID].push_back( curSelector);
118 return StatusCode::SUCCESS;
124 const char *treeDescr,
127 std::string
prefix =
"/" + m_validationStream +
"/";
130 tree->Branch(
"x" , &m_val_x ,
"x/F");
131 tree->Branch(
"y" , &m_val_y ,
"y/F");
132 tree->Branch(
"z" , &m_val_z ,
"z/F");
133 tree->Branch(
"p" , &m_val_p ,
"p/F");
134 tree->Branch(
"pdg", &m_val_pdg,
"pdg/I");
150 m_val_p =
p.momentum().mag();
151 m_val_pdg =
p.pdgCode();
161 for (
const auto& simSelector : m_simSelectorSet ) {
173 SimSvcID selectedSimID = identifySimID(
p);
180 <<
" to simulator with ID=" << selectedSimID <<
".");
182 p->setNextSimID( selectedSimID);
184 if ( m_orderingTool.isEnabled() ) { m_orderingTool->setOrder(*
p); }
194 if ( !m_simSelector[geoID].
size()) {
195 ATH_MSG_INFO( m_screenOutputPrefix <<
"No SimulationSelectors registered for GeoID="
199 ATH_MSG_INFO( m_screenOutputPrefix <<
"Current particle not selected by any SimulationSelector with GeoID="
217 bool selected =
false;
232 for ( ; !selected && (selectorIt != selectorItEnd) ; ++selectorIt) {
234 selected = (*selectorIt)->selfSelect( *
p);
249 ATH_MSG_DEBUG( m_screenOutputPrefix <<
"Initializing particle stack");
254 if ( !m_simSelectorSet.size() ) {
257 m_simSelectorSet.insert( m_simSelector[curGeoID].
begin(), m_simSelector[curGeoID].
end() );
260 ATH_MSG_DEBUG(
"Number of unique SimulationSelctors registered: "
261 << m_simSelectorSet.size() );
265 for (
const auto& simSelector : m_simSelectorSet ) {
266 simSelector->beginEvent();
269 m_entryLayerTool->setupEvent();
271 for (
auto& particlePointer : simParticles ) {
275 m_geoIDSvcQuick->identifyAndRegNextGeoID(
particle);
282 m_entryLayerTool->registerParticle(
particle);
285 size_t order = simParticles.size();
287 for (
auto& particlePtr: simParticles ) {
289 if (!m_orderingTool.isEnabled() ) { particlePtr->setOrder(
order--); }
291 selectAndStore(particlePtr);
294 return StatusCode::SUCCESS;
304 for ( ; fSimSelIter != fSimSelIterEnd; ++fSimSelIter )
305 (*fSimSelIter)->endEvent();
307 return StatusCode::SUCCESS;
323 ATH_MSG_WARNING(
"The provided new ISFParticle had no TruthBinding ! Copying over the one from the parent ISFParticle.");
334 geoID = m_geoIDSvcQuick->identifyAndRegNextGeoID(
particle);
340 if ( m_validationOutput ) {
342 fillPosValTree( m_t_pushPosition,
particle);
352 if ( m_validateGeoID) {
355 ATH_MSG_WARNING(
"Validating GeoID: GeoIDSvc resolves a particle's position to a different GeoID than stored in the particle:");
356 ATH_MSG_WARNING(
" assigned=" << geoID <<
" GeoIDSvc=" << identifiedGeoID);
363 ATH_MSG_ERROR( m_screenOutputPrefix <<
"Trying to push particle onto the stack with unknown geoID=" << geoID
364 <<
". Dropping this particle.");
372 selectAndStore( particlePtr );
379 ISF::ISFParticleVector::const_iterator partIt = m_popParticles.begin();
380 ISF::ISFParticleVector::const_iterator partEnd = m_popParticles.end();
381 for ( ; partIt != partEnd; ++partIt) {
385 m_popParticles.clear();
388 if ( m_particles.size() ) {
400 if ( curID != returnID || m_popParticles.size() >= maxVectorSize ) {
401 tempQueue.push(m_particles.top());
405 m_popParticles.push_back( curParticle );
409 }
while ( m_particles.size() ) ;
410 m_particles = std::move(tempQueue);
413 return m_popParticles;
420 ATH_MSG_INFO( m_screenOutputPrefix <<
"==== ISF Particle Stack Dump ====");
421 ATH_MSG_INFO( m_screenOutputPrefix <<
" 'active' particles -> ready to be simulated");
422 ATH_MSG_INFO( m_screenOutputPrefix <<
" 'onHold' particles -> no sim Selector decision yet, waiting in routing chain");
424 ATH_MSG_INFO( m_screenOutputPrefix <<
" Number of 'active' particles: " << m_particles.size());
426 ATH_MSG_INFO( m_screenOutputPrefix <<
" --- SimGeoID=" << geoID
428 ATH_MSG_INFO( m_screenOutputPrefix <<
" Routing Chain has length "
429 << m_simSelector[geoID].
size() );
431 ATH_MSG_INFO( m_screenOutputPrefix <<
"=================================");
433 return StatusCode::SUCCESS;