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 eta, int depth)
 
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

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

Definition at line 75 of file LutXml.h.

Constructor & Destructor Documentation

LutXml::LutXml ( )

Definition at line 55 of file LutXml.cc.

References init(), and XMLDOMBlock::XMLDOMBlock().

55  : XMLDOMBlock( "CFGBrickSet", 1 )
56 {
57  init();
58 }
void init(void)
Definition: LutXml.cc:80
LutXml::LutXml ( XERCES_CPP_NAMESPACE::InputSource &  _source)
LutXml::LutXml ( std::string  filename)

Definition at line 67 of file LutXml.cc.

References init().

68 {
69  init();
70 }
void init(void)
Definition: LutXml.cc:80
LutXml::~LutXml ( )
override

Definition at line 73 of file LutXml.cc.

References brick, and fetchall_from_DQM_v2::release.

Member Function Documentation

int LutXml::a_to_i ( char *  inbuf)

Definition at line 372 of file LutXml.cc.

References mps_fire::result.

Referenced by create_lut_map().

372  {
373  int result;
374  sscanf(inbuf,"%d",&result);
375  return result;
376 }
DOMElement * LutXml::add_checksum ( XERCES_CPP_NAMESPACE::DOMDocument *  parent,
Config config 
)
protected

Definition at line 183 of file LutXml.cc.

References XMLProcessor::_toXMLCh(), class-composition::child, LutXml::_Config::crate, LutXml::_Config::fiber, LutXml::_Config::fiberchan, get_checksum(), LutXml::_Config::lut, LutXml::_Config::lut_type, LutXml::_Config::slot, and LutXml::_Config::topbottom.

Referenced by addLut().

184 {
185  DOMElement * child = parent -> createElement( XMLProcessor::_toXMLCh( "Data" ) );
186  child -> setAttribute( XMLProcessor::_toXMLCh("crate"), XMLProcessor::_toXMLCh( config.crate ) );
187  child -> setAttribute( XMLProcessor::_toXMLCh("slot"), XMLProcessor::_toXMLCh( config.slot ) );
188  child -> setAttribute( XMLProcessor::_toXMLCh("fpga"), XMLProcessor::_toXMLCh( config.topbottom ) );
189  child -> setAttribute( XMLProcessor::_toXMLCh("fiber"), XMLProcessor::_toXMLCh( config.fiber ) );
190  child -> setAttribute( XMLProcessor::_toXMLCh("fiberchan"), XMLProcessor::_toXMLCh( config.fiberchan ) );
191  child -> setAttribute( XMLProcessor::_toXMLCh("luttype"), XMLProcessor::_toXMLCh( config.lut_type ) );
192  child -> setAttribute( XMLProcessor::_toXMLCh("elements"), XMLProcessor::_toXMLCh( "1" ) );
193  child -> setAttribute( XMLProcessor::_toXMLCh("encoding"), XMLProcessor::_toXMLCh( "hex" ) );
194  DOMText * checksum_value = parent -> createTextNode( XMLProcessor::_toXMLCh( get_checksum(config.lut) ));
195  child -> appendChild( checksum_value );
196 
197  parent -> getDocumentElement() -> appendChild( child );
198 
199  return child;
200 }
Definition: config.py:1
static std::string get_checksum(std::vector< unsigned int > &lut)
Definition: LutXml.cc:238
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:183
template<typename T >
XERCES_CPP_NAMESPACE::DOMElement* LutXml::addData ( std::string  _elements,
std::string  _encoding,
const T _lut 
)
protected

Referenced by addLut().

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

Definition at line 158 of file LutXml.cc.

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

