diff --git a/Trigger/TrigAlgorithms/TrigGenericAlgs/src/RandomErrorAlg.cxx b/Trigger/TrigAlgorithms/TrigGenericAlgs/src/RandomErrorAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..865caab3f8e4c8127ad335e52dbd36b5b7c4cb58 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigGenericAlgs/src/RandomErrorAlg.cxx @@ -0,0 +1,24 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include <random> + +#include "RandomErrorAlg.h" + +RandomErrorAlg::RandomErrorAlg(const std::string& name, ISvcLocator* pSvcLocator) + : AthReentrantAlgorithm(name, pSvcLocator) {} + +StatusCode RandomErrorAlg::execute(const EventContext& /*eventContext*/) const { + + static thread_local std::random_device rd; + static thread_local std::default_random_engine generator (rd()); + std::uniform_real_distribution<double> distribution (0., 1.); + + if ( distribution(generator) < m_errorProbability ) { + ATH_MSG_ERROR("Returning random StatusCode::FAILURE"); + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} diff --git a/Trigger/TrigAlgorithms/TrigGenericAlgs/src/RandomErrorAlg.h b/Trigger/TrigAlgorithms/TrigGenericAlgs/src/RandomErrorAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..531310535877412e19f4f47cb4dce9ff2d5ca0ec --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigGenericAlgs/src/RandomErrorAlg.h @@ -0,0 +1,25 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGGENERICALGS_RandomError_h +#define TRIGGENERICALGS_RandomError_h + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" + +/** + * @class RandomError + * @brief Throw an error with given probability + **/ +class RandomErrorAlg : public AthReentrantAlgorithm { + public: + + RandomErrorAlg(const std::string& name, ISvcLocator* svcLoc); + + virtual StatusCode execute(const EventContext& eventContext) const override; + + private: + Gaudi::Property<double> m_errorProbability {this, "ErrorProbability", 0.5, "Probablility od throwing an error"}; +}; + +#endif // TRIGGENERICALGS_RandomError_h diff --git a/Trigger/TrigAlgorithms/TrigGenericAlgs/src/components/TrigGenericAlgs_entries.cxx b/Trigger/TrigAlgorithms/TrigGenericAlgs/src/components/TrigGenericAlgs_entries.cxx index 698e263873daeab2f4c6cfcfbc3aea834c2eb3b9..514e572e0568c9b02fa5749d78530fb08550ce01 100644 --- a/Trigger/TrigAlgorithms/TrigGenericAlgs/src/components/TrigGenericAlgs_entries.cxx +++ b/Trigger/TrigAlgorithms/TrigGenericAlgs/src/components/TrigGenericAlgs_entries.cxx @@ -13,6 +13,7 @@ #include "../TrigRoiUpdater.h" #include "../MergeTopoStarts.h" #include "../AcceptL1TopoMonitor.h" +#include "../RandomErrorAlg.h" DECLARE_COMPONENT( DummyFEX ) DECLARE_COMPONENT( PESA::DummyUnseededAllTEAlgo ) @@ -29,3 +30,4 @@ DECLARE_COMPONENT( PESA::SeededSuperRoiAllTEAlgo ) DECLARE_COMPONENT( PESA::TrigRoiUpdater ) DECLARE_COMPONENT( MergeTopoStarts ) DECLARE_COMPONENT( AcceptL1TopoMonitor ) +DECLARE_COMPONENT( RandomErrorAlg ) diff --git a/Trigger/TrigMonitoring/TrigSteerMonitor/src/TrigErrorMonTool.cxx b/Trigger/TrigMonitoring/TrigSteerMonitor/src/TrigErrorMonTool.cxx index 52263624a1264b6c432d25d35fe1e8bac19c2530..a4f7d9e4c7f250f1540545be5992ea0f97e80318 100644 --- a/Trigger/TrigMonitoring/TrigSteerMonitor/src/TrigErrorMonTool.cxx +++ b/Trigger/TrigMonitoring/TrigSteerMonitor/src/TrigErrorMonTool.cxx @@ -15,6 +15,7 @@ TrigErrorMonTool::TrigErrorMonTool(const std::string& type, const std::string& n // ============================================================================= StatusCode TrigErrorMonTool::initialize() { ATH_CHECK(m_monTool.retrieve(DisableTool{m_monTool.name().empty()})); + ATH_CHECK(m_algToChainTool.retrieve(DisableTool{m_algToChainTool.name().empty()})); ATH_CHECK(m_aess.retrieve()); return StatusCode::SUCCESS; } @@ -24,6 +25,7 @@ StatusCode TrigErrorMonTool::initialize() { // ============================================================================= StatusCode TrigErrorMonTool::finalize() { ATH_CHECK(m_monTool.release()); + ATH_CHECK(m_algToChainTool.release()); ATH_CHECK(m_aess.release()); return StatusCode::SUCCESS; } @@ -41,6 +43,16 @@ std::unordered_map<std::string_view, StatusCode> TrigErrorMonTool::algExecErrors auto monErrorAlgName = Monitored::Scalar<std::string>("ErrorAlgName", key.str()); auto monErrorCode = Monitored::Scalar<std::string>("ErrorCode", state.execStatus().message()); auto mon = Monitored::Group(m_monTool, monErrorAlgName, monErrorCode); + + if (m_algToChainTool.isEnabled()) { + std::set<std::string> chainNames = m_algToChainTool->getActiveChainsForAlg(key.str(), eventContext); + // Monitored::Collection requires operator[] + std::vector<std::string> chainNamesVec(chainNames.begin(), chainNames.end()); + + auto monErrorChainNames= Monitored::Collection<std::vector<std::string>>("ErrorChainName", chainNamesVec); + Monitored::Group(m_monTool, monErrorChainNames, monErrorCode); + } + } } return algErrors; diff --git a/Trigger/TrigMonitoring/TrigSteerMonitor/src/TrigErrorMonTool.h b/Trigger/TrigMonitoring/TrigSteerMonitor/src/TrigErrorMonTool.h index ebbbe1ddd40afa51268493b13f0bd8209074a087..b3f1c752b8d463196b5861117e916231a267390a 100644 --- a/Trigger/TrigMonitoring/TrigSteerMonitor/src/TrigErrorMonTool.h +++ b/Trigger/TrigMonitoring/TrigSteerMonitor/src/TrigErrorMonTool.h @@ -8,6 +8,7 @@ #include "AthenaBaseComps/AthAlgTool.h" #include "AthenaMonitoringKernel/Monitored.h" #include "GaudiKernel/EventContext.h" +#include "TrigCompositeUtils/AlgToChainTool.h" class IAlgExecStateSvc; @@ -30,6 +31,7 @@ public: private: ServiceHandle<IAlgExecStateSvc> m_aess{this, "AlgExecStateSvc", "AlgExecStateSvc"}; ToolHandle<GenericMonitoringTool> m_monTool{this, "MonTool", "", "Monitoring tool"}; + ToolHandle<TrigCompositeUtils::AlgToChainTool> m_algToChainTool {this, "AlgToChainTool", "", "Tool to retrieve chains for algorithm"}; }; diff --git a/Trigger/TrigSteer/TrigCompositeUtils/Root/AlgToChainTool.cxx b/Trigger/TrigSteer/TrigCompositeUtils/Root/AlgToChainTool.cxx index 91c6e8acd60a228f0590169342576c3f13018a97..1a1bff3b2d3fd146a9e39013b432fc06c9456ad4 100644 --- a/Trigger/TrigSteer/TrigCompositeUtils/Root/AlgToChainTool.cxx +++ b/Trigger/TrigSteer/TrigCompositeUtils/Root/AlgToChainTool.cxx @@ -54,7 +54,7 @@ std::set<std::string> TrigCompositeUtils::AlgToChainTool::getChainsForAlg(const result.insert(m_sequencerToChainMap.at(sequencer).begin(), m_sequencerToChainMap.at(sequencer).end()); } } catch ( const std::out_of_range & ex ) { - ATH_MSG_ERROR ( algorithmName << " is not part of the menu!" ); + ATH_MSG_DEBUG ( algorithmName << " is not part of the menu!" ); } return result; diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py index 32d9d0eac792108c06db4e1a6f9b49844b0732f2..a5e8ece08353a46ee245556130dd796216dd2d16 100644 --- a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py +++ b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py @@ -236,6 +236,18 @@ def triggerMonitoringCfg(flags, hypos, filters, l1Decoder): #mon.FinalChainStep = allChains mon.L1Decisions = getProp( l1Decoder, 'L1DecoderSummaryKey' ) + # For now use old svcMgr interface as this service is not available from acc.getService() + algToChainTool = CompFactory.getComp("TrigCompositeUtils::AlgToChainTool")() + from AthenaCommon.AppMgr import ServiceMgr as svcMgr + if hasattr(svcMgr,'HltEventLoopMgr'): + svcMgr.HltEventLoopMgr.TrigErrorMonTool.AlgToChainTool = conf2toConfigurable(algToChainTool) + + svcMgr.HltEventLoopMgr.TrigErrorMonTool.MonTool.defineHistogram( + 'ErrorChainName,ErrorCode', path='EXPERT', type='TH2I', + title='Error StatusCodes per chain;Chain name;StatusCode', + xbins=1, xmin=0, xmax=1, ybins=1, ymin=0, ymax=1) + + from DecisionHandling.DecisionHandlingConfig import setupFilterMonitoring [ [ setupFilterMonitoring( alg ) for alg in algs ] for algs in list(filters.values()) ]