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
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- 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, dbwrite_o2o_template::lastValue, lutGrpMap, L1ConfigOnlineProdBase< L1CaloEcalScaleRcd, L1CaloEcalScale >::m_omdsReader, L1CaloEcalScale::nBinEta, L1CaloEcalScale::nBinRank, l1t::OMDSReader::QueryResults::numberRows(), pos, funct::pow(), L1CaloEcalScale::setBin(), EcalTPGGroups::setValue(), l1t::OMDSReader::singleAttribute(), groupFilesInBlocks::temp, run_regression::test, 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  int lastValue = 0;
224  for(int tpg = 0; tpg < 256 ; tpg++){
225 
226  for(int i = 0; i < 1024 ; i++) {
227 
228  if(tpg == (0xff & (lut_->at(i)))){
229  tpgValue[tpg] = i;
230  lastValue = i;
231  break;
232  }
233  tpgValue[tpg] = lastValue;
234  }
235  }
236  tpgValueMap[grpIt->first] = tpgValue;
237  }
238 
239 
240  std::vector < std::string > groupMap;
241  groupMap.push_back("LOGIC_ID");
242  groupMap.push_back("GROUP_ID");
243 
244 
245 
246  l1t::OMDSReader::QueryResults grpMapResults =
247  m_omdsReader.basicQuery( groupMap,
248  "CMS_ECAL_CONF",
249  "FE_CONFIG_LUT_DAT",
250  "FE_CONFIG_LUT_DAT.LUT_CONF_ID",
251  m_omdsReader.singleAttribute(objectKey)
252  );
253  if( grpMapResults.queryFailed()
254  || (grpMapResults.numberRows()==0) ) // check query successful
255  {
256  edm::LogError( "L1-O2O" ) << "Problem with L1CaloEcalScale key. No fe_config_lut_dat info" ;
257  return boost::shared_ptr< L1CaloEcalScale >() ;
258  }
259 
260  nEntries = grpMapResults.numberRows();
261  for(int i = 0; i< nEntries; ++i){
262  std::string ecid_name;
263  int logic_id;
264  grpMapResults.fillVariableFromRow("LOGIC_ID",i, logic_id);
265  int group_id;
266  grpMapResults.fillVariableFromRow("GROUP_ID",i, group_id);
267  // if(logic_id >= 2100001901 && logic_id <= 2100001916)
268  // std::cout<< "missing logic id found " <<logic_id <<std::endl;
270  m_omdsReader.basicQuery( IDStrings,
271  "CMS_ECAL_COND",
272  "CHANNELVIEW",
273  "CHANNELVIEW.LOGIC_ID",
274  m_omdsReader.singleAttribute(logic_id)
275  );
276  if( paramResults.queryFailed()
277  || (paramResults.numberRows()==0) ) // check query successful
278  {
279  edm::LogError( "L1-O2O" ) << "Problem with L1CaloEcalScale key. Unable to find logic_id channel view" ;
280  return boost::shared_ptr< L1CaloEcalScale >() ;
281  }
282  for(int j = 0; j < IDResults.numberRows(); j++){
283 
284  std::string ecid_name, maps_to;
285 
286  IDResults.fillVariableFromRow("NAME",j, ecid_name);
287  IDResults.fillVariableFromRow("maps_to",j, maps_to);
288  if(logic_id >= 2100001901 && logic_id <= 2100001916)
289  // std::cout << " name " << ecid_name << " maps to " << maps_to <<std::endl;
290  if(ecid_name != maps_to){
291  continue; // make sure they match
292  }
293  if(ecid_name== "EB_trigger_tower" || ecid_name == "EE_trigger_tower") {
294  int id1,id2;
295  IDResults.fillVariableFromRow("ID1",j, id1);
296  IDResults.fillVariableFromRow("ID2",j, id2);
297 
298  if(ecid_name == "EB_trigger_tower")
299  id1+=36; //lowest TCC for barrel 37
301  /* if(ecid_name == "EE_trigger_tower"){
302  int testID = theMapping_->TCCid(temp);
303 
304  if( testID != id1 ){
305  std::cout << " unmatched mapping testID " <<testID <<std::endl;
306  std::cout << "id1 " << id1 << " id2 " <<id2<< " iphi " << temp.iphi() <<" ieta " << temp.ieta() <<std::endl;
307  }
308  }
309  if(ecid_name == "EB_trigger_tower"){
310  int testID = theMapping_->TCCid(temp);
311  if( testID != id1 ){
312  std::cout << " unmatched mapping testID " <<testID <<std::endl;
313  std::cout << "id1 " << id1 << " id2 " <<id2<< " iphi " << temp.iphi() <<" ieta " << temp.ieta() <<std::endl;
314  }
315  }
316  */
317  // if(temp.ieta() == -18 || temp.ietaAbs() == 28)
318  // if(logic_id >= 2100001901 && logic_id <= 2100001916)
319 
320 
321  lutGrpMap->setValue(temp, group_id); // assume ee has less than 68 tt
322  break;
323  }
324  }
325  }
326 
328 
329 
330 
331  for( unsigned short ieta = 1 ; ieta <= L1CaloEcalScale::nBinEta; ++ieta ){
332  EcalSubdetector subdet = ( ieta <= 17 ) ? EcalBarrel : EcalEndcap ;
333  double et_lsb = (ieta<=17) ? eb_lsb : ee_lsb;
334  for(int pos = 0; pos <=1; pos++){
335  int zside = (int) pow(-1,pos);
336 
337  // std::cout << "ieta " <<zside*ieta ;
338  for(int iphi = 1; iphi<=72; iphi++){
339  if(!EcalTrigTowerDetId::validDetId(zside,subdet,ieta, iphi))
340  continue;
341  EcalTrigTowerDetId test(zside, subdet, ieta, iphi);
342  EcalTPGGroups::EcalTPGGroupsMapItr itLut = gMap.find(test) ;
343  if(itLut != gMap.end()) {
344  // std::cout << " non mapped section iphi " << iphi << " ieta " <<ieta << " tccid " << theMapping_->TCCid(test) << " iTT " << theMapping_->iTT(test)<< std::endl;
345  std::vector<int> tpgValue = tpgValueMap[itLut->second];
346 
347  for( unsigned short irank = 0 ; irank < L1CaloEcalScale::nBinRank; ++irank )
348  {
349  ecalScale->setBin(irank, ieta, zside, et_lsb * tpgValue[irank]);
350 
351  // std::cout << " irank " << irank << " etValue " << et_lsb*tpgValue[irank] << std::endl;
352  }
353 
354  break;
355  }
356  }
357  }
358  }
359 
360 
361  // ecalScale->print(std::cout);
362 
363 
364 // ------------ method called to produce the data ------------
365  return boost::shared_ptr< L1CaloEcalScale >( ecalScale );
366 }
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:121
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