22 #include "boost/lexical_cast.hpp"
49 boost::shared_ptr<L1GtPsbSetup> pL1GtPsbSetup = boost::shared_ptr<L1GtPsbSetup>(
55 std::vector<L1GtPsbConfig> psbConfigurations;
60 std::vector<std::string>::iterator newEnd = std::remove_if(
62 psbColumns.erase(newEnd, psbColumns.end());
66 psbColumns, gtSchema,
"GT_SETUP",
"GT_SETUP.ID",
70 if (!
checkOneLineResult(psbKeys,
"GT_SETUP query for PSB keys with ID = " + objectKey)) {
72 <<
"Problem to get content of CMS_GT.GT_SETUP for GT_SETUP.ID key: "
78 for (std::vector<std::string>::const_iterator it = psbColumns.begin(); it != psbColumns.end(); ++it) {
91 pL1GtPsbSetup->setGtPsbSetup(psbConfigurations);
94 LogTrace(
"L1-O2O") << (*pL1GtPsbSetup) << std::endl;
107 unsigned len = columnName.size();
110 return len <= ( startMatch.size() + endMatch.size() ) ||
112 columnName.substr(0, startMatch.size()) != startMatch ||
114 columnName.substr(len - endMatch.size(), endMatch.size()) != endMatch;
156 std::vector<std::string> columnNames;
158 static const std::string lvdPrefix =
"ENABLE_TT_LVDS_";
161 static const std::string serSuffix =
"_REC_ENABLE";
162 static const std::string boardSlotColumn =
"BOARD_SLOT";
163 static const std::string ch0FormatColumn =
"CH0_SEND_LVDS_NOT_DS92LV16";
164 static const std::string ch1FormatColumn =
"CH1_SEND_LVDS_NOT_DS92LV16";
166 columnNames.push_back(boardSlotColumn);
167 columnNames.push_back(ch0FormatColumn);
168 columnNames.push_back(ch1FormatColumn);
184 if (!
checkOneLineResult(psbQuery,
"GT_PSB_SETUP query for PSB keys with ID = " + psbKey)) {
186 <<
"Problem to get setup for PSB keys with ID = " << psbKey;
195 bool sendLvds0, sendLvds1;
215 psbSetup.push_back(toAdd);
235 psbSetup.push_back(toAdd);
242 std::vector<bool>
result(nColumns);
244 for (
unsigned i = 0;
i < nColumns; ++
i) {
258 edm::LogError(
"L1-O2O") <<
"\n " << queryDescription +
" failed: no match found!";
262 edm::LogError(
"L1-O2O") <<
"\nProblem with " << queryDescription <<
": "
263 << ( result.
numberRows() ) <<
" rows were returned, expected 1.";
281 std::ostringstream colName;
282 colName << prefix << number <<
suffix;
284 return colName.str();
289 std::istringstream stream(aString);
292 for (
unsigned i = 0;
i < aString.size(); ++
i) {
293 if (stream >> result) {
305 throw cms::Exception(
"NumberNotFound") <<
"Failed to extract numeric value from " << aString;
bool checkOneLineResult(const l1t::OMDSReader::QueryResults &result, const std::string &queryDescription) const
Ensures that result contains exactly one line, returning false otherwise.
static bool notPsbColumnName(const std::string &columnName)
std::string numberedColumnName(const std::string &prefix, unsigned number, const std::string &suffix) const
Concatenates prefix, number and suffix into a string.
bool fillVariable(const std::string &columnName, T &outputVariable) const
const QueryResults singleAttribute(const T &data) const
void getRequiredValue(const l1t::OMDSReader::QueryResults &result, const std::string &colName, T &value) const
void setGtPsbEnableRecLvds(const std::vector< bool > &)
void setGtPsbCh0SendLvds(const bool &)
void addDefaultPsb(const std::string &psbColumn, std::vector< L1GtPsbConfig > &psbSetup) const
Creates a default valued PSB from an empty foreign key in the GT_SETUP table.
static const int PsbSerLinkNumberChannels
number of channels per board
virtual boost::shared_ptr< L1GtPsbSetup > newObject(const std::string &objectKey)
public methods
static const int PsbNumberLvdsGroups
number of LVDS groups per board
void setGtPsbEnableRecSerLink(const std::vector< bool > &)
const QueryResults basicQuery(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="") const
l1t::OMDSReader m_omdsReader
std::vector< bool > extractBoolVector(const l1t::OMDSReader::QueryResults &query, const std::string &prefix, const std::string &suffix, unsigned nColumns) const
~L1GtPsbSetupConfigOnlineProd()
destructor
void setGtBoardSlot(const int &)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
L1GtPsbSetupConfigOnlineProd(const edm::ParameterSet &)
constructor
void setGtPsbCh1SendLvds(const bool &)
void addPsbFromDb(const std::string &psbKey, std::vector< L1GtPsbConfig > &psbSetup) const
Creates a new PSB object from a GT_PSB_SETUP entry and adds.
std::vector< std::string > columnNames(const std::string &schemaName, const std::string &tableName) const
unsigned numberFromString(const std::string &aString) const