83 strftime( timebuf, 50,
"%Y-%m-%d %H:%M:%S", gmtime( &_time ) );
84 creationstamp = timebuf;
86 formatrevision =
"default_revision";
88 generalizedindex = -1;
120 root = XMLString::transcode(
"CFGBrickSet");
121 brick = XMLString::transcode(
"CFGBrick");
138 std::cerr <<
"LUT not found, null pointer is returned" << std::endl;
212 DOMElement * rootElem =
document -> getDocumentElement();
242 std::cout <<
"Unknown LUT type...produced XML will be incorrect" << std::endl;
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);
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;
354 else if ( lut .
size() == 1024 ){
356 for (
int i=0;
i<1024;
i++) {
362 std::cout <<
"ERROR: irregular LUT size, do not know how to compute checksum, exiting..." << std::endl;
366 for (
int i=0;
i<16;
i++) result << std::hex << (((
int)(digest[
i]))&0xFF);
372 return result . str();
382 gettimeofday( &_t,
NULL );
383 double _time =(double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0;
385 HcalEmap _emap(
"./backup/official_emap_v6.04_080905.txt");
386 std::vector<HcalEmap::HcalEmapRow> & _map = _emap.
get_map();
387 std::cout <<
"HcalEmap contains " << _map .
size() <<
" entries" << std::endl;
390 for (std::vector<HcalEmap::HcalEmapRow>::const_iterator row=_map.begin(); row!=_map.end(); row++){
391 if (row->subdet==
"HB"){
393 uint32_t raw_id = det_id.
rawId();
394 std::vector<unsigned int> *
l =
getLutFast(raw_id);
397 if (row->subdet==
"HE"){
399 uint32_t raw_id = det_id.
rawId();
400 std::vector<unsigned int> *
l =
getLutFast(raw_id);
403 if (row->subdet==
"HF"){
405 uint32_t raw_id = det_id.
rawId();
406 std::vector<unsigned int> *
l =
getLutFast(raw_id);
409 if (row->subdet==
"HO"){
411 uint32_t raw_id = det_id.
rawId();
412 std::vector<unsigned int> *
l =
getLutFast(raw_id);
416 gettimeofday( &_t,
NULL );
417 std::cout <<
"access to " << _counter <<
" HCAL channels took: " << (double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0 - _time <<
"sec" << std::endl;
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 std::cerr <<
"Impossible to determine HCAL subdetector!!!" << std::endl;
478 std::cerr <<
"Impossible to determine HCAL subdetector!!!" << std::endl;
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];
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);
571 else if (lut_type==2){
576 lut_map.insert(std::pair<uint32_t,std::vector<unsigned int> >(_key,_lut));
580 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)
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