CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
XMLConfigReader Class Reference

#include <XMLConfigReader.h>

Public Member Functions

unsigned int getPatternsVersion () const
 
void readConfig (const std::string fName)
 
void readConfig (L1TMuonOverlapParams *aConfig) const
 
std::vector< std::vector< int > > readEvent (unsigned int iEvent=0, unsigned int iProcessor=0, bool readEta=false)
 
void readLUTs (std::vector< l1t::LUT * > luts, const L1TMuonOverlapParams &aConfig, const std::vector< std::string > &types)
 
std::vector< std::shared_ptr< GoldenPattern > > readPatterns (const L1TMuonOverlapParams &aConfig)
 
void setConfigFile (const std::string &fName)
 
void setEventsFile (const std::string &fName)
 
void setPatternsFile (const std::string &fName)
 
 XMLConfigReader ()
 
 ~XMLConfigReader ()
 

Private Member Functions

std::unique_ptr< GoldenPatternbuildGP (xercesc::DOMElement *aGPElement, const L1TMuonOverlapParams &aConfig, unsigned int index=0, unsigned int aGPNumber=999)
 

Private Attributes

std::vector< std::shared_ptr< GoldenPattern > > aGPs
 Cache with GPs read. More...
 
std::string configFile
 
std::string eventsFile
 
std::string patternsFile
 

Detailed Description

Definition at line 27 of file XMLConfigReader.h.

Constructor & Destructor Documentation

XMLConfigReader::XMLConfigReader ( )

Initialise XML parser

Definition at line 42 of file XMLConfigReader.cc.

42  {
43 
44  //XMLPlatformUtils::Initialize();
45 
47  //parser = new XercesDOMParser();
48  //parser->setValidationScheme(XercesDOMParser::Val_Auto);
49  //parser->setDoNamespaces(false);
50 
51  //doc = 0;
52 }
XMLConfigReader::~XMLConfigReader ( )

Definition at line 54 of file XMLConfigReader.cc.

55 {
56  // delete parser;
57  //XMLPlatformUtils::Terminate();
58 }

Member Function Documentation

std::unique_ptr< GoldenPattern > XMLConfigReader::buildGP ( xercesc::DOMElement *  aGPElement,
const L1TMuonOverlapParams aConfig,
unsigned int  index = 0,
unsigned int  aGPNumber = 999 
)
private

Build empty GP

Loop over layers

MeanDistPhi vector

PDF vector

Definition at line 230 of file XMLConfigReader.cc.

References _toDOMS(), _toString(), diffTreeTool::index, MuonTCMETValueMapProducer_cff::nLayers, L1TMuonOverlapParams::nLayers(), L1TMuonOverlapParams::nPdfAddrBits(), L1TMuonOverlapParams::nRefLayers(), fetchall_from_DQM_v2::release, and heppy_batch::val.

Referenced by readPatterns().

233  {
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().c_str());
242  stringStr.str("");
243  if (index>0) stringStr<<"value"<<index;
244  else stringStr.str("value");
245  XMLCh *xmlValue=_toDOMS(stringStr.str().c_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 = 0;
261  DOMElement* aLayerElement = 0;
262  DOMElement* aItemElement = 0;
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 }
std::vector< int > vector1D
Definition: GoldenPattern.h:48
XERCES_CPP_NAMESPACE_USE std::string _toString(XMLCh const *toTranscode)
XMLCh * _toDOMS(std::string temp)
std::vector< vector1D > vector2D
Definition: GoldenPattern.h:49
std::vector< vector2D > vector3D
Definition: GoldenPattern.h:50
int nPdfAddrBits() const
Access to specific general settings.
unsigned int XMLConfigReader::getPatternsVersion ( ) const

Definition at line 128 of file XMLConfigReader.cc.

References _toDOMS(), _toString(), common_cff::doc, createfilelist::parser, patternsFile, fetchall_from_DQM_v2::release, and jets_cff::version.

Referenced by L1TMuonOverlapParamsESProducer::L1TMuonOverlapParamsESProducer().

