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

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

Definition at line 58 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.cc.

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

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

Definition at line 23 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.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 << "EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::Error parsing document"
42  << std::endl;
43  return -1;
44  }
45 
46  DOMElement* elementRoot = xmlDoc->getDocumentElement();
47 
48  xuti::readHeader(elementRoot, header);
49 
50  // need some extra code here
51 
52  delete parser;
54  return 0;
55 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
int EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalFunParams record 
)
static

Definition at line 110 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.cc.

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

113  {
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)