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;
24 std::cout <<
" DAQTowerStatus should not be filled out from an xml file ..." << std::endl;
25 XMLPlatformUtils::Initialize();
27 XercesDOMParser*
parser =
new XercesDOMParser;
28 parser->setValidationScheme( XercesDOMParser::Val_Never );
29 parser->setDoNamespaces(
false );
30 parser->setDoSchema(
false );
32 parser->parse(filename.c_str());
34 DOMDocument* xmlDoc = parser->getDocument();
36 std::cout <<
"EcalDAQTowerStatusXMLTranslator::Error parsing document" << std::endl;
40 DOMElement* elementRoot = xmlDoc->getDocumentElement();
56 cellnode = cellnode->getNextSibling();
58 while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
59 cellnode = cellnode->getNextSibling();
64 XMLPlatformUtils::Terminate();
71 std::fstream fs(filename.c_str(),
ios::out);
79 XMLPlatformUtils::Initialize();
80 DOMImplementation* impl =
81 DOMImplementationRegistry::getDOMImplementation(
fromNative(
"LS").c_str());
83 DOMWriter* writer =
static_cast<DOMImplementationLS*
>(impl)->createDOMWriter( );
84 writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
86 DOMDocumentType* doctype = impl->createDocumentType(
fromNative(
"XML").c_str(), 0, 0 );
90 doc->setEncoding(
fromNative(
"UTF-8").c_str() );
91 doc->setStandalone(
true);
94 DOMElement*
root = doc->getDocumentElement();
98 if (!record.
barrelItems().size())
return std::string();
103 if (record.
find(rawid) == record.
end())
continue;
104 DOMElement* cellnode=
writeCell(root,rawid);
110 if (!record.
endcapItems().size())
return std::string();
117 if (record.
find(rawid) == record.
end())
continue;
118 DOMElement* cellnode=
writeCell(root,rawid);
123 std::string
dump =
toNative(writer->writeToString(*root));
129 std::ofstream
fout(fn.c_str());
137 if (record.
find(rawid) == record.
end())
continue;
138 int ieta = rawid.
ieta();
139 int line = 17 - ieta;
141 int iphi = rawid.
iphi() - 1;
142 valEB[
line][iphi] = record[rawid].getStatusCode();
145 for(
int iphi = 0; iphi < 72; iphi++)
153 int valEE[2][20][20];
154 for(
int k = 0 ;
k < 2;
k++ )
155 for(
int ix = 0 ; ix < 20; ix++)
156 for(
int iy = 0 ; iy < 20; iy++)
157 valEE[
k][ix][iy] = -1;
163 int ix = rawid.
ix() - 1;
164 int iy = 20 - rawid.
iy();
165 int side = rawid.
zside();
167 if(side == -1) iz = 0;
168 if(ix < 0 || ix > 19)
std::cout <<
" Pb in ix " << ix << std::endl;
169 if(iy < 0 || iy > 19)
std::cout <<
" Pb in iy " << iy << std::endl;
170 valEE[iz][ix][iy] = record[rawid].getStatusCode();
173 for(
int k = 0 ;
k < 2;
k++ ) {
176 fout <<
" Side : " << iz << std::endl;
178 for(
int ix = 0 ; ix < 20; ix++) {
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
const_iterator end() const
const std::string DAQTowerStatus_tag("EcalDAQTowerStatus")
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
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalDAQTowerStatus &record)
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 DAQStatusCode_tag("DAQStatusCode")
int iphi() const
get the tower iphi
static int readXML(const std::string &filename, EcalCondHeader &header, EcalDAQTowerStatus &record)
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 void plot(std::string, const EcalDAQTowerStatus &record)
static bool validHashIndex(int hi)
static std::string dumpXML(const EcalCondHeader &header, const EcalDAQTowerStatus &record)
XercesString fromNative(const char *str)
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
std::string toNative(const XMLCh *str)
string root
initialization