CMS 3D CMS Logo

List of all members | Static Public Member Functions | Static Private Member Functions
EcalPedestalsXMLTranslator Class Reference

#include <EcalPedestalsXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

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

Detailed Description

Translates a EcalGainRatio record to XML and vice versa

Author
Francesco RUBBO
Version
Id
EcalPedestalsXMLTranslator.h,v 0 2010/04/26 fay Exp
Date
26 Apr 2010

Definition at line 15 of file EcalPedestalsXMLTranslator.h.

Member Function Documentation

◆ dumpXML()

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

Definition at line 114 of file EcalPedestalsXMLTranslator.cc.

114  {
115  unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
116 
117  DOMLSSerializer* writer = impl->createLSSerializer();
118  if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
119  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
120 
121  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr);
122  DOMDocument* doc = impl->createDocument(nullptr, cms::xerces::uStr(Pedestals_tag.c_str()).ptr(), doctype);
123 
124  DOMElement* root = doc->getDocumentElement();
125 
127  if (record.barrelItems().empty())
128  return std::string();
129  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
130  uint32_t rawid = EBDetId::unhashIndex(cellid);
131 
132  if (record.find(rawid) == record.end())
133  continue;
134  if (!record[rawid].mean_x12 && !record[rawid].rms_x12)
135  continue;
136 
137  DOMElement* cellnode = writeCell(root, rawid);
138 
139  WriteNodeWithValue(cellnode, mean12_tag, record[rawid].mean_x12);
140  WriteNodeWithValue(cellnode, mean6_tag, record[rawid].mean_x6);
141  WriteNodeWithValue(cellnode, mean1_tag, record[rawid].mean_x1);
142  WriteNodeWithValue(cellnode, rms12_tag, record[rawid].rms_x12);
143  WriteNodeWithValue(cellnode, rms6_tag, record[rawid].rms_x6);
144  WriteNodeWithValue(cellnode, rms1_tag, record[rawid].rms_x1);
145  }
146 
147  if (record.endcapItems().empty())
148  return std::string();
149  for (int cellid = 0; cellid < EEDetId::kSizeForDenseIndexing; ++cellid) {
150  if (!EEDetId::validHashIndex(cellid))
151  continue;
152 
153  uint32_t rawid = EEDetId::unhashIndex(cellid);
154 
155  if (record.find(rawid) == record.end())
156  continue;
157  if (!record[rawid].mean_x12 && !record[rawid].rms_x12)
158  continue;
159 
160  DOMElement* cellnode = writeCell(root, rawid);
161 
162  WriteNodeWithValue(cellnode, mean12_tag, record[rawid].mean_x12);
163  WriteNodeWithValue(cellnode, mean6_tag, record[rawid].mean_x6);
164  WriteNodeWithValue(cellnode, mean1_tag, record[rawid].mean_x1);
165  WriteNodeWithValue(cellnode, rms12_tag, record[rawid].rms_x12);
166  WriteNodeWithValue(cellnode, rms6_tag, record[rawid].rms_x6);
167  WriteNodeWithValue(cellnode, rms1_tag, record[rawid].rms_x1);
168  }
169 
170  std::string dump = cms::xerces::toString(writer->writeToString(root));
171  doc->release();
172  doctype->release();
173  writer->release();
174 
175  return dump;
176 }

References common_cff::doc, FrontierConditions_GlobalTag_cff::dump, RecoTauValidation_cfi::header, EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, xuti::mean12_tag(), xuti::mean1_tag(), xuti::mean6_tag(), EBDetId::MIN_HASH, xuti::Pedestals_tag(), GlobalPosition_Frontier_DevDB_cff::record, xuti::rms12_tag(), xuti::rms1_tag(), xuti::rms6_tag(), AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), cms::xerces::uStr(), EEDetId::validHashIndex(), xuti::writeCell(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cscNeutronWriter_cfi::writer.

◆ readXML()

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

Definition at line 22 of file EcalPedestalsXMLTranslator.cc.

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

References xuti::Cell_tag(), officialStyle::chan, gather_cfg::cout, corrVsCorr::filename, xuti::getChildNode(), xuti::GetNodeData(), RecoTauValidation_cfi::header, xuti::mean12_tag(), xuti::mean1_tag(), xuti::mean6_tag(), writedatasetfile::parser, xuti::readCellId(), xuti::readHeader(), GlobalPosition_Frontier_DevDB_cff::record, xuti::rms12_tag(), xuti::rms1_tag(), xuti::rms6_tag(), cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

◆ writeXML()

int EcalPedestalsXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalPedestals record 
)
static
xuti::getChildNode
xercesc::DOMNode * getChildNode(xercesc::DOMNode *node, const std::string &nodename)
get the child of
EcalPedestalsXMLTranslator::dumpXML
static std::string dumpXML(const EcalCondHeader &header, const EcalPedestals &record)
Definition: EcalPedestalsXMLTranslator.cc:114
common_cff.doc
doc
Definition: common_cff.py:54
xuti::rms12_tag
const std::string rms12_tag("rms_x12")
xuti::writeHeader
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
Definition: DOMHelperFunctions.cc:151
xuti::writeCell
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
Definition: DOMHelperFunctions.cc:71
EEDetId::unhashIndex
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
xuti::rms6_tag
const std::string rms6_tag("rms_x6")
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EBDetId::unhashIndex
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
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
xuti::mean6_tag
const std::string mean6_tag("mean_x6")
DetId
Definition: DetId.h:17
cms::xerces::toString
std::string toString(XMLCh const *toTranscode)
Definition: XercesStrUtils.h:34
EEDetId::kSizeForDenseIndexing
Definition: EEDetId.h:329
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
xuti::rms1_tag
const std::string rms1_tag("rms_x1")
FrontierConditions_GlobalTag_cff.dump
dump
Definition: FrontierConditions_GlobalTag_cff.py:12
cms::concurrency::xercesTerminate
void xercesTerminate()
Definition: Xerces.cc:23
root
Definition: RooFitFunction.h:10
EEDetId::validHashIndex
static bool validHashIndex(int i)
Definition: EEDetId.h:239
cms::xerces::uStr
ZStr< XMLCh > uStr(char const *str)
Definition: XercesStrUtils.h:30
xuti::mean1_tag
const std::string mean1_tag("mean_x1")
xuti::mean12_tag
const std::string mean12_tag("mean_x12")
impl
Definition: trackAlgoPriorityOrder.h:18
officialStyle.chan
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi....
Definition: officialStyle.py:106
EBDetId::kSizeForDenseIndexing
Definition: EBDetId.h:155
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
xuti::readCellId
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
Definition: DOMHelperFunctions.cc:24
EBDetId::MIN_HASH
static const int MIN_HASH
Definition: EBDetId.h:149
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")
xuti::Pedestals_tag
const std::string Pedestals_tag("EcalPedestals")
xuti::GetNodeData
void GetNodeData(xercesc::DOMNode *node, T &value)
get the node data
Definition: DOMHelperFunctions.h:38