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

#include <EcalTimeBiasCorrectionsXMLTranslator.h>

Static Public Member Functions

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

Detailed Description

Definition at line 16 of file EcalTimeBiasCorrectionsXMLTranslator.h.

Member Function Documentation

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

Definition at line 60 of file EcalTimeBiasCorrectionsXMLTranslator.cc.

References hcal_timing_source_file_cfg::dump, EcalTimeBiasCorrections::EBTimeCorrAmplitudeBins, EcalTimeBiasCorrections::EBTimeCorrShiftBins, EcalTimeBiasCorrections::EETimeCorrAmplitudeBins, EcalTimeBiasCorrections::EETimeCorrShiftBins, xuti::fromNative(), xuti::IntercalibConstants_tag(), pyrootRender::root, AlCaHLTBitMon_QueryRunRegistry::string, xuti::toNative(), xuti::Value_tag(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cms::concurrency::xercesInitialize().

61  {
62 
64 
65  DOMImplementation* impl =
66  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
67 
68  DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
69  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
70 
71  DOMDocumentType* doctype = impl->createDocumentType(fromNative("XML").c_str(), 0, 0 );
72  DOMDocument * doc =
73  impl->createDocument( 0, fromNative(IntercalibConstants_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 
82  xuti::writeHeader(root,header);
83 
84  std::vector<float> vect = record.EBTimeCorrAmplitudeBins;
85  std::vector<float>::iterator it;
86 
87  std::string ETCAB_tag = "EBTimeCorrAmplitudeBins";
88  // std::cout << ETCAB_tag << vect.size()<< "\n";
89  DOMElement* ETCAB =
90  root->getOwnerDocument()->createElement( fromNative(ETCAB_tag).c_str());
91  root->appendChild(ETCAB);
92  for (it = vect.begin(); it != vect.end(); it++ ) {
93  // std::cout << *it << " ";
94  WriteNodeWithValue(ETCAB, Value_tag, *it);
95  }
96  // std::cout << "\n";
97  vect = record.EBTimeCorrShiftBins;
98  ETCAB_tag = "EBTimeCorrShiftBins";
99  // std::cout << ETCAB_tag << vect.size()<< "\n";
100  ETCAB = root->getOwnerDocument()->createElement( fromNative(ETCAB_tag).c_str());
101  root->appendChild(ETCAB);
102  for (it = vect.begin(); it != vect.end(); it++ ) {
103  // std::cout << *it << " ";
104  WriteNodeWithValue(ETCAB, Value_tag, *it);
105  }
106  // std::cout << "\n";
107  vect = record.EETimeCorrAmplitudeBins;
108  ETCAB_tag = "EETimeCorrAmplitudeBins";
109  // std::cout << ETCAB_tag << vect.size()<< "\n";
110  ETCAB = root->getOwnerDocument()->createElement( fromNative(ETCAB_tag).c_str());
111  root->appendChild(ETCAB);
112  for (it = vect.begin(); it != vect.end(); it++ ) {
113  // std::cout << *it << " ";
114  WriteNodeWithValue(ETCAB, Value_tag, *it);
115  }
116  // std::cout << "\n";
117  vect = record.EETimeCorrShiftBins;
118  ETCAB_tag = "EETimeCorrShiftBins";
119  // std::cout << ETCAB_tag << vect.size()<< "\n";
120  ETCAB = root->getOwnerDocument()->createElement( fromNative(ETCAB_tag).c_str());
121  root->appendChild(ETCAB);
122  for (it = vect.begin(); it != vect.end(); it++ ) {
123  // std::cout << *it << " ";
124  WriteNodeWithValue(ETCAB, Value_tag, *it);
125  }
126  // std::cout << "\n";
127 
128  std::string dump= toNative(writer->writeToString(*root));
129  doc->release();
130  return dump;
131 }
std::vector< float > EBTimeCorrShiftBins
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")
std::vector< float > EBTimeCorrAmplitudeBins
std::vector< float > EETimeCorrShiftBins
const std::string IntercalibConstants_tag("EcalIntercalibConstants")
std::vector< float > EETimeCorrAmplitudeBins
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 EcalTimeBiasCorrectionsXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalTimeBiasCorrections record 
)
static

Definition at line 22 of file EcalTimeBiasCorrectionsXMLTranslator.cc.

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

24  {
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  if (!xmlDoc) {
38  std::cout << "EcalTimeBiasCorrectionsXMLTranslator::Error parsing document" << std::endl;
39  return -1;
40  }
41 
42  // Get the top-level element
43  DOMElement* elementRoot = xmlDoc->getDocumentElement();
44 
45  xuti::readHeader(elementRoot, header);
46 
47  delete parser;
49  return 0;
50 }
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 EcalTimeBiasCorrectionsXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalTimeBiasCorrections record 
)
static

Definition at line 52 of file EcalTimeBiasCorrectionsXMLTranslator.cc.

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

54  {
55  std::fstream fs(filename.c_str(),ios::out);
56  fs<< dumpXML(header,record);
57  return 0;
58 }
tuple filename
Definition: lut2db_cfg.py:20
static std::string dumpXML(const EcalCondHeader &header, const EcalTimeBiasCorrections &record)