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)
 
template<typename T >
DOMElement * addData (std::string _elements, std::string _encoding, const T &_lut)
 
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 (XERCES_CPP_NAMESPACE::InputSource &_source)
 
 LutXml (std::string filename)
 
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=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=nullptr)
 
const char * getTagValue (const std::string &tagName, int _item, XERCES_CPP_NAMESPACE::DOMElement *_document)
 
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 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 std::string &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (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 int &attrValue, int _item=0)
 
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 std::string &tagValue, 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 (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const int &tagValue, int _item=0)
 
int write (std::string target="stdout")
 
 XMLDOMBlock ()
 
 XMLDOMBlock (std::string xmlFileName)
 
 XMLDOMBlock (XERCES_CPP_NAMESPACE::InputSource &_source)
 
 XMLDOMBlock (std::string _root, int rootElementName)
 
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)
 
XERCES_CPP_NAMESPACE::DOMElement * addParameter (std::string _name, std::string _type, std::string _value)
 
XERCES_CPP_NAMESPACE::DOMElement * addParameter (std::string _name, std::string _type, int _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 74 of file LutXml.h.

Constructor & Destructor Documentation

◆ LutXml() [1/3]

LutXml::LutXml ( )

Definition at line 57 of file LutXml.cc.

References init().

57 : XMLDOMBlock("CFGBrickSet", 1) { init(); }
void init(void)
Definition: LutXml.cc:68

◆ LutXml() [2/3]

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

◆ LutXml() [3/3]

LutXml::LutXml ( std::string  filename)

Definition at line 61 of file LutXml.cc.

References init().

61 : XMLDOMBlock(filename) { init(); }
void init(void)
Definition: LutXml.cc:68

◆ ~LutXml()

LutXml::~LutXml ( )
override

Definition at line 63 of file LutXml.cc.

References brick, and fetchall_from_DQM_v2::release.

Member Function Documentation

◆ a_to_i()

int LutXml::a_to_i ( char *  inbuf)

Definition at line 341 of file LutXml.cc.

References mps_fire::result.

Referenced by create_lut_map().

341  {
342  int result;
343  sscanf(inbuf, "%d", &result);
344  return result;
345 }

◆ add_checksum()

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

Definition at line 173 of file LutXml.cc.

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

Referenced by addLut().

173  {
174  DOMElement *child = parent->createElement(XMLProcessor::_toXMLCh("Data"));
175  child->setAttribute(XMLProcessor::_toXMLCh("crate"), XMLProcessor::_toXMLCh(config.crate));
176  child->setAttribute(XMLProcessor::_toXMLCh("slot"), XMLProcessor::_toXMLCh(config.slot));
177  child->setAttribute(XMLProcessor::_toXMLCh("fpga"), XMLProcessor::_toXMLCh(config.topbottom));
178  child->setAttribute(XMLProcessor::_toXMLCh("fiber"), XMLProcessor::_toXMLCh(config.fiber));
179  child->setAttribute(XMLProcessor::_toXMLCh("fiberchan"), XMLProcessor::_toXMLCh(config.fiberchan));
180  child->setAttribute(XMLProcessor::_toXMLCh("luttype"), XMLProcessor::_toXMLCh(config.lut_type));
181  child->setAttribute(XMLProcessor::_toXMLCh("elements"), XMLProcessor::_toXMLCh("1"));
182  child->setAttribute(XMLProcessor::_toXMLCh("encoding"), XMLProcessor::_toXMLCh("hex"));
183  DOMText *checksum_value = parent->createTextNode(XMLProcessor::_toXMLCh(get_checksum(config.lut)));
184  child->appendChild(checksum_value);
185 
186  parent->getDocumentElement()->appendChild(child);
187 
188  return child;
189 }
Definition: config.py:1
static std::string get_checksum(std::vector< unsigned int > &lut)
Definition: LutXml.cc:213
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:172

◆ 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 
)

Definition at line 150 of file LutXml.cc.

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

