Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:37

0001 #include "RecoBTag/XMLCalibration/interface/CalibratedHistogramXML.h"
0002 #include "RecoBTag/XMLCalibration/interface/CalibrationXML.h"
0003 #include <iostream>
0004 
0005 using namespace std;
0006 void CalibratedHistogramXML::read(XERCES_CPP_NAMESPACE::DOMElement *dom) {
0007   binValues.clear();
0008   binULimits.clear();
0009   int size = CalibrationXML::readAttribute<int>(dom, "size");
0010 
0011   DOMNode *n1 = dom->getFirstChild();
0012   int bin;
0013   for (bin = 0; bin < size; bin++) {
0014     while ((n1->getNodeType() != DOMNode::ELEMENT_NODE) && (n1 != nullptr))
0015       n1 = n1->getNextSibling();
0016     if (n1) {
0017       DOMElement *binElement = (DOMElement *)n1;
0018       binValues.push_back(CalibrationXML::readAttribute<double>(binElement, "value"));
0019 
0020       binULimits.push_back(CalibrationXML::readAttribute<double>(binElement, "uLimit"));
0021       n1 = n1->getNextSibling();
0022     }
0023   }
0024   if (bin > 0)
0025     binValues.push_back(CalibrationXML::readAttribute<int>(dom, "overFlowValue"));
0026 
0027   limits = Range(binULimits.front(), binULimits.back());
0028   totalValid = false;
0029 }
0030 
0031 void CalibratedHistogramXML::write(XERCES_CPP_NAMESPACE::DOMElement *dom) const {
0032   int size = binULimits.size();
0033   CalibrationXML::writeAttribute(dom, "size", size);
0034   DOMElement *binElement;
0035   for (int bin = 0; bin < size; bin++) {
0036     binElement = CalibrationXML::addChild(dom, "Bin");
0037     CalibrationXML::writeAttribute(binElement, "value", binValues[bin]);
0038     CalibrationXML::writeAttribute(binElement, "uLimit", binULimits[bin]);
0039   }
0040   CalibrationXML::writeAttribute(dom, "overFlowValue", binValues[size]);
0041 }