11 #include "CoolKernel/types.h"
20 std::shared_ptr<TrigConf::L1PrescalesSet>
22 auto pss = std::make_shared<L1PrescalesSet>();
40 std::shared_ptr<TrigConf::L1PrescalesSet>
43 ATH_MSG_WARNING(
"Currently it is not possible to load run 2 prescale sets from the database. Will not load L1 psk " << psk );
46 auto pss = std::make_shared<L1PrescalesSet>();
48 ATH_MSG_DEBUG(
"Setting up TrigDBL1PrescalesSetLoader with DB connection " << m_dbConnection.value() );
56 ATH_MSG_WARNING(
"Failed loading L1 prescales set from db with key " << psk );
70 ATH_CHECK(m_pskFolderInputKey.initialize());
71 if( m_configSource ==
"FILE" || m_configSource ==
"DB" ) {
72 renounce( m_pskFolderInputKey );
75 ATH_CHECK(m_l1PrescalesSetOutputKey.initialize());
77 if( m_configSource ==
"COOL" && m_dbConnection ==
"JOSVC" ) {
78 if(
auto joSvc = serviceLocator()->service<TrigConf::IJobOptionsSvc>(
"JobOptionsSvc" ) ) {
79 if( joSvc->l1PrescaleKey()>0 ) {
80 m_psk = joSvc->l1PrescaleKey();
81 m_dbConnection = joSvc->server();
82 ATH_MSG_INFO(
"Set psk to " << m_psk <<
" and db connection to " << m_dbConnection );
94 if( m_configSource ==
"FILE" ) {
98 m_pssMap.insert(std::make_pair(0
u, createFromFile(m_filename)));
100 }
else if( m_psk != 0
u ) {
105 m_pssMap.insert(std::make_pair(m_psk,
createFromDB(m_psk,
true)));
109 return StatusCode::SUCCESS;
115 ATH_MSG_DEBUG(
"L1PrescaleCondAlg::execute with lb " << ctx.eventID().lumi_block());
118 if (writeCondHandle.
isValid()) {
119 return StatusCode::SUCCESS;
122 unsigned int l1Psk = m_psk;
125 if(m_configSource ==
"COOL") {
129 if ( pskAL ==
nullptr ) {
130 ATH_MSG_FATAL(
"Null pointer to the read conditions object of " << m_pskFolderInputKey.key());
131 return StatusCode::FAILURE;
135 return StatusCode::FAILURE;
140 l1Psk = (*pskAL)[
"Lvl1PrescaleConfigurationKey"].data<cool::UInt32>();
141 ATH_MSG_INFO(
"Extracted the L1 PSK " << l1Psk <<
" for run " << ctx.eventID().run_number()
142 <<
" and lb " << ctx.eventID().lumi_block() );
149 start.set_lumi_block(0);
151 stop.set_lumi_block(0);
156 std::shared_ptr<const L1PrescalesSet> pss;
158 if( m_configSource ==
"FILE" ) {
160 pss = m_pssMap.at(0);
162 }
else if ( l1Psk != 0 ) {
164 auto pssi = m_pssMap.find( l1Psk );
166 if( pssi == m_pssMap.end()) {
168 bool isRun3 =
range.start().run_number()>350000;
172 if( pss ==
nullptr ) {
173 ATH_MSG_ERROR(
"Failed loading L1 prescales set from the database" );
174 return StatusCode::FAILURE;
177 const auto p = m_pssMap.insert(std::make_pair( l1Psk, pss ));
178 pss =
p.first->second;
188 ATH_MSG_ERROR(
"Failed loading L1 prescales set (not reading from FILE and no psk known)" );
189 return StatusCode::FAILURE;
194 if( pss ==
nullptr ) {
198 ATH_MSG_INFO(
"Recording L1 prescales set with range " <<
range <<
" (key = " << pss->
psk() <<
")");
202 return StatusCode::SUCCESS;