CMS 3D CMS Logo

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

◆ dumpXML()

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

Definition at line 51 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.cc.

References gather_cfg::cout, hcalRecHitTable_cff::doc, GCP_Ntuples_cfg::dump, RecoTauValidation_cfi::header, AlCaHarvesting_cff::record, AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), cms::xerces::uStr(), xuti::Value_tag(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and convertToRaw::writer.

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();
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)
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)

◆ readXML()

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

Definition at line 21 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.cc.

References gather_cfg::cout, corrVsCorr::filename, RecoTauValidation_cfi::header, 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

◆ writeXML()

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