9#include "CoolKernel/types.h"
43 }
else if(
m_bgk != 0u ) {
52 return StatusCode::SUCCESS;
55std::shared_ptr<TrigConf::L1BunchGroupSet>
57 auto bgs = std::make_shared<L1BunchGroupSet>();
59 ATH_MSG_DEBUG(
"Setting up JsonFileLoader with file " << filename );
62 if( psLoader.
loadFile( filename, *bgs) ) {
65 ATH_MSG_INFO(
"L1 BunchGroup set successfully loaded from file " << filename );
67 ATH_MSG_WARNING(
"Failed loading L1 BunchGroup set from file " << filename );
74std::shared_ptr<TrigConf::L1BunchGroupSet>
76 auto bgs = std::make_shared<L1BunchGroupSet>();
79 std::string crest_server(
"");
80 std::string crest_api(
"");
81 std::string dbname(
"");
90 catch(std::exception & e) {
91 ATH_MSG_WARNING(
"Failed loading L1BunchGroup set from db with key " << bgk );
102 ATH_MSG_DEBUG(
"BunchGroupCondAlg::execute with lb " << ctx.eventID().lumi_block());
105 if (writeCondHandle.
isValid()) {
106 return StatusCode::SUCCESS;
109 unsigned int l1Ggk =
m_bgk;
117 if ( bgkAL ==
nullptr ) {
119 return StatusCode::FAILURE;
121 if (not readH.
range(range)) {
123 return StatusCode::FAILURE;
128 l1Ggk = (*bgkAL)[
"Lvl1BunchGroupConfigurationKey"].data<cool::UInt32>();
129 ATH_MSG_INFO(
"Extracted the L1 bgk " << l1Ggk <<
" for run " << ctx.eventID().run_number()
130 <<
" and lb " << ctx.eventID().lumi_block() );
134 EventIDBase::number_type
run = ctx.eventID().run_number();
135 EventIDBase start, stop;
136 start.set_run_number(
run);
137 start.set_lumi_block(0);
138 stop.set_run_number(
run+1);
139 stop.set_lumi_block(0);
140 range = EventIDRange(start,stop);
144 std::shared_ptr<const L1BunchGroupSet> bgs;
148 bgs = m_BgsMap.at(0);
150 }
else if ( l1Ggk != 0 ) {
152 auto bgsi = m_BgsMap.find( l1Ggk );
154 if( bgsi == m_BgsMap.end()) {
158 if( bgs ==
nullptr ) {
159 ATH_MSG_ERROR(
"Failed loading bunchgroup set from the database" );
160 return StatusCode::FAILURE;
163 const auto p = m_BgsMap.insert(std::make_pair( l1Ggk, bgs ));
164 bgs = p.first->second;
174 ATH_MSG_ERROR(
"Failed loading L1 BunchGroup set (not reading from FILE and no bgk known)" );
175 return StatusCode::FAILURE;
179 if( bgs ==
nullptr ) {
180 ATH_MSG_INFO(
"Recording empty L1BunchGroupSet set with range " << range);
183 ATH_MSG_INFO(
"Recording L1BunchGroupSet set with range " << range <<
" (key = " << bgs->bgsk() <<
")");
187 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 (L1 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
SG::WriteCondHandleKey< TrigConf::L1BunchGroupSet > m_l1BunchGroupSetOutputKey
BunchGroupCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< AthenaAttributeList > m_bgkFolderInputKey
Gaudi::Property< unsigned int > m_bgk
std::shared_ptr< L1BunchGroupSet > createFromFile(const std::string &filename) const
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_configSource
Gaudi::Property< std::string > m_filename
std::shared_ptr< L1BunchGroupSet > createFromDB(unsigned int) const
virtual StatusCode execute(const EventContext &ctx) const override
Gaudi::Property< std::string > m_dbConnection
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 loadBunchGroupSet(unsigned int bgsk, L1BunchGroupSet &bgs, const std::string &outFileName="") const
Load content from the Trigger DB into an L1PrescalesSet for a given L1PrescaleKey (L1PSK)
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...