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
EcalClusterEnergyCorrectionObjectSpecificXMLTranslator Class Reference

#include <EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.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:
EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.h,v 1.0
Date
November 2011

Definition at line 17 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.h.

Member Function Documentation

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

Definition at line 51 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.cc.

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

52  {
53  unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
54 
55  DOMLSSerializer* writer = impl->createLSSerializer();
56  if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
57  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
58 
59  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr);
60  const std::string ECECOS_tag("EcalClusterEnergyCorrectionObjectSpecific");
61  DOMDocument* doc = impl->createDocument(nullptr, cms::xerces::uStr(ECECOS_tag.c_str()).ptr(), doctype);
62 
63  DOMElement* root = doc->getDocumentElement();
64  xuti::writeHeader(root, header);
65 
66  const std::string ECEC_tag[9] = {"fEta",
67  "fBremEtaElectrons",
68  "fBremEtaPhotons",
69  "fEtElectronsEB",
70  "fEtElectronsEE",
71  "fEtPhotonsEB",
72  "fEtPhotonsEE",
73  "fEnergyElectronsEE",
74  "fEnergyPhotonsEE"};
75  int tit = 0;
76  int par = 0;
77  for (EcalFunctionParameters::const_iterator it = record.params().begin(); it != record.params().end(); ++it) {
78  if (par < 2)
79  tit = 0;
80  else if (par < 86)
81  tit = 1;
82  else if (par < 170)
83  tit = 2;
84  else if (par < 177)
85  tit = 3;
86  else if (par < 184)
87  tit = 4;
88  else if (par < 191)
89  tit = 5;
90  else if (par < 198)
91  tit = 6;
92  else if (par < 203)
93  tit = 7;
94  else
95  tit = 8;
96  DOMElement* ECEC = root->getOwnerDocument()->createElement(cms::xerces::uStr(ECEC_tag[tit].c_str()).ptr());
97  root->appendChild(ECEC);
98 
99  WriteNodeWithValue(ECEC, Value_tag, *it);
100  par++;
101  }
102  std::cout << "\n";
103 
104  std::string dump = cms::xerces::toString(writer->writeToString(root));
105  doc->release();
106  doctype->release();
107  writer->release();
108 
109  return dump;
110 }
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 cout
Definition: gather_cfg.py:144
tuple dump
OutputFilePath = cms.string(&#39;/tmp/zhokin/&#39;), OutputFileExt = cms.string(&#39;&#39;),.
int EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalFunParams record 
)
static

Definition at line 21 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.cc.

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

23  {
25 
26  XercesDOMParser* parser = new XercesDOMParser;
27  parser->setValidationScheme(XercesDOMParser::Val_Never);
28  parser->setDoNamespaces(false);
29  parser->setDoSchema(false);
30 
31  parser->parse(filename.c_str());
32 
33  DOMDocument* xmlDoc = parser->getDocument();
34 
35  if (!xmlDoc) {
36  std::cout << "EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::Error parsing document" << std::endl;
37  return -1;
38  }
39 
40  DOMElement* elementRoot = xmlDoc->getDocumentElement();
41 
42  xuti::readHeader(elementRoot, header);
43 
44  // need some extra code here
45 
46  delete parser;
48  return 0;
49 }
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 EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalFunParams record 
)
static

Definition at line 112 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.cc.

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

114  {
116 
117  std::fstream fs(filename.c_str(), ios::out);
118  fs << dumpXML(header, record);
119 
121 
122  return 0;
123 }
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