CMS 3D CMS Logo

XMLConfigWriter.cc
Go to the documentation of this file.
2 
8 
11 
12 
13 #include <iostream>
14 #include <sstream>
15 #include <cmath>
16 #include <ctime>
17 #include <iomanip>
18 #include <bitset>
19 
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"
32 
33 #if _XERCES_VERSION <30100
34 #include "xercesc/dom/DOMWriter.hpp"
35 #else
36  #include "xercesc/dom/DOMLSSerializer.hpp"
37  #include "xercesc/dom/DOMLSOutput.hpp"
38 #endif
39 //
40 
41 namespace {
42  unsigned int eta2Bits(unsigned int eta) {
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; ;
57  }
58 }
59 
61 // XMLConfigWriter
63 inline std::string _toString(XMLCh const* toTranscode) {
64 std::string tmp(xercesc::XMLString::transcode(toTranscode));
65 return tmp;
66 }
67 
68 inline XMLCh* _toDOMS(std::string temp) {
69  XMLCh* buff = XMLString::transcode(temp.c_str());
70  return buff;
71 }
75 
76  XMLPlatformUtils::Initialize();
77 
79  domImpl = DOMImplementationRegistry::getDOMImplementation(_toDOMS("Range"));
80 
81  myOMTFConfig = aOMTFConfig;
82 
83 }
87 
88  theDoc = domImpl->createDocument(nullptr,_toDOMS(docName), nullptr);
89  theTopElement = theDoc->getDocumentElement();
90 
91  unsigned int version = myOMTFConfig->patternsVersion();
92  unsigned int mask16bits = 0xFFFF;
93 
94  version &=mask16bits;
95 
96  std::ostringstream stringStr;
97  stringStr.str("");
98  stringStr<<"0x"<<std::hex<<std::setfill('0')<<std::setw(4)<<version;
99  theTopElement->setAttribute(_toDOMS("version"), _toDOMS(stringStr.str()));
100 
101 }
105 
106  XMLFormatTarget* formTarget = new LocalFileFormatTarget(fName.c_str());
107 
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);
112  }
113  domWriter->writeNode(formTarget,*theTopElement);
114 
115 #else
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);
121  theSerializer->write(theTopElement, theOutput);
122  theOutput->release();
123  theSerializer->release();
124 #endif
125 
126  delete formTarget;
127 }
130 xercesc::DOMElement * XMLConfigWriter::writeEventHeader(unsigned int eventId,
131  unsigned int mixedEventId){
132 
133  unsigned int eventBx = eventId*2;
134 
135  xercesc::DOMElement *aEvent = nullptr;
136  xercesc::DOMElement *aBx = nullptr;
137  std::ostringstream stringStr;
138 
139  aEvent = theDoc->createElement(_toDOMS("Event"));
140 
141  stringStr.str("");
142  stringStr<<eventId;
143  aEvent->setAttribute(_toDOMS("iEvent"), _toDOMS(stringStr.str()));
144 
145  stringStr.str("");
146  stringStr<<mixedEventId;
147  aEvent->setAttribute(_toDOMS("iMixedEvent"), _toDOMS(stringStr.str()));
148 
149  aBx = theDoc->createElement(_toDOMS("bx"));
150  stringStr.str("");
151  stringStr<<eventBx;
152  aBx->setAttribute(_toDOMS("iBx"), _toDOMS(stringStr.str()));
153  aEvent->appendChild(aBx);
154 
155  theTopElement->appendChild(aEvent);
156 
157  return aBx;
158 }
161 xercesc::DOMElement * XMLConfigWriter::writeEventData(xercesc::DOMElement *aTopElement,
162  const OmtfName & board,
163  const OMTFinput & aInput){
164 
165  std::ostringstream stringStr;
166 
167  xercesc::DOMElement *aProcessor = theDoc->createElement(_toDOMS("Processor"));
168  aProcessor->setAttribute(_toDOMS("board"), _toDOMS(board.name()) );
169 
170  unsigned int iProcessor = board.processor();
171  stringStr.str("");
172  stringStr<<iProcessor;
173  aProcessor->setAttribute(_toDOMS("iProcessor"), _toDOMS(stringStr.str()));
174  stringStr.str("");
175  if (board.position()==1) stringStr<<"+";
176  stringStr<<board.position();
177  aProcessor->setAttribute(_toDOMS("position"), _toDOMS(stringStr.str()));
178 
179  xercesc::DOMElement *aLayer, *aHit;
180  for(unsigned int iLayer=0;iLayer<myOMTFConfig->nLayers();++iLayer){
181  const OMTFinput::vector1D & layerDataPhi = aInput.getLayerData(iLayer);
182  const OMTFinput::vector1D & layerDataEta = aInput.getLayerData(iLayer,true);
183 
184  aLayer = theDoc->createElement(_toDOMS("Layer"));
185  stringStr.str("");
186  stringStr<<iLayer;
187  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
188  for(unsigned int iHit=0;iHit<layerDataPhi.size();++iHit){
189  aHit = theDoc->createElement(_toDOMS("Hit"));
190  stringStr.str("");
191  stringStr<<iHit;
192  aHit->setAttribute(_toDOMS("iInput"), _toDOMS(stringStr.str()));
193  stringStr.str("");
194  stringStr<<layerDataPhi[iHit];
195  aHit->setAttribute(_toDOMS("iPhi"), _toDOMS(stringStr.str()));
196  stringStr.str("");
197  stringStr<<eta2Bits(abs(layerDataEta[iHit]));
198  aHit->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
199  if(layerDataPhi[iHit]>=(int)myOMTFConfig->nPhiBins()) continue;
200  aLayer->appendChild(aHit);
201  }
202  if(aLayer->getChildNodes()->getLength()) aProcessor->appendChild(aLayer);
203  }
204 
205  aTopElement->appendChild(aProcessor);
206  return aProcessor;
207 
208 }
211 void XMLConfigWriter::writeAlgoMuon(xercesc::DOMElement *aTopElement,
212  unsigned int iRefHit,
213  const AlgoMuon & aCand){
214 
215  xercesc::DOMElement* aResult = theDoc->createElement(_toDOMS("AlgoMuon"));
216  std::ostringstream stringStr;
217  stringStr.str("");
218  stringStr<<iRefHit;
219  aResult->setAttribute(_toDOMS("iRefHit"),_toDOMS(stringStr.str()));
220  stringStr.str("");
221  stringStr<<aCand.getPt();
222  aResult->setAttribute(_toDOMS("ptCode"),_toDOMS(stringStr.str()));
223  stringStr.str("");
224  stringStr<<aCand.getPhi();
225  aResult->setAttribute(_toDOMS("phiCode"),_toDOMS(stringStr.str()));
226  stringStr.str("");
227  stringStr<<eta2Bits(abs(aCand.getEta()));
228  aResult->setAttribute(_toDOMS("etaCode"),_toDOMS(stringStr.str()));
229  stringStr.str("");
230  stringStr<<aCand.getCharge();
231  aResult->setAttribute(_toDOMS("charge"),_toDOMS(stringStr.str()));
232  stringStr.str("");
233  stringStr<<aCand.getQ();
234  aResult->setAttribute(_toDOMS("nHits"), _toDOMS(stringStr.str()));
235  stringStr.str("");
236  stringStr<<aCand.getDisc();
237  aResult->setAttribute(_toDOMS("disc"), _toDOMS(stringStr.str()));
238  stringStr.str("");
239  stringStr<<aCand.getRefLayer();
240  aResult->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
241  stringStr.str("");
242  stringStr<<std::bitset<18>(aCand.getHits());
243  aResult->setAttribute(_toDOMS("layers"),_toDOMS(stringStr.str()));
244  stringStr.str("");
245  stringStr<<aCand.getPhiRHit();
246  aResult->setAttribute(_toDOMS("phiRHit"),_toDOMS(stringStr.str()));
247  stringStr.str("");
248  stringStr<<aCand.getPatternNumber();
249  aResult->setAttribute(_toDOMS("patNum"),_toDOMS(stringStr.str()));
250 
251  aTopElement->appendChild(aResult);
252 }
255 void XMLConfigWriter::writeCandMuon(xercesc::DOMElement *aTopElement,
256  const l1t::RegionalMuonCand& aCand){
257 
258  xercesc::DOMElement* aResult = theDoc->createElement(_toDOMS("CandMuon"));
259  std::ostringstream stringStr;
260  stringStr.str("");
261  stringStr<<aCand.hwPt();
262  aResult->setAttribute(_toDOMS("hwPt"),_toDOMS(stringStr.str()));
263  stringStr.str("");
264  stringStr<<aCand.hwPhi();
265  aResult->setAttribute(_toDOMS("hwPhi"),_toDOMS(stringStr.str()));
266  stringStr.str("");
267  stringStr<<aCand.hwEta();
268  aResult->setAttribute(_toDOMS("hwEta"),_toDOMS(stringStr.str()));
269  stringStr.str("");
270  stringStr<<aCand.hwSign();
271  aResult->setAttribute(_toDOMS("hwSign"),_toDOMS(stringStr.str()));
272  stringStr.str("");
273  stringStr<<aCand.hwSignValid();
274  aResult->setAttribute(_toDOMS("hwSignValid"),_toDOMS(stringStr.str()));
275  stringStr.str("");
276  stringStr<<aCand.hwQual();
277  aResult->setAttribute(_toDOMS("hwQual"), _toDOMS(stringStr.str()));
278  stringStr.str("");
279  std::map<int, int> hwAddrMap = aCand.trackAddress();
280  stringStr<<std::bitset<29>(hwAddrMap[0]);
281  aResult->setAttribute(_toDOMS("hwTrackAddress"), _toDOMS(stringStr.str()));
282  stringStr.str("");
283  stringStr<<aCand.link();
284  aResult->setAttribute(_toDOMS("link"), _toDOMS(stringStr.str()));
285  stringStr.str("");
286  stringStr<<aCand.processor();
287  aResult->setAttribute(_toDOMS("processor"), _toDOMS(stringStr.str()));
288  stringStr.str("");
289  if (aCand.trackFinderType() == l1t::omtf_neg) stringStr<<"OMTF_NEG";
290  else if (aCand.trackFinderType() == l1t::omtf_pos) stringStr<<"OMTF_POS";
291  else stringStr<<aCand.trackFinderType();
292  aResult->setAttribute(_toDOMS("trackFinderType"), _toDOMS(stringStr.str()));
293  aTopElement->appendChild(aResult);
294 }
299 void XMLConfigWriter::writeResultsData(xercesc::DOMElement *aTopElement,
300  unsigned int iRegion,
301  const Key & aKey,
302  const OMTFResult & aResult){
303 
304  OMTFResult::vector2D results = aResult.getResults();
305 
306  std::ostringstream stringStr;
308  xercesc::DOMElement* aGP = theDoc->createElement(_toDOMS("GP"));
309  stringStr.str("");
310  stringStr<<aKey.thePtCode;
311  aGP->setAttribute(_toDOMS("iPt"), _toDOMS(stringStr.str()));
312  stringStr.str("");
313  stringStr<<aKey.theEtaCode;
314  aGP->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
315  stringStr.str("");
316  stringStr<<"0";
317  aGP->setAttribute(_toDOMS("iPhi"), _toDOMS(stringStr.str()));
318  stringStr.str("");
319  stringStr<<aKey.theCharge;
320  aGP->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));
323  for(unsigned int iRefLayer=0;iRefLayer<myOMTFConfig->nRefLayers();++iRefLayer){
324  xercesc::DOMElement* aRefLayer = theDoc->createElement(_toDOMS("Result"));
325  stringStr.str("");
326  stringStr<<iRefLayer;
327  aRefLayer->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
328  stringStr.str("");
329  stringStr<<iRegion;
330  aRefLayer->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
331  stringStr.str("");
332  stringStr<<myOMTFConfig->getRefToLogicNumber()[iRefLayer];
333  aRefLayer->setAttribute(_toDOMS("iLogicLayer"), _toDOMS(stringStr.str()));
334  for(unsigned int iLogicLayer=0;iLogicLayer<myOMTFConfig->nLayers();++iLogicLayer){
335  xercesc::DOMElement* aLayer = theDoc->createElement(_toDOMS("Layer"));
336  stringStr.str("");
337  stringStr<<iLogicLayer;
338  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
339  stringStr.str("");
340  stringStr<<results[iLogicLayer][iRefLayer];
341  aLayer->setAttribute(_toDOMS("value"), _toDOMS(stringStr.str()));
342  if(results[iLogicLayer][iRefLayer]) aRefLayer->appendChild(aLayer);
343  }
344  if(aRefLayer->getChildNodes()->getLength()) aGP->appendChild(aRefLayer);
345  }
346  if(aGP->getChildNodes()->getLength()) aTopElement->appendChild(aGP);
347 }
351 
352  std::ostringstream stringStr;
353  xercesc::DOMElement *aLayer=nullptr, *aRefLayer=nullptr, *aPdf=nullptr;
354 
355  xercesc::DOMElement* aGPElement = theDoc->createElement(_toDOMS("GP"));
356  stringStr.str("");
357  stringStr<<aGP.key().thePtCode;
358  aGPElement->setAttribute(_toDOMS("iPt"), _toDOMS(stringStr.str()));
359  stringStr.str("");
360  //stringStr<<aGP.key().theEtaCode;
361  stringStr<<"0";//No eta code at the moment
362  aGPElement->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
363  stringStr.str("");
364  stringStr<<0; //No phi code is assigned to GP for the moment.
365  aGPElement->setAttribute(_toDOMS("iPhi"), _toDOMS(stringStr.str()));
366  stringStr.str("");
367  stringStr<<aGP.key().theCharge;
368  aGPElement->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));
369 
370  for(unsigned int iLayer = 0;iLayer<myOMTFConfig->nLayers();++iLayer){
371  int nOfPhis = 0;
373  aLayer = theDoc->createElement(_toDOMS("Layer"));
374  stringStr.str("");
375  stringStr<<iLayer;
377  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
378  stringStr.str("");
379  stringStr<<nOfPhis;
380  aLayer->setAttribute(_toDOMS("nOfPhis"), _toDOMS(stringStr.str()));
381  for(unsigned int iRefLayer=0;iRefLayer<myOMTFConfig->nRefLayers();++iRefLayer){
382  aRefLayer = theDoc->createElement(_toDOMS("RefLayer"));
383  int meanDistPhi = aGP.meanDistPhiValue(iLayer,iRefLayer);
384  stringStr.str("");
385  stringStr<<meanDistPhi;
386  aRefLayer->setAttribute(_toDOMS("meanDistPhi"), _toDOMS(stringStr.str()));
387  int selDistPhi = 0;
388  stringStr.str("");
389  stringStr<<selDistPhi;
390  aRefLayer->setAttribute(_toDOMS("selDistPhi"), _toDOMS(stringStr.str()));
391  int selDistPhiShift = 0;
392  stringStr.str("");
393  stringStr<<selDistPhiShift;
394  aRefLayer->setAttribute(_toDOMS("selDistPhiShift"), _toDOMS(stringStr.str()));
395  int distMsbPhiShift = 0;
396  stringStr.str("");
397  stringStr<<distMsbPhiShift;
398  aRefLayer->setAttribute(_toDOMS("distMsbPhiShift"), _toDOMS(stringStr.str()));
399  aLayer->appendChild(aRefLayer);
400  }
401  for(unsigned int iRefLayer=0;iRefLayer<myOMTFConfig->nRefLayers();++iRefLayer){
402  for(unsigned int iPdf=0;iPdf<exp2(myOMTFConfig->nPdfAddrBits());++iPdf){
403  aPdf = theDoc->createElement(_toDOMS("PDF"));
404  stringStr.str("");
405  stringStr<<aGP.pdfValue(iLayer,iRefLayer,iPdf);
406  aPdf->setAttribute(_toDOMS("value"), _toDOMS(stringStr.str()));
407  aLayer->appendChild(aPdf);
408  }
409  }
410  aGPElement->appendChild(aLayer);
411  }
412  theTopElement->appendChild(aGPElement);
413 }
417  const GoldenPattern & aGP2,
418  const GoldenPattern & aGP3,
419  const GoldenPattern & aGP4){
420 
421  std::ostringstream stringStr;
422  xercesc::DOMElement *aLayer=nullptr, *aRefLayer=nullptr, *aPdf=nullptr;
423 
424  xercesc::DOMElement* aGPElement = theDoc->createElement(_toDOMS("GP"));
425  stringStr.str("");
426 
427  stringStr<<aGP1.key().thePtCode;
428  aGPElement->setAttribute(_toDOMS("iPt1"), _toDOMS(stringStr.str()));
429  stringStr.str("");
430 
431  stringStr<<aGP2.key().thePtCode;
432  aGPElement->setAttribute(_toDOMS("iPt2"), _toDOMS(stringStr.str()));
433  stringStr.str("");
434 
435  stringStr<<aGP3.key().thePtCode;
436  aGPElement->setAttribute(_toDOMS("iPt3"), _toDOMS(stringStr.str()));
437  stringStr.str("");
438 
439  stringStr<<aGP4.key().thePtCode;
440  aGPElement->setAttribute(_toDOMS("iPt4"), _toDOMS(stringStr.str()));
441 
442  stringStr.str("");
443  //stringStr<<aGP1.key().theEtaCode;
444  stringStr<<"0";//No eta code at the moment
445  aGPElement->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
446  stringStr.str("");
447  stringStr<<"0";//No phi code is assigned to GP for the moment.
448  aGPElement->setAttribute(_toDOMS("iPhi"), _toDOMS(stringStr.str()));
449  stringStr.str("");
450  stringStr<<aGP1.key().theCharge;
451 
452  aGPElement->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));
453 
454  for(unsigned int iLayer = 0;iLayer<myOMTFConfig->nLayers();++iLayer){
455  int nOfPhis = 0;
457  aLayer = theDoc->createElement(_toDOMS("Layer"));
458  stringStr.str("");
459  stringStr<<iLayer;
461  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
462  stringStr.str("");
463  stringStr<<nOfPhis;
464  aLayer->setAttribute(_toDOMS("nOfPhis"), _toDOMS(stringStr.str()));
465  for(unsigned int iRefLayer=0;iRefLayer<myOMTFConfig->nRefLayers();++iRefLayer){
466  aRefLayer = theDoc->createElement(_toDOMS("RefLayer"));
467  int meanDistPhi = aGP1.meanDistPhiValue(iLayer,iRefLayer);
468 
469  stringStr.str("");
470  stringStr<<meanDistPhi;
471  aRefLayer->setAttribute(_toDOMS("meanDistPhi"), _toDOMS(stringStr.str()));
472 
473  //int meanDistPhi2 = aGP2.meanDistPhiValue(iLayer,iRefLayer);
474  //stringStr.str("");
475  //stringStr<<meanDistPhi2;
476  //aRefLayer->setAttribute(_toDOMS("meanDistPhi2"), _toDOMS(stringStr.str()));
477 
478  int selDistPhi = 0;
479  stringStr.str("");
480  stringStr<<selDistPhi;
481  aRefLayer->setAttribute(_toDOMS("selDistPhi"), _toDOMS(stringStr.str()));
482  int selDistPhiShift = 0;
483  stringStr.str("");
484  stringStr<<selDistPhiShift;
485  aRefLayer->setAttribute(_toDOMS("selDistPhiShift"), _toDOMS(stringStr.str()));
486  int distMsbPhiShift = 0;
487  stringStr.str("");
488  stringStr<<distMsbPhiShift;
489  aRefLayer->setAttribute(_toDOMS("distMsbPhiShift"), _toDOMS(stringStr.str()));
490  aLayer->appendChild(aRefLayer);
491  }
492  for(unsigned int iRefLayer=0;iRefLayer<myOMTFConfig->nRefLayers();++iRefLayer){
493  for(unsigned int iPdf=0;iPdf<exp2(myOMTFConfig->nPdfAddrBits());++iPdf){
494  aPdf = theDoc->createElement(_toDOMS("PDF"));
495  stringStr.str("");
496  stringStr<<aGP1.pdfValue(iLayer,iRefLayer,iPdf);
497  aPdf->setAttribute(_toDOMS("value1"), _toDOMS(stringStr.str()));
498  stringStr.str("");
499  stringStr<<aGP2.pdfValue(iLayer,iRefLayer,iPdf);
500  aPdf->setAttribute(_toDOMS("value2"), _toDOMS(stringStr.str()));
501  stringStr.str("");
502  stringStr<<aGP3.pdfValue(iLayer,iRefLayer,iPdf);
503  aPdf->setAttribute(_toDOMS("value3"), _toDOMS(stringStr.str()));
504  stringStr.str("");
505  stringStr<<aGP4.pdfValue(iLayer,iRefLayer,iPdf);
506  aPdf->setAttribute(_toDOMS("value4"), _toDOMS(stringStr.str()));
507  aLayer->appendChild(aPdf);
508  }
509  }
510  aGPElement->appendChild(aLayer);
511  }
512  theTopElement->appendChild(aGPElement);
513 }
516 void XMLConfigWriter::writeConnectionsData(const std::vector<std::vector <OMTFConfiguration::vector2D> > & measurements4D){
517 
518  std::ostringstream stringStr;
519 
520  for(unsigned int iProcessor=0;iProcessor<6;++iProcessor){
521  xercesc::DOMElement* aProcessorElement = theDoc->createElement(_toDOMS("Processor"));
522  stringStr.str("");
523  stringStr<<iProcessor;
524  aProcessorElement->setAttribute(_toDOMS("iProcessor"), _toDOMS(stringStr.str()));
525  for(unsigned int iRefLayer=0;iRefLayer<myOMTFConfig->nRefLayers();++iRefLayer){
526  xercesc::DOMElement* aRefLayerElement = theDoc->createElement(_toDOMS("RefLayer"));
527  stringStr.str("");
528  stringStr<<iRefLayer;
529  aRefLayerElement->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
530  stringStr.str("");
531  stringStr<<myOMTFConfig->getProcessorPhiVsRefLayer()[iProcessor][iRefLayer];
532  aRefLayerElement->setAttribute(_toDOMS("iGlobalPhiStart"), _toDOMS(stringStr.str()));
533  aProcessorElement->appendChild(aRefLayerElement);
534  }
535  unsigned int iRefHit = 0;
537  for(unsigned int iRefLayer=0;iRefLayer<myOMTFConfig->nRefLayers();++iRefLayer){
538  for(unsigned int iRegion=0;iRegion<6;++iRegion){
539  unsigned int maxHitCount = 0;
540  for(unsigned int iInput=0;iInput<14;++iInput) {
541  if((int)maxHitCount<myOMTFConfig->getMeasurements4Dref()[iProcessor][iRegion][iRefLayer][iInput])
542  maxHitCount = myOMTFConfig->getMeasurements4Dref()[iProcessor][iRegion][iRefLayer][iInput];
543  }
544  for(unsigned int iInput=0;iInput<14;++iInput){
545  unsigned int hitCount = myOMTFConfig->getMeasurements4Dref()[iProcessor][iRegion][iRefLayer][iInput];
546  if(hitCount<maxHitCount*0.1) continue;
547  xercesc::DOMElement* aRefHitElement = theDoc->createElement(_toDOMS("RefHit"));
548  stringStr.str("");
549  stringStr<<iRefHit;
550  aRefHitElement->setAttribute(_toDOMS("iRefHit"), _toDOMS(stringStr.str()));
551  stringStr.str("");
552  stringStr<<iRefLayer;
553  aRefHitElement->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
554 
555  stringStr.str("");
556  stringStr<<iRegion;
557  aRefHitElement->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
558 
559  stringStr.str("");
560  stringStr<<iInput;
561  aRefHitElement->setAttribute(_toDOMS("iInput"), _toDOMS(stringStr.str()));
562  unsigned int logicRegionSize = 10/360.0*myOMTFConfig->nPhiBins();
563  int lowScaleEnd = std::pow(2,myOMTFConfig->nPhiBits()-1);
565  int iPhiMin = myOMTFConfig->getProcessorPhiVsRefLayer()[iProcessor][iRefLayer]-myOMTFConfig->globalPhiStart(iProcessor)-lowScaleEnd;
566  int iPhiMax = iPhiMin+logicRegionSize-1;
567 
568  iPhiMin+=iRegion*logicRegionSize;
569  iPhiMax+=iRegion*logicRegionSize;
570 
571  stringStr.str("");
572  stringStr<<iPhiMin;
573  aRefHitElement->setAttribute(_toDOMS("iPhiMin"), _toDOMS(stringStr.str()));
574 
575  stringStr.str("");
576  stringStr<<iPhiMax;
577  aRefHitElement->setAttribute(_toDOMS("iPhiMax"), _toDOMS(stringStr.str()));
578  if(iRefHit<myOMTFConfig->nRefHits()) aProcessorElement->appendChild(aRefHitElement);
579  ++iRefHit;
580  }
581  for(;iRegion==5 && iRefLayer==7 && iRefHit<myOMTFConfig->nRefHits();++iRefHit){
582  xercesc::DOMElement* aRefHitElement = theDoc->createElement(_toDOMS("RefHit"));
583  stringStr.str("");
584  stringStr<<iRefHit;
585  aRefHitElement->setAttribute(_toDOMS("iRefHit"), _toDOMS(stringStr.str()));
586  stringStr.str("");
587  stringStr<<0;
588  aRefHitElement->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
589 
590  stringStr.str("");
591  stringStr<<0;
592  aRefHitElement->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
593 
594  stringStr.str("");
595  stringStr<<0;
596  aRefHitElement->setAttribute(_toDOMS("iInput"), _toDOMS(stringStr.str()));
597 
598  int iPhiMin = 0;
599  int iPhiMax = 1;
600 
601  stringStr.str("");
602  stringStr<<iPhiMin;
603  aRefHitElement->setAttribute(_toDOMS("iPhiMin"), _toDOMS(stringStr.str()));
604 
605  stringStr.str("");
606  stringStr<<iPhiMax;
607  aRefHitElement->setAttribute(_toDOMS("iPhiMax"), _toDOMS(stringStr.str()));
608 
609  aProcessorElement->appendChild(aRefHitElement);
610  }
611  }
612  }
614  for(unsigned int iRegion=0;iRegion<6;++iRegion){
615  xercesc::DOMElement* aRegionElement = theDoc->createElement(_toDOMS("LogicRegion"));
616  stringStr.str("");
617  stringStr<<iRegion;
618  aRegionElement->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
619 
620  for(unsigned int iLogicLayer=0;iLogicLayer<myOMTFConfig->nLayers();++iLogicLayer){
621  xercesc::DOMElement* aLayerElement = theDoc->createElement(_toDOMS("Layer"));
622  stringStr.str("");
623  stringStr<<iLogicLayer;
625  aLayerElement->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
626  const OMTFConfiguration::vector1D & myCounts = myOMTFConfig->getMeasurements4D()[iProcessor][iRegion][iLogicLayer];
627  unsigned int maxInput = findMaxInput(myCounts);
628  unsigned int begin = 0, end = 0;
629  if((int)maxInput-2>=0) begin = maxInput-2;
630  else begin = maxInput;
631  end = maxInput+3;
632  stringStr.str("");
633  stringStr<<begin;
634  aLayerElement->setAttribute(_toDOMS("iFirstInput"), _toDOMS(stringStr.str()));
635  stringStr.str("");
636  stringStr<<end-begin+1;
637  aLayerElement->setAttribute(_toDOMS("nInputs"), _toDOMS(stringStr.str()));
638  aRegionElement->appendChild(aLayerElement);
639  }
640  aProcessorElement->appendChild(aRegionElement);
641  }
642  theTopElement->appendChild(aProcessorElement);
643  }
644 }
648 
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];
654  maxInput = iInput;
655  }
656  }
657  return maxInput;
658 }
661 
Key key() const
Definition: GoldenPattern.h:58
void writeConnectionsData(const std::vector< std::vector< OMTFConfiguration::vector2D > > &measurements4D)
int getCharge() const
Definition: AlgoMuon.h:28
int getEta() const
Definition: AlgoMuon.h:22
XMLConfigWriter(const OMTFConfiguration *aOMTFConfig)
std::string _toString(XMLCh const *toTranscode)
int getQ() const
Definition: AlgoMuon.h:25
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)
int theCharge
Definition: GoldenPattern.h:35
unsigned int processor() const
Definition: OmtfName.cc:60
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
Definition: OMTFResult.h:20
unsigned int eta2Bits(unsigned int eta)
std::vector< int > vector1D
Definition: OMTFinput.h:15
unsigned int thePtCode
Definition: GoldenPattern.h:34
int getDisc() const
Definition: AlgoMuon.h:20
const OMTFinput::vector1D & getLayerData(unsigned int iLayer, bool giveEta=false) const
Definition: OMTFinput.cc:19
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
XMLCh * _toDOMS(std::string temp)
unsigned int findMaxInput(const OMTFConfiguration::vector1D &myCounts)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< int > vector1D
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
#define end
Definition: vmac.h:39
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)
int position() const
Definition: OmtfName.cc:58
const int hwPhi() const
Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
int getRefLayer() const
Definition: AlgoMuon.h:23
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
Definition: OMTFResult.h:14
int getHits() const
Definition: AlgoMuon.h:24
int globalPhiStart(unsigned int iProcessor) const
int pdfValue(unsigned int iLayer, unsigned int iRefLayer, unsigned int iBin) const
Definition: GoldenPattern.h:70
const std::vector< int > & getRefToLogicNumber() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::string name() const
Definition: OmtfName.cc:39
#define begin
Definition: vmac.h:32
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
int getPt() const
Definition: AlgoMuon.h:27
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
Definition: GoldenPattern.h:68
xercesc::DOMElement * theTopElement
vector4D & getMeasurements4Dref()
unsigned int getPatternNumber() const
Definition: AlgoMuon.h:30
int getPhi() const
Definition: AlgoMuon.h:21
int getPhiRHit() const
Definition: AlgoMuon.h:29
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
unsigned int patternsVersion() const
void writeGPData(const GoldenPattern &aGP)
int theEtaCode
Definition: GoldenPattern.h:33
vector4D & getMeasurements4D()