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

#include <EcalPedestalsXMLTranslator.h>

Static Public Member Functions

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

Detailed Description

Definition at line 24 of file EcalPedestalsXMLTranslator.h.

Member Function Documentation

std::string EcalPedestalsXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalPedestals record 
)
static

Definition at line 114 of file EcalPedestalsXMLTranslator.cc.

References EcalCondObjectContainer< T >::barrelItems(), asciidump::doc, hcal_timing_source_file_cfg::dump, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::endcapItems(), EcalCondObjectContainer< T >::find(), xuti::fromNative(), EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, xuti::mean12_tag(), xuti::mean1_tag(), xuti::mean6_tag(), cond::ecalped::mean_x12, cond::ecalped::mean_x6, EBDetId::MIN_HASH, xuti::Pedestals_tag(), xuti::rms12_tag(), xuti::rms1_tag(), xuti::rms6_tag(), 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().

114  {
115 
117  DOMImplementation* impl =
118  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
119 
120  DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
121  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
122 
123  DOMDocumentType* doctype = impl->createDocumentType(fromNative("XML").c_str(), 0, 0 );
124  DOMDocument * doc =
125  impl->createDocument( 0, fromNative(Pedestals_tag).c_str(), doctype );
126 
127  doc->setEncoding(fromNative("UTF-8").c_str() );
128  doc->setStandalone(true);
129  doc->setVersion(fromNative("1.0").c_str() );
130 
131  DOMElement* root = doc->getDocumentElement();
132 
133  xuti::writeHeader(root,header);
134  if (!record.barrelItems().size()) return std::string();
135  for(int cellid = EBDetId::MIN_HASH;
137  ++cellid) {
138  uint32_t rawid = EBDetId::unhashIndex(cellid);
139 
140  if (record.find(rawid) == record.end()) continue;
141  if(!record[rawid].mean_x12 && !record[rawid].rms_x12) continue;
142 
143  DOMElement* cellnode=writeCell(root,rawid);
144 
145  WriteNodeWithValue(cellnode,mean12_tag,record[rawid].mean_x12);
146  WriteNodeWithValue(cellnode,mean6_tag,record[rawid].mean_x6);
147  WriteNodeWithValue(cellnode,mean1_tag,record[rawid].mean_x1);
148  WriteNodeWithValue(cellnode,rms12_tag,record[rawid].rms_x12);
149  WriteNodeWithValue(cellnode,rms6_tag,record[rawid].rms_x6);
150  WriteNodeWithValue(cellnode,rms1_tag,record[rawid].rms_x1);
151  }
152 
153  if (!record.endcapItems().size()) return std::string();
154  for(int cellid = 0;
156  ++cellid) {
157  if(!EEDetId::validHashIndex(cellid)) continue;
158 
159  uint32_t rawid = EEDetId::unhashIndex(cellid);
160 
161  if (record.find(rawid) == record.end()) continue;
162  if(!record[rawid].mean_x12 && !record[rawid].rms_x12) continue;
163 
164  DOMElement* cellnode=writeCell(root,rawid);
165 
166  WriteNodeWithValue(cellnode,mean12_tag,record[rawid].mean_x12);
167  WriteNodeWithValue(cellnode,mean6_tag,record[rawid].mean_x6);
168  WriteNodeWithValue(cellnode,mean1_tag,record[rawid].mean_x1);
169  WriteNodeWithValue(cellnode,rms12_tag,record[rawid].rms_x12);
170  WriteNodeWithValue(cellnode,rms6_tag,record[rawid].rms_x6);
171  WriteNodeWithValue(cellnode,rms1_tag,record[rawid].rms_x1);
172  }
173 
174  std::string dump= toNative(writer->writeToString(*root));
175  doc->release();
176  return dump;
177 }
const std::string mean12_tag("mean_x12")
const Items & barrelItems() const
void xercesInitialize()
Definition: Xerces.cc:17
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:99
const std::string mean1_tag("mean_x1")
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
static const int MIN_HASH
Definition: EBDetId.h:156
const std::string Pedestals_tag("EcalPedestals")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
tuple doc
Definition: asciidump.py:381
const std::string mean6_tag("mean_x6")
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:114
const_iterator find(uint32_t rawId) const
XercesString fromNative(const char *str)
Definition: XercesString.h:31
const std::string rms12_tag("rms_x12")
const std::string rms6_tag("rms_x6")
const_iterator end() const
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
const Items & endcapItems() const
const std::string rms1_tag("rms_x1")
std::string toNative(const XMLCh *str)
Definition: XercesString.h:42
string root
initialization
Definition: dbtoconf.py:70
int EcalPedestalsXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalPedestals record 
)
static

Definition at line 23 of file EcalPedestalsXMLTranslator.cc.

