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);
277 else if ( lut .
size() == 4096){
279 for (
int i=0;
i<4096;
i++) {
281 md5_append(&md5er,&tool,1);
286 edm::LogError(
"LutXml") <<
"Irregular LUT size, "<< lut.size() <<
" , do not know how to compute checksum, exiting...";
289 md5_finish(&md5er,digest);
290 for (
int i=0;
i<16;
i++) result << std::hex << (((
int)(digest[
i]))&0xFF);
293 return result .
str();
302 gettimeofday( &_t,
nullptr );
303 double _time =(double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0;
305 HcalEmap _emap(
"./backup/official_emap_v6.04_080905.txt");
306 std::vector<HcalEmap::HcalEmapRow> & _map = _emap.
get_map();
307 edm::LogInfo(
"LutXml") <<
"HcalEmap contains " << _map .
size() <<
" entries";
310 for (std::vector<HcalEmap::HcalEmapRow>::const_iterator row=_map.begin(); row!=_map.end(); ++row){
311 if (row->subdet==
"HB"){
313 uint32_t raw_id = det_id.
rawId();
314 std::vector<unsigned int> *
l =
getLutFast(raw_id);
317 if (row->subdet==
"HE"){
319 uint32_t raw_id = det_id.
rawId();
320 std::vector<unsigned int> *
l =
getLutFast(raw_id);
323 if (row->subdet==
"HF"){
325 uint32_t raw_id = det_id.
rawId();
326 std::vector<unsigned int> *
l =
getLutFast(raw_id);
329 if (row->subdet==
"HO"){
331 uint32_t raw_id = det_id.
rawId();
332 std::vector<unsigned int> *
l =
getLutFast(raw_id);
336 gettimeofday( &_t,
nullptr );
337 edm::LogInfo(
"LutXml") <<
"access to " << _counter <<
" HCAL channels took: " << (double)(_t . tv_sec) + (double)(_t . tv_usec)/1000000.0 - _time <<
"sec";
349 int crate=crate_<20? crate_ : crate_-20;
351 if (crate==2 || crate==9 || crate==12) result=
HcalForward;
352 else if (crate==3 || crate==6 || crate==7 || crate==13) result=
HcalOuter;
353 else if (crate==0 || crate==1 || crate==4 || crate==5 || crate==10 || crate==11 || crate==14 || crate==15 || crate==17){
356 else if (eta==16 && depth<3) result=
HcalBarrel;
357 else if (eta==16 && depth>=3) result=
HcalEndcap;
359 edm::LogError(
"LutXml") <<
"Impossible to determine HCAL subdetector!!!";
364 edm::LogError(
"LutXml") <<
"Impossible to determine HCAL subdetector!!!";
374 sscanf(inbuf,
"%d",&result);
390 DOMNodeList * brick_list =
document->getDocumentElement()->getElementsByTagName(
brick);
391 int n_of_bricks = brick_list->getLength();
392 for(
int i=0;
i!=n_of_bricks;
i++){
393 DOMElement * aBrick = (DOMElement *)(brick_list->item(
i));
394 DOMNodeList * par_list = aBrick->getElementsByTagName(XMLString::transcode(
"Parameter"));
395 int n_of_par = par_list->getLength();
403 for(
int j=0; j!=n_of_par; j++){
404 DOMElement * aPar = (DOMElement *)(par_list->item(j));
406 if ( strcmp(aName,
"IETA")==0 ) ieta=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
407 if ( strcmp(aName,
"IPHI")==0 ) iphi=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
408 if ( strcmp(aName,
"DEPTH")==0 ) depth=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
409 if ( strcmp(aName,
"CRATE")==0 ) crate=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
410 if ( strcmp(aName,
"LUT_TYPE")==0 ) lut_type=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
411 if ( strcmp(aName,
"SLB")==0 ) slb=
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
414 DOMElement * _data = (DOMElement *)(aBrick->getElementsByTagName(XMLString::transcode(
"Data"))->item(0));
415 char * _str = XMLString::transcode(_data->getFirstChild()->getNodeValue());
418 int _string_length = strlen(_str);
419 std::vector<unsigned int> _lut;
420 unsigned int _base = 16;
421 unsigned int _item=0;
422 for (
int i=0;
i!=_string_length;
i++){
424 char ch_cur = _str[
i];
425 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');
426 else if (_base==10) _range = (ch_cur>=
'0' and ch_cur<=
'9');
428 if ( ch_cur>=
'a' and ch_cur<=
'f' ) ch_cur += 10-
'a';
429 else if ( ch_cur>=
'A' and ch_cur<=
'F' ) ch_cur += 10-
'A';
430 else if ( ch_cur>=
'0' and ch_cur<=
'9' ) ch_cur += -
'0';
433 bool last_digit =
false;
434 if ( (
i+1)==_string_length ) last_digit=
true;
436 char ch_next = _str[
i+1];
437 bool _range_next =
false;
438 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');
439 else if (_base==10) _range_next = (ch_next>=
'0' and ch_next<=
'9');
440 if ( !_range_next ) last_digit=
true;
443 _lut.push_back(_item);
454 else if (lut_type==2){
455 int version=(
abs(ieta)>29 && slb!=12 && crate>20) ? 1: 0;
460 lut_map.insert(std::pair<uint32_t,std::vector<unsigned int> >(_key,_lut));
464 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