150  {
151  DOMElement *child = document->createElement(XMLProcessor::_toXMLCh("Data"));
152  child->setAttribute(XMLProcessor::_toXMLCh("elements"), XMLProcessor::_toXMLCh(_elements));
153  child->setAttribute(XMLProcessor::_toXMLCh("encoding"), XMLProcessor::_toXMLCh(_encoding));
154 
155  std::stringstream buf;
156 
157  for (const auto &iter : _lut) {
158  char buf2[16];
159  sprintf(buf2, "%lx", uint64_t(iter));
160  buf << buf2 << " ";
161  }
162 
163  std::string _value = buf.str();
164 
165  DOMText *data_value = document->createTextNode(XMLProcessor::_toXMLCh(_value));
166  child->appendChild(data_value);
167 
168  brickElem->appendChild(child);
169 
170  return child;
171 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:117
unsigned long long uint64_t
Definition: Time.h:13
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:172
XERCES_CPP_NAMESPACE::DOMElement * brickElem
Definition: LutXml.h:90

◆ addLut()

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

Definition at line 82 of file LutXml.cc.

References XMLProcessor::_toXMLCh(), add_checksum(), addData(), addParameter(), brickElem, LutXml::_Config::codedvetothreshold, 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, to_string(), LutXml::_Config::topbottom, and LutXml::_Config::weight.

82  {
83  DOMElement *rootElem = document->getDocumentElement();
84 
85  brickElem = document->createElement(XMLProcessor::_toXMLCh("CFGBrick"));
86  rootElem->appendChild(brickElem);
87 
88  addParameter("INFOTYPE", "string", _config.infotype);
89  addParameter("CREATIONTAG", "string", _config.creationtag);
90  addParameter("CREATIONSTAMP", "string", _config.creationstamp);
91  addParameter("FORMATREVISION", "string", _config.formatrevision);
92  addParameter("TARGETFIRMWARE", "string", _config.targetfirmware);
93  addParameter("GENERALIZEDINDEX", "int", _config.generalizedindex);
94  addParameter("CRATE", "int", _config.crate);
95  addParameter("SLOT", "int", _config.slot);
96 
97  if (checksums_xml) {
98  addParameter("CHECKSUM", "string", get_checksum(_config.lut));
99  }
100 
101  if (_config.lut_type == 1) { // linearizer LUT
102  addParameter("IETA", "int", _config.ieta);
103  addParameter("IPHI", "int", _config.iphi);
104  addParameter("TOPBOTTOM", "int", _config.topbottom);
105  addParameter("LUT_TYPE", "int", _config.lut_type);
106  addParameter("FIBER", "int", _config.fiber);
107  addParameter("FIBERCHAN", "int", _config.fiberchan);
108  addParameter("DEPTH", "int", _config.depth);
109  addData(to_string(_config.lut.size()), "hex", _config.lut);
110  } else if (_config.lut_type == 2 || _config.lut_type == 4) { // compression LUT or HE feature bit LUT
111  addParameter("IETA", "int", _config.ieta);
112  addParameter("IPHI", "int", _config.iphi);
113  addParameter("TOPBOTTOM", "int", _config.topbottom);
114  addParameter("LUT_TYPE", "int", _config.lut_type);
115  addParameter("SLB", "int", _config.fiber);
116  addParameter("SLBCHAN", "int", _config.fiberchan);
117  addParameter("WEIGHT", "int", _config.weight);
118  // Special coded veto threshold value of zero disables vetoing in PFA1'
119  if (_config.codedvetothreshold > 0) {
120  // A valid coded value here is in the range (1, 2048) inclusive
121  if (_config.codedvetothreshold <= 2048) {
122  // The coded value of 2048 means to do vetoing with no threshold
123  int actualvetothreshold = _config.codedvetothreshold == 2048 ? 0 : _config.codedvetothreshold;
124  addParameter("PREFIRE_VETO_THRESHOLD", "int", actualvetothreshold);
125  } else {
126  edm::LogWarning("LutXml") << "Positive veto threshold of " << _config.codedvetothreshold
127  << " is not in range (1, 2048) ! Vetoing will not be done in PFA1' !";
128  }
129  }
130  addData(to_string(_config.lut.size()), "hex", _config.lut);
131  } else if (_config.lut_type == 5) { // channel masks
132  addParameter("MASK_TYPE", "string", "TRIGGERCHANMASK");
133  addData(to_string(_config.mask.size()), "hex", _config.mask);
134  } else if (_config.lut_type == 6) { // adc threshold for tdc mask
135  addParameter("THRESH_TYPE", "string", "TRIGINTIME");
136  addData(to_string(_config.mask.size()), "hex", _config.mask);
137  } else if (_config.lut_type == 7) { // tdc mask
138  addParameter("TDCMAP_TYPE", "string", "TRIGINTIME");
139  addData(to_string(_config.mask.size()), "hex", _config.mask);
140  } else {
141  edm::LogError("LutXml") << "Unknown LUT type...produced XML will be incorrect";
142  }
143 
144  if (checksums_xml) {
145  add_checksum(checksums_xml->getDocument(), _config);
146  }
147 }
XERCES_CPP_NAMESPACE::DOMElement * addParameter(std::string _name, std::string _type, std::string _value)
Definition: LutXml.cc:191
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:117
std::string targetfirmware
Definition: LutXml.h:36
int generalizedindex
Definition: LutXml.h:37
XERCES_CPP_NAMESPACE::DOMElement * add_checksum(XERCES_CPP_NAMESPACE::DOMDocument *parent, Config &config)
Definition: LutXml.cc:173
XERCES_CPP_NAMESPACE::DOMElement * addData(std::string _elements, std::string _encoding, const T &_lut)
Log< level::Error, false > LogError
static std::string to_string(const XMLCh *ch)
int topbottom
Definition: LutXml.h:32
std::vector< unsigned int > lut
Definition: LutXml.h:40
std::string creationtag
Definition: LutXml.h:33
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:268
static std::string get_checksum(std::vector< unsigned int > &lut)
Definition: LutXml.cc:213
int codedvetothreshold
Definition: LutXml.h:39
std::string formatrevision
Definition: LutXml.h:35
std::string infotype
Definition: LutXml.h:31
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:172
Log< level::Warning, false > LogWarning
XERCES_CPP_NAMESPACE::DOMElement * brickElem
Definition: LutXml.h:90
int lut_type
Definition: LutXml.h:32
std::string creationstamp
Definition: LutXml.h:34
int fiberchan
Definition: LutXml.h:32
std::vector< uint64_t > mask
Definition: LutXml.h:41

◆ addParameter() [1/2]

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

Definition at line 191 of file LutXml.cc.

References XMLProcessor::_toXMLCh(), brickElem, submitPVValidationJobs::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().

191  {
192  DOMElement *child = document->createElement(XMLProcessor::_toXMLCh("Parameter"));
193  child->setAttribute(XMLProcessor::_toXMLCh("name"), XMLProcessor::_toXMLCh(_name));
194  child->setAttribute(XMLProcessor::_toXMLCh("type"), XMLProcessor::_toXMLCh(_type));
195  DOMText *parameter_value = document->createTextNode(XMLProcessor::_toXMLCh(_value));
196  child->appendChild(parameter_value);
197 
198  brickElem->appendChild(child);
199 
200  return child;
201 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:117
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:172
XERCES_CPP_NAMESPACE::DOMElement * brickElem
Definition: LutXml.h:90

◆ addParameter() [2/2]

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

Definition at line 203 of file LutXml.cc.

References addParameter(), visDQMUpload::buf, and AlCaHLTBitMon_QueryRunRegistry::string.

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__(), and jetTools.SetTagInfos::__init__().

203  {
204  char buf[128];
205  sprintf(buf, "%d", _value);
206  std::string str_value = buf;
207  return addParameter(_name, _type, str_value);
208 }
XERCES_CPP_NAMESPACE::DOMElement * addParameter(std::string _name, std::string _type, std::string _value)
Definition: LutXml.cc:191

◆ begin()

LutXml::const_iterator LutXml::begin ( ) const

Definition at line 460 of file LutXml.cc.

References lut_map.

460 { return lut_map.begin(); }
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:93

◆ create_lut_map()

int LutXml::create_lut_map ( void  )

Definition at line 352 of file LutXml.cc.

References XMLProcessor::_toXMLCh(), a_to_i(), funct::abs(), brick, FCDTask_cfi::crate, hcalRecHitTable_cff::depth, XMLDOMBlock::document, FCDTask_cfi::fiber, mps_fire::i, hcalRecHitTable_cff::ieta, hcalRecHitTable_cff::iphi, dqmiolumiharvest::j, lut_map, DetId::rawId(), slb(), FCDTask_cfi::slot, subdet_from_crate(), and relval_steps::version.

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

352  {
353  //delete lut_map;
354  lut_map.clear();
355  //lut_map = new std::map<uint32_t,std::vector<unsigned int> >();
356 
357  if (document) {
358  //DOMElement * rootElem =
359  DOMNodeList *brick_list = document->getDocumentElement()->getElementsByTagName(brick);
360  int n_of_bricks = brick_list->getLength();
361  for (int i = 0; i != n_of_bricks; i++) {
362  DOMElement *aBrick = (DOMElement *)(brick_list->item(i));
363  DOMNodeList *par_list = aBrick->getElementsByTagName(XMLString::transcode("Parameter"));
364  int n_of_par = par_list->getLength();
365  int ieta = -99;
366  int iphi = -99;
367  int depth = -99;
368  int crate = -99;
369  int slot = -99;
370  int fiber = -99;
371  int lut_type = -99;
372  int slb = -99;
373  HcalSubdetector subdet;
374  for (int j = 0; j != n_of_par; j++) {
375  DOMElement *aPar = (DOMElement *)(par_list->item(j));
376  char *aName = XMLString::transcode(aPar->getAttribute(XMLProcessor::_toXMLCh("name")));
377  if (strcmp(aName, "IETA") == 0)
378  ieta = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
379  if (strcmp(aName, "IPHI") == 0)
380  iphi = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
381  if (strcmp(aName, "DEPTH") == 0)
382  depth = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
383  if (strcmp(aName, "CRATE") == 0)
384  crate = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
385  if (strcmp(aName, "SLOT") == 0)
386  slot = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
387  if (strcmp(aName, "FIBER") == 0)
388  fiber = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
389  if (strcmp(aName, "LUT_TYPE") == 0)
390  lut_type = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
391  if (strcmp(aName, "SLB") == 0)
392  slb = a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
393  }
394  subdet = subdet_from_crate(crate, slot, fiber);
395  DOMElement *_data = (DOMElement *)(aBrick->getElementsByTagName(XMLString::transcode("Data"))->item(0));
396  char *_str = XMLString::transcode(_data->getFirstChild()->getNodeValue());
397 
398  // get the LUT vector
399  int _string_length = strlen(_str);
400  std::vector<unsigned int> _lut;
401  unsigned int _base = 16;
402  unsigned int _item = 0;
403  for (int i = 0; i != _string_length; i++) {
404  bool _range = false;
405  char ch_cur = _str[i];
406  if (_base == 16)
407  _range = (ch_cur >= '0' and ch_cur <= '9') || (ch_cur >= 'a' and ch_cur <= 'f') ||
408  (ch_cur >= 'A' and ch_cur <= 'F');
409  else if (_base == 10)
410  _range = (ch_cur >= '0' and ch_cur <= '9');
411  if (_range) {
412  if (ch_cur >= 'a' and ch_cur <= 'f')
413  ch_cur += 10 - 'a';
414  else if (ch_cur >= 'A' and ch_cur <= 'F')
415  ch_cur += 10 - 'A';
416  else if (ch_cur >= '0' and ch_cur <= '9')
417  ch_cur += -'0';
418  _item = _item * _base;
419  _item += ch_cur;
420  bool last_digit = false;
421  if ((i + 1) == _string_length)
422  last_digit = true;
423  else {
424  char ch_next = _str[i + 1];
425  bool _range_next = false;
426  if (_base == 16)
427  _range_next = (ch_next >= '0' and ch_next <= '9') || (ch_next >= 'a' and ch_next <= 'f') ||
428  (ch_next >= 'A' and ch_next <= 'F');
429  else if (_base == 10)
430  _range_next = (ch_next >= '0' and ch_next <= '9');
431  if (!_range_next)
432  last_digit = true;
433  }
434  if (last_digit) {
435  _lut.push_back(_item);
436  _item = 0;
437  }
438  }
439  }
440  // filling the map
441  uint32_t _key = 0;
442  if (lut_type == 1) {
443  HcalDetId _id(subdet, ieta, iphi, depth);
444  _key = _id.rawId();
445  } else if (lut_type == 2) {
446  int version = (abs(ieta) > 29 && slb != 12 && crate > 20) ? 1 : 0;
447  HcalTrigTowerDetId _id(ieta, iphi, 10 * version);
448  _key = _id.rawId();
449  } else
450  continue;
451  lut_map.insert(std::pair<uint32_t, std::vector<unsigned int> >(_key, _lut));
452  }
453  } else {
454  edm::LogError("LutXml") << "XML file with LUTs is not loaded, cannot create map!";
455  }
456 
457  return 0;
458 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:117
static int slb(const HcalTriggerPrimitiveSample &theSample)
Log< level::Error, false > LogError
int a_to_i(char *inbuf)
Definition: LutXml.cc:341
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HcalSubdetector subdet_from_crate(int crate, int slot, int fiber)
Definition: LutXml.cc:317
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:93
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:172
XMLCh * brick
Definition: LutXml.h:81

◆ end()

LutXml::const_iterator LutXml::end ( ) const

Definition at line 462 of file LutXml.cc.

References lut_map.

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

462 { return lut_map.end(); }
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:93

◆ find()

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

Definition at line 464 of file LutXml.cc.

References lut_map.

Referenced by dumpLutDiff().

464 { return lut_map.find(id); }
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:93

◆ get_checksum()

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

Definition at line 213 of file LutXml.cc.

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

Referenced by add_checksum(), and addLut().

213  {
214  std::stringstream result;
215  md5_state_t md5er;
216  md5_byte_t digest[16];
217  md5_init(&md5er);
218  // linearizer LUT:
219  if (lut.size() == 128) {
220  unsigned char tool[2];
221  for (int i = 0; i < 128; i++) {
222  tool[0] = lut[i] & 0xFF;
223  tool[1] = (lut[i] >> 8) & 0xFF;
224  md5_append(&md5er, tool, 2);
225  }
226  } else if (lut.size() == 256) {
227  unsigned char tool[2];
228  for (int i = 0; i < 256; i++) {
229  tool[0] = lut[i] & 0xFF;
230  tool[1] = (lut[i] >> 8) & 0xFF;
231  md5_append(&md5er, tool, 2);
232  }
233  }
234  // compression LUT:
235  else if (lut.size() == 1024) {
236  unsigned char tool;
237  for (int i = 0; i < 1024; i++) {
238  tool = lut[i] & 0xFF;
239  md5_append(&md5er, &tool, 1);
240  }
241  } else if (lut.size() == 2048) {
242  unsigned char tool;
243  for (int i = 0; i < 2048; i++) {
244  tool = lut[i] & 0xFF;
245  md5_append(&md5er, &tool, 1);
246  }
247  }
248  // HE fine grain LUT
249  else if (lut.size() == 4096) {
250  unsigned char tool;
251  for (int i = 0; i < 4096; i++) {
252  tool = lut[i] & 0xFF;
253  md5_append(&md5er, &tool, 1);
254  }
255  } else {
256  edm::LogError("LutXml") << "Irregular LUT size, " << lut.size()
257  << " , do not know how to compute checksum, exiting...";
258  exit(-1);
259  }
260  md5_finish(&md5er, digest);
261  for (int i = 0; i < 16; i++)
262  result << std::hex << (((int)(digest[i])) & 0xFF);
263 
264  return result.str();
265 }
Log< level::Error, false > LogError
def exit(msg="")

◆ getCurrentBrick()

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

Definition at line 210 of file LutXml.cc.

References brickElem, and XMLDOMBlock::getString().

210 { return getString(brickElem); }
std::string & getString(void)
Definition: XMLDOMBlock.cc:419
XERCES_CPP_NAMESPACE::DOMElement * brickElem
Definition: LutXml.h:90

◆ getLutFast()

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

Definition at line 74 of file LutXml.cc.

References lut_map.

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

74  {
75  if (lut_map.find(det_id) != lut_map.end())
76  return &(lut_map)[det_id];
77  edm::LogError("LutXml") << "LUT not found, null pointer is returned";
78  return nullptr;
79 }
Log< level::Error, false > LogError
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:93

◆ init()

void LutXml::init ( void  )

Definition at line 68 of file LutXml.cc.

References brick, and brickElem.

Referenced by LutXml().

68  {
69  root = XMLString::transcode("CFGBrickSet");
70  brick = XMLString::transcode("CFGBrick");
71  brickElem = nullptr;
72 }
XMLCh * brick
Definition: LutXml.h:81
XERCES_CPP_NAMESPACE::DOMElement * brickElem
Definition: LutXml.h:90

◆ subdet_from_crate()

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

Definition at line 317 of file LutXml.cc.

References FCDTask_cfi::crate, FCDTask_cfi::fiber, HcalBarrel, HcalEmpty, HcalEndcap, HcalForward, HcalOuter, and FCDTask_cfi::slot.

Referenced by create_lut_map().

317  {
318  // HBHE: 0,1,4,5,10,11,14,15,17 (+20)
319  // HF: 2,9,12 (+20)
320  // HO: 3,6,7,13,18 (+20)
321  int crate = crate_ < 20 ? crate_ : crate_ - 20;
322  if (crate == 2 || crate == 9 || crate == 12)
323  return HcalForward;
324  else if (crate == 3 || crate == 6 || crate == 7 || crate == 13 || crate == 18)
325  return HcalOuter;
326  else if (crate == 0 || crate == 1 || crate == 4 || crate == 5 || crate == 10 || crate == 11 || crate == 14 ||
327  crate == 15 || crate == 17) {
328  if (slot % 3 == 1)
329  return HcalBarrel;
330  else if (slot % 3 == 0)
331  return HcalEndcap;
332  else if (fiber < 12)
333  return HcalBarrel;
334  else
335  return HcalEndcap;
336  }
337  edm::LogWarning("LutXml::subdet_from_crate") << "crate " << crate_ << " is not accounted for";
338  return HcalEmpty;
339 }
Log< level::Warning, false > LogWarning

◆ test_access()

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

Definition at line 267 of file LutXml.cc.

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

267  {
268  edm::LogInfo("LutXml") << "Created map size: " << lut_map.size();
269 
270  struct timeval _t;
271  gettimeofday(&_t, nullptr);
272  double _time = (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0;
273 
274  HcalEmap _emap("./backup/official_emap_v6.04_080905.txt");
275  std::vector<HcalEmap::HcalEmapRow> &_map = _emap.get_map();
276  edm::LogInfo("LutXml") << "HcalEmap contains " << _map.size() << " entries";
277 
278  int _counter = 0;
279  for (std::vector<HcalEmap::HcalEmapRow>::const_iterator row = _map.begin(); row != _map.end(); ++row) {
280  if (row->subdet == "HB") {
281  HcalDetId det_id(HcalBarrel, row->ieta, row->iphi, row->idepth);
282  uint32_t raw_id = det_id.rawId();
283  std::vector<unsigned int> *l = getLutFast(raw_id);
284  if (l)
285  _counter++;
286  }
287  if (row->subdet == "HE") {
288  HcalDetId det_id(HcalEndcap, row->ieta, row->iphi, row->idepth);
289  uint32_t raw_id = det_id.rawId();
290  std::vector<unsigned int> *l = getLutFast(raw_id);
291  if (l)
292  _counter++;
293  }
294  if (row->subdet == "HF") {
295  HcalDetId det_id(HcalForward, row->ieta, row->iphi, row->idepth);
296  uint32_t raw_id = det_id.rawId();
297  std::vector<unsigned int> *l = getLutFast(raw_id);
298  if (l)
299  _counter++;
300  }
301  if (row->subdet == "HO") {
302  HcalDetId det_id(HcalOuter, row->ieta, row->iphi, row->idepth);
303  uint32_t raw_id = det_id.rawId();
304  std::vector<unsigned int> *l = getLutFast(raw_id);
305  if (l)
306  _counter++;
307  }
308  }
309  gettimeofday(&_t, nullptr);
310  edm::LogInfo("LutXml") << "access to " << _counter
311  << " HCAL channels took: " << (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0 - _time
312  << "sec";
313 
314  return 0;
315 }
Log< level::Info, false > LogInfo
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:93
std::vector< unsigned int > * getLutFast(uint32_t det_id)
Definition: LutXml.cc:74

Member Data Documentation

◆ brick

XMLCh* LutXml::brick
protected

Definition at line 81 of file LutXml.h.

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

◆ brickElem

XERCES_CPP_NAMESPACE::DOMElement* LutXml::brickElem
protected

Definition at line 90 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 93 of file LutXml.h.

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

◆ root

XMLCh* LutXml::root
protected

Definition at line 80 of file LutXml.h.