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

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

Definition at line 68 of file EcalTPGStripStatusXMLTranslator.cc.

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

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

Definition at line 26 of file EcalTPGStripStatusXMLTranslator.cc.

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

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

Definition at line 55 of file EcalTPGStripStatusXMLTranslator.cc.

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

57  {
59 
60  std::fstream fs(filename.c_str(),ios::out);
61  fs<< dumpXML(header,record);
62 
64 
65  return 0;
66 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
static std::string dumpXML(const EcalCondHeader &header, const EcalTPGStripStatus &record)