CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::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 }
const OMTFConfiguration * myOMTFConfig
XMLCh * _toDOMS(std::string temp)
xercesc::DOMImplementation * domImpl
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 }
const OMTFConfiguration * myOMTFConfig
XMLCh * _toDOMS(std::string temp)
xercesc::DOMImplementation * domImpl

Member Function Documentation

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

Definition at line 114 of file XMLConfigWriter.cc.

References domImpl, and theTopElement.

Referenced by XMLEventWriter::endJob(), 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
void XMLConfigWriter::finaliseXMLDocument ( const std::string &  fName)
unsigned int XMLConfigWriter::findMaxInput ( const OMTFConfiguration::vector1D myCounts)

Definition at line 659 of file XMLConfigWriter.cc.

References SiStripPI::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 }
unsigned int XMLConfigWriter::findMaxInput ( const OMTFConfiguration::vector1D myCounts)
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(), writeGPs(), and XMLEventWriter::XMLEventWriter().

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 }
xercesc::DOMDocument * theDoc
xercesc::DOMElement * theTopElement
const OMTFConfiguration * myOMTFConfig
XMLCh * _toDOMS(std::string temp)
xercesc::DOMImplementation * domImpl
unsigned int patternsVersion() const
void XMLConfigWriter::initialiseXMLDocument ( const std::string &  docName)
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 XMLEventWriter::observeProcesorEmulation(), and 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 }
unsigned int eta2Bits(unsigned int eta)
xercesc::DOMDocument * theDoc
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
XMLCh * _toDOMS(std::string temp)
void XMLConfigWriter::writeAlgoMuon ( xercesc::DOMElement *  aTopElement,
const AlgoMuon aMuon 
)

Definition at line 220 of file XMLConfigWriter.cc.

References _toDOMS(), funct::abs(), XERCES_CPP_NAMESPACE_USE::eta2Bits(), AlgoMuon::getCharge(), AlgoMuon::getDisc(), AlgoMuon::getEtaHw(), AlgoMuon::getFiredLayerBits(), AlgoMuon::getHwPatternNumber(), AlgoMuon::getPhi(), AlgoMuon::getPhiRHit(), AlgoMuon::getPt(), AlgoMuon::getQ(), AlgoMuon::getRefHitNumber(), AlgoMuon::getRefLayer(), and theDoc.

220  {
221  xercesc::DOMElement* aResult = theDoc->createElement(_toDOMS("AlgoMuon"));
222  std::ostringstream stringStr;
223  stringStr.str("");
224  stringStr << aCand.getRefHitNumber();
225  aResult->setAttribute(_toDOMS("iRefHit"), _toDOMS(stringStr.str()));
226  stringStr.str("");
227  stringStr << aCand.getPt();
228  aResult->setAttribute(_toDOMS("ptCode"), _toDOMS(stringStr.str()));
229  stringStr.str("");
230  stringStr << aCand.getPhi();
231  aResult->setAttribute(_toDOMS("phiCode"), _toDOMS(stringStr.str()));
232  stringStr.str("");
233  stringStr << eta2Bits(abs(aCand.getEtaHw()));
234  aResult->setAttribute(_toDOMS("etaCode"), _toDOMS(stringStr.str()));
235  stringStr.str("");
236  stringStr << aCand.getCharge();
237  aResult->setAttribute(_toDOMS("charge"), _toDOMS(stringStr.str()));
238  stringStr.str("");
239  stringStr << aCand.getQ();
240  aResult->setAttribute(_toDOMS("nHits"), _toDOMS(stringStr.str()));
241  stringStr.str("");
242  stringStr << aCand.getDisc();
243  aResult->setAttribute(_toDOMS("disc"), _toDOMS(stringStr.str()));
244  stringStr.str("");
245  stringStr << aCand.getRefLayer();
246  aResult->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
247  stringStr.str("");
248  stringStr << std::bitset<18>(aCand.getFiredLayerBits());
249  aResult->setAttribute(_toDOMS("layers"), _toDOMS(stringStr.str()));
250  stringStr.str("");
251  stringStr << aCand.getPhiRHit();
252  aResult->setAttribute(_toDOMS("phiRHit"), _toDOMS(stringStr.str()));
253  stringStr.str("");
254  stringStr << aCand.getHwPatternNumber();
255  aResult->setAttribute(_toDOMS("patNum"), _toDOMS(stringStr.str()));
256 
257  aTopElement->appendChild(aResult);
258 }
unsigned int eta2Bits(unsigned int eta)
xercesc::DOMDocument * theDoc
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
XMLCh * _toDOMS(std::string temp)
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 XMLEventWriter::observeProcesorEmulation(), and 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 hwSignValid() const
Get charge sign valid bit (0 - not valid (high pT muon); 1 - valid)
const int hwQual() const
Get quality code.
xercesc::DOMDocument * theDoc
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
const std::map< int, int > & trackAddress() const
Get the track address (identifies track primitives used for reconstruction)
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 tftype trackFinderType() const
Get track-finder which found the muon (bmtf, emtf_pos/emtf_neg or omtf_pos/omtf_neg) ...
const int processor() const
Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF) ...
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
XMLCh * _toDOMS(std::string temp)
const int hwSign() const
Get charge sign bit (charge = (-1)^(sign))
void XMLConfigWriter::writeCandMuon ( xercesc::DOMElement *  aTopElement,
const l1t::RegionalMuonCand aCand 
)
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, dataset::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 }
unsigned int nRefLayers() const
unsigned int nRefHits() const
unsigned int nLayers() const
unsigned int nPhiBins() const
unsigned int nPhiBits() const
xercesc::DOMDocument * theDoc
xercesc::DOMElement * theTopElement
const std::vector< std::vector< int > > & getProcessorPhiVsRefLayer() const
unsigned int findMaxInput(const OMTFConfiguration::vector1D &myCounts)
std::vector< int > vector1D
int globalPhiStart(unsigned int iProcessor) const
const OMTFConfiguration * myOMTFConfig
XMLCh * _toDOMS(std::string temp)
string end
Definition: dataset.py:937
vector4D & getMeasurements4Dref()
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
vector4D & getMeasurements4D()
void XMLConfigWriter::writeConnectionsData ( const std::vector< std::vector< OMTFConfiguration::vector2D > > &  measurements4D)
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 XMLEventWriter::observeProcesorEmulation(), and 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 }
unsigned int processor() const
Definition: OmtfName.cc:84
unsigned int nLayers() const
unsigned int nPhiBins() const
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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int position() const
Definition: OmtfName.cc:82
std::string name() const
Definition: OmtfName.cc:51
const OMTFConfiguration * myOMTFConfig
XMLCh * _toDOMS(std::string temp)
xercesc::DOMElement* XMLConfigWriter::writeEventData ( xercesc::DOMElement *  aTopElement,
const OmtfName board,
const OMTFinput aInput 
)
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 XMLEventWriter::observeEventBegin(), and 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 }
xercesc::DOMDocument * theDoc
xercesc::DOMElement * theTopElement
XMLCh * _toDOMS(std::string temp)
xercesc::DOMElement* XMLConfigWriter::writeEventHeader ( unsigned int  eventId,
unsigned int  mixedEventId = 0 
)
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 }
Key key() const
Definition: GoldenPattern.h:56
unsigned int nRefLayers() const
int theCharge
Definition: GoldenPattern.h:36
unsigned int nLayers() const
unsigned int thePtCode
Definition: GoldenPattern.h:35
xercesc::DOMDocument * theDoc
xercesc::DOMElement * theTopElement
unsigned int nPdfAddrBits() const
int pdfValue(unsigned int iLayer, unsigned int iRefLayer, unsigned int iBin) const
Definition: GoldenPattern.h:68
const OMTFConfiguration * myOMTFConfig
XMLCh * _toDOMS(std::string temp)
int meanDistPhiValue(unsigned int iLayer, unsigned int iRefLayer) const
Definition: GoldenPattern.h:66
void XMLConfigWriter::writeGPData ( GoldenPattern aGP)

