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

#include <EcalTPGStripStatusXMLTranslator.h>

Static Public Member Functions

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

Detailed Description

Definition at line 23 of file EcalTPGStripStatusXMLTranslator.h.

Member Function Documentation

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

Definition at line 63 of file EcalTPGStripStatusXMLTranslator.cc.

References xuti::Cell_tag(), gather_cfg::cout, asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::fromNative(), EcalTPGStripStatus::getMap(), dbtoconf::root, xuti::toNative(), xuti::TPGStripStatus_tag(), groupFilesInBlocks::tt, xuti::writeHeader(), and xuti::WriteNodeWithValue().

Referenced by cond::PayLoadInspector< DataT >::dump().

63  {
64 
65  XMLPlatformUtils::Initialize();
66  DOMImplementation* impl =
67  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
68 
69  DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
70  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
71 
72  DOMDocumentType* doctype = impl->createDocumentType(fromNative("XML").c_str(), 0, 0 );
73  DOMDocument * doc =
74  impl->createDocument( 0, fromNative(TPGStripStatus_tag).c_str(), doctype );
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  std::string TCC_tag("TCC");
84  std::string TT_tag("TT");
85  std::string ST_tag("ST");
86  const EcalTPGStripStatusMap &stripMap = record.getMap();
87  std::cout << "EcalTPGStripStatusXMLTranslator::dumpXML strip map size " << stripMap.size() << std::endl;
89  for(itSt = stripMap.begin(); itSt != stripMap.end(); ++itSt) {
90  if(itSt->second > 0) {
91  int tccid = itSt->first/8192 & 0x7F;
92  int tt = itSt->first/64 & 0x7F;
93  int pseudostrip = itSt->first/8 & 0x7;
94  // std::cout << "Bad strip ID = " << itSt->first
95  // << " TCC " << tccid << " TT " << tt << " ST " << pseudostrip
96  // << ", status = " << itSt->second << std::endl;
97  DOMElement* cell_node =
98  root->getOwnerDocument()->createElement( fromNative(Cell_tag).c_str());
99  stringstream value_s;
100  value_s << tccid ;
101  cell_node->setAttribute(fromNative(TCC_tag).c_str(),
102  fromNative(value_s.str()).c_str());
103  value_s.str("");
104  value_s << tt ;
105  cell_node->setAttribute(fromNative(TT_tag).c_str(),
106  fromNative(value_s.str()).c_str());
107  value_s.str("");
108  value_s << pseudostrip;
109  cell_node->setAttribute(fromNative(ST_tag).c_str(),
110  fromNative(value_s.str()).c_str());
111  root->appendChild(cell_node);
112 
113  WriteNodeWithValue(cell_node, TPGStripStatus_tag, 1);
114  }
115  }
116 
117  std::string dump = toNative(writer->writeToString(*root));
118  doc->release();
119  return dump;
120 }
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
const std::string Cell_tag("cell")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
tuple doc
Definition: asciidump.py:381
const std::string TPGStripStatus_tag("EcalTPGStripStatus")
XercesString fromNative(const char *str)
Definition: XercesString.h:31
tuple cout
Definition: gather_cfg.py:121
std::map< uint32_t, uint16_t > EcalTPGStripStatusMap
std::string toNative(const XMLCh *str)
Definition: XercesString.h:42
std::map< uint32_t, uint16_t >::const_iterator EcalTPGStripStatusMapIterator
string root
initialization
Definition: dbtoconf.py:70
int EcalTPGStripStatusXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalTPGStripStatus record 
)
static

Definition at line 25 of file EcalTPGStripStatusXMLTranslator.cc.

References gather_cfg::cout, geometryXMLtoCSV::parser, and xuti::readHeader().

27  {
28 
29  std::cout << " TPGStripStatus should not be filled out from an xml file ..." << std::endl;
30  XMLPlatformUtils::Initialize();
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;
50  XMLPlatformUtils::Terminate();
51  return 0;
52  }
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
int EcalTPGStripStatusXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalTPGStripStatus record 
)
static

Definition at line 54 of file EcalTPGStripStatusXMLTranslator.cc.

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

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