test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Static Public Member Functions
EcalADCToGeVXMLTranslator Class Reference

#include <EcalADCToGeVXMLTranslator.h>

Static Public Member Functions

static std::string dumpXML (const EcalCondHeader &header, const EcalADCToGeVConstant &record)
 
static int readXML (const std::string &filename, EcalCondHeader &header, EcalADCToGeVConstant &record)
 
static int writeXML (const std::string &filename, const EcalCondHeader &header, const EcalADCToGeVConstant &record)
 

Detailed Description

Definition at line 21 of file EcalADCToGeVXMLTranslator.h.

Member Function Documentation

std::string EcalADCToGeVXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalADCToGeVConstant record 
)
static

Definition at line 81 of file EcalADCToGeVXMLTranslator.cc.

References xuti::ADCToGeVConstant_tag(), xuti::Barrel_tag(), hcal_timing_source_file_cfg::dump, xuti::Endcap_tag(), xuti::fromNative(), EcalADCToGeVConstant::getEBValue(), EcalADCToGeVConstant::getEEValue(), pyrootRender::root, AlCaHLTBitMon_QueryRunRegistry::string, xuti::toNative(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cms::concurrency::xercesInitialize().

82  {
83 
85 
86  DOMImplementation* impl =
87  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
88 
89  DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
90  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
91 
92  DOMDocumentType* doctype = impl->createDocumentType(fromNative("XML").c_str(), 0, 0 );
93  DOMDocument * doc =
94  impl->createDocument( 0, fromNative(ADCToGeVConstant_tag).c_str(), doctype );
95 
96 
97  doc->setEncoding(fromNative("UTF-8").c_str() );
98  doc->setStandalone(true);
99  doc->setVersion(fromNative("1.0").c_str() );
100 
101  DOMElement* root = doc->getDocumentElement();
102 
103  xuti::writeHeader(root,header);
104 
107 
108  std::string dump= toNative(writer->writeToString(*root));
109  doc->release();
110 
111  // cms::concurrency::xercesTerminate();
112 
113  return dump;
114 }
void xercesInitialize()
Definition: Xerces.cc:17
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
const std::string ADCToGeVConstant_tag("EcalADCToGeVConstant")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
XercesString fromNative(const char *str)
Definition: XercesString.h:31
const std::string Endcap_tag("EndcapValue")
const std::string Barrel_tag("BarrelValue")
std::string toNative(const XMLCh *str)
Definition: XercesString.h:42
int EcalADCToGeVXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalADCToGeVConstant record 
)
static

Definition at line 23 of file EcalADCToGeVXMLTranslator.cc.

References xuti::Barrel_tag(), gather_cfg::cout, xuti::Endcap_tag(), xuti::getChildNode(), xuti::GetNodeData(), createfilelist::parser, xuti::readHeader(), EcalADCToGeVConstant::setEBValue(), EcalADCToGeVConstant::setEEValue(), cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

Referenced by popcon::EcalADCToGeVHandler::getNewObjects().

25  {
26 
27 
29 
30  XercesDOMParser* parser = new XercesDOMParser;
31  parser->setValidationScheme( XercesDOMParser::Val_Never );
32  parser->setDoNamespaces( false );
33  parser->setDoSchema( false );
34 
35  parser->parse(filename.c_str());
36 
37  DOMDocument* xmlDoc = parser->getDocument();
38  if (!xmlDoc) {
39  std::cout << "EcalADCToGeVXMLTranslator::Error parsing document" << std::endl;
40  return -1;
41  }
42 
43  // Get the top-level element
44  DOMElement* elementRoot = xmlDoc->getDocumentElement();
45 
46  xuti::readHeader(elementRoot, header);
47 
48 
49  DOMNode * barrelnode = xuti::getChildNode(elementRoot,Barrel_tag);
50  DOMNode * endcapnode = xuti::getChildNode(elementRoot,Endcap_tag);
51 
52  double barrelvalue=0;
53  double endcapvalue=0;
54 
55  xuti::GetNodeData(barrelnode,barrelvalue);
56  xuti::GetNodeData(endcapnode,endcapvalue);
57 
58  record.setEBValue(barrelvalue);
59  record.setEEValue(endcapvalue);
60 
61 
62  delete parser;
64  return 0;
65 
66 }
void xercesTerminate()
Definition: Xerces.cc:22
void xercesInitialize()
Definition: Xerces.cc:17
void setEEValue(const float &value)
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
void setEBValue(const float &value)
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
tuple filename
Definition: lut2db_cfg.py:20
const std::string Endcap_tag("EndcapValue")
tuple cout
Definition: gather_cfg.py:145
const std::string Barrel_tag("BarrelValue")
int EcalADCToGeVXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalADCToGeVConstant record 
)
static

Definition at line 72 of file EcalADCToGeVXMLTranslator.cc.

References EcalCondTools::dumpXML(), and GenerateHcalLaserBadRunList::out.

74  {
75  std::fstream fs(filename.c_str(),ios::out);
76  fs<< dumpXML(header,record);
77  return 0;
78 
79 }
static std::string dumpXML(const EcalCondHeader &header, const EcalADCToGeVConstant &record)
tuple filename
Definition: lut2db_cfg.py:20