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)
 
virtual std::shared_ptr< L1CaloHcalScalenewObject (const std::string &objectKey) override
 
std::shared_ptr< L1CaloHcalScaleproduce (const L1CaloHcalScaleRcd &iRecord) override
 
 ~L1CaloHcalScaleConfigOnlineProd ()
 
- Public Member Functions inherited from L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >
 L1ConfigOnlineProdBase (const edm::ParameterSet &)
 
 ~L1ConfigOnlineProdBase ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()(false)
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer () noexcept(false)
 
- 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
 
L1CaloHcalScalehcalScale
 
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::shared_ptr< L1CaloHcalScale > data, std::string &objectKey)
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- 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())
 
virtual void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
 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 56 of file L1CaloHcalScaleConfigOnlineProd.cc.

Constructor & Destructor Documentation

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

Definition at line 88 of file L1CaloHcalScaleConfigOnlineProd.cc.

References caloTPG.

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

Member Function Documentation

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

Implements L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >.

Definition at line 98 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(), particleFlowClusterECALTimeSelected_cfi::depth, end, l1t::OMDSReader::QueryResults::fillVariable(), l1t::OMDSReader::QueryResults::fillVariableFromRow(), HcalTrigTowerGeometry::firstHFTower(), CaloTPGTranscoderULUT::getOutputLUTId(), hcalScale, hcaluncomp, CaloTPGTranscoderULUT::HTvalid(), 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(), L1CaloHcalScale::print(), das::query(), l1t::OMDSReader::QueryResults::queryFailed(), alignCSCRings::s, dataDML::schema, L1CaloHcalScale::setBin(), l1t::OMDSReader::singleAttribute(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, theTrigTowerGeometry, totemRPUVPatternFinder_cfi::threshold, HcalTrigTowerGeometry::towerEtaBounds(), and HcalDigiParam_cfi::zside.

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

Member Data Documentation

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

Definition at line 57 of file L1CaloHcalScaleConfigOnlineProd.cc.

Referenced by newObject().

const HcalTrigTowerGeometry* L1CaloHcalScaleConfigOnlineProd::theTrigTowerGeometry
private

Definition at line 54 of file L1CaloHcalScaleConfigOnlineProd.cc.

Referenced by newObject(), and produce().

HcalTrigTowerDetId* L1CaloHcalScaleConfigOnlineProd::ttDetId
private

Definition at line 62 of file L1CaloHcalScaleConfigOnlineProd.cc.