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.

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 }

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

◆ readXML()

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

Definition at line 21 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.cc.

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 }

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

◆ writeXML()

int EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalFunParams record 
)
static
submitPVValidationJobs.dump
dump
Definition: submitPVValidationJobs.py:55
EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::dumpXML
static std::string dumpXML(const EcalCondHeader &header, const EcalFunParams &record)
Definition: EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.cc:51
xuti::writeHeader
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
Definition: DOMHelperFunctions.cc:151
boostedTaus_cff.doc
doc
Definition: boostedTaus_cff.py:20
gather_cfg.cout
cout
Definition: gather_cfg.py:144
writedatasetfile.parser
parser
Definition: writedatasetfile.py:7
cscNeutronWriter_cfi.writer
writer
Definition: cscNeutronWriter_cfi.py:6
cms::xerces::toString
std::string toString(XMLCh const *toTranscode)
Definition: XercesStrUtils.h:35
xuti::WriteNodeWithValue
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
Definition: DOMHelperFunctions.h:46
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
cms::concurrency::xercesTerminate
void xercesTerminate()
Definition: Xerces.cc:23
root
Definition: RooFitFunction.h:10
cms::xerces::uStr
ZStr< XMLCh > uStr(char const *str)
Definition: XercesStrUtils.h:31
AlCaHarvesting_cff.record
record
Definition: AlCaHarvesting_cff.py:42
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
impl
Definition: trackAlgoPriorityOrder.h:18
xuti::Value_tag
const std::string Value_tag("Value")
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:291
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
cms::concurrency::xercesInitialize
void xercesInitialize()
Definition: Xerces.cc:18
xuti::readHeader
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
Definition: DOMHelperFunctions.cc:164