CMS 3D CMS Logo

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

#include <EcalTPGStripStatusXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

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

Detailed Description

Translates a Ecal record to XML

Version
Id
EcalDAQStripStatusXMLTranslator.h,v 1.1 2011/06/14 fay Exp
Date
14 Jun 2011

Definition at line 14 of file EcalTPGStripStatusXMLTranslator.h.

Member Function Documentation

◆ dumpXML()

std::string EcalTPGStripStatusXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalTPGStripStatus record 
)
staticprivate

Definition at line 67 of file EcalTPGStripStatusXMLTranslator.cc.

References xuti::Cell_tag(), gather_cfg::cout, ALCARECOEcalPhiSym_cff::doc, GCP_Ntuples_cfg::dump, RecoTauValidation_cfi::header, Hcal_FrontierConditions_cff::record, AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), xuti::TPGStripStatus_tag(), groupFilesInBlocks::tt, cms::xerces::uStr(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and convertToRaw::writer.

67  {
68  unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
69 
70  DOMLSSerializer* writer = impl->createLSSerializer();
71  if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
72  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
73 
74  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr);
75  DOMDocument* doc = impl->createDocument(nullptr, cms::xerces::uStr(TPGStripStatus_tag.c_str()).ptr(), doctype);
76  DOMElement* root = doc->getDocumentElement();
77 
79  std::string TCC_tag("TCC");
80  std::string TT_tag("TT");
81  std::string ST_tag("ST");
82  const EcalTPGStripStatusMap& stripMap = record.getMap();
83  std::cout << "EcalTPGStripStatusXMLTranslator::dumpXML strip map size " << stripMap.size() << std::endl;
85  for (itSt = stripMap.begin(); itSt != stripMap.end(); ++itSt) {
86  if (itSt->second > 0) {
87  int tccid = itSt->first / 8192 & 0x7F;
88  int tt = itSt->first / 64 & 0x7F;
89  int pseudostrip = itSt->first / 8 & 0x7;
90  // std::cout << "Bad strip ID = " << itSt->first
91  // << " TCC " << tccid << " TT " << tt << " ST " << pseudostrip
92  // << ", status = " << itSt->second << std::endl;
93  DOMElement* cell_node = root->getOwnerDocument()->createElement(cms::xerces::uStr(Cell_tag.c_str()).ptr());
94  stringstream value_s;
95  value_s << tccid;
96  cell_node->setAttribute(cms::xerces::uStr(TCC_tag.c_str()).ptr(), cms::xerces::uStr(value_s.str().c_str()).ptr());
97  value_s.str("");
98  value_s << tt;
99  cell_node->setAttribute(cms::xerces::uStr(TT_tag.c_str()).ptr(), cms::xerces::uStr(value_s.str().c_str()).ptr());
100  value_s.str("");
101  value_s << pseudostrip;
102  cell_node->setAttribute(cms::xerces::uStr(ST_tag.c_str()).ptr(), cms::xerces::uStr(value_s.str().c_str()).ptr());
103  root->appendChild(cell_node);
104 
105  WriteNodeWithValue(cell_node, TPGStripStatus_tag, 1);
106  }
107  }
108 
109  std::string dump = cms::xerces::toString(writer->writeToString(root));
110  doc->release();
111  doctype->release();
112  writer->release();
113  return dump;
114 }
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
std::string toString(XMLCh const *toTranscode)
Definition: TTTypes.h:54
const std::string Cell_tag("cell")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)
const std::string TPGStripStatus_tag("EcalTPGStripStatus")
std::map< uint32_t, uint16_t > EcalTPGStripStatusMap
std::map< uint32_t, uint16_t >::const_iterator EcalTPGStripStatusMapIterator

◆ readXML()

int EcalTPGStripStatusXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalTPGStripStatus record 
)
static

Definition at line 26 of file EcalTPGStripStatusXMLTranslator.cc.

References gather_cfg::cout, corrVsCorr::filename, RecoTauValidation_cfi::header, writedatasetfile::parser, xuti::readHeader(), cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

28  {
29  std::cout << " TPGStripStatus should not be filled out from an xml file ..." << std::endl;
31 
32  XercesDOMParser* parser = new XercesDOMParser;
33  parser->setValidationScheme(XercesDOMParser::Val_Never);
34  parser->setDoNamespaces(false);
35  parser->setDoSchema(false);
36 
37  parser->parse(filename.c_str());
38 
39  DOMDocument* xmlDoc = parser->getDocument();
40  if (!xmlDoc) {
41  std::cout << "EcalTPGStripStatusXMLTranslator::Error parsing document" << std::endl;
42  return -1;
43  }
44 
45  DOMElement* elementRoot = xmlDoc->getDocumentElement();
46 
47  xuti::readHeader(elementRoot, header);
48 
49  delete parser;
51  return 0;
52 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from

◆ writeXML()

int EcalTPGStripStatusXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalTPGStripStatus record 
)
static