CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
LutXml Class Reference

#include <CalibCalorimetry/HcalTPGAlgos/interface/LutXml.h>

Inheritance diagram for LutXml:
XMLDOMBlock

Classes

struct  _Config
 

Public Types

typedef struct LutXml::_Config Config
 
typedef std::map< uint32_t, std::vector< unsigned int > >::const_iterator const_iterator
 

Public Member Functions

int a_to_i (char *inbuf)
 
void addLut (Config &_config, XMLDOMBlock *checksums_xml=nullptr)
 
const_iterator begin () const
 
int create_lut_map (void)
 
const_iterator end () const
 
const_iterator find (uint32_t) const
 
std::string & getCurrentBrick (void)
 
std::vector< unsigned int > * getLutFast (uint32_t det_id)
 
void init (void)
 
 LutXml ()
 
 LutXml (std::string filename)
 
 LutXml (XERCES_CPP_NAMESPACE::InputSource &_source)
 
HcalSubdetector subdet_from_crate (int crate, int slot, int fiber)
 
int test_access (std::string filename)
 
 ~LutXml () override
 
- Public Member Functions inherited from XMLDOMBlock
XERCES_CPP_NAMESPACE::DOMElement * add_element (XERCES_CPP_NAMESPACE::DOMElement *parent, XMLCh *tagname, XMLCh *value)
 
XERCES_CPP_NAMESPACE::DOMDocument * getDocument (void)
 
XERCES_CPP_NAMESPACE::DOMDocument * getDocumentConst (void) const
 
XERCES_CPP_NAMESPACE::DOMDocument * getNewDocument (std::string xmlFileName)
 
std::string & getString (void)
 
std::string & getString (XERCES_CPP_NAMESPACE::DOMNode *_node)
 
const char * getTagAttribute (const std::string &tagName, const std::string &attrName, int _item=0)
 
const char * getTagValue (const std::string &tagName, int _item, XERCES_CPP_NAMESPACE::DOMElement *_document)
 
const char * getTagValue (const std::string &tagName, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=nullptr)
 
std::string getTimestamp (time_t _time)
 
XMLDOMBlockoperator+= (const XMLDOMBlock &other)
 
void parse (XERCES_CPP_NAMESPACE::InputSource &_source)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (const std::string &tagName, const std::string &attrName, const int &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const std::string &attrName, const int &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (const std::string &tagName, const int &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=nullptr)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (const std::string &tagName, const std::string &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=nullptr)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const int &tagValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const std::string &tagValue, int _item=0)
 
int write (std::string target="stdout")
 
 XMLDOMBlock ()
 
 XMLDOMBlock (std::string _root, int rootElementName)
 
 XMLDOMBlock (std::string xmlFileName)
 
 XMLDOMBlock (XERCES_CPP_NAMESPACE::InputSource &_source)
 
virtual ~XMLDOMBlock ()
 

Static Public Member Functions

static std::string get_checksum (std::vector< unsigned int > &lut)
 

Protected Member Functions

XERCES_CPP_NAMESPACE::DOMElement * add_checksum (XERCES_CPP_NAMESPACE::DOMDocument *parent, Config &config)
 
template<typename T >
XERCES_CPP_NAMESPACE::DOMElement * addData (std::string _elements, std::string _encoding, const T &_lut)
 
template<typename T >
DOMElement * addData (std::string _elements, std::string _encoding, const T &_lut)
 
XERCES_CPP_NAMESPACE::DOMElement * addParameter (std::string _name, std::string _type, int _value)
 
XERCES_CPP_NAMESPACE::DOMElement * addParameter (std::string _name, std::string _type, std::string _value)
 
- Protected Member Functions inherited from XMLDOMBlock
int init (std::string _root)
 

Protected Attributes

XMLCh * brick
 
XERCES_CPP_NAMESPACE::DOMElement * brickElem
 
std::map< uint32_t, std::vector< unsigned int > > lut_map
 
XMLCh * root
 
- Protected Attributes inherited from XMLDOMBlock
XERCES_CPP_NAMESPACE::DOMDocument * document
 
XERCES_CPP_NAMESPACE::ErrorHandler * errHandler
 
