41 creationtag =
"default_tag";
44 time_t _time =
time(
nullptr);
45 strftime(timebuf, 50,
"%Y-%m-%d %H:%M:%S", gmtime(&_time));
46 creationstamp = timebuf;
48 formatrevision =
"default_revision";
49 targetfirmware =
"default_revision";
50 generalizedindex = -1;
65 root = XMLString::transcode(
"CFGBrickSet");
66 brick = XMLString::transcode(
"CFGBrick");
73 edm::LogError(
"LutXml") <<
"LUT not found, null pointer is returned";
79 DOMElement *rootElem =
document->getDocumentElement();
123 edm::LogError(
"LutXml") <<
"Unknown LUT type...produced XML will be incorrect";
131 template <
typename T>
137 std::stringstream buf;
139 for (
const auto &iter : _lut) {
141 sprintf(buf2,
"%lx",
uint64_t(iter));
148 child->appendChild(data_value);
166 child->appendChild(checksum_value);
168 parent->getDocumentElement()->appendChild(child);
178 child->appendChild(parameter_value);
187 sprintf(buf,
"%d", _value);
198 md5_byte_t digest[16];
201 if (lut.size() == 128) {
202 unsigned char tool[2];
203 for (
int i = 0;
i < 128;
i++) {
204 tool[0] = lut[
i] & 0xFF;
205 tool[1] = (lut[
i] >> 8) & 0xFF;
206 md5_append(&md5er, tool, 2);
208 }
else if (lut.size() == 256) {
209 unsigned char tool[2];
210 for (
int i = 0;
i < 256;
i++) {
211 tool[0] = lut[
i] & 0xFF;
212 tool[1] = (lut[
i] >> 8) & 0xFF;
213 md5_append(&md5er, tool, 2);
217 else if (lut.size() == 1024) {
219 for (
int i = 0;
i < 1024;
i++) {
220 tool = lut[
i] & 0xFF;
221 md5_append(&md5er, &tool, 1);
223 }
else if (lut.size() == 2048) {
225 for (
int i = 0;
i < 2048;
i++) {
226 tool = lut[
i] & 0xFF;
227 md5_append(&md5er, &tool, 1);
231 else if (lut.size() == 4096) {
233 for (
int i = 0;
i < 4096;
i++) {
234 tool = lut[
i] & 0xFF;
235 md5_append(&md5er, &tool, 1);
238 edm::LogError(
"LutXml") <<
"Irregular LUT size, " << lut.size()
239 <<
" , do not know how to compute checksum, exiting...";
242 md5_finish(&md5er, digest);
243 for (
int i = 0;
i < 16;
i++)
244 result << std::hex << (((
int)(digest[
i])) & 0xFF);
253 gettimeofday(&_t,
nullptr);
254 double _time = (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0;
256 HcalEmap _emap(
"./backup/official_emap_v6.04_080905.txt");
257 std::vector<HcalEmap::HcalEmapRow> &_map = _emap.
get_map();
258 edm::LogInfo(
"LutXml") <<
"HcalEmap contains " << _map.size() <<
" entries";
261 for (std::vector<HcalEmap::HcalEmapRow>::const_iterator row = _map.begin(); row != _map.end(); ++row) {
262 if (row->subdet ==
"HB") {
264 uint32_t raw_id = det_id.
rawId();
269 if (row->subdet ==
"HE") {
271 uint32_t raw_id = det_id.
rawId();
276 if (row->subdet ==
"HF") {
278 uint32_t raw_id = det_id.
rawId();
283 if (row->subdet ==
"HO") {
285 uint32_t raw_id = det_id.
rawId();
291 gettimeofday(&_t,
nullptr);
293 <<
" HCAL channels took: " << (double)(_t.tv_sec) + (double)(_t.tv_usec) / 1000000.0 - _time
304 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)
310 else if (crate == 0 || crate == 1 || crate == 4 || crate == 5 || crate == 10 || crate == 11 || crate == 14 ||
311 crate == 15 || crate == 17) {
316 else if (eta == 16 && depth < 3)
318 else if (eta == 16 && depth >= 3)
321 edm::LogError(
"LutXml") <<
"Impossible to determine HCAL subdetector!!!";
325 edm::LogError(
"LutXml") <<
"Impossible to determine HCAL subdetector!!!";
334 sscanf(inbuf,
"%d", &result);
350 DOMNodeList *brick_list =
document->getDocumentElement()->getElementsByTagName(
brick);
351 int n_of_bricks = brick_list->getLength();
352 for (
int i = 0;
i != n_of_bricks;
i++) {
353 DOMElement *aBrick = (DOMElement *)(brick_list->item(
i));
354 DOMNodeList *par_list = aBrick->getElementsByTagName(XMLString::transcode(
"Parameter"));
355 int n_of_par = par_list->getLength();
363 for (
int j = 0;
j != n_of_par;
j++) {
364 DOMElement *aPar = (DOMElement *)(par_list->item(
j));
366 if (strcmp(aName,
"IETA") == 0)
367 ieta =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
368 if (strcmp(aName,
"IPHI") == 0)
369 iphi =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
370 if (strcmp(aName,
"DEPTH") == 0)
371 depth =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
372 if (strcmp(aName,
"CRATE") == 0)
373 crate =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
374 if (strcmp(aName,
"LUT_TYPE") == 0)
375 lut_type =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
376 if (strcmp(aName,
"SLB") == 0)
377 slb =
a_to_i(XMLString::transcode(aPar->getFirstChild()->getNodeValue()));
380 DOMElement *_data = (DOMElement *)(aBrick->getElementsByTagName(XMLString::transcode(
"Data"))->item(0));
381 char *_str = XMLString::transcode(_data->getFirstChild()->getNodeValue());
384 int _string_length = strlen(_str);
385 std::vector<unsigned int> _lut;
386 unsigned int _base = 16;
387 unsigned int _item = 0;
388 for (
int i = 0;
i != _string_length;
i++) {
390 char ch_cur = _str[
i];
392 _range = (ch_cur >=
'0' and ch_cur <= '9') || (ch_cur >=
'a' and ch_cur <=
'f') ||
393 (ch_cur >=
'A' and ch_cur <=
'F');
394 else if (_base == 10)
395 _range = (ch_cur >=
'0' and ch_cur <=
'9');
397 if (ch_cur >=
'a' and ch_cur <=
'f')
399 else if (ch_cur >=
'A' and ch_cur <=
'F')
401 else if (ch_cur >=
'0' and ch_cur <=
'9')
403 _item = _item * _base;
405 bool last_digit =
false;
406 if ((
i + 1) == _string_length)
409 char ch_next = _str[
i + 1];
410 bool _range_next =
false;
412 _range_next = (ch_next >=
'0' and ch_next <= '9') || (ch_next >=
'a' and ch_next <=
'f') ||
413 (ch_next >=
'A' and ch_next <=
'F');
414 else if (_base == 10)
415 _range_next = (ch_next >=
'0' and ch_next <=
'9');
420 _lut.push_back(_item);
430 }
else if (lut_type == 2) {
431 int version = (
abs(ieta) > 29 && slb != 12 && crate > 20) ? 1 : 0;
436 lut_map.insert(std::pair<uint32_t, std::vector<unsigned int> >(_key, _lut));
439 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)
constexpr uint32_t rawId() const
get the raw id
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
std::map< uint32_t, std::vector< unsigned int > > lut_map
unsigned long long uint64_t
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)
XERCES_CPP_NAMESPACE::DOMElement * brickElem
const_iterator begin() const
std::string creationstamp
std::vector< uint64_t > mask
const_iterator end() const