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 Attributes
L1CaloEcalScaleConfigOnlineProd Class Reference
Inheritance diagram for L1CaloEcalScaleConfigOnlineProd:
L1ConfigOnlineProdBase< L1CaloEcalScaleRcd, L1CaloEcalScale > edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

 L1CaloEcalScaleConfigOnlineProd (const edm::ParameterSet &)
 
virtual boost::shared_ptr
< L1CaloEcalScale
newObject (const std::string &objectKey)
 
 ~L1CaloEcalScaleConfigOnlineProd ()
 
- Public Member Functions inherited from L1ConfigOnlineProdBase< L1CaloEcalScaleRcd, L1CaloEcalScale >
 L1ConfigOnlineProdBase (const edm::ParameterSet &)
 
boost::shared_ptr
< L1CaloEcalScale
produce (const L1CaloEcalScaleRcd &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 Attributes

L1CaloEcalScaleecalScale
 
std::map< int, std::vector
< int > * > 
groupInfo
 
EcalTPGGroupslutGrpMap
 
const EcalElectronicsMappingtheMapping_
 

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< L1CaloEcalScaleRcd, L1CaloEcalScale >
bool getObjectKey (const L1CaloEcalScaleRcd &record, boost::shared_ptr< L1CaloEcalScale > 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< L1CaloEcalScaleRcd, L1CaloEcalScale >
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 L1CaloEcalScaleConfigOnlineProd.cc.

Constructor & Destructor Documentation

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

Definition at line 79 of file L1CaloEcalScaleConfigOnlineProd.cc.

References groupInfo, and theMapping_.

80 {
81 
82  // do anything here that needs to be done at desctruction time
83  // (e.g. close files, deallocate resources etc.)
84  delete theMapping_;
85 
86  // delete ecalScale;
87  // delete lutGrpMap;
88  groupInfo.clear();
89 
90 
91 }
std::map< int, std::vector< int > * > groupInfo
const EcalElectronicsMapping * theMapping_

Member Function Documentation

boost::shared_ptr< L1CaloEcalScale > L1CaloEcalScaleConfigOnlineProd::newObject ( const std::string &  objectKey)
virtual

Implements L1ConfigOnlineProdBase< L1CaloEcalScaleRcd, L1CaloEcalScale >.

Definition at line 94 of file L1CaloEcalScaleConfigOnlineProd.cc.

References l1t::OMDSReader::basicQuery(), gather_cfg::cout, EcalBarrel, EcalEndcap, ecalScale, l1t::OMDSReader::QueryResults::fillVariable(), l1t::OMDSReader::QueryResults::fillVariableFromRow(), EcalTPGGroups::getMap(), EcalElectronicsMapping::getTrigTowerDetId(), groupInfo, i, j, lutGrpMap, L1ConfigOnlineProdBase< L1CaloEcalScaleRcd, L1CaloEcalScale >::m_omdsReader, L1CaloEcalScale::nBinEta, L1CaloEcalScale::nBinRank, l1t::OMDSReader::QueryResults::numberRows(), pos, funct::pow(), L1CaloEcalScale::setBin(), EcalTPGGroups::setValue(), l1t::OMDSReader::singleAttribute(), cond::rpcobtemp::temp, theMapping_, and EcalTrigTowerDetId::validDetId().

95 {
96  using namespace edm::es;
97 
98  std:: cout << "object Key " << objectKey <<std::endl;
99 
100  if(objectKey == "NULL" || objectKey == "") // return default blank ecal scale
101  return boost::shared_ptr< L1CaloEcalScale >( ecalScale );
102  if(objectKey == "IDENTITY"){ // return identity ecal scale
103  ecalScale = 0;
104  ecalScale = new L1CaloEcalScale(1);
105  return boost::shared_ptr< L1CaloEcalScale >( ecalScale);
106  }
107 
108 
109  double ee_lsb = 0.;
110  double eb_lsb = 0.;
111 
112  std::vector < std::string > mainStrings;
113 
114  // ~~~~~~~~~ Cut values ~~~~~~~~~
115 
116 
117  std::vector< std::string > paramStrings ;
118  paramStrings.push_back("LOGIC_ID"); // EB/EE
119  paramStrings.push_back("ETSAT"); //Only object needed
120 
121 
122  std::vector< std::string> IDStrings;
123  IDStrings.push_back("NAME");
124  IDStrings.push_back("ID1");
125  IDStrings.push_back("ID2");
126  IDStrings.push_back("maps_to");
127 
128  l1t::OMDSReader::QueryResults paramResults =
129  m_omdsReader.basicQuery( paramStrings,
130  "CMS_ECAL_CONF",
131  "FE_CONFIG_LUTPARAM_DAT",
132  "FE_CONFIG_LUTPARAM_DAT.LUT_CONF_ID",
133  m_omdsReader.singleAttribute(objectKey)
134  );
135 
136  if( paramResults.queryFailed()
137  || (paramResults.numberRows()==0) ) // check query successful
138  {
139  edm::LogError( "L1-O2O" ) << "Problem with L1CaloEcalScale key. Unable to find lutparam dat table" ;
140  return boost::shared_ptr< L1CaloEcalScale >() ;
141  }
142 
143 
144 
145  for(int i = 0; i < paramResults.numberRows() ; i++){
146 
147  //EcalTPGPhysicsConst::Item item;
148  float etSat;
149  paramResults.fillVariableFromRow("ETSAT",i,etSat);
150 
151  std::string ecid_name;
152  int logic_id;
153  paramResults.fillVariableFromRow("LOGIC_ID",i, logic_id);
154 
155 
157  m_omdsReader.basicQuery(IDStrings,
158  "CMS_ECAL_COND",
159  "CHANNELVIEW",
160  "CHANNELVIEW.LOGIC_ID",
161  m_omdsReader.singleAttribute(logic_id)
162  );
163 
164  logicID.fillVariable("NAME",ecid_name);
165 
166  if(ecid_name =="EB")
167  eb_lsb = etSat/1024;
168  else if("EE" == ecid_name)
169  ee_lsb = etSat/1024;
170  else {
171  edm::LogError( "L1-O2O" ) << "Problem with L1CaloEcalScale LOGIC_ID. unable to find channel view with appropiate logic id" ;
172  return boost::shared_ptr< L1CaloEcalScale >() ;
173  }
174 
175  }
176  // std::cout << " eb lsb " << eb_lsb << " ee_lsb " << ee_lsb << std::endl;
177 
178  std::vector< std::string > grpLUT;
179  grpLUT.push_back("GROUP_ID");
180  grpLUT.push_back("LUT_ID");
181  grpLUT.push_back("LUT_VALUE");
182 
183  l1t::OMDSReader::QueryResults lutGrpResults =
184  m_omdsReader.basicQuery( grpLUT,
185  "CMS_ECAL_CONF",
186  "FE_LUT_PER_GROUP_DAT",
187  "FE_LUT_PER_GROUP_DAT.LUT_CONF_ID",
188  m_omdsReader.singleAttribute(objectKey)
189  );
190 
191  if( lutGrpResults.queryFailed()
192  || (lutGrpResults.numberRows()%1024 !=0) ) // check query successful
193  {
194  edm::LogError( "L1-O2O" ) << "Problem with L1CaloEcalScale key. No group info" ;
195  return boost::shared_ptr< L1CaloEcalScale >() ;
196  }
197 
198 
199  int nEntries = lutGrpResults.numberRows();
200  for(int i = 0; i < nEntries; i++) {
201  int group, lutID;
202  float lutValue;
203 
204  lutGrpResults.fillVariableFromRow("GROUP_ID",i,group);
205  if(groupInfo.find(group) == groupInfo.end()){
206  groupInfo[group] = new std::vector<int>;
207  (groupInfo[group])->resize(1024);
208  }
209 
210  lutGrpResults.fillVariableFromRow("LUT_ID",i,lutID);
211  lutGrpResults.fillVariableFromRow("LUT_VALUE",i,lutValue);
212  groupInfo[group]->at(lutID) = (int) lutValue;
213  }
214 
215  std::map<int, std::vector<int> > tpgValueMap;
216 
217  std::map<int, std::vector<int>* >::iterator grpIt;
218  for ( grpIt = groupInfo.begin(); grpIt != groupInfo.end() ; ++grpIt){
219  const std::vector<int> * lut_ = grpIt->second;
220 
221  std::vector<int> tpgValue;
222  tpgValue.resize(256);
223  for(int tpg = 0; tpg < 256 ; tpg++){
224 
225  for(int i = 0; i < 1024 ; i++) {
226 
227  if(tpg == (0xff & (lut_->at(i)))){
228  tpgValue[tpg] = i;
229  break;
230  }
231  }
232  }
233  tpgValueMap[grpIt->first] = tpgValue;
234  }
235 
236 
237  std::vector < std::string > groupMap;
238  groupMap.push_back("LOGIC_ID");
239  groupMap.push_back("GROUP_ID");
240 
241 
242 
243  l1t::OMDSReader::QueryResults grpMapResults =
244  m_omdsReader.basicQuery( groupMap,
245  "CMS_ECAL_CONF",
246  "FE_CONFIG_LUT_DAT",
247  "FE_CONFIG_LUT_DAT.LUT_CONF_ID",
248  m_omdsReader.singleAttribute(objectKey)
249  );
250  if( grpMapResults.queryFailed()
251  || (grpMapResults.numberRows()==0) ) // check query successful
252  {
253  edm::LogError( "L1-O2O" ) << "Problem with L1CaloEcalScale key. No fe_config_lut_dat info" ;
254  return boost::shared_ptr< L1CaloEcalScale >() ;
255  }
256 
257  nEntries = grpMapResults.numberRows();
258  for(int i = 0; i< nEntries; ++i){
259  std::string ecid_name;
260  int logic_id;
261  grpMapResults.fillVariableFromRow("LOGIC_ID",i, logic_id);
262  int group_id;
263  grpMapResults.fillVariableFromRow("GROUP_ID",i, group_id);
264  // if(logic_id >= 2100001901 && logic_id <= 2100001916)
265  // std::cout<< "missing logic id found " <<logic_id <<std::endl;
267  m_omdsReader.basicQuery( IDStrings,
268  "CMS_ECAL_COND",
269  "CHANNELVIEW",
270  "CHANNELVIEW.LOGIC_ID",
271  m_omdsReader.singleAttribute(logic_id)
272  );
273  if( paramResults.queryFailed()
274  || (paramResults.numberRows()==0) ) // check query successful
275  {
276  edm::LogError( "L1-O2O" ) << "Problem with L1CaloEcalScale key. Unable to find logic_id channel view" ;
277  return boost::shared_ptr< L1CaloEcalScale >() ;
278  }
279  for(int j = 0; j < IDResults.numberRows(); j++){
280 
281  std::string ecid_name, maps_to;
282 
283  IDResults.fillVariableFromRow("NAME",j, ecid_name);
284  IDResults.fillVariableFromRow("maps_to",j, maps_to);
285  if(logic_id >= 2100001901 && logic_id <= 2100001916)
286  // std::cout << " name " << ecid_name << " maps to " << maps_to <<std::endl;
287  if(ecid_name != maps_to){
288  continue; // make sure they match
289  }
290  if(ecid_name== "EB_trigger_tower" || ecid_name == "EE_trigger_tower") {
291  int id1,id2;
292  IDResults.fillVariableFromRow("ID1",j, id1);
293  IDResults.fillVariableFromRow("ID2",j, id2);
294 
295  if(ecid_name == "EB_trigger_tower")
296  id1+=36; //lowest TCC for barrel 37
298  /* if(ecid_name == "EE_trigger_tower"){
299  int testID = theMapping_->TCCid(temp);
300 
301  if( testID != id1 ){
302  std::cout << " unmatched mapping testID " <<testID <<std::endl;
303  std::cout << "id1 " << id1 << " id2 " <<id2<< " iphi " << temp.iphi() <<" ieta " << temp.ieta() <<std::endl;
304  }
305  }
306  if(ecid_name == "EB_trigger_tower"){
307  int testID = theMapping_->TCCid(temp);
308  if( testID != id1 ){
309  std::cout << " unmatched mapping testID " <<testID <<std::endl;
310  std::cout << "id1 " << id1 << " id2 " <<id2<< " iphi " << temp.iphi() <<" ieta " << temp.ieta() <<std::endl;
311  }
312  }
313  */
314  // if(temp.ieta() == -18 || temp.ietaAbs() == 28)
315  // if(logic_id >= 2100001901 && logic_id <= 2100001916)
316 
317 
318  lutGrpMap->setValue(temp, group_id); // assume ee has less than 68 tt
319  break;
320  }
321  }
322  }
323 
325 
326 
327 
328  for( unsigned short ieta = 1 ; ieta <= L1CaloEcalScale::nBinEta; ++ieta ){
329  EcalSubdetector subdet = ( ieta <= 17 ) ? EcalBarrel : EcalEndcap ;
330  double et_lsb = (ieta<=17) ? eb_lsb : ee_lsb;
331  for(int pos = 0; pos <=1; pos++){
332  int zside = (int) pow(-1,pos);
333 
334  // std::cout << "ieta " <<zside*ieta ;
335  for(int iphi = 1; iphi<=72; iphi++){
336  if(!EcalTrigTowerDetId::validDetId(zside,subdet,ieta, iphi))
337  continue;
338  EcalTrigTowerDetId test(zside, subdet, ieta, iphi);
339  EcalTPGGroups::EcalTPGGroupsMapItr itLut = gMap.find(test) ;
340  if(itLut != gMap.end()) {
341  // std::cout << " non mapped section iphi " << iphi << " ieta " <<ieta << " tccid " << theMapping_->TCCid(test) << " iTT " << theMapping_->iTT(test)<< std::endl;
342  std::vector<int> tpgValue = tpgValueMap[itLut->second];
343 
344  for( unsigned short irank = 0 ; irank < L1CaloEcalScale::nBinRank; ++irank )
345  {
346  ecalScale->setBin(irank, ieta, zside, et_lsb * tpgValue[irank]);
347 
348  // std::cout << " irank " << irank << " etValue " << et_lsb*tpgValue[irank] << std::endl;
349  }
350 
351  break;
352  }
353  }
354  }
355  }
356 
357 
358 
359 
360 
361 // ------------ method called to produce the data ------------
362  return boost::shared_ptr< L1CaloEcalScale >( ecalScale );
363 }
int i
Definition: DBlmapReader.cc:9
const EcalTPGGroupsMap & getMap() const
Definition: EcalTPGGroups.h:26
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:311
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:295
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:21
std::map< int, std::vector< int > * > groupInfo
EcalTrigTowerDetId getTrigTowerDetId(int TCCid, int iTT) const
Builds a EcalTrigTowerDetID from the TCCid &amp; TriggerTower index in TCC.
void setBin(unsigned short rank, unsigned short eta, short etaSign, double et)
set scale element; use this to create non-linear scales
bool fillVariableFromRow(const std::string &columnName, int rowNumber, T &outputVariable) const
Definition: OMDSReader.h:319
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
int j
Definition: DBlmapReader.cc:9
void setValue(const uint32_t &rawId, const uint32_t &ObjectId)
Definition: EcalTPGGroups.cc:9
const EcalElectronicsMapping * theMapping_
static bool validDetId(int iz, EcalSubdetector sd, int i, int j)
check if a valid index combination
static const unsigned short nBinRank
static const unsigned short nBinEta
tuple cout
Definition: gather_cfg.py:41
EcalSubdetector
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:20
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40

Member Data Documentation

L1CaloEcalScale* L1CaloEcalScaleConfigOnlineProd::ecalScale
private
std::map<int, std::vector<int>* > L1CaloEcalScaleConfigOnlineProd::groupInfo
private
EcalTPGGroups* L1CaloEcalScaleConfigOnlineProd::lutGrpMap
private
const EcalElectronicsMapping* L1CaloEcalScaleConfigOnlineProd::theMapping_
private