XERCES_CPP_NAMESPACE::XercesDOMParser * parser
 
std::string * the_string
 
std::string theFileName
 
XMLProcessortheProcessor
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 27 of file LutXml.h.

Member Typedef Documentation

◆ Config

◆ const_iterator

typedef std::map<uint32_t, std::vector<unsigned int> >::const_iterator LutXml::const_iterator

Definition at line 72 of file LutXml.h.

Constructor & Destructor Documentation

◆ LutXml() [1/3]

LutXml::LutXml ( )

Definition at line 54 of file LutXml.cc.

54 : XMLDOMBlock("CFGBrickSet", 1) { init(); }

References init().

◆ LutXml() [2/3]

LutXml::LutXml ( XERCES_CPP_NAMESPACE::InputSource &  _source)

◆ LutXml() [3/3]

LutXml::LutXml ( std::string  filename)

Definition at line 58 of file LutXml.cc.

58 : XMLDOMBlock(filename) { init(); }

References init().

◆ ~LutXml()

LutXml::~LutXml ( )
override

Definition at line 60 of file LutXml.cc.

60  {
63 }

References brick, and fetchall_from_DQM_v2::release.

Member Function Documentation

◆ a_to_i()

int LutXml::a_to_i ( char *  inbuf)

Definition at line 325 of file LutXml.cc.

325  {
326  int result;
327  sscanf(inbuf, "%d", &result);
328  return result;
329 }

References mps_fire::result.

Referenced by create_lut_map().

◆ add_checksum()

DOMElement * LutXml::add_checksum ( XERCES_CPP_NAMESPACE::DOMDocument *  parent,
Config config 
)
protected

Definition at line 157 of file LutXml.cc.

157  {
158  DOMElement *child = parent->createElement(XMLProcessor::_toXMLCh("Data"));
159  child->setAttribute(XMLProcessor::_toXMLCh("crate"), XMLProcessor::_toXMLCh(config.crate));
160  child->setAttribute(XMLProcessor::_toXMLCh("slot"), XMLProcessor::_toXMLCh(config.slot));
161  child->setAttribute(XMLProcessor::_toXMLCh("fpga"), XMLProcessor::_toXMLCh(config.topbottom));
162  child->setAttribute(XMLProcessor::_toXMLCh("fiber"), XMLProcessor::_toXMLCh(config.fiber));
163  child->setAttribute(XMLProcessor::_toXMLCh("fiberchan"), XMLProcessor::_toXMLCh(config.fiberchan));
164  child->setAttribute(XMLProcessor::_toXMLCh("luttype"), XMLProcessor::_toXMLCh(config.lut_type));
165  child->setAttribute(XMLProcessor::_toXMLCh("elements"), XMLProcessor::_toXMLCh("1"));
166  child->setAttribute(XMLProcessor::_toXMLCh("encoding"), XMLProcessor::_toXMLCh("hex"));
167  DOMText *checksum_value = parent->createTextNode(XMLProcessor::_toXMLCh(get_checksum(config.lut)));
168  child->appendChild(checksum_value);
169 
170  parent->getDocumentElement()->appendChild(child);
171 
172  return child;
173 }

References XMLProcessor::_toXMLCh(), class-composition::child, get_checksum(), and class-composition::parent.

Referenced by addLut().

◆ addData() [1/2]

template<typename T >
XERCES_CPP_NAMESPACE::DOMElement* LutXml::addData ( std::string  _elements,
std::string  _encoding,
const T _lut 
)
protected

Referenced by addLut().

◆ addData() [2/2]

template<typename T >
DOMElement* LutXml::addData ( std::string  _elements,
std::string  _encoding,
const T _lut 
)
protected

Definition at line 134 of file LutXml.cc.

