CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
XMLConfigWriter Class Reference

#include <XMLConfigWriter.h>

Public Member Functions

void finaliseXMLDocument (const std::string &fName)
 
void finaliseXMLDocument (const std::string &fName)
 
unsigned int findMaxInput (const OMTFConfiguration::vector1D &myCounts)
 
unsigned int findMaxInput (const OMTFConfiguration::vector1D &myCounts)
 
void initialiseXMLDocument (const std::string &docName)
 
void initialiseXMLDocument (const std::string &docName)
 
void writeAlgoMuon (xercesc::DOMElement *aTopElement, unsigned int iRefHit, const AlgoMuon &aMuon)
 
void writeAlgoMuon (xercesc::DOMElement *aTopElement, const AlgoMuon &aMuon)
 
void writeCandMuon (xercesc::DOMElement *aTopElement, const l1t::RegionalMuonCand &aCand)
 
void writeCandMuon (xercesc::DOMElement *aTopElement, const l1t::RegionalMuonCand &aCand)
 
void writeConnectionsData (const std::vector< std::vector< OMTFConfiguration::vector2D > > &measurements4D)
 
void writeConnectionsData (const std::vector< std::vector< OMTFConfiguration::vector2D > > &measurements4D)
 
xercesc::DOMElement * writeEventData (xercesc::DOMElement *aTopElement, const OmtfName &board, const OMTFinput &aInput)
 
xercesc::DOMElement * writeEventData (xercesc::DOMElement *aTopElement, const OmtfName &board, const OMTFinput &aInput)
 
xercesc::DOMElement * writeEventHeader (unsigned int eventId, unsigned int mixedEventId=0)
 
xercesc::DOMElement * writeEventHeader (unsigned int eventId, unsigned int mixedEventId=0)
 
void writeGPData (const GoldenPattern &aGP)
 
void writeGPData (const GoldenPattern &aGP1, const GoldenPattern &aGP2, const GoldenPattern &aGP3, const GoldenPattern &aGP4)
 
void writeGPData (GoldenPattern &aGP)
 
void writeGPData (GoldenPattern *aGP1, GoldenPattern *aGP2, GoldenPattern *aGP3, GoldenPattern *aGP4)
 
template<class GoldenPatternType >
void writeGPs (const GoldenPatternVec< GoldenPatternType > &goldenPats, std::string fName)
 
void writeResultsData (xercesc::DOMElement *aTopElement, unsigned int iRegion, const Key &aKey, const OMTFResult &aResult)
 
void writeResultsData (xercesc::DOMElement *aTopElement, unsigned int iRegion, const Key &aKey, const GoldenPatternResult &aResult)
 
 XMLConfigWriter (const OMTFConfiguration *aOMTFConfig)
 
 XMLConfigWriter (const OMTFConfiguration *aOMTFConfig, bool writePdfThresholds=false, bool writeMeanDistPhi1=false)
 

Private Attributes

xercesc::DOMImplementation * domImpl
 
const OMTFConfigurationmyOMTFConfig
 
xercesc::DOMDocument * theDoc
 
xercesc::DOMElement * theTopElement
 
bool writeMeanDistPhi1 = false
 
bool writePdfThresholds = false
 

Detailed Description

Definition at line 28 of file XMLConfigWriter.h.

Constructor & Destructor Documentation

◆ XMLConfigWriter() [1/2]

XMLConfigWriter::XMLConfigWriter ( const OMTFConfiguration aOMTFConfig)

Initialise XML document

Definition at line 88 of file XMLConfigWriter.cc.

References _toDOMS(), domImpl, and myOMTFConfig.

88  {
89  XMLPlatformUtils::Initialize();
90 
92  domImpl = DOMImplementationRegistry::getDOMImplementation(_toDOMS("Range"));
93 
94  myOMTFConfig = aOMTFConfig;
95 }
XMLCh * _toDOMS(std::string temp)
const OMTFConfiguration * myOMTFConfig
xercesc::DOMImplementation * domImpl

◆ XMLConfigWriter() [2/2]

XMLConfigWriter::XMLConfigWriter ( const OMTFConfiguration aOMTFConfig,
bool  writePdfThresholds = false,
bool  writeMeanDistPhi1 = false 
)

Initialise XML document

Definition at line 88 of file XMLConfigWriter.cc.

References _toDOMS(), domImpl, and myOMTFConfig.

90  XMLPlatformUtils::Initialize();
91 
93  domImpl = DOMImplementationRegistry::getDOMImplementation(_toDOMS("Range"));
94 
95  myOMTFConfig = aOMTFConfig;
96 }
XMLCh * _toDOMS(std::string temp)
const OMTFConfiguration * myOMTFConfig
xercesc::DOMImplementation * domImpl

Member Function Documentation

◆ finaliseXMLDocument() [1/2]

void XMLConfigWriter::finaliseXMLDocument ( const std::string &  fName)

Definition at line 114 of file XMLConfigWriter.cc.