128  {
129 
130  if(!patternsFile.size()) 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 }
XERCES_CPP_NAMESPACE_USE std::string _toString(XMLCh const *toTranscode)
XMLCh * _toDOMS(std::string temp)
std::string patternsFile
void XMLConfigReader::readConfig ( const std::string  fName)
void XMLConfigReader::readConfig ( L1TMuonOverlapParams aConfig) const

Addresing bits numbers

Chamber sectors connections to logic processros. Start/End values for all processors, and chamber types are put into a single vector

hw <-> logic numbering map

ref<->logic numberig map

Definition at line 341 of file XMLConfigReader.cc.

References _toDOMS(), _toString(), L1TMuonOverlapParams::LayerMapNode::bendingLayer, configFile, L1TMuonOverlapParams::LayerMapNode::connectedToLayer, common_cff::doc, L1TMuonOverlapParams::GENERAL_ADDRBITS, L1TMuonOverlapParams::GENERAL_HITSPERLAYER, L1TMuonOverlapParams::GENERAL_NCONFIG, L1TMuonOverlapParams::GENERAL_NGOLDENPATTERNS, L1TMuonOverlapParams::GENERAL_NINPUTS, L1TMuonOverlapParams::GENERAL_NLAYERS, L1TMuonOverlapParams::GENERAL_NLOGIC_REGIONS, L1TMuonOverlapParams::GENERAL_NPROCESSORS, L1TMuonOverlapParams::GENERAL_NREFHITS, L1TMuonOverlapParams::GENERAL_NREFLAYERS, L1TMuonOverlapParams::GENERAL_NTESTREFHITS, L1TMuonOverlapParams::GENERAL_PHIBINS, L1TMuonOverlapParams::GENERAL_PHIBITS, L1TMuonOverlapParams::GENERAL_VALBITS, L1TMuonOverlapParams::LayerMapNode::hwNumber, mps_fire::i, L1TMuonOverlapParams::LayerInputNode::iFirstInput, cuy::ii, L1TMuonOverlapParams::RefHitNode::iInput, L1TMuonOverlapParams::LayerInputNode::iLayer, L1TMuonOverlapParams::RefHitNode::iPhiMax, L1TMuonOverlapParams::RefHitNode::iPhiMin, L1TMuonOverlapParams::RefHitNode::iRefHit, L1TMuonOverlapParams::RefHitNode::iRefLayer, L1TMuonOverlapParams::RefHitNode::iRegion, L1TMuonOverlapParams::LayerMapNode::logicNumber, L1TMuonOverlapParams::RefLayerMapNode::logicNumber, L1TMuonOverlapParams::LayerInputNode::nInputs, MuonTCMETValueMapProducer_cff::nLayers, ecaldqm::binning::nPhiBins, createfilelist::parser, L1TMuonOverlapParams::RefLayerMapNode::refLayer, fetchall_from_DQM_v2::release, L1TMuonOverlapParams::setConnectedSectorsEnd(), L1TMuonOverlapParams::setConnectedSectorsStart(), L1TMuonOverlapParams::setFwVersion(), L1TMuonOverlapParams::setGeneralParams(), L1TMuonOverlapParams::setGlobalPhiStartMap(), L1TMuonOverlapParams::setLayerInputMap(), L1TMuonOverlapParams::setLayerMap(), L1TMuonOverlapParams::setRefHitMap(), L1TMuonOverlapParams::setRefLayerMap(), and jets_cff::version.

341  {
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 = 0;
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 = 0;
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 = 0;
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 = 0;
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 = 0;
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 = 0;
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 = 0;
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 = 0;
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 }
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
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
XMLCh * _toDOMS(std::string temp)
void setGeneralParams(const std::vector< int > &paramsVec)
bool bendingLayer
Is this a bending layers?
ii
Definition: cuy.py:588
void setConnectedSectorsStart(const std::vector< int > &aVector)
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)
unsigned int logicNumber
Corresponding logical layer number.
void setFwVersion(unsigned fwVersion)
std::string configFile
std::vector< std::vector< int > > XMLConfigReader::readEvent ( unsigned int  iEvent = 0,
unsigned int  iProcessor = 0,
bool  readEta = false 
)

