#include <EcalLaserAPDPNRatiosXMLTranslator.h>
Static Public Member Functions | |
static std::string | dumpXML (const EcalCondHeader &header, const EcalLaserAPDPNRatios &record) |
static int | readXML (const std::string &filename, EcalCondHeader &header, EcalLaserAPDPNRatios &record) |
static int | writeXML (const std::string &filename, const EcalCondHeader &header, const EcalLaserAPDPNRatios &record) |
Definition at line 31 of file EcalLaserAPDPNRatiosXMLTranslator.h.
std::string EcalLaserAPDPNRatiosXMLTranslator::dumpXML | ( | const EcalCondHeader & | header, |
const EcalLaserAPDPNRatios & | record | ||
) | [static] |
Definition at line 123 of file EcalLaserAPDPNRatiosXMLTranslator.cc.
References asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::fromNative(), EcalLaserAPDPNRatios::getLaserMap(), EcalLaserAPDPNRatios::getTimeMap(), i, EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, xuti::Laser_p1_tag(), xuti::Laser_p2_tag(), xuti::Laser_p3_tag(), xuti::Laser_tag(), EBDetId::MIN_HASH, p1, p2, p3, dbtoconf::root, AlCaHLTBitMon_QueryRunRegistry::string, lumiQTWidget::t, xuti::toNative(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), EEDetId::validHashIndex(), xuti::writeCell(), xuti::writeHeader(), and xuti::WriteNodeWithValue().
{ XMLPlatformUtils::Initialize(); DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str()); DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( ); writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true); DOMDocumentType* doctype = impl->createDocumentType( fromNative("XML").c_str(), 0, 0 ); DOMDocument * doc = impl->createDocument( 0, fromNative(Laser_tag).c_str(), doctype ); doc->setEncoding(fromNative("UTF-8").c_str() ); doc->setStandalone(true); doc->setVersion(fromNative("1.0").c_str() ); DOMElement* root = doc->getDocumentElement(); xuti::writeHeader(root,header); string Lasertag = "Laser", LMtag = "LM"; for(int cellid = 0; cellid < (int)record.getTimeMap().size(); cellid++) { DOMElement* cellnode = doc->createElement( fromNative(Lasertag).c_str()); root->appendChild(cellnode); stringstream value_s; value_s << cellid; cellnode->setAttribute(fromNative(LMtag).c_str(), fromNative(value_s.str()).c_str()); long int t123[3]; t123[0]=(record.getTimeMap())[cellid].t1.value(); t123[1]=(record.getTimeMap())[cellid].t2.value(); t123[2]=(record.getTimeMap())[cellid].t3.value(); string Laser_t_tag[3] = {"t1","t2","t3"}; for(int i = 0; i < 3; i++) { time_t t = t123[i] >> 32; char buf[256]; struct tm lt; localtime_r(&t, <); strftime(buf, sizeof(buf), "%F %R:%S", <); buf[sizeof(buf)-1] = 0; DOMDocument* subdoc = cellnode->getOwnerDocument(); DOMElement* new_node = subdoc->createElement(fromNative(Laser_t_tag[i]).c_str()); cellnode->appendChild(new_node); std::stringstream value_ss; value_ss << t123[i]; string newstr = value_ss.str() + " [" + string(buf) +"]"; DOMText* tvalue = subdoc->createTextNode(fromNative(newstr).c_str()); new_node->appendChild(tvalue); } } for(int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) { uint32_t rawid = EBDetId::unhashIndex(cellid); DOMElement* cellnode= writeCell(root,rawid); float p1=(record.getLaserMap())[rawid].p1; float p2=(record.getLaserMap())[rawid].p2; float p3=(record.getLaserMap())[rawid].p3; WriteNodeWithValue(cellnode,Laser_p1_tag,p1); WriteNodeWithValue(cellnode,Laser_p2_tag,p2); WriteNodeWithValue(cellnode,Laser_p3_tag,p3); } for(int cellid = 0; cellid < EEDetId::kSizeForDenseIndexing; ++cellid) { if(!EEDetId::validHashIndex(cellid)) continue; uint32_t rawid = EEDetId::unhashIndex(cellid); DOMElement* cellnode=writeCell(root,rawid); float p1=(record.getLaserMap())[rawid].p1; float p2=(record.getLaserMap())[rawid].p2; float p3=(record.getLaserMap())[rawid].p3; WriteNodeWithValue(cellnode,Laser_p1_tag,p1); WriteNodeWithValue(cellnode,Laser_p2_tag,p2); WriteNodeWithValue(cellnode,Laser_p3_tag,p3); } std::string dump= toNative(writer->writeToString(*root)); doc->release(); // XMLPlatformUtils::Terminate(); return dump; }
int EcalLaserAPDPNRatiosXMLTranslator::readXML | ( | const std::string & | filename, |
EcalCondHeader & | header, | ||
EcalLaserAPDPNRatios & | record | ||
) | [static] |
Definition at line 30 of file EcalLaserAPDPNRatiosXMLTranslator.cc.
References xuti::Cell_tag(), gather_cfg::cout, cond::rpcobgas::detid, xuti::getChildNode(), xuti::GetNodeData(), xuti::Laser_p1_tag(), xuti::Laser_p2_tag(), xuti::Laser_p3_tag(), EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p1, p1, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p2, p2, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p3, p3, geometryXMLtoCSV::parser, xuti::readCellId(), xuti::readHeader(), and EcalLaserAPDPNRatios::setValue().
{ XMLPlatformUtils::Initialize(); XercesDOMParser* parser = new XercesDOMParser; parser->setValidationScheme( XercesDOMParser::Val_Never ); parser->setDoNamespaces( false ); parser->setDoSchema( false ); parser->parse(filename.c_str()); DOMDocument* xmlDoc = parser->getDocument(); if (!xmlDoc) { std::cout << "EcalLaserAPDPNRatiosXMLTranslator::Error parsing document" << std::endl; return -1; } DOMElement* elementRoot = xmlDoc->getDocumentElement(); xuti::readHeader(elementRoot,header); DOMNode * cellnode = getChildNode(elementRoot,Cell_tag); while(cellnode) { float p1 = 0; float p2 = 0; float p3 = 0; // edm::TimeStamp t1=0; // edm::TimeStamp t2=0; // edm::TimeStamp t3=0; DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode)); DOMNode* p1_node = getChildNode(cellnode,Laser_p1_tag); GetNodeData(p1_node,p1); DOMNode* p2_node = getChildNode(cellnode,Laser_p2_tag); GetNodeData(p2_node,p2); DOMNode* p3_node = getChildNode(cellnode,Laser_p3_tag); GetNodeData(p3_node,p3); // DOMNode* t1_node = getChildNode(cellnode,Laser_t1_tag); // GetNodeData(t1_node,t1); // DOMNode* t2_node = getChildNode(cellnode,Laser_t2_tag); // GetNodeData(t3_node,t2); // DOMNode* p1_node = getChildNode(cellnode,Laser_t3_tag); // GetNodeData(t3_node,t3); EcalLaserAPDPNRatios::EcalLaserAPDPNpair pair; pair.p1 =p1; pair.p2 =p2; pair.p3 =p3; record.setValue(detid,pair); cellnode = cellnode->getNextSibling(); while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE) cellnode = cellnode->getNextSibling(); } delete parser; XMLPlatformUtils::Terminate(); return 0; }
int EcalLaserAPDPNRatiosXMLTranslator::writeXML | ( | const std::string & | filename, |
const EcalCondHeader & | header, | ||
const EcalLaserAPDPNRatios & | record | ||
) | [static] |
Definition at line 114 of file EcalLaserAPDPNRatiosXMLTranslator.cc.
References EcalCondTools::dumpXML(), and dbtoconf::out.