CMS 3D CMS Logo

CalibratedHistogramXML.cc
Go to the documentation of this file.
3 #include <iostream>
4 
5 using namespace std;
6 void CalibratedHistogramXML::read(XERCES_CPP_NAMESPACE::DOMElement *dom) {
7  binValues.clear();
8  binULimits.clear();
9  int size = CalibrationXML::readAttribute<int>(dom, "size");
10 
11  DOMNode *n1 = dom->getFirstChild();
12  int bin;
13  for (bin = 0; bin < size; bin++) {
14  while ((n1->getNodeType() != DOMNode::ELEMENT_NODE) && (n1 != nullptr))
15  n1 = n1->getNextSibling();
16  if (n1) {
17  DOMElement *binElement = (DOMElement *)n1;
18  binValues.push_back(CalibrationXML::readAttribute<double>(binElement, "value"));
19 
20  binULimits.push_back(CalibrationXML::readAttribute<double>(binElement, "uLimit"));
21  n1 = n1->getNextSibling();
22  }
23  }
24  if (bin > 0)
25  binValues.push_back(CalibrationXML::readAttribute<int>(dom, "overFlowValue"));
26 
27  limits = Range(binULimits.front(), binULimits.back());
28  totalValid = false;
29 }
30 
31 void CalibratedHistogramXML::write(XERCES_CPP_NAMESPACE::DOMElement *dom) const {
32  int size = binULimits.size();
34  DOMElement *binElement;
35  for (int bin = 0; bin < size; bin++) {
36  binElement = CalibrationXML::addChild(dom, "Bin");
37  CalibrationXML::writeAttribute(binElement, "value", binValues[bin]);
38  CalibrationXML::writeAttribute(binElement, "uLimit", binULimits[bin]);
39  }
40  CalibrationXML::writeAttribute(dom, "overFlowValue", binValues[size]);
41 }
size
Write out results.
static void writeAttribute(DOMElement *dom, const std::string &name, const T &value)
static DOMElement * addChild(DOMNode *dom, const std::string &name)
PixelRecoRange< float > Range
XERCES_CPP_NAMESPACE::DOMNode DOMNode
void write(DOMElement *dom) const override
XERCES_CPP_NAMESPACE::DOMElement DOMElement
void read(DOMElement *dom) override