References domImpl, isotrackTrainRegressor::fName, and theTopElement.

Referenced by OMTFReconstruction::endJob(), OMTFPatternMaker::endJob(), and writeGPs().

114  {
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 }
xercesc::DOMElement * theTopElement
xercesc::DOMImplementation * domImpl

◆ finaliseXMLDocument() [2/2]

void XMLConfigWriter::finaliseXMLDocument ( const std::string &  fName)

◆ findMaxInput() [1/2]

unsigned int XMLConfigWriter::findMaxInput ( const OMTFConfiguration::vector1D myCounts)

Definition at line 659 of file XMLConfigWriter.cc.

References WZElectronSkims53X_cff::max.

Referenced by writeConnectionsData().

659  {
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 }

◆ findMaxInput() [2/2]

unsigned int XMLConfigWriter::findMaxInput ( const OMTFConfiguration::vector1D myCounts)

◆ initialiseXMLDocument() [1/2]

void XMLConfigWriter::initialiseXMLDocument ( const std::string &  docName)

Definition at line 98 of file XMLConfigWriter.cc.

References _toDOMS(), domImpl, myOMTFConfig, OMTFConfiguration::patternsVersion(), theDoc, theTopElement, and relval_steps::version.

Referenced by OMTFReconstruction::beginRun(), OMTFPatternMaker::endJob(), and writeGPs().

98  {
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 }
XMLCh * _toDOMS(std::string temp)
xercesc::DOMDocument * theDoc
unsigned int patternsVersion() const
xercesc::DOMElement * theTopElement
const OMTFConfiguration * myOMTFConfig
xercesc::DOMImplementation * domImpl

◆ initialiseXMLDocument() [2/2]

void XMLConfigWriter::initialiseXMLDocument ( const std::string &  docName)

◆ writeAlgoMuon() [1/2]

void XMLConfigWriter::writeAlgoMuon ( xercesc::DOMElement *  aTopElement,
unsigned int  iRefHit,
const AlgoMuon aMuon 
)

Definition at line 219 of file XMLConfigWriter.cc.

References _toDOMS(), funct::abs(), XERCES_CPP_NAMESPACE_USE::eta2Bits(), AlgoMuon::getCharge(), AlgoMuon::getDisc(), AlgoMuon::getEta(), AlgoMuon::getHits(), AlgoMuon::getPatternNumber(), AlgoMuon::getPhi(), AlgoMuon::getPhiRHit(), AlgoMuon::getPt(), AlgoMuon::getQ(), AlgoMuon::getRefLayer(), and theDoc.

Referenced by OMTFReconstruction::writeResultToXML().

219  {
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 }
XMLCh * _toDOMS(std::string temp)
unsigned int eta2Bits(unsigned int eta)
xercesc::DOMDocument * theDoc
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ writeAlgoMuon() [2/2]

void XMLConfigWriter::writeAlgoMuon ( xercesc::DOMElement *  aTopElement,
const AlgoMuon aMuon 
)

Definition at line 218 of file XMLConfigWriter.cc.

References _toDOMS(), funct::abs(), XERCES_CPP_NAMESPACE_USE::eta2Bits(), AlgoMuon::getChargeConstr(), AlgoMuon::getDisc(), AlgoMuon::getEtaHw(), AlgoMuon::getFiredLayerBits(), AlgoMuon::getHwPatternNumConstr(), AlgoMuon::getPhi(), AlgoMuon::getPhiRHit(), AlgoMuon::getPtConstr(), AlgoMuon::getQ(), AlgoMuon::getRefHitNumber(), AlgoMuon::getRefLayer(), and theDoc.

218  {
219  xercesc::DOMElement* aResult = theDoc->createElement(_toDOMS("AlgoMuon"));
220  std::ostringstream stringStr;
221  stringStr.str("");
222  stringStr << aCand.getRefHitNumber();
223  aResult->setAttribute(_toDOMS("iRefHit"), _toDOMS(stringStr.str()));
224  stringStr.str("");
225  stringStr << aCand.getPtConstr();
226  aResult->setAttribute(_toDOMS("ptCode"), _toDOMS(stringStr.str()));
227  stringStr.str("");
228  stringStr << aCand.getPhi();
229  aResult->setAttribute(_toDOMS("phiCode"), _toDOMS(stringStr.str()));
230  stringStr.str("");
231  stringStr << eta2Bits(abs(aCand.getEtaHw()));
232  aResult->setAttribute(_toDOMS("etaCode"), _toDOMS(stringStr.str()));
233  stringStr.str("");
234  stringStr << aCand.getChargeConstr();
235  aResult->setAttribute(_toDOMS("charge"), _toDOMS(stringStr.str()));
236  stringStr.str("");
237  stringStr << aCand.getQ();
238  aResult->setAttribute(_toDOMS("nHits"), _toDOMS(stringStr.str()));
239  stringStr.str("");
240  stringStr << aCand.getDisc();
241  aResult->setAttribute(_toDOMS("disc"), _toDOMS(stringStr.str()));
242  stringStr.str("");
243  stringStr << aCand.getRefLayer();
244  aResult->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
245  stringStr.str("");
246  stringStr << std::bitset<18>(aCand.getFiredLayerBits());
247  aResult->setAttribute(_toDOMS("layers"), _toDOMS(stringStr.str()));
248  stringStr.str("");
249  stringStr << aCand.getPhiRHit();
250  aResult->setAttribute(_toDOMS("phiRHit"), _toDOMS(stringStr.str()));
251  stringStr.str("");
252  stringStr << aCand.getHwPatternNumConstr();
253  aResult->setAttribute(_toDOMS("patNum"), _toDOMS(stringStr.str()));
254 
255  aTopElement->appendChild(aResult);
256 }
XMLCh * _toDOMS(std::string temp)
unsigned int eta2Bits(unsigned int eta)
xercesc::DOMDocument * theDoc
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ writeCandMuon() [1/2]