134  {
135  DOMElement *child = document->createElement(XMLProcessor::_toXMLCh("Data"));
136  child->setAttribute(XMLProcessor::_toXMLCh("elements"), XMLProcessor::_toXMLCh(_elements));
137  child->setAttribute(XMLProcessor::_toXMLCh("encoding"), XMLProcessor::_toXMLCh(_encoding));
138 
139  std::stringstream buf;
140 
141  for (const auto &iter : _lut) {
142  char buf2[16];
143  sprintf(buf2, "%lx", uint64_t(iter));
144  buf << buf2 << " ";
145  }
146 
147  std::string _value = buf.str();
148 
149  DOMText *data_value = document->createTextNode(XMLProcessor::_toXMLCh(_value));
150  child->appendChild(data_value);
151 
152  brickElem->appendChild(child);
153 
154  return child;
155 }

References XMLProcessor::_toXMLCh(), brickElem, visDQMUpload::buf, class-composition::child, XMLDOMBlock::document, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ addLut()

void LutXml::addLut ( LutXml::Config _config,
XMLDOMBlock checksums_xml = nullptr 
)

Definition at line 79 of file LutXml.cc.

79  {
80  DOMElement *rootElem = document->getDocumentElement();
81 
82  brickElem = document->createElement(XMLProcessor::_toXMLCh("CFGBrick"));
83  rootElem->appendChild(brickElem);
84 
85  addParameter("INFOTYPE", "string", _config.infotype);
86  addParameter("CREATIONTAG", "string", _config.creationtag);
87  addParameter("CREATIONSTAMP", "string", _config.creationstamp);
88  addParameter("FORMATREVISION", "string", _config.formatrevision);
89  addParameter("TARGETFIRMWARE", "string", _config.targetfirmware);
90  addParameter("GENERALIZEDINDEX", "int", _config.generalizedindex);
91  addParameter("CRATE", "int", _config.crate);
92  addParameter("SLOT", "int", _config.slot);
93 
94  if (checksums_xml) {
95  addParameter("CHECKSUM", "string", get_checksum(_config.lut));
96  }
97 
98  if (_config.lut_type == 1) { // linearizer LUT
99  addParameter("IETA", "int", _config.ieta);
100  addParameter("IPHI", "int", _config.iphi);
101  addParameter("TOPBOTTOM", "int", _config.topbottom);
102  addParameter("LUT_TYPE", "int", _config.lut_type);
103  addParameter("FIBER", "int", _config.fiber);
104  addParameter("FIBERCHAN", "int", _config.fiberchan);
105  addParameter("DEPTH", "int", _config.depth);
106  addData(to_string(_config.lut.size()), "hex", _config.lut);
107  } else if (_config.lut_type == 2 || _config.lut_type == 4) { // compression LUT or HE feature bit LUT
108  addParameter("IETA", "int", _config.ieta);
109  addParameter("IPHI", "int", _config.iphi);
110  addParameter("TOPBOTTOM", "int", _config.topbottom);
111  addParameter("LUT_TYPE", "int", _config.lut_type);
112  addParameter("SLB", "int", _config.fiber);
113  addParameter("SLBCHAN", "int", _config.fiberchan);
114  addData(to_string(_config.lut.size()), "hex", _config.lut);
115  } else if (_config.lut_type == 5) { // channel masks
116  addParameter("MASK_TYPE", "string", "TRIGGERCHANMASK");
117  addData(to_string(_config.mask.size()), "hex", _config.mask);
118  } else if (_config.lut_type == 6) { // adc threshold for tdc mask
119  addParameter("THRESH_TYPE", "string", "TRIGINTIME");
120  addData(to_string(_config.mask.size()), "hex", _config.mask);
121  } else if (_config.lut_type == 7) { // tdc mask
122  addParameter("TDCMAP_TYPE", "string", "TRIGINTIME");
123  addData(to_string(_config.mask.size()), "hex", _config.mask);
124  } else {
125  edm::LogError("LutXml") << "Unknown LUT type...produced XML will be incorrect";
126  }
127 
128  if (checksums_xml) {
129  add_checksum(checksums_xml->getDocument(), _config);
130  }
131 }

References XMLProcessor::_toXMLCh(), add_checksum(), addData(), addParameter(), brickElem, LutXml::_Config::crate, LutXml::_Config::creationstamp, LutXml::_Config::creationtag, LutXml::_Config::depth, XMLDOMBlock::document, LutXml::_Config::fiber, LutXml::_Config::fiberchan, LutXml::_Config::formatrevision, LutXml::_Config::generalizedindex, get_checksum(), XMLDOMBlock::getDocument(), LutXml::_Config::ieta, LutXml::_Config::infotype, LutXml::_Config::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, LutXml::_Config::mask, LutXml::_Config::slot, LutXml::_Config::targetfirmware, and LutXml::_Config::topbottom.

