diff --git a/Control/GaudiSequencer/src/AthEventCounter.cxx b/Control/GaudiSequencer/src/AthEventCounter.cxx index 93b1135dde40aa76ef48d031a387e9208b1153cb..f35878fadc73447f001521c9a58f021e4f74bdbe 100644 --- a/Control/GaudiSequencer/src/AthEventCounter.cxx +++ b/Control/GaudiSequencer/src/AthEventCounter.cxx @@ -10,26 +10,7 @@ /////////////////////////////////////////////////////////////////// #include "AthEventCounter.h" - -/** - ** Constructor(s) - **/ -AthEventCounter::AthEventCounter(const std::string& name, ISvcLocator* pSvcLocator) : - AthAlgorithm( name, pSvcLocator ), - m_skip ( 0 ), - m_total( 0 ) -{ - declareProperty( "Frequency", m_frequency=1, - "The frequency with which the number of events should be " - "reported. The default is 1, corresponding to every event" ); - m_frequency.verifier().setBounds( 0, 1000 ); -} - -/** - ** Destructor - **/ -AthEventCounter::~AthEventCounter( ) -{} +#include <cstdlib> StatusCode AthEventCounter::initialize() @@ -39,16 +20,17 @@ AthEventCounter::initialize() } StatusCode -AthEventCounter::execute() +AthEventCounter::execute(const EventContext& ) const { - m_total++; - int freq = m_frequency; - if ( freq > 0 ) { - m_skip++; - if ( m_skip >= freq ) { - ATH_MSG_INFO ("execute ==> seen events: " << m_total); - m_skip = 0; - } + int currTotal=(m_total++); + if (m_frequency==0) { + return StatusCode::SUCCESS; + } + + int rem=std::div(currTotal,m_frequency).rem; + + if (rem==0) { + ATH_MSG_INFO ("execute ==> seen events: " << currTotal); } return StatusCode::SUCCESS; } diff --git a/Control/GaudiSequencer/src/AthEventCounter.h b/Control/GaudiSequencer/src/AthEventCounter.h index eda3a324da6f4f035e03fb5639dd90bb6ead931e..573ee85aac477f64cc51e0ea7fd63ac91caa7928 100644 --- a/Control/GaudiSequencer/src/AthEventCounter.h +++ b/Control/GaudiSequencer/src/AthEventCounter.h @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // AthEventCounter.h @@ -11,29 +11,23 @@ #ifndef GAUDISEQUENCER_ATHEVENTCOUNTER_H #define GAUDISEQUENCER_ATHEVENTCOUNTER_H -#include "AthenaBaseComps/AthAlgorithm.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" #include "Gaudi/Property.h" +#include <atomic> -class AthEventCounter : public AthAlgorithm +class AthEventCounter : public AthReentrantAlgorithm { public: - /** - ** Constructor(s) - **/ - AthEventCounter( const std::string& name, ISvcLocator* pSvcLocator ); - - /** - ** Destructor - **/ - ~AthEventCounter( ); + using AthReentrantAlgorithm::AthReentrantAlgorithm; + ~AthEventCounter( ) = default; /***************************** ** Public Function Members ** *****************************/ StatusCode initialize(); - StatusCode execute(); + StatusCode execute(const EventContext& ctx) const ; StatusCode finalize(); private: @@ -47,18 +41,14 @@ private: ** should be reported. The default is 1, corresponding ** to every event. **/ - Gaudi::CheckedProperty<int> m_frequency; - - /** - ** The number of events skipped since the last time - ** the count was reported. - **/ - int m_skip; + Gaudi::Property<int> m_frequency{this, "Frequency", 1, + "The frequency with which the number of events should be " + "reported. The default is 1, corresponding to every event" }; /** ** The total events seen. **/ - int m_total; + mutable std::atomic<int> m_total{0}; }; #endif // GAUDISEQUENCER_ATHEVENTCOUNTER_H diff --git a/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py b/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py index 7548b782cd656c2d5f20c797041c92f2ae93b11c..f28933f2cb8dc6010bea12025468a04d36bfafef 100644 --- a/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py +++ b/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py @@ -419,13 +419,13 @@ if rec.doJiveXML() and DetFlags.detdescr.ID_on() : # put quasi empty first algorithm so that the first real # algorithm does not see the memory change due to event manipulation #from AthenaPoolTools.AthenaPoolToolsConf import EventCounter -from GaudiAlg.GaudiAlgConf import EventCounter - +#from GaudiAlg.GaudiAlgConf import EventCounter +from GaudiSequencer.GaudiSequencerConf import AthEventCounter as EventCounter import PerfMonComps.DomainsRegistry as pdr pdr.flag_domain('admin') # one print every 100 event -topSequence+=EventCounter(Frequency=100) +topSequence+=EventCounter("EventCounter",Frequency=100) #Temporary: Schedule conversion algorithm for EventInfo object: # Note that we need to check whether the HLT already added this algorithm to the