20 #include "xercesc/framework/StdOutFormatTarget.hpp"
21 #include "xercesc/framework/LocalFileFormatTarget.hpp"
22 #include "xercesc/parsers/XercesDOMParser.hpp"
23 #include "xercesc/dom/DOM.hpp"
24 #include "xercesc/dom/DOMException.hpp"
25 #include "xercesc/dom/DOMImplementation.hpp"
26 #include "xercesc/sax/HandlerBase.hpp"
27 #include "xercesc/util/XMLString.hpp"
28 #include "xercesc/util/PlatformUtils.hpp"
29 #include "xercesc/util/XercesDefs.hpp"
30 #include "xercesc/util/XercesVersion.hpp"
31 XERCES_CPP_NAMESPACE_USE
33 #if _XERCES_VERSION <30100
34 #include "xercesc/dom/DOMWriter.hpp"
36 #include "xercesc/dom/DOMLSSerializer.hpp"
37 #include "xercesc/dom/DOMLSOutput.hpp"
43 if (eta== 73)
return 0b100000000;
44 else if (eta== 78)
return 0b010000000;
45 else if (eta== 85)
return 0b001000000;
46 else if (eta== 90)
return 0b000100000;
47 else if (eta== 94)
return 0b000010000;
48 else if (eta== 99)
return 0b000001000;
49 else if (eta==103)
return 0b000000100;
50 else if (eta==110)
return 0b000000010;
51 else if (eta== 75)
return 0b110000000;
52 else if (eta== 79)
return 0b011000000;
53 else if (eta== 92)
return 0b000110000;
54 else if (eta==115)
return 0b000000001;
55 else if (eta==121)
return 0b000000000;
56 else return 0b111111111; ;
69 XMLCh* buff = XMLString::transcode(temp.c_str());
76 XMLPlatformUtils::Initialize();
79 domImpl = DOMImplementationRegistry::getDOMImplementation(
_toDOMS(
"Range"));
92 unsigned int mask16bits = 0xFFFF;
96 std::ostringstream stringStr;
98 stringStr<<
"0x"<<std::hex<<std::setfill(
'0')<<std::setw(4)<<
version;
106 XMLFormatTarget* formTarget =
new LocalFileFormatTarget(fName.c_str());
108 #if _XERCES_VERSION <30100
109 xercesc::DOMWriter* domWriter = (
dynamic_cast<DOMImplementation*
>(
domImpl))->createDOMWriter();
110 if(domWriter->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true)){
111 domWriter->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
116 xercesc::DOMLSSerializer* theSerializer = (
dynamic_cast<DOMImplementation*
>(
domImpl))->createLSSerializer();
117 if (theSerializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
true))
118 theSerializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
119 DOMLSOutput* theOutput = (
dynamic_cast<DOMImplementation*
>(
domImpl))->createLSOutput();
120 theOutput->setByteStream(formTarget);
122 theOutput->release();
123 theSerializer->release();
131 unsigned int mixedEventId){
133 unsigned int eventBx = eventId*2;
135 xercesc::DOMElement *aEvent = 0;
136 xercesc::DOMElement *aBx = 0;
137 std::ostringstream stringStr;
143 aEvent->setAttribute(
_toDOMS(
"iEvent"),
_toDOMS(stringStr.str()));
146 stringStr<<mixedEventId;
147 aEvent->setAttribute(
_toDOMS(
"iMixedEvent"),
_toDOMS(stringStr.str()));
153 aEvent->appendChild(aBx);
165 std::ostringstream stringStr;
167 xercesc::DOMElement *aProcessor =
theDoc->createElement(
_toDOMS(
"Processor"));
170 unsigned int iProcessor = board.
processor();
172 stringStr<<iProcessor;
173 aProcessor->setAttribute(
_toDOMS(
"iProcessor"),
_toDOMS(stringStr.str()));
175 if (board.
position()==1) stringStr<<
"+";
177 aProcessor->setAttribute(
_toDOMS(
"position"),
_toDOMS(stringStr.str()));
179 xercesc::DOMElement *aLayer, *aHit;
187 aLayer->setAttribute(
_toDOMS(
"iLayer"),
_toDOMS(stringStr.str()));
188 for(
unsigned int iHit=0;iHit<layerDataPhi.size();++iHit){
194 stringStr<<layerDataPhi[iHit];
200 aLayer->appendChild(aHit);
202 if(aLayer->getChildNodes()->getLength()) aProcessor->appendChild(aLayer);
205 aTopElement->appendChild(aProcessor);
212 unsigned int iRefHit,
215 xercesc::DOMElement* aResult =
theDoc->createElement(
_toDOMS(
"AlgoMuon"));
216 std::ostringstream stringStr;
219 aResult->setAttribute(
_toDOMS(
"iRefHit"),
_toDOMS(stringStr.str()));
221 stringStr<<aCand.
getPt();
222 aResult->setAttribute(
_toDOMS(
"ptCode"),
_toDOMS(stringStr.str()));
224 stringStr<<aCand.
getPhi();
225 aResult->setAttribute(
_toDOMS(
"phiCode"),
_toDOMS(stringStr.str()));
228 aResult->setAttribute(
_toDOMS(
"etaCode"),
_toDOMS(stringStr.str()));
231 aResult->setAttribute(
_toDOMS(
"charge"),
_toDOMS(stringStr.str()));
233 stringStr<<aCand.
getQ();
234 aResult->setAttribute(
_toDOMS(
"nHits"),
_toDOMS(stringStr.str()));
240 aResult->setAttribute(
_toDOMS(
"iRefLayer"),
_toDOMS(stringStr.str()));
242 stringStr<<std::bitset<18>(aCand.
getHits());
243 aResult->setAttribute(
_toDOMS(
"layers"),
_toDOMS(stringStr.str()));
246 aResult->setAttribute(
_toDOMS(
"phiRHit"),
_toDOMS(stringStr.str()));
249 aResult->setAttribute(
_toDOMS(
"patNum"),
_toDOMS(stringStr.str()));
251 aTopElement->appendChild(aResult);
258 xercesc::DOMElement* aResult =
theDoc->createElement(
_toDOMS(
"CandMuon"));
259 std::ostringstream stringStr;
261 stringStr<<aCand.
hwPt();
264 stringStr<<aCand.
hwPhi();
267 stringStr<<aCand.
hwEta();
270 stringStr<<aCand.
hwSign();
271 aResult->setAttribute(
_toDOMS(
"hwSign"),
_toDOMS(stringStr.str()));
274 aResult->setAttribute(
_toDOMS(
"hwSignValid"),
_toDOMS(stringStr.str()));
276 stringStr<<aCand.
hwQual();
277 aResult->setAttribute(
_toDOMS(
"hwQual"),
_toDOMS(stringStr.str()));
280 stringStr<<std::bitset<29>(hwAddrMap[0]);
281 aResult->setAttribute(
_toDOMS(
"hwTrackAddress"),
_toDOMS(stringStr.str()));
283 stringStr<<aCand.
link();
287 aResult->setAttribute(
_toDOMS(
"processor"),
_toDOMS(stringStr.str()));
292 aResult->setAttribute(
_toDOMS(
"trackFinderType"),
_toDOMS(stringStr.str()));
293 aTopElement->appendChild(aResult);
300 unsigned int iRegion,
306 std::ostringstream stringStr;
308 xercesc::DOMElement* aGP =
theDoc->createElement(
_toDOMS(
"GP"));
324 xercesc::DOMElement* aRefLayer =
theDoc->createElement(
_toDOMS(
"Result"));
326 stringStr<<iRefLayer;
327 aRefLayer->setAttribute(
_toDOMS(
"iRefLayer"),
_toDOMS(stringStr.str()));
330 aRefLayer->setAttribute(
_toDOMS(
"iRegion"),
_toDOMS(stringStr.str()));
333 aRefLayer->setAttribute(
_toDOMS(
"iLogicLayer"),
_toDOMS(stringStr.str()));
335 xercesc::DOMElement* aLayer =
theDoc->createElement(
_toDOMS(
"Layer"));
337 stringStr<<iLogicLayer;
338 aLayer->setAttribute(
_toDOMS(
"iLayer"),
_toDOMS(stringStr.str()));
340 stringStr<<results[iLogicLayer][iRefLayer];
342 if(results[iLogicLayer][iRefLayer]) aRefLayer->appendChild(aLayer);
344 if(aRefLayer->getChildNodes()->getLength()) aGP->appendChild(aRefLayer);
346 if(aGP->getChildNodes()->getLength()) aTopElement->appendChild(aGP);
352 std::ostringstream stringStr;
353 xercesc::DOMElement *aLayer=0, *aRefLayer=0, *aPdf=0;
355 xercesc::DOMElement* aGPElement =
theDoc->createElement(
_toDOMS(
"GP"));
358 aGPElement->setAttribute(
_toDOMS(
"iPt"),
_toDOMS(stringStr.str()));
362 aGPElement->setAttribute(
_toDOMS(
"iEta"),
_toDOMS(stringStr.str()));
365 aGPElement->setAttribute(
_toDOMS(
"iPhi"),
_toDOMS(stringStr.str()));
368 aGPElement->setAttribute(
_toDOMS(
"iCharge"),
_toDOMS(stringStr.str()));
377 aLayer->setAttribute(
_toDOMS(
"iLayer"),
_toDOMS(stringStr.str()));
380 aLayer->setAttribute(
_toDOMS(
"nOfPhis"),
_toDOMS(stringStr.str()));
385 stringStr<<meanDistPhi;
386 aRefLayer->setAttribute(
_toDOMS(
"meanDistPhi"),
_toDOMS(stringStr.str()));
389 stringStr<<selDistPhi;
390 aRefLayer->setAttribute(
_toDOMS(
"selDistPhi"),
_toDOMS(stringStr.str()));
391 int selDistPhiShift = 0;
393 stringStr<<selDistPhiShift;
394 aRefLayer->setAttribute(
_toDOMS(
"selDistPhiShift"),
_toDOMS(stringStr.str()));
395 int distMsbPhiShift = 0;
397 stringStr<<distMsbPhiShift;
398 aRefLayer->setAttribute(
_toDOMS(
"distMsbPhiShift"),
_toDOMS(stringStr.str()));
399 aLayer->appendChild(aRefLayer);
405 stringStr<<aGP.
pdfValue(iLayer,iRefLayer,iPdf);
407 aLayer->appendChild(aPdf);
410 aGPElement->appendChild(aLayer);
421 std::ostringstream stringStr;
422 xercesc::DOMElement *aLayer=0, *aRefLayer=0, *aPdf=0;
424 xercesc::DOMElement* aGPElement =
theDoc->createElement(
_toDOMS(
"GP"));
428 aGPElement->setAttribute(
_toDOMS(
"iPt1"),
_toDOMS(stringStr.str()));
432 aGPElement->setAttribute(
_toDOMS(
"iPt2"),
_toDOMS(stringStr.str()));
436 aGPElement->setAttribute(
_toDOMS(
"iPt3"),
_toDOMS(stringStr.str()));
440 aGPElement->setAttribute(
_toDOMS(
"iPt4"),
_toDOMS(stringStr.str()));
445 aGPElement->setAttribute(
_toDOMS(
"iEta"),
_toDOMS(stringStr.str()));
448 aGPElement->setAttribute(
_toDOMS(
"iPhi"),
_toDOMS(stringStr.str()));
452 aGPElement->setAttribute(
_toDOMS(
"iCharge"),
_toDOMS(stringStr.str()));
461 aLayer->setAttribute(
_toDOMS(
"iLayer"),
_toDOMS(stringStr.str()));
464 aLayer->setAttribute(
_toDOMS(
"nOfPhis"),
_toDOMS(stringStr.str()));
470 stringStr<<meanDistPhi;
471 aRefLayer->setAttribute(
_toDOMS(
"meanDistPhi"),
_toDOMS(stringStr.str()));
480 stringStr<<selDistPhi;
481 aRefLayer->setAttribute(
_toDOMS(
"selDistPhi"),
_toDOMS(stringStr.str()));
482 int selDistPhiShift = 0;
484 stringStr<<selDistPhiShift;
485 aRefLayer->setAttribute(
_toDOMS(
"selDistPhiShift"),
_toDOMS(stringStr.str()));
486 int distMsbPhiShift = 0;
488 stringStr<<distMsbPhiShift;
489 aRefLayer->setAttribute(
_toDOMS(
"distMsbPhiShift"),
_toDOMS(stringStr.str()));
490 aLayer->appendChild(aRefLayer);
496 stringStr<<aGP1.
pdfValue(iLayer,iRefLayer,iPdf);
499 stringStr<<aGP2.
pdfValue(iLayer,iRefLayer,iPdf);
502 stringStr<<aGP3.
pdfValue(iLayer,iRefLayer,iPdf);
505 stringStr<<aGP4.
pdfValue(iLayer,iRefLayer,iPdf);
507 aLayer->appendChild(aPdf);
510 aGPElement->appendChild(aLayer);
518 std::ostringstream stringStr;
520 for(
unsigned int iProcessor=0;iProcessor<6;++iProcessor){
521 xercesc::DOMElement* aProcessorElement =
theDoc->createElement(
_toDOMS(
"Processor"));
523 stringStr<<iProcessor;
524 aProcessorElement->setAttribute(
_toDOMS(
"iProcessor"),
_toDOMS(stringStr.str()));
526 xercesc::DOMElement* aRefLayerElement =
theDoc->createElement(
_toDOMS(
"RefLayer"));
528 stringStr<<iRefLayer;
529 aRefLayerElement->setAttribute(
_toDOMS(
"iRefLayer"),
_toDOMS(stringStr.str()));
532 aRefLayerElement->setAttribute(
_toDOMS(
"iGlobalPhiStart"),
_toDOMS(stringStr.str()));
533 aProcessorElement->appendChild(aRefLayerElement);
535 unsigned int iRefHit = 0;
538 for(
unsigned int iRegion=0;iRegion<6;++iRegion){
539 unsigned int maxHitCount = 0;
540 for(
unsigned int iInput=0;iInput<14;++iInput) {
544 for(
unsigned int iInput=0;iInput<14;++iInput){
546 if(hitCount<maxHitCount*0.1)
continue;
547 xercesc::DOMElement* aRefHitElement =
theDoc->createElement(
_toDOMS(
"RefHit"));
550 aRefHitElement->setAttribute(
_toDOMS(
"iRefHit"),
_toDOMS(stringStr.str()));
552 stringStr<<iRefLayer;
553 aRefHitElement->setAttribute(
_toDOMS(
"iRefLayer"),
_toDOMS(stringStr.str()));
557 aRefHitElement->setAttribute(
_toDOMS(
"iRegion"),
_toDOMS(stringStr.str()));
561 aRefHitElement->setAttribute(
_toDOMS(
"iInput"),
_toDOMS(stringStr.str()));
566 int iPhiMax = iPhiMin+logicRegionSize-1;
568 iPhiMin+=iRegion*logicRegionSize;
569 iPhiMax+=iRegion*logicRegionSize;
573 aRefHitElement->setAttribute(
_toDOMS(
"iPhiMin"),
_toDOMS(stringStr.str()));
577 aRefHitElement->setAttribute(
_toDOMS(
"iPhiMax"),
_toDOMS(stringStr.str()));
578 if(iRefHit<myOMTFConfig->nRefHits()) aProcessorElement->appendChild(aRefHitElement);
582 xercesc::DOMElement* aRefHitElement =
theDoc->createElement(
_toDOMS(
"RefHit"));
585 aRefHitElement->setAttribute(
_toDOMS(
"iRefHit"),
_toDOMS(stringStr.str()));
588 aRefHitElement->setAttribute(
_toDOMS(
"iRefLayer"),
_toDOMS(stringStr.str()));
592 aRefHitElement->setAttribute(
_toDOMS(
"iRegion"),
_toDOMS(stringStr.str()));
596 aRefHitElement->setAttribute(
_toDOMS(
"iInput"),
_toDOMS(stringStr.str()));
603 aRefHitElement->setAttribute(
_toDOMS(
"iPhiMin"),
_toDOMS(stringStr.str()));
607 aRefHitElement->setAttribute(
_toDOMS(
"iPhiMax"),
_toDOMS(stringStr.str()));
609 aProcessorElement->appendChild(aRefHitElement);
614 for(
unsigned int iRegion=0;iRegion<6;++iRegion){
615 xercesc::DOMElement* aRegionElement =
theDoc->createElement(
_toDOMS(
"LogicRegion"));
618 aRegionElement->setAttribute(
_toDOMS(
"iRegion"),
_toDOMS(stringStr.str()));
621 xercesc::DOMElement* aLayerElement =
theDoc->createElement(
_toDOMS(
"Layer"));
623 stringStr<<iLogicLayer;
625 aLayerElement->setAttribute(
_toDOMS(
"iLayer"),
_toDOMS(stringStr.str()));
629 if((
int)maxInput-2>=0) begin = maxInput-2;
630 else begin = maxInput;
634 aLayerElement->setAttribute(
_toDOMS(
"iFirstInput"),
_toDOMS(stringStr.str()));
636 stringStr<<
end-begin+1;
637 aLayerElement->setAttribute(
_toDOMS(
"nInputs"),
_toDOMS(stringStr.str()));
638 aRegionElement->appendChild(aLayerElement);
640 aProcessorElement->appendChild(aRegionElement);
649 unsigned int max = 0;
650 unsigned int maxInput = 0;
651 for(
unsigned int iInput=0;iInput<14;++iInput){
652 if(myCounts[iInput]>(
int)max){
653 max = myCounts[iInput];
void writeConnectionsData(const std::vector< std::vector< OMTFConfiguration::vector2D > > &measurements4D)
XMLConfigWriter(const OMTFConfiguration *aOMTFConfig)
const int hwSignValid() const
Get charge sign valid bit (0 - not valid (high pT muon); 1 - valid)
unsigned int nRefLayers() const
unsigned int nRefHits() const
void initialiseXMLDocument(const std::string &docName)
std::string _toString(const XMLCh *toTranscode)
unsigned int processor() const
unsigned int nLayers() const
unsigned int nPhiBins() const
xercesc::DOMElement * writeEventData(xercesc::DOMElement *aTopElement, const OmtfName &board, const OMTFinput &aInput)
const OMTFResult::vector2D & getResults() const
unsigned int eta2Bits(unsigned int eta)
const int hwQual() const
Get quality code.
unsigned int nPhiBits() const
unsigned int nPdfAddrBits() const
void writeResultsData(xercesc::DOMElement *aTopElement, unsigned int iRegion, const Key &aKey, const OMTFResult &aResult)
const std::vector< std::vector< int > > & getProcessorPhiVsRefLayer() const
unsigned int findMaxInput(const OMTFConfiguration::vector1D &myCounts)
Abs< T >::type abs(const T &t)
std::vector< int > vector1D
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
const std::map< int, int > & trackAddress() const
Get the track address (identifies track primitives used for reconstruction)
void writeCandMuon(xercesc::DOMElement *aTopElement, const l1t::RegionalMuonCand &aCand)
const int hwPhi() const
Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
xercesc::DOMImplementation * domImpl
const int link() const
Get link on which the MicroGMT receives the candidate.
const tftype trackFinderType() const
Get track-finder which found the muon (bmtf, emtf_pos/emtf_neg or omtf_pos/omtf_neg) ...
const OMTFConfiguration * myOMTFConfig
const int processor() const
Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF) ...
std::vector< vector1D > vector2D
int globalPhiStart(unsigned int iProcessor) const
int pdfValue(unsigned int iLayer, unsigned int iRefLayer, unsigned int iBin) const
const std::vector< int > & getRefToLogicNumber() const
std::vector< std::vector< double > > tmp
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
XMLCh * _toDOMS(std::string temp)
void finaliseXMLDocument(const std::string &fName)
const int hwSign() const
Get charge sign bit (charge = (-1)^(sign))
void writeAlgoMuon(xercesc::DOMElement *aTopElement, unsigned int iRefHit, const AlgoMuon &aMuon)
xercesc::DOMElement * writeEventHeader(unsigned int eventId, unsigned int mixedEventId=0)
xercesc::DOMDocument * theDoc
int meanDistPhiValue(unsigned int iLayer, unsigned int iRefLayer) const
xercesc::DOMElement * theTopElement
vector4D & getMeasurements4Dref()
unsigned int getPatternNumber() const
Power< A, B >::type pow(const A &a, const B &b)
unsigned int patternsVersion() const
void writeGPData(const GoldenPattern &aGP)
vector4D & getMeasurements4D()