14 #include "xercesc/framework/StdOutFormatTarget.hpp"
15 #include "xercesc/framework/LocalFileFormatTarget.hpp"
16 #include "xercesc/parsers/XercesDOMParser.hpp"
17 #include "xercesc/dom/DOM.hpp"
18 #include "xercesc/dom/DOMException.hpp"
19 #include "xercesc/dom/DOMImplementation.hpp"
20 #include "xercesc/sax/HandlerBase.hpp"
21 #include "xercesc/util/XMLString.hpp"
22 #include "xercesc/util/PlatformUtils.hpp"
23 #include "xercesc/util/XercesDefs.hpp"
24 XERCES_CPP_NAMESPACE_USE
43 XMLPlatformUtils::Initialize();
46 parser =
new XercesDOMParser();
47 parser->setValidationScheme(XercesDOMParser::Val_Auto);
48 parser->setDoNamespaces(
false);
56 std::stringstream strStream;
60 if(type==
"iCharge") outWidth = 1;
61 if(type==
"iEta") outWidth = 2;
62 if(type==
"iPt") outWidth = 9;
63 if(type==
"meanDistPhi"){
73 strStream <<
"#<header> V1 "<<totalInWidth<<
" "<<outWidth<<
" </header> "<<std::endl;
80 if(type==
"iCharge") out = it->key().theCharge==-1 ? 0:1;
81 if(type==
"iEta") out = it->key().theEtaCode;
82 if(type==
"iPt") out = it->key().thePtCode;
83 if(type==
"meanDistPhi"){
84 for(
unsigned int iLayer = 0;iLayer<(unsigned) aConfig.
nLayers();++iLayer){
85 for(
unsigned int iRefLayer=0;iRefLayer<(unsigned) aConfig.
nRefLayers();++iRefLayer){
86 out = (1<<(outWidth-1)) + it->meanDistPhiValue(iLayer,iRefLayer);
87 strStream<<in<<
" "<<out<<std::endl;
93 for(
unsigned int iLayer = 0;iLayer<(unsigned)aConfig.
nLayers();++iLayer){
94 for(
unsigned int iRefLayer=0;iRefLayer<(unsigned)aConfig.
nRefLayers();++iRefLayer){
95 for(
unsigned int iPdf=0;iPdf<exp2(aConfig.
nPdfAddrBits());++iPdf){
96 out = it->pdfValue(iLayer,iRefLayer,iPdf);
97 strStream<<in<<
" "<<out<<std::endl;
103 if(type!=
"meanDistPhi" && type!=
"pdf"){
104 strStream<<in<<
" "<<out<<std::endl;
109 lut->
read(strStream);
118 xercesc::DOMDocument*
doc =
parser->getDocument();
121 unsigned int nElem = doc->getElementsByTagName(
_toDOMS(
"GP"))->getLength();
124 edm::LogError(
"critical")<<
"No GoldenPattern items: GP found"<<std::endl;
129 DOMElement* aGPElement = 0;
130 for(
unsigned int iItem=0;iItem<nElem;++iItem){
131 aNode = doc->getElementsByTagName(
_toDOMS(
"GP"))->item(iItem);
132 aGPElement =
static_cast<DOMElement *
>(aNode);
134 std::ostringstream stringStr;
138 stringStr<<
"iPt"<<
index;
140 if(aGPElement->getAttributeNode(
_toDOMS(stringStr.str().c_str()))){
141 aGP =
buildGP(aGPElement, aConfig, index);
142 if(aGP)
aGPs.push_back(aGP);
145 aGP =
buildGP(aGPElement, aConfig);
146 if(aGP)
aGPs.push_back(aGP);
161 std::ostringstream stringStr;
162 if(index>0) stringStr<<
"iPt"<<
index;
163 else stringStr.str(
"iPt");
165 unsigned int iPt = std::atoi(
_toString(aGPElement->getAttribute(
_toDOMS(stringStr.str().c_str()))).c_str());
168 int iEta = std::atoi(
_toString(aGPElement->getAttribute(
_toDOMS(
"iEta"))).c_str());
169 int iCharge = std::atoi(
_toString(aGPElement->getAttribute(
_toDOMS(
"iCharge"))).c_str());
171 unsigned int nLayers = aGPElement->getElementsByTagName(
_toDOMS(
"Layer"))->getLength();
175 DOMElement* aLayerElement = 0;
176 DOMElement* aItemElement = 0;
182 for(
unsigned int iLayer=0;iLayer<nLayers;++iLayer){
183 aNode = aGPElement->getElementsByTagName(
_toDOMS(
"Layer"))->item(iLayer);
184 aLayerElement =
static_cast<DOMElement *
>(aNode);
186 unsigned int nItems = aLayerElement->getElementsByTagName(
_toDOMS(
"RefLayer"))->getLength();
189 for(
unsigned int iItem=0;iItem<nItems;++iItem){
190 aNode = aLayerElement->getElementsByTagName(
_toDOMS(
"RefLayer"))->item(iItem);
191 aItemElement =
static_cast<DOMElement *
>(aNode);
192 val = std::atoi(
_toString(aItemElement->getAttribute(
_toDOMS(
"meanDistPhi"))).c_str());
193 meanDistPhi1D[iItem] = val;
195 meanDistPhi2D[iLayer] = meanDistPhi1D;
199 if(index>0) stringStr<<
"value"<<
index;
200 else stringStr.str(
"value");
201 nItems = aLayerElement->getElementsByTagName(
_toDOMS(
"PDF"))->getLength();
203 for(
unsigned int iRefLayer=0;iRefLayer<(unsigned) aConfig.
nRefLayers();++iRefLayer){
205 for(
unsigned int iPdf=0;iPdf<exp2(aConfig.
nPdfAddrBits());++iPdf){
206 aNode = aLayerElement->getElementsByTagName(
_toDOMS(
"PDF"))->item(iRefLayer*exp2(aConfig.
nPdfAddrBits())+iPdf);
207 aItemElement =
static_cast<DOMElement *
>(aNode);
208 val = std::atoi(
_toString(aItemElement->getAttribute(
_toDOMS(stringStr.str().c_str()))).c_str());
211 pdf2D[iRefLayer] = pdf1D;
213 pdf3D[iLayer] = pdf2D;
216 Key aKey(iEta,iPt,iCharge);
226 unsigned int iProcessor,
310 xercesc::DOMDocument*
doc =
parser->getDocument();
312 unsigned int nElem = doc->getElementsByTagName(
_toDOMS(
"OMTF"))->getLength();
317 DOMNode *aNode = doc->getElementsByTagName(
_toDOMS(
"OMTF"))->item(0);
318 DOMElement* aOMTFElement =
static_cast<DOMElement *
>(aNode);
324 nElem = aOMTFElement->getElementsByTagName(
_toDOMS(
"GlobalData"))->getLength();
326 aNode = aOMTFElement->getElementsByTagName(
_toDOMS(
"GlobalData"))->item(0);
327 DOMElement* aElement =
static_cast<DOMElement *
>(aNode);
329 unsigned int nPdfAddrBits = std::atoi(
_toString(aElement->getAttribute(
_toDOMS(
"nPdfAddrBits"))).c_str());
330 unsigned int nPdfValBits = std::atoi(
_toString(aElement->getAttribute(
_toDOMS(
"nPdfValBits"))).c_str());
331 unsigned int nHitsPerLayer = std::atoi(
_toString(aElement->getAttribute(
_toDOMS(
"nHitsPerLayer"))).c_str());
332 unsigned int nPhiBits = std::atoi(
_toString(aElement->getAttribute(
_toDOMS(
"nPhiBits"))).c_str());
334 unsigned int nRefHits = std::atoi(
_toString(aElement->getAttribute(
_toDOMS(
"nRefHits"))).c_str());
335 unsigned int nTestRefHits = std::atoi(
_toString(aElement->getAttribute(
_toDOMS(
"nTestRefHits"))).c_str());
336 unsigned int nProcessors = std::atoi(
_toString(aElement->getAttribute(
_toDOMS(
"nProcessors"))).c_str());
337 unsigned int nLogicRegions = std::atoi(
_toString(aElement->getAttribute(
_toDOMS(
"nLogicRegions"))).c_str());
338 unsigned int nInputs = std::atoi(
_toString(aElement->getAttribute(
_toDOMS(
"nInputs"))).c_str());
339 unsigned int nLayers = std::atoi(
_toString(aElement->getAttribute(
_toDOMS(
"nLayers"))).c_str());
340 unsigned int nRefLayers = std::atoi(
_toString(aElement->getAttribute(
_toDOMS(
"nRefLayers"))).c_str());
341 unsigned int nGoldenPatterns = std::atoi(
_toString(aElement->getAttribute(
_toDOMS(
"nGoldenPatterns"))).c_str());
361 std::vector<int> sectorsStart(3*nProcessors), sectorsEnd(3*nProcessors);
362 nElem = aOMTFElement->getElementsByTagName(
_toDOMS(
"ConnectionMap"))->getLength();
363 DOMElement* aConnectionElement = 0;
364 for(uint
i=0;
i<nElem;++
i){
365 aNode = aOMTFElement->getElementsByTagName(
_toDOMS(
"ConnectionMap"))->item(
i);
366 aConnectionElement =
static_cast<DOMElement *
>(aNode);
367 unsigned int iProcessor = std::atoi(
_toString(aConnectionElement->getAttribute(
_toDOMS(
"iProcessor"))).c_str());
368 unsigned int barrelMin = std::atoi(
_toString(aConnectionElement->getAttribute(
_toDOMS(
"barrelMin"))).c_str());
369 unsigned int barrelMax = std::atoi(
_toString(aConnectionElement->getAttribute(
_toDOMS(
"barrelMax"))).c_str());
370 unsigned int endcap10DegMin = std::atoi(
_toString(aConnectionElement->getAttribute(
_toDOMS(
"endcap10DegMin"))).c_str());
371 unsigned int endcap10DegMax = std::atoi(
_toString(aConnectionElement->getAttribute(
_toDOMS(
"endcap10DegMax"))).c_str());
372 unsigned int endcap20DegMin = std::atoi(
_toString(aConnectionElement->getAttribute(
_toDOMS(
"endcap20DegMin"))).c_str());
373 unsigned int endcap20DegMax = std::atoi(
_toString(aConnectionElement->getAttribute(
_toDOMS(
"endcap20DegMax"))).c_str());
375 sectorsStart[iProcessor] = barrelMin;
376 sectorsStart[iProcessor + nProcessors] = endcap10DegMin;
377 sectorsStart[iProcessor + 2*nProcessors] = endcap20DegMin;
379 sectorsEnd[iProcessor] = barrelMax;
380 sectorsEnd[iProcessor + nProcessors] = endcap10DegMax;
381 sectorsEnd[iProcessor + 2*nProcessors] = endcap20DegMax;
388 std::vector<L1TMuonOverlapParams::LayerMapNode> aLayerMapVec;
391 nElem = aOMTFElement->getElementsByTagName(
_toDOMS(
"LayerMap"))->getLength();
392 DOMElement* aLayerElement = 0;
393 for(uint
i=0;
i<nElem;++
i){
394 aNode = aOMTFElement->getElementsByTagName(
_toDOMS(
"LayerMap"))->item(
i);
395 aLayerElement =
static_cast<DOMElement *
>(aNode);
396 unsigned int hwNumber = std::atoi(
_toString(aLayerElement->getAttribute(
_toDOMS(
"hwNumber"))).c_str());
397 unsigned int logicNumber = std::atoi(
_toString(aLayerElement->getAttribute(
_toDOMS(
"logicNumber"))).c_str());
398 unsigned int isBendingLayer = std::atoi(
_toString(aLayerElement->getAttribute(
_toDOMS(
"bendingLayer"))).c_str());
399 unsigned int iConnectedLayer = std::atoi(
_toString(aLayerElement->getAttribute(
_toDOMS(
"connectedToLayer"))).c_str());
404 aLayerMapVec.push_back(aLayerMapNode);
409 std::vector<L1TMuonOverlapParams::RefLayerMapNode> aRefLayerMapVec;
412 nElem = aOMTFElement->getElementsByTagName(
_toDOMS(
"RefLayerMap"))->getLength();
413 DOMElement* aRefLayerElement = 0;
414 for(uint
i=0;
i<nElem;++
i){
415 aNode = aOMTFElement->getElementsByTagName(
_toDOMS(
"RefLayerMap"))->item(
i);
416 aRefLayerElement =
static_cast<DOMElement *
>(aNode);
417 unsigned int refLayer = std::atoi(
_toString(aRefLayerElement->getAttribute(
_toDOMS(
"refLayer"))).c_str());
418 unsigned int logicNumber = std::atoi(
_toString(aRefLayerElement->getAttribute(
_toDOMS(
"logicNumber"))).c_str());
421 aRefLayerMapVec.push_back(aRefLayerNode);
425 std::vector<int> aGlobalPhiStartVec(nProcessors*nRefLayers);
427 std::vector<L1TMuonOverlapParams::RefHitNode> aRefHitMapVec(nProcessors*nRefHits);
430 std::vector<L1TMuonOverlapParams::LayerInputNode> aLayerInputMapVec(nProcessors*nLogicRegions*nLayers);
433 nElem = aOMTFElement->getElementsByTagName(
_toDOMS(
"Processor"))->getLength();
434 assert(nElem==nProcessors);
435 DOMElement* aProcessorElement = 0;
436 for(uint
i=0;
i<nElem;++
i){
437 aNode = aOMTFElement->getElementsByTagName(
_toDOMS(
"Processor"))->item(
i);
438 aProcessorElement =
static_cast<DOMElement *
>(aNode);
439 unsigned int iProcessor = std::atoi(
_toString(aProcessorElement->getAttribute(
_toDOMS(
"iProcessor"))).c_str());
440 unsigned int nElem1 = aProcessorElement->getElementsByTagName(
_toDOMS(
"RefLayer"))->getLength();
441 assert(nElem1==nRefLayers);
442 DOMElement* aRefLayerElement = 0;
443 for(uint
ii=0;
ii<nElem1;++
ii){
444 aNode = aProcessorElement->getElementsByTagName(
_toDOMS(
"RefLayer"))->item(
ii);
445 aRefLayerElement =
static_cast<DOMElement *
>(aNode);
446 unsigned int iRefLayer = std::atoi(
_toString(aRefLayerElement->getAttribute(
_toDOMS(
"iRefLayer"))).c_str());
447 int iPhi = std::atoi(
_toString(aRefLayerElement->getAttribute(
_toDOMS(
"iGlobalPhiStart"))).c_str());
448 aGlobalPhiStartVec[iRefLayer + iProcessor*nRefLayers] = iPhi;
451 nElem1 = aProcessorElement->getElementsByTagName(
_toDOMS(
"RefHit"))->getLength();
452 assert( (iProcessor==0 && nElem1==nRefHits) || (iProcessor!=0 && nElem1==0) );
453 DOMElement* aRefHitElement = 0;
454 for(uint
ii=0;
ii<nElem1;++
ii){
455 aNode = aProcessorElement->getElementsByTagName(
_toDOMS(
"RefHit"))->item(
ii);
456 aRefHitElement =
static_cast<DOMElement *
>(aNode);
457 unsigned int iRefHit = std::atoi(
_toString(aRefHitElement->getAttribute(
_toDOMS(
"iRefHit"))).c_str());
458 int iPhiMin = std::atoi(
_toString(aRefHitElement->getAttribute(
_toDOMS(
"iPhiMin"))).c_str());
459 int iPhiMax = std::atoi(
_toString(aRefHitElement->getAttribute(
_toDOMS(
"iPhiMax"))).c_str());
460 unsigned int iInput = std::atoi(
_toString(aRefHitElement->getAttribute(
_toDOMS(
"iInput"))).c_str());
461 unsigned int iRegion = std::atoi(
_toString(aRefHitElement->getAttribute(
_toDOMS(
"iRegion"))).c_str());
462 unsigned int iRefLayer = std::atoi(
_toString(aRefHitElement->getAttribute(
_toDOMS(
"iRefLayer"))).c_str());
467 aRefHitNode.
iInput = iInput;
470 for (
unsigned int iProcessor=0; iProcessor<nProcessors; iProcessor++) aRefHitMapVec[iRefHit + iProcessor*nRefHits] = aRefHitNode;
473 unsigned int nElem2 = aProcessorElement->getElementsByTagName(
_toDOMS(
"LogicRegion"))->getLength();
474 assert( (iProcessor==0 && nElem2==nLogicRegions) || (iProcessor!=0 && nElem2==0) );
475 DOMElement* aRegionElement = 0;
476 for(uint
ii=0;
ii<nElem2;++
ii){
477 aNode = aProcessorElement->getElementsByTagName(
_toDOMS(
"LogicRegion"))->item(
ii);
478 aRegionElement =
static_cast<DOMElement *
>(aNode);
479 unsigned int iRegion = std::atoi(
_toString(aRegionElement->getAttribute(
_toDOMS(
"iRegion"))).c_str());
480 unsigned int nElem3 = aRegionElement->getElementsByTagName(
_toDOMS(
"Layer"))->getLength();
482 DOMElement* aLayerElement = 0;
483 for(uint iii=0;iii<nElem3;++iii){
484 aNode = aRegionElement->getElementsByTagName(
_toDOMS(
"Layer"))->item(iii);
485 aLayerElement =
static_cast<DOMElement *
>(aNode);
486 unsigned int iLayer = std::atoi(
_toString(aLayerElement->getAttribute(
_toDOMS(
"iLayer"))).c_str());
487 unsigned int iFirstInput = std::atoi(
_toString(aLayerElement->getAttribute(
_toDOMS(
"iFirstInput"))).c_str());
488 unsigned int nInputs = std::atoi(
_toString(aLayerElement->getAttribute(
_toDOMS(
"nInputs"))).c_str());
489 aLayerInputNode.
iLayer = iLayer;
491 aLayerInputNode.
nInputs = nInputs;
492 for (
unsigned int iProcessor=0; iProcessor<nProcessors; ++iProcessor) aLayerInputMapVec[iLayer + iRegion*nLayers + iProcessor*nLayers*nLogicRegions] = aLayerInputNode;
void setLayerMap(const std::vector< LayerMapNode > &aVector)
Connections definitions.
void setConnectedSectorsEnd(const std::vector< int > &aVector)
xercesc::DOMDocument * doc
unsigned int hwNumber
short layer number used within OMTF emulator
std::vector< int > vector1D
void setRefLayerMap(const std::vector< RefLayerMapNode > &aVector)
std::string _toString(const XMLCh *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)
std::vector< GoldenPattern * > readPatterns(const L1TMuonOverlapParams &aConfig)
int read(std::istream &stream)
std::vector< vector1D > vector2D
std::vector< vector2D > vector3D
void setPdf(const vector3D &aPdf)
void setGeneralParams(const std::vector< int > ¶msVec)
GoldenPattern * buildGP(xercesc::DOMElement *aGPElement, const L1TMuonOverlapParams &aConfig, unsigned int index=0)
XMLCh * transcode(const T &fInput)
void readConfig(const std::string fName)
bool bendingLayer
Is this a bending layers?
void setConnectedSectorsStart(const std::vector< int > &aVector)
xercesc::XercesDOMParser * parser
int nPdfAddrBits() const
Access to specific general settings.
unsigned int refLayer
Reference layer number.
void setGlobalPhiStartMap(const std::vector< int > &aVector)
void setLayerInputMap(const std::vector< LayerInputNode > &aVector)
std::vector< GoldenPattern * > aGPs
Cache with GPs read.
void setRefHitMap(const std::vector< RefHitNode > &aVector)
std::vector< std::vector< double > > tmp
void setMeanDistPhi(const vector2D &aMeanDistPhi)
unsigned int logicNumber
Corresponding logical layer number.
unsigned int connectedToLayer
XMLCh * _toDOMS(std::string temp)
void setFwVersion(unsigned fwVersion)