CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Types | Private Attributes
L1CaloHcalScaleConfigOnlineProd Class Reference
Inheritance diagram for L1CaloHcalScaleConfigOnlineProd:
L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale > edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

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
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProducer const & operator= (const ESProducer &)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector
< ESProxyIndex > > 
updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
 ESProxyFactoryProducer (const ESProxyFactoryProducer &)=delete
 
const ESProxyFactoryProduceroperator= (const ESProxyFactoryProducer &)=delete
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
void createKeyedProxies (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
 DataProxyProvider ()
 
 DataProxyProvider (const DataProxyProvider &)=delete
 
const ComponentDescriptiondescription () const
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const DataProxyProvideroperator= (const DataProxyProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 

Private Types

typedef std::vector< double > RCTdecompression
 

Private Attributes

CaloTPGTranscoderULUTcaloTPG
 
std::vector< RCTdecompressionhcaluncomp
 
const HcalTrigTowerGeometrytheTrigTowerGeometry
 
HcalTrigTowerDetIdttDetId
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Types inherited from edm::ESProxyFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::DataProxyProvider
using KeyedProxiesVector = std::vector< std::pair< DataKey, std::shared_ptr< DataProxy >>>
 
- Protected Member Functions inherited from L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >
bool getObjectKey (const L1CaloHcalScaleRcd &record, std::string &objectKey)
 
- Protected Member Functions inherited from edm::ESProducer
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 TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
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::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedProxiesVector registerProxies (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 
- Protected Attributes inherited from L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >
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

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

Definition at line 51 of file L1CaloHcalScaleConfigOnlineProd.cc.

Constructor & Destructor Documentation

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

Definition at line 77 of file L1CaloHcalScaleConfigOnlineProd.cc.

References caloTPG.

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

Member Function Documentation

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

Implements L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >.

Definition at line 85 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(), HLT_FULL_cff::depth, dataset::end, l1t::OMDSReader::QueryResults::fillVariable(), l1t::OMDSReader::QueryResults::fillVariableFromRow(), HcalTrigTowerGeometry::firstHFTower(), CaloTPGTranscoderULUT::getOutputLUTId(), hcaluncomp, CaloTPGTranscoderULUT::HTvalid(), mps_fire::i, isotrackApplyRegressor::k, log, L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >::m_omdsReader, 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, dtDQMClient_cfg::threshold, HcalTrigTowerGeometry::towerEtaBounds(), and ecaldqm::zside().

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

Member Data Documentation

CaloTPGTranscoderULUT* L1CaloHcalScaleConfigOnlineProd::caloTPG
private
std::vector<RCTdecompression> L1CaloHcalScaleConfigOnlineProd::hcaluncomp
private

Definition at line 52 of file L1CaloHcalScaleConfigOnlineProd.cc.

Referenced by newObject().

const HcalTrigTowerGeometry* L1CaloHcalScaleConfigOnlineProd::theTrigTowerGeometry
private

Definition at line 49 of file L1CaloHcalScaleConfigOnlineProd.cc.

Referenced by newObject(), and produce().

HcalTrigTowerDetId* L1CaloHcalScaleConfigOnlineProd::ttDetId
private

Definition at line 56 of file L1CaloHcalScaleConfigOnlineProd.cc.