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

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

Definition at line 57 of file EcalClusterCrackCorrXMLTranslator.cc.

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

59  {
60 
61  unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation( cms::xerces::uStr("LS").ptr()));
62 
63  DOMLSSerializer* writer = impl->createLSSerializer();
64  if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
65  writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );
66 
67  DOMDocumentType* doctype =
68  impl->createDocumentType( cms::xerces::uStr("XML").ptr(), nullptr, nullptr );
69  const std::string EcalClusterCrackCorr_tag("EcalClusterCrackCorr");
70  DOMDocument * doc =
71  impl->createDocument( nullptr, cms::xerces::uStr(EcalClusterCrackCorr_tag.c_str()).ptr(), doctype );
72 
73  DOMElement* root = doc->getDocumentElement();
74  xuti::writeHeader(root, header);
75 
76  const std::string ECCC_tag[4] = {"IPCloseEtaSide", "IPFarEtaSide",
77  "IPClosePhiSide", "IPFarPhiSide"};;
78  int num = 0;
79  for ( EcalFunctionParameters::const_iterator it = record.params().begin(); it != record.params().end(); ++it ) {
80  int side = num /5;
81  int par = num%5;
82  std::string s;
83  std::stringstream out;
84  out << par;
85  s = out.str();
86  std::string sw = ECCC_tag[side] + "_" + s;
87  DOMElement* ECCC =
88  root->getOwnerDocument()->createElement( cms::xerces::uStr(sw.c_str()).ptr());
89  root->appendChild(ECCC);
90 
91  WriteNodeWithValue(ECCC,Value_tag,*it);
92  num++;
93  }
94 
95  std::string dump = cms::xerces::toString(writer->writeToString( root ));
96  doc->release();
97  doctype->release();
98  writer->release();
99 
100  return dump;
101 }
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 EcalClusterCrackCorrXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalFunParams record 
)
static

Definition at line 23 of file EcalClusterCrackCorrXMLTranslator.cc.

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

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

Definition at line 104 of file EcalClusterCrackCorrXMLTranslator.cc.

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

107  {
108 
110 
111  std::fstream fs(filename.c_str(),ios::out);
112  fs<< dumpXML(header,record);
113 
115 
116  return 0;
117 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
static std::string dumpXML(const EcalCondHeader &header, const EcalFunParams &record)