References xuti::Cell_tag(), gather_cfg::cout, cond::rpcobgas::detid, xuti::getChildNode(), xuti::GetNodeData(), xuti::mean12_tag(), xuti::mean1_tag(), xuti::mean6_tag(), geometryXMLtoCSV::parser, xuti::readCellId(), xuti::readHeader(), xuti::rms12_tag(), xuti::rms1_tag(), xuti::rms6_tag(), cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

25  {
26 
28 
29  XercesDOMParser* parser = new XercesDOMParser;
30  parser->setValidationScheme( XercesDOMParser::Val_Never );
31  parser->setDoNamespaces( false );
32  parser->setDoSchema( false );
33 
34  parser->parse(filename.c_str());
35 
36  DOMDocument* xmlDoc = parser->getDocument();
37  if (!xmlDoc) {
38  std::cout << "EcalPedestalsXMLTranslator::Error parsing document" << std::endl;
39  return -1;
40  }
41 
42  DOMElement* elementRoot = xmlDoc->getDocumentElement();
43 
44  xuti::readHeader(elementRoot,header);
45 
46  DOMNode * cellnode = getChildNode(elementRoot,Cell_tag);
47 
48  int chan = 0;
49  while(cellnode) {
50  // std::cout << " Channel " << chan << std::endl;
51  float mean12 = 0;
52  float mean6 = 0;
53  float mean1 = 0;
54  float rms12 = 0;
55  float rms6 = 0;
56  float rms1 = 0;
57  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
58  // std::cout << " readCell Id Channel " << chan << " tag " << mean12_tag << std::endl;
59 
60  DOMNode* mean12_node = getChildNode(cellnode,mean12_tag);
61  GetNodeData(mean12_node,mean12);
62  // std::cout << " tag " << mean12_tag << " mean12 " << mean12 << std::endl;
63 
64  DOMNode* mean6_node = getChildNode(cellnode,mean6_tag);
65  GetNodeData(mean6_node,mean6);
66  // std::cout << " tag " << mean6_tag << " mean6 " << mean6 << std::endl;
67 
68  DOMNode* mean1_node = getChildNode(cellnode,mean1_tag);
69  GetNodeData(mean1_node,mean1);
70  // std::cout << " tag " << mean1_tag << " mean1 " << mean1 << std::endl;
71 
72  DOMNode* rms12_node = getChildNode(cellnode,rms12_tag);
73  GetNodeData(rms12_node,rms12);
74  // std::cout << " tag 12 " << rms12_tag << " rms 12 " << rms12 << std::endl;
75 
76  DOMNode* rms6_node = getChildNode(cellnode,rms6_tag);
77  GetNodeData(rms6_node,rms6);
78  // std::cout << " tag 6 " << rms6_tag << " rms 6 " << rms6 << std::endl;
79 
80  DOMNode* rms1_node = getChildNode(cellnode,rms1_tag);
81  // std::cout << " tag 1 " << rms1_tag << std::endl;
82 
83  GetNodeData(rms1_node,rms1);
84  // std::cout << " Channel " << chan << " mean12 " << mean12 << " rms 1 " << rms1 << std::endl;
85  record[detid].mean_x12 = mean12;
86  record[detid].mean_x6 = mean6;
87  record[detid].mean_x1 = mean1;
88  record[detid].rms_x12 = rms12;
89  record[detid].rms_x6 = rms6;
90  record[detid].rms_x1 = rms1;
91 
92  cellnode = cellnode->getNextSibling();
93 
94  while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
95  cellnode = cellnode->getNextSibling();
96  chan++;
97  }
98 
99  delete parser;
101  std::cout << " nb of channels found in xml file " << chan << std::endl;
102  return 0;
103  }
const std::string mean12_tag("mean_x12")
void xercesTerminate()
Definition: Xerces.cc:22
void xercesInitialize()
Definition: Xerces.cc:17
const std::string mean1_tag("mean_x1")
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
const std::string mean6_tag("mean_x6")
tuple filename
Definition: lut2db_cfg.py:20
const std::string rms12_tag("rms_x12")
const std::string rms6_tag("rms_x6")
tuple cout
Definition: gather_cfg.py:121
const std::string rms1_tag("rms_x1")
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
int EcalPedestalsXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalPedestals record 
)
static

Definition at line 105 of file EcalPedestalsXMLTranslator.cc.

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

107  {
108  std::fstream fs(filename.c_str(),ios::out);
109  fs<< dumpXML(header,record);
110  return 0;
111 }
static std::string dumpXML(const EcalCondHeader &header, const EcalPedestals &record)
tuple out
Definition: dbtoconf.py:99
tuple filename
Definition: lut2db_cfg.py:20