void XMLConfigWriter::writeCandMuon ( xercesc::DOMElement *  aTopElement,
const l1t::RegionalMuonCand aCand 
)

Definition at line 260 of file XMLConfigWriter.cc.

References _toDOMS(), l1t::RegionalMuonCand::hwEta(), l1t::RegionalMuonCand::hwPhi(), l1t::RegionalMuonCand::hwPt(), l1t::RegionalMuonCand::hwQual(), l1t::RegionalMuonCand::hwSign(), l1t::RegionalMuonCand::hwSignValid(), l1t::RegionalMuonCand::link(), l1t::omtf_neg, l1t::omtf_pos, l1t::RegionalMuonCand::processor(), theDoc, l1t::RegionalMuonCand::trackAddress(), and l1t::RegionalMuonCand::trackFinderType().

Referenced by OMTFReconstruction::writeResultToXML().

260  {
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 }
const int hwPhi() const
Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
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) ...
XMLCh * _toDOMS(std::string temp)
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
const int hwQual() const
Get quality code.
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
xercesc::DOMDocument * theDoc
const tftype trackFinderType() const
Get track-finder which found the muon (bmtf, emtf_pos/emtf_neg or omtf_pos/omtf_neg) ...
const int hwSign() const
Get charge sign bit (charge = (-1)^(sign))
const std::map< int, int > & trackAddress() const
Get the track address (identifies track primitives used for reconstruction)
const int hwSignValid() const
Get charge sign valid bit (0 - not valid (high pT muon); 1 - valid)

◆ writeCandMuon() [2/2]

void XMLConfigWriter::writeCandMuon ( xercesc::DOMElement *  aTopElement,
const l1t::RegionalMuonCand aCand 
)

◆ writeConnectionsData() [1/2]

void XMLConfigWriter::writeConnectionsData ( const std::vector< std::vector< OMTFConfiguration::vector2D > > &  measurements4D)

iPhiMin and iPhiMax are expressed in n bit scale -2**n, +2**2-1 used in each processor

Definition at line 522 of file XMLConfigWriter.cc.

References _toDOMS(), SplitLinear::begin, mps_fire::end, findMaxInput(), OMTFConfiguration::getMeasurements4D(), OMTFConfiguration::getMeasurements4Dref(), OMTFConfiguration::getProcessorPhiVsRefLayer(), OMTFConfiguration::globalPhiStart(), myOMTFConfig, OMTFConfiguration::nLayers(), OMTFConfiguration::nPhiBins(), OMTFConfiguration::nPhiBits(), OMTFConfiguration::nRefHits(), OMTFConfiguration::nRefLayers(), funct::pow(), theDoc, and theTopElement.

Referenced by OMTFPatternMaker::endJob().

523  {
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 }
const std::vector< std::vector< int > > & getProcessorPhiVsRefLayer() const
XMLCh * _toDOMS(std::string temp)
unsigned int nRefHits() const
xercesc::DOMDocument * theDoc
unsigned int nPhiBins() const
xercesc::DOMElement * theTopElement
unsigned int findMaxInput(const OMTFConfiguration::vector1D &myCounts)
std::vector< int > vector1D
unsigned int nLayers() const
int globalPhiStart(unsigned int iProcessor) const
unsigned int nRefLayers() const
unsigned int nPhiBits() const
const OMTFConfiguration * myOMTFConfig
vector4D & getMeasurements4Dref()
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
vector4D & getMeasurements4D()

◆ writeConnectionsData() [2/2]

void XMLConfigWriter::writeConnectionsData ( const std::vector< std::vector< OMTFConfiguration::vector2D > > &  measurements4D)

◆ writeEventData() [1/2]

xercesc::DOMElement * XMLConfigWriter::writeEventData ( xercesc::DOMElement *  aTopElement,
const OmtfName board,
const OMTFinput aInput 
)

Definition at line 168 of file XMLConfigWriter.cc.

