CMS 3D CMS Logo

XMLConfigWriter.cc
Go to the documentation of this file.
2 
8 
11 
12 #include <iostream>
13 #include <sstream>
14 #include <cmath>
15 #include <ctime>
16 #include <iomanip>
17 #include <bitset>
18 
19 #include "xercesc/framework/StdOutFormatTarget.hpp"
20 #include "xercesc/framework/LocalFileFormatTarget.hpp"
21 #include "xercesc/parsers/XercesDOMParser.hpp"
22 #include "xercesc/dom/DOM.hpp"
23 #include "xercesc/dom/DOMException.hpp"
24 #include "xercesc/dom/DOMImplementation.hpp"
25 #include "xercesc/sax/HandlerBase.hpp"
26 #include "xercesc/util/XMLString.hpp"
27 #include "xercesc/util/PlatformUtils.hpp"
28 #include "xercesc/util/XercesDefs.hpp"
29 #include "xercesc/util/XercesVersion.hpp"
31 
32 #if _XERCES_VERSION < 30100
33 #include "xercesc/dom/DOMWriter.hpp"
34 #else
35 #include "xercesc/dom/DOMLSSerializer.hpp"
36 #include "xercesc/dom/DOMLSOutput.hpp"
37 #endif
38 //
39 
40 namespace {
41  unsigned int eta2Bits(unsigned int eta) {
42  if (eta == 73)
43  return 0b100000000;
44  else if (eta == 78)
45  return 0b010000000;
46  else if (eta == 85)
47  return 0b001000000;
48  else if (eta == 90)
49  return 0b000100000;
50  else if (eta == 94)
51  return 0b000010000;
52  else if (eta == 99)
53  return 0b000001000;
54  else if (eta == 103)
55  return 0b000000100;
56  else if (eta == 110)
57  return 0b000000010;
58  else if (eta == 75)
59  return 0b110000000;
60  else if (eta == 79)
61  return 0b011000000;
62  else if (eta == 92)
63  return 0b000110000;
64  else if (eta == 115)
65  return 0b000000001;
66  else if (eta == 121)
67  return 0b000000000;
68  else
69  return 0b111111111;
70  ;
71  }
72 } // namespace
73 
75 // XMLConfigWriter
77 inline std::string _toString(XMLCh const* toTranscode) {
78  std::string tmp(xercesc::XMLString::transcode(toTranscode));
79  return tmp;
80 }
81 
82 inline XMLCh* _toDOMS(std::string temp) {
83  XMLCh* buff = XMLString::transcode(temp.c_str());
84  return buff;
85 }
89  XMLPlatformUtils::Initialize();
90 
92  domImpl = DOMImplementationRegistry::getDOMImplementation(_toDOMS("Range"));
93 
94  myOMTFConfig = aOMTFConfig;
95 }
99  theDoc = domImpl->createDocument(nullptr, _toDOMS(docName), nullptr);
100  theTopElement = theDoc->getDocumentElement();
101 
102  unsigned int version = myOMTFConfig->patternsVersion();
103  unsigned int mask16bits = 0xFFFF;
104 
105  version &= mask16bits;
106 
107  std::ostringstream stringStr;
108  stringStr.str("");
109  stringStr << "0x" << std::hex << std::setfill('0') << std::setw(4) << version;
110  theTopElement->setAttribute(_toDOMS("version"), _toDOMS(stringStr.str()));
111 }
115  XMLFormatTarget* formTarget = new LocalFileFormatTarget(fName.c_str());
116 
117 #if _XERCES_VERSION < 30100
118  xercesc::DOMWriter* domWriter = (dynamic_cast<DOMImplementation*>(domImpl))->createDOMWriter();
119  if (domWriter->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true)) {
120  domWriter->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
121  }
122  domWriter->writeNode(formTarget, *theTopElement);
123 
124 #else
125  xercesc::DOMLSSerializer* theSerializer = (dynamic_cast<DOMImplementation*>(domImpl))->createLSSerializer();
126  if (theSerializer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
127  theSerializer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
128  DOMLSOutput* theOutput = (dynamic_cast<DOMImplementation*>(domImpl))->createLSOutput();
129  theOutput->setByteStream(formTarget);
130  theSerializer->write(theTopElement, theOutput);
131  theOutput->release();
132  theSerializer->release();
133 #endif
134 
135  delete formTarget;
136 }
139 xercesc::DOMElement* XMLConfigWriter::writeEventHeader(unsigned int eventId, unsigned int mixedEventId) {
140  unsigned int eventBx = eventId * 2;
141 
142  xercesc::DOMElement* aEvent = nullptr;
143  xercesc::DOMElement* aBx = nullptr;
144  std::ostringstream stringStr;
145 
146  aEvent = theDoc->createElement(_toDOMS("Event"));
147 
148  stringStr.str("");
149  stringStr << eventId;
150  aEvent->setAttribute(_toDOMS("iEvent"), _toDOMS(stringStr.str()));
151 
152  stringStr.str("");
153  stringStr << mixedEventId;
154  aEvent->setAttribute(_toDOMS("iMixedEvent"), _toDOMS(stringStr.str()));
155 
156  aBx = theDoc->createElement(_toDOMS("bx"));
157  stringStr.str("");
158  stringStr << eventBx;
159  aBx->setAttribute(_toDOMS("iBx"), _toDOMS(stringStr.str()));
160  aEvent->appendChild(aBx);
161 
162  theTopElement->appendChild(aEvent);
163 
164  return aBx;
165 }
168 xercesc::DOMElement* XMLConfigWriter::writeEventData(xercesc::DOMElement* aTopElement,
169  const OmtfName& board,
170  const OMTFinput& aInput) {
171  std::ostringstream stringStr;
172 
173  xercesc::DOMElement* aProcessor = theDoc->createElement(_toDOMS("Processor"));
174  aProcessor->setAttribute(_toDOMS("board"), _toDOMS(board.name()));
175 
176  unsigned int iProcessor = board.processor();
177  stringStr.str("");
178  stringStr << iProcessor;
179  aProcessor->setAttribute(_toDOMS("iProcessor"), _toDOMS(stringStr.str()));
180  stringStr.str("");
181  if (board.position() == 1)
182  stringStr << "+";
183  stringStr << board.position();
184  aProcessor->setAttribute(_toDOMS("position"), _toDOMS(stringStr.str()));
185 
186  xercesc::DOMElement *aLayer, *aHit;
187  for (unsigned int iLayer = 0; iLayer < myOMTFConfig->nLayers(); ++iLayer) {
188  const OMTFinput::vector1D& layerDataPhi = aInput.getLayerData(iLayer);
189  const OMTFinput::vector1D& layerDataEta = aInput.getLayerData(iLayer, true);
190 
191  aLayer = theDoc->createElement(_toDOMS("Layer"));
192  stringStr.str("");
193  stringStr << iLayer;
194  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
195  for (unsigned int iHit = 0; iHit < layerDataPhi.size(); ++iHit) {
196  aHit = theDoc->createElement(_toDOMS("Hit"));
197  stringStr.str("");
198  stringStr << iHit;
199  aHit->setAttribute(_toDOMS("iInput"), _toDOMS(stringStr.str()));
200  stringStr.str("");
201  stringStr << layerDataPhi[iHit];
202  aHit->setAttribute(_toDOMS("iPhi"), _toDOMS(stringStr.str()));
203  stringStr.str("");
204  stringStr << eta2Bits(abs(layerDataEta[iHit]));
205  aHit->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
206  if (layerDataPhi[iHit] >= (int)myOMTFConfig->nPhiBins())
207  continue;
208  aLayer->appendChild(aHit);
209  }
210  if (aLayer->getChildNodes()->getLength())
211  aProcessor->appendChild(aLayer);
212  }
213 
214  aTopElement->appendChild(aProcessor);
215  return aProcessor;
216 }
219 void XMLConfigWriter::writeAlgoMuon(xercesc::DOMElement* aTopElement, unsigned int iRefHit, const AlgoMuon& aCand) {
220  xercesc::DOMElement* aResult = theDoc->createElement(_toDOMS("AlgoMuon"));
221  std::ostringstream stringStr;
222  stringStr.str("");
223  stringStr << iRefHit;
224  aResult->setAttribute(_toDOMS("iRefHit"), _toDOMS(stringStr.str()));
225  stringStr.str("");
226  stringStr << aCand.getPt();
227  aResult->setAttribute(_toDOMS("ptCode"), _toDOMS(stringStr.str()));
228  stringStr.str("");
229  stringStr << aCand.getPhi();
230  aResult->setAttribute(_toDOMS("phiCode"), _toDOMS(stringStr.str()));
231  stringStr.str("");
232  stringStr << eta2Bits(abs(aCand.getEta()));
233  aResult->setAttribute(_toDOMS("etaCode"), _toDOMS(stringStr.str()));
234  stringStr.str("");
235  stringStr << aCand.getCharge();
236  aResult->setAttribute(_toDOMS("charge"), _toDOMS(stringStr.str()));
237  stringStr.str("");
238  stringStr << aCand.getQ();
239  aResult->setAttribute(_toDOMS("nHits"), _toDOMS(stringStr.str()));
240  stringStr.str("");
241  stringStr << aCand.getDisc();
242  aResult->setAttribute(_toDOMS("disc"), _toDOMS(stringStr.str()));
243  stringStr.str("");
244  stringStr << aCand.getRefLayer();
245  aResult->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
246  stringStr.str("");
247  stringStr << std::bitset<18>(aCand.getHits());
248  aResult->setAttribute(_toDOMS("layers"), _toDOMS(stringStr.str()));
249  stringStr.str("");
250  stringStr << aCand.getPhiRHit();
251  aResult->setAttribute(_toDOMS("phiRHit"), _toDOMS(stringStr.str()));
252  stringStr.str("");
253  stringStr << aCand.getPatternNumber();
254  aResult->setAttribute(_toDOMS("patNum"), _toDOMS(stringStr.str()));
255 
256  aTopElement->appendChild(aResult);
257 }
260 void XMLConfigWriter::writeCandMuon(xercesc::DOMElement* aTopElement, const l1t::RegionalMuonCand& aCand) {
261  xercesc::DOMElement* aResult = theDoc->createElement(_toDOMS("CandMuon"));
262  std::ostringstream stringStr;
263  stringStr.str("");
264  stringStr << aCand.hwPt();
265  aResult->setAttribute(_toDOMS("hwPt"), _toDOMS(stringStr.str()));
266  stringStr.str("");
267  stringStr << aCand.hwPhi();
268  aResult->setAttribute(_toDOMS("hwPhi"), _toDOMS(stringStr.str()));
269  stringStr.str("");
270  stringStr << aCand.hwEta();
271  aResult->setAttribute(_toDOMS("hwEta"), _toDOMS(stringStr.str()));
272  stringStr.str("");
273  stringStr << aCand.hwSign();
274  aResult->setAttribute(_toDOMS("hwSign"), _toDOMS(stringStr.str()));
275  stringStr.str("");
276  stringStr << aCand.hwSignValid();
277  aResult->setAttribute(_toDOMS("hwSignValid"), _toDOMS(stringStr.str()));
278  stringStr.str("");
279  stringStr << aCand.hwQual();
280  aResult->setAttribute(_toDOMS("hwQual"), _toDOMS(stringStr.str()));
281  stringStr.str("");
282  std::map<int, int> hwAddrMap = aCand.trackAddress();
283  stringStr << std::bitset<29>(hwAddrMap[0]);
284  aResult->setAttribute(_toDOMS("hwTrackAddress"), _toDOMS(stringStr.str()));
285  stringStr.str("");
286  stringStr << aCand.link();
287  aResult->setAttribute(_toDOMS("link"), _toDOMS(stringStr.str()));
288  stringStr.str("");
289  stringStr << aCand.processor();
290  aResult->setAttribute(_toDOMS("processor"), _toDOMS(stringStr.str()));
291  stringStr.str("");
292  if (aCand.trackFinderType() == l1t::omtf_neg)
293  stringStr << "OMTF_NEG";
294  else if (aCand.trackFinderType() == l1t::omtf_pos)
295  stringStr << "OMTF_POS";
296  else
297  stringStr << aCand.trackFinderType();
298  aResult->setAttribute(_toDOMS("trackFinderType"), _toDOMS(stringStr.str()));
299  aTopElement->appendChild(aResult);
300 }
305 void XMLConfigWriter::writeResultsData(xercesc::DOMElement* aTopElement,
306  unsigned int iRegion,
307  const Key& aKey,
308  const OMTFResult& aResult) {
310 
311  std::ostringstream stringStr;
313  xercesc::DOMElement* aGP = theDoc->createElement(_toDOMS("GP"));
314  stringStr.str("");
315  stringStr << aKey.thePtCode;
316  aGP->setAttribute(_toDOMS("iPt"), _toDOMS(stringStr.str()));
317  stringStr.str("");
318  stringStr << aKey.theEtaCode;
319  aGP->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
320  stringStr.str("");
321  stringStr << "0";
322  aGP->setAttribute(_toDOMS("iPhi"), _toDOMS(stringStr.str()));
323  stringStr.str("");
324  stringStr << aKey.theCharge;
325  aGP->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));
328  for (unsigned int iRefLayer = 0; iRefLayer < myOMTFConfig->nRefLayers(); ++iRefLayer) {
329  xercesc::DOMElement* aRefLayer = theDoc->createElement(_toDOMS("Result"));
330  stringStr.str("");
331  stringStr << iRefLayer;
332  aRefLayer->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
333  stringStr.str("");
334  stringStr << iRegion;
335  aRefLayer->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
336  stringStr.str("");
337  stringStr << myOMTFConfig->getRefToLogicNumber()[iRefLayer];
338  aRefLayer->setAttribute(_toDOMS("iLogicLayer"), _toDOMS(stringStr.str()));
339  for (unsigned int iLogicLayer = 0; iLogicLayer < myOMTFConfig->nLayers(); ++iLogicLayer) {
340  xercesc::DOMElement* aLayer = theDoc->createElement(_toDOMS("Layer"));
341  stringStr.str("");
342  stringStr << iLogicLayer;
343  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
344  stringStr.str("");
345  stringStr << results[iLogicLayer][iRefLayer];
346  aLayer->setAttribute(_toDOMS("value"), _toDOMS(stringStr.str()));
347  if (results[iLogicLayer][iRefLayer])
348  aRefLayer->appendChild(aLayer);
349  }
350  if (aRefLayer->getChildNodes()->getLength())
351  aGP->appendChild(aRefLayer);
352  }
353  if (aGP->getChildNodes()->getLength())
354  aTopElement->appendChild(aGP);
355 }
359  std::ostringstream stringStr;
360  xercesc::DOMElement *aLayer = nullptr, *aRefLayer = nullptr, *aPdf = nullptr;
361 
362  xercesc::DOMElement* aGPElement = theDoc->createElement(_toDOMS("GP"));
363  stringStr.str("");
364  stringStr << aGP.key().thePtCode;
365  aGPElement->setAttribute(_toDOMS("iPt"), _toDOMS(stringStr.str()));
366  stringStr.str("");
367  //stringStr<<aGP.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 << aGP.key().theCharge;
375  aGPElement->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));
376 
377  for (unsigned int iLayer = 0; iLayer < myOMTFConfig->nLayers(); ++iLayer) {
378  int nOfPhis = 0;
380  aLayer = theDoc->createElement(_toDOMS("Layer"));
381  stringStr.str("");
382  stringStr << iLayer;
384  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
385  stringStr.str("");
386  stringStr << nOfPhis;
387  aLayer->setAttribute(_toDOMS("nOfPhis"), _toDOMS(stringStr.str()));
388  for (unsigned int iRefLayer = 0; iRefLayer < myOMTFConfig->nRefLayers(); ++iRefLayer) {
389  aRefLayer = theDoc->createElement(_toDOMS("RefLayer"));
390  int meanDistPhi = aGP.meanDistPhiValue(iLayer, iRefLayer);
391  stringStr.str("");
392  stringStr << meanDistPhi;
393  aRefLayer->setAttribute(_toDOMS("meanDistPhi"), _toDOMS(stringStr.str()));
394  int selDistPhi = 0;
395  stringStr.str("");
396  stringStr << selDistPhi;
397  aRefLayer->setAttribute(_toDOMS("selDistPhi"), _toDOMS(stringStr.str()));
398  int selDistPhiShift = 0;
399  stringStr.str("");
400  stringStr << selDistPhiShift;
401  aRefLayer->setAttribute(_toDOMS("selDistPhiShift"), _toDOMS(stringStr.str()));
402  int distMsbPhiShift = 0;
403  stringStr.str("");
404  stringStr << distMsbPhiShift;
405  aRefLayer->setAttribute(_toDOMS("distMsbPhiShift"), _toDOMS(stringStr.str()));
406  aLayer->appendChild(aRefLayer);
407  }
408  for (unsigned int iRefLayer = 0; iRefLayer < myOMTFConfig->nRefLayers(); ++iRefLayer) {
409  for (unsigned int iPdf = 0; iPdf < exp2(myOMTFConfig->nPdfAddrBits()); ++iPdf) {
410  aPdf = theDoc->createElement(_toDOMS("PDF"));
411  stringStr.str("");
412  stringStr << aGP.pdfValue(iLayer, iRefLayer, iPdf);
413  aPdf->setAttribute(_toDOMS("value"), _toDOMS(stringStr.str()));
414  aLayer->appendChild(aPdf);
415  }
416  }
417  aGPElement->appendChild(aLayer);
418  }
419  theTopElement->appendChild(aGPElement);
420 }
424  const GoldenPattern& aGP2,
425  const GoldenPattern& aGP3,
426  const GoldenPattern& aGP4) {
427  std::ostringstream stringStr;
428  xercesc::DOMElement *aLayer = nullptr, *aRefLayer = nullptr, *aPdf = nullptr;
429 
430  xercesc::DOMElement* aGPElement = theDoc->createElement(_toDOMS("GP"));
431  stringStr.str("");
432 
433  stringStr << aGP1.key().thePtCode;
434  aGPElement->setAttribute(_toDOMS("iPt1"), _toDOMS(stringStr.str()));
435  stringStr.str("");
436 
437  stringStr << aGP2.key().thePtCode;
438  aGPElement->setAttribute(_toDOMS("iPt2"), _toDOMS(stringStr.str()));
439  stringStr.str("");
440 
441  stringStr << aGP3.key().thePtCode;
442  aGPElement->setAttribute(_toDOMS("iPt3"), _toDOMS(stringStr.str()));
443  stringStr.str("");
444 
445  stringStr << aGP4.key().thePtCode;
446  aGPElement->setAttribute(_toDOMS("iPt4"), _toDOMS(stringStr.str()));
447 
448  stringStr.str("");
449  //stringStr<<aGP1.key().theEtaCode;
450  stringStr << "0"; //No eta code at the moment
451  aGPElement->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
452  stringStr.str("");
453  stringStr << "0"; //No phi code is assigned to GP for the moment.
454  aGPElement->setAttribute(_toDOMS("iPhi"), _toDOMS(stringStr.str()));
455  stringStr.str("");
456  stringStr << aGP1.key().theCharge;
457 
458  aGPElement->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));
459 
460  for (unsigned int iLayer = 0; iLayer < myOMTFConfig->nLayers(); ++iLayer) {
461  int nOfPhis = 0;
463  aLayer = theDoc->createElement(_toDOMS("Layer"));
464  stringStr.str("");
465  stringStr << iLayer;
467  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
468  stringStr.str("");
469  stringStr << nOfPhis;
470  aLayer->setAttribute(_toDOMS("nOfPhis"), _toDOMS(stringStr.str()));
471  for (unsigned int iRefLayer = 0; iRefLayer < myOMTFConfig->nRefLayers(); ++iRefLayer) {
472  aRefLayer = theDoc->createElement(_toDOMS("RefLayer"));
473  int meanDistPhi = aGP1.meanDistPhiValue(iLayer, iRefLayer);
474 
475  stringStr.str("");
476  stringStr << meanDistPhi;
477  aRefLayer->setAttribute(_toDOMS("meanDistPhi"), _toDOMS(stringStr.str()));
478 
479  //int meanDistPhi2 = aGP2.meanDistPhiValue(iLayer,iRefLayer);
480  //stringStr.str("");
481  //stringStr<<meanDistPhi2;
482  //aRefLayer->setAttribute(_toDOMS("meanDistPhi2"), _toDOMS(stringStr.str()));
483 
484  int selDistPhi = 0;
485  stringStr.str("");
486  stringStr << selDistPhi;
487  aRefLayer->setAttribute(_toDOMS("selDistPhi"), _toDOMS(stringStr.str()));
488  int selDistPhiShift = 0;
489  stringStr.str("");
490  stringStr << selDistPhiShift;
491  aRefLayer->setAttribute(_toDOMS("selDistPhiShift"), _toDOMS(stringStr.str()));
492  int distMsbPhiShift = 0;
493  stringStr.str("");
494  stringStr << distMsbPhiShift;
495  aRefLayer->setAttribute(_toDOMS("distMsbPhiShift"), _toDOMS(stringStr.str()));
496  aLayer->appendChild(aRefLayer);
497  }
498  for (unsigned int iRefLayer = 0; iRefLayer < myOMTFConfig->nRefLayers(); ++iRefLayer) {
499  for (unsigned int iPdf = 0; iPdf < exp2(myOMTFConfig->nPdfAddrBits()); ++iPdf) {
500  aPdf = theDoc->createElement(_toDOMS("PDF"));
501  stringStr.str("");
502  stringStr << aGP1.pdfValue(iLayer, iRefLayer, iPdf);
503  aPdf->setAttribute(_toDOMS("value1"), _toDOMS(stringStr.str()));
504  stringStr.str("");
505  stringStr << aGP2.pdfValue(iLayer, iRefLayer, iPdf);
506  aPdf->setAttribute(_toDOMS("value2"), _toDOMS(stringStr.str()));
507  stringStr.str("");
508  stringStr << aGP3.pdfValue(iLayer, iRefLayer, iPdf);
509  aPdf->setAttribute(_toDOMS("value3"), _toDOMS(stringStr.str()));
510  stringStr.str("");
511  stringStr << aGP4.pdfValue(iLayer, iRefLayer, iPdf);
512  aPdf->setAttribute(_toDOMS("value4"), _toDOMS(stringStr.str()));
513  aLayer->appendChild(aPdf);
514  }
515  }
516  aGPElement->appendChild(aLayer);
517  }
518  theTopElement->appendChild(aGPElement);
519 }
523  const std::vector<std::vector<OMTFConfiguration::vector2D> >& measurements4D) {
524  std::ostringstream stringStr;
525 
526  for (unsigned int iProcessor = 0; iProcessor < 6; ++iProcessor) {
527  xercesc::DOMElement* aProcessorElement = theDoc->createElement(_toDOMS("Processor"));
528  stringStr.str("");
529  stringStr << iProcessor;
530  aProcessorElement->setAttribute(_toDOMS("iProcessor"), _toDOMS(stringStr.str()));
531  for (unsigned int iRefLayer = 0; iRefLayer < myOMTFConfig->nRefLayers(); ++iRefLayer) {
532  xercesc::DOMElement* aRefLayerElement = theDoc->createElement(_toDOMS("RefLayer"));
533  stringStr.str("");
534  stringStr << iRefLayer;
535  aRefLayerElement->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
536  stringStr.str("");
537  stringStr << myOMTFConfig->getProcessorPhiVsRefLayer()[iProcessor][iRefLayer];
538  aRefLayerElement->setAttribute(_toDOMS("iGlobalPhiStart"), _toDOMS(stringStr.str()));
539  aProcessorElement->appendChild(aRefLayerElement);
540  }
541  unsigned int iRefHit = 0;
543  for (unsigned int iRefLayer = 0; iRefLayer < myOMTFConfig->nRefLayers(); ++iRefLayer) {
544  for (unsigned int iRegion = 0; iRegion < 6; ++iRegion) {
545  unsigned int maxHitCount = 0;
546  for (unsigned int iInput = 0; iInput < 14; ++iInput) {
547  if ((int)maxHitCount < myOMTFConfig->getMeasurements4Dref()[iProcessor][iRegion][iRefLayer][iInput])
548  maxHitCount = myOMTFConfig->getMeasurements4Dref()[iProcessor][iRegion][iRefLayer][iInput];
549  }
550  for (unsigned int iInput = 0; iInput < 14; ++iInput) {
551  unsigned int hitCount = myOMTFConfig->getMeasurements4Dref()[iProcessor][iRegion][iRefLayer][iInput];
552  if (hitCount < maxHitCount * 0.1)
553  continue;
554  xercesc::DOMElement* aRefHitElement = theDoc->createElement(_toDOMS("RefHit"));
555  stringStr.str("");
556  stringStr << iRefHit;
557  aRefHitElement->setAttribute(_toDOMS("iRefHit"), _toDOMS(stringStr.str()));
558  stringStr.str("");
559  stringStr << iRefLayer;
560  aRefHitElement->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
561 
562  stringStr.str("");
563  stringStr << iRegion;
564  aRefHitElement->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
565 
566  stringStr.str("");
567  stringStr << iInput;
568  aRefHitElement->setAttribute(_toDOMS("iInput"), _toDOMS(stringStr.str()));
569  unsigned int logicRegionSize = 10 / 360.0 * myOMTFConfig->nPhiBins();
570  int lowScaleEnd = std::pow(2, myOMTFConfig->nPhiBits() - 1);
572  int iPhiMin = myOMTFConfig->getProcessorPhiVsRefLayer()[iProcessor][iRefLayer] -
573  myOMTFConfig->globalPhiStart(iProcessor) - lowScaleEnd;
574  int iPhiMax = iPhiMin + logicRegionSize - 1;
575 
576  iPhiMin += iRegion * logicRegionSize;
577  iPhiMax += iRegion * logicRegionSize;
578 
579  stringStr.str("");
580  stringStr << iPhiMin;
581  aRefHitElement->setAttribute(_toDOMS("iPhiMin"), _toDOMS(stringStr.str()));
582 
583  stringStr.str("");
584  stringStr << iPhiMax;
585  aRefHitElement->setAttribute(_toDOMS("iPhiMax"), _toDOMS(stringStr.str()));
586  if (iRefHit < myOMTFConfig->nRefHits())
587  aProcessorElement->appendChild(aRefHitElement);
588  ++iRefHit;
589  }
590  for (; iRegion == 5 && iRefLayer == 7 && iRefHit < myOMTFConfig->nRefHits(); ++iRefHit) {
591  xercesc::DOMElement* aRefHitElement = theDoc->createElement(_toDOMS("RefHit"));
592  stringStr.str("");
593  stringStr << iRefHit;
594  aRefHitElement->setAttribute(_toDOMS("iRefHit"), _toDOMS(stringStr.str()));
595  stringStr.str("");
596  stringStr << 0;
597  aRefHitElement->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
598 
599  stringStr.str("");
600  stringStr << 0;
601  aRefHitElement->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
602 
603  stringStr.str("");
604  stringStr << 0;
605  aRefHitElement->setAttribute(_toDOMS("iInput"), _toDOMS(stringStr.str()));
606 
607  int iPhiMin = 0;
608  int iPhiMax = 1;
609 
610  stringStr.str("");
611  stringStr << iPhiMin;
612  aRefHitElement->setAttribute(_toDOMS("iPhiMin"), _toDOMS(stringStr.str()));
613 
614  stringStr.str("");
615  stringStr << iPhiMax;
616  aRefHitElement->setAttribute(_toDOMS("iPhiMax"), _toDOMS(stringStr.str()));
617 
618  aProcessorElement->appendChild(aRefHitElement);
619  }
620  }
621  }
623  for (unsigned int iRegion = 0; iRegion < 6; ++iRegion) {
624  xercesc::DOMElement* aRegionElement = theDoc->createElement(_toDOMS("LogicRegion"));
625  stringStr.str("");
626  stringStr << iRegion;
627  aRegionElement->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
628 
629  for (unsigned int iLogicLayer = 0; iLogicLayer < myOMTFConfig->nLayers(); ++iLogicLayer) {
630  xercesc::DOMElement* aLayerElement = theDoc->createElement(_toDOMS("Layer"));
631  stringStr.str("");
632  stringStr << iLogicLayer;
634  aLayerElement->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
635  const OMTFConfiguration::vector1D& myCounts =
636  myOMTFConfig->getMeasurements4D()[iProcessor][iRegion][iLogicLayer];
637  unsigned int maxInput = findMaxInput(myCounts);
638  unsigned int begin = 0, end = 0;
639  if ((int)maxInput - 2 >= 0)
640  begin = maxInput - 2;
641  else
642  begin = maxInput;
643  end = maxInput + 3;
644  stringStr.str("");
645  stringStr << begin;
646  aLayerElement->setAttribute(_toDOMS("iFirstInput"), _toDOMS(stringStr.str()));
647  stringStr.str("");
648  stringStr << end - begin + 1;
649  aLayerElement->setAttribute(_toDOMS("nInputs"), _toDOMS(stringStr.str()));
650  aRegionElement->appendChild(aLayerElement);
651  }
652  aProcessorElement->appendChild(aRegionElement);
653  }
654  theTopElement->appendChild(aProcessorElement);
655  }
656 }
660  unsigned int max = 0;
661  unsigned int maxInput = 0;
662  for (unsigned int iInput = 0; iInput < 14; ++iInput) {
663  if (myCounts[iInput] > (int)max) {
664  max = myCounts[iInput];
665  maxInput = iInput;
666  }
667  }
668  return maxInput;
669 }
const int hwPhi() const
Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
std::string _toString(XMLCh const *toTranscode)
void writeConnectionsData(const std::vector< std::vector< OMTFConfiguration::vector2D > > &measurements4D)
XMLConfigWriter(const OMTFConfiguration *aOMTFConfig)
int getQ() const
Definition: AlgoMuon.h:39
const OMTFResult::vector2D & getResults() const
Definition: OMTFResult.h:18
const std::vector< std::vector< int > > & getProcessorPhiVsRefLayer() const
void initialiseXMLDocument(const std::string &docName)
const int link() const
Get link on which the MicroGMT receives the candidate.
const int processor() const
Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF) ...
int theCharge
Definition: GoldenPattern.h:36
XMLCh * _toDOMS(std::string temp)
xercesc::DOMElement * writeEventData(xercesc::DOMElement *aTopElement, const OmtfName &board, const OMTFinput &aInput)
int getCharge() const
Definition: AlgoMuon.h:42
unsigned int eta2Bits(unsigned int eta)
unsigned int getPatternNumber() const
Definition: AlgoMuon.h:44
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
std::vector< int > vector1D
Definition: OMTFinput.h:13
unsigned int thePtCode
Definition: GoldenPattern.h:35
const int hwQual() const
Get quality code.
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
unsigned int nRefHits() const
int pdfValue(unsigned int iLayer, unsigned int iRefLayer, unsigned int iBin) const
Definition: GoldenPattern.h:68
const OMTFinput::vector1D & getLayerData(unsigned int iLayer, bool giveEta=false) const
Definition: OMTFinput.cc:17
xercesc::DOMDocument * theDoc
unsigned int nPhiBins() const
unsigned int patternsVersion() const
xercesc::DOMElement * theTopElement
Key key() const
Definition: GoldenPattern.h:56
void writeResultsData(xercesc::DOMElement *aTopElement, unsigned int iRegion, const Key &aKey, const OMTFResult &aResult)
unsigned int nPdfAddrBits() const
const tftype trackFinderType() const
Get track-finder which found the muon (bmtf, emtf_pos/emtf_neg or omtf_pos/omtf_neg) ...
unsigned int findMaxInput(const OMTFConfiguration::vector1D &myCounts)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< int > vector1D
unsigned int nLayers() const
const std::vector< int > & getRefToLogicNumber() const
void writeCandMuon(xercesc::DOMElement *aTopElement, const l1t::RegionalMuonCand &aCand)
const int hwSign() const
Get charge sign bit (charge = (-1)^(sign))
int globalPhiStart(unsigned int iProcessor) const
unsigned int nRefLayers() const
unsigned int nPhiBits() const
int position() const
Definition: OmtfName.cc:82
int getHits() const
Definition: AlgoMuon.h:38
std::vector< vector1D > vector2D
Definition: OMTFResult.h:12
const std::map< int, int > & trackAddress() const
Get the track address (identifies track primitives used for reconstruction)
int getPhiRHit() const
Definition: AlgoMuon.h:43
const int hwSignValid() const
Get charge sign valid bit (0 - not valid (high pT muon); 1 - valid)
std::string name() const
Definition: OmtfName.cc:51
int getRefLayer() const
Definition: AlgoMuon.h:37
int getPhi() const
Definition: AlgoMuon.h:35
const OMTFConfiguration * myOMTFConfig
unsigned int processor() const
Definition: OmtfName.cc:84
void finaliseXMLDocument(const std::string &fName)
results
Definition: mysort.py:8
int getDisc() const
Definition: AlgoMuon.h:34
xercesc::DOMImplementation * domImpl
void writeAlgoMuon(xercesc::DOMElement *aTopElement, unsigned int iRefHit, const AlgoMuon &aMuon)
int getPt() const
Definition: AlgoMuon.h:41
int meanDistPhiValue(unsigned int iLayer, unsigned int iRefLayer) const
Definition: GoldenPattern.h:66
xercesc::DOMElement * writeEventHeader(unsigned int eventId, unsigned int mixedEventId=0)
tmp
align.sh
Definition: createJobs.py:716
vector4D & getMeasurements4Dref()
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
int getEta() const
Definition: AlgoMuon.h:36
void writeGPData(const GoldenPattern &aGP)
int theEtaCode
Definition: GoldenPattern.h:34
vector4D & getMeasurements4D()