CMS 3D CMS Logo

XMLConfigReader.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <cmath>
3 #include <algorithm>
4 #include <utility>
5 #include <array>
6 
10 
12 
14 
15 #include "xercesc/framework/StdOutFormatTarget.hpp"
16 #include "xercesc/framework/LocalFileFormatTarget.hpp"
17 #include "xercesc/parsers/XercesDOMParser.hpp"
18 #include "xercesc/dom/DOM.hpp"
19 #include "xercesc/dom/DOMException.hpp"
20 #include "xercesc/dom/DOMImplementation.hpp"
21 #include "xercesc/sax/HandlerBase.hpp"
22 #include "xercesc/util/XMLString.hpp"
23 #include "xercesc/util/PlatformUtils.hpp"
24 #include "xercesc/util/XercesDefs.hpp"
26 
29 // XMLConfigReader
31 inline std::string _toString(XMLCh const *toTranscode) {
32  std::string tmp(xercesc::XMLString::transcode(toTranscode));
33  return tmp;
34 }
35 
36 inline XMLCh *_toDOMS(std::string temp) {
37  XMLCh *buff = XMLString::transcode(temp.c_str());
38  return buff;
39 }
43  //XMLPlatformUtils::Initialize();
44 
46  //parser = new XercesDOMParser();
47  //parser->setValidationScheme(XercesDOMParser::Val_Auto);
48  //parser->setDoNamespaces(false);
49 
50  //doc = 0;
51 }
52 
54  // delete parser;
55  //XMLPlatformUtils::Terminate();
56 }
59 void XMLConfigReader::readLUTs(std::vector<l1t::LUT *> luts,
60  const L1TMuonOverlapParams &aConfig,
61  const std::vector<std::string> &types) {
63  auto const &aGPs = readPatterns(aConfig);
64 
65  for (unsigned int i = 0; i < luts.size(); i++) {
66  l1t::LUT *lut = luts[i];
67  const std::string &type = types[i];
68 
69  std::stringstream strStream;
70  int totalInWidth = 7; //Number of bits used to address LUT
71  int outWidth = 6; //Number of bits used to store LUT value
72 
73  if (type == "iCharge")
74  outWidth = 1;
75  if (type == "iEta")
76  outWidth = 2;
77  if (type == "iPt")
78  outWidth = 9;
79  if (type == "meanDistPhi") {
80  outWidth = 11;
81  totalInWidth = 14;
82  }
83  if (type == "pdf") {
84  outWidth = 6;
85  totalInWidth = 21;
86  }
87 
89  strStream << "#<header> V1 " << totalInWidth << " " << outWidth << " </header> " << std::endl;
90 
91  unsigned int in = 0;
92  int out = 0;
93  for (const auto &it : aGPs) {
94  if (type == "iCharge")
95  out = it->key().theCharge == -1 ? 0 : 1;
96  if (type == "iEta")
97  out = it->key().theEtaCode;
98  if (type == "iPt")
99  out = it->key().thePtCode;
100  if (type == "meanDistPhi") {
101  for (unsigned int iLayer = 0; iLayer < (unsigned)aConfig.nLayers(); ++iLayer) {
102  for (unsigned int iRefLayer = 0; iRefLayer < (unsigned)aConfig.nRefLayers(); ++iRefLayer) {
103  out = (1 << (outWidth - 1)) + it->meanDistPhiValue(iLayer, iRefLayer);
104  strStream << in << " " << out << std::endl;
105  ++in;
106  }
107  }
108  }
109  if (type == "pdf") {
110  for (unsigned int iLayer = 0; iLayer < (unsigned)aConfig.nLayers(); ++iLayer) {
111  for (unsigned int iRefLayer = 0; iRefLayer < (unsigned)aConfig.nRefLayers(); ++iRefLayer) {
112  for (unsigned int iPdf = 0; iPdf < exp2(aConfig.nPdfAddrBits()); ++iPdf) {
113  out = it->pdfValue(iLayer, iRefLayer, iPdf);
114  strStream << in << " " << out << std::endl;
115  ++in;
116  }
117  }
118  }
119  }
120  if (type != "meanDistPhi" && type != "pdf") {
121  strStream << in << " " << out << std::endl;
122  ++in;
123  }
124  }
125 
127  lut->read(strStream);
128  }
129 }
133  if (patternsFile.empty())
134  return 0;
135 
136  unsigned int version = 0;
137  XMLPlatformUtils::Initialize();
138  {
139  XercesDOMParser parser;
140  parser.setValidationScheme(XercesDOMParser::Val_Auto);
141  parser.setDoNamespaces(false);
142 
143  parser.parse(patternsFile.c_str());
144  xercesc::DOMDocument *doc = parser.getDocument();
145  assert(doc);
146 
147  XMLCh *xmlOmtf = _toDOMS("OMTF");
148  XMLCh *xmlVersion = _toDOMS("version");
149  DOMNode *aNode = doc->getElementsByTagName(xmlOmtf)->item(0);
150  DOMElement *aOMTFElement = static_cast<DOMElement *>(aNode);
151 
152  version = std::stoul(_toString(aOMTFElement->getAttribute(xmlVersion)), nullptr, 16);
153  XMLString::release(&xmlOmtf);
154  XMLString::release(&xmlVersion);
155  parser.resetDocumentPool();
156  }
157  XMLPlatformUtils::Terminate();
158 
159  return version;
160 }
163 std::vector<std::shared_ptr<GoldenPattern>> XMLConfigReader::readPatterns(const L1TMuonOverlapParams &aConfig) {
164  aGPs.clear();
165 
166  XMLPlatformUtils::Initialize();
167 
168  XMLCh *xmlGP = _toDOMS("GP");
169  std::array<XMLCh *, 4> xmliPt = {{_toDOMS("iPt1"), _toDOMS("iPt2"), _toDOMS("iPt3"), _toDOMS("iPt4")}};
170 
171  {
172  XercesDOMParser parser;
173  parser.setValidationScheme(XercesDOMParser::Val_Auto);
174  parser.setDoNamespaces(false);
175 
176  parser.parse(patternsFile.c_str());
177  xercesc::DOMDocument *doc = parser.getDocument();
178  assert(doc);
179 
180  unsigned int nElem = doc->getElementsByTagName(xmlGP)->getLength();
181  if (nElem < 1) {
182  edm::LogError("critical") << "Problem parsing XML file " << patternsFile << std::endl;
183  edm::LogError("critical") << "No GoldenPattern items: GP found" << std::endl;
184  return aGPs;
185  }
186 
187  DOMNode *aNode = nullptr;
188  DOMElement *aGPElement = nullptr;
189  unsigned int iGPNumber = 0;
190 
191  for (unsigned int iItem = 0; iItem < nElem; ++iItem) {
192  aNode = doc->getElementsByTagName(xmlGP)->item(iItem);
193  aGPElement = static_cast<DOMElement *>(aNode);
194 
195  std::unique_ptr<GoldenPattern> aGP;
196  for (unsigned int index = 1; index < 5; ++index) {
198  if (aGPElement->getAttributeNode(xmliPt[index - 1])) {
199  aGP = buildGP(aGPElement, aConfig, index, iGPNumber);
200  if (aGP) {
201  aGPs.emplace_back(std::move(aGP));
202  iGPNumber++;
203  }
204  } else {
205  aGP = buildGP(aGPElement, aConfig);
206  if (aGP) {
207  aGPs.emplace_back(std::move(aGP));
208  iGPNumber++;
209  }
210  break;
211  }
212  }
213  }
214 
215  // Reset the documents vector pool and release all the associated memory back to the system.
216  //parser->resetDocumentPool();
217  parser.resetDocumentPool();
218  }
219  XMLString::release(&xmlGP);
220  XMLString::release(&xmliPt[0]);
221  XMLString::release(&xmliPt[1]);
222  XMLString::release(&xmliPt[2]);
223  XMLString::release(&xmliPt[3]);
224 
225  XMLPlatformUtils::Terminate();
226 
227  return aGPs;
228 }
231 std::unique_ptr<GoldenPattern> XMLConfigReader::buildGP(DOMElement *aGPElement,
232  const L1TMuonOverlapParams &aConfig,
233  unsigned int index,
234  unsigned int aGPNumber) {
235  XMLCh *xmliEta = _toDOMS("iEta");
236  //index 0 means no number at the end
237  std::ostringstream stringStr;
238  if (index > 0)
239  stringStr << "iPt" << index;
240  else
241  stringStr.str("iPt");
242  XMLCh *xmliPt = _toDOMS(stringStr.str());
243  stringStr.str("");
244  if (index > 0)
245  stringStr << "value" << index;
246  else
247  stringStr.str("value");
248  XMLCh *xmlValue = _toDOMS(stringStr.str());
249 
250  XMLCh *xmliCharge = _toDOMS("iCharge");
251  XMLCh *xmlLayer = _toDOMS("Layer");
252  XMLCh *xmlRefLayer = _toDOMS("RefLayer");
253  XMLCh *xmlmeanDistPhi = _toDOMS("meanDistPhi");
254  XMLCh *xmlPDF = _toDOMS("PDF");
255 
256  unsigned int iPt = std::atoi(_toString(aGPElement->getAttribute(xmliPt)).c_str());
257  int iEta = std::atoi(_toString(aGPElement->getAttribute(xmliEta)).c_str());
258  int iCharge = std::atoi(_toString(aGPElement->getAttribute(xmliCharge)).c_str());
259  int val = 0;
260  unsigned int nLayers = aGPElement->getElementsByTagName(xmlLayer)->getLength();
261  assert(nLayers == (unsigned)aConfig.nLayers());
262 
263  DOMNode *aNode = nullptr;
264  DOMElement *aLayerElement = nullptr;
265  DOMElement *aItemElement = nullptr;
266  GoldenPattern::vector2D meanDistPhi2D(nLayers);
267  GoldenPattern::vector1D pdf1D(exp2(aConfig.nPdfAddrBits()));
268  GoldenPattern::vector3D pdf3D(aConfig.nLayers());
269  GoldenPattern::vector2D pdf2D(aConfig.nRefLayers());
270 
271  if (iPt == 0) {
272  GoldenPattern::vector1D meanDistPhi1D(aConfig.nRefLayers());
273  meanDistPhi2D.assign(aConfig.nLayers(), meanDistPhi1D);
274  pdf1D.assign(exp2(aConfig.nPdfAddrBits()), 0);
275  pdf2D.assign(aConfig.nRefLayers(), pdf1D);
276  pdf3D.assign(aConfig.nLayers(), pdf2D);
277 
278  Key aKey(iEta, iPt, iCharge, aGPNumber);
279  auto aGP = std::make_unique<GoldenPattern>(aKey, static_cast<const OMTFConfiguration *>(nullptr));
280  aGP->setMeanDistPhi(meanDistPhi2D);
281  aGP->setPdf(pdf3D);
282  return aGP;
283  }
284 
286  for (unsigned int iLayer = 0; iLayer < nLayers; ++iLayer) {
287  aNode = aGPElement->getElementsByTagName(xmlLayer)->item(iLayer);
288  aLayerElement = static_cast<DOMElement *>(aNode);
290  unsigned int nItems = aLayerElement->getElementsByTagName(xmlRefLayer)->getLength();
291  assert(nItems == (unsigned)aConfig.nRefLayers());
292  GoldenPattern::vector1D meanDistPhi1D(nItems);
293  for (unsigned int iItem = 0; iItem < nItems; ++iItem) {
294  aNode = aLayerElement->getElementsByTagName(xmlRefLayer)->item(iItem);
295  aItemElement = static_cast<DOMElement *>(aNode);
296  val = std::atoi(_toString(aItemElement->getAttribute(xmlmeanDistPhi)).c_str());
297  meanDistPhi1D[iItem] = val;
298  }
299  meanDistPhi2D[iLayer] = meanDistPhi1D;
300 
302  nItems = aLayerElement->getElementsByTagName(xmlPDF)->getLength();
303  assert(nItems == aConfig.nRefLayers() * exp2(aConfig.nPdfAddrBits()));
304  for (unsigned int iRefLayer = 0; iRefLayer < (unsigned)aConfig.nRefLayers(); ++iRefLayer) {
305  pdf1D.assign(exp2(aConfig.nPdfAddrBits()), 0);
306  for (unsigned int iPdf = 0; iPdf < exp2(aConfig.nPdfAddrBits()); ++iPdf) {
307  aNode = aLayerElement->getElementsByTagName(xmlPDF)->item(iRefLayer * exp2(aConfig.nPdfAddrBits()) + iPdf);
308  aItemElement = static_cast<DOMElement *>(aNode);
309  val = std::atoi(_toString(aItemElement->getAttribute(xmlValue)).c_str());
310  pdf1D[iPdf] = val;
311  }
312  pdf2D[iRefLayer] = pdf1D;
313  }
314  pdf3D[iLayer] = pdf2D;
315  }
316 
317  Key aKey(iEta, iPt, iCharge, aGPNumber);
318  auto aGP = std::make_unique<GoldenPattern>(aKey, static_cast<const OMTFConfiguration *>(nullptr));
319  aGP->setMeanDistPhi(meanDistPhi2D);
320  aGP->setPdf(pdf3D);
321 
322  XMLString::release(&xmliEta);
323  XMLString::release(&xmliPt);
324  XMLString::release(&xmliCharge);
325  XMLString::release(&xmlLayer);
326  XMLString::release(&xmlRefLayer);
327  XMLString::release(&xmlmeanDistPhi);
328  XMLString::release(&xmlPDF);
329  XMLString::release(&xmlValue);
330 
331  return aGP;
332 }
335 std::vector<std::vector<int>> XMLConfigReader::readEvent(unsigned int iEvent, unsigned int iProcessor, bool readEta) {
336  return OMTFinput::vector2D();
337 }
341  XMLPlatformUtils::Initialize();
342  {
343  XercesDOMParser parser;
344  parser.setValidationScheme(XercesDOMParser::Val_Auto);
345  parser.setDoNamespaces(false);
346 
347  XMLCh *xmlOMTF = _toDOMS("OMTF");
348  XMLCh *xmlversion = _toDOMS("version");
349  XMLCh *xmlGlobalData = _toDOMS("GlobalData");
350  XMLCh *xmlnPdfAddrBits = _toDOMS("nPdfAddrBits");
351  XMLCh *xmlnPdfValBits = _toDOMS("nPdfValBits");
352  XMLCh *xmlnPhiBits = _toDOMS("nPhiBits");
353  XMLCh *xmlnPhiBins = _toDOMS("nPhiBins");
354  XMLCh *xmlnProcessors = _toDOMS("nProcessors");
355  XMLCh *xmlnLogicRegions = _toDOMS("nLogicRegions");
356  XMLCh *xmlnInputs = _toDOMS("nInputs");
357  XMLCh *xmlnLayers = _toDOMS("nLayers");
358  XMLCh *xmlnRefLayers = _toDOMS("nRefLayers");
359  XMLCh *xmliProcessor = _toDOMS("iProcessor");
360  XMLCh *xmlbarrelMin = _toDOMS("barrelMin");
361  XMLCh *xmlbarrelMax = _toDOMS("barrelMax");
362  XMLCh *xmlendcap10DegMin = _toDOMS("endcap10DegMin");
363  XMLCh *xmlendcap10DegMax = _toDOMS("endcap10DegMax");
364  XMLCh *xmlendcap20DegMin = _toDOMS("endcap20DegMin");
365  XMLCh *xmlendcap20DegMax = _toDOMS("endcap20DegMax");
366  XMLCh *xmlLayerMap = _toDOMS("LayerMap");
367  XMLCh *xmlhwNumber = _toDOMS("hwNumber");
368  XMLCh *xmllogicNumber = _toDOMS("logicNumber");
369  XMLCh *xmlbendingLayer = _toDOMS("bendingLayer");
370  XMLCh *xmlconnectedToLayer = _toDOMS("connectedToLayer");
371  XMLCh *xmlRefLayerMap = _toDOMS("RefLayerMap");
372  XMLCh *xmlrefLayer = _toDOMS("refLayer");
373  XMLCh *xmlProcessor = _toDOMS("Processor");
374  XMLCh *xmlRefLayer = _toDOMS("RefLayer");
375  XMLCh *xmliRefLayer = _toDOMS("iRefLayer");
376  XMLCh *xmliGlobalPhiStart = _toDOMS("iGlobalPhiStart");
377  XMLCh *xmlRefHit = _toDOMS("RefHit");
378  XMLCh *xmliRefHit = _toDOMS("iRefHit");
379  XMLCh *xmliPhiMin = _toDOMS("iPhiMin");
380  XMLCh *xmliPhiMax = _toDOMS("iPhiMax");
381  XMLCh *xmliInput = _toDOMS("iInput");
382  XMLCh *xmliRegion = _toDOMS("iRegion");
383  XMLCh *xmlLogicRegion = _toDOMS("LogicRegion");
384  XMLCh *xmlLayer = _toDOMS("Layer");
385  XMLCh *xmliLayer = _toDOMS("iLayer");
386  XMLCh *xmliFirstInput = _toDOMS("iFirstInput");
387  XMLCh *xmlnHitsPerLayer = _toDOMS("nHitsPerLayer");
388  XMLCh *xmlnRefHits = _toDOMS("nRefHits");
389  XMLCh *xmlnTestRefHits = _toDOMS("nTestRefHits");
390  XMLCh *xmlnGoldenPatterns = _toDOMS("nGoldenPatterns");
391  XMLCh *xmlConnectionMap = _toDOMS("ConnectionMap");
392  parser.parse(configFile.c_str());
393  xercesc::DOMDocument *doc = parser.getDocument();
394  assert(doc);
395  unsigned int nElem = doc->getElementsByTagName(xmlOMTF)->getLength();
396  if (nElem != 1) {
397  edm::LogError("critical") << "Problem parsing XML file " << configFile << std::endl;
398  assert(nElem == 1);
399  }
400  DOMNode *aNode = doc->getElementsByTagName(xmlOMTF)->item(0);
401  DOMElement *aOMTFElement = static_cast<DOMElement *>(aNode);
402 
403  unsigned int version = std::stoul(_toString(aOMTFElement->getAttribute(xmlversion)), nullptr, 16);
404  aConfig->setFwVersion(version);
405 
407  nElem = aOMTFElement->getElementsByTagName(xmlGlobalData)->getLength();
408  assert(nElem == 1);
409  aNode = aOMTFElement->getElementsByTagName(xmlGlobalData)->item(0);
410  DOMElement *aElement = static_cast<DOMElement *>(aNode);
411 
412  unsigned int nPdfAddrBits = std::atoi(_toString(aElement->getAttribute(xmlnPdfAddrBits)).c_str());
413  unsigned int nPdfValBits = std::atoi(_toString(aElement->getAttribute(xmlnPdfValBits)).c_str());
414  unsigned int nHitsPerLayer = std::atoi(_toString(aElement->getAttribute(xmlnHitsPerLayer)).c_str());
415  unsigned int nPhiBits = std::atoi(_toString(aElement->getAttribute(xmlnPhiBits)).c_str());
416  unsigned int nPhiBins = std::atoi(_toString(aElement->getAttribute(xmlnPhiBins)).c_str());
417 
418  unsigned int nRefHits = std::atoi(_toString(aElement->getAttribute(xmlnRefHits)).c_str());
419  unsigned int nTestRefHits = std::atoi(_toString(aElement->getAttribute(xmlnTestRefHits)).c_str());
420  unsigned int nProcessors = std::atoi(_toString(aElement->getAttribute(xmlnProcessors)).c_str());
421  unsigned int nLogicRegions = std::atoi(_toString(aElement->getAttribute(xmlnLogicRegions)).c_str());
422  unsigned int nInputs = std::atoi(_toString(aElement->getAttribute(xmlnInputs)).c_str());
423  unsigned int nLayers = std::atoi(_toString(aElement->getAttribute(xmlnLayers)).c_str());
424  unsigned int nRefLayers = std::atoi(_toString(aElement->getAttribute(xmlnRefLayers)).c_str());
425  unsigned int nGoldenPatterns = std::atoi(_toString(aElement->getAttribute(xmlnGoldenPatterns)).c_str());
426 
427  std::vector<int> paramsVec(L1TMuonOverlapParams::GENERAL_NCONFIG);
428  paramsVec[L1TMuonOverlapParams::GENERAL_ADDRBITS] = nPdfAddrBits;
429  paramsVec[L1TMuonOverlapParams::GENERAL_VALBITS] = nPdfValBits;
430  paramsVec[L1TMuonOverlapParams::GENERAL_HITSPERLAYER] = nHitsPerLayer;
431  paramsVec[L1TMuonOverlapParams::GENERAL_PHIBITS] = nPhiBits;
433  paramsVec[L1TMuonOverlapParams::GENERAL_NREFHITS] = nRefHits;
434  paramsVec[L1TMuonOverlapParams::GENERAL_NTESTREFHITS] = nTestRefHits;
435  paramsVec[L1TMuonOverlapParams::GENERAL_NPROCESSORS] = nProcessors;
436  paramsVec[L1TMuonOverlapParams::GENERAL_NLOGIC_REGIONS] = nLogicRegions;
437  paramsVec[L1TMuonOverlapParams::GENERAL_NINPUTS] = nInputs;
439  paramsVec[L1TMuonOverlapParams::GENERAL_NREFLAYERS] = nRefLayers;
440  paramsVec[L1TMuonOverlapParams::GENERAL_NGOLDENPATTERNS] = nGoldenPatterns;
441  aConfig->setGeneralParams(paramsVec);
442 
445  std::vector<int> sectorsStart(3 * nProcessors), sectorsEnd(3 * nProcessors);
446  nElem = aOMTFElement->getElementsByTagName(xmlConnectionMap)->getLength();
447  DOMElement *aConnectionElement = nullptr;
448  for (unsigned int i = 0; i < nElem; ++i) {
449  aNode = aOMTFElement->getElementsByTagName(xmlConnectionMap)->item(i);
450  aConnectionElement = static_cast<DOMElement *>(aNode);
451  unsigned int iProcessor = std::atoi(_toString(aConnectionElement->getAttribute(xmliProcessor)).c_str());
452  unsigned int barrelMin = std::atoi(_toString(aConnectionElement->getAttribute(xmlbarrelMin)).c_str());
453  unsigned int barrelMax = std::atoi(_toString(aConnectionElement->getAttribute(xmlbarrelMax)).c_str());
454  unsigned int endcap10DegMin = std::atoi(_toString(aConnectionElement->getAttribute(xmlendcap10DegMin)).c_str());
455  unsigned int endcap10DegMax = std::atoi(_toString(aConnectionElement->getAttribute(xmlendcap10DegMax)).c_str());
456  unsigned int endcap20DegMin = std::atoi(_toString(aConnectionElement->getAttribute(xmlendcap20DegMin)).c_str());
457  unsigned int endcap20DegMax = std::atoi(_toString(aConnectionElement->getAttribute(xmlendcap20DegMax)).c_str());
458 
459  sectorsStart[iProcessor] = barrelMin;
460  sectorsStart[iProcessor + nProcessors] = endcap10DegMin;
461  sectorsStart[iProcessor + 2 * nProcessors] = endcap20DegMin;
462 
463  sectorsEnd[iProcessor] = barrelMax;
464  sectorsEnd[iProcessor + nProcessors] = endcap10DegMax;
465  sectorsEnd[iProcessor + 2 * nProcessors] = endcap20DegMax;
466  }
467  aConfig->setConnectedSectorsStart(sectorsStart);
468  aConfig->setConnectedSectorsEnd(sectorsEnd);
469 
471  std::vector<L1TMuonOverlapParams::LayerMapNode> aLayerMapVec;
473 
474  nElem = aOMTFElement->getElementsByTagName(xmlLayerMap)->getLength();
475  DOMElement *aLayerElement = nullptr;
476  for (unsigned int i = 0; i < nElem; ++i) {
477  aNode = aOMTFElement->getElementsByTagName(xmlLayerMap)->item(i);
478  aLayerElement = static_cast<DOMElement *>(aNode);
479  unsigned int hwNumber = std::atoi(_toString(aLayerElement->getAttribute(xmlhwNumber)).c_str());
480  unsigned int logicNumber = std::atoi(_toString(aLayerElement->getAttribute(xmllogicNumber)).c_str());
481  unsigned int isBendingLayer = std::atoi(_toString(aLayerElement->getAttribute(xmlbendingLayer)).c_str());
482  unsigned int iConnectedLayer = std::atoi(_toString(aLayerElement->getAttribute(xmlconnectedToLayer)).c_str());
483  aLayerMapNode.logicNumber = logicNumber;
484  aLayerMapNode.hwNumber = hwNumber;
485  aLayerMapNode.connectedToLayer = iConnectedLayer;
486  aLayerMapNode.bendingLayer = isBendingLayer;
487  aLayerMapVec.push_back(aLayerMapNode);
488  }
489  aConfig->setLayerMap(aLayerMapVec);
490 
492  std::vector<L1TMuonOverlapParams::RefLayerMapNode> aRefLayerMapVec;
494 
495  nElem = aOMTFElement->getElementsByTagName(xmlRefLayerMap)->getLength();
496  DOMElement *aRefLayerElement = nullptr;
497  for (unsigned int i = 0; i < nElem; ++i) {
498  aNode = aOMTFElement->getElementsByTagName(xmlRefLayerMap)->item(i);
499  aRefLayerElement = static_cast<DOMElement *>(aNode);
500  unsigned int refLayer = std::atoi(_toString(aRefLayerElement->getAttribute(xmlrefLayer)).c_str());
501  unsigned int logicNumber = std::atoi(_toString(aRefLayerElement->getAttribute(xmllogicNumber)).c_str());
502  aRefLayerNode.refLayer = refLayer;
503  aRefLayerNode.logicNumber = logicNumber;
504  aRefLayerMapVec.push_back(aRefLayerNode);
505  }
506  aConfig->setRefLayerMap(aRefLayerMapVec);
507 
508  std::vector<int> aGlobalPhiStartVec(nProcessors * nRefLayers);
509 
510  std::vector<L1TMuonOverlapParams::RefHitNode> aRefHitMapVec(nProcessors * nRefHits);
512 
513  std::vector<L1TMuonOverlapParams::LayerInputNode> aLayerInputMapVec(nProcessors * nLogicRegions * nLayers);
514  L1TMuonOverlapParams::LayerInputNode aLayerInputNode;
515 
516  nElem = aOMTFElement->getElementsByTagName(xmlProcessor)->getLength();
517  assert(nElem == nProcessors);
518  DOMElement *aProcessorElement = nullptr;
519  for (unsigned int i = 0; i < nElem; ++i) {
520  aNode = aOMTFElement->getElementsByTagName(xmlProcessor)->item(i);
521  aProcessorElement = static_cast<DOMElement *>(aNode);
522  unsigned int iProcessor = std::atoi(_toString(aProcessorElement->getAttribute(xmliProcessor)).c_str());
523  unsigned int nElem1 = aProcessorElement->getElementsByTagName(xmlRefLayer)->getLength();
524  assert(nElem1 == nRefLayers);
525  DOMElement *aRefLayerElement = nullptr;
526  for (unsigned int ii = 0; ii < nElem1; ++ii) {
527  aNode = aProcessorElement->getElementsByTagName(xmlRefLayer)->item(ii);
528  aRefLayerElement = static_cast<DOMElement *>(aNode);
529  unsigned int iRefLayer = std::atoi(_toString(aRefLayerElement->getAttribute(xmliRefLayer)).c_str());
530  int iPhi = std::atoi(_toString(aRefLayerElement->getAttribute(xmliGlobalPhiStart)).c_str());
531  aGlobalPhiStartVec[iRefLayer + iProcessor * nRefLayers] = iPhi;
532  }
534  nElem1 = aProcessorElement->getElementsByTagName(xmlRefHit)->getLength();
535  assert((iProcessor == 0 && nElem1 == nRefHits) || (iProcessor != 0 && nElem1 == 0));
536  DOMElement *aRefHitElement = nullptr;
537  for (unsigned int ii = 0; ii < nElem1; ++ii) {
538  aNode = aProcessorElement->getElementsByTagName(xmlRefHit)->item(ii);
539  aRefHitElement = static_cast<DOMElement *>(aNode);
540  unsigned int iRefHit = std::atoi(_toString(aRefHitElement->getAttribute(xmliRefHit)).c_str());
541  int iPhiMin = std::atoi(_toString(aRefHitElement->getAttribute(xmliPhiMin)).c_str());
542  int iPhiMax = std::atoi(_toString(aRefHitElement->getAttribute(xmliPhiMax)).c_str());
543  unsigned int iInput = std::atoi(_toString(aRefHitElement->getAttribute(xmliInput)).c_str());
544  unsigned int iRegion = std::atoi(_toString(aRefHitElement->getAttribute(xmliRegion)).c_str());
545  unsigned int iRefLayer = std::atoi(_toString(aRefHitElement->getAttribute(xmliRefLayer)).c_str());
546 
547  aRefHitNode.iRefHit = iRefHit;
548  aRefHitNode.iPhiMin = iPhiMin;
549  aRefHitNode.iPhiMax = iPhiMax;
550  aRefHitNode.iInput = iInput;
551  aRefHitNode.iRegion = iRegion;
552  aRefHitNode.iRefLayer = iRefLayer;
553  for (unsigned int iProcessor = 0; iProcessor < nProcessors; iProcessor++)
554  aRefHitMapVec[iRefHit + iProcessor * nRefHits] = aRefHitNode;
555  }
557  unsigned int nElem2 = aProcessorElement->getElementsByTagName(xmlLogicRegion)->getLength();
558  assert((iProcessor == 0 && nElem2 == nLogicRegions) || (iProcessor != 0 && nElem2 == 0));
559  DOMElement *aRegionElement = nullptr;
560  for (unsigned int ii = 0; ii < nElem2; ++ii) {
561  aNode = aProcessorElement->getElementsByTagName(xmlLogicRegion)->item(ii);
562  aRegionElement = static_cast<DOMElement *>(aNode);
563  unsigned int iRegion = std::atoi(_toString(aRegionElement->getAttribute(xmliRegion)).c_str());
564  unsigned int nElem3 = aRegionElement->getElementsByTagName(xmlLayer)->getLength();
565  assert(nElem3 == nLayers);
566  DOMElement *aLayerElement = nullptr;
567  for (unsigned int iii = 0; iii < nElem3; ++iii) {
568  aNode = aRegionElement->getElementsByTagName(xmlLayer)->item(iii);
569  aLayerElement = static_cast<DOMElement *>(aNode);
570  unsigned int iLayer = std::atoi(_toString(aLayerElement->getAttribute(xmliLayer)).c_str());
571  unsigned int iFirstInput = std::atoi(_toString(aLayerElement->getAttribute(xmliFirstInput)).c_str());
572  unsigned int nInputs = std::atoi(_toString(aLayerElement->getAttribute(xmlnInputs)).c_str());
573  aLayerInputNode.iLayer = iLayer;
574  aLayerInputNode.iFirstInput = iFirstInput;
575  aLayerInputNode.nInputs = nInputs;
576  for (unsigned int iProcessor = 0; iProcessor < nProcessors; ++iProcessor)
577  aLayerInputMapVec[iLayer + iRegion * nLayers + iProcessor * nLayers * nLogicRegions] = aLayerInputNode;
578  }
579  }
580  }
581 
582  aConfig->setGlobalPhiStartMap(aGlobalPhiStartVec);
583  aConfig->setLayerInputMap(aLayerInputMapVec);
584  aConfig->setRefHitMap(aRefHitMapVec);
585 
586  // Reset the documents vector pool and release all the associated memory back to the system.
587  parser.resetDocumentPool();
588 
589  XMLString::release(&xmlOMTF);
590  XMLString::release(&xmlversion);
591  XMLString::release(&xmlGlobalData);
592  XMLString::release(&xmlnPdfAddrBits);
593  XMLString::release(&xmlnPdfValBits);
594  XMLString::release(&xmlnPhiBits);
595  XMLString::release(&xmlnPhiBins);
596  XMLString::release(&xmlnProcessors);
597  XMLString::release(&xmlnLogicRegions);
598  XMLString::release(&xmlnInputs);
599  XMLString::release(&xmlnLayers);
600  XMLString::release(&xmlnRefLayers);
601  XMLString::release(&xmliProcessor);
602  XMLString::release(&xmlbarrelMin);
603  XMLString::release(&xmlbarrelMax);
604  XMLString::release(&xmlendcap10DegMin);
605  XMLString::release(&xmlendcap10DegMax);
606  XMLString::release(&xmlendcap20DegMin);
607  XMLString::release(&xmlendcap20DegMax);
608  XMLString::release(&xmlLayerMap);
609  XMLString::release(&xmlhwNumber);
610  XMLString::release(&xmllogicNumber);
611  XMLString::release(&xmlbendingLayer);
612  XMLString::release(&xmlconnectedToLayer);
613  XMLString::release(&xmlRefLayerMap);
614  XMLString::release(&xmlrefLayer);
615  XMLString::release(&xmlProcessor);
616  XMLString::release(&xmlRefLayer);
617  XMLString::release(&xmliRefLayer);
618  XMLString::release(&xmliGlobalPhiStart);
619  XMLString::release(&xmlRefHit);
620  XMLString::release(&xmliRefHit);
621  XMLString::release(&xmliPhiMin);
622  XMLString::release(&xmliPhiMax);
623  XMLString::release(&xmliInput);
624  XMLString::release(&xmliRegion);
625  XMLString::release(&xmlLogicRegion);
626  XMLString::release(&xmlLayer);
627  XMLString::release(&xmliLayer);
628  XMLString::release(&xmliFirstInput);
629  XMLString::release(&xmlnHitsPerLayer);
630  XMLString::release(&xmlnRefHits);
631  XMLString::release(&xmlnTestRefHits);
632  XMLString::release(&xmlnGoldenPatterns);
633  XMLString::release(&xmlConnectionMap);
634  }
635  XMLPlatformUtils::Terminate();
636 }
639 
640 // xercesc::XercesDOMParser *parser;
641 // xercesc::DOMDocument* doc;
L1TMuonOverlapParams::LayerInputNode::iFirstInput
unsigned int iFirstInput
Definition: L1TMuonOverlapParams.h:80
L1TMuonOverlapParams::LayerMapNode::connectedToLayer
unsigned int connectedToLayer
Definition: L1TMuonOverlapParams.h:45
XMLConfigReader::~XMLConfigReader
~XMLConfigReader()
Definition: XMLConfigReader.cc:53
L1TMuonOverlapParams::RefHitNode::iRegion
unsigned int iRegion
Definition: L1TMuonOverlapParams.h:71
common_cff.doc
doc
Definition: common_cff.py:54
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
L1TMuonOverlapParams::setRefHitMap
void setRefHitMap(const std::vector< RefHitNode > &aVector)
Definition: L1TMuonOverlapParams.h:171
L1TMuonOverlapParams::RefHitNode::iRefHit
unsigned int iRefHit
Definition: L1TMuonOverlapParams.h:69
L1TMuonOverlapParams::GENERAL_NINPUTS
Definition: L1TMuonOverlapParams.h:115
_toString
XERCES_CPP_NAMESPACE_USE std::string _toString(XMLCh const *toTranscode)
Definition: XMLConfigReader.cc:31
L1TMuonOverlapParams::LayerInputNode::iLayer
unsigned int iLayer
Definition: L1TMuonOverlapParams.h:81
L1TMuonOverlapParams::RefHitNode::iPhiMax
int iPhiMax
Definition: L1TMuonOverlapParams.h:68
cms::cuda::assert
assert(be >=bs)
XMLConfigReader.h
writedatasetfile.parser
parser
Definition: writedatasetfile.py:7
OMTFinput::vector2D
std::vector< vector1D > vector2D
Definition: OMTFinput.h:14
XERCES_CPP_NAMESPACE_USE
Definition: XMLConfigWriter.cc:40
GoldenPattern::vector1D
std::vector< int > vector1D
Definition: GoldenPattern.h:46
L1TMuonOverlapParams::GENERAL_NLOGIC_REGIONS
Definition: L1TMuonOverlapParams.h:114
L1TMuonOverlapParams::GENERAL_NTESTREFHITS
Definition: L1TMuonOverlapParams.h:112
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
L1TMuonOverlapParams::GENERAL_HITSPERLAYER
Definition: L1TMuonOverlapParams.h:108
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
L1TMuonOverlapParams::GENERAL_NREFLAYERS
Definition: L1TMuonOverlapParams.h:117
L1TMuonOverlapParams::setGeneralParams
void setGeneralParams(const std::vector< int > &paramsVec)
Definition: L1TMuonOverlapParams.h:134
RPCConst.h
L1TMuonOverlapParams::setConnectedSectorsEnd
void setConnectedSectorsEnd(const std::vector< int > &aVector)
Definition: L1TMuonOverlapParams.h:182
L1TMuonOverlapParams::RefLayerMapNode
Definition: L1TMuonOverlapParams.h:52
L1TMuonOverlapParams::GENERAL_NPROCESSORS
Definition: L1TMuonOverlapParams.h:113
Key
Definition: GoldenPattern.h:15
XMLConfigReader::configFile
std::string configFile
Definition: XMLConfigReader.h:52
GoldenPattern::vector3D
std::vector< vector2D > vector3D
Definition: GoldenPattern.h:48
L1TMuonOverlapParams::GENERAL_NLAYERS
Definition: L1TMuonOverlapParams.h:116
_toDOMS
XMLCh * _toDOMS(std::string temp)
Definition: XMLConfigReader.cc:36
L1TMuonOverlapParams::GENERAL_VALBITS
Definition: L1TMuonOverlapParams.h:107
l1t::LUT::read
int read(std::istream &stream)
Definition: LUT.cc:11
XMLConfigReader::readEvent
std::vector< std::vector< int > > readEvent(unsigned int iEvent=0, unsigned int iProcessor=0, bool readEta=false)
Definition: XMLConfigReader.cc:335
XMLConfigReader::readPatterns
std::vector< std::shared_ptr< GoldenPattern > > readPatterns(const L1TMuonOverlapParams &aConfig)
Definition: XMLConfigReader.cc:163
L1TMuonOverlapParams
Definition: L1TMuonOverlapParams.h:14
L1TMuonOverlapParams::GENERAL_NREFHITS
Definition: L1TMuonOverlapParams.h:111
L1TMuonOverlapParams.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MuonTCMETValueMapProducer_cff.nLayers
nLayers
Definition: MuonTCMETValueMapProducer_cff.py:38
L1TMuonOverlapParams::setFwVersion
void setFwVersion(unsigned fwVersion)
Definition: L1TMuonOverlapParams.h:130
L1TMuonOverlapParams::setLayerMap
void setLayerMap(const std::vector< LayerMapNode > &aVector)
Connections definitions.
Definition: L1TMuonOverlapParams.h:167
fetchall_from_DQM_v2.release
release
Definition: fetchall_from_DQM_v2.py:92
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
XMLConfigReader::XMLConfigReader
XMLConfigReader()
Definition: XMLConfigReader.cc:42
recoMuon::in
Definition: RecoMuonEnumerators.h:6
L1TMuonOverlapParams::nRefLayers
int nRefLayers() const
Definition: L1TMuonOverlapParams.h:162
iEvent
int iEvent
Definition: GenABIO.cc:224
XMLConfigReader::readLUTs
void readLUTs(std::vector< l1t::LUT * > luts, const L1TMuonOverlapParams &aConfig, const std::vector< std::string > &types)
Definition: XMLConfigReader.cc:59
L1TMuonOverlapParams::setGlobalPhiStartMap
void setGlobalPhiStartMap(const std::vector< int > &aVector)
Definition: L1TMuonOverlapParams.h:173
L1TMuonOverlapParams::RefHitNode::iPhiMin
int iPhiMin
Definition: L1TMuonOverlapParams.h:68
L1TMuonOverlapParams::setLayerInputMap
void setLayerInputMap(const std::vector< LayerInputNode > &aVector)
Definition: L1TMuonOverlapParams.h:175
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
L1TMuonOverlapParams::GENERAL_PHIBINS
Definition: L1TMuonOverlapParams.h:110
L1TMuonOverlapParams::setConnectedSectorsStart
void setConnectedSectorsStart(const std::vector< int > &aVector)
Definition: L1TMuonOverlapParams.h:177
XMLConfigReader::readConfig
void readConfig(const std::string fName)
XMLConfigReader::patternsFile
std::string patternsFile
Definition: XMLConfigReader.h:53
types
types
Definition: AlignPCLThresholds_PayloadInspector.cc:30
L1TMuonOverlapParams::RefHitNode::iRefLayer
unsigned int iRefLayer
Definition: L1TMuonOverlapParams.h:70
heppy_batch.val
val
Definition: heppy_batch.py:351
eostools.move
def move(src, dest)
Definition: eostools.py:511
L1TMuonOverlapParams::nPdfAddrBits
int nPdfAddrBits() const
Access to specific general settings.
Definition: L1TMuonOverlapParams.h:140
XMLConfigReader::getPatternsVersion
unsigned int getPatternsVersion() const
Definition: XMLConfigReader.cc:132
l1t::LUT
Definition: LUT.h:29
L1TMuonOverlapParams::LayerInputNode::nInputs
unsigned int nInputs
Definition: L1TMuonOverlapParams.h:82
L1TMuonOverlapParams::LayerMapNode::hwNumber
unsigned int hwNumber
short layer number used within OMTF emulator
Definition: L1TMuonOverlapParams.h:35
XMLConfigReader::buildGP
std::unique_ptr< GoldenPattern > buildGP(xercesc::DOMElement *aGPElement, const L1TMuonOverlapParams &aConfig, unsigned int index=0, unsigned int aGPNumber=999)
Definition: XMLConfigReader.cc:231
L1TMuonOverlapParams::LayerInputNode
Definition: L1TMuonOverlapParams.h:78
L1TMuonOverlapParams::RefLayerMapNode::refLayer
unsigned int refLayer
Reference layer number.
Definition: L1TMuonOverlapParams.h:55
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
GoldenPattern.h
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
L1TowerCalibrationProducer_cfi.iEta
iEta
Definition: L1TowerCalibrationProducer_cfi.py:60
L1TMuonOverlapParams::setRefLayerMap
void setRefLayerMap(const std::vector< RefLayerMapNode > &aVector)
Definition: L1TMuonOverlapParams.h:169
L1TMuonOverlapParams::GENERAL_NCONFIG
Definition: L1TMuonOverlapParams.h:119
L1TMuonOverlapParams::RefHitNode
Definition: L1TMuonOverlapParams.h:65
L1TMuonOverlapParams::RefHitNode::iInput
unsigned int iInput
Definition: L1TMuonOverlapParams.h:67
L1TMuonOverlapParams::LayerMapNode::logicNumber
unsigned int logicNumber
logic numer of the layer
Definition: L1TMuonOverlapParams.h:38
L1TMuonOverlapParams::LayerMapNode
Definition: L1TMuonOverlapParams.h:32
ecaldqm::binning::nPhiBins
Definition: MESetBinningUtils.h:69
L1TMuonOverlapParams::nLayers
int nLayers() const
Definition: L1TMuonOverlapParams.h:160
OMTFinput.h
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
GoldenPattern::vector2D
std::vector< vector1D > vector2D
Definition: GoldenPattern.h:47
L1TMuonOverlapParams::LayerMapNode::bendingLayer
bool bendingLayer
Is this a bending layers?
Definition: L1TMuonOverlapParams.h:41
L1TMuonOverlapParams::GENERAL_NGOLDENPATTERNS
Definition: L1TMuonOverlapParams.h:118
XMLConfigReader::aGPs
std::vector< std::shared_ptr< GoldenPattern > > aGPs
Cache with GPs read.
Definition: XMLConfigReader.h:65
cuy.ii
ii
Definition: cuy.py:590
L1TMuonOverlapParams::GENERAL_ADDRBITS
Definition: L1TMuonOverlapParams.h:106
L1TMuonOverlapParams::GENERAL_PHIBITS
Definition: L1TMuonOverlapParams.h:109
L1TMuonOverlapParams::RefLayerMapNode::logicNumber
unsigned int logicNumber
Corresponding logical layer number.
Definition: L1TMuonOverlapParams.h:58