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>
17 using namespace XERCES_CPP_NAMESPACE;
25 std::cout <<
" DCSTowerStatus should not be filled out from an xml file ..." << std::endl;
28 XercesDOMParser*
parser =
new XercesDOMParser;
29 parser->setValidationScheme( XercesDOMParser::Val_Never );
30 parser->setDoNamespaces(
false );
31 parser->setDoSchema(
false );
33 parser->parse(filename.c_str());
35 DOMDocument* xmlDoc = parser->getDocument();
37 std::cout <<
"EcalDCSTowerStatusXMLTranslator::Error parsing document" << std::endl;
41 DOMElement* elementRoot = xmlDoc->getDocumentElement();
57 cellnode = cellnode->getNextSibling();
59 while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
60 cellnode = cellnode->getNextSibling();
72 std::fstream fs(filename.c_str(),
ios::out);
81 DOMImplementation* impl =
82 DOMImplementationRegistry::getDOMImplementation(
fromNative(
"LS").c_str());
84 DOMWriter* writer =
static_cast<DOMImplementationLS*
>(impl)->createDOMWriter( );
85 writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
87 DOMDocumentType* doctype = impl->createDocumentType(
fromNative(
"XML").c_str(), 0, 0 );
91 doc->setEncoding(
fromNative(
"UTF-8").c_str() );
92 doc->setStandalone(
true);
95 DOMElement*
root = doc->getDocumentElement();
104 if (record.
find(rawid) == record.
end())
continue;
105 DOMElement* cellnode=
writeCell(root,rawid);
118 if (record.
find(rawid) == record.
end())
continue;
119 DOMElement* cellnode=
writeCell(root,rawid);
130 std::ofstream
fout(fn.c_str());
138 if (record.
find(rawid) == record.
end())
continue;
139 int ieta = rawid.
ieta();
140 int line = 17 - ieta;
142 int iphi = rawid.
iphi() - 1;
143 valEB[
line][iphi] = record[rawid].getStatusCode();
146 for(
int iphi = 0; iphi < 72; iphi++)
154 int valEE[2][20][20];
155 for(
int k = 0 ;
k < 2;
k++ )
156 for(
int ix = 0 ; ix < 20; ix++)
157 for(
int iy = 0 ; iy < 20; iy++)
158 valEE[
k][ix][iy] = -1;
164 int ix = rawid.
ix() - 1;
165 int iy = 20 - rawid.
iy();
166 int side = rawid.
zside();
168 if(side == -1) iz = 0;
169 if(ix < 0 || ix > 19)
std::cout <<
" Pb in ix " << ix << std::endl;
170 if(iy < 0 || iy > 19)
std::cout <<
" Pb in iy " << iy << std::endl;
171 valEE[iz][ix][iy] = record[rawid].getStatusCode();
174 for(
int k = 0 ;
k < 2;
k++ ) {
177 fout <<
" Side : " << iz << std::endl;
179 for(
int ix = 0 ; ix < 20; ix++) {
180 if(valEE[
k][ix][
line] < 0)
fout <<
" . ";
181 else fout << setw(2) << valEE[
k][ix][
line] <<
" ";
static int readXML(const std::string &filename, EcalCondHeader &header, EcalDCSTowerStatus &record)
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
const std::string DCSTowerStatus_tag("EcalDCSTowerStatus")
const_iterator end() const
static void plot(std::string, const EcalDCSTowerStatus &record)
static EcalScDetId unhashIndex(int hi)
const Items & endcapItems() const
const_iterator find(uint32_t rawId) const
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
int ieta() const
get the tower ieta
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
const std::string Cell_tag("cell")
const Items & barrelItems() const
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
const std::string DCSStatusCode_tag("DCSStatusCode")
int iphi() const
get the tower iphi
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
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalDCSTowerStatus &record)
static bool validHashIndex(int hi)
XercesString fromNative(const char *str)
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
static std::string dumpXML(const EcalCondHeader &header, const EcalDCSTowerStatus &record)
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
std::string toNative(const XMLCh *str)
string root
initialization