CMS 3D CMS Logo

HcalLutManager.cc
Go to the documentation of this file.
1 #include <cstdlib>
2 #include <fstream>
3 #include <memory>
4 #include <sstream>
5 #include <sys/stat.h>
6 #include <sys/time.h>
7 #include <sys/types.h>
8 #include <unistd.h>
9 
10 #include <cstdlib> // For srand() and rand()
11 
12 #ifdef HAVE_XDAQ
13 #include <toolbox/string.h>
14 #else
15 #include "CaloOnlineTools/HcalOnlineDb/interface/xdaq_compat.h" // Replaces toolbox::toString
16 #endif
17 
19 
21 
31 
34 using namespace std;
35 using namespace oracle::occi;
36 using namespace hcal;
37 
47 
48 HcalLutManager::HcalLutManager(std::vector<HcalGenericDetId>& map) {
49  init();
50  _iter.init(map);
51 }
52 
54  const HcalChannelQuality* _cq,
55  uint32_t _status_word_to_mask) {
56  init();
57  emap = _emap;
58  cq = _cq;
59  status_word_to_mask = _status_word_to_mask;
60 }
61 
63  const HcalChannelQuality* _cq,
64  uint32_t _status_word_to_mask) {
65  init();
66  conditions = _conditions;
67  emap = conditions->getHcalMapping();
68  cq = _cq;
69  status_word_to_mask = _status_word_to_mask;
70 }
71 
73  lut_xml = nullptr;
74  lut_checksums_xml = nullptr;
75  db = nullptr;
76  lmap = nullptr;
77  emap = nullptr;
78  cq = nullptr;
79  conditions = nullptr;
80  status_word_to_mask = 0x0000;
81 }
82 
84  delete lut_xml;
85  delete lut_checksums_xml;
86  delete db;
87  delete lmap;
88 }
89 
90 int HcalLutManager::initChannelIterator(std::vector<HcalGenericDetId>& map) {
91  _iter.init(map);
92  return _iter.size();
93 }
94 
95 std::string& HcalLutManager::getLutXml(std::vector<unsigned int>& _lut) {
96  if (lut_xml)
97  delete lut_xml;
98 
99  lut_xml = new LutXml();
100 
101  LutXml::Config _config;
102  _config.lut = _lut;
103  lut_xml->addLut(_config);
104  lut_xml->addLut(_config);
105  lut_xml->addLut(_config);
106 
107  //return lut_xml->getString();
108  return lut_xml->getCurrentBrick();
109 }
110 
112  int result;
113  sscanf(number.c_str(), "%d", &result);
114  return result;
115 }
116 
119  if (_det.find("HB") != std::string::npos)
120  result = HcalBarrel;
121  else if (_det.find("HE") != std::string::npos)
122  result = HcalEndcap;
123  else if (_det.find("HF") != std::string::npos)
125  else if (_det.find("HO") != std::string::npos)
126  result = HcalOuter;
127  else
128  result = HcalOther;
129 
130  return result;
131 }
132 
134  HcalLutManager _manager;
135  HcalLutSet _set = _manager.getLutSetFromFile(_filename);
136  std::stringstream s;
137  s << "===> Test of HcalLutSet HcalLutManager::getLutSetFromFile( std::string _filename )" << std::endl << std::endl;
138  s << _set.label << std::endl;
139  for (unsigned int i = 0; i != _set.subdet.size(); i++)
140  s << _set.subdet[i] << " ";
141  s << std::endl;
142  for (unsigned int i = 0; i != _set.eta_min.size(); i++)
143  s << _set.eta_min[i] << " ";
144  s << std::endl;
145  for (unsigned int i = 0; i != _set.eta_max.size(); i++)
146  s << _set.eta_max[i] << " ";
147  s << std::endl;
148  for (unsigned int i = 0; i != _set.phi_min.size(); i++)
149  s << _set.phi_min[i] << " ";
150  s << std::endl;
151  for (unsigned int i = 0; i != _set.phi_max.size(); i++)
152  s << _set.phi_max[i] << " ";
153  s << std::endl;
154  for (unsigned int i = 0; i != _set.depth_min.size(); i++)
155  s << _set.depth_min[i] << " ";
156  s << std::endl;
157  for (unsigned int i = 0; i != _set.depth_max.size(); i++)
158  s << _set.depth_max[i] << " ";
159  s << std::endl;
160  for (unsigned int j = 0; j != _set.lut[0].size(); j++) {
161  for (unsigned int i = 0; i != _set.lut.size(); i++) {
162  s << _set.lut[i][j] << " ";
163  }
164  s << "---> " << j << std::endl;
165  }
166  edm::LogInfo("HcalLutManager") << s.str();
167  return 0;
168 }
169 
171  HcalLutSet _lutset;
172 
173  ifstream infile(_filename.c_str());
175 
176  if (infile.is_open()) {
177  edm::LogInfo("HcalLutManager") << "File " << _filename << " is open..." << std::endl
178  << "Reading LUTs and their eta/phi/depth/subdet ranges...";
179 
180  // get label
181  getline(infile, _lutset.label);
182 
183  if (_type == 1) { // for linearization LUTs get subdetectors (default)
184  //get subdetectors
185  getline(infile, buf);
187  }
188 
189  //get min etas
190  std::vector<std::string> buf_vec;
191  getline(infile, buf);
192  buf_vec = HcalQIEManager::splitString(buf);
193  for (std::vector<std::string>::const_iterator iter = buf_vec.begin(); iter != buf_vec.end(); iter++) {
194  _lutset.eta_min.push_back(HcalLutManager::getInt(*iter));
195  }
196 
197  //get max etas
198  getline(infile, buf);
199  buf_vec = HcalQIEManager::splitString(buf);
200  for (std::vector<std::string>::const_iterator iter = buf_vec.begin(); iter != buf_vec.end(); iter++) {
201  _lutset.eta_max.push_back(HcalLutManager::getInt(*iter));
202  }
203 
204  //get min phis
205  getline(infile, buf);
206  buf_vec = HcalQIEManager::splitString(buf);
207  for (std::vector<std::string>::const_iterator iter = buf_vec.begin(); iter != buf_vec.end(); iter++) {
208  _lutset.phi_min.push_back(HcalLutManager::getInt(*iter));
209  }
210 
211  //get max phis
212  getline(infile, buf);
213  buf_vec = HcalQIEManager::splitString(buf);
214  for (std::vector<std::string>::const_iterator iter = buf_vec.begin(); iter != buf_vec.end(); iter++) {
215  _lutset.phi_max.push_back(HcalLutManager::getInt(*iter));
216  }
217 
218  if (_type == 1) { // for linearization LUTs get depth range (default)
219  //get min depths
220  getline(infile, buf);
221  buf_vec = HcalQIEManager::splitString(buf);
222  for (std::vector<std::string>::const_iterator iter = buf_vec.begin(); iter != buf_vec.end(); iter++) {
223  _lutset.depth_min.push_back(HcalLutManager::getInt(*iter));
224  }
225 
226  //get max depths
227  getline(infile, buf);
228  buf_vec = HcalQIEManager::splitString(buf);
229  for (std::vector<std::string>::const_iterator iter = buf_vec.begin(); iter != buf_vec.end(); iter++) {
230  _lutset.depth_max.push_back(HcalLutManager::getInt(*iter));
231  }
232  }
233 
234  bool first_lut_entry = true;
235  while (getline(infile, buf)) {
236  buf_vec = HcalQIEManager::splitString(buf);
237  for (unsigned int i = 0; i < buf_vec.size(); i++) {
238  if (first_lut_entry) {
239  std::vector<unsigned int> _l;
240  _lutset.lut.push_back(_l);
241  }
242  _lutset.lut[i].push_back(HcalLutManager::getInt(buf_vec[i]));
243  }
244  first_lut_entry = false;
245  }
246  }
247 
248  edm::LogInfo("HcalLutManager") << "done.";
249 
250  return _lutset;
251 }
252 
253 std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getLutXmlFromAsciiMaster(std::string _filename,
254  std::string _tag,
255  int _crate,
256  bool split_by_crate) {
257  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from ascii master file...";
258  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
259 
260  LMap _lmap;
261  _lmap.read("./backup/HCALmapHBEF.txt", "HBEF");
262  _lmap.read("./backup/HCALmapHO.txt", "HO");
263  std::map<int, LMapRow>& _map = _lmap.get_map();
264  edm::LogInfo("HcalLutManager") << "LMap contains " << _map.size() << " channels";
265 
266  // read LUTs and their eta/phi/depth/subdet ranges
267  HcalLutSet _set = getLutSetFromFile(_filename);
268  int lut_set_size = _set.lut.size(); // number of different luts
269 
270  RooGKCounter _counter;
271  //loop over all HCAL channels
272  for (std::map<int, LMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
273  LutXml::Config _cfg;
274 
275  // search for the correct LUT for a given channel,
276  // higher LUT numbers have priority in case of overlapping
277  int lut_index = -1;
278  for (int i = 0; i < lut_set_size; i++) {
279  if ((row->second.crate == _crate || _crate == -1) && // -1 stands for all crates
280  _set.eta_min[i] <= row->second.side * row->second.eta &&
281  _set.eta_max[i] >= row->second.side * row->second.eta && _set.phi_min[i] <= row->second.phi &&
282  _set.phi_max[i] >= row->second.phi && _set.depth_min[i] <= row->second.depth &&
283  _set.depth_max[i] >= row->second.depth && get_subdetector(_set.subdet[i]) == row->second.det) {
284  lut_index = i;
285  }
286  }
287  if (lut_index >= 0) {
288  if (_xml.count(row->second.crate) == 0 && split_by_crate) {
289  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->second.crate, std::make_shared<LutXml>()));
290  } else if (_xml.count(0) == 0 && !split_by_crate) {
291  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
292  }
293  _cfg.ieta = row->second.side * row->second.eta;
294  _cfg.iphi = row->second.phi;
295  _cfg.depth = row->second.depth;
296  _cfg.crate = row->second.crate;
297  _cfg.slot = row->second.htr;
298  if (row->second.fpga.find("top") != std::string::npos)
299  _cfg.topbottom = 1;
300  else if (row->second.fpga.find("bot") != std::string::npos)
301  _cfg.topbottom = 0;
302  else
303  edm::LogWarning("HcalLutManager") << "fpga out of range...";
304  // FIXME: probably fixed. fiber==htr_fi, not rm_fi in LMAP notation.
305  //_cfg.fiber = row->second.rm_fi;
306  _cfg.fiber = row->second.htr_fi;
307  _cfg.fiberchan = row->second.fi_ch;
308  if (_set.lut[lut_index].size() == 128)
309  _cfg.lut_type = 1;
310  else
311  _cfg.lut_type = 2;
312  _cfg.creationtag = _tag;
313  _cfg.creationstamp = get_time_stamp(time(nullptr));
314  _cfg.targetfirmware = "1.0.0";
315  _cfg.formatrevision = "1"; //???
316  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
317  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
318  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
319  _cfg.generalizedindex = _cfg.iphi * 10000 + _cfg.depth * 1000 + (row->second.side > 0) * 100 + row->second.eta +
320  ((row->second.det == HcalForward && row->second.eta == 29) ? (4 * 10000) : (0));
321  _cfg.lut = _set.lut[lut_index];
322  if (split_by_crate) {
323  _xml[row->second.crate]->addLut(_cfg, lut_checksums_xml);
324  _counter.count();
325  } else {
326  _xml[0]->addLut(_cfg, lut_checksums_xml);
327  _counter.count();
328  }
329  }
330  }
331  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
332  << "Generating linearization (input) LUTs from ascii master file...DONE" << std::endl;
333  return _xml;
334 }
335 
336 //
337 //_____ get HO from ASCII master here ___________________________________
338 //
339 std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename,
340  std::string _tag,
341  int _crate,
342  bool split_by_crate) {
343  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from ascii master file...";
344  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
345 
346  EMap _emap(emap);
347  std::vector<EMap::EMapRow>& _map = _emap.get_map();
348  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " entries";
349 
350  // read LUTs and their eta/phi/depth/subdet ranges
351  HcalLutSet _set = getLutSetFromFile(_filename);
352  int lut_set_size = _set.lut.size(); // number of different luts
353  edm::LogInfo("HcalLutManager") << " ==> " << lut_set_size << " sets of different LUTs read from the master file";
354 
355  // setup "zero" LUT for channel masking
356  std::vector<unsigned int> zeroLut;
357  for (size_t adc = 0; adc < 128; adc++)
358  zeroLut.push_back(0);
359 
360  RooGKCounter _counter;
361  //loop over all EMap channels
362  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
363  if ((row->subdet.find("HB") != string::npos || row->subdet.find("HE") != string::npos ||
364  row->subdet.find("HO") != string::npos || row->subdet.find("HF") != string::npos) &&
365  row->subdet.size() == 2) {
366  LutXml::Config _cfg;
367 
368  // search for the correct LUT for a given channel,
369  // higher LUT numbers have priority in case of overlapping
370  int lut_index = -1;
371  for (int i = 0; i < lut_set_size; i++) {
372  if ((row->crate == _crate || _crate == -1) && // -1 stands for all crates
373  _set.eta_min[i] <= row->ieta && _set.eta_max[i] >= row->ieta && _set.phi_min[i] <= row->iphi &&
374  _set.phi_max[i] >= row->iphi && _set.depth_min[i] <= row->idepth && _set.depth_max[i] >= row->idepth &&
375  _set.subdet[i].find(row->subdet) != string::npos) {
376  lut_index = i;
377  }
378  }
379  if (lut_index >= 0) {
380  if (_xml.count(row->crate) == 0 && split_by_crate) {
381  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
382  } else if (_xml.count(0) == 0 && !split_by_crate) {
383  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
384  }
385  _cfg.ieta = row->ieta;
386  _cfg.iphi = row->iphi;
387  _cfg.depth = row->idepth;
388  _cfg.crate = row->crate;
389  _cfg.slot = row->slot;
390  if (row->topbottom.find('t') != std::string::npos)
391  _cfg.topbottom = 1;
392  else if (row->topbottom.find('b') != std::string::npos)
393  _cfg.topbottom = 0;
394  else if (row->topbottom.find('u') != std::string::npos)
395  _cfg.topbottom = 2;
396  else
397  edm::LogWarning("HcalLutManager") << "fpga out of range...";
398  _cfg.fiber = row->fiber;
399  _cfg.fiberchan = row->fiberchan;
400  _cfg.lut_type = 1;
401  _cfg.creationtag = _tag;
402  _cfg.creationstamp = get_time_stamp(time(nullptr));
403  _cfg.targetfirmware = "1.0.0";
404  _cfg.formatrevision = "1"; //???
405  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
406  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
407  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
408  _cfg.generalizedindex =
409  _cfg.iphi * 10000 + _cfg.depth * 1000 + (row->ieta > 0) * 100 + abs(row->ieta) +
410  (((row->subdet.find("HF") != string::npos) && abs(row->ieta) == 29) ? (4 * 10000) : (0));
411  //
412  // consider channel status here
413  DetId _detId(row->rawId);
414  uint32_t status_word = cq->getValues(_detId)->getValue();
415  if ((status_word & status_word_to_mask) > 0) {
416  _cfg.lut = zeroLut;
417  } else {
418  _cfg.lut = _set.lut[lut_index];
419  }
420  if (split_by_crate) {
421  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
422  _counter.count();
423  } else {
424  _xml[0]->addLut(_cfg, lut_checksums_xml);
425  _counter.count();
426  }
427  }
428  }
429  }
430  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
431  << "Generating linearization (input) LUTs from ascii master file...DONE" << std::endl;
432  return _xml;
433 }
434 
436  std::string _filename, std::string _tag, int _crate, bool split_by_crate) {
437  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from ascii master file...";
438  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
439 
440  // read LUTs and their eta/phi/depth/subdet ranges
441  HcalLutSet _set = getLutSetFromFile(_filename);
442  int lut_set_size = _set.lut.size(); // number of different luts
443  edm::LogInfo("HcalLutManager") << " ==> " << lut_set_size << " sets of different LUTs read from the master file";
444 
445  RooGKCounter _counter;
446  //loop over all EMap channels
447  for (_iter.begin(); !_iter.end(); _iter.next()) {
448  HcalSubdetector _subdet = _iter.getHcalSubdetector();
449  if ((_subdet == HcalBarrel || _subdet == HcalEndcap || _subdet == HcalForward || _subdet == HcalOuter)) {
450  int _ieta = _iter.getIeta();
451  int _iphi = _iter.getIphi();
452  int _depth = _iter.getDepth();
453 
454  // FIXME: this is probably wrong, raw ids are different
455  HcalElectronicsId _eId(_iter.getHcalGenericDetId().rawId());
456  int aCrate = _eId.readoutVMECrateId();
457  int aSlot = _eId.htrSlot();
458  int aTopBottom = _eId.htrTopBottom();
459  int aFiber = _eId.fiberIndex();
460  int aFiberChan = _eId.fiberChanId();
461 
462  LutXml::Config _cfg;
463 
464  // search for the correct LUT for a given channel,
465  // higher LUT numbers have priority in case of overlapping
466  int lut_index = -1;
467  for (int i = 0; i < lut_set_size; i++) {
468  if ((aCrate == _crate || _crate == -1) && // -1 stands for all crates
469  _set.eta_min[i] <= _ieta && _set.eta_max[i] >= _ieta && _set.phi_min[i] <= _iphi &&
470  _set.phi_max[i] >= _iphi && _set.depth_min[i] <= _depth && _set.depth_max[i] >= _depth &&
471  _set.subdet[i].find(_ass.getSubdetectorString(_subdet)) != string::npos) {
472  lut_index = i;
473  }
474  }
475  if (lut_index >= 0) {
476  if (_xml.count(aCrate) == 0 && split_by_crate) {
477  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(aCrate, std::make_shared<LutXml>()));
478  } else if (_xml.count(0) == 0 && !split_by_crate) {
479  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
480  }
481  _cfg.ieta = _ieta;
482  _cfg.iphi = _iphi;
483  _cfg.depth = _depth;
484  _cfg.crate = aCrate;
485  _cfg.slot = aSlot;
486  _cfg.topbottom = aTopBottom;
487  _cfg.fiber = aFiber;
488  _cfg.fiberchan = aFiberChan;
489  _cfg.lut_type = 1;
490  _cfg.creationtag = _tag;
491  _cfg.creationstamp = get_time_stamp(time(nullptr));
492  _cfg.targetfirmware = "1.0.0";
493  _cfg.formatrevision = "1"; //???
494  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
495  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
496  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
497  _cfg.generalizedindex = _cfg.iphi * 10000 + _cfg.depth * 1000 + (_ieta > 0) * 100 + abs(_ieta) +
498  (((_subdet == HcalForward) && abs(_ieta) == 29) ? (4 * 10000) : (0));
499  _cfg.lut = _set.lut[lut_index];
500  if (split_by_crate) {
501  _xml[aCrate]->addLut(_cfg, lut_checksums_xml);
502  _counter.count();
503  } else {
504  _xml[0]->addLut(_cfg, lut_checksums_xml);
505  _counter.count();
506  }
507  }
508  }
509  }
510  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
511  << "Generating linearization (input) LUTs from ascii master file...DONE" << std::endl;
512  return _xml;
513 }
514 
515 std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getCompressionLutXmlFromAsciiMaster(std::string _filename,
516  std::string _tag,
517  int _crate,
518  bool split_by_crate) {
519  edm::LogInfo("HcalLutManager") << "Generating compression (output) LUTs from ascii master file...";
520  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
521 
522  edm::LogInfo("HcalLutManager")
523  << "instantiating CaloTPGTranscoderULUT in order to check the validity of (ieta,iphi)...";
524  CaloTPGTranscoderULUT _coder;
525 
526  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
527  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
528  EMap _emap(emap);
529  std::vector<EMap::EMapRow>& _map = _emap.get_map();
530  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " channels";
531 
532  // read LUTs and their eta/phi/depth/subdet ranges
533  HcalLutSet _set = getLutSetFromFile(_filename, 2);
534  int lut_set_size = _set.lut.size(); // number of different luts
535  edm::LogInfo("HcalLutManager") << " ==> " << lut_set_size << " sets of different LUTs read from the master file";
536 
537  //loop over all EMap channels
538  RooGKCounter _counter;
539  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
540  LutXml::Config _cfg;
541 
542  // search for the correct LUT for a given channel,
543  // higher LUT numbers have priority in case of overlapping
544  int lut_index = -1;
545  for (int i = 0; i < lut_set_size; i++) {
546  if (row->subdet.find("HT") != std::string::npos &&
547  (row->crate == _crate || _crate == -1) && // -1 stands for all crates
548  _set.eta_min[i] <= row->ieta && _set.eta_max[i] >= row->ieta && _set.phi_min[i] <= row->iphi &&
549  _set.phi_max[i] >= row->iphi && _coder.HTvalid(row->ieta, row->iphi, row->idepth / 10)) {
550  lut_index = i;
551  }
552  }
553  if (lut_index >= 0) {
554  if (_xml.count(row->crate) == 0 && split_by_crate) {
555  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
556  } else if (_xml.count(0) == 0 && !split_by_crate) {
557  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
558  }
559  _cfg.ieta = row->ieta;
560  _cfg.iphi = row->iphi;
561  _cfg.depth = row->idepth;
562  _cfg.crate = row->crate;
563  _cfg.slot = row->slot;
564  if (row->topbottom.find('t') != std::string::npos)
565  _cfg.topbottom = 1;
566  else if (row->topbottom.find('b') != std::string::npos)
567  _cfg.topbottom = 0;
568  else if (row->topbottom.find('u') != std::string::npos)
569  _cfg.topbottom = 2;
570  else
571  edm::LogWarning("HcalLutManager") << "fpga out of range...";
572  _cfg.fiber = row->fiber;
573  _cfg.fiberchan = row->fiberchan;
574  if (_set.lut[lut_index].size() == 128)
575  _cfg.lut_type = 1;
576  else
577  _cfg.lut_type = 2;
578  _cfg.creationtag = _tag;
579  _cfg.creationstamp = get_time_stamp(time(nullptr));
580  _cfg.targetfirmware = "1.0.0";
581  _cfg.formatrevision = "1"; //???
582  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
583  // int generalizedIndex=id.ietaAbs()+10000*id.iphi()+
584  // ((id.ieta()<0)?(0):(100));
585  _cfg.generalizedindex = _cfg.iphi * 10000 + (row->ieta > 0) * 100 + abs(row->ieta);
586  _cfg.lut = _set.lut[lut_index];
587  if (split_by_crate) {
588  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
589  _counter.count();
590  } else {
591  _xml[0]->addLut(_cfg, lut_checksums_xml);
592  _counter.count();
593  }
594  }
595  }
596  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
597  << "Generating compression (output) LUTs from ascii master file...DONE" << std::endl;
598  return _xml;
599 }
600 
601 std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getLinearizationLutXmlFromCoder(const HcalTPGCoder& _coder,
602  std::string _tag,
603  bool split_by_crate) {
604  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...";
605  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
606 
607  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
608  //std::vector<EMap::EMapRow> & _map = _emap.get_map();
609  //std::cout << "EMap contains " << _map . size() << " entries" << std::endl;
610 
611  LMap _lmap;
612  _lmap.read("backup/HCALmapHBEF.txt", "HBEF");
613  // HO is not part of trigger, so TPGCoder cannot generate LUTs for it
614  //_lmap . read( "backup/HCALmapHO.txt", "HO" );
615  std::map<int, LMapRow>& _map = _lmap.get_map();
616  edm::LogInfo("HcalLutManager") << "LMap contains " << _map.size() << " channels";
617 
618  // read LUTs and their eta/phi/depth/subdet ranges
619  //HcalLutSet _set = getLinearizationLutSetFromCoder();
620  //int lut_set_size = _set.lut.size(); // number of different luts
621 
622  //loop over all HCAL channels
623  RooGKCounter _counter;
624  for (std::map<int, LMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
625  LutXml::Config _cfg;
626 
627  if (_xml.count(row->second.crate) == 0 && split_by_crate) {
628  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->second.crate, std::make_shared<LutXml>()));
629  } else if (_xml.count(0) == 0 && !split_by_crate) {
630  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
631  }
632  _cfg.ieta = row->second.side * row->second.eta;
633  _cfg.iphi = row->second.phi;
634  _cfg.depth = row->second.depth;
635  _cfg.crate = row->second.crate;
636  _cfg.slot = row->second.htr;
637  if (row->second.fpga.find("top") != std::string::npos)
638  _cfg.topbottom = 1;
639  else if (row->second.fpga.find("bot") != std::string::npos)
640  _cfg.topbottom = 0;
641  else
642  edm::LogWarning("HcalLutManager") << "fpga out of range...";
643  // FIXME: probably fixed. fiber==htr_fi, not rm_fi in LMAP notation.
644  //_cfg.fiber = row->second.rm_fi;
645  _cfg.fiber = row->second.htr_fi;
646  _cfg.fiberchan = row->second.fi_ch;
647  _cfg.lut_type = 1;
648  _cfg.creationtag = _tag;
649  _cfg.creationstamp = get_time_stamp(time(nullptr));
650  _cfg.targetfirmware = "1.0.0";
651  _cfg.formatrevision = "1"; //???
652  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
653  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
654  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
655  _cfg.generalizedindex = _cfg.iphi * 10000 + _cfg.depth * 1000 + (row->second.side > 0) * 100 + row->second.eta +
656  ((row->second.det == HcalForward && row->second.eta == 29) ? (4 * 10000) : (0));
657 
658  //HcalDetId _detid(row->first);
659  HcalDetId _detid(row->second.det, row->second.side * row->second.eta, row->second.phi, row->second.depth);
660  //std::cout << "### DEBUG: rawid = " << _detid.rawId() << std::endl;
661 
662  //std::cout << "### DEBUG: subdetector = " << row->second.det << std::endl;
663  std::vector<unsigned short> coder_lut = _coder.getLinearizationLUT(_detid);
664  for (std::vector<unsigned short>::const_iterator _i = coder_lut.begin(); _i != coder_lut.end(); _i++) {
665  unsigned int _temp = (unsigned int)(*_i);
666  //if (_temp!=0) std::cout << "DEBUG non-zero LUT!!!!!!!!!!!!!!!" << (*_i) << " " << _temp << std::endl;
667  //unsigned int _temp = 0;
668  _cfg.lut.push_back(_temp);
669  }
670  if (split_by_crate) {
671  _xml[row->second.crate]->addLut(_cfg, lut_checksums_xml);
672  _counter.count();
673  } else {
674  _xml[0]->addLut(_cfg, lut_checksums_xml);
675  _counter.count();
676  }
677  }
678  edm::LogInfo("HcalLutManager") << "Generated LUTs: " << _counter.getCount() << std::endl
679  << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...DONE" << std::endl;
680  return _xml;
681 }
682 
683 std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getMasks(int masktype, std::string _tag, bool split_by_crate) {
684  edm::LogInfo("HcalLutManager") << "Generating TDC masks...";
685 
686  EMap _emap(emap);
687  std::vector<EMap::EMapRow>& _map = _emap.get_map();
688  edm::LogInfo("HcalLutManager") << "EMap contains new" << _map.size() << " entries";
689 
690  std::map<int, std::vector<uint64_t>> masks;
691 
692  for (const auto& row : _map) {
693  std::string subdet = row.subdet;
694  if (subdet != "HF")
695  continue;
696  int crate = row.crate;
697  int slot = row.slot;
698  int crot = 100 * crate + slot;
699  int fiber = row.fiber;
700  int channel = row.fiberchan;
701  unsigned int finel = 4 * fiber + channel;
702  if (masks.count(crot) == 0)
703  masks[crot] = {};
704  if (finel >= masks[crot].size())
705  masks[crot].resize(finel + 1);
706 
707  if (masktype == 0) {
708  HcalSubdetector _subdet;
709  if (row.subdet.find("HB") != string::npos)
710  _subdet = HcalBarrel;
711  else if (row.subdet.find("HE") != string::npos)
712  _subdet = HcalEndcap;
713  else if (row.subdet.find("HO") != string::npos)
714  _subdet = HcalOuter;
715  else if (row.subdet.find("HF") != string::npos)
716  _subdet = HcalForward;
717  else
718  _subdet = HcalOther;
719  HcalDetId _detid(_subdet, row.ieta, row.iphi, row.idepth);
720  masks[crot][finel] = conditions->getHcalTPChannelParameter(_detid)->getMask();
721  } else {
722  auto parameters = conditions->getHcalTPParameters();
723  masks[crot][finel] = masktype == 1 ? parameters->getADCThresholdHF() : parameters->getTDCMaskHF();
724  }
725  }
726 
727  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
728  RooGKCounter _counter;
729 
730  for (const auto& i : masks) {
731  int crot = i.first;
732  int crate = crot / 100;
733 
734  LutXml::Config _cfg;
735  _cfg.lut_type = 5 + masktype;
736  _cfg.crate = crate;
737  _cfg.slot = crot % 100;
738  _cfg.generalizedindex = crot;
739  _cfg.mask = i.second;
740  _cfg.creationtag = _tag;
741  _cfg.targetfirmware = "1.0.0";
742  _cfg.formatrevision = "1";
743 
744  int c = split_by_crate ? crate : 0;
745  if (_xml.count(c) == 0)
746  _xml[c] = std::make_shared<LutXml>();
747 
748  _xml[c]->addLut(_cfg);
749  _counter.count();
750  }
751 
752  edm::LogInfo("HcalLutManager") << "Generated LUTs: " << _counter.getCount() << std::endl
753  << "Generating Masks...DONE" << std::endl;
754  return _xml;
755 }
756 
757 std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getLinearizationLutXmlFromCoderEmap(const HcalTPGCoder& _coder,
758  std::string _tag,
759  bool split_by_crate) {
760  edm::LogInfo("HcalLutManager") << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...";
761  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
762 
763  EMap _emap(emap);
764  std::vector<EMap::EMapRow>& _map = _emap.get_map();
765  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " entries";
766 
767  RooGKCounter _counter;
768  //loop over all EMap channels
769  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
770  if ((row->subdet.find("HB") != string::npos || row->subdet.find("HE") != string::npos ||
771  row->subdet.find("HF") != string::npos) &&
772  row->subdet.size() == 2) {
773  LutXml::Config _cfg;
774 
775  if (_xml.count(row->crate) == 0 && split_by_crate) {
776  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
777  } else if (_xml.count(0) == 0 && !split_by_crate) {
778  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
779  }
780  _cfg.ieta = row->ieta;
781  _cfg.iphi = row->iphi;
782  _cfg.depth = row->idepth;
783  _cfg.crate = row->crate;
784  _cfg.slot = row->slot;
785  if (row->topbottom.find('t') != std::string::npos)
786  _cfg.topbottom = 1;
787  else if (row->topbottom.find('b') != std::string::npos)
788  _cfg.topbottom = 0;
789  else if (row->topbottom.find('u') != std::string::npos)
790  _cfg.topbottom = 2;
791  else
792  edm::LogWarning("HcalLutManager") << "fpga out of range...";
793  _cfg.fiber = row->fiber;
794  _cfg.fiberchan = row->fiberchan;
795  _cfg.lut_type = 1;
796  _cfg.creationtag = _tag;
797  _cfg.creationstamp = get_time_stamp(time(nullptr));
798  _cfg.targetfirmware = "1.0.0";
799  _cfg.formatrevision = "1"; //???
800  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
801  // int generalizedIndex=id.ietaAbs()+1000*id.depth()+10000*id.iphi()+
802  // ((id.ieta()<0)?(0):(100))+((id.subdet()==HcalForward && id.ietaAbs()==29)?(4*10000):(0));
803  _cfg.generalizedindex = _cfg.iphi * 10000 + _cfg.depth * 1000 + (row->ieta > 0) * 100 + abs(row->ieta) +
804  (((row->subdet.find("HF") != string::npos) && abs(row->ieta) == 29) ? (4 * 10000) : (0));
805  HcalSubdetector _subdet;
806  if (row->subdet.find("HB") != string::npos)
807  _subdet = HcalBarrel;
808  else if (row->subdet.find("HE") != string::npos)
809  _subdet = HcalEndcap;
810  else if (row->subdet.find("HO") != string::npos)
811  _subdet = HcalOuter;
812  else if (row->subdet.find("HF") != string::npos)
813  _subdet = HcalForward;
814  else
815  _subdet = HcalOther;
816  HcalDetId _detid(_subdet, row->ieta, row->iphi, row->idepth);
817 
818  for (const auto i : _coder.getLinearizationLUT(_detid))
819  _cfg.lut.push_back(i);
820 
821  if (split_by_crate) {
822  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
823  _counter.count();
824  } else {
825  _xml[0]->addLut(_cfg, lut_checksums_xml);
826  _counter.count();
827  }
828  }
829  }
830  edm::LogInfo("HcalLutManager") << "Generated LUTs: " << _counter.getCount() << std::endl
831  << "Generating linearization (input) LUTs from HcaluLUTTPGCoder...DONE" << std::endl;
832  return _xml;
833 }
834 
835 std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getHEFineGrainLUTs(std::string _tag, bool split_by_crate) {
836  edm::LogInfo("HcalLutManager") << "Generating HE fine grain LUTs";
837  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
838 
839  EMap _emap(emap);
840  std::vector<EMap::EMapRow>& _map = _emap.get_map();
841  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " entries";
842 
843  RooGKCounter _counter;
844  //loop over all EMap channels
845  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
846  if (row->subdet.find("HT") != string::npos && row->subdet.size() == 2) {
847  int abseta = abs(row->ieta);
848  const HcalTopology* topo = cq->topo();
849  if (abseta <= topo->lastHBRing() or abseta > topo->lastHERing())
850  continue;
851  if (abseta >= topo->firstHEDoublePhiRing() and row->fiberchan % 2 == 1)
852  continue; //do only actual physical towers
853  LutXml::Config _cfg;
854 
855  if (_xml.count(row->crate) == 0 && split_by_crate) {
856  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
857  } else if (_xml.count(0) == 0 && !split_by_crate) {
858  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
859  }
860  _cfg.ieta = row->ieta;
861  _cfg.iphi = row->iphi;
862  _cfg.depth = row->idepth;
863  _cfg.crate = row->crate;
864  _cfg.slot = row->slot;
865  if (row->topbottom.find('t') != std::string::npos)
866  _cfg.topbottom = 1;
867  else if (row->topbottom.find('b') != std::string::npos)
868  _cfg.topbottom = 0;
869  else if (row->topbottom.find('u') != std::string::npos)
870  _cfg.topbottom = 2;
871  else
872  edm::LogWarning("HcalLutManager") << "fpga out of range...";
873  _cfg.fiber = row->fiber;
874  _cfg.fiberchan = row->fiberchan;
875  _cfg.lut_type = 4;
876  _cfg.creationtag = _tag;
877  _cfg.creationstamp = get_time_stamp(time(nullptr));
878  _cfg.targetfirmware = "1.0.0";
879  _cfg.formatrevision = "1"; //???
880  _cfg.generalizedindex = _cfg.iphi * 10000 + _cfg.depth * 1000 + (row->ieta > 0) * 100 + abs(row->ieta) +
881  (((row->subdet.find("HF") != string::npos) && abs(row->ieta) == 29) ? (4 * 10000) : (0));
882  // fine grain LUTs only relevant for HE
883  HcalSubdetector _subdet = HcalEndcap;
884  HcalDetId _detid(_subdet, row->ieta, row->iphi, row->idepth);
885 
886  HcalFinegrainBit fg_algo(conditions->getHcalTPParameters()->getFGVersionHBHE());
887 
888  // loop over all possible configurations,
889  // computing the LUT for each
890  const int n_fgab_bits = 2048;
891  for (int i = 0; i < 2 * n_fgab_bits; i++) {
893  for (int k = 0; k < 6; k++) {
894  tow[0][k] = (1 << k) & i;
895  tow[1][k] = (1 << (k + 6)) & i;
896  }
897  _cfg.lut.push_back(fg_algo.compute(tow).to_ulong());
898  }
899 
900  if (split_by_crate) {
901  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
902  _counter.count();
903  } else {
904  _xml[0]->addLut(_cfg, lut_checksums_xml);
905  _counter.count();
906  }
907  }
908  }
909  edm::LogInfo("HcalLutManager") << "Generated LUTs: " << _counter.getCount() << std::endl
910  << "Generating HE fine grain LUTs from HcaluLUTTPGCoder...DONE" << std::endl;
911  return _xml;
912 }
913 
914 std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getCompressionLutXmlFromCoder(
915  const CaloTPGTranscoderULUT& _coder, std::string _tag, bool split_by_crate) {
916  edm::LogInfo("HcalLutManager") << "Generating compression (output) LUTs from CaloTPGTranscoderULUT," << std::endl
917  << "initialized from Event Setup" << std::endl;
918  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
919 
920  EMap _emap(emap);
921 
922  std::map<int, unsigned int> maxsize;
923 
924  std::vector<EMap::EMapRow>& _map = _emap.get_map();
925  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " channels";
926 
927  //need to equalize compression LUT size in each crate-slot, needed for mixed uHTR
928  for (const auto& row : _map) {
929  if (row.subdet.find("HT") == std::string::npos)
930  continue;
931  HcalTrigTowerDetId _detid(row.rawId);
932  if (!cq->topo()->validHT(_detid))
933  continue;
934  int crot = 100 * row.crate + row.slot;
935  unsigned int size = _coder.getCompressionLUT(_detid).size();
936  if (maxsize.count(crot) == 0 || size > maxsize[crot])
937  maxsize[crot] = size;
938  }
939 
940  RooGKCounter _counter;
941  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
942  LutXml::Config _cfg;
943 
944  if (row->subdet.find("HT") == std::string::npos)
945  continue;
946 
947  HcalTrigTowerDetId _detid(row->rawId);
948 
949  if (!cq->topo()->validHT(_detid))
950  continue;
951 
952  if (_xml.count(row->crate) == 0 && split_by_crate) {
953  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
954  } else if (_xml.count(0) == 0 && !split_by_crate) {
955  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
956  }
957 
958  _cfg.ieta = row->ieta;
959  _cfg.iphi = row->iphi;
960  _cfg.depth = row->idepth;
961  _cfg.crate = row->crate;
962  _cfg.slot = row->slot;
963  if (row->topbottom.find('t') != std::string::npos)
964  _cfg.topbottom = 1;
965  else if (row->topbottom.find('b') != std::string::npos)
966  _cfg.topbottom = 0;
967  else if (row->topbottom.find('u') != std::string::npos)
968  _cfg.topbottom = 2;
969  else
970  edm::LogWarning("HcalLutManager") << "fpga out of range...";
971  _cfg.fiber = row->fiber;
972  _cfg.fiberchan = row->fiberchan;
973  _cfg.lut_type = 2;
974  _cfg.creationtag = _tag;
975  _cfg.creationstamp = get_time_stamp(time(nullptr));
976  _cfg.targetfirmware = "1.0.0";
977  _cfg.formatrevision = "1"; //???
978  _cfg.generalizedindex = _cfg.iphi * 10000 + (row->ieta > 0) * 100 + abs(row->ieta); //is this used for anything?
979 
980  _cfg.lut = _coder.getCompressionLUT(_detid);
981  auto pWeight = conditions->getHcalTPChannelParameter(_detid, false);
982  if (pWeight)
983  _cfg.weight = pWeight->getauxi1();
984 
985  int crot = 100 * row->crate + row->slot;
986  unsigned int size = _cfg.lut.size();
987  if (size < maxsize[crot]) {
988  edm::LogWarning("HcalLutManager") << " resizing LUT for " << _detid << ", channel=[" << _cfg.crate << ":"
989  << _cfg.slot << ":" << _cfg.fiber << ":" << _cfg.fiberchan
990  << "], using value=" << _cfg.lut[size - 1] << std::endl;
991  for (unsigned int i = size; i < maxsize[crot]; ++i)
992  _cfg.lut.push_back(_cfg.lut[size - 1]);
993  }
994 
995  if (split_by_crate) {
996  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
997  _counter.count();
998  } else {
999  _xml[0]->addLut(_cfg, lut_checksums_xml);
1000  _counter.count();
1001  }
1002  }
1003  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
1004  << "Generating compression (output) LUTs from CaloTPGTranscoderULUT...DONE"
1005  << std::endl;
1006 
1007  return _xml;
1008 }
1009 
1010 std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getCompressionLutXmlFromCoder(std::string _tag,
1011  bool split_by_crate) {
1012  edm::LogInfo("HcalLutManager") << "Generating compression (output) LUTs from CaloTPGTranscoderULUT";
1013  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
1014 
1015  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v5_080208.txt");
1016  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
1017  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
1018  EMap _emap(emap);
1019 
1020  std::vector<EMap::EMapRow>& _map = _emap.get_map();
1021  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " channels";
1022 
1023  // read LUTs and their eta/phi/depth/subdet ranges
1024  //HcalLutSet _set = getLutSetFromFile( _filename, 2 );
1025  //int lut_set_size = _set.lut.size(); // number of different luts
1026 
1027  CaloTPGTranscoderULUT _coder;
1028 
1029  //loop over all EMap channels
1030  RooGKCounter _counter;
1031  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
1032  LutXml::Config _cfg;
1033 
1034  // only trigger tower channels
1035  // and valid (ieta,iphi)
1036  const int tp_version = row->idepth / 10;
1037  if (row->subdet.find("HT") != std::string::npos && _coder.HTvalid(row->ieta, row->iphi, tp_version)) {
1038  if (_xml.count(row->crate) == 0 && split_by_crate) {
1039  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
1040  } else if (_xml.count(0) == 0 && !split_by_crate) {
1041  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
1042  }
1043  _cfg.ieta = row->ieta;
1044  _cfg.iphi = row->iphi;
1045  _cfg.depth = row->idepth;
1046  _cfg.crate = row->crate;
1047  _cfg.slot = row->slot;
1048  if (row->topbottom.find('t') != std::string::npos)
1049  _cfg.topbottom = 1;
1050  else if (row->topbottom.find('b') != std::string::npos)
1051  _cfg.topbottom = 0;
1052  else if (row->topbottom.find('u') != std::string::npos)
1053  _cfg.topbottom = 2;
1054  else
1055  edm::LogWarning("HcalLutManager") << "fpga out of range...";
1056  _cfg.fiber = row->fiber;
1057  _cfg.fiberchan = row->fiberchan;
1058  _cfg.lut_type = 2;
1059  _cfg.creationtag = _tag;
1060  _cfg.creationstamp = get_time_stamp(time(nullptr));
1061  _cfg.targetfirmware = "1.0.0";
1062  _cfg.formatrevision = "1"; //???
1063  // "original" definition of GENERALIZEDINDEX from Mike Weinberger
1064  // int generalizedIndex=id.ietaAbs()+10000*id.iphi()+
1065  // ((id.ieta()<0)?(0):(100));
1066  _cfg.generalizedindex = _cfg.iphi * 10000 + (row->ieta > 0) * 100 + abs(row->ieta);
1067 
1068  // FIXME: work around bug in emap v6: rawId wasn't filled
1069  //HcalTrigTowerDetId _detid(row->rawId);
1070  HcalTrigTowerDetId _detid(row->ieta, row->iphi);
1071 
1072  _cfg.lut = _coder.getCompressionLUT(_detid);
1073 
1074  if (split_by_crate) {
1075  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
1076  _counter.count();
1077  } else {
1078  _xml[0]->addLut(_cfg, lut_checksums_xml);
1079  _counter.count();
1080  }
1081  }
1082  }
1083  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
1084  << "Generating compression (output) LUTs from CaloTPGTranscoderULUT...DONE"
1085  << std::endl;
1086  return _xml;
1087 }
1088 
1089 int HcalLutManager::writeLutXmlFiles(std::map<int, std::shared_ptr<LutXml>>& _xml,
1090  std::string _tag,
1091  bool split_by_crate) {
1092  for (std::map<int, std::shared_ptr<LutXml>>::const_iterator cr = _xml.begin(); cr != _xml.end(); cr++) {
1093  std::stringstream output_file_name;
1094  if (split_by_crate) {
1095  output_file_name << _tag << "_" << cr->first << ".xml";
1096  } else {
1097  output_file_name << _tag << ".xml";
1098  }
1099  cr->second->write(output_file_name.str());
1100  }
1101  return 0;
1102 }
1103 
1104 int HcalLutManager::createLinLutXmlFiles(std::string _tag, std::string _lin_file, bool split_by_crate) {
1105  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1106  std::map<int, std::shared_ptr<LutXml>> xml;
1107  if (!lut_checksums_xml) {
1108  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1109  }
1110 
1111  if (!_lin_file.empty()) {
1112  addLutMap(xml, getLinearizationLutXmlFromAsciiMasterEmap(_lin_file, _tag, -1, split_by_crate));
1113  }
1114  writeLutXmlFiles(xml, _tag, split_by_crate);
1115 
1116  std::string checksums_file = _tag + "_checksums.xml";
1117  lut_checksums_xml->write(checksums_file);
1118 
1119  return 0;
1120 }
1121 
1123  std::string _lin_file,
1124  std::string _comp_file,
1125  bool split_by_crate) {
1126  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1127  std::map<int, std::shared_ptr<LutXml>> xml;
1128  if (!lut_checksums_xml) {
1129  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1130  }
1131 
1132  if (!_lin_file.empty()) {
1133  //addLutMap( xml, getLutXmlFromAsciiMaster( _lin_file, _tag, -1, split_by_crate ) );
1134  addLutMap(xml, getLinearizationLutXmlFromAsciiMasterEmap(_lin_file, _tag, -1, split_by_crate));
1135  }
1136  if (!_comp_file.empty()) {
1137  //std::cout << "DEBUG1!!!!" << std::endl;
1138  addLutMap(xml, getCompressionLutXmlFromAsciiMaster(_comp_file, _tag, -1, split_by_crate));
1139  //std::cout << "DEBUG2!!!!" << std::endl;
1140  }
1141  writeLutXmlFiles(xml, _tag, split_by_crate);
1142 
1143  std::string checksums_file = _tag + "_checksums.xml";
1144  lut_checksums_xml->write(checksums_file);
1145 
1146  return 0;
1147 }
1148 
1150  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1151  std::map<int, std::shared_ptr<LutXml>> xml;
1152  if (!lut_checksums_xml) {
1153  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1154  }
1155 
1156  addLutMap(xml, getCompressionLutXmlFromCoder(_tag, split_by_crate));
1157 
1158  writeLutXmlFiles(xml, _tag, split_by_crate);
1159 
1160  std::string checksums_file = _tag + "_checksums.xml";
1161  lut_checksums_xml->write(checksums_file);
1162 
1163  return 0;
1164 }
1165 
1166 int HcalLutManager::createAllLutXmlFilesFromCoder(const HcalTPGCoder& _coder, std::string _tag, bool split_by_crate) {
1167  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1168  std::map<int, std::shared_ptr<LutXml>> xml;
1169  if (!lut_checksums_xml) {
1170  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1171  }
1172 
1173  //addLutMap( xml, getLinearizationLutXmlFromCoder( _coder, _tag, split_by_crate ) );
1174  addLutMap(xml, getLinearizationLutXmlFromCoderEmap(_coder, _tag, split_by_crate));
1175  addLutMap(xml, getCompressionLutXmlFromCoder(_tag, split_by_crate));
1176 
1177  writeLutXmlFiles(xml, _tag, split_by_crate);
1178 
1179  std::string checksums_file = _tag + "_checksums.xml";
1180  lut_checksums_xml->write(checksums_file);
1181 
1182  return 0;
1183 }
1184 
1185 //
1186 //_____ use this for creating a full set of LUTs ________________________
1187 //
1189  const HcalTPGCoder& _coder,
1190  const CaloTPGTranscoderULUT& _transcoder,
1191  std::string _lin_file,
1192  bool split_by_crate) {
1193  std::map<int, std::shared_ptr<LutXml>> xml;
1194  if (!lut_checksums_xml) {
1195  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1196  }
1197 
1198  if (!_lin_file.empty()) {
1199  const std::map<int, std::shared_ptr<LutXml>> _lin_lut_ascii_xml =
1200  getLinearizationLutXmlFromAsciiMasterEmap(_lin_file, _tag, -1, split_by_crate);
1201  addLutMap(xml, _lin_lut_ascii_xml);
1202  }
1203  const std::map<int, std::shared_ptr<LutXml>> _lin_lut_xml =
1204  getLinearizationLutXmlFromCoderEmap(_coder, _tag, split_by_crate);
1205  addLutMap(xml, _lin_lut_xml);
1206  //
1207  const std::map<int, std::shared_ptr<LutXml>> _comp_lut_xml =
1208  getCompressionLutXmlFromCoder(_transcoder, _tag, split_by_crate);
1209  addLutMap(xml, _comp_lut_xml);
1210 
1211  const std::map<int, std::shared_ptr<LutXml>> _HE_FG_lut_xml = getHEFineGrainLUTs(_tag, split_by_crate);
1212  addLutMap(xml, _HE_FG_lut_xml);
1213 
1214  writeLutXmlFiles(xml, _tag, split_by_crate);
1215 
1216  std::string checksums_file = _tag + "_checksums.xml";
1217  lut_checksums_xml->write(checksums_file);
1218 
1219  return 0;
1220 }
1221 
1223  const HcalTPGCoder& _coder,
1224  std::string _lin_file,
1225  bool split_by_crate) {
1226  std::map<int, std::shared_ptr<LutXml>> xml;
1227  if (!lut_checksums_xml) {
1228  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1229  }
1230 
1231  if (!_lin_file.empty()) {
1232  const std::map<int, std::shared_ptr<LutXml>> _lin_lut_ascii_xml =
1233  getLinearizationLutXmlFromAsciiMasterEmap(_lin_file, _tag, -1, split_by_crate);
1234  addLutMap(xml, _lin_lut_ascii_xml);
1235  }
1236  const std::map<int, std::shared_ptr<LutXml>> _lin_lut_xml =
1237  getLinearizationLutXmlFromCoderEmap(_coder, _tag, split_by_crate);
1238  addLutMap(xml, _lin_lut_xml);
1239  //
1240  const std::map<int, std::shared_ptr<LutXml>> _comp_lut_xml = getCompressionLutXmlFromCoder(_tag, split_by_crate);
1241  addLutMap(xml, _comp_lut_xml);
1242 
1243  writeLutXmlFiles(xml, _tag, split_by_crate);
1244 
1245  std::string checksums_file = _tag + "_checksums.xml";
1246  lut_checksums_xml->write(checksums_file);
1247 
1248  return 0;
1249 }
1250 
1251 // use this to create HBEF only from coders (physics LUTs)
1253  std::string _lin_file,
1254  bool split_by_crate) {
1255  //std::cout << "DEBUG1: split_by_crate = " << split_by_crate << std::endl;
1256  std::map<int, std::shared_ptr<LutXml>> xml;
1257  if (!lut_checksums_xml) {
1258  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1259  }
1260 
1261  if (!_lin_file.empty()) {
1262  addLutMap(xml, getLutXmlFromAsciiMaster(_lin_file, _tag, -1, split_by_crate));
1263  }
1264  addLutMap(xml, getCompressionLutXmlFromCoder(_tag, split_by_crate));
1265  writeLutXmlFiles(xml, _tag, split_by_crate);
1266 
1267  std::string checksums_file = _tag + "_checksums.xml";
1268  lut_checksums_xml->write(checksums_file);
1269 
1270  return 0;
1271 }
1272 
1273 void HcalLutManager::addLutMap(std::map<int, std::shared_ptr<LutXml>>& result,
1274  const std::map<int, std::shared_ptr<LutXml>>& other) {
1275  for (std::map<int, std::shared_ptr<LutXml>>::const_iterator lut = other.begin(); lut != other.end(); lut++) {
1276  edm::LogInfo("HcalLutManager") << "Added LUTs for crate " << lut->first;
1277  if (result.count(lut->first) == 0) {
1278  result.insert(*lut);
1279  } else {
1280  *(result[lut->first]) += *(lut->second);
1281  }
1282  }
1283 }
1284 
1285 string HcalLutManager::get_time_stamp(time_t _time) {
1286  char timebuf[50];
1287  //strftime( timebuf, 50, "%c", gmtime( &_time ) );
1288  strftime(timebuf, 50, "%Y-%m-%d %H:%M:%S", gmtime(&_time));
1289  std::string creationstamp = timebuf;
1290 
1291  return creationstamp;
1292 }
1293 
1295  local_connect(_filename, "backup/HCALmapHBEF.txt", "backup/HCALmapHO.txt");
1296 
1297  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
1298  EMap _emap(emap);
1299  std::vector<EMap::EMapRow>& _map = _emap.get_map();
1300  int map_size = _map.size();
1301  edm::LogInfo("HcalLutManager") << "EMap contains " << map_size << " channels";
1302 
1303  // make sure that all init is done
1304  std::vector<unsigned int> _lut;
1305  _lut = getLutFromXml(_tag, 1107313727, hcal::ConfigurationDatabase::LinearizerLUT);
1306 
1307  edm::LogInfo("HcalLutManager") << "Testing direct parsing of the LUT XML";
1308  struct timeval _t;
1309  gettimeofday(&_t, nullptr);
1310  double _time = (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0;
1311  test_direct_xml_parsing(_filename);
1312  gettimeofday(&_t, nullptr);
1313  edm::LogInfo("HcalLutManager") << "parsing took that much time: "
1314  << (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0 - _time;
1315 
1316  gettimeofday(&_t, nullptr);
1317  _time = (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0;
1318  edm::LogInfo("HcalLutManager") << "before loop over random LUTs: " << _time;
1319  int _raw_id;
1320 
1321  // loop over random LUTs
1322  for (int _iter = 0; _iter < 100; _iter++) {
1323  gettimeofday(&_t, nullptr);
1324  //std::cout << "before getting a LUT: " << _t . tv_sec << "." << _t . tv_usec << std::endl;
1325 
1326  // select valid random emap channel
1327  while (true) {
1328  int _key = (rand() % map_size);
1329  //_key = 3356;
1330  if ((_map[_key].subdet.find("HB") != string::npos || _map[_key].subdet.find("HE") != string::npos ||
1331  _map[_key].subdet.find("HO") != string::npos || _map[_key].subdet.find("HF") != string::npos) &&
1332  _map[_key].subdet.size() == 2) {
1333  HcalSubdetector _subdet;
1334  if (_map[_key].subdet.find("HB") != string::npos)
1335  _subdet = HcalBarrel;
1336  else if (_map[_key].subdet.find("HE") != string::npos)
1337  _subdet = HcalEndcap;
1338  else if (_map[_key].subdet.find("HO") != string::npos)
1339  _subdet = HcalOuter;
1340  else if (_map[_key].subdet.find("HF") != string::npos)
1341  _subdet = HcalForward;
1342  else
1343  _subdet = HcalOther;
1344  HcalDetId _detid(_subdet, _map[_key].ieta, _map[_key].iphi, _map[_key].idepth);
1345  _raw_id = _detid.rawId();
1346  break;
1347  }
1348  }
1349  _lut = getLutFromXml(_tag, _raw_id, hcal::ConfigurationDatabase::LinearizerLUT);
1350 
1351  gettimeofday(&_t, nullptr);
1352  }
1353  double d_time = _t.tv_sec + _t.tv_usec / 1000000.0 - _time;
1354  edm::LogInfo("HcalLutManager") << "after the loop over random LUTs: " << _time + d_time << std::endl
1355  << "total time: " << d_time << std::endl;
1356 
1357  edm::LogInfo("HcalLutManager") << "LUT length = " << _lut.size();
1358  for (std::vector<unsigned int>::const_iterator i = _lut.end() - 1; i != _lut.begin() - 1; i--) {
1359  edm::LogInfo("HcalLutManager") << (i - _lut.begin()) << " " << _lut[(i - _lut.begin())];
1360  break;
1361  }
1362 
1363  db->disconnect();
1364 
1365  delete db;
1366  db = nullptr;
1367 
1368  return 0;
1369 }
1370 
1371 int HcalLutManager::read_lmap(std::string lmap_hbef_file, std::string lmap_ho_file) {
1372  delete lmap;
1373  lmap = new LMap();
1374  lmap->read(lmap_hbef_file, "HBEF");
1375  lmap->read(lmap_ho_file, "HO");
1376  edm::LogInfo("HcalLutManager") << "LMap contains " << lmap->get_map().size()
1377  << " channels (compare to 9072 of all HCAL channels)";
1378  return 0;
1379 }
1380 
1382  delete db;
1383  db = new HCALConfigDB();
1384  db->connect(lut_xml_file);
1385  return 0;
1386 }
1387 
1388 int HcalLutManager::local_connect(std::string lut_xml_file, std::string lmap_hbef_file, std::string lmap_ho_file) {
1389  read_lmap(lmap_hbef_file, lmap_ho_file);
1390  read_luts(lut_xml_file);
1391  return 0;
1392 }
1393 
1395  uint32_t _rawid,
1396  hcal::ConfigurationDatabase::LUTType _lt) {
1397  edm::LogInfo("HcalLutManager") << "getLutFromXml (new version) is not implemented. Use getLutFromXml_old() for now";
1398 
1399  std::vector<unsigned int> result;
1400 
1401  return result;
1402 }
1403 
1404 // obsolete, use getLutFromXml() instead
1406  uint32_t _rawid,
1407  hcal::ConfigurationDatabase::LUTType _lt) {
1408  if (!lmap) {
1409  edm::LogError("HcalLutManager") << "Cannot find LUT without LMAP, exiting...";
1410  exit(-1);
1411  }
1412  if (!db) {
1413  edm::LogError("HcalLutManager") << "Cannot find LUT, no source (local XML file), exiting...";
1414  exit(-1);
1415  }
1416 
1417  std::vector<unsigned int> result;
1418 
1419  std::map<int, LMapRow>& _map = lmap->get_map();
1420  //std::cout << "HcalLutManager: LMap contains " << _map . size() << " channels (out of 9072 total)" << std::endl;
1421 
1422  HcalDetId _id(_rawid);
1423 
1424  unsigned int _crate, _slot, _fiber, _channel;
1425  std::string _fpga;
1426  int topbottom, luttype;
1427 
1428  // FIXME: check validity of _rawid
1429  if (_map.find(_rawid) != _map.end()) {
1430  _crate = _map[_rawid].crate;
1431  _slot = _map[_rawid].htr;
1432  _fiber = _map[_rawid].htr_fi;
1433  _channel = _map[_rawid].fi_ch;
1434  _fpga = _map[_rawid].fpga;
1435 
1436  if (_fpga.find("top") != std::string::npos)
1437  topbottom = 1;
1438  else if (_fpga.find("bot") != std::string::npos)
1439  topbottom = 0;
1440  else {
1441  edm::LogError("HcalLutManager") << "Irregular LMAP fpga value... do not know what to do - exiting";
1442  exit(-1);
1443  }
1444  if (_lt == hcal::ConfigurationDatabase::LinearizerLUT)
1445  luttype = 1;
1446  else
1447  luttype = 2;
1448 
1449  result = db->getOnlineLUT(tag, _crate, _slot, topbottom, _fiber, _channel, luttype);
1450  }
1451 
1452  return result;
1453 }
1454 
1455 int HcalLutManager::get_xml_files_from_db(std::string tag, const std::string db_accessor, bool split_by_crate) {
1456  std::map<int, std::shared_ptr<LutXml>> lut_map = get_brickSet_from_oracle(tag, db_accessor);
1457  if (split_by_crate) {
1458  writeLutXmlFiles(lut_map, tag, split_by_crate);
1459  } else {
1460  LutXml result;
1461  for (std::map<int, std::shared_ptr<LutXml>>::const_iterator xml = lut_map.begin(); xml != lut_map.end(); xml++) {
1462  result += *(xml->second);
1463  }
1464  std::stringstream out_file;
1465  out_file << tag << ".xml";
1466  result.write(out_file.str());
1467  }
1468 
1469  return 0;
1470 }
1471 
1472 std::map<int, std::shared_ptr<LutXml>> HcalLutManager::get_brickSet_from_oracle(std::string tag,
1473  const std::string _accessor) {
1474  HCALConfigDB* db = new HCALConfigDB();
1475  XMLProcessor::getInstance(); // initialize xerces-c engine
1476  //const std::string _accessor = "occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22";
1477  db->connect(_accessor);
1478  oracle::occi::Connection* _connection = db->getConnection();
1479 
1480  edm::LogInfo("HcalLutManager") << "Preparing to request the LUT CLOBs from the database...";
1481 
1482  //int crate = 0;
1483 
1484  //
1485  // _____ query is different for the old validation DB _________________
1486  //
1487  //std::string query = ("SELECT TRIG_PRIM_LOOKUPTBL_DATA_CLOB, CRATE FROM CMS_HCL_HCAL_CONDITION_OWNER.V_HCAL_TRIG_LOOKUP_TABLES");
1488  std::string query = ("SELECT TRIG_PRIM_LOOKUPTBL_DATA_CLOB, CRATE FROM CMS_HCL_HCAL_COND.V_HCAL_TRIG_LOOKUP_TABLES");
1489  //query+=toolbox::toString(" WHERE TAG_NAME='%s' AND CRATE=%d", tag.c_str(), crate);
1490  query += toolbox::toString(" WHERE TAG_NAME='%s'", tag.c_str());
1491 
1492  std::string brick_set;
1493 
1494  std::map<int, std::shared_ptr<LutXml>> lut_map;
1495 
1496  try {
1497  //SELECT
1498  edm::LogInfo("HcalLutManager") << "Executing the query...";
1499  Statement* stmt = _connection->createStatement();
1500  ResultSet* rs = stmt->executeQuery(query);
1501  edm::LogInfo("HcalLutManager") << "Executing the query... done";
1502 
1503  edm::LogInfo("HcalLutManager") << "Processing the query results...";
1504  //RooGKCounter _lines;
1505  while (rs->next()) {
1506  //_lines.count();
1507  oracle::occi::Clob clob = rs->getClob(1);
1508  int crate = rs->getInt(2);
1509  if (crate != -1) { // not a brick with checksums
1510  edm::LogInfo("HcalLutManager") << "Getting LUTs for crate #" << crate << " out of the database...";
1511  brick_set = db->clobToString(clob);
1512  /*
1513  // FIXME: DEBUG lut xml files from simple strings
1514  stringstream file_name;
1515  ofstream out_file;
1516  file_name << tag << "_" << crate << "_debug" << ".xml";
1517  out_file . open( file_name.str().c_str() );
1518  out_file << brick_set;
1519  out_file . close();
1520  */
1521  const char* bs = brick_set.c_str();
1522  MemBufInputSource* lut_clob = new MemBufInputSource((const XMLByte*)bs, strlen(bs), "lut_clob", false);
1523  std::shared_ptr<LutXml> lut_xml = std::make_shared<LutXml>(*lut_clob);
1524  lut_map[crate] = lut_xml;
1525  edm::LogInfo("HcalLutManager") << "done";
1526  }
1527  }
1528  //Always terminate statement
1529  _connection->terminateStatement(stmt);
1530  //std::cout << "Query line count: " << _lines.getCount() << std::endl;
1531  } catch (SQLException& e) {
1532  XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
1533  ::toolbox::toString("Oracle exception : %s", e.getMessage().c_str()));
1534  }
1535 
1536  //std::cout << lut_map.size() << std::endl;
1537 
1538  db->disconnect();
1539  //delete db;
1540  return lut_map;
1541 }
1542 
1544  std::string _prefix,
1545  std::string tag_name,
1546  std::string comment,
1548  int subversion) {
1549  edm::LogInfo("HcalLutManager") << "Generating XML loader for LUTs...";
1550  //std::cout << _prefix << "..." << tag_name << std::endl;
1551 
1555 
1556  baseConf.tag_name = tag_name;
1557  //baseConf . comment_description = tag_name;
1558  baseConf.comment_description = comment;
1559  baseConf.iov_begin = "1";
1560  baseConf.iov_end = "-1";
1561 
1562  conf.version = version;
1563 
1564  std::stringstream _subversion;
1565  _subversion << subversion;
1566  conf.subversion = _subversion.str();
1567 
1568  CSconf.version = conf.version;
1569  CSconf.subversion = conf.subversion;
1570  CSconf.trig_prim_lookuptbl_data_file = _prefix + "_checksums.xml.dat";
1571  CSconf.comment_description = tag_name;
1572 
1573  XMLLUTLoader doc(&baseConf);
1574 
1575  std::vector<int> crate_number;
1576  std::vector<std::string> file_name = HcalQIEManager::splitString(file_list);
1577  for (std::vector<std::string>::const_iterator _f = file_name.begin(); _f != file_name.end(); _f++) {
1578  int crate_begin = _f->rfind("_");
1579  int crate_end = _f->rfind(".xml.dat");
1580  crate_number.push_back(getInt(_f->substr(crate_begin + 1, crate_end - crate_begin - 1)));
1581  }
1582  //
1583  //_____ fix due to the new convention: version/subversion combo must be unique for every payload
1584  //
1585  char _buf[128];
1586  time_t _offset = time(nullptr);
1587  sprintf(_buf, "%d", (uint32_t)_offset);
1588  conf.version.append(".");
1589  conf.version.append(_buf);
1590  CSconf.version = conf.version;
1591  //
1592  for (std::vector<std::string>::const_iterator _file = file_name.begin(); _file != file_name.end(); _file++) {
1593  conf.trig_prim_lookuptbl_data_file = *_file;
1594  //conf . trig_prim_lookuptbl_data_file += ".dat";
1595  conf.crate = crate_number[_file - file_name.begin()];
1596  //
1597  //_____ fix due to the new convention: version/subversion combo must be unique for every payload
1598  //
1599  sprintf(_buf, "%.2d", conf.crate);
1600  conf.subversion.clear();
1601  conf.subversion.append(_buf);
1602  sprintf(_buf, "CRATE%.2d", conf.crate);
1603  std::string _namelabel;
1604  _namelabel.append(_buf);
1605  conf.name_label = _namelabel;
1606  doc.addLUT(&conf);
1607  }
1608 
1609  doc.addChecksums(&CSconf);
1610  //doc . write( _prefix + "_Loader.xml" );
1611  doc.write(tag_name + "_Loader.xml");
1612 
1613  edm::LogInfo("HcalLutManager") << "Generating XML loader for LUTs... done.";
1614 
1615  return 0;
1616 }
1617 
1619  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v5_080208.txt");
1620  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.03_080817.txt");
1621  //EMap _emap("../../../CondFormats/HcalObjects/data/official_emap_v6.04_080905.txt");
1622  EMap _emap(emap);
1623  std::vector<EMap::EMapRow>& _map = _emap.get_map();
1624  std::stringstream s;
1625  s << "EMap contains " << _map.size() << " channels" << std::endl;
1626 
1627  //loop over all EMap channels
1628  //RooGKCounter _c;
1629  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
1630  // only trigger tower channels
1631  if (row->subdet.find("HT") != std::string::npos) {
1632  s << " -----> Subdet = " << row->subdet << std::endl;
1633 
1634  if (abs(row->ieta) > 28) {
1635  //if (row->iphi == 71){
1636  s << " ==> (ieta,iphi) = " << row->ieta << ", " << row->iphi << std::endl;
1637  }
1638  }
1639  }
1640  edm::LogInfo("HcalLutManager") << s.str();
1641 }
1642 
1644  /*
1645  XMLDOMBlock _xml(_filename);
1646  //DOMElement * data_set_elem = (DOMElement *)(document -> getElementsByTagName( XMLProcessor::_toXMLCh( "DATA_SET" ) ) -> item(0));
1647  DOMNodeList * brick_list = _xml . getDocument() -> getElementsByTagName( XMLProcessor::_toXMLCh( "CFGBrick" ));
1648 
1649  double n_bricks = brick_list->getLength();
1650  std::cout << "amount of LUT bricks: " << n_bricks << std::endl;
1651 
1652  for (int iter=0; iter!=n_bricks; iter++){
1653  DOMElement * _brick = (DOMElement *)(brick_list->item(iter));
1654 
1655  DOMElement * _param = 0;
1656  // loop over brick parameters
1657  int par_iter = 0;
1658  while(1){
1659  _param = (DOMElement *)(_brick->getElementsByTagName(XMLProcessor::_toXMLCh("Parameter")));
1660  std::string _name = _param->getAttribute( XMLProcessor::_toXMLCh( "name" ) );
1661  if (_name.find("IETA")==string::npos) break;
1662 
1663  std::string _tag = "Parameter";
1664  std::cout << "### Parameter IETA = " << _xml.getTagValue( _tag, 0, _brick);
1665  par_iter++;
1666  }
1667  }
1668  */
1669  return 0;
1670 }
1671 
1672 //
1673 //_____ attempt to include ZDC LUTs _____________________________________
1674 //
1676  const HcalTPGCoder& _coder,
1677  const CaloTPGTranscoderULUT& _transcoder,
1678  std::string _lin_file,
1679  bool split_by_crate) {
1680  std::map<int, std::shared_ptr<LutXml>> xml;
1681  if (!lut_checksums_xml) {
1682  lut_checksums_xml = new XMLDOMBlock("CFGBrick", 1);
1683  }
1684 
1685  if (!_lin_file.empty()) {
1686  const std::map<int, std::shared_ptr<LutXml>> _lin_lut_ascii_xml =
1687  getLinearizationLutXmlFromAsciiMasterEmap(_lin_file, _tag, -1, split_by_crate);
1688  addLutMap(xml, _lin_lut_ascii_xml);
1689  }
1690  const std::map<int, std::shared_ptr<LutXml>> _lin_lut_xml =
1691  getLinearizationLutXmlFromCoderEmap(_coder, _tag, split_by_crate);
1692  addLutMap(xml, _lin_lut_xml);
1693  //
1694  const std::map<int, std::shared_ptr<LutXml>> _comp_lut_xml =
1695  getCompressionLutXmlFromCoder(_transcoder, _tag, split_by_crate);
1696  addLutMap(xml, _comp_lut_xml);
1697 
1698  const std::map<int, std::shared_ptr<LutXml>> _HE_FG_lut_xml = getHEFineGrainLUTs(_tag, split_by_crate);
1699  addLutMap(xml, _HE_FG_lut_xml);
1700 
1701  for (auto masktype : {0, 1, 2}) {
1702  const auto masks = getMasks(masktype, _tag, split_by_crate);
1703  addLutMap(xml, masks);
1704  }
1705  //
1706  const std::map<int, std::shared_ptr<LutXml>> _zdc_lut_xml = getZdcLutXml(_tag, split_by_crate);
1707  addLutMap(xml, _zdc_lut_xml);
1708 
1709  writeLutXmlFiles(xml, _tag, split_by_crate);
1710 
1711  std::string checksums_file = _tag + "_checksums.xml";
1712  lut_checksums_xml->write(checksums_file);
1713 
1714  return 0;
1715 }
1716 
1717 std::map<int, std::shared_ptr<LutXml>> HcalLutManager::getZdcLutXml(std::string _tag, bool split_by_crate) {
1718  edm::LogInfo("HcalLutManager") << "Generating ZDC LUTs ...may the Force be with us...";
1719  std::map<int, std::shared_ptr<LutXml>> _xml; // index - crate number
1720 
1721  EMap _emap(emap);
1722 
1723  ZdcLut zdc;
1724 
1725  std::vector<EMap::EMapRow>& _map = _emap.get_map();
1726  edm::LogInfo("HcalLutManager") << "EMap contains " << _map.size() << " channels";
1727 
1728  //loop over all EMap channels
1729  RooGKCounter _counter;
1730  for (std::vector<EMap::EMapRow>::const_iterator row = _map.begin(); row != _map.end(); row++) {
1731  LutXml::Config _cfg;
1732 
1733  // only ZDC channels
1734  if (row->zdc_section.find("ZDC") != std::string::npos) {
1735  if (_xml.count(row->crate) == 0 && split_by_crate) {
1736  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(row->crate, std::make_shared<LutXml>()));
1737  } else if (_xml.count(0) == 0 && !split_by_crate) {
1738  _xml.insert(std::pair<int, std::shared_ptr<LutXml>>(0, std::make_shared<LutXml>()));
1739  }
1740  // FIXME: introduce proper tag names in ZDC bricks for logical channel info
1741  _cfg.ieta = row->zdc_channel; // int
1742  //_cfg.ieta = row->zdc_zside; // int
1743  //_cfg.iphi = row->zdc_section; // string
1744  _cfg.depth = row->idepth; // int
1745  _cfg.crate = row->crate;
1746  _cfg.slot = row->slot;
1747  if (row->topbottom.find('t') != std::string::npos)
1748  _cfg.topbottom = 1;
1749  else if (row->topbottom.find('b') != std::string::npos)
1750  _cfg.topbottom = 0;
1751  else
1752  edm::LogWarning("HcalLutManager") << "fpga out of range...";
1753  _cfg.fiber = row->fiber;
1754  _cfg.fiberchan = row->fiberchan;
1755  _cfg.lut_type = 1;
1756  _cfg.creationtag = _tag;
1757  _cfg.creationstamp = get_time_stamp(time(nullptr));
1758  _cfg.targetfirmware = "1.0.0";
1759  _cfg.formatrevision = "1"; //???
1760  _cfg.generalizedindex = 0;
1761 
1762  //HcalZDCDetId _detid(row->zdc_section, (row->zdc_zside>0), row->zdc_channel);
1763 
1764  std::vector<int> coder_lut = zdc.get_lut(row->zdc_section, row->zdc_zside, row->zdc_channel);
1765  edm::LogInfo("HcalLutManager") << "***DEBUG: ZDC lut size: " << coder_lut.size();
1766  if (!coder_lut.empty()) {
1767  for (std::vector<int>::const_iterator _i = coder_lut.begin(); _i != coder_lut.end(); _i++) {
1768  unsigned int _temp = (unsigned int)(*_i);
1769  //if (_temp!=0) std::cout << "DEBUG non-zero LUT!!!!!!!!!!!!!!!" << (*_i) << " " << _temp << std::endl;
1770  //unsigned int _temp = 0;
1771  _cfg.lut.push_back(_temp);
1772  }
1773  //_cfg.lut = _set.lut[lut_index];
1774 
1775  if (split_by_crate) {
1776  _xml[row->crate]->addLut(_cfg, lut_checksums_xml);
1777  _counter.count();
1778  } else {
1779  _xml[0]->addLut(_cfg, lut_checksums_xml);
1780  _counter.count();
1781  }
1782  } //size of lut
1783  }
1784  }
1785  edm::LogInfo("HcalLutManager") << "LUTs generated: " << _counter.getCount() << std::endl
1786  << "Generating ZDC LUTs...DONE" << std::endl;
1787 
1788  return _xml;
1789 }
HcalOther
Definition: HcalAssistant.h:38
HcalLutManager::local_connect
int local_connect(std::string lut_xml_file, std::string lmap_hbef_file, std::string lmap_ho_file)
Definition: HcalLutManager.cc:1388
HcalLutManager::createAllLutXmlFilesFromCoder
int createAllLutXmlFilesFromCoder(const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
Definition: HcalLutManager.cc:1166
LutXml::_Config::creationtag
std::string creationtag
Definition: LutXml.h:33
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
init
int init
Definition: HydjetWrapper.h:64
common_cff.doc
doc
Definition: common_cff.py:54
HcalLutManager::createLutXmlFiles_HBEFFromCoder_HOFromAscii_ZDC
int createLutXmlFiles_HBEFFromCoder_HOFromAscii_ZDC(std::string _tag, const HcalTPGCoder &_coder, const CaloTPGTranscoderULUT &_transcoder, std::string _lin_file, bool split_by_crate=true)
Definition: HcalLutManager.cc:1675
mps_fire.i
i
Definition: mps_fire.py:428
XMLProcessor::getInstance
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:134
MessageLogger.h
HcalLutManager::test_direct_xml_parsing
int test_direct_xml_parsing(std::string _filename)
Definition: HcalLutManager.cc:1643
HcalLutManager::createLinLutXmlFiles
int createLinLutXmlFiles(std::string _tag, std::string _lin_file, bool split_by_crate=true)
Definition: HcalLutManager.cc:1104
XMLLUTLoader::_lutDBConfig::name_label
std::string name_label
Definition: XMLLUTLoader.h:37
LMap.h
HcalElectronicsId::readoutVMECrateId
constexpr int readoutVMECrateId() const
get the readout VME crate number
Definition: HcalElectronicsId.h:105
LMap
Definition: LMap.h:66
HcalLutManager::getLinearizationLutXmlFromCoderEmap
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromCoderEmap(const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
Definition: HcalLutManager.cc:757
hcal
Definition: ConfigurationDatabase.cc:13
gpuClustering::adc
uint16_t *__restrict__ uint16_t const *__restrict__ adc
Definition: gpuClusterChargeCut.h:20
XMLProcessor::_loaderBaseConfig::iov_begin
std::string iov_begin
Definition: XMLProcessor.h:49
CaloTPGTranscoderULUT::getCompressionLUT
virtual const std::vector< unsigned int > getCompressionLUT(const HcalTrigTowerDetId &id) const
Definition: CaloTPGTranscoderULUT.cc:282
LutXml::_Config::mask
std::vector< uint64_t > mask
Definition: LutXml.h:40
HcalTopology
Definition: HcalTopology.h:26
LutXml::_Config::topbottom
int topbottom
Definition: LutXml.h:32
getInt
int getInt(ResultSet *rset, int ipar)
Definition: ODFEDAQConfig.cc:26
HcalTPGCoder::getLinearizationLUT
virtual std::vector< unsigned short > getLinearizationLUT(HcalDetId id) const
Get the full linearization LUT (128 elements). Default implementation just uses adc2Linear to get all...
Definition: HcalTPGCoder.cc:3
if
if(0==first)
Definition: CAHitNtupletGeneratorKernelsImpl.h:48
LutXml::_Config::slot
int slot
Definition: LutXml.h:32
HcalLutManager::getCompressionLutXmlFromAsciiMaster
std::map< int, std::shared_ptr< LutXml > > getCompressionLutXmlFromAsciiMaster(std::string _filename, std::string _tag, int _crate=-1, bool split_by_crate=true)
Definition: HcalLutManager.cc:515
HcalLutManager::createAllLutXmlFiles
int createAllLutXmlFiles(std::string _tag, std::string _lin_file, std::string _comp_file, bool split_by_crate=true)
Definition: HcalLutManager.cc:1122
protons_cff.time
time
Definition: protons_cff.py:39
HcalLutSet::eta_min
std::vector< int > eta_min
Definition: HcalLutManager.h:35
HcalLutManager::getMasks
std::map< int, std::shared_ptr< LutXml > > getMasks(int var, std::string _tag, bool split_by_crate=true)
Definition: HcalLutManager.cc:683
XERCES_CPP_NAMESPACE_USE
Definition: XMLConfigWriter.cc:40
HcalChannelQuality
Definition: HcalChannelQuality.h:17
HcalLutManager::createCompLutXmlFilesFromCoder
int createCompLutXmlFilesFromCoder(std::string _tag, bool split_by_crate=true)
Definition: HcalLutManager.cc:1149
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
HcalBarrel
Definition: HcalAssistant.h:33
XMLProcessor::_loaderBaseConfig::comment_description
std::string comment_description
Definition: XMLProcessor.h:55
XMLProcessor::_loaderBaseConfig::tag_name
std::string tag_name
Definition: XMLProcessor.h:53
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
HcalLutManager::create_lut_loader
int create_lut_loader(std::string file_list, std::string _prefix, std::string tag_name, std::string comment="default comment", std::string version="V00-01-01", int subversion=1)
Definition: HcalLutManager.cc:1543
LutXml::_Config::targetfirmware
std::string targetfirmware
Definition: LutXml.h:36
contentValuesCheck.file_name
file_name
Definition: contentValuesCheck.py:38
XMLDOMBlock
Definition: XMLDOMBlock.h:39
HcalLutSet::eta_max
std::vector< int > eta_max
Definition: HcalLutManager.h:35
HcalTPGCoder
Definition: HcalTPGCoder.h:26
HcalFinegrainBit
Definition: HcalFinegrainBit.h:7
HcalLutManager::addLutMap
void addLutMap(std::map< int, std::shared_ptr< LutXml > > &result, const std::map< int, std::shared_ptr< LutXml > > &other)
Definition: HcalLutManager.cc:1273
LutXml::_Config::generalizedindex
int generalizedindex
Definition: LutXml.h:37
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
dqmiodatasetharvest.db
db
Definition: dqmiodatasetharvest.py:119
HcalLutSet::lut
std::vector< std::vector< unsigned int > > lut
Definition: HcalLutManager.h:36
HcalTopology::firstHEDoublePhiRing
int firstHEDoublePhiRing() const
Definition: HcalTopology.h:101
HcalLutManager::getLinearizationLutXmlFromAsciiMasterEmap
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap(std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)
Definition: HcalLutManager.cc:339
HcalLutSet::phi_max
std::vector< int > phi_max
Definition: HcalLutManager.h:35
DetId
Definition: DetId.h:17
LutXml::_Config::iphi
int iphi
Definition: LutXml.h:32
HcalLutSet::depth_min
std::vector< int > depth_min
Definition: HcalLutManager.h:35
LutXml::_Config::lut_type
int lut_type
Definition: LutXml.h:32
alignCSCRings.s
s
Definition: alignCSCRings.py:92
cms::cuda::bs
bs
Definition: HistoContainer.h:127
ZdcLut
Generation of ZDC Lookup tables and associate helper methods.
Definition: ZdcLut.h:30
toolbox::toString
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
CaloTPGTranscoderULUT::HTvalid
virtual bool HTvalid(const int ieta, const int iphi, const int version) const
Definition: CaloTPGTranscoderULUT.cc:198
query
Definition: query.py:1
oracle::occi
Definition: ConnectionManager.h:7
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
RooGKCounter.h
ZdcLut.h
HcalElectronicsId
Readout chain identification for Hcal.
Definition: HcalElectronicsId.h:32
HcalLutManager::get_time_stamp
static std::string get_time_stamp(time_t _time)
Definition: HcalLutManager.cc:1285
XMLProcessor::_DBConfig::subversion
std::string subversion
Definition: XMLProcessor.h:120
RooGKCounter
Definition: RooGKCounter.h:10
HcalOuter
Definition: HcalAssistant.h:35
LutXml::_Config::creationstamp
std::string creationstamp
Definition: LutXml.h:34
LutXml::_Config::weight
int weight
Definition: LutXml.h:38
trackingPlots.other
other
Definition: trackingPlots.py:1460
HcalLutManager_test::getLutSetFromFile_test
static int getLutSetFromFile_test(std::string _filename)
Definition: HcalLutManager.cc:133
dqmdumpme.k
k
Definition: dqmdumpme.py:60
HcalLutManager::writeLutXmlFiles
int writeLutXmlFiles(std::map< int, std::shared_ptr< LutXml > > &_xml, std::string _tag="default_tag", bool split_by_crate=true)
Definition: HcalLutManager.cc:1089
HcalQIEManager::splitString
static std::vector< std::string > splitString(const std::string &fLine)
Definition: HcalQIEManager.cc:96
LMap::read
int read(std::string accessor, std::string type="HBEF")
Definition: LMap.cc:47
xdaq_compat.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LutXml::_Config::ieta
int ieta
Definition: LutXml.h:32
HCALConfigDB
Gather config data from online DB.
Definition: HCALConfigDB.h:20
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
XMLLUTLoader::_checksumsDBConfig
Definition: XMLLUTLoader.h:42
HcalLutManager::get_xml_files_from_db
int get_xml_files_from_db(std::string tag, const std::string db_accessor="occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22", bool split_by_crate=true)
Definition: HcalLutManager.cc:1455
HcalLutManager::createLutXmlFiles_HBEFFromCoder_HOFromAscii
int createLutXmlFiles_HBEFFromCoder_HOFromAscii(std::string _tag, const HcalTPGCoder &_coder, std::string _lin_file, bool split_by_crate=true)
Definition: HcalLutManager.cc:1222
HcalLutManager::getLutFromXml_old
std::vector< unsigned int > getLutFromXml_old(std::string tag, uint32_t _rawid, hcal::ConfigurationDatabase::LUTType _lt)
Definition: HcalLutManager.cc:1405
LutXml::_Config::crate
int crate
Definition: LutXml.h:32
LutXml::_Config::lut
std::vector< unsigned int > lut
Definition: LutXml.h:39
HcalLutManager::test_xml_access
int test_xml_access(std::string _tag, std::string _filename)
Definition: HcalLutManager.cc:1294
HcalLutManager::read_luts
int read_luts(std::string lut_xml_file)
Definition: HcalLutManager.cc:1381
HcalQIEManager.h
HcalDetId.h
XMLLUTLoader::_lutDBConfig
Definition: XMLLUTLoader.h:34
LutXml::_Config::depth
int depth
Definition: LutXml.h:32
HcalLutManager::getLutXml
std::string & getLutXml(std::vector< unsigned int > &_lut)
Definition: HcalLutManager.cc:95
HcalLutManager::createAllLutXmlFilesLinAsciiCompCoder
int createAllLutXmlFilesLinAsciiCompCoder(std::string _tag, std::string _lin_file, bool split_by_crate=true)
Definition: HcalLutManager.cc:1252
XMLProcessor::_DBConfig::version
std::string version
Definition: XMLProcessor.h:119
EMap
Definition: LMap.h:80
LMap::get_map
std::map< int, LMapRow > & get_map(void)
Definition: LMap.cc:49
HcalDetId
Definition: HcalDetId.h:12
createfilelist.int
int
Definition: createfilelist.py:10
HcalLutManager::initChannelIterator
int initChannelIterator(std::vector< HcalGenericDetId > &map)
Definition: HcalLutManager.cc:90
HcalLutManager::~HcalLutManager
~HcalLutManager()
Definition: HcalLutManager.cc:83
HcalLutManager::getLutSetFromFile
HcalLutSet getLutSetFromFile(std::string _filename, int _type=1)
Definition: HcalLutManager.cc:170
HcalLutManager::getZdcLutXml
std::map< int, std::shared_ptr< LutXml > > getZdcLutXml(std::string _tag, bool split_by_crate=true)
Definition: HcalLutManager.cc:1717
DeadROCCounter.out_file
out_file
Definition: DeadROCCounter.py:50
LutXml::_Config::fiber
int fiber
Definition: LutXml.h:32
HcalTopology::lastHERing
int lastHERing() const
Definition: HcalTopology.h:94
HcalSubdetector.h
HcalFinegrainBit::Tower
std::array< std::bitset< 6 >, 2 > Tower
Definition: HcalFinegrainBit.h:11
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
HcalLutSet::phi_min
std::vector< int > phi_min
Definition: HcalLutManager.h:35
XMLDOMBlock.h
cms::cuda::for
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
Definition: HistoContainer.h:27
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
XMLLUTLoader
Definition: XMLLUTLoader.h:29
XMLLUTLoader::_lutDBConfig::crate
int crate
Definition: XMLLUTLoader.h:39
LutXml::_Config::fiberchan
int fiberchan
Definition: LutXml.h:32
HcalLutManager::getLinearizationLutXmlFromAsciiMasterEmap_new
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromAsciiMasterEmap_new(std::string _filename, std::string _tag, int _crate, bool split_by_crate=true)
Definition: HcalLutManager.cc:435
HcalElectronicsMap
Definition: HcalElectronicsMap.h:31
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
HcalForward
Definition: HcalAssistant.h:36
hcalSimParameters_cfi.zdc
zdc
Definition: hcalSimParameters_cfi.py:97
LutXml::_Config::formatrevision
std::string formatrevision
Definition: LutXml.h:35
HcalLutManager::HcalLutManager
HcalLutManager()
Definition: HcalLutManager.cc:46
HcalLutManager::get_subdetector
static HcalSubdetector get_subdetector(std::string _subdet)
Definition: HcalLutManager.cc:117
HcalDbService
Definition: HcalDbService.h:26
HcalLutManager
Various manipulations with trigger Lookup Tables.
Definition: HcalLutManager.h:39
submitPVValidationJobs.conditions
list conditions
Definition: submitPVValidationJobs.py:674
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
XMLLUTLoader::_checksumsDBConfig::comment_description
std::string comment_description
Definition: XMLLUTLoader.h:44
LutXml::_Config
Definition: LutXml.h:29
HcalEndcap
Definition: HcalAssistant.h:34
HcalLutManager::get_brickSet_from_oracle
std::map< int, std::shared_ptr< LutXml > > get_brickSet_from_oracle(std::string tag, const std::string _accessor="occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22")
Definition: HcalLutManager.cc:1472
HcalLutSet::label
std::string label
Definition: HcalLutManager.h:33
EMap::get_map
std::vector< EMap::EMapRow > & get_map(void)
Definition: LMap.cc:316
HcalLutManager::getInt
static int getInt(std::string number)
Definition: HcalLutManager.cc:111
RooGKCounter::getCount
unsigned long int getCount(void)
Definition: RooGKCounter.cc:95
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
XMLLUTLoader.h
timingPdfMaker.infile
infile
Definition: timingPdfMaker.py:350
XMLProcessor.h
HcalLutSet::depth_max
std::vector< int > depth_max
Definition: HcalLutManager.h:35
XMLLUTLoader::_lutDBConfig::trig_prim_lookuptbl_data_file
std::string trig_prim_lookuptbl_data_file
Definition: XMLLUTLoader.h:38
HcalLutManager::read_lmap
int read_lmap(std::string lmap_hbef_file, std::string lmap_ho_file)
Definition: HcalLutManager.cc:1371
HcalLutManager::init
void init(void)
Definition: HcalLutManager.cc:72
Oracle.h
mps_fire.result
result
Definition: mps_fire.py:311
XMLLUTLoader::_loaderBaseConfig
Definition: XMLLUTLoader.h:31
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
genParticles_cff.map
map
Definition: genParticles_cff.py:11
RooGKCounter::count
void count(void)
Definition: RooGKCounter.cc:54
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
HcalLutManager::getLutXmlFromAsciiMaster
std::map< int, std::shared_ptr< LutXml > > getLutXmlFromAsciiMaster(std::string _filename, std::string _tag, int _crate=-1, bool split_by_crate=true)
Definition: HcalLutManager.cc:253
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
LutXml
Definition: LutXml.h:27
XMLProcessor::_loaderBaseConfig::iov_end
std::string iov_end
Definition: XMLProcessor.h:50
HcalLutSet::subdet
std::vector< std::string > subdet
Definition: HcalLutManager.h:34
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
HcalLutManager::getLinearizationLutXmlFromCoder
std::map< int, std::shared_ptr< LutXml > > getLinearizationLutXmlFromCoder(const HcalTPGCoder &_coder, std::string _tag, bool split_by_crate=true)
Definition: HcalLutManager.cc:601
edm::Log
Definition: MessageLogger.h:70
XMLLUTLoader::_checksumsDBConfig::trig_prim_lookuptbl_data_file
std::string trig_prim_lookuptbl_data_file
Definition: XMLLUTLoader.h:46
CaloTPGTranscoderULUT
Definition: CaloTPGTranscoderULUT.h:18
HcalLutManager::test_emap
void test_emap(void)
Definition: HcalLutManager.cc:1618
cmsswSequenceInfo.maxsize
maxsize
Definition: cmsswSequenceInfo.py:33
HcalLutSet
Definition: HcalLutManager.h:31
HcalLutManager::getHEFineGrainLUTs
std::map< int, std::shared_ptr< LutXml > > getHEFineGrainLUTs(std::string _tag, bool split_by_crate=true)
Definition: HcalLutManager.cc:835
HcalLutManager.h
HcalLutManager::getLutFromXml
std::vector< unsigned int > getLutFromXml(std::string tag, uint32_t _rawid, hcal::ConfigurationDatabase::LUTType _lt)
Definition: HcalLutManager.cc:1394
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HcalTrigTowerDetId
Definition: HcalTrigTowerDetId.h:14
HcalLutManager::getCompressionLutXmlFromCoder
std::map< int, std::shared_ptr< LutXml > > getCompressionLutXmlFromCoder(std::string _tag, bool split_by_crate=true)
Definition: HcalLutManager.cc:1010