◆ addParameter() [1/2]

DOMElement * LutXml::addParameter ( std::string  _name,
std::string  _type,
int  _value 
)
protected

◆ addParameter() [2/2]

DOMElement * LutXml::addParameter ( std::string  _name,
std::string  _type,
std::string  _value 
)
protected

Definition at line 175 of file LutXml.cc.

175  {
176  DOMElement *child = document->createElement(XMLProcessor::_toXMLCh("Parameter"));
177  child->setAttribute(XMLProcessor::_toXMLCh("name"), XMLProcessor::_toXMLCh(_name));
178  child->setAttribute(XMLProcessor::_toXMLCh("type"), XMLProcessor::_toXMLCh(_type));
179  DOMText *parameter_value = document->createTextNode(XMLProcessor::_toXMLCh(_value));
180  child->appendChild(parameter_value);
181 
182  brickElem->appendChild(child);
183 
184  return child;
185 }

References XMLProcessor::_toXMLCh(), brickElem, class-composition::child, and XMLDOMBlock::document.

Referenced by metTools.AddMETCollection::__init__(), trackTools.MakeAODTrackCandidates::__init__(), coreTools.RunOnData::__init__(), runJetUncertainties.RunJetUncertainties::__init__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::__init__(), cmsswVersionTools.PickRelValInputFiles::__init__(), coreTools.RemoveMCMatching::__init__(), trackTools.MakePATTrackCandidates::__init__(), trigTools.SwitchOnTrigger::__init__(), trigTools.SwitchOnTriggerStandAlone::__init__(), tauTools.AddTauCollection::__init__(), trackTools.MakeTrackCandidates::__init__(), trigTools.SwitchOnTriggerMatching::__init__(), trigTools.SwitchOnTriggerMatchingStandAlone::__init__(), trigTools.SwitchOnTriggerMatchEmbedding::__init__(), jetTools.AddJetCollection::__init__(), jetTools.SwitchJetCollection::__init__(), jetTools.UpdateJetCollection::__init__(), jetTools.AddJetID::__init__(), jetTools.SetTagInfos::__init__(), addLut(), and addParameter().

◆ begin()

LutXml::const_iterator LutXml::begin ( ) const

Definition at line 444 of file LutXml.cc.

444 { return lut_map.begin(); }

References lut_map.

◆ create_lut_map()

int LutXml::create_lut_map ( void  )

Definition at line 336 of file LutXml.cc.

