17 #include <boost/property_tree/xml_parser.hpp> 27 const unsigned int mask16bits = 0xFFFF;
31 std::ostringstream stringStr;
33 stringStr <<
"0x" << std::hex << std::setfill(
'0') << std::setw(4) <<
version;
35 tree.put(
"OMTF.<xmlattr>.version", stringStr.str());
46 procTree.add(
"<xmlattr>.iProcessor", iProcessor);
48 std::ostringstream stringStr;
50 procTree.add(
"<xmlattr>.position", stringStr.str());
55 const std::shared_ptr<OMTFinput>&
input,
58 const std::vector<l1t::RegionalMuonCand>& candMuons) {
62 if (candMuons.empty())
66 boost::property_tree::ptree layerTree;
68 for (
unsigned int iHit = 0; iHit <
input->getMuonStubs()[iLayer].size(); ++iHit) {
69 int hitPhi =
input->getPhiHw(iLayer, iHit);
73 auto& hitTree = layerTree.add(
"Hit",
"");
75 hitTree.add(
"<xmlattr>.iInput", iHit);
76 hitTree.add(
"<xmlattr>.iEta",
input->getHitEta(iLayer, iHit));
77 hitTree.add(
"<xmlattr>.iPhi", hitPhi);
84 hitTree.add(
"<xmlattr>.iQual", 1);
86 hitTree.add(
"<xmlattr>.iQual",
input->getHitQual(iLayer, iHit));
89 if (!layerTree.empty()) {
90 layerTree.add(
"<xmlattr>.iLayer", iLayer);
91 procTree.add_child(
"Layer", layerTree);
95 for (
auto& algoCand : algoCandidates) {
97 if (algoCand->isValid()) {
98 auto& algoMuonTree =
procTree.add(
"AlgoMuon",
"");
99 algoMuonTree.add(
"<xmlattr>.charge", algoCand->getChargeConstr());
100 algoMuonTree.add(
"<xmlattr>.disc", algoCand->getDisc());
101 algoMuonTree.add(
"<xmlattr>.pdfSumConstr", algoCand->getGpResultConstr().getPdfSum());
102 algoMuonTree.add(
"<xmlattr>.pdfSumUnconstr", algoCand->getGpResultUnconstr().getPdfSumUnconstr());
103 algoMuonTree.add(
"<xmlattr>.etaCode", algoCand->getEtaHw());
104 algoMuonTree.add(
"<xmlattr>.iRefHit", algoCand->getRefHitNumber());
105 algoMuonTree.add(
"<xmlattr>.iRefLayer", algoCand->getRefLayer());
109 algoMuonTree.add(
"<xmlattr>.layersConstr", std::bitset<18>(algoCand->getGpResultConstr().getFiredLayerBits()));
110 algoMuonTree.add(
"<xmlattr>.layersUnconstr",
111 std::bitset<18>(algoCand->getGpResultUnconstr().getFiredLayerBits()));
113 algoMuonTree.add(
"<xmlattr>.nHits", algoCand->getQ());
115 algoMuonTree.add(
"<xmlattr>.firedCntConstr", algoCand->getGpResultConstr().getFiredLayerCnt());
116 algoMuonTree.add(
"<xmlattr>.firedCntUnconstr", algoCand->getGpResultUnconstr().getFiredLayerCnt());
118 algoMuonTree.add(
"<xmlattr>.patNumConstr", algoCand->getHwPatternNumConstr());
119 algoMuonTree.add(
"<xmlattr>.patNumUnconstr", algoCand->getHwPatternNumUnconstr());
121 algoMuonTree.add(
"<xmlattr>.phiCode", algoCand->getPhi());
123 algoMuonTree.add(
"<xmlattr>.phiConstr", algoCand->getGpResultConstr().getPhi());
124 algoMuonTree.add(
"<xmlattr>.phiUnConstr", algoCand->getGpResultUnconstr().getPhi());
126 algoMuonTree.add(
"<xmlattr>.phiRHit", algoCand->getPhiRHit());
130 algoMuonTree.add(
"<xmlattr>.ptCodeConstr", algoCand->getPtConstr());
131 algoMuonTree.add(
"<xmlattr>.ptCodeUnconstr", algoCand->getPtUnconstr());
133 auto& gpResultTree = algoMuonTree.add(
"gpResultConstr",
"");
134 auto& gpResultConstr = algoCand->getGpResultConstr();
136 gpResultTree.add(
"<xmlattr>.patNum", algoCand->getHwPatternNumConstr());
137 gpResultTree.add(
"<xmlattr>.pdfSum", gpResultConstr.getPdfSum());
139 for (
unsigned int iLogicLayer = 0; iLogicLayer < gpResultConstr.getStubResults().size(); ++iLogicLayer) {
140 auto& layerTree = gpResultTree.add(
"layer",
"");
141 layerTree.add(
"<xmlattr>.num", iLogicLayer);
142 auto pdfBin = gpResultConstr.getStubResults()[iLogicLayer].getPdfBin();
145 layerTree.add(
"<xmlattr>.pdfBin", pdfBin);
146 layerTree.add(
"<xmlattr>.pdfVal", gpResultConstr.getStubResults()[iLogicLayer].getPdfVal());
147 layerTree.add(
"<xmlattr>.fired", gpResultConstr.isLayerFired(iLogicLayer));
150 if (algoCand->getGpResultUnconstr().isValid()) {
151 auto& gpResultTree = algoMuonTree.add(
"gpResultUnconstr",
"");
152 auto& gpResult = algoCand->getGpResultUnconstr();
154 gpResultTree.add(
"<xmlattr>.patNum", algoCand->getHwPatternNumUnconstr());
155 gpResultTree.add(
"<xmlattr>.pdfSum", gpResult.getPdfSumUnconstr());
157 for (
unsigned int iLogicLayer = 0; iLogicLayer < gpResult.getStubResults().size(); ++iLogicLayer) {
158 auto& layerTree = gpResultTree.add(
"layer",
"");
159 layerTree.add(
"<xmlattr>.num", iLogicLayer);
160 auto pdfBin = gpResult.getStubResults()[iLogicLayer].getPdfBin();
163 layerTree.add(
"<xmlattr>.pdfBin", pdfBin);
164 layerTree.add(
"<xmlattr>.pdfVal", gpResult.getStubResults()[iLogicLayer].getPdfVal());
165 layerTree.add(
"<xmlattr>.fired", gpResult.isLayerFired(iLogicLayer));
171 for (
auto& candMuon : candMuons) {
172 auto& candMuonTree =
procTree.add(
"CandMuon",
"");
173 candMuonTree.add(
"<xmlattr>.hwEta", candMuon.hwEta());
174 candMuonTree.add(
"<xmlattr>.hwPhi", candMuon.hwPhi());
175 candMuonTree.add(
"<xmlattr>.hwPt", candMuon.hwPt());
176 candMuonTree.add(
"<xmlattr>.hwUPt", candMuon.hwPtUnconstrained());
177 candMuonTree.add(
"<xmlattr>.hwQual", candMuon.hwQual());
178 candMuonTree.add(
"<xmlattr>.hwSign", candMuon.hwSign());
179 candMuonTree.add(
"<xmlattr>.hwSignValid", candMuon.hwSignValid());
180 candMuonTree.add(
"<xmlattr>.hwTrackAddress", std::bitset<29>(candMuon.trackAddress().at(0)));
181 candMuonTree.add(
"<xmlattr>.link", candMuon.link());
182 candMuonTree.add(
"<xmlattr>.processor", candMuon.processor());
184 std::ostringstream stringStr;
186 stringStr <<
"OMTF_NEG";
188 stringStr <<
"OMTF_POS";
190 stringStr << candMuon.trackFinderType();
191 candMuonTree.add(
"<xmlattr>.trackFinderType", stringStr.str());
210 std::unique_ptr<l1t::RegionalMuonCandBxCollection>& finalCandidates) {}
213 edm::LogInfo(
"l1tOmtfEventPrint") <<
"XMLEventWriter::endJob() - writing the data to the xml - starting";
215 fName,
tree, std::locale(), boost::property_tree::xml_parser::xml_writer_make_settings<std::string>(
' ', 2));
216 edm::LogInfo(
"l1tOmtfEventPrint") <<
"XMLEventWriter::endJob() - writing the data to the xml - done";
void observeProcesorEmulation(unsigned int iProcessor, l1t::tftype mtfType, const std::shared_ptr< OMTFinput > &input, const AlgoMuons &algoCandidates, const AlgoMuons &gbCandidates, const std::vector< l1t::RegionalMuonCand > &candMuons) override
static std::string const input
unsigned int nPhiBins() const
unsigned int patternsVersion() const
unsigned int nLayers() const
def write_xml(scenario, fileName)
Log< level::Info, false > LogInfo
std::vector< AlgoMuonPtr > AlgoMuons
boost::property_tree::ptree * eventTree
void observeEventEnd(const edm::Event &iEvent, std::unique_ptr< l1t::RegionalMuonCandBxCollection > &finalCandidates) override
XMLEventWriter(const OMTFConfiguration *aOMTFConfig, std::string fName)
boost::property_tree::ptree procTree
void observeEventBegin(const edm::Event &iEvent) override
~XMLEventWriter() override
const OMTFConfiguration * omtfConfig
void observeProcesorBegin(unsigned int iProcessor, l1t::tftype mtfType) override