CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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)
 
virtual boost::shared_ptr
< L1CaloHcalScale
newObject (const std::string &objectKey)
 
 ~L1CaloHcalScaleConfigOnlineProd ()
 
- Public Member Functions inherited from L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >
 L1ConfigOnlineProdBase (const edm::ParameterSet &)
 
boost::shared_ptr
< L1CaloHcalScale
produce (const L1CaloHcalScaleRcd &iRecord)
 
 ~L1ConfigOnlineProdBase ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer ()
 
- 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 ()
 

Private Types

typedef std::vector< double > RCTdecompression
 

Private Attributes

CaloTPGTranscoderULUTcaloTPG
 
L1CaloHcalScalehcalScale
 
std::vector< RCTdecompressionhcaluncomp
 
HcalTrigTowerGeometry theTrigTowerGeometry
 
HcalTrigTowerDetIdttDetId
 

Additional Inherited Members

- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair
< DataKey, boost::shared_ptr
< DataProxy > > > 
KeyedProxies
 
typedef std::vector
< EventSetupRecordKey
Keys
 
typedef std::map
< EventSetupRecordKey,
KeyedProxies
RecordProxies
 
- Protected Member Functions inherited from L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >
bool getObjectKey (const L1CaloHcalScaleRcd &record, boost::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::auto_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::auto_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::DbConnection m_dbConnection
 
cond::DbSession 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 54 of file L1CaloHcalScaleConfigOnlineProd.cc.

Constructor & Destructor Documentation

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

Definition at line 85 of file L1CaloHcalScaleConfigOnlineProd.cc.

References caloTPG.

86 {
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 != 0)
92  delete caloTPG;
93 
94 
95 
96 
97 
98 
99 }

Member Function Documentation

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

Implements L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >.

Definition at line 102 of file L1CaloHcalScaleConfigOnlineProd.cc.

References abs, l1t::OMDSReader::QueryResults::attributeLists(), l1t::OMDSReader::basicQuery(), l1t::OMDSReader::basicQueryView(), caloTPG, gather_cfg::cout, l1t::DataManager::dbSession(), end, l1t::OMDSReader::QueryResults::fillVariableFromRow(), HcalTrigTowerGeometry::firstHFTower(), CaloTPGTranscoderULUT::getOutputLUTId(), hcalScale, hcaluncomp, CaloTPGTranscoderULUT::HTvalid(), i, gen::k, funct::log(), L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >::m_omdsReader, min, L1CaloHcalScale::nBinEta, L1CaloHcalScale::nBinRank, ExpressReco_HICollisions_FallBack::nominal_gain, l1t::OMDSReader::QueryResults::numberRows(), summarizeEdmComparisonLogfiles::objectName, pos, funct::pow(), L1CaloHcalScale::print(), o2o::query, l1t::OMDSReader::QueryResults::queryFailed(), cond::DbSession::schema(), python.IdGenerator::schema, L1CaloHcalScale::setBin(), l1t::OMDSReader::singleAttribute(), mathSSE::sqrt(), theTrigTowerGeometry, crabWrap::threshold, and HcalTrigTowerGeometry::towerEtaBounds().

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

Member Data Documentation

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

Definition at line 55 of file L1CaloHcalScaleConfigOnlineProd.cc.

Referenced by newObject().

HcalTrigTowerGeometry L1CaloHcalScaleConfigOnlineProd::theTrigTowerGeometry
private

Definition at line 52 of file L1CaloHcalScaleConfigOnlineProd.cc.

Referenced by newObject().

HcalTrigTowerDetId* L1CaloHcalScaleConfigOnlineProd::ttDetId
private

Definition at line 60 of file L1CaloHcalScaleConfigOnlineProd.cc.