References _toDOMS(), funct::abs(), XERCES_CPP_NAMESPACE_USE::eta2Bits(), OMTFinput::getLayerData(), myOMTFConfig, OmtfName::name(), OMTFConfiguration::nLayers(), OMTFConfiguration::nPhiBins(), OmtfName::position(), OmtfName::processor(), and theDoc.

Referenced by OMTFReconstruction::writeResultToXML().

170  {
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 }
XMLCh * _toDOMS(std::string temp)
unsigned int eta2Bits(unsigned int eta)
std::vector< int > vector1D
Definition: OMTFinput.h:13
const OMTFinput::vector1D & getLayerData(unsigned int iLayer, bool giveEta=false) const
Definition: OMTFinput.cc:17
xercesc::DOMDocument * theDoc
unsigned int nPhiBins() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned int nLayers() const
int position() const
Definition: OmtfName.cc:82
std::string name() const
Definition: OmtfName.cc:51
const OMTFConfiguration * myOMTFConfig
unsigned int processor() const
Definition: OmtfName.cc:84

◆ writeEventData() [2/2]

xercesc::DOMElement* XMLConfigWriter::writeEventData ( xercesc::DOMElement *  aTopElement,
const OmtfName board,
const OMTFinput aInput 
)

◆ writeEventHeader() [1/2]

xercesc::DOMElement * XMLConfigWriter::writeEventHeader ( unsigned int  eventId,
unsigned int  mixedEventId = 0 
)

Definition at line 139 of file XMLConfigWriter.cc.

References _toDOMS(), theDoc, and theTopElement.

Referenced by OMTFReconstruction::reconstruct().

139  {
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 }
XMLCh * _toDOMS(std::string temp)
xercesc::DOMDocument * theDoc
xercesc::DOMElement * theTopElement

◆ writeEventHeader() [2/2]

xercesc::DOMElement* XMLConfigWriter::writeEventHeader ( unsigned int  eventId,
unsigned int  mixedEventId = 0 
)

◆ writeGPData() [1/4]

void XMLConfigWriter::writeGPData ( const GoldenPattern aGP)

Definition at line 358 of file XMLConfigWriter.cc.

References _toDOMS(), GoldenPattern::key(), GoldenPattern::meanDistPhiValue(), myOMTFConfig, OMTFConfiguration::nLayers(), OMTFConfiguration::nPdfAddrBits(), OMTFConfiguration::nRefLayers(), GoldenPattern::pdfValue(), Key::theCharge, theDoc, Key::thePtCode, and theTopElement.

Referenced by OMTFPatternMaker::endJob(), writeGPs(), and OMTFPatternMaker::writeMergedGPs().

358  {
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 }
int theCharge
Definition: GoldenPattern.h:36
XMLCh * _toDOMS(std::string temp)
unsigned int thePtCode
Definition: GoldenPattern.h:35
int pdfValue(unsigned int iLayer, unsigned int iRefLayer, unsigned int iBin) const
Definition: GoldenPattern.h:68
xercesc::DOMDocument * theDoc
xercesc::DOMElement * theTopElement
Key key() const
Definition: GoldenPattern.h:56
unsigned int nPdfAddrBits() const
unsigned int nLayers() const
unsigned int nRefLayers() const
const OMTFConfiguration * myOMTFConfig
int meanDistPhiValue(unsigned int iLayer, unsigned int iRefLayer) const
Definition: GoldenPattern.h:66

◆ writeGPData() [2/4]

void XMLConfigWriter::writeGPData ( GoldenPattern aGP)

Definition at line 355 of file XMLConfigWriter.cc.

References _toDOMS(), GoldenPattern::getDistPhiBitShift(), GoldenPattern::getMeanDistPhi(), GoldenPattern::key(), myOMTFConfig, OMTFConfiguration::nLayers(), OMTFConfiguration::nPdfAddrBits(), OMTFConfiguration::nRefLayers(), GoldenPattern::pdfValue(), Key::theCharge, theDoc, Key::thePt, and theTopElement.

