CMS 3D CMS Logo

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

#include <EcalTimeBiasCorrectionsXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

static std::string dumpXML (const EcalCondHeader &header, const EcalTimeBiasCorrections &record)
 

Detailed Description

Definition at line 13 of file EcalTimeBiasCorrectionsXMLTranslator.h.

Member Function Documentation

std::string EcalTimeBiasCorrectionsXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalTimeBiasCorrections record 
)
staticprivate

Definition at line 63 of file EcalTimeBiasCorrectionsXMLTranslator.cc.

References common_cff::doc, FrontierConditions_GlobalTag_cff::dump, EcalTimeBiasCorrections::EBTimeCorrAmplitudeBins, EcalTimeBiasCorrections::EBTimeCorrShiftBins, EcalTimeBiasCorrections::EETimeCorrAmplitudeBins, EcalTimeBiasCorrections::EETimeCorrShiftBins, xuti::IntercalibConstants_tag(), AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), cms::xerces::uStr(), xuti::Value_tag(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cscNeutronWriter_cfi::writer.

64  {
65 
66  unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
67 
68  DOMLSSerializer* writer = impl->createLSSerializer();
69  if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
70  writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );
71 
72  DOMDocumentType* doctype = impl->createDocumentType( cms::xerces::uStr("XML").ptr(), nullptr, nullptr );
73  DOMDocument* doc =
74  impl->createDocument( nullptr, cms::xerces::uStr(IntercalibConstants_tag.c_str()).ptr(), doctype );
75  DOMElement* root = doc->getDocumentElement();
76 
77  xuti::writeHeader(root,header);
78 
79  std::vector<float> vect = record.EBTimeCorrAmplitudeBins;
80  std::vector<float>::iterator it;
81 
82  std::string ETCAB_tag = "EBTimeCorrAmplitudeBins";
83  // std::cout << ETCAB_tag << vect.size()<< "\n";
84  DOMElement* ETCAB =
85  root->getOwnerDocument()->createElement( cms::xerces::uStr(ETCAB_tag.c_str()).ptr());
86  root->appendChild(ETCAB);
87  for (it = vect.begin(); it != vect.end(); it++ ) {
88  // std::cout << *it << " ";
89  WriteNodeWithValue(ETCAB, Value_tag, *it);
90  }
91  // std::cout << "\n";
92  vect = record.EBTimeCorrShiftBins;
93  ETCAB_tag = "EBTimeCorrShiftBins";
94  // std::cout << ETCAB_tag << vect.size()<< "\n";
95  ETCAB = root->getOwnerDocument()->createElement( cms::xerces::uStr(ETCAB_tag.c_str()).ptr());
96  root->appendChild(ETCAB);
97  for (it = vect.begin(); it != vect.end(); it++ ) {
98  // std::cout << *it << " ";
99  WriteNodeWithValue(ETCAB, Value_tag, *it);
100  }
101  // std::cout << "\n";
102  vect = record.EETimeCorrAmplitudeBins;
103  ETCAB_tag = "EETimeCorrAmplitudeBins";
104  // std::cout << ETCAB_tag << vect.size()<< "\n";
105  ETCAB = root->getOwnerDocument()->createElement( cms::xerces::uStr(ETCAB_tag.c_str()).ptr());
106  root->appendChild(ETCAB);
107  for (it = vect.begin(); it != vect.end(); it++ ) {
108  // std::cout << *it << " ";
109  WriteNodeWithValue(ETCAB, Value_tag, *it);
110  }
111  // std::cout << "\n";
112  vect = record.EETimeCorrShiftBins;
113  ETCAB_tag = "EETimeCorrShiftBins";
114  // std::cout << ETCAB_tag << vect.size()<< "\n";
115  ETCAB = root->getOwnerDocument()->createElement( cms::xerces::uStr(ETCAB_tag.c_str()).ptr());
116  root->appendChild(ETCAB);
117  for (it = vect.begin(); it != vect.end(); it++ ) {
118  // std::cout << *it << " ";
119  WriteNodeWithValue(ETCAB, Value_tag, *it);
120  }
121  // std::cout << "\n";
122 
123  std::string dump = cms::xerces::toString( writer->writeToString( root ));
124  doc->release();
125  doctype->release();
126  writer->release();
127 
128  return dump;
129 }
std::vector< float > EBTimeCorrShiftBins
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
const std::string Value_tag("Value")
std::vector< float > EBTimeCorrAmplitudeBins
std::vector< float > EETimeCorrShiftBins
std::string toString(XMLCh const *toTranscode)
const std::string IntercalibConstants_tag("EcalIntercalibConstants")
std::vector< float > EETimeCorrAmplitudeBins
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)
int EcalTimeBiasCorrectionsXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalTimeBiasCorrections record 
)
static

Definition at line 21 of file EcalTimeBiasCorrectionsXMLTranslator.cc.

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

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

Definition at line 50 of file EcalTimeBiasCorrectionsXMLTranslator.cc.

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

52  {
54 
55  std::fstream fs(filename.c_str(),ios::out);
56  fs<< dumpXML(header,record);
57 
59 
60  return 0;
61 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
static std::string dumpXML(const EcalCondHeader &header, const EcalTimeBiasCorrections &record)