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());
202 edm::LogError(
"L1-O2O") <<
"Problem with L1CaloHcalScale key. Unable to find lutparam dat table nrows" 204 return std::unique_ptr<L1CaloHcalScale>();
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;
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;
260 auto hcalScale = std::make_unique<L1CaloHcalScale>(0);
263 const int tp_version = 0;
282 hcalScale->setBin(irank,
ieta,
zside, etvalue);
289 s << std::setprecision(10);
const QueryResults singleAttribute(const T &data) const
virtual bool HTvalid(const int ieta, const int iphi, const int version) const
~L1CaloHcalScaleConfigOnlineProd() override
L1CaloHcalScaleConfigOnlineProd(const edm::ParameterSet &iConfig)
Log< level::Error, false > LogError
std::unique_ptr< L1CaloHcalScale > newObject(const std::string &objectKey) override
int firstHFTower(int version) const
std::unique_ptr< L1CaloHcalScale > produce(const L1CaloHcalScaleRcd &iRecord) override
T const * product() 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
HcalTrigTowerDetId * ttDetId
bool fillVariableFromRow(const std::string &columnName, int rowNumber, T &outputVariable) 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="")
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
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
const DepRecordT getRecord() const
Power< A, B >::type pow(const A &a, const B &b)
virtual int getOutputLUTId(const HcalTrigTowerDetId &id) const