355  {
356  std::ostringstream stringStr;
357  xercesc::DOMElement *aLayer = nullptr, *aRefLayer = nullptr, *aPdf = nullptr;
358 
359  xercesc::DOMElement* aGPElement = theDoc->createElement(_toDOMS("GP"));
360  stringStr.str("");
361  stringStr << aGP.key().thePt;
362  aGPElement->setAttribute(_toDOMS("iPt"), _toDOMS(stringStr.str()));
363  stringStr.str("");
364  //stringStr<<aGP.key().theEtaCode;
365  stringStr << "0"; //No eta code at the moment
366  aGPElement->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
367  stringStr.str("");
368  stringStr << 0; //No phi code is assigned to GP for the moment.
369  aGPElement->setAttribute(_toDOMS("iPhi"), _toDOMS(stringStr.str()));
370  stringStr.str("");
371  stringStr << aGP.key().theCharge;
372  aGPElement->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));
373 
374  for (unsigned int iLayer = 0; iLayer < myOMTFConfig->nLayers(); ++iLayer) {
375  int nOfPhis = 0;
377  aLayer = theDoc->createElement(_toDOMS("Layer"));
378  stringStr.str("");
379  stringStr << iLayer;
381  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
382  stringStr.str("");
383  stringStr << nOfPhis;
384  aLayer->setAttribute(_toDOMS("nOfPhis"), _toDOMS(stringStr.str()));
385  for (unsigned int iRefLayer = 0; iRefLayer < myOMTFConfig->nRefLayers(); ++iRefLayer) {
386  aRefLayer = theDoc->createElement(_toDOMS("RefLayer"));
387  int meanDistPhi0 = aGP.getMeanDistPhi()[iLayer][iRefLayer][0];
388  stringStr.str("");
389  stringStr << meanDistPhi0;
390  aRefLayer->setAttribute(_toDOMS("meanDistPhi0"), _toDOMS(stringStr.str()));
391 
392  int meanDistPhi1 = aGP.getMeanDistPhi()[iLayer][iRefLayer][1];
393  stringStr.str("");
394  stringStr << meanDistPhi1;
395  aRefLayer->setAttribute(_toDOMS("meanDistPhi1"), _toDOMS(stringStr.str()));
396 
397  int selDistPhi = 0;
398  stringStr.str("");
399  stringStr << selDistPhi;
400  aRefLayer->setAttribute(_toDOMS("selDistPhi"), _toDOMS(stringStr.str()));
401 
402  int selDistPhiShift =
403  aGP.getDistPhiBitShift(iLayer, iRefLayer); //TODO check if Wojtek expects it here or on the distMsbPhiShift
404  stringStr.str("");
405  stringStr << selDistPhiShift;
406  aRefLayer->setAttribute(_toDOMS("selDistPhiShift"), _toDOMS(stringStr.str()));
407 
408  int distMsbPhiShift = 0;
409  stringStr.str("");
410  stringStr << distMsbPhiShift;
411  aRefLayer->setAttribute(_toDOMS("distMsbPhiShift"), _toDOMS(stringStr.str()));
412  aLayer->appendChild(aRefLayer);
413  }
414  for (unsigned int iRefLayer = 0; iRefLayer < myOMTFConfig->nRefLayers(); ++iRefLayer) {
415  for (unsigned int iPdf = 0; iPdf < exp2(myOMTFConfig->nPdfAddrBits()); ++iPdf) {
416  aPdf = theDoc->createElement(_toDOMS("PDF"));
417  stringStr.str("");
418  stringStr << aGP.pdfValue(iLayer, iRefLayer, iPdf);
419  aPdf->setAttribute(_toDOMS("value"), _toDOMS(stringStr.str()));
420  aLayer->appendChild(aPdf);
421  }
422  }
423  aGPElement->appendChild(aLayer);
424  }
425  theTopElement->appendChild(aGPElement);
426 }
int theCharge
Definition: GoldenPattern.h:36
XMLCh * _toDOMS(std::string temp)
int pdfValue(unsigned int iLayer, unsigned int iRefLayer, unsigned int iBin) const
Definition: GoldenPattern.h:68
const vector2D & getMeanDistPhi() const
Definition: GoldenPattern.h:60
xercesc::DOMDocument * theDoc
xercesc::DOMElement * theTopElement
Key key() const
Definition: GoldenPattern.h:56
unsigned int nPdfAddrBits() const
unsigned int nLayers() const
unsigned int nRefLayers() const
unsigned int thePt
const OMTFConfiguration * myOMTFConfig
int getDistPhiBitShift(unsigned int iLayer, unsigned int iRefLayer) const override
Definition: GoldenPattern.h:72

◆ writeGPData() [3/4]

void XMLConfigWriter::writeGPData ( const GoldenPattern aGP1,
const GoldenPattern aGP2,
const GoldenPattern aGP3,
const GoldenPattern aGP4 
)

Definition at line 423 of file XMLConfigWriter.cc.

References _toDOMS(), GoldenPattern::key(), GoldenPattern::meanDistPhiValue(), myOMTFConfig, OMTFConfiguration::nLayers(), OMTFConfiguration::nPdfAddrBits(), OMTFConfiguration::nRefLayers(), GoldenPattern::pdfValue(), Key::theCharge, theDoc, Key::thePtCode, and theTopElement.

426  {
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 }
int theCharge
Definition: GoldenPattern.h:36
XMLCh * _toDOMS(std::string temp)
unsigned int thePtCode
Definition: GoldenPattern.h:35
int pdfValue(unsigned int iLayer, unsigned int iRefLayer, unsigned int iBin) const
Definition: GoldenPattern.h:68
xercesc::DOMDocument * theDoc
xercesc::DOMElement * theTopElement
Key key() const
Definition: GoldenPattern.h:56
unsigned int nPdfAddrBits() const
unsigned int nLayers() const
unsigned int nRefLayers() const
const OMTFConfiguration * myOMTFConfig
int meanDistPhiValue(unsigned int iLayer, unsigned int iRefLayer) const
Definition: GoldenPattern.h:66