Definition at line 357 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.

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

Definition at line 431 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.

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

Definition at line 532 of file XMLConfigWriter.cc.

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

Referenced by PatternOptimizerBase::endJob().

532  {
533  initialiseXMLDocument("OMTF");
534  GoldenPattern* dummy = new GoldenPatternWithThresh(Key(0, 0, 0), myOMTFConfig);
535 
536  OMTFConfiguration::vector2D mergedPartters = myOMTFConfig->getPatternGroups(goldenPats);
537  for (unsigned int iGroup = 0; iGroup < mergedPartters.size(); iGroup++) {
538  std::vector<GoldenPattern*> gps(4, dummy);
539  for (unsigned int i = 0; i < mergedPartters[iGroup].size(); i++) {
540  GoldenPattern* gp = dynamic_cast<GoldenPattern*>(goldenPats.at(mergedPartters[iGroup][i]).get());
541  if (!gp) {
542  throw cms::Exception("OMTF::XMLConfigWriter::writeGPs: the gps are not GoldenPatterns ");
543  }
544  /*cout<<gp->key()<<endl;;
545  for(unsigned int iLayer = 0; iLayer<myOMTFConfig->nLayers(); ++iLayer) {
546  for(unsigned int iRefLayer=0; iRefLayer<myOMTFConfig->nRefLayers(); ++iRefLayer) {
547  if(gp->getPdf()[iLayer][iRefLayer][0] != 0) {
548  cout<<"iLayer "<<iLayer<<" iRefLayer "<<iRefLayer<<" pdf[0] "<<gp->getPdf()[iLayer][iRefLayer][0]<<"!!!!!!!!!!!!!!!!!!!!\n";
549  }
550  }
551  }*/
552  gps[i] = gp;
553  }
554  writeGPData(gps[0], gps[1], gps[2], gps[3]);
555  }
557 }
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)
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(), bookConverter::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 }
unsigned int nRefLayers() const
dictionary results
int theCharge
Definition: GoldenPattern.h:36
unsigned int nLayers() const
const OMTFResult::vector2D & getResults() const
Definition: OMTFResult.h:18
unsigned int thePtCode
Definition: GoldenPattern.h:35
xercesc::DOMDocument * theDoc
std::vector< vector1D > vector2D
Definition: OMTFResult.h:12
const std::vector< int > & getRefToLogicNumber() const
const OMTFConfiguration * myOMTFConfig
XMLCh * _toDOMS(std::string temp)
int theEtaCode
Definition: GoldenPattern.h:34
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 306 of file XMLConfigWriter.cc.

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

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

Member Data Documentation

xercesc::DOMImplementation * XMLConfigWriter::domImpl
private

Definition at line 61 of file XMLConfigWriter.h.

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

const OMTFConfiguration * XMLConfigWriter::myOMTFConfig
private
xercesc::DOMDocument * XMLConfigWriter::theDoc
private
xercesc::DOMElement * XMLConfigWriter::theTopElement
private
bool XMLConfigWriter::writeMeanDistPhi1 = false
private

Definition at line 70 of file XMLConfigWriter.h.

Referenced by writeGPData().

bool XMLConfigWriter::writePdfThresholds = false
private

Definition at line 69 of file XMLConfigWriter.h.

Referenced by writeGPData().