CMS 3D CMS Logo

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 &)
 
std::unique_ptr< L1CaloEcalScalenewObject (const std::string &objectKey) override
 
 ~L1CaloEcalScaleConfigOnlineProd () override
 
- Public Member Functions inherited from L1ConfigOnlineProdBase< L1CaloEcalScaleRcd, L1CaloEcalScale >
 L1ConfigOnlineProdBase (const edm::ParameterSet &)
 
virtual std::unique_ptr< L1CaloEcalScaleproduce (const L1CaloEcalScaleRcd &iRecord)
 
 ~L1ConfigOnlineProdBase () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- 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 Attributes

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< 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< L1CaloEcalScaleRcd, L1CaloEcalScale >
bool getObjectKey (const L1CaloEcalScaleRcd &record, std::string &objectKey)
 
- Protected Member Functions inherited from edm::ESProducer
 ESProducer (const ESProducer &)=delete
 
ESProducer const & operator= (const ESProducer &)=delete
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
- 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())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 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 ( )
override

Definition at line 63 of file L1CaloEcalScaleConfigOnlineProd.cc.

References groupInfo, and theMapping_.

64 {
65 
66  // do anything here that needs to be done at desctruction time
67  // (e.g. close files, deallocate resources etc.)
68  delete theMapping_;
69 
70  // delete lutGrpMap;
71  groupInfo.clear();
72 
73 
74 }
std::map< int, std::vector< int > * > groupInfo
const EcalElectronicsMapping * theMapping_

Member Function Documentation

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

Implements L1ConfigOnlineProdBase< L1CaloEcalScaleRcd, L1CaloEcalScale >.

Definition at line 77 of file L1CaloEcalScaleConfigOnlineProd.cc.

References l1t::OMDSReader::basicQuery(), gather_cfg::cout, DEFINE_FWK_EVENTSETUP_MODULE, EcalBarrel, EcalEndcap, l1t::OMDSReader::QueryResults::fillVariable(), l1t::OMDSReader::QueryResults::fillVariableFromRow(), EcalTPGGroups::getMap(), EcalElectronicsMapping::getTrigTowerDetId(), edmIntegrityCheck::group, groupInfo, mps_fire::i, globals_cff::id1, globals_cff::id2, createfilelist::int, lutGrpMap, L1ConfigOnlineProdBase< L1CaloEcalScaleRcd, L1CaloEcalScale >::m_omdsReader, L1CaloEcalScale::nBinEta, L1CaloEcalScale::nBinRank, l1t::OMDSReader::QueryResults::numberRows(), funct::pow(), l1t::OMDSReader::QueryResults::queryFailed(), EcalTPGGroups::setValue(), l1t::OMDSReader::singleAttribute(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, PFTauMVAInputDiscriminatorTranslator_cfi::test, theMapping_, EcalTrigTowerDetId::validDetId(), and ecaldqm::zside().

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

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