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.

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 }

References xuti::Cell_tag(), gather_cfg::cout, common_cff::doc, FrontierConditions_GlobalTag_cff::dump, RecoTauValidation_cfi::header, GlobalPosition_Frontier_DevDB_cff::record, AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), xuti::TPGStripStatus_tag(), groupFilesInBlocks::tt, cms::xerces::uStr(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cscNeutronWriter_cfi::writer.

◆ readXML()

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

Definition at line 26 of file EcalTPGStripStatusXMLTranslator.cc.

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 }

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

◆ writeXML()

int EcalTPGStripStatusXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalTPGStripStatus record 
)
static
EcalTPGStripStatusMap
std::map< uint32_t, uint16_t > EcalTPGStripStatusMap
Definition: EcalTPGStripStatus.h:24
common_cff.doc
doc
Definition: common_cff.py:54
xuti::writeHeader
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
Definition: DOMHelperFunctions.cc:151
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
gather_cfg.cout
cout
Definition: gather_cfg.py:144
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
writedatasetfile.parser
parser
Definition: writedatasetfile.py:7
cscNeutronWriter_cfi.writer
writer
Definition: cscNeutronWriter_cfi.py:6
EcalTPGStripStatusXMLTranslator::dumpXML
static std::string dumpXML(const EcalCondHeader &header, const EcalTPGStripStatus &record)
Definition: EcalTPGStripStatusXMLTranslator.cc:67
xuti::TPGStripStatus_tag
const std::string TPGStripStatus_tag("EcalTPGStripStatus")
cms::xerces::toString
std::string toString(XMLCh const *toTranscode)
Definition: XercesStrUtils.h:34
xuti::WriteNodeWithValue
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
Definition: DOMHelperFunctions.h:46
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FrontierConditions_GlobalTag_cff.dump
dump
Definition: FrontierConditions_GlobalTag_cff.py:12
cms::concurrency::xercesTerminate
void xercesTerminate()
Definition: Xerces.cc:23
EcalTPGStripStatusMapIterator
std::map< uint32_t, uint16_t >::const_iterator EcalTPGStripStatusMapIterator
Definition: EcalTPGStripStatus.h:25
root
Definition: RooFitFunction.h:10
cms::xerces::uStr
ZStr< XMLCh > uStr(char const *str)
Definition: XercesStrUtils.h:30
impl
Definition: trackAlgoPriorityOrder.h:18
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
cms::concurrency::xercesInitialize
void xercesInitialize()
Definition: Xerces.cc:18
xuti::readHeader
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
Definition: DOMHelperFunctions.cc:164
xuti::Cell_tag
const std::string Cell_tag("cell")