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());
49 procTree.add(
"<xmlattr>.iProcessor", iProcessor);
51 std::ostringstream stringStr;
53 procTree.add(
"<xmlattr>.position", stringStr.str());
58 const std::shared_ptr<OMTFinput>&
input,
61 const std::vector<l1t::RegionalMuonCand>& candMuons) {
68 if (candMuons.empty())
72 boost::property_tree::ptree layerTree;
74 for (
unsigned int iHit = 0; iHit <
input->getMuonStubs()[iLayer].size(); ++iHit) {
75 int hitPhi =
input->getPhiHw(iLayer, iHit);
79 auto& hitTree = layerTree.add(
"Hit",
"");
81 hitTree.add(
"<xmlattr>.iInput", iHit);
82 hitTree.add(
"<xmlattr>.iEta",
input->getHitEta(iLayer, iHit));
83 hitTree.add(
"<xmlattr>.iPhi", hitPhi);
90 hitTree.add(
"<xmlattr>.iQual", 1);
92 hitTree.add(
"<xmlattr>.iQual",
input->getHitQual(iLayer, iHit));
95 if (!layerTree.empty()) {
96 layerTree.add(
"<xmlattr>.iLayer", iLayer);
97 procTree.add_child(
"Layer", layerTree);
101 for (
auto& algoCand : algoCandidates) {
103 if (algoCand->isValid()) {
104 auto& algoMuonTree =
procTree.add(
"AlgoMuon",
"");
105 algoMuonTree.add(
"<xmlattr>.charge", algoCand->getChargeConstr());
106 algoMuonTree.add(
"<xmlattr>.disc", algoCand->getDisc());
107 algoMuonTree.add(
"<xmlattr>.pdfSumConstr", algoCand->getGpResultConstr().getPdfSum());
108 algoMuonTree.add(
"<xmlattr>.pdfSumUnconstr", algoCand->getGpResultUnconstr().getPdfSumUnconstr());
109 algoMuonTree.add(
"<xmlattr>.etaCode", algoCand->getEtaHw());
110 algoMuonTree.add(
"<xmlattr>.iRefHit", algoCand->getRefHitNumber());
111 algoMuonTree.add(
"<xmlattr>.iRefLayer", algoCand->getRefLayer());
115 algoMuonTree.add(
"<xmlattr>.layersConstr", std::bitset<18>(algoCand->getGpResultConstr().getFiredLayerBits()));
116 algoMuonTree.add(
"<xmlattr>.layersUnconstr",
117 std::bitset<18>(algoCand->getGpResultUnconstr().getFiredLayerBits()));
119 algoMuonTree.add(
"<xmlattr>.nHits", algoCand->getQ());
121 algoMuonTree.add(
"<xmlattr>.firedCntConstr", algoCand->getGpResultConstr().getFiredLayerCnt());
122 algoMuonTree.add(
"<xmlattr>.firedCntUnconstr", algoCand->getGpResultUnconstr().getFiredLayerCnt());
124 algoMuonTree.add(
"<xmlattr>.patNumConstr", algoCand->getHwPatternNumConstr());
125 algoMuonTree.add(
"<xmlattr>.patNumUnconstr", algoCand->getHwPatternNumUnconstr());
127 algoMuonTree.add(
"<xmlattr>.phiCode", algoCand->getPhi());
129 algoMuonTree.add(
"<xmlattr>.phiConstr", algoCand->getGpResultConstr().getPhi());
130 algoMuonTree.add(
"<xmlattr>.phiUnConstr", algoCand->getGpResultUnconstr().getPhi());
132 algoMuonTree.add(
"<xmlattr>.phiRHit", algoCand->getPhiRHit());
136 algoMuonTree.add(
"<xmlattr>.ptCodeConstr", algoCand->getPtConstr());
137 algoMuonTree.add(
"<xmlattr>.ptCodeUnconstr", algoCand->getPtUnconstr());
139 auto& gpResultTree = algoMuonTree.add(
"gpResultConstr",
"");
140 auto& gpResultConstr = algoCand->getGpResultConstr();
142 gpResultTree.add(
"<xmlattr>.patNum", algoCand->getHwPatternNumConstr());
143 gpResultTree.add(
"<xmlattr>.pdfSum", gpResultConstr.getPdfSum());
145 for (
unsigned int iLogicLayer = 0; iLogicLayer < gpResultConstr.getStubResults().size(); ++iLogicLayer) {
146 auto& layerTree = gpResultTree.add(
"layer",
"");
147 layerTree.add(
"<xmlattr>.num", iLogicLayer);
148 auto pdfBin = gpResultConstr.getStubResults()[iLogicLayer].getPdfBin();
151 layerTree.add(
"<xmlattr>.pdfBin", pdfBin);
152 layerTree.add(
"<xmlattr>.pdfVal", gpResultConstr.getStubResults()[iLogicLayer].getPdfVal());
153 layerTree.add(
"<xmlattr>.fired", gpResultConstr.isLayerFired(iLogicLayer));
156 if (algoCand->getGpResultUnconstr().isValid()) {
157 auto& gpResultTree = algoMuonTree.add(
"gpResultUnconstr",
"");
158 auto& gpResult = algoCand->getGpResultUnconstr();
160 gpResultTree.add(
"<xmlattr>.patNum", algoCand->getHwPatternNumUnconstr());
161 gpResultTree.add(
"<xmlattr>.pdfSum", gpResult.getPdfSumUnconstr());
163 for (
unsigned int iLogicLayer = 0; iLogicLayer < gpResult.getStubResults().size(); ++iLogicLayer) {
164 auto& layerTree = gpResultTree.add(
"layer",
"");
165 layerTree.add(
"<xmlattr>.num", iLogicLayer);
166 auto pdfBin = gpResult.getStubResults()[iLogicLayer].getPdfBin();
169 layerTree.add(
"<xmlattr>.pdfBin", pdfBin);
170 layerTree.add(
"<xmlattr>.pdfVal", gpResult.getStubResults()[iLogicLayer].getPdfVal());
171 layerTree.add(
"<xmlattr>.fired", gpResult.isLayerFired(iLogicLayer));
177 for (
auto& candMuon : candMuons) {
178 auto& candMuonTree =
procTree.add(
"CandMuon",
"");
179 candMuonTree.add(
"<xmlattr>.hwEta", candMuon.hwEta());
180 candMuonTree.add(
"<xmlattr>.hwPhi", candMuon.hwPhi());
181 candMuonTree.add(
"<xmlattr>.hwPt", candMuon.hwPt());
182 candMuonTree.add(
"<xmlattr>.hwUPt", candMuon.hwPtUnconstrained());
183 candMuonTree.add(
"<xmlattr>.hwQual", candMuon.hwQual());
184 candMuonTree.add(
"<xmlattr>.hwSign", candMuon.hwSign());
185 candMuonTree.add(
"<xmlattr>.hwSignValid", candMuon.hwSignValid());
186 candMuonTree.add(
"<xmlattr>.hwTrackAddress", std::bitset<29>(candMuon.trackAddress().at(0)));
187 candMuonTree.add(
"<xmlattr>.link", candMuon.link());
188 candMuonTree.add(
"<xmlattr>.processor", candMuon.processor());
190 std::ostringstream stringStr;
192 stringStr <<
"OMTF_NEG";
194 stringStr <<
"OMTF_POS";
196 stringStr << candMuon.trackFinderType();
197 candMuonTree.add(
"<xmlattr>.trackFinderType", stringStr.str());
220 std::unique_ptr<l1t::RegionalMuonCandBxCollection>& finalCandidates) {}
223 edm::LogInfo(
"l1tOmtfEventPrint") <<
"XMLEventWriter::endJob() - writing the data to the xml - starting";
225 fName,
tree, std::locale(), boost::property_tree::xml_parser::xml_writer_make_settings<std::string>(
' ', 2));
226 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