Skip to content
Snippets Groups Projects
Commit d1d131bc authored by Attila Krasznahorkay's avatar Attila Krasznahorkay
Browse files

Fixed a logic error in xAOD::TEvent::fill().

The loop over TEvent::m_outputObjects was unsafe so far. Since the
loop could add new elements to the container itself. Making the loop
miss some elements of the container. See ATLASG-1555 for a longer
description.
parent 0f978791
No related branches found
No related tags found
No related merge requests found
...@@ -1429,30 +1429,32 @@ namespace xAOD { ...@@ -1429,30 +1429,32 @@ namespace xAOD {
} }
} }
// Prepare the objects for writing: // Prepare the objects for writing. Note that we need to iterate over a
// copy of the m_outputObjects container. Since the putAux(...) function
// called inside the loop may itself add elements to the m_outputObject
// container.
std::string unsetObjects; std::string unsetObjects;
Object_t::const_iterator itr = m_outputObjects.begin(); Object_t outputObjectsCopy = m_outputObjects;
Object_t::const_iterator end = m_outputObjects.end(); for( auto& itr : outputObjectsCopy ) {
for( ; itr != end; ++itr ) {
// Check that a new object was provided in the event: // Check that a new object was provided in the event:
if( ! itr->second->isSet() ) { if( ! itr.second->isSet() ) {
// We are now going to fail. But let's collect the names of // We are now going to fail. But let's collect the names of
// all the unset objects: // all the unset objects:
if( unsetObjects.size() ) { if( unsetObjects.size() ) {
unsetObjects.append( ", \"" + itr->first + "\"" ); unsetObjects.append( ", \"" + itr.first + "\"" );
} else { } else {
unsetObjects.append( "\"" + itr->first + "\"" ); unsetObjects.append( "\"" + itr.first + "\"" );
} }
continue; continue;
} }
// Make sure that any dynamic auxiliary variables that // Make sure that any dynamic auxiliary variables that
// were added to the object after it was put into the event, // were added to the object after it was put into the event,
// get added to the output: // get added to the output:
if( ! putAux( *m_outTree, *( itr->second ) ) ) { if( ! putAux( *m_outTree, *( itr.second ) ) ) {
::Error( "xAOD::TEvent::fill", ::Error( "xAOD::TEvent::fill",
XAOD_MESSAGE( "Failed to put dynamic auxiliary variables " XAOD_MESSAGE( "Failed to put dynamic auxiliary variables "
"in the output for object \"%s\"" ), "in the output for object \"%s\"" ),
itr->first.c_str() ); itr.first.c_str() );
return 0; return 0;
} }
} }
...@@ -2235,7 +2237,7 @@ namespace xAOD { ...@@ -2235,7 +2237,7 @@ namespace xAOD {
// If not, update the output manager. This can happen when we copy // If not, update the output manager. This can happen when we copy
// objects from the input to the output files, and we process // objects from the input to the output files, and we process
// multiple input files. // multiple input files.
// Check if the output manager is of the right type: // Check if the output manager is of the right type:
TAuxManager* mgr = dynamic_cast< TAuxManager* >( vitr->second ); TAuxManager* mgr = dynamic_cast< TAuxManager* >( vitr->second );
if( ! mgr ) { if( ! mgr ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment