|
ATLAS Offline Software
|
Go to the documentation of this file.
6 #include "GaudiKernel/Incident.h"
7 #include "GaudiKernel/IIncidentSvc.h"
8 #include "GaudiKernel/GaudiException.h"
21 #define BOOST_BIND_GLOBAL_PLACEHOLDERS // Needed to silence Boost pragma message
22 #include <boost/property_tree/ptree.hpp>
23 #include <boost/property_tree/json_parser.hpp>
28 : base_class(
name, svcLoc ),
29 m_tmcAux( nullptr ), m_tmc( nullptr ), m_menu(),
30 m_ctpConfig(), m_chainList(), m_sequenceList(), m_bgSet() {
51 CHECK( incSvc.retrieve() );
52 incSvc->addListener(
this, IncidentType::BeginEvent, 0,
61 incSvc->addListener(
this, IncidentType::BeginInputFile, 0,
65 m_tmcAux = std::make_unique<xAOD::TriggerMenuAuxContainer>();
66 m_tmc = std::make_unique<xAOD::TriggerMenuContainer>();
70 m_hltJsonAux = std::make_unique<xAOD::TriggerMenuJsonAuxContainer>();
71 m_hltJson = std::make_unique<xAOD::TriggerMenuJsonContainer>();
78 m_l1JsonAux = std::make_unique<xAOD::TriggerMenuJsonAuxContainer>();
79 m_l1Json = std::make_unique<xAOD::TriggerMenuJsonContainer>();
82 m_hltpsJsonAux = std::make_unique<xAOD::TriggerMenuJsonAuxContainer>();
83 m_hltpsJson = std::make_unique<xAOD::TriggerMenuJsonContainer>();
86 m_l1psJsonAux = std::make_unique<xAOD::TriggerMenuJsonAuxContainer>();
87 m_l1psJson = std::make_unique<xAOD::TriggerMenuJsonContainer>();
90 m_bgJsonAux = std::make_unique<xAOD::TriggerMenuJsonAuxContainer>();
91 m_bgJson = std::make_unique<xAOD::TriggerMenuJsonContainer>();
103 return StatusCode::SUCCESS;
109 return StatusCode::SUCCESS;
117 <<
"Trigger menu not loaded";
118 throw GaudiException(
"Service not initialised correctly",
119 "TrigConf::xAODConfigSvc::ctpConfig",
120 StatusCode::FAILURE );
132 <<
"Trigger menu not loaded";
133 throw GaudiException(
"Service not initialised correctly",
134 "TrigConf::xAODConfigSvc::bunchGroupSet",
135 StatusCode::FAILURE );
148 <<
"Trigger menu not loaded";
149 throw GaudiException(
"Service not initialised correctly",
150 "TrigConf::xAODConfigSvc::chains",
151 StatusCode::FAILURE );
163 <<
"Trigger menu not loaded";
164 throw GaudiException(
"Service not initialised correctly",
165 "TrigConf::xAODConfigSvc::chains",
166 StatusCode::FAILURE );
177 if( !hltMenuHandle.
isValid() ) {
182 return hltMenuHandle->smk();
193 if( !
m_menu.get()->m_ptr ) {
195 <<
"Trigger menu not yet known. Configuration key not returned.";
196 throw GaudiException(
"Service not initialised correctly",
197 "TrigConf::xAODConfigSvc::masterKey",
198 StatusCode::FAILURE );
203 return m_menu.get()->m_ptr->smk();
211 const bool firstEvent = !
m_currentL1ps.get()->isInitialized();
222 return l1psRCH->psk();
233 if( !
m_menu.get()->m_ptr ) {
235 <<
"Trigger menu not yet known. Configuration key not returned.";
236 throw GaudiException(
"Service not initialised correctly",
237 "TrigConf::xAODConfigSvc::lvl1PrescaleKey",
238 StatusCode::FAILURE );
243 return m_menu.get()->m_ptr->l1psk();
249 const bool firstEvent = !
m_currentBg.get()->isInitialized();
260 return l1BGS->
bgsk();
265 <<
"There's no way to access the bunch group set key from a legacy AOD!" <<
endmsg;
284 return hltpsRCH->psk();
295 if( !
m_menu.get()->m_ptr ) {
297 <<
"Trigger menu not yet known. Configuration key not returned.";
298 throw GaudiException(
"Service not initialised correctly",
299 "TrigConf::xAODConfigSvc::hltPrescaleKey",
300 StatusCode::FAILURE );
305 return m_menu.get()->m_ptr->hltpsk();
313 if( hltMenuHandle.
isValid() ) {
314 return *hltMenuHandle;
319 throw GaudiException(
"Service not initialised correctly",
320 "TrigConf::xAODConfigSvc::hltMenu",
321 StatusCode::FAILURE );
330 throw GaudiException(
"Service not initialised correctly",
331 "TrigConf::xAODConfigSvc::hltMenu",
332 StatusCode::FAILURE );
342 return *l1MenuHandle;
347 throw GaudiException(
"Service not initialised correctly",
348 "TrigConf::xAODConfigSvc::l1Menu",
349 StatusCode::FAILURE );
364 throw GaudiException(
"Service not initialised correctly",
365 "TrigConf::xAODConfigSvc::hltPrescalesSet",
366 StatusCode::FAILURE );
381 throw GaudiException(
"Service not initialised correctly",
382 "TrigConf::xAODConfigSvc::l1PrescalesSet",
383 StatusCode::FAILURE );
397 throw GaudiException(
"Service not initialised correctly",
398 "TrigConf::xAODConfigSvc::l1BunchGroupSet",
399 StatusCode::FAILURE );
413 if( inc.type() == IncidentType::BeginInputFile ) {
416 <<
"Couldn't read in the input file's metadata";
417 throw GaudiException(
"Couldn't read in the input file's "
419 "TrigConf::xAODConfigSvc::handle",
420 StatusCode::FAILURE );
426 else if( inc.type() == IncidentType::BeginEvent ) {
429 <<
"Couldn't prepare the trigger configuration for the "
431 throw GaudiException(
"Couldn't prepare the trigger configuration "
432 "for the current event",
433 "TrigConf::xAODConfigSvc::handle",
434 StatusCode::FAILURE );
440 REPORT_MESSAGE( MSG::WARNING ) <<
"Unknown incident type received: "
513 return StatusCode::FAILURE;
515 REPORT_MESSAGE( MSG::WARNING ) <<
"Couldn't retrieve xAOD::TriggerMenuContainer or xAOD::TriggerMenuJsonContainer(s)" <<
endmsg;
516 return StatusCode::SUCCESS;
530 <<
"In this input file we found xAOD::TriggerMenuJsonContainer(s), but no xAOD::TriggerMenuContainer. "
531 <<
"This is inconsistent with previous input files." <<
endmsg;
532 return StatusCode::FAILURE;
535 <<
"In this input file we found xAOD::TriggerMenuJsonContainer(s), but no xAOD::TriggerMenuContainer. "
536 <<
"This is inconsistent with previous input files." <<
endmsg;
537 return StatusCode::SUCCESS;
546 <<
"In this input file we found xAOD::TriggerMenuContainer, but no xAOD::TriggerMenuJsonContainer. "
547 <<
"This is inconsistent with previous input files." <<
endmsg;
548 return StatusCode::FAILURE;
551 <<
"In this input file we found xAOD::TriggerMenuContainer, but no xAOD::TriggerMenuJsonContainer. "
552 <<
"This is inconsistent with previous input files." <<
endmsg;
553 return StatusCode::SUCCESS;
564 if (input_hltmonitoring) {
574 return StatusCode::SUCCESS;
579 if( ! input_tmc->
size() ) {
580 REPORT_MESSAGE( MSG::WARNING ) <<
"No trigger configurations are available on the input" <<
endmsg;
581 return StatusCode::SUCCESS;
586 bool alreadyHave =
false;
598 m_tmc->push_back( newMenu );
599 *newMenu = *inputMenu;
601 <<
", L1PSK = " << newMenu->
l1psk()
605 return StatusCode::SUCCESS;
610 ATH_MSG_ERROR(
"Both m_menuJSONContainerAvailable and m_triggerMenuContainerAvailable are false" );
611 return StatusCode::FAILURE;
616 bool alreadyHave =
false;
618 if (inputTriggerMenuJson->key() == existingTriggerMenuJson->key()) {
628 existing->push_back( newTriggerMenuJson );
629 *newTriggerMenuJson = *inputTriggerMenuJson;
637 const EventContext& context = Gaudi::Hive::currentContext();
655 <<
"Coudln't retrieve xAOD::TrigConfKeys";
656 return StatusCode::FAILURE;
659 return StatusCode::SUCCESS;
666 bgKey = bgKeyRH.
cptr();
674 ATH_MSG_ERROR(
"Both m_menuJSONContainerAvailable and m_triggerMenuContainerAvailable are false" );
675 return StatusCode::FAILURE;
685 <<
"Configuration matches the loaded one, nothing to do." <<
endmsg;
686 return StatusCode::SUCCESS;
696 for( ; menu_itr != menu_end; ++menu_itr ) {
700 loadedMenuInSlot = *menu_itr;
701 m_menu.get(context)->m_ptr = loadedMenuInSlot;
708 chainList, sequenceList,
711 <<
" chainList.size() = " << chainList.size()
712 <<
" sequenceList.size() = " << sequenceList.size()
715 return StatusCode::SUCCESS;
720 <<
"Couldn't find configuration for current event (SMK:"
721 <<
keys->smk() <<
", L1PSK:" <<
keys->l1psk()
722 <<
", HLTPSK:" <<
keys->hltpsk() <<
")";
723 return StatusCode::FAILURE;
738 bool validConfig =
true;
745 if( !hltMenuHandle.
isValid() ) {
749 if (!currentHlt.
isInitialized() or currentHlt.
smk() != hltMenuHandle->smk()) {
752 currentHlt.
setData( hltMenuHandle->data() );
753 currentHlt.
setSMK( hltMenuHandle->smk() );
758 if( !l1MenuHandle.
isValid() ) {
765 currentL1.
setData( l1MenuHandle->data() );
766 currentL1.
setSMK( l1MenuHandle->smk() );
773 <<
"L1 and HLT prescales will not be available via the TrigConf::xAODConfigSvc in the first "
774 <<
"event when running with UseInFileMetadata=False" <<
endmsg;
786 currentL1ps.
setData( l1psRCH->data() );
787 currentL1ps.
setPSK( l1psRCH->psk() );
796 if (!currentHltps.
isInitialized() or currentHltps.
psk() != hltpsRCH->psk()) {
798 currentHltps.
clear();
799 currentHltps.
setData( hltpsRCH->data() );
800 currentHltps.
setPSK( hltpsRCH->psk() );
811 <<
"Configuration matches the loaded one, nothing to do." <<
endmsg;
812 return StatusCode::SUCCESS;
832 REPORT_MESSAGE( MSG::INFO ) <<
"Loaded Trigger configuration from Conditions Store and Detector Store:"
839 <<
" chainList.size() = " << chainList.size()
840 <<
" sequenceList.size() = " << sequenceList.size()
843 return StatusCode::SUCCESS;
855 bool validConfig =
true;
856 if (loadedHltJson ==
nullptr || loadedHltJson->
key() !=
keys->smk()) {
860 if (loadedL1Json ==
nullptr || loadedL1Json->
key() !=
keys->smk()) {
863 if (loadedHltpsJson ==
nullptr || loadedHltpsJson->
key() !=
keys->hltpsk()) {
866 if (loadedL1psJson ==
nullptr || loadedL1psJson->
key() !=
keys->l1psk()) {
870 if (loadedBgJson ==
nullptr || loadedBgJson->
key() !=
static_cast<unsigned int>(bgKey->
id())) {
877 <<
"Configuration matches the loaded one, nothing to do." <<
endmsg;
878 return StatusCode::SUCCESS;
913 if (currentHltmonitoringJson.
m_ptr) {
914 currentHltmonitoring.
setSMK( currentHltmonitoringJson.
m_ptr->
key() );
940 REPORT_MESSAGE( MSG::INFO ) <<
"Loaded xAOD::TriggerMenuJson configuration:"
941 <<
" SMK = " <<
keys->smk()
942 <<
", L1PSK = " <<
keys->l1psk()
943 <<
", HLTPSK = " <<
keys->hltpsk()
947 <<
" chainList.size() = " << chainList.size()
948 <<
" sequenceList.size() = " << sequenceList.size()
951 return StatusCode::SUCCESS;
960 const bool optional) {
964 cacheOfLoadedMenuPtr.
m_ptr =
nullptr;
965 for( ; menu_itr != menu_end; ++menu_itr ) {
967 if( keyToCheck != (*menu_itr)->key() )
continue;
969 ptrToLocatedMenu = *menu_itr;
970 cacheOfLoadedMenuPtr.
m_ptr = ptrToLocatedMenu;
971 std::stringstream rawData;
972 rawData << ptrToLocatedMenu->
payload();
973 dataStructure.
clear();
976 boost::property_tree::read_json(rawData,
pt);
978 }
catch (
const boost::property_tree::json_parser_error&
e) {
979 REPORT_MESSAGE(
MSG::FATAL ) <<
"Unable to decode a JSON trigger menu metadata payload for " << humanName <<
" with key " << keyToCheck <<
endmsg;
981 return StatusCode::FAILURE;
986 if (not optional and ptrToLocatedMenu ==
nullptr) {
988 <<
"Couldn't find configuration for current event"
989 <<
", Requested key=" << keyToCheck
990 <<
", Requested menu=" << humanName
992 return StatusCode::FAILURE;
994 return StatusCode::SUCCESS;
virtual const HLTPrescalesSet & hltPrescalesSet(const EventContext &ctx=Gaudi::Hive::currentContext()) const override
Returns the JSON configured HLT prescales ptree.
void setPSK(unsigned int psk)
void setBGSK(unsigned int bgsk)
std::unique_ptr< xAOD::TriggerMenuJsonAuxContainer > m_bgJsonAux
Const iterator class for DataVector/DataList.
SG::SlotSpecificObj< L1Menu > m_currentL1
SG::ReadCondHandleKey< TrigConf::L1PrescalesSet > m_L1PrescaleSetKey
bool isInitialized() const
StatusCode readMetadata()
Function reading in a new metadata object from the input.
void copyMetadataToPersonalStore(const xAOD::TriggerMenuJsonContainer *input, xAOD::TriggerMenuJsonContainer *existing)
Helper function for copying into the service's private data store.
void setSMK(unsigned int psk)
SG::SlotSpecificObj< L1BunchGroupSet > m_currentBg
StatusCode prepareEvent()
Function setting up the service for a new event.
virtual const CTPConfig * ctpConfig() const override
Get the LVL1 trigger menu.
const_pointer_type cptr()
Dereference the pointer.
SG::SlotSpecificObj< L1PrescalesSet > m_currentL1ps
StatusCode prepareEventxAODTriggerMenu(const xAOD::TrigConfKeys *keys, const EventContext &context)
Do per-event decoding for R2 in-file serialised xAOD::TriggerMenu metadata.
std::unique_ptr< xAOD::TriggerMenuJsonContainer > m_hltJson
SG::SlotSpecificObj< MenuPtrWrapper > m_menu
virtual const HLTMenu & hltMenu(const EventContext &ctx=Gaudi::Hive::currentContext()) const override
Returns the JSON configured HLTMenu ptree.
std::shared_mutex m_sharedMutex
The mutex used to to restrict access to m_tmc when it is being written to.
Gaudi::Property< std::string > m_metaNameJSON_hltps
SG::SlotSpecificObj< HLTPrescalesSet > m_currentHltps
SG::SlotSpecificObj< HLTChainList > m_chainList
The "translated" HLT configuration object.
Gaudi::Property< bool > m_useInFileMetadata
Gaudi::Property< std::string > m_metaNameJSON_hltmonitoring
SG::SlotSpecificObj< TriggerMenuJsonPtrWrapper > m_currentL1psJson
SG::SlotSpecificObj< TriggerMenuJsonPtrWrapper > m_currentHltJson
std::unique_ptr< xAOD::TriggerMenuJsonContainer > m_l1Json
SG::SlotSpecificObj< CTPConfig > m_ctpConfig
StatusCode prepareTriggerMenu(const xAOD::TriggerMenu *menu, CTPConfig &ctpConfig, HLTChainList &chainList, HLTSequenceList &sequenceList, BunchGroupSet &bgSet, MsgStream &msg)
In order to avoid duplicating code between how the dual-use and the Athena-only code translates the x...
virtual uint32_t bunchGroupSetKey() const override
Get the LVL1 bunch group set key.
virtual StatusCode initialize() override
Function initialising the service.
const std::string & key() const
Return the StoreGate ID for the referenced object.
virtual uint32_t lvl1PrescaleKey() const override
Get the LVL1 prescale key.
SG::SlotSpecificObj< BunchGroupSet > m_bgSet
The "translated" bunch group set object.
void setPSK(unsigned int psk)
void setData(const ptree &data)
Setting the configuration data.
Gaudi::Property< std::string > m_metaNameJSON_l1ps
Forward iterator to traverse the main components of the trigger configuration.
bool xAODKeysMatch(const xAOD::TrigConfKeys *keys, const xAOD::TriggerMenu *menu)
Since this is used in a couple of places, it seemed to make sense to put this simple code into a cent...
SG::ReadHandleKey< xAOD::BunchConfKey > m_eventBGKey
virtual void handle(const Incident &inc) override
Function handling the incoming incidents.
list of all HLT chains in a trigger menu
std::unique_ptr< xAOD::TriggerMenuContainer > m_tmc
std::unique_ptr< xAOD::TriggerMenuJsonContainer > m_l1psJson
::StatusCode StatusCode
StatusCode definition for legacy code.
SG::ReadHandleKey< xAOD::TrigConfKeys > m_eventKey
SG::ReadHandleKey< HLTMenu > m_hltMenuKey
bool m_triggerMenuContainerAvailable
Is decoded R2 format data available?
unsigned int psk() const
setter and getter for the L1 prescale key
std::unique_ptr< xAOD::TriggerMenuJsonContainer > m_hltpsJson
virtual uint32_t masterKey() const override
Get the Super Master Key.
Gaudi::Property< std::string > m_metaNameJSON_hlt
#define CHECK(...)
Evaluate an expression and check for errors.
virtual StatusCode finalize() override
Function finalising the service.
StatusCode prepareEventxAODTriggerMenuJson(const xAOD::TrigConfKeys *keys, const xAOD::BunchConfKey *bgKey, const EventContext &context)
Do per-event decoding for R3 in-file serialised xAOD::TriggerMenuJson metadata.
std::unique_ptr< xAOD::TriggerMenuJsonAuxContainer > m_l1psJsonAux
std::unique_ptr< xAOD::TriggerMenuJsonAuxContainer > m_hltpsJsonAux
virtual void clear() override
Clearing the configuration data.
std::unique_ptr< xAOD::TriggerMenuJsonAuxContainer > m_hltmonitoringJsonAux
bool m_menuJSONContainerAvailable
Is decoded R3 format data available?
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadCondHandleKey< TrigConf::HLTPrescalesSet > m_HLTPrescaleSetKey
ServiceHandle< StoreGateSvc > m_metaStore
Connection to the metadata store.
const std::vector< BunchGroup > & bunchGroups() const
bool m_isInFailure
Internal state of the service.
boost::property_tree::ptree ptree
Gaudi::Property< bool > m_stopOnFailure
SG::SlotSpecificObj< TriggerMenuJsonPtrWrapper > m_currentBgJson
Class describing the configuration used in a given event.
TriggerMenu_v1 TriggerMenu
Define the latest version of the trigger menu class.
std::string to_string(const DetectorType &type)
Helpers for checking error return status codes and reporting errors.
StatusCode initialize(bool used=true)
Base class for Trigger configuration data and wrapper around underlying representation.
virtual const HLTChainList & chains() const override
Get the HLT chains.
uint32_t id() const
Get the 32-bit identifier of the bunch configuration.
#define REPORT_MESSAGE(LVL)
Report a message.
HLT monitoring configuration.
std::unique_ptr< xAOD::TriggerMenuJsonAuxContainer > m_hltJsonAux
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
SG::ReadCondHandleKey< TrigConf::L1BunchGroupSet > m_L1BunchGroupSetKey
std::unique_ptr< xAOD::TriggerMenuAuxContainer > m_tmcAux
SG::SlotSpecificObj< HLTMenu > m_currentHlt
virtual const BunchGroupSet * bunchGroupSet() const override
Get the LVL1 bunch group set.
virtual const HLTMonitoring & hltMonitoring(const EventContext &ctx=Gaudi::Hive::currentContext()) const override
Returns the JSON configured HLTMonitoring ptree.
virtual void clear() override
Clearing the configuration data.
std::unique_ptr< xAOD::TriggerMenuJsonContainer > m_hltmonitoringJson
virtual const L1PrescalesSet & l1PrescalesSet(const EventContext &ctx=Gaudi::Hive::currentContext()) const override
Returns the JSON configured L1 prescales ptree.
Gaudi::Property< std::string > m_metaName
const Menu & menu() const
std::unique_ptr< xAOD::TriggerMenuJsonContainer > m_bgJson
virtual const HLTSequenceList & sequences() const override
Get the HLT sequences.
TriggerMenuJson_v1 TriggerMenuJson
Define the latest version of the trigger menu JSON class.
Gaudi::Property< std::string > m_metaNameJSON_l1
virtual void clear()
Clearing the configuration data.
StatusCode prepareEventRun3Athena(const EventContext &context)
Do per-event updating of R3 JSON-based metadata, reading the data direct from the Conditions and Dete...
SG::SlotSpecificObj< TriggerMenuJsonPtrWrapper > m_currentHltpsJson
SG::SlotSpecificObj< HLTMonitoring > m_currentHltmonitoring
unsigned int bgsk() const
setter and getter for the bunch group key
unsigned int psk() const
setter and getter for the HLT prescale key
StatusCode loadPtree(const std::string &humanName, const xAOD::TriggerMenuJsonContainer *metaContainer, const uint32_t keyToCheck, TriggerMenuJsonPtrWrapper &cacheOfLoadedMenuPtr, DataStructure &dataStructure, const bool optional=false)
Helper function to find a JSON in a given TriggerMenuJsonContainer using a given key,...
xAODConfigSvc(const std::string &name, ISvcLocator *svcLoc)
Standard service constructor.
std::unique_ptr< xAOD::TriggerMenuJsonAuxContainer > m_l1JsonAux
virtual const L1Menu & l1Menu(const EventContext &ctx=Gaudi::Hive::currentContext()) const override
Returns the JSON configured L1 ptree.
SG::ReadHandleKey< L1Menu > m_l1MenuKey
virtual uint32_t hltPrescaleKey() const override
Get the HLT prescale key.
size_type size() const noexcept
Returns the number of elements in the collection.
Gaudi::Property< std::string > m_metaNameJSON_bg
SG::SlotSpecificObj< TriggerMenuJsonPtrWrapper > m_currentHltmonitoringJson
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
SG::SlotSpecificObj< TriggerMenuJsonPtrWrapper > m_currentL1Json
virtual const L1BunchGroupSet & l1BunchGroupSet(const EventContext &ctx=Gaudi::Hive::currentContext()) const override
Returns the JSON configured bunchgroup ptree.
Class identifying the bunch configuration of a given event.
SG::SlotSpecificObj< HLTSequenceList > m_sequenceList
The "translated" HLT configuration object.