336  {
337  //delete lut_map;
338  lut_map.clear();
339  //lut_map = new std::map<uint32_t,std::vector<unsigned int> >();
340 
341  if (document) {
342  //DOMElement * rootElem =
343  DOMNodeList *brick_list = document->getDocumentElement()->getElementsByTagName(brick);
344  int n_of_bricks = brick_list->getLength();
345  for (int i = 0; i != n_of_bricks; i++) {
346  DOMElement *aBrick = (DOMElement *)(brick_list->item(i));
347  DOMNodeList *par_list = aBrick->getElementsByTagName(XMLString::transcode("Parameter"));
348  int n_of_par = par_list->getLength();
349  int ieta = -99;
350  int iphi = -99;
351  int depth = -99;
352  int crate = -99;
353  int slot = -99;
354  int fiber = -99;
355  int lut_type = -99;
356  int slb = -99;
357  HcalSubdetector subdet;
358  for (int j = 0; j != n_of_par; j++) {
359  DOMElement *aPar = (DOMElement *)(par_list->item(j));
360  char *aName = XMLString::transcode(aPar->getAttribute(XMLProcessor::_toXMLCh("name")));
361  if (strcmp(aName, "IETA") == 0)
362  ieta = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
363  if (strcmp(aName, "IPHI") == 0)
364  iphi = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
365  if (strcmp(aName, "DEPTH") == 0)
366  depth = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
367  if (strcmp(aName, "CRATE") == 0)
368  crate = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
369  if (strcmp(aName, "SLOT") == 0)
370  slot = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
371  if (strcmp(aName, "FIBER") == 0)
372  fiber = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
373  if (strcmp(aName, "LUT_TYPE") == 0)
374  lut_type = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
375  if (strcmp(aName, "SLB") == 0)
376  slb = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
377  }
378  subdet = subdet_from_crate(crate, slot, fiber);
379  DOMElement *_data = (DOMElement *)(aBrick->getElementsByTagName(XMLString::transcode("Data"))->item(0));
380  char *_str = XMLString::transcode(_data->getFirstChild()->getNodeValue());
381 
382  // get the LUT vector
383  int _string_length = strlen(_str);
384  std::vector<unsigned int> _lut;
385  unsigned int _base = 16;
386  unsigned int _item = 0;
387  for (int i = 0; i != _string_length; i++) {
388  bool _range = false;
389  char ch_cur = _str[i];
390  if (_base == 16)
391  _range = (ch_cur >= '0' and ch_cur <= '9') || (ch_cur >= 'a' and ch_cur <= 'f') ||
392  (ch_cur >= 'A' and ch_cur <= 'F');
393  else if (_base == 10)
394  _range = (ch_cur >= '0' and ch_cur <= '9');
395  if (_range) {
396  if (ch_cur >= 'a' and ch_cur <= 'f')
397  ch_cur += 10 - 'a';
398  else if (ch_cur >= 'A' and ch_cur <= 'F')
399  ch_cur += 10 - 'A';
400  else if (ch_cur >= '0' and ch_cur <= '9')
401  ch_cur += -'0';
402  _item = _item * _base;
403  _item += ch_cur;
404  bool last_digit = false;
405  if ((i + 1) == _string_length)
406  last_digit = true;
407  else {
408  char ch_next = _str[i + 1];
409  bool _range_next = false;
410  if (_base == 16)
411  _range_next = (ch_next >= '0' and ch_next <= '9') || (ch_next >= 'a' and ch_next <= 'f') ||
412  (ch_next >= 'A' and ch_next <= 'F');
413  else if (_base == 10)
414  _range_next = (ch_next >= '0' and ch_next <= '9');
415  if (!_range_next)
416  last_digit = true;
417  }
418  if (last_digit) {
419  _lut.push_back(_item);
420  _item = 0;
421  }
422  }
423  }
424  // filling the map
425  uint32_t _key = 0;
426  if (lut_type == 1) {
427  HcalDetId _id(subdet, ieta, iphi, depth);
428  _key = _id.rawId();
429  } else if (lut_type == 2) {
430  int version = (abs(ieta) > 29 && slb != 12 && crate > 20) ? 1 : 0;
431  HcalTrigTowerDetId _id(ieta, iphi, 10 * version);
432  _key = _id.rawId();
433  } else
434  continue;
435  lut_map.insert(std::pair<uint32_t, std::vector<unsigned int> >(_key, _lut));
436  }
437  } else {
438  edm::LogError("LutXml") << "XML file with LUTs is not loaded, cannot create map!";
439  }
440 
441  return 0;
442 }

References XMLProcessor::_toXMLCh(), a_to_i(), funct::abs(), brick, LEDCalibrationChannels::depth, XMLDOMBlock::document, mps_fire::i, LEDCalibrationChannels::ieta, LEDCalibrationChannels::iphi, dqmiolumiharvest::j, lut_map, DetId::rawId(), slb(), subdet_from_crate(), and BeamSplash_cfg::version.

Referenced by HcalLutAnalyzer::analyze(), main(), and HcaluLUTTPGCoder::updateXML().

◆ end()

LutXml::const_iterator LutXml::end ( ) const

Definition at line 446 of file LutXml.cc.

446 { return lut_map.end(); }

References lut_map.

Referenced by Types.LuminosityBlockRange::cppID(), Types.EventRange::cppID(), and dumpLutDiff().

◆ find()

LutXml::const_iterator LutXml::find ( uint32_t  id) const

Definition at line 448 of file LutXml.cc.

