11 #include "CoolKernel/types.h"
20 std::shared_ptr<TrigConf::HLTPrescalesSet>
22 auto pss = std::make_shared<HLTPrescalesSet>();
39 std::shared_ptr<TrigConf::HLTPrescalesSet>
42 ATH_MSG_WARNING(
"Currently it is not possible to load run 2 prescale sets from the database. Will not load HLT psk " << psk );
45 auto pss = std::make_shared<HLTPrescalesSet>();
47 ATH_MSG_DEBUG(
"Setting up TrigDBHLTPrescalesSetLoader with DB connection " << m_dbConnection.value() );
55 ATH_MSG_WARNING(
"Failed loading HLT prescales set from db with key " << psk );
69 ATH_CHECK(m_pskFolderInputKey.initialize());
70 if( m_configSource ==
"FILE" || m_configSource ==
"DB" ) {
71 renounce( m_pskFolderInputKey );
74 ATH_CHECK(m_hltPrescalesSetOutputKey.initialize());
76 if( m_dbConnection ==
"JOSVC" ) {
77 if( m_configSource ==
"COOL" || m_configSource ==
"DB" ) {
78 if(
auto joSvc = serviceLocator()->service<TrigConf::IJobOptionsSvc>(
"JobOptionsSvc" ) ) {
79 if( joSvc->hltPrescaleKey()>0 ) {
80 m_psk = joSvc->hltPrescaleKey();
81 m_dbConnection = joSvc->server();
82 ATH_MSG_INFO(
"Set psk to " << m_psk <<
" and db connection to " << m_dbConnection );
95 if( m_configSource ==
"FILE" ) {
99 std::shared_ptr<HLTPrescalesSet> pss = createFromFile( m_filename );
100 if( pss ==
nullptr ) {
101 ATH_MSG_ERROR(
"Failed loading HLT prescales set from the file " << m_filename );
102 return StatusCode::FAILURE;
104 m_pssMap.insert(std::make_pair(0
u, std::move(pss)));
106 }
else if( m_psk != 0
u ) {
111 std::shared_ptr<HLTPrescalesSet> pss =
createFromDB( m_psk,
true );
112 if( pss ==
nullptr ) {
113 ATH_MSG_ERROR(
"Failed loading HLT prescales set " << m_psk <<
" from the database" );
114 return StatusCode::FAILURE;
116 m_pssMap.insert(std::make_pair(m_psk.value(), std::move(pss)));
119 return StatusCode::SUCCESS;
125 ATH_MSG_DEBUG(
"HLTPrescaleCondAlg::execute with lb " << ctx.eventID().lumi_block());
128 if (writeCondHandle.
isValid()) {
129 return StatusCode::SUCCESS;
132 unsigned int hltPsk = m_psk;
135 if(m_configSource ==
"COOL") {
139 if ( pskAL ==
nullptr ) {
140 ATH_MSG_FATAL(
"Null pointer to the read conditions object of " << m_pskFolderInputKey.key());
141 return StatusCode::FAILURE;
145 return StatusCode::FAILURE;
150 hltPsk = (*pskAL)[
"HltPrescaleKey"].data<cool::UInt32>();
151 ATH_MSG_INFO(
"Extracted the HLT PSK " << hltPsk <<
" for run " << ctx.eventID().run_number()
152 <<
" and lb " << ctx.eventID().lumi_block() );
159 start.set_lumi_block(0);
161 stop.set_lumi_block(0);
166 std::shared_ptr<const HLTPrescalesSet> pss;
168 if( m_configSource ==
"FILE" ) {
170 pss = m_pssMap.at(0);
172 }
else if ( hltPsk != 0 ) {
174 auto pssi = m_pssMap.find( hltPsk );
176 if( pssi == m_pssMap.end()) {
178 bool isRun3 =
range.start().run_number()>350000;
182 if( pss ==
nullptr ) {
183 ATH_MSG_ERROR(
"Failed loading HLT prescales set from the database" );
184 return StatusCode::FAILURE;
187 const auto p = m_pssMap.insert(std::make_pair( hltPsk, pss ));
188 pss =
p.first->second;
198 ATH_MSG_ERROR(
"Failed loading HLT prescales set (not reading from FILE and no psk known)" );
199 return StatusCode::FAILURE;
204 if( pss ==
nullptr ) {
209 ATH_MSG_INFO(
"Recording HLT prescales set with range " <<
range <<
" (key = " << pss->
psk() <<
")");
213 return StatusCode::SUCCESS;