◆ writeGPData() [4/4]

void XMLConfigWriter::writeGPData ( GoldenPattern aGP1,
GoldenPattern aGP2,
GoldenPattern aGP3,
GoldenPattern aGP4 
)

Definition at line 429 of file XMLConfigWriter.cc.

References _toDOMS(), GoldenPattern::getDistPhiBitShift(), GoldenPattern::getMeanDistPhi(), GoldenPattern::key(), myOMTFConfig, mergeVDriftHistosByStation::name, OMTFConfiguration::nLayers(), OMTFConfiguration::nPdfAddrBits(), OMTFConfiguration::nRefLayers(), GoldenPattern::pdfValue(), AlCaHLTBitMon_QueryRunRegistry::string, Key::theCharge, theDoc, Key::thePt, theTopElement, relativeConstraints::value, writeMeanDistPhi1, and writePdfThresholds.

429  {
430  std::ostringstream stringStr;
431  auto setAttributeInt = [&](xercesc::DOMElement* domElement, std::string name, int value) -> void {
432  stringStr << value;
433  domElement->setAttribute(_toDOMS(name), _toDOMS(stringStr.str()));
434  stringStr.str("");
435  };
436 
437  auto setAttributeFloat = [&](xercesc::DOMElement* domElement, std::string name, float value) -> void {
438  stringStr << value;
439  domElement->setAttribute(_toDOMS(name), _toDOMS(stringStr.str()));
440  stringStr.str("");
441  };
442 
443  //xercesc::DOMElement *aLayer=nullptr, *aRefLayer=nullptr, *aPdf=nullptr;
444 
445  xercesc::DOMElement* aGPElement = theDoc->createElement(_toDOMS("GP"));
446 
447  setAttributeInt(aGPElement, "iPt1", aGP1->key().thePt);
448  setAttributeInt(aGPElement, "iPt2", aGP2->key().thePt);
449  setAttributeInt(aGPElement, "iPt3", aGP3->key().thePt);
450  setAttributeInt(aGPElement, "iPt4", aGP4->key().thePt);
451 
452  if (writePdfThresholds) {
453  if (dynamic_cast<const GoldenPatternWithThresh*>(aGP1) != nullptr) {
454  for (unsigned int iRefLayer = 0; iRefLayer < myOMTFConfig->nRefLayers(); ++iRefLayer) {
455  //cout<<__FUNCTION__<<":"<<__LINE__<<std::endl;
456  xercesc::DOMElement* aRefLayerThresh = theDoc->createElement(_toDOMS("RefLayerThresh"));
457  setAttributeFloat(
458  aRefLayerThresh, "tresh1", dynamic_cast<const GoldenPatternWithThresh*>(aGP1)->getThreshold(iRefLayer));
459  setAttributeFloat(
460  aRefLayerThresh, "tresh2", dynamic_cast<const GoldenPatternWithThresh*>(aGP2)->getThreshold(iRefLayer));
461  setAttributeFloat(
462  aRefLayerThresh, "tresh3", dynamic_cast<const GoldenPatternWithThresh*>(aGP3)->getThreshold(iRefLayer));
463  setAttributeFloat(
464  aRefLayerThresh, "tresh4", dynamic_cast<const GoldenPatternWithThresh*>(aGP4)->getThreshold(iRefLayer));
465 
466  aGPElement->appendChild(aRefLayerThresh);
467  }
468  }
469  }
470 
471  setAttributeInt(aGPElement, "iEta", 0); //aGP1.key().theEtaCode; //No eta code at the moment
472 
473  setAttributeInt(aGPElement, "iPhi", 0); //No phi code is assigned to GP for the moment.
474 
475  setAttributeInt(aGPElement, "iCharge", aGP1->key().theCharge);
476 
477  for (unsigned int iLayer = 0; iLayer < myOMTFConfig->nLayers(); ++iLayer) {
478  int nOfPhis = 0;
480  xercesc::DOMElement* aLayer = theDoc->createElement(_toDOMS("Layer"));
481 
482  setAttributeInt(aLayer, "iLayer", iLayer);
483  setAttributeInt(aLayer, "nOfPhis", nOfPhis);
484 
485  for (unsigned int iRefLayer = 0; iRefLayer < myOMTFConfig->nRefLayers(); ++iRefLayer) {
486  xercesc::DOMElement* aRefLayer = theDoc->createElement(_toDOMS("RefLayer"));
487 
488  if (writeMeanDistPhi1) {
489  int meanDistPhi0 = aGP1->getMeanDistPhi()[iLayer][iRefLayer][0];
490  setAttributeInt(aRefLayer, "meanDistPhi0", meanDistPhi0);
491 
492  int meanDistPhi1 = aGP1->getMeanDistPhi()[iLayer][iRefLayer][1];
493  setAttributeInt(aRefLayer, "meanDistPhi1", meanDistPhi1);
494  } else {
495  int meanDistPhi = aGP1->getMeanDistPhi()[iLayer][iRefLayer][0];
496  setAttributeInt(aRefLayer, "meanDistPhi", meanDistPhi);
497  }
498 
499  int selDistPhi = 0;
500  setAttributeInt(aRefLayer, "selDistPhi", selDistPhi);
501 
502  int selDistPhiShift = aGP1->getDistPhiBitShift(
503  iLayer, iRefLayer); //TODO check if Wojtek expects it here or on the distMsbPhiShift;
504  setAttributeInt(aRefLayer, "selDistPhiShift", selDistPhiShift);
505 
506  int distMsbPhiShift = 0;
507  setAttributeInt(aRefLayer, "distMsbPhiShift", distMsbPhiShift);
508 
509  aLayer->appendChild(aRefLayer);
510  }
511  for (unsigned int iRefLayer = 0; iRefLayer < myOMTFConfig->nRefLayers(); ++iRefLayer) {
512  for (unsigned int iPdf = 0; iPdf < exp2(myOMTFConfig->nPdfAddrBits()); ++iPdf) {
513  xercesc::DOMElement* aPdf = theDoc->createElement(_toDOMS("PDF"));
514 
515  setAttributeFloat(aPdf, "value1", aGP1->pdfValue(iLayer, iRefLayer, iPdf));
516  setAttributeFloat(aPdf, "value2", aGP2->pdfValue(iLayer, iRefLayer, iPdf));
517  setAttributeFloat(aPdf, "value3", aGP3->pdfValue(iLayer, iRefLayer, iPdf));
518  setAttributeFloat(aPdf, "value4", aGP4->pdfValue(iLayer, iRefLayer, iPdf));
519 
520  aLayer->appendChild(aPdf);
521  }
522  }
523  aGPElement->appendChild(aLayer);
524  }
525  theTopElement->appendChild(aGPElement);
526 }
int theCharge
Definition: GoldenPattern.h:36
XMLCh * _toDOMS(std::string temp)
int pdfValue(unsigned int iLayer, unsigned int iRefLayer, unsigned int iBin) const
Definition: GoldenPattern.h:68
const vector2D & getMeanDistPhi() const
Definition: GoldenPattern.h:60
xercesc::DOMDocument * theDoc
xercesc::DOMElement * theTopElement
Key key() const
Definition: GoldenPattern.h:56
unsigned int nPdfAddrBits() const
unsigned int nLayers() const
unsigned int nRefLayers() const
unsigned int thePt
const OMTFConfiguration * myOMTFConfig
int getDistPhiBitShift(unsigned int iLayer, unsigned int iRefLayer) const override
Definition: GoldenPattern.h:72

