CMS 3D CMS Logo

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

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

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

Definition at line 16 of file EcalClusterCrackCorrXMLTranslator.h.

Member Function Documentation

◆ dumpXML()

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

Definition at line 49 of file EcalClusterCrackCorrXMLTranslator.cc.

References hcalRecHitTable_cff::doc, GCP_Ntuples_cfg::dump, RecoTauValidation_cfi::header, EgammaValidation_cff::num, MillePedeFileConverter_cfg::out, AlCaHarvesting_cff::record, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), cms::xerces::uStr(), xuti::Value_tag(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and convertToRaw::writer.

49  {
50  unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
51 
52  DOMLSSerializer* writer = impl->createLSSerializer();
53  if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
54  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
55 
56  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr);
57  const std::string EcalClusterCrackCorr_tag("EcalClusterCrackCorr");
58  DOMDocument* doc = impl->createDocument(nullptr, cms::xerces::uStr(EcalClusterCrackCorr_tag.c_str()).ptr(), doctype);
59 
60  DOMElement* root = doc->getDocumentElement();
62 
63  const std::string ECCC_tag[4] = {"IPCloseEtaSide", "IPFarEtaSide", "IPClosePhiSide", "IPFarPhiSide"};
64  ;
65  int num = 0;
66  for (EcalFunctionParameters::const_iterator it = record.params().begin(); it != record.params().end(); ++it) {
67  int side = num / 5;
68  int par = num % 5;
69  std::string s;
70  std::stringstream out;
71  out << par;
72  s = out.str();
73  std::string sw = ECCC_tag[side] + "_" + s;
74  DOMElement* ECCC = root->getOwnerDocument()->createElement(cms::xerces::uStr(sw.c_str()).ptr());
75  root->appendChild(ECCC);
76 
77  WriteNodeWithValue(ECCC, Value_tag, *it);
78  num++;
79  }
80 
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)
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)

◆ readXML()

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

Definition at line 21 of file EcalClusterCrackCorrXMLTranslator.cc.

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

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

◆ writeXML()

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