Definition at line 332 of file XMLConfigReader.cc.

Referenced by OMTFinput::readData().

334  {
335 
336  return OMTFinput::vector2D();
337 
338 }
std::vector< vector1D > vector2D
Definition: OMTFinput.h:16
void XMLConfigReader::readLUTs ( std::vector< l1t::LUT * >  luts,
const L1TMuonOverlapParams aConfig,
const std::vector< std::string > &  types 
)

Fill payload string

Prepare the header

Read the data into LUT

Definition at line 61 of file XMLConfigReader.cc.

References aGPs, mps_fire::i, recoMuon::in, lumiPlot::lut, L1TMuonOverlapParams::nLayers(), L1TMuonOverlapParams::nPdfAddrBits(), L1TMuonOverlapParams::nRefLayers(), MillePedeFileConverter_cfg::out, l1t::LUT::read(), readPatterns(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by L1TMuonOverlapParamsESProducer::readPatternsXML().

61  {
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 }
type
Definition: HCALResponse.h:21
int read(std::istream &stream)
Definition: LUT.cc:35
std::vector< std::shared_ptr< GoldenPattern > > readPatterns(const L1TMuonOverlapParams &aConfig)
std::vector< std::shared_ptr< GoldenPattern > > aGPs
Cache with GPs read.
int nPdfAddrBits() const
Access to specific general settings.
Definition: LUT.h:29
std::vector< std::shared_ptr< GoldenPattern > > XMLConfigReader::readPatterns ( const L1TMuonOverlapParams aConfig)

Patterns XML format backward compatibility. Can use both packed by 4, or by 1 XML files.

Definition at line 159 of file XMLConfigReader.cc.

References _toDOMS(), aGPs, buildGP(), common_cff::doc, diffTreeTool::index, eostools::move(), createfilelist::parser, patternsFile, and fetchall_from_DQM_v2::release.

Referenced by readLUTs().

159  {
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 = 0;
185  DOMElement* aGPElement = 0;
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 }
XMLCh * _toDOMS(std::string temp)
std::string patternsFile
std::vector< std::shared_ptr< GoldenPattern > > aGPs
Cache with GPs read.
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
void XMLConfigReader::setConfigFile ( const std::string &  fName)
inline

Definition at line 36 of file XMLConfigReader.h.

Referenced by L1TMuonOverlapParamsESProducer::L1TMuonOverlapParamsESProducer().

36 {configFile = fName;}
std::string configFile
void XMLConfigReader::setEventsFile ( const std::string &  fName)
inline

Definition at line 40 of file XMLConfigReader.h.

References iEvent, edm::readConfig(), and cutBasedMuonId_MuonPOG_V0_cff::types.

40 {eventsFile = fName;}
std::string eventsFile
void XMLConfigReader::setPatternsFile ( const std::string &  fName)
inline

Definition at line 38 of file XMLConfigReader.h.

Referenced by L1TMuonOverlapParamsESProducer::L1TMuonOverlapParamsESProducer().

38 {patternsFile = fName;}
std::string patternsFile

Member Data Documentation

std::vector<std::shared_ptr<GoldenPattern> > XMLConfigReader::aGPs
private

Cache with GPs read.

Definition at line 69 of file XMLConfigReader.h.

Referenced by readLUTs(), and readPatterns().

std::string XMLConfigReader::configFile
private

Definition at line 56 of file XMLConfigReader.h.

Referenced by readConfig(), and cmsswPreprocessor.CmsswPreprocessor::run().

std::string XMLConfigReader::eventsFile
private

Definition at line 58 of file XMLConfigReader.h.

std::string XMLConfigReader::patternsFile
private

Definition at line 57 of file XMLConfigReader.h.

Referenced by getPatternsVersion(), and readPatterns().