88 edm::LogInfo(
"L1CaloHcalScaleConfigOnlineProd") <<
"object Key " << objectKey;
90 if (objectKey ==
"NULL" || objectKey.empty()) {
91 return std::make_unique<L1CaloHcalScale>(0);
93 if (objectKey ==
"IDENTITY") {
94 return std::make_unique<L1CaloHcalScale>(1);
97 std::vector<unsigned int> analyticalLUT(1024, 0);
98 std::vector<unsigned int> identityLUT(1024, 0);
101 for (
unsigned int i = 0;
i < 1024;
i++) {
102 analyticalLUT[
i] = (
unsigned int)(
sqrt(14.94 *
log(1. +
i / 14.94) *
i) + 0.5);
107 for (
int i = 0;
i < 4176;
i++) {
112 std::vector<std::string> mainStrings;
113 mainStrings.push_back(
"HCAL_LUT_METADATA");
114 mainStrings.push_back(
"HCAL_LUT_CHAN_DATA");
118 std::vector<std::string> metaStrings;
119 metaStrings.push_back(
"RCTLSB");
120 metaStrings.push_back(
"NOMINAL_GAIN");
125 "V_HCAL_LUT_METADATA_V1",
126 "V_HCAL_LUT_METADATA_V1.TAG_NAME",
130 "HCAL_SCALE_KEY.HCAL_TAG",
135 edm::LogError(
"L1-O2O") <<
"Problem with L1CaloHcalScale key. Unable to find lutparam dat table";
136 return std::unique_ptr<L1CaloHcalScale>();
139 double hcalLSB, nominal_gain;
141 paramResults.
fillVariable(
"NOMINAL_GAIN", nominal_gain);
143 float rctlsb = hcalLSB;
148 "HCAL_SCALE_KEY.HCAL_TAG",
156 coral::IQuery*
query = schema.newQuery();
159 std::vector<std::string> channelStrings;
160 channelStrings.push_back(
"IPHI");
161 channelStrings.push_back(
"IETA");
162 channelStrings.push_back(
"DEPTH");
163 channelStrings.push_back(
"LUT_GRANULARITY");
164 channelStrings.push_back(
"OUTPUT_LUT_THRESHOLD");
165 channelStrings.push_back(
"OBJECTNAME");
167 std::vector<std::string>::const_iterator it = channelStrings.begin();
168 std::vector<std::string>::const_iterator
end = channelStrings.end();
169 for (; it !=
end; ++it) {
170 query->addToOutputList(*it);
174 coral::AttributeList myresult;
175 myresult.extend(
"IPHI",
typeid(
int));
176 myresult.extend(
"IETA",
typeid(
int));
177 myresult.extend(
"DEPTH",
typeid(
int));
178 myresult.extend(
"LUT_GRANULARITY",
typeid(
int));
179 myresult.extend(
"OUTPUT_LUT_THRESHOLD",
typeid(
int));
182 query->defineOutput(myresult);
184 query->addToTableList(
"V_HCAL_LUT_CHAN_DATA_V1");
186 query->setCondition(
"V_HCAL_LUT_CHAN_DATA_V1.TAG_NAME = :" + chanKey.
columnNames().front(),
189 coral::ICursor& cursor = query->execute();
192 std::vector<coral::AttributeList> atts;
193 while (cursor.next()) {
194 atts.push_back(cursor.currentRow());
200 if (chanResults.queryFailed() || (chanResults.numberRows() == 0))
202 edm::LogError(
"L1-O2O") <<
"Problem with L1CaloHcalScale key. Unable to find lutparam dat table nrows"
203 << chanResults.numberRows();
204 return std::unique_ptr<L1CaloHcalScale>();
207 chanResults.attributeLists();
208 for (
int i = 0;
i < chanResults.numberRows(); ++
i) {
210 chanResults.fillVariableFromRow(
"OBJECTNAME",
i, objectName);
212 if (objectName ==
"HcalTrigTowerDetId") {
215 chanResults.fillVariableFromRow(
"LUT_GRANULARITY",
i, lutGranularity);
216 chanResults.fillVariableFromRow(
"IPHI",
i, iphi);
217 chanResults.fillVariableFromRow(
"IETA",
i, ieta);
218 chanResults.fillVariableFromRow(
"DEPTH",
i, depth);
219 chanResults.fillVariableFromRow(
"OUTPUT_LUT_THRESHOLD",
i, threshold);
221 unsigned int outputLut[1024];
223 const int tp_version = depth / 10;
226 double eta_low = 0., eta_high = 0.;
228 double cosh_ieta = fabs(cosh((eta_low + eta_high) / 2.));
236 factor = nominal_gain / cosh_ieta * lutGranularity;
240 for (
unsigned int k = threshold;
k < 1024; ++
k)
244 unsigned int tpg = outputLut[0];
248 for (
unsigned int k = 0;
k < 1024; ++
k) {
249 if (outputLut[
k] != tpg) {
250 unsigned int mid = (low +
k) / 2;
251 hcaluncomp[lutId][tpg] = (tpg == 0 ? low : factor * mid);
260 auto hcalScale = std::make_unique<L1CaloHcalScale>(0);
263 const int tp_version = 0;
265 for (
int pos = 0; pos <= 1; pos++) {
271 for (
int iphi = 1; iphi <= 72; iphi++) {
282 hcalScale->setBin(irank, ieta, zside, etvalue);
289 s << std::setprecision(10);
291 edm::LogInfo(
"L1CaloHcalScaleConfigOnlineProd") << s.str();
static std::vector< std::string > checklist log
bool fillVariable(const std::string &columnName, T &outputVariable) const
const QueryResults singleAttribute(const T &data) const
virtual bool HTvalid(const int ieta, const int iphi, const int version) const
void towerEtaBounds(int ieta, int version, double &eta1, double &eta2) const
where this tower begins and ends in eta
Log< level::Error, false > LogError
const std::vector< coral::AttributeList > & attributeLists() const
const HcalTrigTowerGeometry * theTrigTowerGeometry
const std::vector< std::string > & columnNames() const
virtual int getOutputLUTId(const HcalTrigTowerDetId &id) const
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)
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()
static const unsigned short nBinEta
Power< A, B >::type pow(const A &a, const B &b)
int firstHFTower(int version) const