CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoBTag/XMLCalibration/src/CalibratedHistogramXML.cc

Go to the documentation of this file.
00001 #include "RecoBTag/XMLCalibration/interface/CalibratedHistogramXML.h"
00002 #include "RecoBTag/XMLCalibration/interface/CalibrationXML.h"
00003 #include <iostream>
00004 
00005 using namespace std;
00006 void  CalibratedHistogramXML::read (XERCES_CPP_NAMESPACE::DOMElement * dom)
00007   {
00008     binValues.clear();
00009     binULimits.clear();
00010     int size=  CalibrationXML::readAttribute<int>(dom,"size");
00011     
00012     DOMNode * n1 = dom->getFirstChild();
00013     int bin;
00014     for(bin=0; bin < size; bin ++)
00015     {
00016         while( ( n1->getNodeType() != DOMNode::ELEMENT_NODE ) && ( n1 != 0 ) )   n1 = n1->getNextSibling();
00017           if (n1)
00018           {
00019               DOMElement * binElement = (DOMElement *) n1;
00020               binValues.push_back(CalibrationXML::readAttribute<double>(binElement,"value"));
00021         
00022               binULimits.push_back(CalibrationXML::readAttribute<double>(binElement,"uLimit"));      
00023                n1 = n1->getNextSibling();
00024           }             
00025     }
00026     if(bin>0)
00027       binValues.push_back(CalibrationXML::readAttribute<int>(dom,"overFlowValue"));
00028 
00029     limits = Range(binULimits.front(), binULimits.back());
00030     totalValid = false;
00031   }
00032   
00033 void  CalibratedHistogramXML::write (XERCES_CPP_NAMESPACE::DOMElement * dom) const
00034   {
00035 
00036     int size=binULimits.size();
00037     CalibrationXML::writeAttribute(dom,"size",size);
00038     DOMElement * binElement;
00039     for(int bin=0; bin < size; bin ++)
00040     {
00041        binElement = CalibrationXML::addChild(dom,"Bin");
00042        CalibrationXML::writeAttribute(binElement,"value",binValues[bin]);
00043        CalibrationXML::writeAttribute(binElement,"uLimit",binULimits[bin]);
00044     }
00045     CalibrationXML::writeAttribute(dom,"overFlowValue",binValues[size]);
00046 
00047   }
00048