CMS 3D CMS Logo

L1CaloEcalScaleConfigOnlineProd.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1EmEtScaleOnlineProd
4 // Class: L1EmEtScaleOnlineProd
5 //
13 //
14 // Original Author: Werner Man-Li Sun
15 // Created: Tue Sep 16 22:43:22 CEST 2008
16 //
17 //
18 
19 // system include files
20 
21 // user include files
32 
33 //
34 // class declaration
35 //
36 
37 class L1CaloEcalScaleConfigOnlineProd : public L1ConfigOnlineProdBase<L1CaloEcalScaleRcd, L1CaloEcalScale> {
38 public:
41 
42  std::unique_ptr<L1CaloEcalScale> newObject(const std::string& objectKey) override;
43 
44 private:
46  std::map<int, std::vector<int>*> groupInfo;
48 };
49 
53  lutGrpMap = new EcalTPGGroups();
54 }
55 
57  // do anything here that needs to be done at desctruction time
58  // (e.g. close files, deallocate resources etc.)
59  delete theMapping_;
60 
61  // delete lutGrpMap;
62  groupInfo.clear();
63 }
64 
65 std::unique_ptr<L1CaloEcalScale> L1CaloEcalScaleConfigOnlineProd::newObject(const std::string& objectKey) {
66  std::cout << "object Key " << objectKey << std::endl;
67 
68  if (objectKey == "NULL" || objectKey.empty()) { // return default blank ecal scale
69  return std::make_unique<L1CaloEcalScale>(0);
70  }
71  if (objectKey == "IDENTITY") { // return identity ecal scale
72  return std::make_unique<L1CaloEcalScale>(1);
73  }
74 
75  double ee_lsb = 0.;
76  double eb_lsb = 0.;
77 
78  std::vector<std::string> mainStrings;
79 
80  // ~~~~~~~~~ Cut values ~~~~~~~~~
81 
82  std::vector<std::string> paramStrings;
83  paramStrings.push_back("LOGIC_ID"); // EB/EE
84  paramStrings.push_back("ETSAT"); //Only object needed
85 
86  std::vector<std::string> IDStrings;
87  IDStrings.push_back("NAME");
88  IDStrings.push_back("ID1");
89  IDStrings.push_back("ID2");
90  IDStrings.push_back("maps_to");
91 
92  l1t::OMDSReader::QueryResults paramResults = m_omdsReader.basicQuery(paramStrings,
93  "CMS_ECAL_CONF",
94  "FE_CONFIG_LUTPARAM_DAT",
95  "FE_CONFIG_LUTPARAM_DAT.LUT_CONF_ID",
96  m_omdsReader.singleAttribute(objectKey));
97 
98  if (paramResults.queryFailed() || (paramResults.numberRows() == 0)) // check query successful
99  {
100  edm::LogError("L1-O2O") << "Problem with L1CaloEcalScale key. Unable to find lutparam dat table";
101  return std::unique_ptr<L1CaloEcalScale>();
102  }
103 
104  for (int i = 0; i < paramResults.numberRows(); i++) {
105  //EcalTPGPhysicsConst::Item item;
106  float etSat;
107  paramResults.fillVariableFromRow("ETSAT", i, etSat);
108 
109  std::string ecid_name;
110  int logic_id;
111  paramResults.fillVariableFromRow("LOGIC_ID", i, logic_id);
112 
114  IDStrings, "CMS_ECAL_COND", "CHANNELVIEW", "CHANNELVIEW.LOGIC_ID", m_omdsReader.singleAttribute(logic_id));
115 
116  logicID.fillVariable("NAME", ecid_name);
117 
118  if (ecid_name == "EB")
119  eb_lsb = etSat / 1024;
120  else if ("EE" == ecid_name)
121  ee_lsb = etSat / 1024;
122  else {
123  edm::LogError("L1-O2O")
124  << "Problem with L1CaloEcalScale LOGIC_ID. unable to find channel view with appropiate logic id";
125  return std::unique_ptr<L1CaloEcalScale>();
126  }
127  }
128  // std::cout << " eb lsb " << eb_lsb << " ee_lsb " << ee_lsb << std::endl;
129 
130  std::vector<std::string> grpLUT;
131  grpLUT.push_back("GROUP_ID");
132  grpLUT.push_back("LUT_ID");
133  grpLUT.push_back("LUT_VALUE");
134 
136  "CMS_ECAL_CONF",
137  "FE_LUT_PER_GROUP_DAT",
138  "FE_LUT_PER_GROUP_DAT.LUT_CONF_ID",
139  m_omdsReader.singleAttribute(objectKey));
140 
141  if (lutGrpResults.queryFailed() || (lutGrpResults.numberRows() % 1024 != 0)) // check query successful
142  {
143  edm::LogError("L1-O2O") << "Problem with L1CaloEcalScale key. No group info";
144  return std::unique_ptr<L1CaloEcalScale>();
145  }
146 
147  int nEntries = lutGrpResults.numberRows();
148  for (int i = 0; i < nEntries; i++) {
149  int group, lutID;
150  float lutValue;
151 
152  lutGrpResults.fillVariableFromRow("GROUP_ID", i, group);
153  if (groupInfo.find(group) == groupInfo.end()) {
154  groupInfo[group] = new std::vector<int>;
155  (groupInfo[group])->resize(1024);
156  }
157 
158  lutGrpResults.fillVariableFromRow("LUT_ID", i, lutID);
159  lutGrpResults.fillVariableFromRow("LUT_VALUE", i, lutValue);
160  groupInfo[group]->at(lutID) = (int)lutValue;
161  }
162 
163  std::map<int, std::vector<int> > tpgValueMap;
164 
165  std::map<int, std::vector<int>*>::iterator grpIt;
166  for (grpIt = groupInfo.begin(); grpIt != groupInfo.end(); ++grpIt) {
167  const std::vector<int>* lut_ = grpIt->second;
168 
169  std::vector<int> tpgValue;
170  tpgValue.resize(256);
171  int lastValue = 0;
172  for (int tpg = 0; tpg < 256; tpg++) {
173  for (int i = 0; i < 1024; i++) {
174  if (tpg == (0xff & (lut_->at(i)))) {
175  tpgValue[tpg] = i;
176  lastValue = i;
177  break;
178  }
179  tpgValue[tpg] = lastValue;
180  }
181  }
182  tpgValueMap[grpIt->first] = tpgValue;
183  }
184 
185  std::vector<std::string> groupMap;
186  groupMap.push_back("LOGIC_ID");
187  groupMap.push_back("GROUP_ID");
188 
189  l1t::OMDSReader::QueryResults grpMapResults = m_omdsReader.basicQuery(groupMap,
190  "CMS_ECAL_CONF",
191  "FE_CONFIG_LUT_DAT",
192  "FE_CONFIG_LUT_DAT.LUT_CONF_ID",
193  m_omdsReader.singleAttribute(objectKey));
194  if (grpMapResults.queryFailed() || (grpMapResults.numberRows() == 0)) // check query successful
195  {
196  edm::LogError("L1-O2O") << "Problem with L1CaloEcalScale key. No fe_config_lut_dat info";
197  return std::unique_ptr<L1CaloEcalScale>();
198  }
199 
200  nEntries = grpMapResults.numberRows();
201  for (int i = 0; i < nEntries; ++i) {
202  std::string ecid_name;
203  int logic_id;
204  grpMapResults.fillVariableFromRow("LOGIC_ID", i, logic_id);
205  int group_id;
206  grpMapResults.fillVariableFromRow("GROUP_ID", i, group_id);
207  // if(logic_id >= 2100001901 && logic_id <= 2100001916)
208  // std::cout<< "missing logic id found " <<logic_id <<std::endl;
210  IDStrings, "CMS_ECAL_COND", "CHANNELVIEW", "CHANNELVIEW.LOGIC_ID", m_omdsReader.singleAttribute(logic_id));
211  if (paramResults.queryFailed() || (paramResults.numberRows() == 0)) // check query successful
212  {
213  edm::LogError("L1-O2O") << "Problem with L1CaloEcalScale key. Unable to find logic_id channel view";
214  return std::unique_ptr<L1CaloEcalScale>();
215  }
216  for (int j = 0; j < IDResults.numberRows(); j++) {
217  std::string ecid_name, maps_to;
218 
219  IDResults.fillVariableFromRow("NAME", j, ecid_name);
220  IDResults.fillVariableFromRow("maps_to", j, maps_to);
221  if (logic_id >= 2100001901 && logic_id <= 2100001916)
222  // std::cout << " name " << ecid_name << " maps to " << maps_to <<std::endl;
223  if (ecid_name != maps_to) {
224  continue; // make sure they match
225  }
226  if (ecid_name == "EB_trigger_tower" || ecid_name == "EE_trigger_tower") {
227  int id1, id2;
228  IDResults.fillVariableFromRow("ID1", j, id1);
229  IDResults.fillVariableFromRow("ID2", j, id2);
230 
231  if (ecid_name == "EB_trigger_tower")
232  id1 += 36; //lowest TCC for barrel 37
234  /* if(ecid_name == "EE_trigger_tower"){
235  int testID = theMapping_->TCCid(temp);
236 
237  if( testID != id1 ){
238  std::cout << " unmatched mapping testID " <<testID <<std::endl;
239  std::cout << "id1 " << id1 << " id2 " <<id2<< " iphi " << temp.iphi() <<" ieta " << temp.ieta() <<std::endl;
240  }
241  }
242  if(ecid_name == "EB_trigger_tower"){
243  int testID = theMapping_->TCCid(temp);
244  if( testID != id1 ){
245  std::cout << " unmatched mapping testID " <<testID <<std::endl;
246  std::cout << "id1 " << id1 << " id2 " <<id2<< " iphi " << temp.iphi() <<" ieta " << temp.ieta() <<std::endl;
247  }
248  }
249  */
250  // if(temp.ieta() == -18 || temp.ietaAbs() == 28)
251  // if(logic_id >= 2100001901 && logic_id <= 2100001916)
252 
253  lutGrpMap->setValue(temp, group_id); // assume ee has less than 68 tt
254  break;
255  }
256  }
257  }
258 
260 
261  auto ecalScale = std::make_unique<L1CaloEcalScale>(0);
262 
263  for (unsigned short ieta = 1; ieta <= L1CaloEcalScale::nBinEta; ++ieta) {
264  EcalSubdetector subdet = (ieta <= 17) ? EcalBarrel : EcalEndcap;
265  double et_lsb = (ieta <= 17) ? eb_lsb : ee_lsb;
266  for (int pos = 0; pos <= 1; pos++) {
267  int zside = (int)pow(-1, pos);
268 
269  // std::cout << "ieta " <<zside*ieta ;
270  for (int iphi = 1; iphi <= 72; iphi++) {
272  continue;
274  EcalTPGGroups::EcalTPGGroupsMapItr itLut = gMap.find(test);
275  if (itLut != gMap.end()) {
276  // std::cout << " non mapped section iphi " << iphi << " ieta " <<ieta << " tccid " << theMapping_->TCCid(test) << " iTT " << theMapping_->iTT(test)<< std::endl;
277  std::vector<int> tpgValue = tpgValueMap[itLut->second];
278 
279  for (unsigned short irank = 0; irank < L1CaloEcalScale::nBinRank; ++irank) {
280  ecalScale->setBin(irank, ieta, zside, et_lsb * tpgValue[irank]);
281 
282  // std::cout << " irank " << irank << " etValue " << et_lsb*tpgValue[irank] << std::endl;
283  }
284 
285  break;
286  }
287  }
288  }
289  }
290 
291  // ecalScale->print(std::cout);
292 
293  // ------------ method called to produce the data ------------
294  return ecalScale;
295 }
296 //define this as a plug-in
l1t::OMDSReader::QueryResults
Definition: OMDSReader.h:49
EcalElectronicsMapping
Definition: EcalElectronicsMapping.h:28
EcalElectronicsId.h
mps_fire.i
i
Definition: mps_fire.py:428
L1CaloEcalScale
Definition: L1CaloEcalScale.h:28
EcalTPGGroups::EcalTPGGroupsMapItr
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:20
readEcalDQMStatus.lastValue
lastValue
Definition: readEcalDQMStatus.py:16
L1ConfigOnlineProdBase< L1CaloEcalScaleRcd, L1CaloEcalScale >::m_omdsReader
l1t::OMDSReader m_omdsReader
Definition: L1ConfigOnlineProdBase.h:65
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
L1CaloEcalScaleRcd
Definition: L1CaloEcalScaleRcd.h:12
EcalElectronicsMapping::getTrigTowerDetId
EcalTrigTowerDetId getTrigTowerDetId(int TCCid, int iTT) const
Builds a EcalTrigTowerDetID from the TCCid & TriggerTower index in TCC.
Definition: EcalElectronicsMapping.cc:240
globals_cff.id1
id1
Definition: globals_cff.py:33
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
L1CaloEcalScaleConfigOnlineProd::L1CaloEcalScaleConfigOnlineProd
L1CaloEcalScaleConfigOnlineProd(const edm::ParameterSet &)
Definition: L1CaloEcalScaleConfigOnlineProd.cc:50
EcalTPGGroups
Definition: EcalTPGGroups.h:17
EcalSubdetector
EcalSubdetector
Definition: EcalSubdetector.h:10
l1t::OMDSReader::singleAttribute
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
L1ConfigOnlineProdBase
Definition: L1ConfigOnlineProdBase.h:52
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
EcalBarrel
Definition: EcalSubdetector.h:10
L1CaloEcalScale::nBinRank
static const unsigned short nBinRank
Definition: L1CaloEcalScale.h:31
EcalTriggerPrimitiveDigi.h
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
test
Definition: SmallWORMDict.h:13
EcalTPGLutIdMap.h
ctpps_dqm_sourceclient-live_cfg.test
test
Definition: ctpps_dqm_sourceclient-live_cfg.py:7
EcalTPGGroups::setValue
void setValue(const uint32_t &rawId, const uint32_t &ObjectId)
Definition: EcalTPGGroups.cc:7
l1t::OMDSReader::QueryResults::fillVariableFromRow
bool fillVariableFromRow(const std::string &columnName, int rowNumber, T &outputVariable) const
Definition: OMDSReader.h:279
l1t::OMDSReader::QueryResults::fillVariable
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:274
L1CaloEcalScaleConfigOnlineProd::newObject
std::unique_ptr< L1CaloEcalScale > newObject(const std::string &objectKey) override
Definition: L1CaloEcalScaleConfigOnlineProd.cc:65
EcalTrigTowerDetId.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalEndcap
Definition: EcalSubdetector.h:10
EcalTPGLutGroup.h
L1CaloEcalScaleConfigOnlineProd::theMapping_
const EcalElectronicsMapping * theMapping_
Definition: L1CaloEcalScaleConfigOnlineProd.cc:45
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
edm::ParameterSet
Definition: ParameterSet.h:47
L1CaloEcalScaleConfigOnlineProd::groupInfo
std::map< int, std::vector< int > * > groupInfo
Definition: L1CaloEcalScaleConfigOnlineProd.cc:46
EcalTrigTowerDetId::validDetId
static bool validDetId(int iz, EcalSubdetector sd, int i, int j)
check if a valid index combination
Definition: EcalTrigTowerDetId.cc:86
EcalElectronicsMapping.h
createfilelist.int
int
Definition: createfilelist.py:10
l1t::OMDSReader::QueryResults::numberRows
int numberRows() const
Definition: OMDSReader.h:60
L1CaloEcalScaleConfigOnlineProd::lutGrpMap
EcalTPGGroups * lutGrpMap
Definition: L1CaloEcalScaleConfigOnlineProd.cc:47
EcalTPGGroups::getMap
const EcalTPGGroupsMap & getMap() const
Definition: EcalTPGGroups.h:25
l1t::OMDSReader::basicQuery
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:75
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
L1CaloEcalScaleRcd.h
L1CaloEcalScale.h
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
L1CaloEcalScaleConfigOnlineProd
Definition: L1CaloEcalScaleConfigOnlineProd.cc:37
L1CaloEcalScaleConfigOnlineProd::~L1CaloEcalScaleConfigOnlineProd
~L1CaloEcalScaleConfigOnlineProd() override
Definition: L1CaloEcalScaleConfigOnlineProd.cc:56
l1t::OMDSReader::QueryResults::queryFailed
bool queryFailed() const
Definition: OMDSReader.h:59
EcalTPGPhysicsConst.h
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
globals_cff.id2
id2
Definition: globals_cff.py:34
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
L1CaloEcalScale::nBinEta
static const unsigned short nBinEta
Definition: L1CaloEcalScale.h:32
L1ConfigOnlineProdBase.h
EcalTPGGroups::EcalTPGGroupsMap
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:19
watchdog.group
group
Definition: watchdog.py:82