45 time_t _time =
time(
nullptr);
46 strftime(timebuf, 50,
"%Y-%m-%d %H:%M:%S", gmtime(&_time));
47 creationstamp = timebuf;
49 formatrevision =
"default_revision";
51 generalizedindex = -1;
54 codedvetothreshold = 0;
69 root = XMLString::transcode(
"CFGBrickSet");
70 brick = XMLString::transcode(
"CFGBrick");
77 edm::LogError(
"LutXml") <<
"LUT not found, null pointer is returned";
83 DOMElement *rootElem =
document->getDocumentElement();
124 addParameter(
"PREFIRE_VETO_THRESHOLD",
"int", actualvetothreshold);
127 <<
" is not in range (1, 2048) ! Vetoing will not be done in PFA1' !";
141 edm::LogError(
"LutXml") <<
"Unknown LUT type...produced XML will be incorrect";
149 template <
typename T>
155 std::stringstream
buf;
157 for (
const auto &iter : _lut) {
159 sprintf(buf2,
"%lx",
uint64_t(iter));
166 child->appendChild(data_value);
184 child->appendChild(checksum_value);
196 child->appendChild(parameter_value);
205 sprintf(
buf,
"%d", _value);
216 md5_byte_t digest[16];
219 if (lut.size() == 128) {
220 unsigned char tool[2];
221 for (
int i = 0;
i < 128;
i++) {
222 tool[0] = lut[
i] & 0xFF;
223 tool[1] = (lut[
i] >> 8) & 0xFF;
224 md5_append(&md5er, tool, 2);
226 }
else if (lut.size() == 256) {
227 unsigned char tool[2];
228 for (
int i = 0;
i < 256;
i++) {
229 tool[0] = lut[
i] & 0xFF;
230 tool[1] = (lut[
i] >> 8) & 0xFF;
231 md5_append(&md5er, tool, 2);
235 else if (lut.size() == 1024) {
237 for (
int i = 0;
i < 1024;
i++) {
238 tool = lut[
i] & 0xFF;
239 md5_append(&md5er, &tool, 1);
241 }
else if (lut.size() == 2048) {
243 for (
int i = 0;
i < 2048;
i++) {
244 tool = lut[
i] & 0xFF;
245 md5_append(&md5er, &tool, 1);
249 else if (lut.size() == 4096) {
251 for (
int i = 0;
i < 4096;
i++) {
252 tool = lut[
i] & 0xFF;
253 md5_append(&md5er, &tool, 1);
256 edm::LogError(
"LutXml") <<
"Irregular LUT size, " << lut.size()
257 <<
" , do not know how to compute checksum, exiting...";
260 md5_finish(&md5er, digest);
261 for (
int i = 0;
i < 16;
i++)
262 result << std::hex << (((
int)(digest[
i])) & 0xFF);
271 gettimeofday(&_t,
nullptr);
272 double _time = (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0;
274 HcalEmap _emap(
"./backup/official_emap_v6.04_080905.txt");
275 std::vector<HcalEmap::HcalEmapRow> &_map = _emap.
get_map();
276 edm::LogInfo(
"LutXml") <<
"HcalEmap contains " << _map.size() <<
" entries";
279 for (std::vector<HcalEmap::HcalEmapRow>::const_iterator row = _map.begin(); row != _map.end(); ++row) {
280 if (row->subdet ==
"HB") {
282 uint32_t raw_id = det_id.
rawId();
287 if (row->subdet ==
"HE") {
289 uint32_t raw_id = det_id.
rawId();
294 if (row->subdet ==
"HF") {
296 uint32_t raw_id = det_id.
rawId();
301 if (row->subdet ==
"HO") {
303 uint32_t raw_id = det_id.
rawId();
309 gettimeofday(&_t,
nullptr);
311 <<
" HCAL channels took: " << (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0 - _time
321 int crate = crate_ < 20 ? crate_ : crate_ - 20;
330 else if (
slot % 3 == 0)
337 edm::LogWarning(
"LutXml::subdet_from_crate") <<
"crate " << crate_ <<
" is not accounted for";
343 sscanf(inbuf,
"%d", &
result);
359 DOMNodeList *brick_list =
document->getDocumentElement()->getElementsByTagName(
brick);
360 int n_of_bricks = brick_list->getLength();
361 for (
int i = 0;
i != n_of_bricks;
i++) {
362 DOMElement *aBrick = (DOMElement *)(brick_list->item(
i));
363 DOMNodeList *par_list = aBrick->getElementsByTagName(XMLString::transcode(
"Parameter"));
364 int n_of_par = par_list->getLength();
374 for (
int j = 0;
j != n_of_par;
j++) {
375 DOMElement *aPar = (DOMElement *)(par_list->item(
j));
377 if (strcmp(aName,
"IETA") == 0)
378 ieta =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
379 if (strcmp(aName,
"IPHI") == 0)
380 iphi =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
381 if (strcmp(aName,
"DEPTH") == 0)
382 depth =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
383 if (strcmp(aName,
"CRATE") == 0)
384 crate =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
385 if (strcmp(aName,
"SLOT") == 0)
386 slot =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
387 if (strcmp(aName,
"FIBER") == 0)
388 fiber =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
389 if (strcmp(aName,
"LUT_TYPE") == 0)
390 lut_type =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
391 if (strcmp(aName,
"SLB") == 0)
392 slb =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
395 DOMElement *_data = (DOMElement *)(aBrick->getElementsByTagName(XMLString::transcode(
"Data"))->item(0));
396 char *_str = XMLString::transcode(_data->getFirstChild()->getNodeValue());
399 int _string_length = strlen(_str);
400 std::vector<unsigned int> _lut;
401 unsigned int _base = 16;
402 unsigned int _item = 0;
403 for (
int i = 0;
i != _string_length;
i++) {
405 char ch_cur = _str[
i];
407 _range = (ch_cur >=
'0' and ch_cur <= '9') || (ch_cur >=
'a' and ch_cur <=
'f') ||
408 (ch_cur >=
'A' and ch_cur <=
'F');
409 else if (_base == 10)
410 _range = (ch_cur >=
'0' and ch_cur <=
'9');
412 if (ch_cur >=
'a' and ch_cur <=
'f')
414 else if (ch_cur >=
'A' and ch_cur <=
'F')
416 else if (ch_cur >=
'0' and ch_cur <=
'9')
418 _item = _item * _base;
420 bool last_digit =
false;
421 if ((
i + 1) == _string_length)
424 char ch_next = _str[
i + 1];
425 bool _range_next =
false;
427 _range_next = (ch_next >=
'0' and ch_next <= '9') || (ch_next >=
'a' and ch_next <=
'f') ||
428 (ch_next >=
'A' and ch_next <=
'F');
429 else if (_base == 10)
430 _range_next = (ch_next >=
'0' and ch_next <=
'9');
435 _lut.push_back(_item);
445 }
else if (lut_type == 2) {
451 lut_map.insert(std::pair<uint32_t, std::vector<unsigned int> >(_key, _lut));
454 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)
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)
Log< level::Error, false > LogError
static std::string to_string(const XMLCh *ch)
std::string & getCurrentBrick(void)
std::string & getString(void)
const_iterator find(uint32_t) const
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
Log< level::Info, false > LogInfo
HcalSubdetector subdet_from_crate(int crate, int slot, int fiber)
std::map< uint32_t, std::vector< unsigned int > > lut_map
unsigned long long uint64_t
constexpr uint32_t rawId() const
get the raw id
const_iterator end() const
std::map< uint32_t, std::vector< unsigned int > >::const_iterator const_iterator
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)
Log< level::Warning, false > LogWarning
XERCES_CPP_NAMESPACE::DOMElement * brickElem
const_iterator begin() const
std::string creationstamp
std::vector< uint64_t > mask