43 creationtag =
"default_tag";
46 time_t _time =
time(
nullptr );
47 strftime( timebuf, 50,
"%Y-%m-%d %H:%M:%S", gmtime( &_time ) );
48 creationstamp = timebuf;
50 formatrevision =
"default_revision";
51 targetfirmware =
"default_revision";
52 generalizedindex = -1;
82 root = XMLString::transcode(
"CFGBrickSet");
83 brick = XMLString::transcode(
"CFGBrick");
90 edm::LogError(
"LutXml") <<
"LUT not found, null pointer is returned";
99 DOMElement * rootElem =
document -> getDocumentElement();
124 addData( to_string(_config.
lut.size()),
"hex", _config.
lut );
133 addData( to_string(_config.
lut.size()),
"hex", _config.
lut );
136 addParameter(
"MASK_TYPE",
"string",
"TRIGGERCHANMASK" );
148 edm::LogError(
"LutXml") <<
"Unknown LUT type...produced XML will be incorrect";
157 template <
typename T>
164 std::stringstream buf;
166 for (
const auto& iter : _lut){
175 child -> appendChild( data_value );
195 child -> appendChild( checksum_value );
197 parent -> getDocumentElement() -> appendChild( child );
210 child -> appendChild( parameter_value );
222 sprintf(buf,
"%d", _value);
242 md5_byte_t digest[16];
245 if ( lut .
size() == 128){
246 unsigned char tool[2];
247 for (
int i=0;
i<128;
i++) {
249 tool[1]=(lut[
i]>>8)&0xFF;
250 md5_append(&md5er,tool,2);
253 else if ( lut .
size() == 256){
254 unsigned char tool[2];
255 for (
int i=0;
i<256;
i++) {
257 tool[1]=(lut[
i]>>8)&0xFF;
258 md5_append(&md5er,tool,2);
262 else if ( lut .
size() == 1024 ){
264 for (
int i=0;
i<1024;
i++) {
266 md5_append(&md5er,&tool,1);
269 else if ( lut .
size() == 2048 ){
271 for (
int i=0;
i<2048;
i++) {
273 md5_append(&md5er,&tool,1);
278 edm::LogError(
"LutXml") <<
"Irregular LUT size, "<< lut.size() <<
" , do not know how to compute checksum, exiting...";
281 md5_finish(&md5er,digest);
282 for (
int i=0;
i<16;
i++) result << std::hex << (((
int)(digest[
i]))&0xFF);
285 return result .
str();
294 gettimeofday( &_t,
nullptr );
295 double _time =(double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0;
297 HcalEmap _emap(
"./backup/official_emap_v6.04_080905.txt");
298 std::vector<HcalEmap::HcalEmapRow> & _map = _emap.
get_map();
299 edm::LogInfo(
"LutXml") <<
"HcalEmap contains " << _map .
size() <<
" entries";
302 for (std::vector<HcalEmap::HcalEmapRow>::const_iterator row=_map.begin(); row!=_map.end(); ++row){
303 if (row->subdet==
"HB"){
305 uint32_t raw_id = det_id.
rawId();
306 std::vector<unsigned int> *
l =
getLutFast(raw_id);
309 if (row->subdet==
"HE"){
311 uint32_t raw_id = det_id.
rawId();
312 std::vector<unsigned int> *
l =
getLutFast(raw_id);
315 if (row->subdet==
"HF"){
317 uint32_t raw_id = det_id.
rawId();
318 std::vector<unsigned int> *
l =
getLutFast(raw_id);
321 if (row->subdet==
"HO"){
323 uint32_t raw_id = det_id.
rawId();
324 std::vector<unsigned int> *
l =
getLutFast(raw_id);
328 gettimeofday( &_t,
nullptr );
329 edm::LogInfo(
"LutXml") <<
"access to " << _counter <<
" HCAL channels took: " << (double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0 - _time <<
"sec";
341 int crate=crate_<20? crate_ : crate_-20;
343 if (crate==2 || crate==9 || crate==12) result=
HcalForward;
344 else if (crate==3 || crate==6 || crate==7 || crate==13) result=
HcalOuter;
345 else if (crate==0 || crate==1 || crate==4 || crate==5 || crate==10 || crate==11 || crate==14 || crate==15 || crate==17){
348 else if (eta==16 && depth<3) result=
HcalBarrel;
349 else if (eta==16 && depth>=3) result=
HcalEndcap;
351 edm::LogError(
"LutXml") <<
"Impossible to determine HCAL subdetector!!!";
356 edm::LogError(
"LutXml") <<
"Impossible to determine HCAL subdetector!!!";
366 sscanf(inbuf,
"%d",&result);
382 DOMNodeList * brick_list =
document->getDocumentElement()->getElementsByTagName(
brick);
383 int n_of_bricks = brick_list->getLength();
384 for(
int i=0;
i!=n_of_bricks;
i++){
385 DOMElement * aBrick = (DOMElement *)(brick_list->item(
i));
386 DOMNodeList * par_list = aBrick->getElementsByTagName(XMLString::transcode(
"Parameter"));
387 int n_of_par = par_list->getLength();
395 for(
int j=0; j!=n_of_par; j++){
396 DOMElement * aPar = (DOMElement *)(par_list->item(j));
398 if ( strcmp(aName,
"IETA")==0 ) ieta=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
399 if ( strcmp(aName,
"IPHI")==0 ) iphi=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
400 if ( strcmp(aName,
"DEPTH")==0 ) depth=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
401 if ( strcmp(aName,
"CRATE")==0 ) crate=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
402 if ( strcmp(aName,
"LUT_TYPE")==0 ) lut_type=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
403 if ( strcmp(aName,
"SLB")==0 ) slb=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
406 DOMElement * _data = (DOMElement *)(aBrick->getElementsByTagName(XMLString::transcode(
"Data"))->item(0));
407 char * _str = XMLString::transcode(_data->getFirstChild()->getNodeValue());
410 int _string_length = strlen(_str);
411 std::vector<unsigned int> _lut;
412 unsigned int _base = 16;
413 unsigned int _item=0;
414 for (
int i=0;
i!=_string_length;
i++){
416 char ch_cur = _str[
i];
417 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');
418 else if (_base==10) _range = (ch_cur>=
'0' and ch_cur<=
'9');
420 if ( ch_cur>=
'a' and ch_cur<=
'f' ) ch_cur += 10-
'a';
421 else if ( ch_cur>=
'A' and ch_cur<=
'F' ) ch_cur += 10-
'A';
422 else if ( ch_cur>=
'0' and ch_cur<=
'9' ) ch_cur += -
'0';
425 bool last_digit =
false;
426 if ( (
i+1)==_string_length ) last_digit=
true;
428 char ch_next = _str[
i+1];
429 bool _range_next =
false;
430 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');
431 else if (_base==10) _range_next = (ch_next>=
'0' and ch_next<=
'9');
432 if ( !_range_next ) last_digit=
true;
435 _lut.push_back(_item);
446 else if (lut_type==2){
447 int version=(
abs(ieta)>29 && slb!=12 && crate>20) ? 1: 0;
452 lut_map.insert(std::pair<uint32_t,std::vector<unsigned int> >(_key,_lut));
456 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
void addLut(Config &_config, XMLDOMBlock *checksums_xml=nullptr)
HcalSubdetector subdet_from_crate(int crate, int eta, int depth)
static int slb(const HcalTriggerPrimitiveSample &theSample)
XERCES_CPP_NAMESPACE::DOMElement * add_checksum(XERCES_CPP_NAMESPACE::DOMDocument *parent, Config &config)
XERCES_CPP_NAMESPACE::DOMElement * addData(std::string _elements, std::string _encoding, const T &_lut)
std::map< uint32_t, std::vector< unsigned int > > lut_map
constexpr uint32_t rawId() const
get the raw id
std::map< uint32_t, std::vector< unsigned int > >::const_iterator const_iterator
std::string & getCurrentBrick(void)
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
unsigned long long uint64_t
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
const_iterator begin() const
std::string creationstamp
std::vector< uint64_t > mask
const_iterator end() const