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