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
EcalClusterCrackCorrXMLTranslator Class Reference

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

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

Definition at line 20 of file EcalClusterCrackCorrXMLTranslator.h.

Member Function Documentation

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

Definition at line 56 of file EcalClusterCrackCorrXMLTranslator.cc.

References hcal_timing_source_file_cfg::dump, xuti::fromNative(), pileupDistInMC::num, GenerateHcalLaserBadRunList::out, EcalFunParams::params(), pyrootRender::root, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, xuti::toNative(), xuti::Value_tag(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cms::concurrency::xercesInitialize().

58  {
59 
61 
62  DOMImplementation* impl =
63  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
64 
65  DOMWriter* writer =
66  static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
67  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
68 
69  DOMDocumentType* doctype =
70  impl->createDocumentType( fromNative("XML").c_str(), 0, 0 );
71  const std::string EcalClusterCrackCorr_tag("EcalClusterCrackCorr");
72  DOMDocument * doc =
73  impl->createDocument( 0, fromNative(EcalClusterCrackCorr_tag).c_str(), doctype );
74 
75 
76  doc->setEncoding(fromNative("UTF-8").c_str() );
77  doc->setStandalone(true);
78  doc->setVersion(fromNative("1.0").c_str() );
79 
80  DOMElement* root = doc->getDocumentElement();
81  xuti::writeHeader(root, header);
82 
83  const std::string ECCC_tag[4] = {"IPCloseEtaSide", "IPFarEtaSide",
84  "IPClosePhiSide", "IPFarPhiSide"};;
85  int num = 0;
86  for ( EcalFunctionParameters::const_iterator it = record.params().begin(); it != record.params().end(); ++it ) {
87  int side = num /5;
88  int par = num%5;
89  std::string s;
90  std::stringstream out;
91  out << par;
92  s = out.str();
93  std::string sw = ECCC_tag[side] + "_" + s;
94  DOMElement* ECCC =
95  root->getOwnerDocument()->createElement( fromNative(sw).c_str());
96  root->appendChild(ECCC);
97 
98  WriteNodeWithValue(ECCC,Value_tag,*it);
99  num++;
100  }
101 
102  std::string dump= toNative(writer->writeToString(*root));
103  doc->release();
104  return dump;
105 }
void xercesInitialize()
Definition: Xerces.cc:17
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
XercesString fromNative(const char *str)
Definition: XercesString.h:31
std::string toNative(const XMLCh *str)
Definition: XercesString.h:42
int EcalClusterCrackCorrXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalFunParams record 
)
static

Definition at line 22 of file EcalClusterCrackCorrXMLTranslator.cc.

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

25  {
26 
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 << "EcalClusterCrackCorrXMLTranslator::Error parsing document" << std::endl;
41  return -1;
42  }
43 
44  DOMElement* elementRoot = xmlDoc->getDocumentElement();
45 
46  xuti::readHeader(elementRoot, header);
47 
48  // need some extra code here
49 
50  delete parser;
52  return 0;
53 }
void xercesTerminate()
Definition: Xerces.cc:22
void xercesInitialize()
Definition: Xerces.cc:17
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:145
int EcalClusterCrackCorrXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalFunParams record 
)
static

Definition at line 108 of file EcalClusterCrackCorrXMLTranslator.cc.

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

111  {
112 
113  std::fstream fs(filename.c_str(),ios::out);
114  fs<< dumpXML(header,record);
115  return 0;
116 }
tuple filename
Definition: lut2db_cfg.py:20
static std::string dumpXML(const EcalCondHeader &header, const EcalFunParams &record)