CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
XMLConfigWriter.cc
Go to the documentation of this file.
2 
8 
10 
11 #include <iostream>
12 #include <sstream>
13 #include <cmath>
14 #include <ctime>
15 #include <iomanip>
16 #include <bitset>
17 
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
30 
31 #if _XERCES_VERSION <30100
32 #include "xercesc/dom/DOMWriter.hpp"
33 #else
34  #include "xercesc/dom/DOMLSSerializer.hpp"
35  #include "xercesc/dom/DOMLSOutput.hpp"
36 #endif
37 //
38 
40 // XMLConfigWriter
42 inline std::string _toString(XMLCh const* toTranscode) {
44 return tmp;
45 }
46 
47 inline XMLCh* _toDOMS(std::string temp) {
48  XMLCh* buff = XMLString::transcode(temp.c_str());
49  return buff;
50 }
54 
55  XMLPlatformUtils::Initialize();
56 
58  domImpl = DOMImplementationRegistry::getDOMImplementation(_toDOMS("Range"));
59 
60 
61 }
65 
66  theDoc = domImpl->createDocument(0,_toDOMS(docName.c_str()), 0);
67  theTopElement = theDoc->getDocumentElement();
68 
70  unsigned int mask32bits = pow(2,32)-1;
71 
72  version &=mask32bits;
73 
74  std::ostringstream stringStr;
75  stringStr.str("");
76  stringStr<<"0x"<<std::hex<<std::setfill('0')<<std::setw(8)<<version;
77  theTopElement->setAttribute(_toDOMS("version"), _toDOMS(stringStr.str()));
78 
79 }
83 
84  XMLFormatTarget* formTarget = new LocalFileFormatTarget(fName.c_str());
85 
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);
90  }
91  domWriter->writeNode(formTarget,*theTopElement);
92 
93 #else
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);
99  theSerializer->write(theTopElement, theOutput);
100  theOutput->release();
101  theSerializer->release();
102 #endif
103 
104  delete formTarget;
105 }
108 xercesc::DOMElement * XMLConfigWriter::writeEventHeader(unsigned int eventId,
109  unsigned int mixedEventId){
110 
111  unsigned int eventBx = eventId*2;
112 
113  xercesc::DOMElement *aEvent = 0;
114  xercesc::DOMElement *aBx = 0;
115  std::ostringstream stringStr;
116 
117  aEvent = theDoc->createElement(_toDOMS("Event"));
118 
119  stringStr.str("");
120  stringStr<<eventId;
121  aEvent->setAttribute(_toDOMS("iEvent"), _toDOMS(stringStr.str()));
122 
123  stringStr.str("");
124  stringStr<<mixedEventId;
125  aEvent->setAttribute(_toDOMS("iMixedEvent"), _toDOMS(stringStr.str()));
126 
127  aBx = theDoc->createElement(_toDOMS("bx"));
128  stringStr.str("");
129  stringStr<<eventBx;
130  aBx->setAttribute(_toDOMS("iBx"), _toDOMS(stringStr.str()));
131  aEvent->appendChild(aBx);
132 
133  theTopElement->appendChild(aEvent);
134 
135  return aBx;
136 }
139 xercesc::DOMElement * XMLConfigWriter::writeEventData(xercesc::DOMElement *aTopElement,
140  unsigned int iProcessor,
141  const OMTFinput & aInput){
142 
143  std::ostringstream stringStr;
144 
145  xercesc::DOMElement *aProcessor = theDoc->createElement(_toDOMS("Processor"));
146  stringStr.str("");
147  stringStr<<iProcessor;
148  aProcessor->setAttribute(_toDOMS("iProcessor"), _toDOMS(stringStr.str()));
149 
150  xercesc::DOMElement *aLayer, *aHit;
151  for(unsigned int iLayer=0;iLayer<OMTFConfiguration::instance()->nLayers;++iLayer){
152  const OMTFinput::vector1D & layerDataPhi = aInput.getLayerData(iLayer);
153  const OMTFinput::vector1D & layerDataEta = aInput.getLayerData(iLayer,true);
154 
155  aLayer = theDoc->createElement(_toDOMS("Layer"));
156  stringStr.str("");
157  stringStr<<iLayer;
158  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
159  for(unsigned int iHit=0;iHit<layerDataPhi.size();++iHit){
160  aHit = theDoc->createElement(_toDOMS("Hit"));
161  stringStr.str("");
162  stringStr<<iHit;
163  aHit->setAttribute(_toDOMS("iInput"), _toDOMS(stringStr.str()));
164  stringStr.str("");
165  stringStr<<layerDataPhi[iHit];
166  aHit->setAttribute(_toDOMS("iPhi"), _toDOMS(stringStr.str()));
167  stringStr.str("");
168  stringStr<<layerDataEta[iHit];
169  aHit->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
170  if(layerDataPhi[iHit]>=(int)OMTFConfiguration::instance()->nPhiBins) continue;
171  aLayer->appendChild(aHit);
172  }
173  if(aLayer->getChildNodes()->getLength()) aProcessor->appendChild(aLayer);
174  }
175 
176  aTopElement->appendChild(aProcessor);
177  return aProcessor;
178 
179 }
182 void XMLConfigWriter::writeCandidateData(xercesc::DOMElement *aTopElement,
183  unsigned int iRefHit,
184  const AlgoMuon & aCand){
185 
186  xercesc::DOMElement* aResult = theDoc->createElement(_toDOMS("AlgoMuon"));
187  std::ostringstream stringStr;
188  stringStr.str("");
189  stringStr<<iRefHit;
190  aResult->setAttribute(_toDOMS("iRefHit"),_toDOMS(stringStr.str()));
191  stringStr.str("");
192  stringStr<<aCand.getPt();
193  aResult->setAttribute(_toDOMS("ptCode"),_toDOMS(stringStr.str()));
194  stringStr.str("");
195  stringStr<<aCand.getPhi();
196  aResult->setAttribute(_toDOMS("phiCode"),_toDOMS(stringStr.str()));
197  stringStr.str("");
198  stringStr<<aCand.getEta();
199  aResult->setAttribute(_toDOMS("etaCode"),_toDOMS(stringStr.str()));
200  stringStr.str("");
201  stringStr<<aCand.getCharge();
202  aResult->setAttribute(_toDOMS("charge"),_toDOMS(stringStr.str()));
203  stringStr.str("");
204  stringStr<<aCand.getQ();
205  aResult->setAttribute(_toDOMS("nHits"), _toDOMS(stringStr.str()));
206  stringStr.str("");
207  stringStr<<aCand.getDisc();
208  aResult->setAttribute(_toDOMS("disc"), _toDOMS(stringStr.str()));
209  stringStr.str("");
210  stringStr<<aCand.getRefLayer();
211  aResult->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
212  stringStr.str("");
213  stringStr<<std::bitset<18>(aCand.getHits());
214  aResult->setAttribute(_toDOMS("layers"),_toDOMS(stringStr.str()));
215  stringStr.str("");
216  stringStr<<aCand.getPhiRHit();
217  aResult->setAttribute(_toDOMS("phiRHit"),_toDOMS(stringStr.str()));
218 
219  aTopElement->appendChild(aResult);
220 }
223 void XMLConfigWriter::writeResultsData(xercesc::DOMElement *aTopElement,
224  unsigned int iRegion,
225  const Key & aKey,
226  const OMTFResult & aResult){
227 
229 
230  std::ostringstream stringStr;
232  xercesc::DOMElement* aGP = theDoc->createElement(_toDOMS("GP"));
233  stringStr.str("");
234  stringStr<<aKey.thePtCode;
235  aGP->setAttribute(_toDOMS("iPt"), _toDOMS(stringStr.str()));
236  stringStr.str("");
237  stringStr<<aKey.theEtaCode;
238  aGP->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
239  stringStr.str("");
240  stringStr<<"0";
241  aGP->setAttribute(_toDOMS("iPhi"), _toDOMS(stringStr.str()));
242  stringStr.str("");
243  stringStr<<aKey.theCharge;
244  aGP->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));
247  for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
248  xercesc::DOMElement* aRefLayer = theDoc->createElement(_toDOMS("Result"));
249  stringStr.str("");
250  stringStr<<iRefLayer;
251  aRefLayer->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
252  stringStr.str("");
253  stringStr<<iRegion;
254  aRefLayer->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
255  stringStr.str("");
256  stringStr<<OMTFConfiguration::instance()->refToLogicNumber[iRefLayer];
257  aRefLayer->setAttribute(_toDOMS("iLogicLayer"), _toDOMS(stringStr.str()));
258  for(unsigned int iLogicLayer=0;iLogicLayer<OMTFConfiguration::instance()->nLayers;++iLogicLayer){
259  xercesc::DOMElement* aLayer = theDoc->createElement(_toDOMS("Layer"));
260  stringStr.str("");
261  stringStr<<iLogicLayer;
262  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
263  stringStr.str("");
264  stringStr<<results[iLogicLayer][iRefLayer];
265  aLayer->setAttribute(_toDOMS("value"), _toDOMS(stringStr.str()));
266  if(results[iLogicLayer][iRefLayer]) aRefLayer->appendChild(aLayer);
267  }
268  if(aRefLayer->getChildNodes()->getLength()) aGP->appendChild(aRefLayer);
269  }
270  if(aGP->getChildNodes()->getLength()) aTopElement->appendChild(aGP);
271 }
275 
276  std::ostringstream stringStr;
277  xercesc::DOMElement *aLayer=0, *aRefLayer=0, *aPdf=0;
278 
279  xercesc::DOMElement* aGPElement = theDoc->createElement(_toDOMS("GP"));
280  stringStr.str("");
281  stringStr<<aGP.key().thePtCode;
282  aGPElement->setAttribute(_toDOMS("iPt"), _toDOMS(stringStr.str()));
283  stringStr.str("");
284  //stringStr<<aGP.key().theEtaCode;
285  stringStr<<"0";//No eta code at the moment
286  aGPElement->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
287  stringStr.str("");
288  stringStr<<0; //No phi code is assigned to GP for the moment.
289  aGPElement->setAttribute(_toDOMS("iPhi"), _toDOMS(stringStr.str()));
290  stringStr.str("");
291  stringStr<<aGP.key().theCharge;
292  aGPElement->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));
293 
294  for(unsigned int iLayer = 0;iLayer<OMTFConfiguration::instance()->nLayers;++iLayer){
295  int nOfPhis = 0;
297  aLayer = theDoc->createElement(_toDOMS("Layer"));
298  stringStr.str("");
299  stringStr<<iLayer;
301  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
302  stringStr.str("");
303  stringStr<<nOfPhis;
304  aLayer->setAttribute(_toDOMS("nOfPhis"), _toDOMS(stringStr.str()));
305  for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
306  aRefLayer = theDoc->createElement(_toDOMS("RefLayer"));
307  int meanDistPhi = aGP.meanDistPhiValue(iLayer,iRefLayer);
308  stringStr.str("");
309  stringStr<<meanDistPhi;
310  aRefLayer->setAttribute(_toDOMS("meanDistPhi"), _toDOMS(stringStr.str()));
311  int selDistPhi = 0;
312  stringStr.str("");
313  stringStr<<selDistPhi;
314  aRefLayer->setAttribute(_toDOMS("selDistPhi"), _toDOMS(stringStr.str()));
315  int selDistPhiShift = 0;
316  stringStr.str("");
317  stringStr<<selDistPhiShift;
318  aRefLayer->setAttribute(_toDOMS("selDistPhiShift"), _toDOMS(stringStr.str()));
319  int distMsbPhiShift = 0;
320  stringStr.str("");
321  stringStr<<distMsbPhiShift;
322  aRefLayer->setAttribute(_toDOMS("distMsbPhiShift"), _toDOMS(stringStr.str()));
323  aLayer->appendChild(aRefLayer);
324  }
325  for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
326  for(unsigned int iPdf=0;iPdf<exp2(OMTFConfiguration::instance()->nPdfAddrBits);++iPdf){
327  aPdf = theDoc->createElement(_toDOMS("PDF"));
328  stringStr.str("");
329  stringStr<<aGP.pdfValue(iLayer,iRefLayer,iPdf);
330  aPdf->setAttribute(_toDOMS("value"), _toDOMS(stringStr.str()));
331  aLayer->appendChild(aPdf);
332  }
333  }
334  aGPElement->appendChild(aLayer);
335  }
336  theTopElement->appendChild(aGPElement);
337 }
341  const GoldenPattern & aGP2,
342  const GoldenPattern & aGP3,
343  const GoldenPattern & aGP4){
344 
345  std::ostringstream stringStr;
346  xercesc::DOMElement *aLayer=0, *aRefLayer=0, *aPdf=0;
347 
348  xercesc::DOMElement* aGPElement = theDoc->createElement(_toDOMS("GP"));
349  stringStr.str("");
350 
351  stringStr<<aGP1.key().thePtCode;
352  aGPElement->setAttribute(_toDOMS("iPt1"), _toDOMS(stringStr.str()));
353  stringStr.str("");
354 
355  stringStr<<aGP2.key().thePtCode;
356  aGPElement->setAttribute(_toDOMS("iPt2"), _toDOMS(stringStr.str()));
357  stringStr.str("");
358 
359  stringStr<<aGP3.key().thePtCode;
360  aGPElement->setAttribute(_toDOMS("iPt3"), _toDOMS(stringStr.str()));
361  stringStr.str("");
362 
363  stringStr<<aGP4.key().thePtCode;
364  aGPElement->setAttribute(_toDOMS("iPt4"), _toDOMS(stringStr.str()));
365 
366  stringStr.str("");
367  //stringStr<<aGP1.key().theEtaCode;
368  stringStr<<"0";//No eta code at the moment
369  aGPElement->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
370  stringStr.str("");
371  stringStr<<"0";//No phi code is assigned to GP for the moment.
372  aGPElement->setAttribute(_toDOMS("iPhi"), _toDOMS(stringStr.str()));
373  stringStr.str("");
374  stringStr<<aGP1.key().theCharge;
375 
376  aGPElement->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));
377 
378  for(unsigned int iLayer = 0;iLayer<OMTFConfiguration::instance()->nLayers;++iLayer){
379  int nOfPhis = 0;
381  aLayer = theDoc->createElement(_toDOMS("Layer"));
382  stringStr.str("");
383  stringStr<<iLayer;
385  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
386  stringStr.str("");
387  stringStr<<nOfPhis;
388  aLayer->setAttribute(_toDOMS("nOfPhis"), _toDOMS(stringStr.str()));
389  for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
390  aRefLayer = theDoc->createElement(_toDOMS("RefLayer"));
391  int meanDistPhi = aGP1.meanDistPhiValue(iLayer,iRefLayer);
392 
393  stringStr.str("");
394  stringStr<<meanDistPhi;
395  aRefLayer->setAttribute(_toDOMS("meanDistPhi"), _toDOMS(stringStr.str()));
396 
397  //int meanDistPhi2 = aGP2.meanDistPhiValue(iLayer,iRefLayer);
398  //stringStr.str("");
399  //stringStr<<meanDistPhi2;
400  //aRefLayer->setAttribute(_toDOMS("meanDistPhi2"), _toDOMS(stringStr.str()));
401 
402  int selDistPhi = 0;
403  stringStr.str("");
404  stringStr<<selDistPhi;
405  aRefLayer->setAttribute(_toDOMS("selDistPhi"), _toDOMS(stringStr.str()));
406  int selDistPhiShift = 0;
407  stringStr.str("");
408  stringStr<<selDistPhiShift;
409  aRefLayer->setAttribute(_toDOMS("selDistPhiShift"), _toDOMS(stringStr.str()));
410  int distMsbPhiShift = 0;
411  stringStr.str("");
412  stringStr<<distMsbPhiShift;
413  aRefLayer->setAttribute(_toDOMS("distMsbPhiShift"), _toDOMS(stringStr.str()));
414  aLayer->appendChild(aRefLayer);
415  }
416  for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
417  for(unsigned int iPdf=0;iPdf<exp2(OMTFConfiguration::instance()->nPdfAddrBits);++iPdf){
418  aPdf = theDoc->createElement(_toDOMS("PDF"));
419  stringStr.str("");
420  stringStr<<aGP1.pdfValue(iLayer,iRefLayer,iPdf);
421  aPdf->setAttribute(_toDOMS("value1"), _toDOMS(stringStr.str()));
422  stringStr.str("");
423  stringStr<<aGP2.pdfValue(iLayer,iRefLayer,iPdf);
424  aPdf->setAttribute(_toDOMS("value2"), _toDOMS(stringStr.str()));
425  stringStr.str("");
426  stringStr<<aGP3.pdfValue(iLayer,iRefLayer,iPdf);
427  aPdf->setAttribute(_toDOMS("value3"), _toDOMS(stringStr.str()));
428  stringStr.str("");
429  stringStr<<aGP4.pdfValue(iLayer,iRefLayer,iPdf);
430  aPdf->setAttribute(_toDOMS("value4"), _toDOMS(stringStr.str()));
431  aLayer->appendChild(aPdf);
432  }
433  }
434  aGPElement->appendChild(aLayer);
435  }
436  theTopElement->appendChild(aGPElement);
437 }
440 void XMLConfigWriter::writeConnectionsData(const std::vector<std::vector <OMTFConfiguration::vector2D> > & measurements4D){
441 
442  std::ostringstream stringStr;
443 
444  for(unsigned int iProcessor=0;iProcessor<6;++iProcessor){
445  xercesc::DOMElement* aProcessorElement = theDoc->createElement(_toDOMS("Processor"));
446  stringStr.str("");
447  stringStr<<iProcessor;
448  aProcessorElement->setAttribute(_toDOMS("iProcessor"), _toDOMS(stringStr.str()));
449  for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
450  xercesc::DOMElement* aRefLayerElement = theDoc->createElement(_toDOMS("RefLayer"));
451  stringStr.str("");
452  stringStr<<iRefLayer;
453  aRefLayerElement->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
454  stringStr.str("");
455  stringStr<<OMTFConfiguration::instance()->processorPhiVsRefLayer[iProcessor][iRefLayer];
456  aRefLayerElement->setAttribute(_toDOMS("iGlobalPhiStart"), _toDOMS(stringStr.str()));
457  aProcessorElement->appendChild(aRefLayerElement);
458  }
459  unsigned int iRefHit = 0;
460 
463  for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
464  for(unsigned int iRegion=0;iRegion<6;++iRegion){
465  unsigned int maxHitCount = 0;
466  for(unsigned int iInput=0;iInput<14;++iInput) {
467  if((int)maxHitCount<OMTFConfiguration::instance()->measurements4Dref[iProcessor][iRegion][iRefLayer][iInput])
468  maxHitCount = OMTFConfiguration::instance()->measurements4Dref[iProcessor][iRegion][iRefLayer][iInput];
469  }
470  for(unsigned int iInput=0;iInput<14;++iInput){
471  unsigned int hitCount = OMTFConfiguration::instance()->measurements4Dref[iProcessor][iRegion][iRefLayer][iInput];
472  if(hitCount<maxHitCount*0.1) continue;
473  xercesc::DOMElement* aRefHitElement = theDoc->createElement(_toDOMS("RefHit"));
474  stringStr.str("");
475  stringStr<<iRefHit;
476  aRefHitElement->setAttribute(_toDOMS("iRefHit"), _toDOMS(stringStr.str()));
477  stringStr.str("");
478  stringStr<<iRefLayer;
479  aRefHitElement->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
480 
481  stringStr.str("");
482  stringStr<<iRegion;
483  aRefHitElement->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
484 
485  stringStr.str("");
486  stringStr<<iInput;
487  aRefHitElement->setAttribute(_toDOMS("iInput"), _toDOMS(stringStr.str()));
488  unsigned int logicRegionSize = 10/360.0*OMTFConfiguration::instance()->nPhiBins;
489  int lowScaleEnd = std::pow(2,OMTFConfiguration::instance()->nPhiBits-1);
491  int iPhiMin = OMTFConfiguration::instance()->processorPhiVsRefLayer[iProcessor][iRefLayer]-OMTFConfiguration::instance()->globalPhiStart(iProcessor)-lowScaleEnd;
492  int iPhiMax = iPhiMin+logicRegionSize-1;
493 
494  iPhiMin+=iRegion*logicRegionSize;
495  iPhiMax+=iRegion*logicRegionSize;
496 
497  stringStr.str("");
498  stringStr<<iPhiMin;
499  aRefHitElement->setAttribute(_toDOMS("iPhiMin"), _toDOMS(stringStr.str()));
500 
501  stringStr.str("");
502  stringStr<<iPhiMax;
503  aRefHitElement->setAttribute(_toDOMS("iPhiMax"), _toDOMS(stringStr.str()));
504  if(iRefHit<OMTFConfiguration::instance()->nRefHits) aProcessorElement->appendChild(aRefHitElement);
505  ++iRefHit;
506  }
507  for(;iRegion==5 && iRefLayer==7 && iRefHit<OMTFConfiguration::instance()->nRefHits;++iRefHit){
508  xercesc::DOMElement* aRefHitElement = theDoc->createElement(_toDOMS("RefHit"));
509  stringStr.str("");
510  stringStr<<iRefHit;
511  aRefHitElement->setAttribute(_toDOMS("iRefHit"), _toDOMS(stringStr.str()));
512  stringStr.str("");
513  stringStr<<0;
514  aRefHitElement->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
515 
516  stringStr.str("");
517  stringStr<<0;
518  aRefHitElement->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
519 
520  stringStr.str("");
521  stringStr<<0;
522  aRefHitElement->setAttribute(_toDOMS("iInput"), _toDOMS(stringStr.str()));
523 
524  int iPhiMin = 0;
525  int iPhiMax = 1;
526 
527  stringStr.str("");
528  stringStr<<iPhiMin;
529  aRefHitElement->setAttribute(_toDOMS("iPhiMin"), _toDOMS(stringStr.str()));
530 
531  stringStr.str("");
532  stringStr<<iPhiMax;
533  aRefHitElement->setAttribute(_toDOMS("iPhiMax"), _toDOMS(stringStr.str()));
534 
535  aProcessorElement->appendChild(aRefHitElement);
536  }
537  }
538  }
540  for(unsigned int iRegion=0;iRegion<6;++iRegion){
541  xercesc::DOMElement* aRegionElement = theDoc->createElement(_toDOMS("LogicRegion"));
542  stringStr.str("");
543  stringStr<<iRegion;
544  aRegionElement->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
545 
546  for(unsigned int iLogicLayer=0;iLogicLayer<OMTFConfiguration::instance()->nLayers;++iLogicLayer){
547  xercesc::DOMElement* aLayerElement = theDoc->createElement(_toDOMS("Layer"));
548  stringStr.str("");
549  stringStr<<iLogicLayer;
551  aLayerElement->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
552  const OMTFConfiguration::vector1D & myCounts = OMTFConfiguration::instance()->measurements4D[iProcessor][iRegion][iLogicLayer];
553  unsigned int maxInput = findMaxInput(myCounts);
554  unsigned int begin = 0, end = 0;
555  if((int)maxInput-2>=0) begin = maxInput-2;
556  else begin = maxInput;
557  end = maxInput+3;
558  stringStr.str("");
559  stringStr<<begin;
560  aLayerElement->setAttribute(_toDOMS("iFirstInput"), _toDOMS(stringStr.str()));
561  stringStr.str("");
562  stringStr<<end-begin+1;
563  aLayerElement->setAttribute(_toDOMS("nInputs"), _toDOMS(stringStr.str()));
564  aRegionElement->appendChild(aLayerElement);
565  }
566  aProcessorElement->appendChild(aRegionElement);
567  }
568  theTopElement->appendChild(aProcessorElement);
569  }
570 }
574 
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];
580  maxInput = iInput;
581  }
582  }
583  return maxInput;
584 }
587 
Key key() const
Definition: GoldenPattern.h:59
void writeConnectionsData(const std::vector< std::vector< OMTFConfiguration::vector2D > > &measurements4D)
int getCharge() const
Definition: AlgoMuon.h:25
int getEta() const
Definition: AlgoMuon.h:19
unsigned int nLayers
int getQ() const
Definition: AlgoMuon.h:22
void initialiseXMLDocument(const std::string &docName)
int theCharge
Definition: GoldenPattern.h:37
std::string _toString(const XMLCh *toTranscode)
xercesc::DOMElement * writeEventData(xercesc::DOMElement *aTopElement, unsigned int iProcessor, const OMTFinput &aInput)
const OMTFResult::vector2D & getResults() const
Definition: OMTFResult.h:16
std::vector< std::vector< int > > processorPhiVsRefLayer
std::vector< int > vector1D
Definition: OMTFinput.h:14
unsigned int thePtCode
Definition: GoldenPattern.h:36
int getDisc() const
Definition: AlgoMuon.h:17
std::vector< int > refToLogicNumber
const OMTFinput::vector1D & getLayerData(unsigned int iLayer, bool giveEta=false) const
Definition: OMTFinput.cc:18
void writeResultsData(xercesc::DOMElement *aTopElement, unsigned int iRegion, const Key &aKey, const OMTFResult &aResult)
unsigned int fwVersion
unsigned int findMaxInput(const OMTFConfiguration::vector1D &myCounts)
XMLCh * transcode(const T &fInput)
tuple results
Definition: mps_update.py:44
std::vector< int > vector1D
unsigned int nPhiBins
#define end
Definition: vmac.h:37
int getRefLayer() const
Definition: AlgoMuon.h:20
xercesc::DOMImplementation * domImpl
std::vector< vector1D > vector2D
Definition: OMTFResult.h:12
unsigned int nRefLayers
int getHits() const
Definition: AlgoMuon.h:21
int globalPhiStart(unsigned int iProcessor) const
int pdfValue(unsigned int iLayer, unsigned int iRefLayer, unsigned int iBin) const
Definition: GoldenPattern.h:71
unsigned int nRefHits
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
#define begin
Definition: vmac.h:30
XMLCh * _toDOMS(std::string temp)
int getPt() const
Definition: AlgoMuon.h:24
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
Definition: GoldenPattern.h:69
xercesc::DOMElement * theTopElement
int getPhi() const
Definition: AlgoMuon.h:18
int getPhiRHit() const
Definition: AlgoMuon.h:26
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
static const OMTFConfiguration * instance()
void writeCandidateData(xercesc::DOMElement *aTopElement, unsigned int iRefHit, const AlgoMuon &aCand)
void writeGPData(const GoldenPattern &aGP)
int theEtaCode
Definition: GoldenPattern.h:35