18 #include "xercesc/framework/StdOutFormatTarget.hpp"
19 #include "xercesc/framework/LocalFileFormatTarget.hpp"
20 #include "xercesc/parsers/XercesDOMParser.hpp"
21 #include "xercesc/dom/DOM.hpp"
22 #include "xercesc/dom/DOMException.hpp"
23 #include "xercesc/dom/DOMImplementation.hpp"
24 #include "xercesc/sax/HandlerBase.hpp"
25 #include "xercesc/util/XMLString.hpp"
26 #include "xercesc/util/PlatformUtils.hpp"
27 #include "xercesc/util/XercesDefs.hpp"
28 #include "xercesc/util/XercesVersion.hpp"
29 XERCES_CPP_NAMESPACE_USE
31 #if _XERCES_VERSION <30100
32 #include "xercesc/dom/DOMWriter.hpp"
34 #include "xercesc/dom/DOMLSSerializer.hpp"
35 #include "xercesc/dom/DOMLSOutput.hpp"
55 XMLPlatformUtils::Initialize();
58 domImpl = DOMImplementationRegistry::getDOMImplementation(
_toDOMS(
"Range"));
70 unsigned int mask32bits =
pow(2,32)-1;
74 std::ostringstream stringStr;
76 stringStr<<
"0x"<<std::hex<<std::setfill(
'0')<<std::setw(8)<<
version;
84 XMLFormatTarget* formTarget =
new LocalFileFormatTarget(fName.c_str());
86 #if _XERCES_VERSION <30100
87 xercesc::DOMWriter* domWriter = (
dynamic_cast<DOMImplementation*
>(
domImpl))->createDOMWriter();
88 if(domWriter->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true)){
89 domWriter->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
94 xercesc::DOMLSSerializer* theSerializer = (
dynamic_cast<DOMImplementation*
>(
domImpl))->createLSSerializer();
95 if (theSerializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
true))
96 theSerializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
97 DOMLSOutput* theOutput = (
dynamic_cast<DOMImplementation*
>(
domImpl))->createLSOutput();
98 theOutput->setByteStream(formTarget);
100 theOutput->release();
101 theSerializer->release();
109 unsigned int mixedEventId){
111 unsigned int eventBx = eventId*2;
113 xercesc::DOMElement *aEvent = 0;
114 xercesc::DOMElement *aBx = 0;
115 std::ostringstream stringStr;
121 aEvent->setAttribute(
_toDOMS(
"iEvent"),
_toDOMS(stringStr.str()));
124 stringStr<<mixedEventId;
125 aEvent->setAttribute(
_toDOMS(
"iMixedEvent"),
_toDOMS(stringStr.str()));
131 aEvent->appendChild(aBx);
140 unsigned int iProcessor,
143 std::ostringstream stringStr;
145 xercesc::DOMElement *aProcessor =
theDoc->createElement(
_toDOMS(
"Processor"));
147 stringStr<<iProcessor;
148 aProcessor->setAttribute(
_toDOMS(
"iProcessor"),
_toDOMS(stringStr.str()));
150 xercesc::DOMElement *aLayer, *aHit;
158 aLayer->setAttribute(
_toDOMS(
"iLayer"),
_toDOMS(stringStr.str()));
159 for(
unsigned int iHit=0;iHit<layerDataPhi.size();++iHit){
165 stringStr<<layerDataPhi[iHit];
168 stringStr<<layerDataEta[iHit];
171 aLayer->appendChild(aHit);
173 if(aLayer->getChildNodes()->getLength()) aProcessor->appendChild(aLayer);
176 aTopElement->appendChild(aProcessor);
183 unsigned int iRefHit,
186 xercesc::DOMElement* aResult =
theDoc->createElement(
_toDOMS(
"AlgoMuon"));
187 std::ostringstream stringStr;
190 aResult->setAttribute(
_toDOMS(
"iRefHit"),
_toDOMS(stringStr.str()));
192 stringStr<<aCand.
getPt();
193 aResult->setAttribute(
_toDOMS(
"ptCode"),
_toDOMS(stringStr.str()));
195 stringStr<<aCand.
getPhi();
196 aResult->setAttribute(
_toDOMS(
"phiCode"),
_toDOMS(stringStr.str()));
198 stringStr<<aCand.
getEta();
199 aResult->setAttribute(
_toDOMS(
"etaCode"),
_toDOMS(stringStr.str()));
202 aResult->setAttribute(
_toDOMS(
"charge"),
_toDOMS(stringStr.str()));
204 stringStr<<aCand.
getQ();
205 aResult->setAttribute(
_toDOMS(
"nHits"),
_toDOMS(stringStr.str()));
211 aResult->setAttribute(
_toDOMS(
"iRefLayer"),
_toDOMS(stringStr.str()));
213 stringStr<<std::bitset<18>(aCand.
getHits());
214 aResult->setAttribute(
_toDOMS(
"layers"),
_toDOMS(stringStr.str()));
217 aResult->setAttribute(
_toDOMS(
"phiRHit"),
_toDOMS(stringStr.str()));
219 aTopElement->appendChild(aResult);
224 unsigned int iRegion,
230 std::ostringstream stringStr;
232 xercesc::DOMElement* aGP =
theDoc->createElement(
_toDOMS(
"GP"));
248 xercesc::DOMElement* aRefLayer =
theDoc->createElement(
_toDOMS(
"Result"));
250 stringStr<<iRefLayer;
251 aRefLayer->setAttribute(
_toDOMS(
"iRefLayer"),
_toDOMS(stringStr.str()));
254 aRefLayer->setAttribute(
_toDOMS(
"iRegion"),
_toDOMS(stringStr.str()));
257 aRefLayer->setAttribute(
_toDOMS(
"iLogicLayer"),
_toDOMS(stringStr.str()));
259 xercesc::DOMElement* aLayer =
theDoc->createElement(
_toDOMS(
"Layer"));
261 stringStr<<iLogicLayer;
262 aLayer->setAttribute(
_toDOMS(
"iLayer"),
_toDOMS(stringStr.str()));
264 stringStr<<results[iLogicLayer][iRefLayer];
266 if(results[iLogicLayer][iRefLayer]) aRefLayer->appendChild(aLayer);
268 if(aRefLayer->getChildNodes()->getLength()) aGP->appendChild(aRefLayer);
270 if(aGP->getChildNodes()->getLength()) aTopElement->appendChild(aGP);
276 std::ostringstream stringStr;
277 xercesc::DOMElement *aLayer=0, *aRefLayer=0, *aPdf=0;
279 xercesc::DOMElement* aGPElement =
theDoc->createElement(
_toDOMS(
"GP"));
282 aGPElement->setAttribute(
_toDOMS(
"iPt"),
_toDOMS(stringStr.str()));
286 aGPElement->setAttribute(
_toDOMS(
"iEta"),
_toDOMS(stringStr.str()));
289 aGPElement->setAttribute(
_toDOMS(
"iPhi"),
_toDOMS(stringStr.str()));
292 aGPElement->setAttribute(
_toDOMS(
"iCharge"),
_toDOMS(stringStr.str()));
301 aLayer->setAttribute(
_toDOMS(
"iLayer"),
_toDOMS(stringStr.str()));
304 aLayer->setAttribute(
_toDOMS(
"nOfPhis"),
_toDOMS(stringStr.str()));
309 stringStr<<meanDistPhi;
310 aRefLayer->setAttribute(
_toDOMS(
"meanDistPhi"),
_toDOMS(stringStr.str()));
313 stringStr<<selDistPhi;
314 aRefLayer->setAttribute(
_toDOMS(
"selDistPhi"),
_toDOMS(stringStr.str()));
315 int selDistPhiShift = 0;
317 stringStr<<selDistPhiShift;
318 aRefLayer->setAttribute(
_toDOMS(
"selDistPhiShift"),
_toDOMS(stringStr.str()));
319 int distMsbPhiShift = 0;
321 stringStr<<distMsbPhiShift;
322 aRefLayer->setAttribute(
_toDOMS(
"distMsbPhiShift"),
_toDOMS(stringStr.str()));
323 aLayer->appendChild(aRefLayer);
329 stringStr<<aGP.
pdfValue(iLayer,iRefLayer,iPdf);
331 aLayer->appendChild(aPdf);
334 aGPElement->appendChild(aLayer);
345 std::ostringstream stringStr;
346 xercesc::DOMElement *aLayer=0, *aRefLayer=0, *aPdf=0;
348 xercesc::DOMElement* aGPElement =
theDoc->createElement(
_toDOMS(
"GP"));
352 aGPElement->setAttribute(
_toDOMS(
"iPt1"),
_toDOMS(stringStr.str()));
356 aGPElement->setAttribute(
_toDOMS(
"iPt2"),
_toDOMS(stringStr.str()));
360 aGPElement->setAttribute(
_toDOMS(
"iPt3"),
_toDOMS(stringStr.str()));
364 aGPElement->setAttribute(
_toDOMS(
"iPt4"),
_toDOMS(stringStr.str()));
369 aGPElement->setAttribute(
_toDOMS(
"iEta"),
_toDOMS(stringStr.str()));
372 aGPElement->setAttribute(
_toDOMS(
"iPhi"),
_toDOMS(stringStr.str()));
376 aGPElement->setAttribute(
_toDOMS(
"iCharge"),
_toDOMS(stringStr.str()));
385 aLayer->setAttribute(
_toDOMS(
"iLayer"),
_toDOMS(stringStr.str()));
388 aLayer->setAttribute(
_toDOMS(
"nOfPhis"),
_toDOMS(stringStr.str()));
394 stringStr<<meanDistPhi;
395 aRefLayer->setAttribute(
_toDOMS(
"meanDistPhi"),
_toDOMS(stringStr.str()));
404 stringStr<<selDistPhi;
405 aRefLayer->setAttribute(
_toDOMS(
"selDistPhi"),
_toDOMS(stringStr.str()));
406 int selDistPhiShift = 0;
408 stringStr<<selDistPhiShift;
409 aRefLayer->setAttribute(
_toDOMS(
"selDistPhiShift"),
_toDOMS(stringStr.str()));
410 int distMsbPhiShift = 0;
412 stringStr<<distMsbPhiShift;
413 aRefLayer->setAttribute(
_toDOMS(
"distMsbPhiShift"),
_toDOMS(stringStr.str()));
414 aLayer->appendChild(aRefLayer);
420 stringStr<<aGP1.
pdfValue(iLayer,iRefLayer,iPdf);
423 stringStr<<aGP2.
pdfValue(iLayer,iRefLayer,iPdf);
426 stringStr<<aGP3.
pdfValue(iLayer,iRefLayer,iPdf);
429 stringStr<<aGP4.
pdfValue(iLayer,iRefLayer,iPdf);
431 aLayer->appendChild(aPdf);
434 aGPElement->appendChild(aLayer);
442 std::ostringstream stringStr;
444 for(
unsigned int iProcessor=0;iProcessor<6;++iProcessor){
445 xercesc::DOMElement* aProcessorElement =
theDoc->createElement(
_toDOMS(
"Processor"));
447 stringStr<<iProcessor;
448 aProcessorElement->setAttribute(
_toDOMS(
"iProcessor"),
_toDOMS(stringStr.str()));
450 xercesc::DOMElement* aRefLayerElement =
theDoc->createElement(
_toDOMS(
"RefLayer"));
452 stringStr<<iRefLayer;
453 aRefLayerElement->setAttribute(
_toDOMS(
"iRefLayer"),
_toDOMS(stringStr.str()));
456 aRefLayerElement->setAttribute(
_toDOMS(
"iGlobalPhiStart"),
_toDOMS(stringStr.str()));
457 aProcessorElement->appendChild(aRefLayerElement);
459 unsigned int iRefHit = 0;
464 for(
unsigned int iRegion=0;iRegion<6;++iRegion){
465 unsigned int maxHitCount = 0;
466 for(
unsigned int iInput=0;iInput<14;++iInput) {
470 for(
unsigned int iInput=0;iInput<14;++iInput){
472 if(hitCount<maxHitCount*0.1)
continue;
473 xercesc::DOMElement* aRefHitElement =
theDoc->createElement(
_toDOMS(
"RefHit"));
476 aRefHitElement->setAttribute(
_toDOMS(
"iRefHit"),
_toDOMS(stringStr.str()));
478 stringStr<<iRefLayer;
479 aRefHitElement->setAttribute(
_toDOMS(
"iRefLayer"),
_toDOMS(stringStr.str()));
483 aRefHitElement->setAttribute(
_toDOMS(
"iRegion"),
_toDOMS(stringStr.str()));
487 aRefHitElement->setAttribute(
_toDOMS(
"iInput"),
_toDOMS(stringStr.str()));
492 int iPhiMax = iPhiMin+logicRegionSize-1;
494 iPhiMin+=iRegion*logicRegionSize;
495 iPhiMax+=iRegion*logicRegionSize;
499 aRefHitElement->setAttribute(
_toDOMS(
"iPhiMin"),
_toDOMS(stringStr.str()));
503 aRefHitElement->setAttribute(
_toDOMS(
"iPhiMax"),
_toDOMS(stringStr.str()));
508 xercesc::DOMElement* aRefHitElement =
theDoc->createElement(
_toDOMS(
"RefHit"));
511 aRefHitElement->setAttribute(
_toDOMS(
"iRefHit"),
_toDOMS(stringStr.str()));
514 aRefHitElement->setAttribute(
_toDOMS(
"iRefLayer"),
_toDOMS(stringStr.str()));
518 aRefHitElement->setAttribute(
_toDOMS(
"iRegion"),
_toDOMS(stringStr.str()));
522 aRefHitElement->setAttribute(
_toDOMS(
"iInput"),
_toDOMS(stringStr.str()));
529 aRefHitElement->setAttribute(
_toDOMS(
"iPhiMin"),
_toDOMS(stringStr.str()));
533 aRefHitElement->setAttribute(
_toDOMS(
"iPhiMax"),
_toDOMS(stringStr.str()));
535 aProcessorElement->appendChild(aRefHitElement);
540 for(
unsigned int iRegion=0;iRegion<6;++iRegion){
541 xercesc::DOMElement* aRegionElement =
theDoc->createElement(
_toDOMS(
"LogicRegion"));
544 aRegionElement->setAttribute(
_toDOMS(
"iRegion"),
_toDOMS(stringStr.str()));
547 xercesc::DOMElement* aLayerElement =
theDoc->createElement(
_toDOMS(
"Layer"));
549 stringStr<<iLogicLayer;
551 aLayerElement->setAttribute(
_toDOMS(
"iLayer"),
_toDOMS(stringStr.str()));
555 if((
int)maxInput-2>=0) begin = maxInput-2;
556 else begin = maxInput;
560 aLayerElement->setAttribute(
_toDOMS(
"iFirstInput"),
_toDOMS(stringStr.str()));
562 stringStr<<
end-begin+1;
563 aLayerElement->setAttribute(
_toDOMS(
"nInputs"),
_toDOMS(stringStr.str()));
564 aRegionElement->appendChild(aLayerElement);
566 aProcessorElement->appendChild(aRegionElement);
575 unsigned int max = 0;
576 unsigned int maxInput = 0;
577 for(
unsigned int iInput=0;iInput<14;++iInput){
578 if(myCounts[iInput]>(
int)max){
579 max = myCounts[iInput];
void writeConnectionsData(const std::vector< std::vector< OMTFConfiguration::vector2D > > &measurements4D)
void initialiseXMLDocument(const std::string &docName)
std::string _toString(const XMLCh *toTranscode)
xercesc::DOMElement * writeEventData(xercesc::DOMElement *aTopElement, unsigned int iProcessor, const OMTFinput &aInput)
const OMTFResult::vector2D & getResults() const
std::vector< std::vector< int > > processorPhiVsRefLayer
std::vector< int > refToLogicNumber
vector4D measurements4Dref
void writeResultsData(xercesc::DOMElement *aTopElement, unsigned int iRegion, const Key &aKey, const OMTFResult &aResult)
unsigned int findMaxInput(const OMTFConfiguration::vector1D &myCounts)
XMLCh * transcode(const T &fInput)
std::vector< int > vector1D
xercesc::DOMImplementation * domImpl
std::vector< vector1D > vector2D
int globalPhiStart(unsigned int iProcessor) const
int pdfValue(unsigned int iLayer, unsigned int iRefLayer, unsigned int iBin) const
std::vector< std::vector< double > > tmp
XMLCh * _toDOMS(std::string temp)
void finaliseXMLDocument(const std::string &fName)
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
Power< A, B >::type pow(const A &a, const B &b)
static const OMTFConfiguration * instance()
void writeCandidateData(xercesc::DOMElement *aTopElement, unsigned int iRefHit, const AlgoMuon &aCand)
void writeGPData(const GoldenPattern &aGP)