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) override
 
 ~L1CaloEcalScaleConfigOnlineProd ()
 
- Public Member Functions inherited from L1ConfigOnlineProdBase< L1CaloEcalScaleRcd, L1CaloEcalScale >
 L1ConfigOnlineProdBase (const edm::ParameterSet &)
 
virtual 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,
edm::propagate_const
< std::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::persistency::Session m_dbSession
 
bool m_forceGeneration
 
l1t::OMDSReader m_omdsReader
 

Detailed Description

Definition at line 38 of file L1CaloEcalScaleConfigOnlineProd.cc.

Constructor & Destructor Documentation

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

Definition at line 78 of file L1CaloEcalScaleConfigOnlineProd.cc.

References groupInfo, and theMapping_.

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

Member Function Documentation

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

Implements L1ConfigOnlineProdBase< L1CaloEcalScaleRcd, L1CaloEcalScale >.

Definition at line 93 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(), watchdog::group, groupInfo, i, j, dbwrite_o2o_template::lastValue, lutGrpMap, L1ConfigOnlineProdBase< L1CaloEcalScaleRcd, L1CaloEcalScale >::m_omdsReader, L1CaloEcalScale::nBinEta, L1CaloEcalScale::nBinRank, l1t::OMDSReader::QueryResults::numberRows(), funct::pow(), L1CaloEcalScale::setBin(), EcalTPGGroups::setValue(), l1t::OMDSReader::singleAttribute(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, FrontierCondition_GT_autoExpress_cfi::test, theMapping_, EcalTrigTowerDetId::validDetId(), and ecaldqm::zside().

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