82 strftime( timebuf, 50,
"%Y-%m-%d %H:%M:%S", gmtime( &_time ) );
83 creationstamp = timebuf;
85 formatrevision =
"default_revision";
87 generalizedindex = -1;
119 root = XMLString::transcode(
"CFGBrickSet");
120 brick = XMLString::transcode(
"CFGBrick");
137 std::cerr <<
"LUT not found, null pointer is returned" << std::endl;
211 DOMElement * rootElem =
document -> getDocumentElement();
241 std::cout <<
"Unknown LUT type...produced XML will be incorrect" << std::endl;
247 if ( checksums_xml ){
258 std::stringstream buf;
260 for (std::vector<unsigned int>::const_iterator
iter = _lut.begin();
iter!=_lut.end();
iter++){
262 sprintf(buf2,
"%x",(*
iter));
270 child -> appendChild( data_value );
294 child -> appendChild( checksum_value );
296 parent -> getDocumentElement() -> appendChild( child );
309 child -> appendChild( parameter_value );
321 sprintf(buf,
"%d", _value);
344 if ( lut .
size() == 128 ){
345 unsigned char tool[2];
346 for (
int i=0;
i<128;
i++) {
348 tool[1]=(lut[
i]>>8)&0xFF;
353 else if ( lut .
size() == 1024 ){
355 for (
int i=0;
i<1024;
i++) {
361 std::cout <<
"ERROR: irregular LUT size, do not know how to compute checksum, exiting..." << std::endl;
365 for (
int i=0;
i<16;
i++) result << std::hex << (((
int)(digest[
i]))&0xFF);
371 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 std::cout <<
"HcalEmap contains " << _map .
size() <<
" entries" << std::endl;
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 std::cout <<
"access to " << _counter <<
" HCAL channels took: " << (double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0 - _time <<
"sec" << std::endl;
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){
469 else if (eta==16 && depth!=3) result=
HcalBarrel;
470 else if (eta==16 && depth==3) result=
HcalEndcap;
472 std::cerr <<
"Impossible to determine HCAL subdetector!!!" << std::endl;
477 std::cerr <<
"Impossible to determine HCAL subdetector!!!" << std::endl;
487 sscanf(inbuf,
"%d",&result);
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();
515 for(
int j=0;
j!=n_of_par;
j++){
517 DOMElement * aPar = (DOMElement *)(par_list->item(
j));
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()));
527 DOMElement * _data = (DOMElement *)(aBrick->getElementsByTagName(XMLString::transcode(
"Data"))->item(0));
528 char * _str = XMLString::transcode(_data->getFirstChild()->getNodeValue());
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++){
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');
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';
547 bool last_digit =
false;
548 if ( (
i+1)==_string_length ) last_digit=
true;
550 char ch_next = _str[
i+1];
551 bool _range_next =
false;
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;
557 _lut.push_back(_item);
568 else if (lut_type==2){
572 lut_map.insert(std::pair<uint32_t,std::vector<unsigned int> >(_key,_lut));
576 std::cerr <<
"XML file with LUTs is not loaded, cannot create map!" << std::endl;
void md5_init(md5_state_t *pms)
DOMElement * addParameter(std::string _name, std::string _type, std::string _value)
std::string targetfirmware
HcalSubdetector subdet_from_crate(int crate, int eta, int depth)
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
void md5_finish(md5_state_t *pms, md5_byte_t digest[16])
DOMDocument * getDocument(void)
static std::string get_checksum(std::vector< unsigned int > &lut)
Abs< T >::type abs(const T &t)
DOMElement * add_checksum(DOMDocument *parent, Config &config)
std::string formatrevision
const_iterator find(uint32_t) const
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)
void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
int test_access(std::string filename)
void addLut(Config &_config, XMLDOMBlock *checksums_xml=0)
const_iterator begin() const
std::string creationstamp
tuple size
Write out results.
const_iterator end() const