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

#include <EcalChannelStatusXMLTranslator.h>

Static Public Member Functions

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

Detailed Description

Definition at line 25 of file EcalChannelStatusXMLTranslator.h.

Member Function Documentation

std::string EcalChannelStatusXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalChannelStatus record 
)
static

Definition at line 94 of file EcalChannelStatusXMLTranslator.cc.

References xuti::ChannelStatus_tag(), xuti::ChannelStatusCode_tag(), asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::fromNative(), EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, EBDetId::MIN_HASH, dbtoconf::root, AlCaHLTBitMon_QueryRunRegistry::string, xuti::toNative(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), EEDetId::validHashIndex(), xuti::writeCell(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cms::concurrency::xercesInitialize().

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

96  {
97 
98 
100 
101  DOMImplementation* impl =
102  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
103 
104  DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
105  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
106 
107  DOMDocumentType* doctype = impl->createDocumentType( fromNative("XML").c_str(), 0, 0 );
108  DOMDocument * doc =
109  impl->createDocument( 0, fromNative(ChannelStatus_tag).c_str(), doctype );
110 
111 
112  doc->setEncoding(fromNative("UTF-8").c_str() );
113  doc->setStandalone(true);
114  doc->setVersion(fromNative("1.0").c_str() );
115 
116 
117  DOMElement* root = doc->getDocumentElement();
118 
119  xuti::writeHeader(root,header);
120 
121  for(int cellid = EBDetId::MIN_HASH;
123  ++cellid)
124  {
125 
126  uint32_t rawid = EBDetId::unhashIndex(cellid);
127 
128  if(!record[rawid].getStatusCode()) continue;
129 
130 
131  DOMElement* cellnode = writeCell(root,rawid);
132 
133  WriteNodeWithValue(cellnode,ChannelStatusCode_tag,record[rawid].getStatusCode());
134 
135 
136  }
137 
138 
139 
140 
141  for(int cellid = 0;
143  ++cellid)
144  {
145 
146  if(!EEDetId::validHashIndex(cellid)) continue;
147 
148  uint32_t rawid = EEDetId::unhashIndex(cellid);
149 
150  if(!record[rawid].getStatusCode()) continue;
151 
152  DOMElement* cellnode = writeCell(root,rawid);
153  WriteNodeWithValue(cellnode,ChannelStatusCode_tag,record[rawid].getStatusCode());
154 
155  }
156 
157 
158  std::string dump= toNative(writer->writeToString(*root));
159  doc->release();
160  // cms::concurrency::xercesTerminate();
161 
162  return dump;
163 
164 }
void xercesInitialize()
Definition: Xerces.cc:17
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:99
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
static bool validHashIndex(int i)
Definition: EEDetId.h:239
const std::string ChannelStatusCode_tag("ChannelStatusCode")
static const int MIN_HASH
Definition: EBDetId.h:156
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
tuple doc
Definition: asciidump.py:381
const std::string ChannelStatus_tag("EcalChannelStatus")
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:114
XercesString fromNative(const char *str)
Definition: XercesString.h:31
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
std::string toNative(const XMLCh *str)
Definition: XercesString.h:42
string root
initialization
Definition: dbtoconf.py:70
int EcalChannelStatusXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalChannelStatus record 
)
static

Definition at line 27 of file EcalChannelStatusXMLTranslator.cc.

References xuti::Cell_tag(), xuti::ChannelStatusCode_tag(), gather_cfg::cout, cond::rpcobgas::detid, xuti::getChildNode(), xuti::GetNodeData(), geometryXMLtoCSV::parser, xuti::readCellId(), xuti::readHeader(), cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

29  {
30 
31 
32 
34 
35  XercesDOMParser* parser = new XercesDOMParser;
36  parser->setValidationScheme( XercesDOMParser::Val_Never );
37  parser->setDoNamespaces( false );
38  parser->setDoSchema( false );
39 
40  parser->parse(filename.c_str());
41 
42  DOMDocument* xmlDoc = parser->getDocument();
43  if (!xmlDoc) {
44  std::cout << "EcalChannelStatusXMLTranslator::Error parsing document" << std::endl;
45  return -1;
46  }
47 
48  DOMElement* elementRoot = xmlDoc->getDocumentElement();
49 
50  xuti::readHeader(elementRoot,header);
51 
52  DOMNode * cellnode = getChildNode(elementRoot,Cell_tag);
53 
54  while(cellnode)
55  {
56  uint16_t csc = 0;
57 
58  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
59 
60  DOMNode* c_node = getChildNode(cellnode,ChannelStatusCode_tag);
61  GetNodeData(c_node,csc);
62 
64  record[detid] = ecalCSC;
65 
66  cellnode = cellnode->getNextSibling();
67 
68  while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
69  cellnode = cellnode->getNextSibling();
70 
71 
72  }
73 
74  delete parser;
76  return 0;
77 
78 
79 }
void xercesTerminate()
Definition: Xerces.cc:22
void xercesInitialize()
Definition: Xerces.cc:17
const std::string ChannelStatusCode_tag("ChannelStatusCode")
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
const std::string Cell_tag("cell")
Definition: DetId.h:18
void GetNodeData(xercesc::DOMNode *node, T &value)
get the node data
xercesc::DOMNode * getChildNode(xercesc::DOMNode *node, const std::string &nodename)
get the child of
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
int EcalChannelStatusXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalChannelStatus record 
)
static

Definition at line 85 of file EcalChannelStatusXMLTranslator.cc.

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

87  {
88  std::fstream fs(filename.c_str(),ios::out);
89  fs<< dumpXML(header,record);
90  return 0;
91  }
static std::string dumpXML(const EcalCondHeader &header, const EcalChannelStatus &record)
tuple out
Definition: dbtoconf.py:99
tuple filename
Definition: lut2db_cfg.py:20