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::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 ()
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
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

- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >
bool getObjectKey (const L1CaloHcalScaleRcd &record, std::string &objectKey)
 
- Protected Member Functions inherited from edm::ESProducer
 ESProducer (const ESProducer &)=delete
 
ESProducer const & operator= (const ESProducer &)=delete
 
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={})
 
- 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 eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 
- 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 40 of file L1CaloHcalScaleConfigOnlineProd.cc.

Member Typedef Documentation

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

Definition at line 55 of file L1CaloHcalScaleConfigOnlineProd.cc.

Constructor & Destructor Documentation

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

Definition at line 86 of file L1CaloHcalScaleConfigOnlineProd.cc.

References caloTPG.

87 {
88  // do anything here that needs to be done at desctruction time
89  // (e.g. close files, deallocate resources etc.)
90 
91  if(caloTPG != nullptr)
92  delete caloTPG;
93 }

Member Function Documentation

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

Implements L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >.

Definition at line 96 of file L1CaloHcalScaleConfigOnlineProd.cc.

References funct::abs(), l1t::OMDSReader::QueryResults::attributeLists(), l1t::OMDSReader::basicQuery(), l1t::OMDSReader::basicQueryView(), caloTPG, l1t::OMDSReader::QueryResults::columnNames(), cond::persistency::Session::coralSession(), l1t::DataManager::dbSession(), egammaForCoreTracking_cff::depth, end, l1t::OMDSReader::QueryResults::fillVariable(), l1t::OMDSReader::QueryResults::fillVariableFromRow(), HcalTrigTowerGeometry::firstHFTower(), CaloTPGTranscoderULUT::getOutputLUTId(), hcaluncomp, CaloTPGTranscoderULUT::HTvalid(), mps_fire::i, createfilelist::int, gen::k, cmsBatch::log, L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >::m_omdsReader, min(), L1CaloHcalScale::nBinEta, L1CaloHcalScale::nBinRank, CaloTPGTranscoder_cfi::nominal_gain, l1t::OMDSReader::QueryResults::numberRows(), summarizeEdmComparisonLogfiles::objectName, funct::pow(), das::query(), l1t::OMDSReader::QueryResults::queryFailed(), alignCSCRings::s, dataDML::schema, l1t::OMDSReader::singleAttribute(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, theTrigTowerGeometry, electronIdCutBased_cfi::threshold, HcalTrigTowerGeometry::towerEtaBounds(), and ecaldqm::zside().

97 {
98  assert( theTrigTowerGeometry != nullptr );
99 
100  edm::LogInfo("L1CaloHcalScaleConfigOnlineProd") << "object Key " << objectKey;
101 
102  if(objectKey == "NULL" || objectKey.empty()) { // return default blank ecal scale
103  return std::make_unique<L1CaloHcalScale>(0);
104  }
105  if(objectKey == "IDENTITY") { // return identity ecal scale
106  return std::make_unique<L1CaloHcalScale>(1);
107  }
108 
109  std::vector<unsigned int> analyticalLUT(1024, 0);
110  std::vector<unsigned int> identityLUT(1024, 0);
111 
112  // Compute compression LUT
113  for (unsigned int i=0; i < 1024; i++) {
114  analyticalLUT[i] = (unsigned int)(sqrt(14.94*log(1.+i/14.94)*i) + 0.5);
115  identityLUT[i] = std::min(i,0xffu);
116  }
117 
118  hcaluncomp.clear();
119  for (int i = 0; i < 4176; i++){
120  RCTdecompression decompressionTable(256,0);
121  hcaluncomp.push_back(decompressionTable);
122  }
123 
124 
125 
126  std::vector < std::string > mainStrings;
127  mainStrings.push_back("HCAL_LUT_METADATA");
128  mainStrings.push_back("HCAL_LUT_CHAN_DATA");
129 
130  // ~~~~~~~~~ Cut values ~~~~~~~~~
131 
132 
133  std::vector< std::string > metaStrings ;
134  metaStrings.push_back("RCTLSB");
135  metaStrings.push_back("NOMINAL_GAIN");
136 
137 
138  l1t::OMDSReader::QueryResults paramResults =
139  m_omdsReader.basicQueryView( metaStrings,
140  "CMS_HCL_HCAL_COND",
141  "V_HCAL_LUT_METADATA_V1",
142  "V_HCAL_LUT_METADATA_V1.TAG_NAME",
144  "HCAL_LUT_METADATA",
145  "CMS_RCT",
146  "HCAL_SCALE_KEY",
147  "HCAL_SCALE_KEY.HCAL_TAG",
148  m_omdsReader.singleAttribute(objectKey)));
149 
150 
151 
152 
153  if( paramResults.queryFailed()
154  || (paramResults.numberRows()!=1) ) // check query successful
155  {
156  edm::LogError( "L1-O2O" ) << "Problem with L1CaloHcalScale key. Unable to find lutparam dat table" ;
157  return std::unique_ptr< L1CaloHcalScale >() ;
158  }
159 
160  double hcalLSB, nominal_gain;
161  paramResults.fillVariable("RCTLSB",hcalLSB);
162  paramResults.fillVariable("NOMINAL_GAIN",nominal_gain);
163 
164  float rctlsb = hcalLSB;
165 
166 
167 
169  "HCAL_LUT_CHAN_DATA",
170  "CMS_RCT",
171  "HCAL_SCALE_KEY",
172  "HCAL_SCALE_KEY.HCAL_TAG",
173  m_omdsReader.singleAttribute(objectKey));
174 
175  //coral::AttributeList myresult;
176  // myresult.extend(
177 
178 
179  std::string schemaName("CMS_HCL_HCAL_COND");
180  coral::ISchema& schema = m_omdsReader.dbSession().coralSession().schema( schemaName ) ;
181  coral::IQuery* query = schema.newQuery(); ;
182 
183 
184  std::vector< std::string > channelStrings;
185  channelStrings.push_back("IPHI");
186  channelStrings.push_back("IETA");
187  channelStrings.push_back("DEPTH");
188  channelStrings.push_back("LUT_GRANULARITY");
189  channelStrings.push_back("OUTPUT_LUT_THRESHOLD");
190  channelStrings.push_back("OBJECTNAME");
191 
192 
193 
194  std::vector< std::string >::const_iterator it = channelStrings.begin() ;
195  std::vector< std::string >::const_iterator end = channelStrings.end() ;
196  for( ; it != end ; ++it )
197  {
198  query->addToOutputList( *it ) ;
199  }
200 
201  std::string ob = "OBJECTNAME";
202  coral::AttributeList myresult;
203  myresult.extend("IPHI", typeid(int));
204  myresult.extend("IETA", typeid(int));
205  myresult.extend("DEPTH", typeid(int));
206  myresult.extend("LUT_GRANULARITY", typeid(int));
207  myresult.extend("OUTPUT_LUT_THRESHOLD", typeid(int));
208  myresult.extend( ob,typeid(std::string));//, typeid(std::string));
209 
210  query->defineOutput( myresult );
211 
212  query->addToTableList( "V_HCAL_LUT_CHAN_DATA_V1");
213 
214  query->setCondition(
215  "V_HCAL_LUT_CHAN_DATA_V1.TAG_NAME = :" + chanKey.columnNames().front(),
216  chanKey.attributeLists().front());
217 
218  coral::ICursor& cursor = query->execute();
219 
220  // when the query goes out of scope.
221  std::vector<coral::AttributeList> atts;
222  while (cursor.next()) {
223  atts.push_back(cursor.currentRow());
224  };
225 
226  delete query;
227 
228  l1t::OMDSReader::QueryResults chanResults(channelStrings,atts);
229  if( chanResults.queryFailed()
230  || (chanResults.numberRows()==0) ) // check query successful
231  {
232  edm::LogError( "L1-O2O" ) << "Problem with L1CaloHcalScale key. Unable to find lutparam dat table nrows" << chanResults.numberRows() ;
233  return std::unique_ptr< L1CaloHcalScale >() ;
234  }
235 
236 
237 
238  chanResults.attributeLists();
239  for(int i = 0; i < chanResults.numberRows() ; ++i){
241  chanResults.fillVariableFromRow("OBJECTNAME",i, objectName);
242  // int
243  if(objectName == "HcalTrigTowerDetId") { //trig tower
244  int ieta, iphi, depth, lutGranularity, threshold;
245 
246 
247  chanResults.fillVariableFromRow("LUT_GRANULARITY",i,lutGranularity);
248  chanResults.fillVariableFromRow("IPHI",i,iphi);
249  chanResults.fillVariableFromRow("IETA",i,ieta);
250  chanResults.fillVariableFromRow("DEPTH",i,depth);
251  chanResults.fillVariableFromRow("OUTPUT_LUT_THRESHOLD",i,threshold);
252 
253 
254  unsigned int outputLut[1024];
255 
256  const int tp_version = depth / 10;
257  uint32_t lutId = caloTPG->getOutputLUTId(ieta, iphi, tp_version);
258 
259  double eta_low = 0., eta_high = 0.;
260  theTrigTowerGeometry->towerEtaBounds(ieta, tp_version, eta_low, eta_high);
261  double cosh_ieta = fabs(cosh((eta_low + eta_high)/2.));
262 
263 
264  if (!caloTPG->HTvalid(ieta, iphi, tp_version)) continue;
265  double factor = 0.;
266  if (abs(ieta) >= theTrigTowerGeometry->firstHFTower(tp_version))
267  factor = rctlsb;
268  else
269  factor = nominal_gain / cosh_ieta * lutGranularity;
270  for (int k = 0; k < threshold; ++k)
271  outputLut[k] = 0;
272 
273  for (unsigned int k = threshold; k < 1024; ++k)
274  outputLut[k] = (abs(ieta) < theTrigTowerGeometry->firstHFTower(tp_version)) ? analyticalLUT[k] : identityLUT[k];
275 
276 
277  // tpg - compressed value
278  unsigned int tpg = outputLut[0];
279 
280  int low = 0;
281 
282  for (unsigned int k = 0; k < 1024; ++k){
283  if (outputLut[k] != tpg){
284  unsigned int mid = (low + k)/2;
285  hcaluncomp[lutId][tpg] = (tpg == 0 ? low : factor * mid);
286  low = k;
287  tpg = outputLut[k];
288  }
289  }
290  hcaluncomp[lutId][tpg] = factor * low;
291  }
292  }
293 
294  auto hcalScale = std::make_unique<L1CaloHcalScale>(0);
295 
296  // XXX L1CaloHcalScale is only setup for 2x3 TP
297  const int tp_version = 0;
298  for( unsigned short ieta = 1 ; ieta <= L1CaloHcalScale::nBinEta; ++ieta ){
299  for(int pos = 0; pos <=1; pos++){
300  for( unsigned short irank = 0 ; irank < L1CaloHcalScale::nBinRank; ++irank ){
301 
302 
303 
304  int zside = (int) pow(-1,pos);
305  int nphi = 0;
306  double etvalue = 0.;
307 
308 
309  for(int iphi = 1; iphi<=72; iphi++){
310  if(!caloTPG->HTvalid(ieta, iphi, tp_version))
311  continue;
312  uint32_t lutId = caloTPG->getOutputLUTId(ieta,iphi, tp_version);
313  nphi++;
314  etvalue += (double) hcaluncomp[lutId][irank];
315 
316  } // phi
317  if (nphi > 0) etvalue /= nphi;
318 
319  hcalScale->setBin(irank, ieta, zside, etvalue);
320 
321  } // rank
322  } // zside
323  }// eta
324 
325  std::stringstream s;
326  s << std::setprecision(10);
327  hcalScale->print(s);
328  edm::LogInfo("L1CaloHcalScaleConfigOnlineProd") << s.str();
329 // ------------ method called to produce the data ------------
330  return hcalScale;
331 }
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:311
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:295
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 &)
def query(query_str, verbose=False)
Definition: das.py:6
Definition: query.py:1
const HcalTrigTowerGeometry * theTrigTowerGeometry
T sqrt(T t)
Definition: SSEVec.h:18
virtual int getOutputLUTId(const HcalTrigTowerDetId &id) const
static const unsigned short nBinRank
const std::vector< coral::AttributeList > & attributeLists() const
Definition: OMDSReader.h:64
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:86
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define end
Definition: vmac.h:39
T min(T a, T b)
Definition: MathUtil.h:58
const std::vector< std::string > & columnNames() const
Definition: OMDSReader.h:62
int k[5][pyjets_maxn]
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:192
coral::ISessionProxy & coralSession()
Definition: Session.cc:236
cond::persistency::Session dbSession()
Definition: DataManager.h:32
static const unsigned short nBinEta
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
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 56 of file L1CaloHcalScaleConfigOnlineProd.cc.

Referenced by newObject().

const HcalTrigTowerGeometry* L1CaloHcalScaleConfigOnlineProd::theTrigTowerGeometry
private

Definition at line 53 of file L1CaloHcalScaleConfigOnlineProd.cc.

Referenced by newObject(), and produce().

HcalTrigTowerDetId* L1CaloHcalScaleConfigOnlineProd::ttDetId
private

Definition at line 61 of file L1CaloHcalScaleConfigOnlineProd.cc.