CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Static Public Member Functions
EcalClusterEnergyCorrectionObjectSpecificXMLTranslator Class Reference

#include <EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.h>

Static Public Member Functions

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

Detailed Description

Translates a EcalClusterEnergyCorrection record to XML and vice versa

Author
Version
Id:
EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.h,v 1.1 2011/11/10 17:52:22 fay Exp
Date
November 2011

Definition at line 21 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.h.

Member Function Documentation

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

Definition at line 57 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.cc.

References gather_cfg::cout, asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::fromNative(), EcalFunParams::params(), dbtoconf::root, xuti::toNative(), xuti::Value_tag(), xuti::writeHeader(), and xuti::WriteNodeWithValue().

Referenced by cond::PayLoadInspector< DataT >::dump().

59  {
60 
61  XMLPlatformUtils::Initialize();
62 
63  DOMImplementation* impl =
64  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
65 
66  DOMWriter* writer =
67  static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
68  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
69 
70  DOMDocumentType* doctype =
71  impl->createDocumentType( fromNative("XML").c_str(), 0, 0 );
72  const std::string ECECOS_tag("EcalClusterEnergyCorrectionObjectSpecific");
73  DOMDocument * doc =
74  impl->createDocument( 0, fromNative(ECECOS_tag).c_str(), doctype );
75 
76 
77  doc->setEncoding(fromNative("UTF-8").c_str() );
78  doc->setStandalone(true);
79  doc->setVersion(fromNative("1.0").c_str() );
80 
81 
82  DOMElement* root = doc->getDocumentElement();
83  xuti::writeHeader(root, header);
84 
85  const std::string ECEC_tag[9] = {"fEta","fBremEtaElectrons","fBremEtaPhotons",
86  "fEtElectronsEB","fEtElectronsEE","fEtPhotonsEB","fEtPhotonsEE",
87  "fEnergyElectronsEE","fEnergyPhotonsEE"};
88  int tit = 0;
89  int par = 0;
90  for ( EcalFunctionParameters::const_iterator it = record.params().begin(); it != record.params().end(); ++it ) {
91  if(par < 2) tit = 0;
92  else if(par < 86) tit = 1;
93  else if(par < 170) tit = 2;
94  else if(par < 177) tit = 3;
95  else if(par < 184) tit = 4;
96  else if(par < 191) tit = 5;
97  else if(par < 198) tit = 6;
98  else if(par < 203) tit = 7;
99  else tit = 8;
100  DOMElement* ECEC =
101  root->getOwnerDocument()->createElement( fromNative(ECEC_tag[tit]).c_str());
102  root->appendChild(ECEC);
103 
104  WriteNodeWithValue(ECEC,Value_tag,*it);
105  par++;
106  }
107  std::cout << "\n";
108 
109  std::string dump= toNative(writer->writeToString(*root));
110  doc->release();
111  return dump;
112 }
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
const std::string Value_tag("Value")
EcalFunctionParameters & params()
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
tuple doc
Definition: asciidump.py:381
XercesString fromNative(const char *str)
Definition: XercesString.h:31
tuple cout
Definition: gather_cfg.py:121
std::string toNative(const XMLCh *str)
Definition: XercesString.h:42
string root
initialization
Definition: dbtoconf.py:70
int EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalFunParams record 
)
static

Definition at line 22 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.cc.

References gather_cfg::cout, geometryXMLtoCSV::parser, and xuti::readHeader().

25  {
26 
27  XMLPlatformUtils::Initialize();
28 
29  XercesDOMParser* parser = new XercesDOMParser;
30  parser->setValidationScheme( XercesDOMParser::Val_Never );
31  parser->setDoNamespaces( false );
32  parser->setDoSchema( false );
33 
34  parser->parse(filename.c_str());
35 
36  DOMDocument* xmlDoc = parser->getDocument();
37 
38 
39  if (!xmlDoc) {
40  std::cout << "EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::Error parsing document"
41  << 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;
52  XMLPlatformUtils::Terminate();
53  return 0;
54 }
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
int EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalFunParams record 
)
static

Definition at line 115 of file EcalClusterEnergyCorrectionObjectSpecificXMLTranslator.cc.

References EcalCondTools::dumpXML(), and dbtoconf::out.

118  {
119 
120  std::fstream fs(filename.c_str(),ios::out);
121  fs<< dumpXML(header,record);
122  return 0;
123 }
static std::string dumpXML(const EcalCondHeader &header, const EcalFunParams &record)
tuple out
Definition: dbtoconf.py:99
tuple filename
Definition: lut2db_cfg.py:20