CMS 3D CMS Logo

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

#include <EcalClusterLocalContCorrXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

static std::string dumpXML (const EcalCondHeader &header, const EcalFunParams &record)
 

Detailed Description

Translates a EcalClusterLocalContCorr record to XML and vice versa

Definition at line 13 of file EcalClusterLocalContCorrXMLTranslator.h.

Member Function Documentation

std::string EcalClusterLocalContCorrXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalFunParams record 
)
staticprivate

Definition at line 50 of file EcalClusterLocalContCorrXMLTranslator.cc.

References remoteMonitoring_LASER_era2018_cfg::dump, EcalFunParams::params(), AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), cms::xerces::uStr(), xuti::Value_tag(), xuti::writeHeader(), and xuti::WriteNodeWithValue().

50  {
51  unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
52 
53  DOMLSSerializer* writer = impl->createLSSerializer();
54  if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
55  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
56 
57  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr);
58 
59  DOMDocument* doc = impl->createDocument(nullptr, cms::xerces::uStr("EcalClusterLocalContCorr").ptr(), doctype);
60 
61  DOMElement* root = doc->getDocumentElement();
62  xuti::writeHeader(root, header);
63 
64  for (auto it : record.params()) {
65  DOMElement* ECEC = root->getOwnerDocument()->createElement(cms::xerces::uStr("ClusterLocal").ptr());
66  root->appendChild(ECEC);
67 
68  WriteNodeWithValue(ECEC, Value_tag, it);
69  }
70 
71  std::string dump = cms::xerces::toString(writer->writeToString(root));
72  doc->release();
73  doctype->release();
74  writer->release();
75 
76  return dump;
77 }
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
const std::string Value_tag("Value")
std::string toString(XMLCh const *toTranscode)
EcalFunctionParameters & params()
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)
tuple dump
OutputFilePath = cms.string(&#39;/tmp/zhokin/&#39;), OutputFileExt = cms.string(&#39;&#39;),.
int EcalClusterLocalContCorrXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalFunParams record 
)
static

Definition at line 20 of file EcalClusterLocalContCorrXMLTranslator.cc.

References gather_cfg::cout, writedatasetfile::parser, xuti::readHeader(), cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

22  {
24 
25  XercesDOMParser* parser = new XercesDOMParser;
26  parser->setValidationScheme(XercesDOMParser::Val_Never);
27  parser->setDoNamespaces(false);
28  parser->setDoSchema(false);
29 
30  parser->parse(filename.c_str());
31 
32  DOMDocument* xmlDoc = parser->getDocument();
33 
34  if (!xmlDoc) {
35  std::cout << "EcalClusterLocalContCorrXMLTranslator::Error parsing document" << std::endl;
36  return -1;
37  }
38 
39  DOMElement* elementRoot = xmlDoc->getDocumentElement();
40 
41  xuti::readHeader(elementRoot, header);
42 
43  // need some extra code here
44 
45  delete parser;
47  return 0;
48 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:144
int EcalClusterLocalContCorrXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalFunParams record 
)
static

Definition at line 79 of file EcalClusterLocalContCorrXMLTranslator.cc.

References EcalCondTools::dumpXML(), compareTotals::fs, submitPVResolutionJobs::out, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

81  {
83 
84  std::fstream fs(filename.c_str(), ios::out);
85  fs << dumpXML(header, record);
86 
88 
89  return 0;
90 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
static std::string dumpXML(const EcalCondHeader &header, const EcalFunParams &record)
tuple filename
Definition: lut2db_cfg.py:20