90 edm::LogInfo(
"L1CaloHcalScaleConfigOnlineProd") <<
"object Key " << objectKey;
92 if (objectKey ==
"NULL" || objectKey.empty()) {
93 return std::make_unique<L1CaloHcalScale>(0);
95 if (objectKey ==
"IDENTITY") {
96 return std::make_unique<L1CaloHcalScale>(1);
99 std::vector<unsigned int> analyticalLUT(1024, 0);
100 std::vector<unsigned int> identityLUT(1024, 0);
103 for (
unsigned int i = 0;
i < 1024;
i++) {
104 analyticalLUT[
i] = (
unsigned int)(
sqrt(14.94 *
log(1. +
i / 14.94) *
i) + 0.5);
109 for (
int i = 0;
i < 4176;
i++) {
114 std::vector<std::string> mainStrings;
115 mainStrings.push_back(
"HCAL_LUT_METADATA");
116 mainStrings.push_back(
"HCAL_LUT_CHAN_DATA");
120 std::vector<std::string> metaStrings;
121 metaStrings.push_back(
"RCTLSB");
122 metaStrings.push_back(
"NOMINAL_GAIN");
127 "V_HCAL_LUT_METADATA_V1",
128 "V_HCAL_LUT_METADATA_V1.TAG_NAME",
132 "HCAL_SCALE_KEY.HCAL_TAG",
137 edm::LogError(
"L1-O2O") <<
"Problem with L1CaloHcalScale key. Unable to find lutparam dat table";
138 return std::unique_ptr<L1CaloHcalScale>();
141 double hcalLSB, nominal_gain;
143 paramResults.
fillVariable(
"NOMINAL_GAIN", nominal_gain);
145 float rctlsb = hcalLSB;
150 "HCAL_SCALE_KEY.HCAL_TAG",
158 coral::IQuery*
query = schema.newQuery();
161 std::vector<std::string> channelStrings;
162 channelStrings.push_back(
"IPHI");
163 channelStrings.push_back(
"IETA");
164 channelStrings.push_back(
"DEPTH");
165 channelStrings.push_back(
"LUT_GRANULARITY");
166 channelStrings.push_back(
"OUTPUT_LUT_THRESHOLD");
167 channelStrings.push_back(
"OBJECTNAME");
169 std::vector<std::string>::const_iterator it = channelStrings.begin();
170 std::vector<std::string>::const_iterator
end = channelStrings.end();
171 for (; it !=
end; ++it) {
172 query->addToOutputList(*it);
176 coral::AttributeList myresult;
177 myresult.extend(
"IPHI",
typeid(
int));
178 myresult.extend(
"IETA",
typeid(
int));
179 myresult.extend(
"DEPTH",
typeid(
int));
180 myresult.extend(
"LUT_GRANULARITY",
typeid(
int));
181 myresult.extend(
"OUTPUT_LUT_THRESHOLD",
typeid(
int));
184 query->defineOutput(myresult);
186 query->addToTableList(
"V_HCAL_LUT_CHAN_DATA_V1");
188 query->setCondition(
"V_HCAL_LUT_CHAN_DATA_V1.TAG_NAME = :" + chanKey.
columnNames().front(),
191 coral::ICursor& cursor =
query->execute();
194 std::vector<coral::AttributeList> atts;
195 while (cursor.next()) {
196 atts.push_back(cursor.currentRow());
202 if (chanResults.queryFailed() || (chanResults.numberRows() == 0))
204 edm::LogError(
"L1-O2O") <<
"Problem with L1CaloHcalScale key. Unable to find lutparam dat table nrows" 205 << chanResults.numberRows();
206 return std::unique_ptr<L1CaloHcalScale>();
209 chanResults.attributeLists();
210 for (
int i = 0;
i < chanResults.numberRows(); ++
i) {
212 chanResults.fillVariableFromRow(
"OBJECTNAME",
i,
objectName);
217 chanResults.fillVariableFromRow(
"LUT_GRANULARITY",
i, lutGranularity);
218 chanResults.fillVariableFromRow(
"IPHI",
i,
iphi);
219 chanResults.fillVariableFromRow(
"IETA",
i,
ieta);
220 chanResults.fillVariableFromRow(
"DEPTH",
i,
depth);
221 chanResults.fillVariableFromRow(
"OUTPUT_LUT_THRESHOLD",
i,
threshold);
223 unsigned int outputLut[1024];
225 const int tp_version =
depth / 10;
228 double eta_low = 0., eta_high = 0.;
230 double cosh_ieta = fabs(cosh((eta_low + eta_high) / 2.));
238 factor = nominal_gain / cosh_ieta * lutGranularity;
246 unsigned int tpg = outputLut[0];
250 for (
unsigned int k = 0;
k < 1024; ++
k) {
251 if (outputLut[
k] != tpg) {
252 unsigned int mid = (
low +
k) / 2;
262 auto hcalScale = std::make_unique<L1CaloHcalScale>(0);
265 const int tp_version = 0;
284 hcalScale->setBin(irank,
ieta,
zside, etvalue);
291 s << std::setprecision(10);
const QueryResults singleAttribute(const T &data) const
virtual bool HTvalid(const int ieta, const int iphi, const int version) const
Log< level::Error, false > LogError
int firstHFTower(int version) const
const std::vector< coral::AttributeList > & attributeLists() const
const HcalTrigTowerGeometry * theTrigTowerGeometry
static const unsigned short nBinRank
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="")
Abs< T >::type abs(const T &t)
const std::vector< std::string > & columnNames() const
bool fillVariable(const std::string &columnName, T &outputVariable) const
l1t::OMDSReader m_omdsReader
Log< level::Info, false > LogInfo
std::vector< RCTdecompression > hcaluncomp
std::vector< double > RCTdecompression
const QueryResults basicQueryView(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &viewName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="")
coral::ISessionProxy & coralSession()
CaloTPGTranscoderULUT * caloTPG
cond::persistency::Session dbSession()
void towerEtaBounds(int ieta, int version, double &eta1, double &eta2) const
where this tower begins and ends in eta
static const unsigned short nBinEta
virtual int getOutputLUTId(const HcalTrigTowerDetId &id) const