448 { return lut_map.find(id); }

References lut_map.

Referenced by BeautifulSoup.Tag::__getattr__(), dumpLutDiff(), and BeautifulSoup.Tag::firstText().

◆ get_checksum()

std::string LutXml::get_checksum ( std::vector< unsigned int > &  lut)
static

Definition at line 197 of file LutXml.cc.

197  {
198  std::stringstream result;
199  md5_state_t md5er;
200  md5_byte_t digest[16];
201  md5_init(&md5er);
202  // linearizer LUT:
203  if (lut.size() == 128) {
204  unsigned char tool[2];
205  for (int i = 0; i < 128; i++) {
206  tool[0] = lut[i] & 0xFF;
207  tool[1] = (lut[i] >> 8) & 0xFF;
208  md5_append(&md5er, tool, 2);
209  }
210  } else if (lut.size() == 256) {
211  unsigned char tool[2];
212  for (int i = 0; i < 256; i++) {
213  tool[0] = lut[i] & 0xFF;
214  tool[1] = (lut[i] >> 8) & 0xFF;
215  md5_append(&md5er, tool, 2);
216  }
217  }
218  // compression LUT:
219  else if (lut.size() == 1024) {
220  unsigned char tool;
221  for (int i = 0; i < 1024; i++) {
222  tool = lut[i] & 0xFF;
223  md5_append(&md5er, &tool, 1);
224  }
225  } else if (lut.size() == 2048) {
226  unsigned char tool;
227  for (int i = 0; i < 2048; i++) {
228  tool = lut[i] & 0xFF;
229  md5_append(&md5er, &tool, 1);
230  }
231  }
232  // HE fine grain LUT
233  else if (lut.size() == 4096) {
234  unsigned char tool;
235  for (int i = 0; i < 4096; i++) {
236  tool = lut[i] & 0xFF;
237  md5_append(&md5er, &tool, 1);
238  }
239  } else {
240  edm::LogError("LutXml") << "Irregular LUT size, " << lut.size()
241  << " , do not know how to compute checksum, exiting...";
242  exit(-1);
243  }
244  md5_finish(&md5er, digest);
245  for (int i = 0; i < 16; i++)
246  result << std::hex << (((int)(digest[i])) & 0xFF);
247 
248  return result.str();
249 }

References beamvalidation::exit(), mps_fire::i, and mps_fire::result.

Referenced by add_checksum(), and addLut().

◆ getCurrentBrick()

std::string & LutXml::getCurrentBrick ( void  )

Definition at line 194 of file LutXml.cc.

194 { return getString(brickElem); }

References brickElem, and XMLDOMBlock::getString().

◆ getLutFast()

std::vector< unsigned int > * LutXml::getLutFast ( uint32_t  det_id)

Definition at line 71 of file LutXml.cc.

71  {
72  if (lut_map.find(det_id) != lut_map.end())
73  return &(lut_map)[det_id];
74  edm::LogError("LutXml") << "LUT not found, null pointer is returned";
75  return nullptr;
76 }

References lut_map.

Referenced by test_access(), and HcaluLUTTPGCoder::updateXML().

◆ init()

void LutXml::init ( void  )

Definition at line 65 of file LutXml.cc.

65  {
66  root = XMLString::transcode("CFGBrickSet");
67  brick = XMLString::transcode("CFGBrick");
68  brickElem = nullptr;
69 }

References brick, and brickElem.

Referenced by LutXml().

◆ subdet_from_crate()

HcalSubdetector LutXml::subdet_from_crate ( int  crate,
int  slot,
int  fiber 
)

Definition at line 301 of file LutXml.cc.

301  {
302  // HBHE: 0,1,4,5,10,11,14,15,17 (+20)
303  // HF: 2,9,12 (+20)
304  // HO: 3,6,7,13,18 (+20)
305  int crate = crate_ < 20 ? crate_ : crate_ - 20;
306  if (crate == 2 || crate == 9 || crate == 12)
307  return HcalForward;
308  else if (crate == 3 || crate == 6 || crate == 7 || crate == 13 || crate == 18)
309  return HcalOuter;
310  else if (crate == 0 || crate == 1 || crate == 4 || crate == 5 || crate == 10 || crate == 11 || crate == 14 ||
311  crate == 15 || crate == 17) {
312  if (slot % 3 == 1)
313  return HcalBarrel;
314  else if (slot % 3 == 0)
315  return HcalEndcap;
316  else if (fiber < 12)
317  return HcalBarrel;
318  else
319  return HcalEndcap;
320  }
321  edm::LogWarning("LutXml::subdet_from_crate") << "crate " << crate_ << " is not accounted for";
322  return HcalEmpty;
323 }

