CMS 3D CMS Logo

List of all members | Static Public Member Functions | Static Private Member Functions
EcalClusterEnergyCorrectionXMLTranslator Class Reference

#include <EcalClusterEnergyCorrectionXMLTranslator.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 EcalClusterEnergyCorrection record to XML and vice versa

Author
Version
Id
EcalClusterEnergyCorrectionXMLTranslator.h,v 1.0
Date
October 2011

Definition at line 17 of file EcalClusterEnergyCorrectionXMLTranslator.h.

Member Function Documentation

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

Definition at line 55 of file EcalClusterEnergyCorrectionXMLTranslator.cc.

References common_cff::doc, FrontierConditions_GlobalTag_cff::dump, EcalFunParams::params(), AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), cms::xerces::uStr(), xuti::Value_tag(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cscNeutronWriter_cfi::writer.

56  {
57 
58  unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation( cms::xerces::uStr("LS").ptr()));
59 
60  DOMLSSerializer* writer = impl->createLSSerializer();
61  if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
62  writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );
63 
64  DOMDocumentType* doctype =
65  impl->createDocumentType( cms::xerces::uStr("XML").ptr(), nullptr, nullptr );
66 
67  DOMDocument* doc =
68  impl->createDocument( nullptr, cms::xerces::uStr("EcalClusterEnergyCorrection").ptr(), doctype );
69 
70  DOMElement* root = doc->getDocumentElement();
71  xuti::writeHeader(root, header);
72 
73  for( auto it : record.params()) {
74  DOMElement* ECEC =
75  root->getOwnerDocument()->createElement( cms::xerces::uStr("ClusterEnergy").ptr());
76  root->appendChild(ECEC);
77 
79  }
80 
81  std::string dump = cms::xerces::toString(writer->writeToString( root ));
82  doc->release();
83  doctype->release();
84  writer->release();
85 
86  return dump;
87 }
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)
Definition: dump.py:1
int EcalClusterEnergyCorrectionXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalFunParams record 
)
static

Definition at line 21 of file EcalClusterEnergyCorrectionXMLTranslator.cc.

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

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

Definition at line 90 of file EcalClusterEnergyCorrectionXMLTranslator.cc.

References EcalCondTools::dumpXML(), MillePedeFileConverter_cfg::out, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

93  {
94 
96 
97  std::fstream fs(filename.c_str(),ios::out);
98  fs<< dumpXML(header,record);
99 
101 
102  return 0;
103 }
static std::string dumpXML(const EcalCondHeader &header, const EcalFunParams &record)
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18