◆ writeGPs()

template<class GoldenPatternType >
template void XMLConfigWriter::writeGPs ( const GoldenPatternVec< GoldenPatternType > &  goldenPats,
std::string  fName 
)

Definition at line 530 of file XMLConfigWriter.cc.

References Exception, finaliseXMLDocument(), isotrackTrainRegressor::fName, OMTFConfiguration::getPatternGroups(), runTauDisplay::gp, mps_fire::i, initialiseXMLDocument(), myOMTFConfig, and writeGPData().

Referenced by PatternOptimizerBase::endJob().

530  {
531  initialiseXMLDocument("OMTF");
533 
534  OMTFConfiguration::vector2D mergedPartters = myOMTFConfig->getPatternGroups(goldenPats);
535  for (unsigned int iGroup = 0; iGroup < mergedPartters.size(); iGroup++) {
536  std::vector<GoldenPattern*> gps(4, dummy);
537  for (unsigned int i = 0; i < mergedPartters[iGroup].size(); i++) {
538  GoldenPattern* gp = dynamic_cast<GoldenPattern*>(goldenPats.at(mergedPartters[iGroup][i]).get());
539  if (!gp) {
540  throw cms::Exception("OMTF::XMLConfigWriter::writeGPs: the gps are not GoldenPatterns ");
541  }
542  gps[i] = gp;
543  }
544  writeGPData(gps[0], gps[1], gps[2], gps[3]);
545  }
547 }
void initialiseXMLDocument(const std::string &docName)
std::vector< vector1D > vector2D
const OMTFConfiguration * myOMTFConfig
void finaliseXMLDocument(const std::string &fName)
vector2D getPatternGroups(const std::vector< std::unique_ptr< GoldenPatternType > > &goldenPats) const
void writeGPData(const GoldenPattern &aGP)

◆ writeResultsData() [1/2]

void XMLConfigWriter::writeResultsData ( xercesc::DOMElement *  aTopElement,
unsigned int  iRegion,
const Key aKey,
const OMTFResult aResult 
)

Write GP key parameters

Write results details for this GP

Definition at line 305 of file XMLConfigWriter.cc.

References _toDOMS(), OMTFConfiguration::getRefToLogicNumber(), OMTFResult::getResults(), myOMTFConfig, OMTFConfiguration::nLayers(), OMTFConfiguration::nRefLayers(), mysort::results, Key::theCharge, theDoc, Key::theEtaCode, and Key::thePtCode.

