42 creationtag =
"default_tag";
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";
50 targetfirmware =
"default_revision";
51 generalizedindex = -1;
66 root = XMLString::transcode(
"CFGBrickSet");
67 brick = XMLString::transcode(
"CFGBrick");
74 edm::LogError(
"LutXml") <<
"LUT not found, null pointer is returned";
80 DOMElement *rootElem =
document->getDocumentElement();
125 edm::LogError(
"LutXml") <<
"Unknown LUT type...produced XML will be incorrect";
133 template <
typename T>
139 std::stringstream
buf;
141 for (
const auto &iter : _lut) {
143 sprintf(buf2,
"%lx",
uint64_t(iter));
150 child->appendChild(data_value);
168 child->appendChild(checksum_value);
180 child->appendChild(parameter_value);
189 sprintf(
buf,
"%d", _value);
200 md5_byte_t digest[16];
203 if (lut.size() == 128) {
204 unsigned char tool[2];
205 for (
int i = 0;
i < 128;
i++) {
206 tool[0] = lut[
i] & 0xFF;
207 tool[1] = (lut[
i] >> 8) & 0xFF;
208 md5_append(&md5er, tool, 2);
210 }
else if (lut.size() == 256) {
211 unsigned char tool[2];
212 for (
int i = 0;
i < 256;
i++) {
213 tool[0] = lut[
i] & 0xFF;
214 tool[1] = (lut[
i] >> 8) & 0xFF;
215 md5_append(&md5er, tool, 2);
219 else if (lut.size() == 1024) {
221 for (
int i = 0;
i < 1024;
i++) {
222 tool = lut[
i] & 0xFF;
223 md5_append(&md5er, &tool, 1);
225 }
else if (lut.size() == 2048) {
227 for (
int i = 0;
i < 2048;
i++) {
228 tool = lut[
i] & 0xFF;
229 md5_append(&md5er, &tool, 1);
233 else if (lut.size() == 4096) {
235 for (
int i = 0;
i < 4096;
i++) {
236 tool = lut[
i] & 0xFF;
237 md5_append(&md5er, &tool, 1);
240 edm::LogError(
"LutXml") <<
"Irregular LUT size, " << lut.size()
241 <<
" , do not know how to compute checksum, exiting...";
244 md5_finish(&md5er, digest);
245 for (
int i = 0;
i < 16;
i++)
246 result << std::hex << (((
int)(digest[
i])) & 0xFF);
255 gettimeofday(&_t,
nullptr);
256 double _time = (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0;
258 HcalEmap _emap(
"./backup/official_emap_v6.04_080905.txt");
259 std::vector<HcalEmap::HcalEmapRow> &_map = _emap.
get_map();
260 edm::LogInfo(
"LutXml") <<
"HcalEmap contains " << _map.size() <<
" entries";
263 for (std::vector<HcalEmap::HcalEmapRow>::const_iterator row = _map.begin(); row != _map.end(); ++row) {
264 if (row->subdet ==
"HB") {
266 uint32_t raw_id = det_id.
rawId();
271 if (row->subdet ==
"HE") {
273 uint32_t raw_id = det_id.
rawId();
278 if (row->subdet ==
"HF") {
280 uint32_t raw_id = det_id.
rawId();
285 if (row->subdet ==
"HO") {
287 uint32_t raw_id = det_id.
rawId();
293 gettimeofday(&_t,
nullptr);
295 <<
" HCAL channels took: " << (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0 - _time
305 int crate = crate_ < 20 ? crate_ : crate_ - 20;
306 if (crate == 2 || crate == 9 || crate == 12)
308 else if (crate == 3 || crate == 6 || crate == 7 || crate == 13 || crate == 18)
310 else if (crate == 0 || crate == 1 || crate == 4 || crate == 5 || crate == 10 || crate == 11 || crate == 14 ||
311 crate == 15 || crate == 17) {
314 else if (slot % 3 == 0)
321 edm::LogWarning(
"LutXml::subdet_from_crate") <<
"crate " << crate_ <<
" is not accounted for";
327 sscanf(inbuf,
"%d", &
result);
343 DOMNodeList *brick_list =
document->getDocumentElement()->getElementsByTagName(
brick);
344 int n_of_bricks = brick_list->getLength();
345 for (
int i = 0;
i != n_of_bricks;
i++) {
346 DOMElement *aBrick = (DOMElement *)(brick_list->item(
i));
347 DOMNodeList *par_list = aBrick->getElementsByTagName(XMLString::transcode(
"Parameter"));
348 int n_of_par = par_list->getLength();
358 for (
int j = 0;
j != n_of_par;
j++) {
359 DOMElement *aPar = (DOMElement *)(par_list->item(
j));
361 if (strcmp(aName,
"IETA") == 0)
362 ieta =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
363 if (strcmp(aName,
"IPHI") == 0)
364 iphi =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
365 if (strcmp(aName,
"DEPTH") == 0)
366 depth =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
367 if (strcmp(aName,
"CRATE") == 0)
368 crate =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
369 if (strcmp(aName,
"SLOT") == 0)
370 slot =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
371 if (strcmp(aName,
"FIBER") == 0)
372 fiber =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
373 if (strcmp(aName,
"LUT_TYPE") == 0)
374 lut_type =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
375 if (strcmp(aName,
"SLB") == 0)
376 slb =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
379 DOMElement *_data = (DOMElement *)(aBrick->getElementsByTagName(XMLString::transcode(
"Data"))->item(0));
380 char *_str = XMLString::transcode(_data->getFirstChild()->getNodeValue());
383 int _string_length = strlen(_str);
384 std::vector<unsigned int> _lut;
385 unsigned int _base = 16;
386 unsigned int _item = 0;
387 for (
int i = 0;
i != _string_length;
i++) {
389 char ch_cur = _str[
i];
391 _range = (ch_cur >=
'0' and ch_cur <=
'9') || (ch_cur >=
'a' and ch_cur <=
'f') ||
392 (ch_cur >=
'A' and ch_cur <=
'F');
393 else if (_base == 10)
394 _range = (ch_cur >=
'0' and ch_cur <=
'9');
396 if (ch_cur >=
'a' and ch_cur <=
'f')
398 else if (ch_cur >=
'A' and ch_cur <=
'F')
400 else if (ch_cur >=
'0' and ch_cur <=
'9')
402 _item = _item * _base;
404 bool last_digit =
false;
405 if ((
i + 1) == _string_length)
408 char ch_next = _str[
i + 1];
409 bool _range_next =
false;
411 _range_next = (ch_next >=
'0' and ch_next <=
'9') || (ch_next >=
'a' and ch_next <=
'f') ||
412 (ch_next >=
'A' and ch_next <=
'F');
413 else if (_base == 10)
414 _range_next = (ch_next >=
'0' and ch_next <=
'9');
419 _lut.push_back(_item);
429 }
else if (lut_type == 2) {
435 lut_map.insert(std::pair<uint32_t, std::vector<unsigned int> >(_key, _lut));
438 edm::LogError(
"LutXml") <<
"XML file with LUTs is not loaded, cannot create map!";