4 #include <xercesc/dom/DOMNode.hpp>
5 #include <xercesc/dom/DOM.hpp>
6 #include <xercesc/parsers/XercesDOMParser.hpp>
7 #include <xercesc/util/PlatformUtils.hpp>
8 #include <xercesc/util/XMLString.hpp>
9 #include <xercesc/sax/SAXException.hpp>
10 #include <xercesc/framework/LocalFileFormatTarget.hpp>
16 using namespace XERCES_CPP_NAMESPACE;
23 fstream fs(filename.c_str(),
ios::out);
31 XMLPlatformUtils::Initialize();
33 DOMImplementation* impl =
34 DOMImplementationRegistry::getDOMImplementation(
fromNative(
"LS").c_str());
36 DOMWriter* writer =
static_cast<DOMImplementationLS*
>(impl)->createDOMWriter( );
37 writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
39 DOMDocumentType* doctype = impl->createDocumentType(
fromNative(
"XML").c_str(), 0, 0 );
44 doc->setEncoding(
fromNative(
"UTF-8").c_str() );
45 doc->setStandalone(
true);
48 DOMElement*
root = doc->getDocumentElement();
52 for ( vector<AlignTransform>::const_iterator it = record.
m_align.begin();
53 it != record.
m_align.end(); it++ ) {
54 int Id = (*it).rawId();
55 int sub = (Id>>24)&0xF;
62 int side = (Id>>16)&1;
71 if(SM < 10) subdet <<
"0" << SM;
79 int side = (Id>>14)&1;
87 if(x == 20) subdet <<
"F";
88 else if(x == 70) subdet <<
"N";
89 else cout <<
" strange value for x " << x << endl;
96 int plane = (Id>>18)&1;
97 int side = (Id>>19)&1;
98 if(side == 0) subdet <<
"-";
100 if(plane) subdet <<
"F";
102 if(x/30) subdet <<
"F";
105 else cout <<
" problem sub = " << sub << endl;
106 cout << (*it).rawId()
107 <<
" " << (*it).rotation().getPhi()
108 <<
" " << (*it).rotation().getTheta()
109 <<
" " << (*it).rotation().getPsi()
110 <<
" " << (*it).translation().x()
111 <<
" " << (*it).translation().y()
112 <<
" " << (*it).translation().z()
114 uint32_t rawid = (*it).rawId();
115 DOMElement* cellnode =
117 root->appendChild(cellnode);
const std::string Phi_tag("Phi")
const std::string x_tag("x")
const std::string id_tag("id")
std::vector< AlignTransform > m_align
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
static std::string dumpXML(const EcalCondHeader &header, const Alignments &record)
static int writeXML(const std::string &filename, const EcalCondHeader &header, const Alignments &record)
const std::string y_tag("y")
const std::string Cell_tag("cell")
const std::string subdet_tag("SubDet")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
const std::string z_tag("z")
const std::string Psi_tag("Psi")
XercesString fromNative(const char *str)
const std::string Theta_tag("Theta")
std::string toNative(const XMLCh *str)
const std::string AlignmentConstant_tag("EcalAlignmentConstant")
string root
initialization