159 {
160  DOMElement * child = document -> createElement( XMLProcessor::_toXMLCh( "Data" ) );
161  child -> setAttribute( XMLProcessor::_toXMLCh("elements"), XMLProcessor::_toXMLCh( _elements ) );
162  child -> setAttribute( XMLProcessor::_toXMLCh("encoding"), XMLProcessor::_toXMLCh( _encoding ) );
163 
164  std::stringstream buf;
165 
166  for (const auto& iter : _lut){
167  char buf2[16];
168  sprintf(buf2,"%lx",uint64_t(iter));
169  buf << buf2 << " ";
170  }
171 
172  std::string _value = buf . str();
173 
174  DOMText * data_value = document -> createTextNode( XMLProcessor::_toXMLCh(_value));
175  child -> appendChild( data_value );
176 
177  brickElem -> appendChild( child );
178 
179  return child;
180 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
unsigned long long uint64_t
Definition: Time.h:15
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:183
#define str(s)
XERCES_CPP_NAMESPACE::DOMElement * brickElem
Definition: LutXml.h:92
void LutXml::addLut ( LutXml::Config _config,
XMLDOMBlock checksums_xml = nullptr 
)

Definition at line 97 of file LutXml.cc.

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::iphi, LutXml::_Config::lut, LutXml::_Config::lut_type, LutXml::_Config::mask, LutXml::_Config::slot, LutXml::_Config::targetfirmware, and LutXml::_Config::topbottom.

98 {
99  DOMElement * rootElem = document -> getDocumentElement();
100 
101  brickElem = document->createElement( XMLProcessor::_toXMLCh("CFGBrick") );
102  rootElem->appendChild(brickElem);
103 
104  addParameter( "CREATIONTAG", "string", _config.creationtag );
105  addParameter( "CREATIONSTAMP", "string", _config.creationstamp );
106  addParameter( "FORMATREVISION", "string", _config.formatrevision );
107  addParameter( "TARGETFIRMWARE", "string", _config.targetfirmware );
108  addParameter( "GENERALIZEDINDEX", "int", _config.generalizedindex );
109  addParameter( "CRATE", "int", _config.crate );
110  addParameter( "SLOT", "int", _config.slot );
111 
112  if(checksums_xml) {
113  addParameter( "CHECKSUM", "string", get_checksum( _config.lut ) );
114  }
115 
116  if(_config.lut_type==1){ // linearizer LUT
117  addParameter( "IETA", "int", _config.ieta );
118  addParameter( "IPHI", "int", _config.iphi );
119  addParameter( "TOPBOTTOM", "int", _config.topbottom );
120  addParameter( "LUT_TYPE", "int", _config.lut_type );
121  addParameter( "FIBER", "int", _config.fiber );
122  addParameter( "FIBERCHAN", "int", _config.fiberchan );
123  addParameter( "DEPTH", "int", _config.depth );
124  addData( to_string(_config.lut.size()), "hex", _config.lut );
125  }
126  else if(_config.lut_type==2 || _config.lut_type==4){ // compression LUT or HE feature bit LUT
127  addParameter( "IETA", "int", _config.ieta );
128  addParameter( "IPHI", "int", _config.iphi );
129  addParameter( "TOPBOTTOM", "int", _config.topbottom );
130  addParameter( "LUT_TYPE", "int", _config.lut_type );
131  addParameter( "SLB", "int", _config.fiber );
132  addParameter( "SLBCHAN", "int", _config.fiberchan );
133  addData( to_string(_config.lut.size()), "hex", _config.lut );
134  }
135  else if(_config.lut_type==5){ // channel masks
136  addParameter( "MASK_TYPE", "string", "TRIGGERCHANMASK" );
137  addData( to_string(_config.mask.size()), "hex", _config.mask );
138  }
139  else if(_config.lut_type==6){ // adc threshold for tdc mask
140  addParameter( "THRESH_TYPE", "string", "TRIGINTIME" );
141  addData( to_string(_config.mask.size()), "hex", _config.mask );
142  }
143  else if(_config.lut_type==7){ // tdc mask
144  addParameter( "TDCMAP_TYPE", "string", "TRIGINTIME" );
145  addData( to_string(_config.mask.size()), "hex", _config.mask );
146  }
147  else{
148  edm::LogError("LutXml") << "Unknown LUT type...produced XML will be incorrect";
149  }
150 
151 
152  if(checksums_xml) {
153  add_checksum( checksums_xml->getDocument(), _config );
154  }
155 }
XERCES_CPP_NAMESPACE::DOMElement * addParameter(std::string _name, std::string _type, std::string _value)
Definition: LutXml.cc:204
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
std::string targetfirmware
Definition: LutXml.h:39
int generalizedindex
Definition: LutXml.h:40
XERCES_CPP_NAMESPACE::DOMElement * add_checksum(XERCES_CPP_NAMESPACE::DOMDocument *parent, Config &config)
Definition: LutXml.cc:183
XERCES_CPP_NAMESPACE::DOMElement * addData(std::string _elements, std::string _encoding, const T &_lut)
int topbottom
Definition: LutXml.h:35
std::vector< unsigned int > lut
Definition: LutXml.h:41
std::string creationtag
Definition: LutXml.h:36
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:312
static std::string get_checksum(std::vector< unsigned int > &lut)
Definition: LutXml.cc:238
std::string formatrevision
Definition: LutXml.h:38
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:183
XERCES_CPP_NAMESPACE::DOMElement * brickElem
Definition: LutXml.h:92
int lut_type
Definition: LutXml.h:35
std::string creationstamp
Definition: LutXml.h:37
int fiberchan
Definition: LutXml.h:35
std::vector< uint64_t > mask
Definition: LutXml.h:42
DOMElement * LutXml::addParameter ( std::string  _name,
std::string  _type,
std::string  _value 
)
protected

Definition at line 204 of file LutXml.cc.

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

Referenced by editorTools.UserCodeTool::__init__(), trackTools.MakeAODTrackCandidates::__init__(), metTools.AddMETCollection::__init__(), HiCoreTools.RestrictInputToAOD::__init__(), coreTools.RunOnData::__init__(), runJetUncertainties.RunJetUncertainties::__init__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::__init__(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool::__init__(), editorTools.ChangeSource::__init__(), cmsswVersionTools.PickRelValInputFiles::__init__(), HiCoreTools.RemoveMCMatching::__init__(), coreTools.RemoveMCMatching::__init__(), trackTools.MakePATTrackCandidates::__init__(), trigTools.SwitchOnTrigger::__init__(), HiCoreTools.RemoveAllPATObjectsBut::__init__(), HiCoreTools.RemoveSpecificPATObjects::__init__(), trigTools.SwitchOnTriggerStandAlone::__init__(), trackTools.MakeTrackCandidates::__init__(), tauTools.AddTauCollection::__init__(), trigTools.SwitchOnTriggerMatching::__init__(), HiCoreTools.RemoveCleaning::__init__(), HiCoreTools.AddCleaning::__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().

205 {
206  DOMElement * child = document -> createElement( XMLProcessor::_toXMLCh( "Parameter" ) );
207  child -> setAttribute( XMLProcessor::_toXMLCh("name"), XMLProcessor::_toXMLCh( _name ) );
208  child -> setAttribute( XMLProcessor::_toXMLCh("type"), XMLProcessor::_toXMLCh( _type ) );
209  DOMText * parameter_value = document -> createTextNode( XMLProcessor::_toXMLCh(_value));
210  child -> appendChild( parameter_value );
211 
212  brickElem -> appendChild( child );
213 
214  return child;
215 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:183
XERCES_CPP_NAMESPACE::DOMElement * brickElem
Definition: LutXml.h:92
DOMElement * LutXml::addParameter ( std::string  _name,
std::string  _type,
int  _value 
)
protected

Definition at line 219 of file LutXml.cc.

References addParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by editorTools.UserCodeTool::__init__(), metTools.AddMETCollection::__init__(), trackTools.MakeAODTrackCandidates::__init__(), coreTools.RunOnData::__init__(), HiCoreTools.RestrictInputToAOD::__init__(), runJetUncertainties.RunJetUncertainties::__init__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::__init__(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool::__init__(), editorTools.ChangeSource::__init__(), cmsswVersionTools.PickRelValInputFiles::__init__(), HiCoreTools.RemoveMCMatching::__init__(), coreTools.RemoveMCMatching::__init__(), trackTools.MakePATTrackCandidates::__init__(), trigTools.SwitchOnTrigger::__init__(), HiCoreTools.RemoveAllPATObjectsBut::__init__(), HiCoreTools.RemoveSpecificPATObjects::__init__(), trigTools.SwitchOnTriggerStandAlone::__init__(), trackTools.MakeTrackCandidates::__init__(), tauTools.AddTauCollection::__init__(), trigTools.SwitchOnTriggerMatching::__init__(), HiCoreTools.RemoveCleaning::__init__(), HiCoreTools.AddCleaning::__init__(), trigTools.SwitchOnTriggerMatchingStandAlone::__init__(), trigTools.SwitchOnTriggerMatchEmbedding::__init__(), jetTools.AddJetCollection::__init__(), jetTools.SwitchJetCollection::__init__(), jetTools.UpdateJetCollection::__init__(), jetTools.AddJetID::__init__(), and jetTools.SetTagInfos::__init__().

220 {
221  char buf[128];
222  sprintf(buf, "%d", _value);
223  std::string str_value = buf;
224  return addParameter( _name, _type, str_value );
225 }
XERCES_CPP_NAMESPACE::DOMElement * addParameter(std::string _name, std::string _type, std::string _value)
Definition: LutXml.cc:204
LutXml::const_iterator LutXml::begin ( ) const

Definition at line 472 of file LutXml.cc.

References lut_map.

472  {
473  return lut_map.begin();
474 }
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:95
int LutXml::create_lut_map ( void  )

Definition at line 383 of file LutXml.cc.

References electrons_cff::_id, XMLProcessor::_toXMLCh(), a_to_i(), funct::abs(), brick, egammaForCoreTracking_cff::depth, XMLDOMBlock::document, mps_fire::i, lut_map, DetId::rawId(), slb(), subdet_from_crate(), and jets_cff::version.

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

383  {
384  //delete lut_map;
385  lut_map.clear();
386  //lut_map = new std::map<uint32_t,std::vector<unsigned int> >();
387 
388  if (document){
389  //DOMElement * rootElem =
390  DOMNodeList * brick_list = document->getDocumentElement()->getElementsByTagName(brick);
391  int n_of_bricks = brick_list->getLength();
392  for(int i=0; i!=n_of_bricks; i++){
393  DOMElement * aBrick = (DOMElement *)(brick_list->item(i));
394  DOMNodeList * par_list = aBrick->getElementsByTagName(XMLString::transcode("Parameter"));
395  int n_of_par = par_list->getLength();
396  int ieta=-99;
397  int iphi=-99;
398  int depth=-99;
399  int crate=-99;
400  int lut_type=-99;
401  int slb=-99;
402  HcalSubdetector subdet;
403  for(int j=0; j!=n_of_par; j++){
404  DOMElement * aPar = (DOMElement *)(par_list->item(j));
405  char * aName = XMLString::transcode( aPar->getAttribute(XMLProcessor::_toXMLCh("name")) );
406  if ( strcmp(aName, "IETA")==0 ) ieta=a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
407  if ( strcmp(aName, "IPHI")==0 ) iphi=a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
408  if ( strcmp(aName, "DEPTH")==0 ) depth=a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
409  if ( strcmp(aName, "CRATE")==0 ) crate=a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
410  if ( strcmp(aName, "LUT_TYPE")==0 ) lut_type=a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
411  if ( strcmp(aName, "SLB")==0 ) slb=a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
412  }
413  subdet=subdet_from_crate(crate,abs(ieta),depth);
414  DOMElement * _data = (DOMElement *)(aBrick->getElementsByTagName(XMLString::transcode("Data"))->item(0));
415  char * _str = XMLString::transcode(_data->getFirstChild()->getNodeValue());
416 
417  // get the LUT vector
418  int _string_length = strlen(_str);
419  std::vector<unsigned int> _lut;
420  unsigned int _base = 16;
421  unsigned int _item=0;
422  for (int i=0; i!=_string_length; i++){
423  bool _range = false;
424  char ch_cur = _str[i];
425  if (_base==16) _range = (ch_cur>='0' and ch_cur<='9') || (ch_cur>='a' and ch_cur<='f') || (ch_cur>='A' and ch_cur<='F');
426  else if (_base==10) _range = (ch_cur>='0' and ch_cur<='9');
427  if ( _range ){
428  if ( ch_cur>='a' and ch_cur<='f' ) ch_cur += 10-'a';
429  else if ( ch_cur>='A' and ch_cur<='F' ) ch_cur += 10-'A';
430  else if ( ch_cur>='0' and ch_cur<='9' ) ch_cur += -'0';
431  _item = _item*_base;
432  _item += ch_cur;
433  bool last_digit = false;
434  if ( (i+1)==_string_length ) last_digit=true;
435  else{
436  char ch_next = _str[i+1];
437  bool _range_next = false;
438  if (_base==16) _range_next = (ch_next>='0' and ch_next<='9') || (ch_next>='a' and ch_next<='f') || (ch_next>='A' and ch_next<='F');
439  else if (_base==10) _range_next = (ch_next>='0' and ch_next<='9');
440  if ( !_range_next ) last_digit=true;
441  }
442  if (last_digit){
443  _lut.push_back(_item);
444  _item=0;
445  }
446  }
447  }
448  // filling the map
449  uint32_t _key = 0;
450  if (lut_type==1){
451  HcalDetId _id(subdet,ieta,iphi,depth);
452  _key = _id.rawId();
453  }
454  else if (lut_type==2){
455  int version=( abs(ieta)>29 && slb!=12 && crate>20) ? 1: 0;
456  HcalTrigTowerDetId _id(ieta,iphi,10*version);
457  _key = _id.rawId();
458  }
459  else continue;
460  lut_map.insert(std::pair<uint32_t,std::vector<unsigned int> >(_key,_lut));
461  }
462  }
463  else{
464  edm::LogError("LutXml") << "XML file with LUTs is not loaded, cannot create map!";
465  }
466 
467 
468 
469  return 0;
470 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
HcalSubdetector subdet_from_crate(int crate, int eta, int depth)
Definition: LutXml.cc:344
static int slb(const HcalTriggerPrimitiveSample &theSample)
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:95
int a_to_i(char *inbuf)
Definition: LutXml.cc:372
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:183
XMLCh * brick
Definition: LutXml.h:83
LutXml::const_iterator LutXml::end ( ) const

Definition at line 476 of file LutXml.cc.

References lut_map.

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

476  {
477  return lut_map.end();
478 }
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:95
LutXml::const_iterator LutXml::find ( uint32_t  id) const

Definition at line 480 of file LutXml.cc.

References lut_map.

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

480  {
481  return lut_map.find(id);
482 }
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:95
std::string LutXml::get_checksum ( std::vector< unsigned int > &  lut)
static

Definition at line 238 of file LutXml.cc.

References cmsRelvalreport::exit, mps_fire::i, mps_fire::result, findQualityFiles::size, and str.

Referenced by add_checksum(), and addLut().

239 {
240  std::stringstream result;
241  md5_state_t md5er;
242  md5_byte_t digest[16];
243  md5_init(&md5er);
244  // linearizer LUT:
245  if ( lut . size() == 128){
246  unsigned char tool[2];
247  for (int i=0; i<128; i++) {
248  tool[0]=lut[i]&0xFF;
249  tool[1]=(lut[i]>>8)&0xFF;
250  md5_append(&md5er,tool,2);
251  }
252  }
253  else if ( lut . size() == 256){
254  unsigned char tool[2];
255  for (int i=0; i<256; i++) {
256  tool[0]=lut[i]&0xFF;
257  tool[1]=(lut[i]>>8)&0xFF;
258  md5_append(&md5er,tool,2);
259  }
260  }
261  // compression LUT:
262  else if ( lut . size() == 1024 ){
263  unsigned char tool;
264  for (int i=0; i<1024; i++) {
265  tool=lut[i]&0xFF;
266  md5_append(&md5er,&tool,1);
267  }
268  }
269  else if ( lut . size() == 2048 ){
270  unsigned char tool;
271  for (int i=0; i<2048; i++) {
272  tool=lut[i]&0xFF;
273  md5_append(&md5er,&tool,1);
274  }
275  }
276  // HE fine grain LUT
277  else if ( lut . size() == 4096){
278  unsigned char tool;
279  for (int i=0; i<4096; i++) {
280  tool=lut[i]&0xFF;
281  md5_append(&md5er,&tool,1);
282  }
283  }
284  else{
285 
286  edm::LogError("LutXml") << "Irregular LUT size, "<< lut.size() << " , do not know how to compute checksum, exiting...";
287  exit(-1);
288  }
289  md5_finish(&md5er,digest);
290  for (int i=0; i<16; i++) result << std::hex << (((int)(digest[i]))&0xFF);
291 
292 
293  return result . str();
294 }
size
Write out results.
#define str(s)
std::string & LutXml::getCurrentBrick ( void  )

Definition at line 230 of file LutXml.cc.

References brickElem, and XMLDOMBlock::getString().

231 {
232  return getString( brickElem );
233 }
std::string & getString(void)
Definition: XMLDOMBlock.cc:459
XERCES_CPP_NAMESPACE::DOMElement * brickElem
Definition: LutXml.h:92
std::vector< unsigned int > * LutXml::getLutFast ( uint32_t  det_id)

Definition at line 88 of file LutXml.cc.

References lut_map.

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

88  {
89  if (lut_map.find(det_id) != lut_map.end()) return &(lut_map)[det_id];
90  edm::LogError("LutXml") << "LUT not found, null pointer is returned";
91  return nullptr;
92 }
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:95
void LutXml::init ( void  )

Definition at line 80 of file LutXml.cc.

References brick, and brickElem.

Referenced by LutXml().

81 {
82  root = XMLString::transcode("CFGBrickSet");
83  brick = XMLString::transcode("CFGBrick");
84  brickElem = nullptr;
85 }
XMLCh * brick
Definition: LutXml.h:83
XERCES_CPP_NAMESPACE::DOMElement * brickElem
Definition: LutXml.h:92
HcalSubdetector LutXml::subdet_from_crate ( int  crate,
int  eta,
int  depth 
)

Definition at line 344 of file LutXml.cc.

References cmsRelvalreport::exit, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, and mps_fire::result.

Referenced by create_lut_map().

344  {
346  // HBHE: 0,1,4,5,10,11,14,15,17
347  // HF: 2,9,12
348  // HO: 3,6,7,13
349  int crate=crate_<20? crate_ : crate_-20;
350 
351  if (crate==2 || crate==9 || crate==12) result=HcalForward;
352  else if (crate==3 || crate==6 || crate==7 || crate==13) result=HcalOuter;
353  else if (crate==0 || crate==1 || crate==4 || crate==5 || crate==10 || crate==11 || crate==14 || crate==15 || crate==17){
354  if (eta<16) result=HcalBarrel;
355  else if (eta>16) result=HcalEndcap;
356  else if (eta==16 && depth<3) result=HcalBarrel;
357  else if (eta==16 && depth>=3) result=HcalEndcap;
358  else{
359  edm::LogError("LutXml") << "Impossible to determine HCAL subdetector!!!";
360  exit(-1);
361  }
362  }
363  else{
364  edm::LogError("LutXml") << "Impossible to determine HCAL subdetector!!!";
365  exit(-1);
366  }
367 
368  return result;
369 }
HcalSubdetector
Definition: HcalAssistant.h:31
int LutXml::test_access ( std::string  filename)

Definition at line 297 of file LutXml.cc.

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

297  {
298 
299  edm::LogInfo("LutXml") << "Created map size: " << lut_map.size();
300 
301  struct timeval _t;
302  gettimeofday( &_t, nullptr );
303  double _time =(double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0;
304 
305  HcalEmap _emap("./backup/official_emap_v6.04_080905.txt");
306  std::vector<HcalEmap::HcalEmapRow> & _map = _emap.get_map();
307  edm::LogInfo("LutXml") << "HcalEmap contains " << _map . size() << " entries";
308 
309  int _counter=0;
310  for (std::vector<HcalEmap::HcalEmapRow>::const_iterator row=_map.begin(); row!=_map.end(); ++row){
311  if (row->subdet=="HB"){
312  HcalDetId det_id(HcalBarrel,row->ieta,row->iphi,row->idepth);
313  uint32_t raw_id = det_id.rawId();
314  std::vector<unsigned int> * l = getLutFast(raw_id);
315  if (l) _counter++;
316  }
317  if (row->subdet=="HE"){
318  HcalDetId det_id(HcalEndcap,row->ieta,row->iphi,row->idepth);
319  uint32_t raw_id = det_id.rawId();
320  std::vector<unsigned int> * l = getLutFast(raw_id);
321  if (l) _counter++;
322  }
323  if (row->subdet=="HF"){
324  HcalDetId det_id(HcalForward,row->ieta,row->iphi,row->idepth);
325  uint32_t raw_id = det_id.rawId();
326  std::vector<unsigned int> * l = getLutFast(raw_id);
327  if (l) _counter++;
328  }
329  if (row->subdet=="HO"){
330  HcalDetId det_id(HcalOuter,row->ieta,row->iphi,row->idepth);
331  uint32_t raw_id = det_id.rawId();
332  std::vector<unsigned int> * l = getLutFast(raw_id);
333  if (l) _counter++;
334  }
335  }
336  gettimeofday( &_t, nullptr );
337  edm::LogInfo("LutXml") << "access to " << _counter << " HCAL channels took: " << (double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0 - _time << "sec";
338 
339 
340  return 0;
341 }
size
Write out results.
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:95
std::vector< unsigned int > * getLutFast(uint32_t det_id)
Definition: LutXml.cc:88

Member Data Documentation

XMLCh* LutXml::brick
protected

Definition at line 83 of file LutXml.h.

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

XERCES_CPP_NAMESPACE::DOMElement* LutXml::brickElem
protected

Definition at line 92 of file LutXml.h.

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

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

Definition at line 95 of file LutXml.h.

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

XMLCh* LutXml::root
protected

Definition at line 82 of file LutXml.h.