Skip to content
Snippets Groups Projects

Filter algorithms outside begin/end event in AlgContextSvc

Merged Sami Kama requested to merge (removed):CondSami into atlas/20.8.X/Conditions
2 files
+ 71
12
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -10,12 +10,15 @@
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/IIncidentSvc.h"
#include "GaudiKernel/ConcurrencyFlags.h"
// ============================================================================
/** @file
* Implementation firl for class AlgContextSvc
* @author ATLAS Collaboration
* @author modified by Vanya BELYAEV ibelyaev@physics.syr.edu
* @date 2007-03-05 (modified)
* @author modified by Sami Kama
* @date 2017-03-17 (modified)
*/
// ============================================================================
/** Instantiation of a static factory class used by clients to create
@@ -37,6 +40,16 @@ StatusCode AlgContextSvc::initialize ()
m_inc.reset();
}
// perform more checks?
auto numSlots=Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents();
numSlots=(1>numSlots)?1:numSlots;
if(numSlots>1000){
warning()<<"Num Slots are greater than 1000. Is this correct? numSlots="<<
numSlots<<endmsg;
numSlots=1000;
warning()<<"Setting numSlots to "<<numSlots<<endmsg;
}
m_inEvtLoop.resize(numSlots,0);
if ( m_check )
{
m_inc = Service::service ( "IncidentSvc" , true ) ;
@@ -55,6 +68,25 @@ StatusCode AlgContextSvc::initialize ()
}
return StatusCode::SUCCESS ;
}
// implementation of start
// needs to be removed once we have a proper service
// for getting configuration information at initialization time
// S. Kama
StatusCode AlgContextSvc::start(){
auto sc=Service::start();
auto numSlots=Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents();
numSlots=(1>numSlots)?1:numSlots;
if(numSlots>1000){
warning()<<"Num Slots are greater than 1000. Is this correct? numSlots="<<
numSlots<<endmsg;
numSlots=1000;
}
m_inEvtLoop.resize(numSlots,0);
return sc;
}
// ============================================================================
// standard finalization of the service @see IService
// ============================================================================
@@ -84,12 +116,17 @@ StatusCode AlgContextSvc::setCurrentAlg ( IAlgorithm* a )
warning() << "IAlgorithm* points to NULL" << endmsg ;
return StatusCode::RECOVERABLE ;
}
if(!m_bypassInc){
auto currSlot=a->getContext().slot();
if(currSlot==EventContext::INVALID_CONTEXT_ID)currSlot=0;
if(!m_inEvtLoop[currSlot]) return StatusCode::SUCCESS;
}
// check whether thread-local algorithm list already exists
// if not, create it
if ( ! m_algorithms.get()) {
m_algorithms.reset( new IAlgContextSvc::Algorithms() );
}
m_algorithms->push_back ( a ) ;
if(a->type()!="IncidentProcAlg") m_algorithms->push_back ( a ) ;
return StatusCode::SUCCESS ;
}
@@ -104,18 +141,23 @@ StatusCode AlgContextSvc::unSetCurrentAlg ( IAlgorithm* a )
m_algorithms.reset( new IAlgContextSvc::Algorithms() );
}
if ( !a )
{
if ( !a ){
warning() << "IAlgorithm* points to NULL" << endmsg ;
return StatusCode::RECOVERABLE ;
}
if ( m_algorithms->empty() || m_algorithms->back() != a )
{
error() << "Algorithm stack is invalid" << endmsg ;
return StatusCode::FAILURE ;
}
m_algorithms->pop_back() ;
if(!m_bypassInc){
auto currSlot=a->getContext().slot();
if(currSlot==EventContext::INVALID_CONTEXT_ID) currSlot=0;
if(!m_inEvtLoop[currSlot]) return StatusCode::SUCCESS;
}
if(a->type()!="IncidentProcAlg"){
if ( m_algorithms->empty() || m_algorithms->back() != a ){
error() << "Algorithm stack is invalid" << endmsg ;
return StatusCode::FAILURE ;
}
m_algorithms->pop_back() ;
}
return StatusCode::SUCCESS ;
}
// ============================================================================
@@ -130,10 +172,20 @@ IAlgorithm* AlgContextSvc::currentAlg () const
// ============================================================================
// handle incident @see IIncidentListener
// ============================================================================
void AlgContextSvc::handle ( const Incident& ) {
void AlgContextSvc::handle ( const Incident& inc ) {
//some false sharing is possible but it should be negligable
auto currSlot=inc.context().slot();
if (currSlot==EventContext::INVALID_CONTEXT_ID){
currSlot=0;
}
if(inc.type()=="BeginEvent"){
m_inEvtLoop[currSlot]=1;
}else if(inc.type()=="EndEvent"){
m_inEvtLoop[currSlot]=0;
}
if ( m_algorithms.get() && !m_algorithms->empty() ) {
//skip incident processing algorithm endevent incident
if((m_algorithms->size()!=1) || ((m_algorithms->back()->type()!="IncidentProcAlg") && (m_algorithms->back()->type()!="AthIncFirerAlg"))){
if((m_algorithms->size()!=1) || (m_algorithms->back()->type()!="IncidentProcAlg")){
error() << "Non-empty stack of algorithms #"
<< m_algorithms->size() << endmsg ;
}
Loading