Referenced by OMTFReconstruction::writeResultToXML().

308  {
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 }
const OMTFResult::vector2D & getResults() const
Definition: OMTFResult.h:18
int theCharge
Definition: GoldenPattern.h:36
XMLCh * _toDOMS(std::string temp)
unsigned int thePtCode
Definition: GoldenPattern.h:35
xercesc::DOMDocument * theDoc
unsigned int nLayers() const
const std::vector< int > & getRefToLogicNumber() const
unsigned int nRefLayers() const
std::vector< vector1D > vector2D
Definition: OMTFResult.h:12
const OMTFConfiguration * myOMTFConfig
results
Definition: mysort.py:8
int theEtaCode
Definition: GoldenPattern.h:34

◆ writeResultsData() [2/2]

void XMLConfigWriter::writeResultsData ( xercesc::DOMElement *  aTopElement,
unsigned int  iRegion,
const Key aKey,
const GoldenPatternResult aResult 
)

Write GP key parameters

Write results details for this GP

Definition at line 304 of file XMLConfigWriter.cc.

References _toDOMS(), GoldenPatternResult::getRefLayer(), OMTFConfiguration::getRefToLogicNumber(), GoldenPatternResult::getStubResults(), myOMTFConfig, OMTFConfiguration::nLayers(), Key::theCharge, theDoc, Key::theEtaCode, and Key::thePt.

307  {
308  std::ostringstream stringStr;
310  xercesc::DOMElement* aGP = theDoc->createElement(_toDOMS("GP"));
311  stringStr.str("");
312  stringStr << aKey.thePt;
313  aGP->setAttribute(_toDOMS("iPt"), _toDOMS(stringStr.str()));
314  stringStr.str("");
315  stringStr << aKey.theEtaCode;
316  aGP->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
317  stringStr.str("");
318  stringStr << "0";
319  aGP->setAttribute(_toDOMS("iPhi"), _toDOMS(stringStr.str()));
320  stringStr.str("");
321  stringStr << aKey.theCharge;
322  aGP->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));
325  {
326  xercesc::DOMElement* aRefLayer = theDoc->createElement(_toDOMS("Result"));
327  stringStr.str("");
328  stringStr << aResult.getRefLayer();
329  aRefLayer->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
330  stringStr.str("");
331  stringStr << iRegion;
332  aRefLayer->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
333  stringStr.str("");
334  stringStr << myOMTFConfig->getRefToLogicNumber()[aResult.getRefLayer()];
335  aRefLayer->setAttribute(_toDOMS("iLogicLayer"), _toDOMS(stringStr.str()));
336  for (unsigned int iLogicLayer = 0; iLogicLayer < myOMTFConfig->nLayers(); ++iLogicLayer) {
337  xercesc::DOMElement* aLayer = theDoc->createElement(_toDOMS("Layer"));
338  stringStr.str("");
339  stringStr << iLogicLayer;
340  aLayer->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
341  stringStr.str("");
342  stringStr << aResult.getStubResults()[iLogicLayer].getPdfVal();
343  aLayer->setAttribute(_toDOMS("value"), _toDOMS(stringStr.str()));
344  if (aResult.getStubResults()[iLogicLayer].getPdfVal())
345  aRefLayer->appendChild(aLayer);
346  }
347  if (aRefLayer->getChildNodes()->getLength())
348  aGP->appendChild(aRefLayer);
349  }
350  if (aGP->getChildNodes()->getLength())
351  aTopElement->appendChild(aGP);
352 }
int theCharge
Definition: GoldenPattern.h:36
XMLCh * _toDOMS(std::string temp)
xercesc::DOMDocument * theDoc
const StubResults & getStubResults() const
unsigned int nLayers() const
const std::vector< int > & getRefToLogicNumber() const
unsigned int thePt
const OMTFConfiguration * myOMTFConfig
int theEtaCode
Definition: GoldenPattern.h:34

Member Data Documentation

◆ domImpl

xercesc::DOMImplementation * XMLConfigWriter::domImpl
private

Definition at line 61 of file XMLConfigWriter.h.

Referenced by finaliseXMLDocument(), initialiseXMLDocument(), and XMLConfigWriter().

◆ myOMTFConfig

const OMTFConfiguration * XMLConfigWriter::myOMTFConfig
private

◆ theDoc

xercesc::DOMDocument * XMLConfigWriter::theDoc
private

◆ theTopElement

xercesc::DOMElement * XMLConfigWriter::theTopElement
private

◆ writeMeanDistPhi1

bool XMLConfigWriter::writeMeanDistPhi1 = false
private

Definition at line 70 of file XMLConfigWriter.h.

Referenced by writeGPData().

◆ writePdfThresholds

bool XMLConfigWriter::writePdfThresholds = false
private

Definition at line 69 of file XMLConfigWriter.h.

Referenced by writeGPData().