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