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;
67 root = XMLString::transcode(
"CFGBrickSet");
68 brick = XMLString::transcode(
"CFGBrick");
75 edm::LogError(
"LutXml") <<
"LUT not found, null pointer is returned";
81 DOMElement *rootElem =
document->getDocumentElement();
127 edm::LogError(
"LutXml") <<
"Unknown LUT type...produced XML will be incorrect";
135 template <
typename T>
141 std::stringstream
buf;
143 for (
const auto &iter : _lut) {
145 sprintf(buf2,
"%lx",
uint64_t(iter));
152 child->appendChild(data_value);
170 child->appendChild(checksum_value);
182 child->appendChild(parameter_value);
191 sprintf(
buf,
"%d", _value);
202 md5_byte_t digest[16];
205 if (lut.size() == 128) {
206 unsigned char tool[2];
207 for (
int i = 0;
i < 128;
i++) {
208 tool[0] = lut[
i] & 0xFF;
209 tool[1] = (lut[
i] >> 8) & 0xFF;
210 md5_append(&md5er, tool, 2);
212 }
else if (lut.size() == 256) {
213 unsigned char tool[2];
214 for (
int i = 0;
i < 256;
i++) {
215 tool[0] = lut[
i] & 0xFF;
216 tool[1] = (lut[
i] >> 8) & 0xFF;
217 md5_append(&md5er, tool, 2);
221 else if (lut.size() == 1024) {
223 for (
int i = 0;
i < 1024;
i++) {
224 tool = lut[
i] & 0xFF;
225 md5_append(&md5er, &tool, 1);
227 }
else if (lut.size() == 2048) {
229 for (
int i = 0;
i < 2048;
i++) {
230 tool = lut[
i] & 0xFF;
231 md5_append(&md5er, &tool, 1);
235 else if (lut.size() == 4096) {
237 for (
int i = 0;
i < 4096;
i++) {
238 tool = lut[
i] & 0xFF;
239 md5_append(&md5er, &tool, 1);
242 edm::LogError(
"LutXml") <<
"Irregular LUT size, " << lut.size()
243 <<
" , do not know how to compute checksum, exiting...";
246 md5_finish(&md5er, digest);
247 for (
int i = 0;
i < 16;
i++)
248 result << std::hex << (((
int)(digest[
i])) & 0xFF);
257 gettimeofday(&_t,
nullptr);
258 double _time = (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0;
260 HcalEmap _emap(
"./backup/official_emap_v6.04_080905.txt");
261 std::vector<HcalEmap::HcalEmapRow> &_map = _emap.
get_map();
262 edm::LogInfo(
"LutXml") <<
"HcalEmap contains " << _map.size() <<
" entries";
265 for (std::vector<HcalEmap::HcalEmapRow>::const_iterator row = _map.begin(); row != _map.end(); ++row) {
266 if (row->subdet ==
"HB") {
268 uint32_t raw_id = det_id.
rawId();
273 if (row->subdet ==
"HE") {
275 uint32_t raw_id = det_id.
rawId();
280 if (row->subdet ==
"HF") {
282 uint32_t raw_id = det_id.
rawId();
287 if (row->subdet ==
"HO") {
289 uint32_t raw_id = det_id.
rawId();
295 gettimeofday(&_t,
nullptr);
297 <<
" HCAL channels took: " << (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0 - _time
307 int crate = crate_ < 20 ? crate_ : crate_ - 20;
308 if (crate == 2 || crate == 9 || crate == 12)
310 else if (crate == 3 || crate == 6 || crate == 7 || crate == 13 || crate == 18)
312 else if (crate == 0 || crate == 1 || crate == 4 || crate == 5 || crate == 10 || crate == 11 || crate == 14 ||
313 crate == 15 || crate == 17) {
316 else if (slot % 3 == 0)
323 edm::LogWarning(
"LutXml::subdet_from_crate") <<
"crate " << crate_ <<
" is not accounted for";
329 sscanf(inbuf,
"%d", &
result);
345 DOMNodeList *brick_list =
document->getDocumentElement()->getElementsByTagName(
brick);
346 int n_of_bricks = brick_list->getLength();
347 for (
int i = 0;
i != n_of_bricks;
i++) {
348 DOMElement *aBrick = (DOMElement *)(brick_list->item(
i));
349 DOMNodeList *par_list = aBrick->getElementsByTagName(XMLString::transcode(
"Parameter"));
350 int n_of_par = par_list->getLength();
360 for (
int j = 0;
j != n_of_par;
j++) {
361 DOMElement *aPar = (DOMElement *)(par_list->item(
j));
363 if (strcmp(aName,
"IETA") == 0)
364 ieta =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
365 if (strcmp(aName,
"IPHI") == 0)
366 iphi =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
367 if (strcmp(aName,
"DEPTH") == 0)
368 depth =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
369 if (strcmp(aName,
"CRATE") == 0)
370 crate =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
371 if (strcmp(aName,
"SLOT") == 0)
372 slot =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
373 if (strcmp(aName,
"FIBER") == 0)
374 fiber =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
375 if (strcmp(aName,
"LUT_TYPE") == 0)
376 lut_type =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
377 if (strcmp(aName,
"SLB") == 0)
378 slb =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
381 DOMElement *_data = (DOMElement *)(aBrick->getElementsByTagName(XMLString::transcode(
"Data"))->item(0));
382 char *_str = XMLString::transcode(_data->getFirstChild()->getNodeValue());
385 int _string_length = strlen(_str);
386 std::vector<unsigned int> _lut;
387 unsigned int _base = 16;
388 unsigned int _item = 0;
389 for (
int i = 0;
i != _string_length;
i++) {
391 char ch_cur = _str[
i];
393 _range = (ch_cur >=
'0' and ch_cur <=
'9') || (ch_cur >=
'a' and ch_cur <=
'f') ||
394 (ch_cur >=
'A' and ch_cur <=
'F');
395 else if (_base == 10)
396 _range = (ch_cur >=
'0' and ch_cur <=
'9');
398 if (ch_cur >=
'a' and ch_cur <=
'f')
400 else if (ch_cur >=
'A' and ch_cur <=
'F')
402 else if (ch_cur >=
'0' and ch_cur <=
'9')
404 _item = _item * _base;
406 bool last_digit =
false;
407 if ((
i + 1) == _string_length)
410 char ch_next = _str[
i + 1];
411 bool _range_next =
false;
413 _range_next = (ch_next >=
'0' and ch_next <=
'9') || (ch_next >=
'a' and ch_next <=
'f') ||
414 (ch_next >=
'A' and ch_next <=
'F');
415 else if (_base == 10)
416 _range_next = (ch_next >=
'0' and ch_next <=
'9');
421 _lut.push_back(_item);
431 }
else if (lut_type == 2) {
437 lut_map.insert(std::pair<uint32_t, std::vector<unsigned int> >(_key, _lut));
440 edm::LogError(
"LutXml") <<
"XML file with LUTs is not loaded, cannot create map!";