5 #include <xercesc/dom/DOMNode.hpp>
6 #include <xercesc/dom/DOM.hpp>
7 #include <xercesc/parsers/XercesDOMParser.hpp>
9 #include <xercesc/util/XMLString.hpp>
10 #include <xercesc/sax/SAXException.hpp>
11 #include <xercesc/framework/LocalFileFormatTarget.hpp>
20 using namespace XERCES_CPP_NAMESPACE;
30 XercesDOMParser*
parser =
new XercesDOMParser;
31 parser->setValidationScheme( XercesDOMParser::Val_Never );
32 parser->setDoNamespaces(
false );
33 parser->setDoSchema(
false );
35 parser->parse(filename.c_str());
37 DOMDocument* xmlDoc = parser->getDocument();
39 std::cout <<
"EcalPulseSymmCovariancesXMLTranslator::Error parsing document" << std::endl;
43 DOMElement* elementRoot = xmlDoc->getDocumentElement();
61 if(
j >=
i) k =
j + (EcalPulseShape::TEMPLATESAMPLES-1)*
i;
62 else k =
i + (EcalPulseShape::TEMPLATESAMPLES-1)*
j;
63 pulsecov_tag[
k] = Form(
"samplecov_%d_%d",
i,
j);
67 DOMNode** covs_node =
new DOMNode*[int(EcalPulseShape::TEMPLATESAMPLES*(EcalPulseShape::TEMPLATESAMPLES+1)/2)];
68 for(
int k=0;
k<EcalPulseShape::TEMPLATESAMPLES*(EcalPulseShape::TEMPLATESAMPLES+1)/2; ++
k) {
73 for(
int k=0;
k<EcalPulseShape::TEMPLATESAMPLES*(EcalPulseShape::TEMPLATESAMPLES+1)/2; ++
k) record[detid].covval[
k] = covs[
k];
75 cellnode = cellnode->getNextSibling();
77 while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
78 cellnode = cellnode->getNextSibling();
84 std::cout <<
" nb of channels found in xml file " << chan << std::endl;
91 std::fstream fs(filename.c_str(),
ios::out);
100 DOMImplementation* impl =
101 DOMImplementationRegistry::getDOMImplementation(
fromNative(
"LS").c_str());
103 DOMWriter* writer =
static_cast<DOMImplementationLS*
>(impl)->createDOMWriter( );
104 writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
106 DOMDocumentType* doctype = impl->createDocumentType(
fromNative(
"XML").c_str(), 0, 0 );
110 doc->setEncoding(
fromNative(
"UTF-8").c_str() );
111 doc->setStandalone(
true);
114 DOMElement*
root = doc->getDocumentElement();
123 pulsecov_tag[linK] = Form(
"samplecov_%d_%d",i,j);
133 if (record.
find(rawid) == record.
end())
continue;
135 DOMElement* cellnode=
writeCell(root,rawid);
150 if (record.
find(rawid) == record.
end())
continue;
152 DOMElement* cellnode=
writeCell(root,rawid);
const Items & barrelItems() const
static const int TEMPLATESAMPLES
static EEDetId unhashIndex(int hi)
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
static bool validHashIndex(int i)
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalPulseSymmCovariances &record)
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
static const int MIN_HASH
const std::string Cell_tag("cell")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
void GetNodeData(xercesc::DOMNode *node, T &value)
get the node data
xercesc::DOMNode * getChildNode(xercesc::DOMNode *node, const std::string &nodename)
get the child of
const std::string PulseSymmCovariances_tag("EcalPulseSymmCovariances")
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
const_iterator find(uint32_t rawId) const
XercesString fromNative(const char *str)
static int readXML(const std::string &filename, EcalCondHeader &header, EcalPulseSymmCovariances &record)
const_iterator end() const
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
const Items & endcapItems() const
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
std::string toNative(const XMLCh *str)
Power< A, B >::type pow(const A &a, const B &b)
static std::string dumpXML(const EcalCondHeader &header, const EcalPulseSymmCovariances &record)