77 creationtag =
"default_tag";
83 strftime( timebuf, 50,
"%Y-%m-%d %H:%M:%S", gmtime( &_time ) );
84 creationstamp = timebuf;
86 formatrevision =
"default_revision";
87 targetfirmware =
"default_revision";
88 generalizedindex = -1;
120 root = XMLString::transcode(
"CFGBrickSet");
121 brick = XMLString::transcode(
"CFGBrick");
138 edm::LogError(
"LutXml") <<
"LUT not found, null pointer is returned";
212 DOMElement * rootElem =
document -> getDocumentElement();
242 edm::LogError(
"LutXml") <<
"Unknown LUT type...produced XML will be incorrect";
248 if ( checksums_xml ){
259 std::stringstream buf;
261 for (std::vector<unsigned int>::const_iterator iter = _lut.begin();iter!=_lut.end();++iter){
263 sprintf(buf2,
"%x",(*iter));
271 child -> appendChild( data_value );
295 child -> appendChild( checksum_value );
297 parent -> getDocumentElement() -> appendChild( child );
310 child -> appendChild( parameter_value );
322 sprintf(buf,
"%d", _value);
342 md5_byte_t digest[16];
345 if ( lut .
size() == 128 ){
346 unsigned char tool[2];
347 for (
int i=0;
i<128;
i++) {
349 tool[1]=(lut[
i]>>8)&0xFF;
350 md5_append(&md5er,tool,2);
354 else if ( lut .
size() == 1024 ){
356 for (
int i=0;
i<1024;
i++) {
358 md5_append(&md5er,&tool,1);
362 edm::LogError(
"LutXml") <<
"Irregular LUT size, do not know how to compute checksum, exiting...";
365 md5_finish(&md5er,digest);
366 for (
int i=0;
i<16;
i++) result << std::hex << (((
int)(digest[
i]))&0xFF);
372 return result .
str();
381 gettimeofday( &_t,
NULL );
382 double _time =(double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0;
384 HcalEmap _emap(
"./backup/official_emap_v6.04_080905.txt");
385 std::vector<HcalEmap::HcalEmapRow> & _map = _emap.
get_map();
386 edm::LogInfo(
"LutXml") <<
"HcalEmap contains " << _map .
size() <<
" entries";
389 for (std::vector<HcalEmap::HcalEmapRow>::const_iterator row=_map.begin(); row!=_map.end(); ++row){
390 if (row->subdet==
"HB"){
392 uint32_t raw_id = det_id.
rawId();
393 std::vector<unsigned int> *
l =
getLutFast(raw_id);
396 if (row->subdet==
"HE"){
398 uint32_t raw_id = det_id.
rawId();
399 std::vector<unsigned int> *
l =
getLutFast(raw_id);
402 if (row->subdet==
"HF"){
404 uint32_t raw_id = det_id.
rawId();
405 std::vector<unsigned int> *
l =
getLutFast(raw_id);
408 if (row->subdet==
"HO"){
410 uint32_t raw_id = det_id.
rawId();
411 std::vector<unsigned int> *
l =
getLutFast(raw_id);
415 gettimeofday( &_t,
NULL );
416 edm::LogInfo(
"LutXml") <<
"access to " << _counter <<
" HCAL channels took: " << (double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0 - _time <<
"sec";
463 int crate=crate_<20? crate_ : crate_-20;
465 if (crate==2 || crate==9 || crate==12) result=
HcalForward;
466 else if (crate==3 || crate==6 || crate==7 || crate==13) result=
HcalOuter;
467 else if (crate==0 || crate==1 || crate==4 || crate==5 || crate==10 || crate==11 || crate==14 || crate==15 || crate==17){
470 else if (eta==16 && depth!=3) result=
HcalBarrel;
471 else if (eta==16 && depth==3) result=
HcalEndcap;
473 edm::LogError(
"LutXml") <<
"Impossible to determine HCAL subdetector!!!";
478 edm::LogError(
"LutXml") <<
"Impossible to determine HCAL subdetector!!!";
488 sscanf(inbuf,
"%d",&result);
504 DOMNodeList * brick_list =
document->getDocumentElement()->getElementsByTagName(
brick);
505 int n_of_bricks = brick_list->getLength();
506 for(
int i=0;
i!=n_of_bricks;
i++){
507 DOMElement * aBrick = (DOMElement *)(brick_list->item(
i));
508 DOMNodeList * par_list = aBrick->getElementsByTagName(XMLString::transcode(
"Parameter"));
509 int n_of_par = par_list->getLength();
516 for(
int j=0; j!=n_of_par; j++){
518 DOMElement * aPar = (DOMElement *)(par_list->item(j));
520 if ( strcmp(aName,
"IETA")==0 ) ieta=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
521 if ( strcmp(aName,
"IPHI")==0 ) iphi=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
522 if ( strcmp(aName,
"DEPTH")==0 ) depth=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
523 if ( strcmp(aName,
"CRATE")==0 ) crate=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
524 if ( strcmp(aName,
"LUT_TYPE")==0 ) lut_type=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
528 DOMElement * _data = (DOMElement *)(aBrick->getElementsByTagName(XMLString::transcode(
"Data"))->item(0));
529 char * _str = XMLString::transcode(_data->getFirstChild()->getNodeValue());
533 int _string_length = strlen(_str);
534 std::vector<unsigned int> _lut;
535 unsigned int _base = 16;
536 unsigned int _item=0;
537 for (
int i=0;
i!=_string_length;
i++){
539 char ch_cur = _str[
i];
540 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');
541 else if (_base==10) _range = (ch_cur>=
'0' and ch_cur<=
'9');
543 if ( ch_cur>=
'a' and ch_cur<=
'f' ) ch_cur += 10-
'a';
544 else if ( ch_cur>=
'A' and ch_cur<=
'F' ) ch_cur += 10-
'A';
545 else if ( ch_cur>=
'0' and ch_cur<=
'9' ) ch_cur += -
'0';
548 bool last_digit =
false;
549 if ( (
i+1)==_string_length ) last_digit=
true;
551 char ch_next = _str[
i+1];
552 bool _range_next =
false;
553 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');
554 else if (_base==10) _range_next = (ch_next>=
'0' and ch_next<=
'9');
555 if ( !_range_next ) last_digit=
true;
558 _lut.push_back(_item);
569 else if (lut_type==2){
573 lut_map.insert(std::pair<uint32_t,std::vector<unsigned int> >(_key,_lut));
577 edm::LogError(
"LutXml") <<
"XML file with LUTs is not loaded, cannot create map!";
XERCES_CPP_NAMESPACE::DOMElement * addParameter(std::string _name, std::string _type, std::string _value)
XERCES_CPP_NAMESPACE::DOMDocument * document
std::string targetfirmware
HcalSubdetector subdet_from_crate(int crate, int eta, int depth)
XERCES_CPP_NAMESPACE::DOMElement * add_checksum(XERCES_CPP_NAMESPACE::DOMDocument *parent, Config &config)
std::map< uint32_t, std::vector< unsigned int > > lut_map
std::map< uint32_t, std::vector< unsigned int > >::const_iterator const_iterator
std::string & getCurrentBrick(void)
uint32_t rawId() const
get the raw id
std::string & getString(void)
std::vector< unsigned int > lut
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
static std::string get_checksum(std::vector< unsigned int > &lut)
Abs< T >::type abs(const T &t)
std::string formatrevision
const_iterator find(uint32_t) const
XERCES_CPP_NAMESPACE::DOMElement * addData(std::string _elements, std::string _encoding, const std::vector< unsigned int > &_lut)
std::vector< HcalEmap::HcalEmapRow > & get_map(void)
static XMLCh * _toXMLCh(std::string temp)
std::vector< unsigned int > * getLutFast(uint32_t det_id)
int test_access(std::string filename)
XERCES_CPP_NAMESPACE::DOMElement * brickElem
void addLut(Config &_config, XMLDOMBlock *checksums_xml=0)
const_iterator begin() const
std::string creationstamp
const_iterator end() const