CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
L1CaloHcalScaleConfigOnlineProd Class Reference
Inheritance diagram for L1CaloHcalScaleConfigOnlineProd:
L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale > edm::ESProducer edm::ESProductResolverFactoryProducer edm::eventsetup::ESProductResolverProvider

Public Member Functions

 L1CaloHcalScaleConfigOnlineProd (const edm::ParameterSet &iConfig)
 
std::unique_ptr< L1CaloHcalScalenewObject (const std::string &objectKey) override
 
std::unique_ptr< L1CaloHcalScaleproduce (const L1CaloHcalScaleRcd &iRecord) override
 
 ~L1CaloHcalScaleConfigOnlineProd () override
 
- Public Member Functions inherited from L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >
 L1ConfigOnlineProdBase (const edm::ParameterSet &)
 
 ~L1ConfigOnlineProdBase () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
 ESProducer (ESProducer &&)=delete
 
ESResolverIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProduceroperator= (const ESProducer &)=delete
 
ESProduceroperator= (ESProducer &&)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESResolverIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProductResolverFactoryProducer
 ESProductResolverFactoryProducer ()
 
 ESProductResolverFactoryProducer (const ESProductResolverFactoryProducer &)=delete
 
const ESProductResolverFactoryProduceroperator= (const ESProductResolverFactoryProducer &)=delete
 
 ~ESProductResolverFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
