diff --git a/Trigger/TrigConfiguration/TrigConfData/TrigConfData/HLTChain.h b/Trigger/TrigConfiguration/TrigConfData/TrigConfData/HLTChain.h index c0755dda26977142d5039171db0747cffa54edd4..dab6cb7e63b5bebe497ef4b93e315a6b4840c449 100644 --- a/Trigger/TrigConfiguration/TrigConfData/TrigConfData/HLTChain.h +++ b/Trigger/TrigConfiguration/TrigConfData/TrigConfData/HLTChain.h @@ -55,6 +55,9 @@ namespace TrigConf { /** Accessor to the groups this chain belongs to */ std::vector<std::string> groups() const; + /** Accessor to the sequencers this chain belongs to */ + std::vector<std::string> sequencers() const; + private: void update() override; diff --git a/Trigger/TrigConfiguration/TrigConfData/TrigConfData/HLTMenu.h b/Trigger/TrigConfiguration/TrigConfData/TrigConfData/HLTMenu.h index ec445700604467987e1761a969b8a29d916c70b9..da6df560576191319825e5731793528750d41225 100644 --- a/Trigger/TrigConfiguration/TrigConfData/TrigConfData/HLTMenu.h +++ b/Trigger/TrigConfiguration/TrigConfData/TrigConfData/HLTMenu.h @@ -9,6 +9,8 @@ #include "TrigConfData/DataStructure.h" #include "TrigConfData/HLTChain.h" +#include <map> + namespace TrigConf { /** @@ -57,6 +59,9 @@ namespace TrigConf { /** Accessor to the connected output streams */ std::vector<DataStructure> streams() const; + /** Accessor to the sequencers */ + std::map<std::string, std::vector<std::string>> sequencers() const; + /** print overview of L1 Menu */ void printMenu(bool full = false) const; diff --git a/Trigger/TrigConfiguration/TrigConfData/src/HLTChain.cxx b/Trigger/TrigConfiguration/TrigConfData/src/HLTChain.cxx index bfeeab95645159a03d7403900149dc4035367bcb..a78b2a391a066bc2c69b090f778dc8e3ce6926fb 100644 --- a/Trigger/TrigConfiguration/TrigConfData/src/HLTChain.cxx +++ b/Trigger/TrigConfiguration/TrigConfData/src/HLTChain.cxx @@ -101,3 +101,18 @@ TrigConf::Chain::groups() const return grouplist; } +std::vector<std::string> +TrigConf::Chain::sequencers() const +{ + + std::vector<std::string> seqlist; + const auto & seqs = getList("sequencers"); + if( !seqs.empty() ) { + seqlist.reserve(seqs.size()); + for( auto & seq : seqs ) { + seqlist.emplace_back( seq.getValue<std::string>() ); + } + } + return seqlist; +} + diff --git a/Trigger/TrigConfiguration/TrigConfData/src/HLTMenu.cxx b/Trigger/TrigConfiguration/TrigConfData/src/HLTMenu.cxx index f75ab64a14ed37c14f13185b42b68294b05ce691..37017087237557655c42c30b05464623ecfe49b0 100644 --- a/Trigger/TrigConfiguration/TrigConfData/src/HLTMenu.cxx +++ b/Trigger/TrigConfiguration/TrigConfData/src/HLTMenu.cxx @@ -74,6 +74,22 @@ TrigConf::HLTMenu::streams() const } +std::map<std::string, std::vector<std::string>> +TrigConf::HLTMenu::sequencers() const +{ + std::map<std::string, std::vector<std::string>> result; + const auto & sequencers = getObject("sequencers"); + + for( auto & sequence : sequencers.getKeys() ) { + for( auto & alg : sequencers.getList(sequence) ) { + result[sequence].emplace_back(alg.getValue<std::string>()); + } + } + + return result; +} + + void TrigConf::HLTMenu::printMenu(bool full) const { diff --git a/Trigger/TrigConfiguration/TrigConfigSvc/src/AlgToChainTool.cxx b/Trigger/TrigConfiguration/TrigConfigSvc/src/AlgToChainTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..cb9c3b9eb2723572cdc6e3625c920a3c4f482290 --- /dev/null +++ b/Trigger/TrigConfiguration/TrigConfigSvc/src/AlgToChainTool.cxx @@ -0,0 +1,59 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "AlgToChainTool.h" + +TrigConf::AlgToChainTool::AlgToChainTool(const std::string& type, + const std::string& name, + const IInterface* parent) + : AthAlgTool (type, name, parent) + {} + + +TrigConf::AlgToChainTool::~AlgToChainTool() {} + + +StatusCode TrigConf::AlgToChainTool::initialize() { + ATH_CHECK( m_HLTMenuKey.initialize() ); + + return StatusCode::SUCCESS; +} + + +StatusCode TrigConf::AlgToChainTool::start() { + SG::ReadHandle<TrigConf::HLTMenu> hltMenuHandle = SG::makeHandle( m_HLTMenuKey ); + ATH_CHECK( hltMenuHandle.isValid() ); + + // fill the maps + for ( const TrigConf::Chain& chain : *hltMenuHandle ) { + for ( const std::string& sequencer : chain.sequencers() ) { + m_sequencerToChainMap[sequencer].push_back(chain.name()); + } + } + + for ( const auto& sequencer : hltMenuHandle->sequencers() ) { + for ( const std::string& algorithm : sequencer.second ) { + // save just second part of algorithm ex. RoRSeqFilter/FFastCaloElectron -> FFastCaloElectron + m_algToSequencersMap[algorithm.substr(algorithm.find('/') + 1)] + .push_back(sequencer.first); + } + } + + return StatusCode::SUCCESS; +} + + +std::set<std::string> TrigConf::AlgToChainTool::getChainsForAlg(const std::string& algorithmName) const { + std::set<std::string> result; + + try { + for ( const std::string& sequencer : m_algToSequencersMap.at(algorithmName) ) { + 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!" ); + } + + return result; +} \ No newline at end of file diff --git a/Trigger/TrigConfiguration/TrigConfigSvc/src/AlgToChainTool.h b/Trigger/TrigConfiguration/TrigConfigSvc/src/AlgToChainTool.h new file mode 100644 index 0000000000000000000000000000000000000000..de01f55feb692b780fa3eb94708da9541b6a8545 --- /dev/null +++ b/Trigger/TrigConfiguration/TrigConfigSvc/src/AlgToChainTool.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGCONFDATA_ALGTOCHAINTOOL_H +#define TRIGCONFDATA_ALGTOCHAINTOOL_H + +#include <string> +#include <set> +#include <vector> +#include <map> + +#include "AthenaBaseComps/AthAlgTool.h" +#include "TrigConfData/HLTMenu.h" + + +namespace TrigConf { + + /** @class AlgToChainTool + * @brief Provide the reverse mapping: algorithms to set fo chain names + **/ + + class AlgToChainTool : public AthAlgTool { + public: + AlgToChainTool(const std::string& type, const std::string& name, const IInterface* parent); + virtual ~AlgToChainTool(); + + virtual StatusCode initialize() override; + + virtual StatusCode start() override; + + /// Request set of chains for given algorithm + std::set<std::string> getChainsForAlg(const std::string& algorithmName) const; + + private: + SG::ReadHandleKey<TrigConf::HLTMenu> m_HLTMenuKey{ this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "HLT Menu" }; + std::map<std::string, std::vector<std::string>> m_sequencerToChainMap; + std::map<std::string, std::vector<std::string>> m_algToSequencersMap; + }; +} + +#endif // TRIGCONFDATA_ALGTOCHAINTOOL_H diff --git a/Trigger/TrigConfiguration/TrigConfigSvc/src/components/TrigConfigSvc_entries.cxx b/Trigger/TrigConfiguration/TrigConfigSvc/src/components/TrigConfigSvc_entries.cxx index 2368747300749d53e804db7cf6d6eec9f25773e8..ddf9a25ec9075d6737489ec1e3376d0bf2b223f8 100644 --- a/Trigger/TrigConfiguration/TrigConfigSvc/src/components/TrigConfigSvc_entries.cxx +++ b/Trigger/TrigConfiguration/TrigConfigSvc/src/components/TrigConfigSvc_entries.cxx @@ -7,6 +7,8 @@ #include "../HLTPrescaleCondAlg.h" +#include "../AlgToChainTool.h" + DECLARE_COMPONENT( TrigConf::L1TopoConfigSvc ) DECLARE_COMPONENT( TrigConf::LVL1ConfigSvc ) DECLARE_COMPONENT( TrigConf::HLTConfigSvc ) @@ -15,3 +17,5 @@ DECLARE_COMPONENT( TrigConf::DSConfigSvc ) DECLARE_COMPONENT( TrigConf::TrigConfigSvc ) DECLARE_COMPONENT( TrigConf::HLTPrescaleCondAlg ) + +DECLARE_COMPONENT( TrigConf::AlgToChainTool ) \ No newline at end of file