CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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=0)
 
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 (InputSource &_source)
 
 LutXml (std::string filename)
 
HcalSubdetector subdet_from_crate (int crate, int eta, int depth)
 
int test_access (std::string filename)
 
virtual ~LutXml ()
 
- Public Member Functions inherited from XMLDOMBlock
DOMElement * add_element (DOMElement *parent, XMLCh *tagname, XMLCh *value)
 
DOMDocument * getDocument (void)
 
DOMDocument * getDocumentConst (void) const
 
DOMDocument * getNewDocument (std::string xmlFileName)
 
std::string & getString (void)
 
std::string & getString (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, DOMDocument *_document=NULL)
 
const char * getTagValue (const std::string &tagName, int _item, DOMElement *_document)
 
std::string getTimestamp (time_t _time)
 
XMLDOMBlockoperator+= (const XMLDOMBlock &other)
 
void parse (InputSource &_source)
 
DOMNode * setTagAttribute (const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
 
DOMNode * setTagAttribute (DOMElement *_elem, const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
 
DOMNode * setTagAttribute (const std::string &tagName, const std::string &attrName, const int &attrValue, int _item=0)
 
DOMNode * setTagAttribute (DOMElement *_elem, const std::string &tagName, const std::string &attrName, const int &attrValue, int _item=0)
 
DOMNode * setTagValue (const std::string &tagName, const std::string &tagValue, int _item=0, DOMDocument *_document=NULL)
 
DOMNode * setTagValue (DOMElement *_elem, const std::string &tagName, const std::string &tagValue, int _item=0)
 
DOMNode * setTagValue (const std::string &tagName, const int &tagValue, int _item=0, DOMDocument *_document=NULL)
 
DOMNode * setTagValue (DOMElement *_elem, const std::string &tagName, const int &tagValue, int _item=0)
 
int write (std::string target="stdout")
 
 XMLDOMBlock ()
 
 XMLDOMBlock (std::string xmlFileName)
 
 XMLDOMBlock (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

DOMElement * add_checksum (DOMDocument *parent, Config &config)
 
DOMElement * addData (std::string _elements, std::string _encoding, const std::vector< unsigned int > &_lut)
 
DOMElement * addParameter (std::string _name, std::string _type, std::string _value)
 
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
 
DOMElement * brickElem
 
std::map< uint32_t,
std::vector< unsigned int > > 
lut_map
 
XMLCh * root
 
- Protected Attributes inherited from XMLDOMBlock
DOMDocument * document
 
ErrorHandler * errHandler
 
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 74 of file LutXml.h.

Constructor & Destructor Documentation

LutXml::LutXml ( )

Definition at line 90 of file LutXml.cc.

References init().

90  : XMLDOMBlock( "CFGBrickSet", 1 )
91 {
92  init();
93 }
void init(void)
Definition: LutXml.cc:117
LutXml::LutXml ( InputSource _source)

Definition at line 96 of file LutXml.cc.

References init().

96  : XMLDOMBlock( _source )
97 {
98  init();
99 }
void init(void)
Definition: LutXml.cc:117
LutXml::LutXml ( std::string  filename)

Definition at line 102 of file LutXml.cc.

References init().

102  : XMLDOMBlock( filename )
103 {
104  init();
105 }
void init(void)
Definition: LutXml.cc:117
tuple filename
Definition: lut2db_cfg.py:20
LutXml::~LutXml ( )
virtual

Definition at line 108 of file LutXml.cc.

References brick, fetchall_from_DQM_v2::release, and root.

109 {
110  //delete brickElem; // belongs to document that belongs to parser???
113  //delete lut_map;
114 }
XMLCh * root
Definition: LutXml.h:81
XMLCh * brick
Definition: LutXml.h:82

Member Function Documentation

int LutXml::a_to_i ( char *  inbuf)

Definition at line 485 of file LutXml.cc.

References query::result.

Referenced by create_lut_map().

485  {
486  int result;
487  sscanf(inbuf,"%d",&result);
488  return result;
489 }
tuple result
Definition: query.py:137
DOMElement * LutXml::add_checksum ( DOMDocument *  parent,
Config config 
)
protected

Definition at line 279 of file LutXml.cc.

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

280 {
281  //template
282  // <Data crate='0' slot='2' fpga='1' fiber='1' fiberchan='0' luttype='1' elements='1' encoding='hex'>c6cf91b39e3bff21623fb7366efda1fd</Data>
283  //
284  DOMElement * child = parent -> createElement( XMLProcessor::_toXMLCh( "Data" ) );
285  child -> setAttribute( XMLProcessor::_toXMLCh("crate"), XMLProcessor::_toXMLCh( config.crate ) );
286  child -> setAttribute( XMLProcessor::_toXMLCh("slot"), XMLProcessor::_toXMLCh( config.slot ) );
287  child -> setAttribute( XMLProcessor::_toXMLCh("fpga"), XMLProcessor::_toXMLCh( config.topbottom ) );
288  child -> setAttribute( XMLProcessor::_toXMLCh("fiber"), XMLProcessor::_toXMLCh( config.fiber ) );
289  child -> setAttribute( XMLProcessor::_toXMLCh("fiberchan"), XMLProcessor::_toXMLCh( config.fiberchan ) );
290  child -> setAttribute( XMLProcessor::_toXMLCh("luttype"), XMLProcessor::_toXMLCh( config.lut_type ) );
291  child -> setAttribute( XMLProcessor::_toXMLCh("elements"), XMLProcessor::_toXMLCh( "1" ) );
292  child -> setAttribute( XMLProcessor::_toXMLCh("encoding"), XMLProcessor::_toXMLCh( "hex" ) );
293  DOMText * checksum_value = parent -> createTextNode( XMLProcessor::_toXMLCh( get_checksum(config.lut) ));
294  child -> appendChild( checksum_value );
295 
296  parent -> getDocumentElement() -> appendChild( child );
297 
298  return child;
299 }
list parent
Definition: dbtoconf.py:74
static std::string get_checksum(std::vector< unsigned int > &lut)
Definition: LutXml.cc:337
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:184
DOMElement * LutXml::addData ( std::string  _elements,
std::string  _encoding,
const std::vector< unsigned int > &  _lut 
)
protected

Definition at line 252 of file LutXml.cc.

References XMLProcessor::_toXMLCh(), brickElem, XMLDOMBlock::document, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by addLut().

253 {
254  DOMElement * child = document -> createElement( XMLProcessor::_toXMLCh( "Data" ) );
255  child -> setAttribute( XMLProcessor::_toXMLCh("elements"), XMLProcessor::_toXMLCh( _elements ) );
256  child -> setAttribute( XMLProcessor::_toXMLCh("encoding"), XMLProcessor::_toXMLCh( _encoding ) );
257 
258  std::stringstream buf;
259 
260  for (std::vector<unsigned int>::const_iterator iter = _lut.begin();iter!=_lut.end();iter++){
261  char buf2[8];
262  sprintf(buf2,"%x",(*iter));
263  buf << buf2 << " ";
264  //buf << (*iter) << " ";
265  }
266 
267  std::string _value = buf . str();
268 
269  DOMText * data_value = document -> createTextNode( XMLProcessor::_toXMLCh(_value));
270  child -> appendChild( data_value );
271 
272  brickElem -> appendChild( child );
273 
274  return child;
275 }
DOMDocument * document
Definition: XMLDOMBlock.h:97
DOMElement * brickElem
Definition: LutXml.h:89
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:184
void LutXml::addLut ( LutXml::Config _config,
XMLDOMBlock checksums_xml = 0 
)

Definition at line 209 of file LutXml.cc.

References XMLProcessor::_toXMLCh(), add_checksum(), addData(), addParameter(), brickElem, gather_cfg::cout, 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::slot, LutXml::_Config::targetfirmware, and LutXml::_Config::topbottom.

210 {
211  DOMElement * rootElem = document -> getDocumentElement();
212 
213  brickElem = document->createElement( XMLProcessor::_toXMLCh("CFGBrick") );
214  rootElem->appendChild(brickElem);
215 
216  addParameter( "IETA", "int", _config.ieta );
217  addParameter( "IPHI", "int", _config.iphi );
218  addParameter( "CRATE", "int", _config.crate );
219  addParameter( "SLOT", "int", _config.slot );
220  addParameter( "TOPBOTTOM", "int", _config.topbottom );
221  addParameter( "LUT_TYPE", "int", _config.lut_type );
222  addParameter( "CREATIONTAG", "string", _config.creationtag );
223  addParameter( "CREATIONSTAMP", "string", _config.creationstamp );
224  addParameter( "FORMATREVISION", "string", _config.formatrevision );
225  addParameter( "TARGETFIRMWARE", "string", _config.targetfirmware );
226  addParameter( "GENERALIZEDINDEX", "int", _config.generalizedindex );
227  addParameter( "CHECKSUM", "string", get_checksum( _config.lut ) );
228 
229  if(_config.lut_type==1){ // linearizer LUT
230  addParameter( "FIBER", "int", _config.fiber );
231  addParameter( "FIBERCHAN", "int", _config.fiberchan );
232  addParameter( "DEPTH", "int", _config.depth );
233  addData( "128", "hex", _config.lut );
234  }
235  else if(_config.lut_type==2){ // compression LUT
236  addParameter( "SLB", "int", _config.fiber );
237  addParameter( "SLBCHAN", "int", _config.fiberchan );
238  addData( "1024", "hex", _config.lut );
239  }
240  else{
241  std::cout << "Unknown LUT type...produced XML will be incorrect" << std::endl;
242  }
243 
244  // if the pointer to the checksums XML was given,
245  // add the checksum to it
246  // checksums_xml is 0 unless explicitely given
247  if ( checksums_xml ){
248  add_checksum( checksums_xml->getDocument(), _config );
249  }
250 }
DOMElement * addParameter(std::string _name, std::string _type, std::string _value)
Definition: LutXml.cc:303
std::string targetfirmware
Definition: LutXml.h:39
DOMDocument * document
Definition: XMLDOMBlock.h:97
int generalizedindex
Definition: LutXml.h:40
int topbottom
Definition: LutXml.h:35
std::vector< unsigned int > lut
Definition: LutXml.h:41
std::string creationtag
Definition: LutXml.h:36
DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:312
static std::string get_checksum(std::vector< unsigned int > &lut)
Definition: LutXml.cc:337
DOMElement * add_checksum(DOMDocument *parent, Config &config)
Definition: LutXml.cc:279
std::string formatrevision
Definition: LutXml.h:38
DOMElement * addData(std::string _elements, std::string _encoding, const std::vector< unsigned int > &_lut)
Definition: LutXml.cc:252
DOMElement * brickElem
Definition: LutXml.h:89
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:184
tuple cout
Definition: gather_cfg.py:121
int lut_type
Definition: LutXml.h:35
std::string creationstamp
Definition: LutXml.h:37
int fiberchan
Definition: LutXml.h:35
DOMElement * LutXml::addParameter ( std::string  _name,
std::string  _type,
std::string  _value 
)
protected

Definition at line 303 of file LutXml.cc.

References XMLProcessor::_toXMLCh(), brickElem, and XMLDOMBlock::document.

Referenced by editorTools.UserCodeTool::__init__(), metTools.AddMETCollection::__init__(), trackTools.MakeAODTrackCandidates::__init__(), coreTools.RunOnData::__init__(), HiCoreTools.RestrictInputToAOD::__init__(), metUncertaintyTools.RunMEtUncertainties::__init__(), jetTools.AddJetCollection::__init__(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool::__init__(), editorTools.ChangeSource::__init__(), HiCoreTools.RemoveMCMatching::__init__(), cmsswVersionTools.PickRelValInputFiles::__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__(), jetTools.SwitchJetCollection::__init__(), trigTools.SwitchOnTriggerMatchEmbedding::__init__(), jetTools.AddJetID::__init__(), jetTools.SetTagInfos::__init__(), addLut(), and addParameter().

304 {
305  DOMElement * child = document -> createElement( XMLProcessor::_toXMLCh( "Parameter" ) );
306  child -> setAttribute( XMLProcessor::_toXMLCh("name"), XMLProcessor::_toXMLCh( _name ) );
307  child -> setAttribute( XMLProcessor::_toXMLCh("type"), XMLProcessor::_toXMLCh( _type ) );
308  DOMText * parameter_value = document -> createTextNode( XMLProcessor::_toXMLCh(_value));
309  child -> appendChild( parameter_value );
310 
311  brickElem -> appendChild( child );
312 
313  return child;
314 }
DOMDocument * document
Definition: XMLDOMBlock.h:97
DOMElement * brickElem
Definition: LutXml.h:89
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:184
DOMElement * LutXml::addParameter ( std::string  _name,
std::string  _type,
int  _value 
)
protected

Definition at line 318 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__(), metUncertaintyTools.RunMEtUncertainties::__init__(), jetTools.AddJetCollection::__init__(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool::__init__(), editorTools.ChangeSource::__init__(), HiCoreTools.RemoveMCMatching::__init__(), cmsswVersionTools.PickRelValInputFiles::__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__(), jetTools.SwitchJetCollection::__init__(), trigTools.SwitchOnTriggerMatchEmbedding::__init__(), jetTools.AddJetID::__init__(), and jetTools.SetTagInfos::__init__().

319 {
320  char buf[128];
321  sprintf(buf, "%d", _value);
322  std::string str_value = buf;
323  return addParameter( _name, _type, str_value );
324 }
DOMElement * addParameter(std::string _name, std::string _type, std::string _value)
Definition: LutXml.cc:303
LutXml::const_iterator LutXml::begin ( ) const

Definition at line 587 of file LutXml.cc.

References lut_map.

587  {
588  return lut_map.begin();
589 }
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:92
int LutXml::create_lut_map ( void  )

Definition at line 496 of file LutXml.cc.

References XMLProcessor::_toXMLCh(), a_to_i(), funct::abs(), brick, dtNoiseDBValidation_cfg::cerr, XMLDOMBlock::document, i, j, lut_map, DetId::rawId(), and subdet_from_crate().

Referenced by HcaluLUTTPGCoder::updateXML().

496  {
497  //delete lut_map;
498  lut_map.clear();
499  //lut_map = new std::map<uint32_t,std::vector<unsigned int> >();
500 
501  if (document){
502  //DOMElement * rootElem =
503  DOMNodeList * brick_list = document->getDocumentElement()->getElementsByTagName(brick);
504  int n_of_bricks = brick_list->getLength();
505  for(int i=0; i!=n_of_bricks; i++){
506  DOMElement * aBrick = (DOMElement *)(brick_list->item(i));
507  DOMNodeList * par_list = aBrick->getElementsByTagName(XMLString::transcode("Parameter"));
508  int n_of_par = par_list->getLength();
509  int ieta=-99;
510  int iphi=-99;
511  int depth=-99;
512  int crate=-99;
513  int lut_type=-99;
514  HcalSubdetector subdet;
515  for(int j=0; j!=n_of_par; j++){
516  //std::cout << "DEBUG: i,j: " << i << ", " << j << std::endl;
517  DOMElement * aPar = (DOMElement *)(par_list->item(j));
518  char * aName = XMLString::transcode( aPar->getAttribute(XMLProcessor::_toXMLCh("name")) );
519  if ( strcmp(aName, "IETA")==0 ) ieta=a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
520  if ( strcmp(aName, "IPHI")==0 ) iphi=a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
521  if ( strcmp(aName, "DEPTH")==0 ) depth=a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
522  if ( strcmp(aName, "CRATE")==0 ) crate=a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
523  if ( strcmp(aName, "LUT_TYPE")==0 ) lut_type=a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
524  }
525  subdet=subdet_from_crate(crate,abs(ieta),depth);
526  //std::cerr << "DEBUG: eta,phi,depth,crate,type,subdet: " << ieta << ", " << iphi << ", " << depth << ", " << crate << ", " << lut_type << ", " << subdet << std::endl;
527  DOMElement * _data = (DOMElement *)(aBrick->getElementsByTagName(XMLString::transcode("Data"))->item(0));
528  char * _str = XMLString::transcode(_data->getFirstChild()->getNodeValue());
529  //std::cout << _str << std::endl;
530  //
531  // get the LUT vector
532  int _string_length = strlen(_str);
533  std::vector<unsigned int> _lut;
534  unsigned int _base = 16;
535  unsigned int _item=0;
536  for (int i=0; i!=_string_length; i++){
537  bool _range;
538  char ch_cur = _str[i];
539  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');
540  else if (_base==10) _range = (ch_cur>='0' and ch_cur<='9');
541  if ( _range ){
542  if ( ch_cur>='a' and ch_cur<='f' ) ch_cur += 10-'a';
543  else if ( ch_cur>='A' and ch_cur<='F' ) ch_cur += 10-'A';
544  else if ( ch_cur>='0' and ch_cur<='9' ) ch_cur += -'0';
545  _item = _item*_base;
546  _item += ch_cur;
547  bool last_digit = false;
548  if ( (i+1)==_string_length ) last_digit=true;
549  else{
550  char ch_next = _str[i+1];
551  bool _range_next;
552  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');
553  else if (_base==10) _range_next = (ch_next>='0' and ch_next<='9');
554  if ( !_range_next ) last_digit=true;
555  }
556  if (last_digit){
557  _lut.push_back(_item);
558  _item=0;
559  }
560  }
561  }
563  //std::cout << _lut[127] << std::endl;
564  // filling the map
565  uint32_t _key = 0;
566  if (lut_type==1){
567  HcalDetId _id(subdet,ieta,iphi,depth);
568  _key = _id.rawId();
569  }
570  else if (lut_type==2){
571  HcalTrigTowerDetId _id(ieta,iphi);
572  _key = _id.rawId();
573  }
574  //lut_map->insert(std::pair<uint32_t,std::vector<unsigned int> >(_key,_lut));
575  lut_map.insert(std::pair<uint32_t,std::vector<unsigned int> >(_key,_lut));
576  }
577  }
578  else{
579  std::cerr << "XML file with LUTs is not loaded, cannot create map!" << std::endl;
580  }
581 
582 
583 
584  return 0;
585 }
int i
Definition: DBlmapReader.cc:9
DOMDocument * document
Definition: XMLDOMBlock.h:97
HcalSubdetector subdet_from_crate(int crate, int eta, int depth)
Definition: LutXml.cc:458
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:92
int a_to_i(char *inbuf)
Definition: LutXml.cc:485
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:184
XMLCh * brick
Definition: LutXml.h:82
LutXml::const_iterator LutXml::end ( ) const

Definition at line 591 of file LutXml.cc.

References lut_map.

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

591  {
592  return lut_map.end();
593 }
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:92
LutXml::const_iterator LutXml::find ( uint32_t  id) const

Definition at line 595 of file LutXml.cc.

References lut_map.

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

595  {
596  return lut_map.find(id);
597 }
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:92
std::string LutXml::get_checksum ( std::vector< unsigned int > &  lut)
static

Definition at line 337 of file LutXml.cc.

References gather_cfg::cout, cmsRelvalreport::exit, i, md5_append(), md5_finish(), md5_init(), query::result, and findQualityFiles::size.

Referenced by add_checksum(), and addLut().

338 {
339  std::stringstream result;
340  md5_state_t md5er;
341  md5_byte_t digest[16];
342  md5_init(&md5er);
343  // linearizer LUT:
344  if ( lut . size() == 128 ){
345  unsigned char tool[2];
346  for (int i=0; i<128; i++) {
347  tool[0]=lut[i]&0xFF;
348  tool[1]=(lut[i]>>8)&0xFF;
349  md5_append(&md5er,tool,2);
350  }
351  }
352  // compression LUT:
353  else if ( lut . size() == 1024 ){
354  unsigned char tool;
355  for (int i=0; i<1024; i++) {
356  tool=lut[i]&0xFF;
357  md5_append(&md5er,&tool,1);
358  }
359  }
360  else{
361  std::cout << "ERROR: irregular LUT size, do not know how to compute checksum, exiting..." << std::endl;
362  exit(-1);
363  }
364  md5_finish(&md5er,digest);
365  for (int i=0; i<16; i++) result << std::hex << (((int)(digest[i]))&0xFF);
366 
367  //std::cout << "CHECKSUM: ";
368  //std::cout << result . str();
369  //std::cout << std::endl;
370 
371  return result . str();
372 }
void md5_init(md5_state_t *pms)
int i
Definition: DBlmapReader.cc:9
void md5_finish(md5_state_t *pms, md5_byte_t digest[16])
tuple result
Definition: query.py:137
tuple lut
Definition: lumiPlot.py:244
unsigned char md5_byte_t
Definition: md5.h:62
void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
tuple cout
Definition: gather_cfg.py:121
tuple size
Write out results.
std::string & LutXml::getCurrentBrick ( void  )

Definition at line 329 of file LutXml.cc.

References brickElem, and XMLDOMBlock::getString().

330 {
331  return getString( brickElem );
332 }
std::string & getString(void)
Definition: XMLDOMBlock.cc:459
DOMElement * brickElem
Definition: LutXml.h:89
std::vector< unsigned int > * LutXml::getLutFast ( uint32_t  det_id)

Definition at line 126 of file LutXml.cc.

References dtNoiseDBValidation_cfg::cerr, and lut_map.

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

126  {
127  /*
128  if (lut_map){
129  return &(*lut_map)[det_id];
130  }
131  else{
132  std::cerr << "LUT not found, null pointer is returned" << std::endl;
133  return 0;
134  }
135  */
136  if (lut_map.find(det_id) != lut_map.end()) return &(lut_map)[det_id];
137  std::cerr << "LUT not found, null pointer is returned" << std::endl;
138  return 0;
139 }
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:92
void LutXml::init ( void  )

Definition at line 117 of file LutXml.cc.

References brick, brickElem, and root.

Referenced by LutXml().

118 {
119  root = XMLString::transcode("CFGBrickSet");
120  brick = XMLString::transcode("CFGBrick");
121  brickElem = 0;
122  //lut_map = 0;
123 }
XMLCh * root
Definition: LutXml.h:81
DOMElement * brickElem
Definition: LutXml.h:89
XMLCh * brick
Definition: LutXml.h:82
HcalSubdetector LutXml::subdet_from_crate ( int  crate,
int  eta,
int  depth 
)

Definition at line 458 of file LutXml.cc.

References dtNoiseDBValidation_cfg::cerr, cmsRelvalreport::exit, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, and query::result.

Referenced by create_lut_map().

458  {
460  // HBHE: 0,1,4,5,10,11,14,15,17
461  // HF: 2,9,12
462  // HO: 3,6,7,13
463 
464  if (crate==2 || crate==9 || crate==12) result=HcalForward;
465  else if (crate==3 || crate==6 || crate==7 || crate==13) result=HcalOuter;
466  else if (crate==0 || crate==1 || crate==4 || crate==5 || crate==10 || crate==11 || crate==14 || crate==15 || crate==17){
467  if (eta<16) result=HcalBarrel;
468  else if (eta>16) result=HcalEndcap;
469  else if (eta==16 && depth!=3) result=HcalBarrel;
470  else if (eta==16 && depth==3) result=HcalEndcap;
471  else{
472  std::cerr << "Impossible to determine HCAL subdetector!!!" << std::endl;
473  exit(-1);
474  }
475  }
476  else{
477  std::cerr << "Impossible to determine HCAL subdetector!!!" << std::endl;
478  exit(-1);
479  }
480 
481  return result;
482 }
T eta() const
tuple result
Definition: query.py:137
HcalSubdetector
Definition: HcalAssistant.h:31
int LutXml::test_access ( std::string  filename)

Definition at line 375 of file LutXml.cc.

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

375  {
376  //create_lut_map();
377  //std::cout << "Created map size: " << lut_map->size() << std::endl;
378  std::cout << "Created map size: " << lut_map.size() << std::endl;
379 
380  struct timeval _t;
381  gettimeofday( &_t, NULL );
382  double _time =(double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0;
383 
384  HcalEmap _emap("./backup/official_emap_v6.04_080905.txt");
385  std::vector<HcalEmap::HcalEmapRow> & _map = _emap.get_map();
386  std::cout << "HcalEmap contains " << _map . size() << " entries" << std::endl;
387 
388  int _counter=0;
389  for (std::vector<HcalEmap::HcalEmapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++){
390  if (row->subdet=="HB"){
391  HcalDetId det_id(HcalBarrel,row->ieta,row->iphi,row->idepth);
392  uint32_t raw_id = det_id.rawId();
393  std::vector<unsigned int> * l = getLutFast(raw_id);
394  if (l) _counter++;
395  }
396  if (row->subdet=="HE"){
397  HcalDetId det_id(HcalEndcap,row->ieta,row->iphi,row->idepth);
398  uint32_t raw_id = det_id.rawId();
399  std::vector<unsigned int> * l = getLutFast(raw_id);
400  if (l) _counter++;
401  }
402  if (row->subdet=="HF"){
403  HcalDetId det_id(HcalForward,row->ieta,row->iphi,row->idepth);
404  uint32_t raw_id = det_id.rawId();
405  std::vector<unsigned int> * l = getLutFast(raw_id);
406  if (l) _counter++;
407  }
408  if (row->subdet=="HO"){
409  HcalDetId det_id(HcalOuter,row->ieta,row->iphi,row->idepth);
410  uint32_t raw_id = det_id.rawId();
411  std::vector<unsigned int> * l = getLutFast(raw_id);
412  if (l) _counter++;
413  }
414  }
415  gettimeofday( &_t, NULL );
416  std::cout << "access to " << _counter << " HCAL channels took: " << (double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0 - _time << "sec" << std::endl;
417 
418  //std::cout << std::endl;
419  //for (std::vector<unsigned int>::const_iterator i=l->begin();i!=l->end();i++){
420  // std::cout << *i << " ";
421  //}
422  //std::cout << std::endl;
423 
424  return 0;
425 }
std::map< uint32_t, std::vector< unsigned int > > lut_map
Definition: LutXml.h:92
#define NULL
Definition: scimark2.h:8
std::vector< unsigned int > * getLutFast(uint32_t det_id)
Definition: LutXml.cc:126
tuple cout
Definition: gather_cfg.py:121
tuple size
Write out results.

Member Data Documentation

XMLCh* LutXml::brick
protected

Definition at line 82 of file LutXml.h.

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

DOMElement* LutXml::brickElem
protected

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

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

XMLCh* LutXml::root
protected

Definition at line 81 of file LutXml.h.

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