void createKeyedResolvers (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
const ComponentDescriptiondescription () const
 
 ESProductResolverProvider ()
 
 ESProductResolverProvider (const ESProductResolverProvider &)=delete
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedResolverskeyedResolvers (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const ESProductResolverProvideroperator= (const ESProductResolverProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~ESProductResolverProvider () noexcept(false)
 

Private Types

typedef std::vector< double > RCTdecompression
 

Private Attributes

CaloTPGTranscoderULUTcaloTPG
 
std::vector< RCTdecompressionhcaluncomp
 
const HcalTrigTowerGeometrytheTrigTowerGeometry
 
edm::ESGetToken< HcalTrigTowerGeometry, CaloGeometryRecordtheTrigTowerGeometryToken
 
HcalTrigTowerDetIdttDetId
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Types inherited from edm::ESProductResolverFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::ESProductResolverProvider
using KeyedResolversVector = std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >>
 
- Protected Member Functions inherited from L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >
bool getObjectKey (const L1CaloHcalScaleRcd &record, std::string &objectKey)
 
- Protected Member Functions inherited from edm::ESProducer
ESConsumesInfoconsumesInfoPushBackNew ()
 
unsigned int consumesInfoSize () const
 
template<typename CallbackT , typename TList , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>> iCallback, const TList *, const TRecord *iRecord, const es::Label &iLabel)
 
template<typename CallbackT , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>>, const eventsetup::produce::Null *, const TRecord *, const es::Label &)
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TDecorator >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename TFunc >
auto setWhatProduced (TFunc &&func, const es::Label &iLabel={})
 
template<typename TReturn , typename TRecord , typename TFunc , typename TDecorator >
ESConsumesCollectorT< TRecord > setWhatProduced (TFunc &&func, TDecorator &&iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProductResolverFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ESProductResolverFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedResolversVector registerResolvers (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::ESProductResolverProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 
- Protected Attributes inherited from L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >
std::optional< edm::ESConsumesCollectorT< L1CaloHcalScaleRcd > > m_consumesCollector
 
bool m_copyFromCondDB
 
cond::persistency::Session m_dbSession
 
bool m_forceGeneration
 
l1t::OMDSReader m_omdsReader
 

Detailed Description

Definition at line 39 of file L1CaloHcalScaleConfigOnlineProd.cc.

Member Typedef Documentation

◆ RCTdecompression

typedef std::vector<double> L1CaloHcalScaleConfigOnlineProd::RCTdecompression
private

Definition at line 52 of file L1CaloHcalScaleConfigOnlineProd.cc.

Constructor & Destructor Documentation

◆ L1CaloHcalScaleConfigOnlineProd()

L1CaloHcalScaleConfigOnlineProd::L1CaloHcalScaleConfigOnlineProd ( const edm::ParameterSet iConfig)

◆ ~L1CaloHcalScaleConfigOnlineProd()

L1CaloHcalScaleConfigOnlineProd::~L1CaloHcalScaleConfigOnlineProd ( )
override

Definition at line 79 of file L1CaloHcalScaleConfigOnlineProd.cc.

References caloTPG.

79  {
80  // do anything here that needs to be done at desctruction time
81  // (e.g. close files, deallocate resources etc.)
82 
83  if (caloTPG != nullptr)
84  delete caloTPG;
85 }

Member Function Documentation

◆ newObject()

std::unique_ptr< L1CaloHcalScale > L1CaloHcalScaleConfigOnlineProd::newObject ( const std::string &  objectKey)
overridevirtual

Implements L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >.

Definition at line 87 of file L1CaloHcalScaleConfigOnlineProd.cc.

References funct::abs(), cms::cuda::assert(), l1t::OMDSReader::QueryResults::attributeLists(), l1t::OMDSReader::basicQuery(), l1t::OMDSReader::basicQueryView(), caloTPG, l1t::OMDSReader::QueryResults::columnNames(), cond::persistency::Session::coralSession(), l1t::DataManager::dbSession(), hcalRecHitTable_cff::depth, mps_fire::end, l1t::OMDSReader::QueryResults::fillVariable(), l1t::OMDSReader::QueryResults::fillVariableFromRow(), HcalTrigTowerGeometry::firstHFTower(), CaloTPGTranscoderULUT::getOutputLUTId(), hcaluncomp, CaloTPGTranscoderULUT::HTvalid(), mps_fire::i, hcalRecHitTable_cff::ieta, createfilelist::int, hcalRecHitTable_cff::iphi, dqmdumpme::k, dqm-mbProfile::log, LaserClient_cfi::low, L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >::m_omdsReader, SiStripPI::min, L1CaloHcalScale::nBinEta, L1CaloHcalScale::nBinRank, nphi, l1t::OMDSReader::QueryResults::numberRows(), summarizeEdmComparisonLogfiles::objectName, funct::pow(), contentValuesFiles::query, l1t::OMDSReader::QueryResults::queryFailed(), alignCSCRings::s, l1t::OMDSReader::singleAttribute(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, theTrigTowerGeometry, DiMuonV_cfg::threshold, HcalTrigTowerGeometry::towerEtaBounds(), and ecaldqm::zside().

87  {
88  assert(theTrigTowerGeometry != nullptr);
89 
90  edm::LogInfo("L1CaloHcalScaleConfigOnlineProd") << "object Key " << objectKey;
91 
92  if (objectKey == "NULL" || objectKey.empty()) { // return default blank ecal scale
93  return std::make_unique<L1CaloHcalScale>(0);
94  }
95  if (objectKey == "IDENTITY") { // return identity ecal scale
96  return std::make_unique<L1CaloHcalScale>(1);
97  }
98 
99  std::vector<unsigned int> analyticalLUT(1024, 0);
100  std::vector<unsigned int> identityLUT(1024, 0);
101 
102  // Compute compression LUT
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);
105  identityLUT[i] = std::min(i, 0xffu);
106  }
107 
108  hcaluncomp.clear();
109  for (int i = 0; i < 4176; i++) {
110  RCTdecompression decompressionTable(256, 0);
111  hcaluncomp.push_back(decompressionTable);
112  }
113 
114  std::vector<std::string> mainStrings;
115  mainStrings.push_back("HCAL_LUT_METADATA");
116  mainStrings.push_back("HCAL_LUT_CHAN_DATA");
117 
118  // ~~~~~~~~~ Cut values ~~~~~~~~~
119 
120  std::vector<std::string> metaStrings;
121  metaStrings.push_back("RCTLSB");
122  metaStrings.push_back("NOMINAL_GAIN");
123 
124  l1t::OMDSReader::QueryResults paramResults =
125  m_omdsReader.basicQueryView(metaStrings,
126  "CMS_HCL_HCAL_COND",
127  "V_HCAL_LUT_METADATA_V1",
128  "V_HCAL_LUT_METADATA_V1.TAG_NAME",
129  m_omdsReader.basicQuery("HCAL_LUT_METADATA",
130  "CMS_RCT",
131  "HCAL_SCALE_KEY",
132  "HCAL_SCALE_KEY.HCAL_TAG",
133  m_omdsReader.singleAttribute(objectKey)));
134 
135  if (paramResults.queryFailed() || (paramResults.numberRows() != 1)) // check query successful
136  {
137  edm::LogError("L1-O2O") << "Problem with L1CaloHcalScale key. Unable to find lutparam dat table";
138  return std::unique_ptr<L1CaloHcalScale>();
139  }
140 
141  double hcalLSB, nominal_gain;
142  paramResults.fillVariable("RCTLSB", hcalLSB);
143  paramResults.fillVariable("NOMINAL_GAIN", nominal_gain);
144 
145  float rctlsb = hcalLSB;
146 
147  l1t::OMDSReader::QueryResults chanKey = m_omdsReader.basicQuery("HCAL_LUT_CHAN_DATA",
148  "CMS_RCT",
149  "HCAL_SCALE_KEY",
150  "HCAL_SCALE_KEY.HCAL_TAG",
151  m_omdsReader.singleAttribute(objectKey));
152 
153  //coral::AttributeList myresult;
154  // myresult.extend(
155 
156  std::string schemaName("CMS_HCL_HCAL_COND");
157  coral::ISchema& schema = m_omdsReader.dbSession().coralSession().schema(schemaName);
158  coral::IQuery* query = schema.newQuery();
159  ;
160 
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");
168 
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);
173  }
174 
175  std::string ob = "OBJECTNAME";
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));
182  myresult.extend(ob, typeid(std::string)); //, typeid(std::string));
183 
184  query->defineOutput(myresult);
185 
186  query->addToTableList("V_HCAL_LUT_CHAN_DATA_V1");
187 
188  query->setCondition("V_HCAL_LUT_CHAN_DATA_V1.TAG_NAME = :" + chanKey.columnNames().front(),
189  chanKey.attributeLists().front());
190 
191  coral::ICursor& cursor = query->execute();
192 
193  // when the query goes out of scope.
194  std::vector<coral::AttributeList> atts;
195  while (cursor.next()) {
196  atts.push_back(cursor.currentRow());
197  };
198 
199  delete query;
200 
201  l1t::OMDSReader::QueryResults chanResults(channelStrings, atts);
202  if (chanResults.queryFailed() || (chanResults.numberRows() == 0)) // check query successful
203  {
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>();
207  }
208 
209  chanResults.attributeLists();
210  for (int i = 0; i < chanResults.numberRows(); ++i) {
212  chanResults.fillVariableFromRow("OBJECTNAME", i, objectName);
213  // int
214  if (objectName == "HcalTrigTowerDetId") { //trig tower
215  int ieta, iphi, depth, lutGranularity, threshold;
216 
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);
222 
223  unsigned int outputLut[1024];
224 
225  const int tp_version = depth / 10;
226  uint32_t lutId = caloTPG->getOutputLUTId(ieta, iphi, tp_version);
227 
228  double eta_low = 0., eta_high = 0.;
229  theTrigTowerGeometry->towerEtaBounds(ieta, tp_version, eta_low, eta_high);
230  double cosh_ieta = fabs(cosh((eta_low + eta_high) / 2.));
231 
232  if (!caloTPG->HTvalid(ieta, iphi, tp_version))
233  continue;
234  double factor = 0.;
235  if (abs(ieta) >= theTrigTowerGeometry->firstHFTower(tp_version))
236  factor = rctlsb;
237  else
238  factor = nominal_gain / cosh_ieta * lutGranularity;
239  for (int k = 0; k < threshold; ++k)
240  outputLut[k] = 0;
241 
242  for (unsigned int k = threshold; k < 1024; ++k)
243  outputLut[k] = (abs(ieta) < theTrigTowerGeometry->firstHFTower(tp_version)) ? analyticalLUT[k] : identityLUT[k];
244 
245  // tpg - compressed value
246  unsigned int tpg = outputLut[0];
247 
248  int low = 0;
249 
250  for (unsigned int k = 0; k < 1024; ++k) {
251  if (outputLut[k] != tpg) {
252  unsigned int mid = (low + k) / 2;
253  hcaluncomp[lutId][tpg] = (tpg == 0 ? low : factor * mid);
254  low = k;
255  tpg = outputLut[k];
256  }
257  }
258  hcaluncomp[lutId][tpg] = factor * low;
259  }
260  }
261 
262  auto hcalScale = std::make_unique<L1CaloHcalScale>(0);
263 
264  // XXX L1CaloHcalScale is only setup for 2x3 TP
265  const int tp_version = 0;
266  for (unsigned short ieta = 1; ieta <= L1CaloHcalScale::nBinEta; ++ieta) {
267  for (int pos = 0; pos <= 1; pos++) {
268  for (unsigned short irank = 0; irank < L1CaloHcalScale::nBinRank; ++irank) {
269  int zside = (int)pow(-1, pos);
270  int nphi = 0;
271  double etvalue = 0.;
272 
273  for (int iphi = 1; iphi <= 72; iphi++) {
274  if (!caloTPG->HTvalid(ieta, iphi, tp_version))
275  continue;
276  uint32_t lutId = caloTPG->getOutputLUTId(ieta, iphi, tp_version);
277  nphi++;
278  etvalue += (double)hcaluncomp[lutId][irank];
279 
280  } // phi
281  if (nphi > 0)
282  etvalue /= nphi;
283 
284  hcalScale->setBin(irank, ieta, zside, etvalue);
285 
286  } // rank
287  } // zside
288  } // eta
289 
290  std::stringstream s;
291  s << std::setprecision(10);
292  hcalScale->print(s);
293  edm::LogInfo("L1CaloHcalScaleConfigOnlineProd") << s.str();
294  // ------------ method called to produce the data ------------
295  return hcalScale;
296 }
const int nphi
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
virtual bool HTvalid(const int ieta, const int iphi, const int version) const
int zside(DetId const &)
Log< level::Error, false > LogError
assert(be >=bs)
Definition: query.py:1
int firstHFTower(int version) const
const std::vector< coral::AttributeList > & attributeLists() const
Definition: OMDSReader.h:58
const HcalTrigTowerGeometry * theTrigTowerGeometry
T sqrt(T t)
Definition: SSEVec.h:19
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="")
Definition: OMDSReader.cc:75
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector< std::string > & columnNames() const
Definition: OMDSReader.h:57
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:274
Log< level::Info, false > LogInfo
std::vector< RCTdecompression > hcaluncomp
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="")
Definition: OMDSReader.cc:158
coral::ISessionProxy & coralSession()
Definition: Session.cc:218
cond::persistency::Session dbSession()
Definition: DataManager.h:26
void towerEtaBounds(int ieta, int version, double &eta1, double &eta2) const
where this tower begins and ends in eta
static const unsigned short nBinEta
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
virtual int getOutputLUTId(const HcalTrigTowerDetId &id) const