References HcalBarrel, HcalEmpty, HcalEndcap, HcalForward, and HcalOuter.

Referenced by create_lut_map().

◆ test_access()

int LutXml::test_access ( std::string  filename)

Definition at line 251 of file LutXml.cc.

251  {
252  edm::LogInfo("LutXml") << "Created map size: " << lut_map.size();
253 
254  struct timeval _t;
255  gettimeofday(&_t, nullptr);
256  double _time = (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0;
257 
258  HcalEmap _emap("./backup/official_emap_v6.04_080905.txt");
259  std::vector<HcalEmap::HcalEmapRow> &_map = _emap.get_map();
260  edm::LogInfo("LutXml") << "HcalEmap contains " << _map.size() << " entries";
261 
262  int _counter = 0;
263  for (std::vector<HcalEmap::HcalEmapRow>::const_iterator row = _map.begin(); row != _map.end(); ++row) {
264  if (row->subdet == "HB") {
265  HcalDetId det_id(HcalBarrel, row->ieta, row->iphi, row->idepth);
266  uint32_t raw_id = det_id.rawId();
267  std::vector<unsigned int> *l = getLutFast(raw_id);
268  if (l)
269  _counter++;
270  }
271  if (row->subdet == "HE") {
272  HcalDetId det_id(HcalEndcap, row->ieta, row->iphi, row->idepth);
273  uint32_t raw_id = det_id.rawId();
274  std::vector<unsigned int> *l = getLutFast(raw_id);
275  if (l)
276  _counter++;
277  }
278  if (row->subdet == "HF") {
279  HcalDetId det_id(HcalForward, row->ieta, row->iphi, row->idepth);
280  uint32_t raw_id = det_id.rawId();
281  std::vector<unsigned int> *l = getLutFast(raw_id);
282  if (l)
283  _counter++;
284  }
285  if (row->subdet == "HO") {
286  HcalDetId det_id(HcalOuter, row->ieta, row->iphi, row->idepth);
287  uint32_t raw_id = det_id.rawId();
288  std::vector<unsigned int> *l = getLutFast(raw_id);
289  if (l)
290  _counter++;
291  }
292  }
293  gettimeofday(&_t, nullptr);
294  edm::LogInfo("LutXml") << "access to " << _counter
295  << " HCAL channels took: " << (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0 - _time
296  << "sec";
297 
298  return 0;
299 }

References HcalEmap::get_map(), getLutFast(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, cmsLHEtoEOSManager::l, lut_map, and DetId::rawId().

Member Data Documentation

◆ brick

XMLCh* LutXml::brick
protected

Definition at line 79 of file LutXml.h.

Referenced by create_lut_map(), init(), and ~LutXml().

◆ brickElem

XERCES_CPP_NAMESPACE::DOMElement* LutXml::brickElem
protected

Definition at line 88 of file LutXml.h.

Referenced by addData(), addLut(), addParameter(), getCurrentBrick(), and init().

◆ lut_map

std::map<uint32_t, std::vector<unsigned int> > LutXml::lut_map
protected

Definition at line 91 of file LutXml.h.

Referenced by begin(), create_lut_map(), end(), find(), getLutFast(), and test_access().

◆ root

XMLCh* LutXml::root
protected

Definition at line 78 of file LutXml.h.

LutXml::_Config::creationtag
std::string creationtag
Definition: LutXml.h:33
XMLProcessor::_toXMLCh
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:172
mps_fire.i
i
Definition: mps_fire.py:355
XMLDOMBlock::XMLDOMBlock
XMLDOMBlock()
Definition: XMLDOMBlock.cc:46
LutXml::addParameter
XERCES_CPP_NAMESPACE::DOMElement * addParameter(std::string _name, std::string _type, std::string _value)
Definition: LutXml.cc:175
LutXml::_Config::mask
std::vector< uint64_t > mask
Definition: LutXml.h:39
LutXml::_Config::topbottom
int topbottom
Definition: LutXml.h:32
edm::LogInfo
Definition: MessageLogger.h:254
XMLDOMBlock::document
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:117
LutXml::_Config::slot
int slot
Definition: LutXml.h:32
HcalBarrel
Definition: HcalAssistant.h:33
HcalEmpty
Definition: HcalAssistant.h:32
LutXml::add_checksum
XERCES_CPP_NAMESPACE::DOMElement * add_checksum(XERCES_CPP_NAMESPACE::DOMDocument *parent, Config &config)
Definition: LutXml.cc:157
LutXml::_Config::targetfirmware
std::string targetfirmware
Definition: LutXml.h:36
slb
static int slb(const HcalTriggerPrimitiveSample &theSample)
Definition: CastorUnpacker.cc:71
LutXml::_Config::generalizedindex
int generalizedindex
Definition: LutXml.h:37
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
config
Definition: config.py:1
LutXml::init
void init(void)
Definition: LutXml.cc:65
LutXml::_Config::iphi
int iphi
Definition: LutXml.h:32
LutXml::_Config::lut_type
int lut_type
Definition: LutXml.h:32
LutXml::brickElem
XERCES_CPP_NAMESPACE::DOMElement * brickElem
Definition: LutXml.h:88
LutXml::get_checksum
static std::string get_checksum(std::vector< unsigned int > &lut)
Definition: LutXml.cc:197
XMLDOMBlock::getString
std::string & getString(void)
Definition: XMLDOMBlock.cc:419
LutXml::a_to_i
int a_to_i(char *inbuf)
Definition: LutXml.cc:325
XMLDOMBlock::getDocument
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:268
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
HcalOuter
Definition: HcalAssistant.h:35
LutXml::_Config::creationstamp
std::string creationstamp
Definition: LutXml.h:34
LutXml::brick
XMLCh * brick
Definition: LutXml.h:79
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LutXml::_Config::ieta
int ieta
Definition: LutXml.h:32
edm::LogWarning
Definition: MessageLogger.h:141
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
edm::LogError
Definition: MessageLogger.h:183
fetchall_from_DQM_v2.release
release
Definition: fetchall_from_DQM_v2.py:92
LutXml::_Config::crate
int crate
Definition: LutXml.h:32
LutXml::_Config::lut
std::vector< unsigned int > lut
Definition: LutXml.h:38
LutXml::_Config::depth
int depth
Definition: LutXml.h:32
HcalDetId
Definition: HcalDetId.h:12
root
Definition: RooFitFunction.h:10
LutXml::getLutFast
std::vector< unsigned int > * getLutFast(uint32_t det_id)
Definition: LutXml.cc:71
LutXml::_Config::fiber
int fiber
Definition: LutXml.h:32
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
LutXml::_Config::fiberchan
int fiberchan
Definition: LutXml.h:32
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
HcalForward
Definition: HcalAssistant.h:36
LutXml::_Config::formatrevision
std::string formatrevision
Definition: LutXml.h:35
HcalEndcap
Definition: HcalAssistant.h:34
LutXml::lut_map
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:91
HcalEmap
Definition: HcalEmap.h:32
LutXml::subdet_from_crate
HcalSubdetector subdet_from_crate(int crate, int slot, int fiber)
Definition: LutXml.cc:301
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
class-composition.child
child
Definition: class-composition.py:91
mps_fire.result
result
Definition: mps_fire.py:303
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
LutXml::_Config::infotype
std::string infotype
Definition: LutXml.h:31
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
child
Definition: simpleInheritance.h:11
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
LutXml::addData
XERCES_CPP_NAMESPACE::DOMElement * addData(std::string _elements, std::string _encoding, const T &_lut)
class-composition.parent
parent
Definition: class-composition.py:88
HcalTrigTowerDetId
Definition: HcalTrigTowerDetId.h:14