4 #include <xercesc/dom/DOMNode.hpp>
5 #include <xercesc/dom/DOM.hpp>
6 #include <xercesc/parsers/XercesDOMParser.hpp>
8 #include <xercesc/util/XMLString.hpp>
9 #include <xercesc/sax/SAXException.hpp>
10 #include <xercesc/framework/LocalFileFormatTarget.hpp>
23 using namespace XERCES_CPP_NAMESPACE;
31 std::cout <<
" TPGTowerStatus should not be filled out from an xml file ..." << std::endl;
34 XercesDOMParser*
parser =
new XercesDOMParser;
35 parser->setValidationScheme( XercesDOMParser::Val_Never );
36 parser->setDoNamespaces(
false );
37 parser->setDoSchema(
false );
39 parser->parse(filename.c_str());
41 DOMDocument* xmlDoc = parser->getDocument();
43 std::cout <<
"EcalTPGTowerStatusXMLTranslator::Error parsing document" << std::endl;
47 DOMElement* elementRoot = xmlDoc->getDocumentElement();
77 std::fstream fs(filename.c_str(),
ios::out);
86 DOMImplementation* impl =
87 DOMImplementationRegistry::getDOMImplementation(
fromNative(
"LS").c_str());
89 DOMWriter* writer =
static_cast<DOMImplementationLS*
>(impl)->createDOMWriter( );
90 writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
92 DOMDocumentType* doctype = impl->createDocumentType(
fromNative(
"XML").c_str(), 0, 0 );
96 doc->setEncoding(
fromNative(
"UTF-8").c_str() );
97 doc->setStandalone(
true);
100 DOMElement*
root = doc->getDocumentElement();
103 std::cout <<
"EcalTPGTowerStatusXMLTranslator::dumpXML" << std::endl;
105 std::cout <<
" tower map size " << towerMap.size() << std::endl;
107 for(it = towerMap.begin(); it != towerMap.end(); ++it) {
108 if((*it).second > 0) {
110 std::cout <<
" TTDetId " << ttId <<
" eta " << ttId.
ieta() <<
" phi " << ttId.
iphi() << std::endl;
111 uint32_t rawid =
ttId;
112 DOMElement* cellnode=
writeCell(root,rawid);
123 std::ofstream
fout(fn.c_str());
126 for(
int iphi = 0; iphi < 72; iphi++)
127 valEB[
line][iphi] = 0;
130 std::cout <<
" tower map size " << towerMap.size() << std::endl;
132 for(it = towerMap.begin(); it != towerMap.end(); ++it) {
133 if((*it).second > 0) {
135 int ieta = ttId.
ieta();
136 int line = 17 - ieta;
138 int iphi = ttId.
iphi() - 1;
139 valEB[
line][iphi] = (*it).second;
143 for(
int iphi = 0; iphi < 72; iphi++)
std::map< uint32_t, uint16_t >::const_iterator EcalTPGTowerStatusMapIterator
std::map< uint32_t, uint16_t > EcalTPGTowerStatusMap
unsigned ttId(DetId const &)
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
int ieta() const
get the tower ieta
const std::string TPGTowerStatus_tag("EcalTPGTowerStatus")
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
static std::string dumpXML(const EcalCondHeader &header, const EcalTPGTowerStatus &record)
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
int iphi() const
get the tower iphi
const std::map< uint32_t, uint16_t > & getMap() const
XercesString fromNative(const char *str)
static void plot(std::string, const EcalTPGTowerStatus &record)
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
static int readXML(const std::string &filename, EcalCondHeader &header, EcalTPGTowerStatus &record)
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalTPGTowerStatus &record)
std::string toNative(const XMLCh *str)