◆ produce()

std::unique_ptr< L1CaloHcalScale > L1CaloHcalScaleConfigOnlineProd::produce ( const L1CaloHcalScaleRcd iRecord)
overridevirtual

Member Data Documentation

◆ caloTPG

CaloTPGTranscoderULUT* L1CaloHcalScaleConfigOnlineProd::caloTPG
private

◆ hcaluncomp

std::vector<RCTdecompression> L1CaloHcalScaleConfigOnlineProd::hcaluncomp
private

Definition at line 53 of file L1CaloHcalScaleConfigOnlineProd.cc.

Referenced by newObject().

◆ theTrigTowerGeometry

const HcalTrigTowerGeometry* L1CaloHcalScaleConfigOnlineProd::theTrigTowerGeometry
private

Definition at line 50 of file L1CaloHcalScaleConfigOnlineProd.cc.

Referenced by newObject(), and produce().

◆ theTrigTowerGeometryToken

edm::ESGetToken<HcalTrigTowerGeometry, CaloGeometryRecord> L1CaloHcalScaleConfigOnlineProd::theTrigTowerGeometryToken
private

Definition at line 49 of file L1CaloHcalScaleConfigOnlineProd.cc.

Referenced by L1CaloHcalScaleConfigOnlineProd(), and produce().

◆ ttDetId

HcalTrigTowerDetId* L1CaloHcalScaleConfigOnlineProd::ttDetId
private

Definition at line 57 of file L1CaloHcalScaleConfigOnlineProd.cc.