13#include "CoolKernel/types.h"
22std::shared_ptr<TrigConf::HLTPrescalesSet>
24 auto pss = std::make_shared<HLTPrescalesSet>();
26 ATH_MSG_DEBUG(
"Setting up JsonFileLoader with file " << filename );
30 if( psLoader.
loadFile( filename, *pss) ) {
33 ATH_MSG_INFO(
"HLT prescales set successfully loaded from file " << filename );
41std::shared_ptr<TrigConf::HLTPrescalesSet>
44 ATH_MSG_WARNING(
"Currently it is not possible to load run 2 prescale sets from the database. Will not load HLT psk " << psk );
47 auto pss = std::make_shared<HLTPrescalesSet>();
51 std::string crest_server(
"");
52 std::string crest_api(
"");
53 std::string dbname(
"");
63 catch(std::exception & e) {
64 ATH_MSG_WARNING(
"Failed loading HLT prescales set from db with key " << psk );
87 if(
auto joSvc = serviceLocator()->service<TrigConf::IJobOptionsSvc>(
"JobOptionsSvc" ) ) {
88 if( joSvc->hltPrescaleKey()>0 ) {
89 m_psk = joSvc->hltPrescaleKey();
109 if( pss ==
nullptr ) {
111 return StatusCode::FAILURE;
113 m_pssMap.insert(std::make_pair(0u, std::move(pss)));
115 }
else if(
m_psk != 0u ) {
121 if( pss ==
nullptr ) {
122 ATH_MSG_ERROR(
"Failed loading HLT prescales set " <<
m_psk <<
" from the database" );
123 return StatusCode::FAILURE;
125 m_pssMap.insert(std::make_pair(
m_psk.value(), std::move(pss)));
128 return StatusCode::SUCCESS;
134 ATH_MSG_DEBUG(
"HLTPrescaleCondAlg::execute with lb " << ctx.eventID().lumi_block());
137 if (writeCondHandle.
isValid()) {
138 return StatusCode::SUCCESS;
141 unsigned int hltPsk =
m_psk;
148 if ( pskAL ==
nullptr ) {
150 return StatusCode::FAILURE;
152 if (not readH.
range(range)) {
154 return StatusCode::FAILURE;
159 hltPsk = (*pskAL)[
"HltPrescaleKey"].data<cool::UInt32>();
160 ATH_MSG_INFO(
"Extracted the HLT PSK " << hltPsk <<
" for run " << ctx.eventID().run_number()
161 <<
" and lb " << ctx.eventID().lumi_block() );
165 EventIDBase::number_type
run = ctx.eventID().run_number();
166 EventIDBase start, stop;
167 start.set_run_number(
run);
168 start.set_lumi_block(0);
169 stop.set_run_number(
run+1);
170 stop.set_lumi_block(0);
171 range = EventIDRange(start,stop);
175 std::shared_ptr<const HLTPrescalesSet> pss;
179 pss = m_pssMap.at(0);
181 }
else if ( hltPsk != 0 ) {
183 auto pssi = m_pssMap.find( hltPsk );
185 if( pssi == m_pssMap.end()) {
187 bool isRun3 = range.start().run_number()>350000;
191 if( pss ==
nullptr ) {
192 ATH_MSG_ERROR(
"Failed loading HLT prescales set from the database" );
193 return StatusCode::FAILURE;
196 const auto p = m_pssMap.insert(std::make_pair( hltPsk, pss ));
197 pss = p.first->second;
207 ATH_MSG_ERROR(
"Failed loading HLT prescales set (not reading from FILE and no psk known)" );
208 return StatusCode::FAILURE;
213 if( pss ==
nullptr ) {
214 ATH_MSG_INFO(
"Recording empty HLT prescales set with range " << range);
218 ATH_MSG_INFO(
"Recording HLT prescales set with range " << range <<
" (key = " << pss->psk() <<
")");
222 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
void createFromDB(GeoFullPhysVol *envelope, IRDBAccessSvc *rdbAccess, IGeoModelSvc *geoModel, StoredMaterialManager *materialManager)
Loader class for Trigger configuration from Json.
Loader class for Trigger configuration (HLT prescales set) from the Trigger DB.
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
Base class for conditions algorithms.
An AttributeList represents a logical row of attributes in a metadata table.
bool range(EventIDRange &r)
const std::string & key() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
HLTPrescaleCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteCondHandleKey< TrigConf::HLTPrescalesSet > m_hltPrescalesSetOutputKey
SG::ReadCondHandleKey< AthenaAttributeList > m_pskFolderInputKey
std::shared_ptr< HLTPrescalesSet > createFromDB(unsigned int psk, bool isRun3) const
Gaudi::Property< unsigned int > m_psk
Gaudi::Property< std::string > m_configSource
Gaudi::Property< std::string > m_dbConnection
std::shared_ptr< HLTPrescalesSet > createFromFile(const std::string &filename) const
virtual StatusCode execute(const EventContext &ctx) const override
Gaudi::Property< std::string > m_filename
virtual StatusCode initialize() override
Loader of trigger configurations from Json files.
void setLevel(MSGTC::Level lvl)
bool loadFile(const std::string &filename, boost::property_tree::ptree &data, const std::string &pathToChild="") const
Load content of json file into a ptree.
Loader of trigger configurations from Json files.
bool loadHLTPrescales(unsigned int hltpsk, HLTPrescalesSet &hltpss, const std::string &outFileName="") const
Load content from the Trigger DB into an HLTPrescalesSet for a given HLTPrescaleKey (HLTPSK)
void setLevel(MSGTC::Level lvl)
void setCrestTrigDB(const std::string &crestTrigDB)
set trigger db for the crest connection
void setCrestConnection(const std::string &server, const std::string &version="")
declare CREST as the source of the configuration An empty crest server makes it use Oracle
uint32_t truncatedHash(const DataStructure &dataStructure)
Function to compute a truncated MD5 hash for a JSON file.
bool isCrestConnection(const std::string &db_connection_string, std::string &crest_server, std::string &crest_api, std::string &dbname)
Function to interpret the trigger connection string for CREST connections Format of the connections s...