CMS 3D CMS Logo

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

#include <EcalWeightGroupXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

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

Detailed Description

Translates a EcalWeightGroup record to XML and vice versa

Author
Stefano ARGIRO
Version
Id
EcalWeightGroupXMLTranslator.h,v 1.2 2009/06/30 14:40:11 argiro Exp
Date
20 Jun 2008

Definition at line 17 of file EcalWeightGroupXMLTranslator.h.

Member Function Documentation

◆ dumpXML()

std::string EcalWeightGroupXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalWeightXtalGroups record 
)
staticprivate

Definition at line 84 of file EcalWeightGroupXMLTranslator.cc.

84  {
85  unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
86 
87  DOMLSSerializer* writer = impl->createLSSerializer();
88  if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
89  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
90 
91  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr);
92  DOMDocument* doc = impl->createDocument(nullptr, cms::xerces::uStr(WeightGroups_tag.c_str()).ptr(), doctype);
93  DOMElement* root = doc->getDocumentElement();
94 
96 
97  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) { // loop on EB cells
98 
99  uint32_t rawid = EBDetId::unhashIndex(cellid);
100 
101  //if (!record[rawid]) continue; // cell absent from original record
102 
103  DOMElement* cellnode = writeCell(root, rawid);
104 
105  WriteNodeWithValue(cellnode, WeightGroup_tag, record[rawid].id());
106 
107  } // loop on EB cells
108 
109  for (int cellid = 0; cellid < EEDetId::kSizeForDenseIndexing; ++cellid) { // loop on EE cells
110 
111  if (!EEDetId::validHashIndex(cellid))
112  continue;
113 
114  uint32_t rawid = EEDetId::unhashIndex(cellid);
115  //xif (!record[rawid]) continue; // cell absent from original record
116 
117  DOMElement* cellnode = writeCell(root, rawid);
118  WriteNodeWithValue(cellnode, WeightGroup_tag, record[rawid].id());
119 
120  } // loop on EE cells
121 
122  std::string dump = cms::xerces::toString(writer->writeToString(root));
123  doc->release();
124  doctype->release();
125  writer->release();
126 
127  return dump;
128 }

References boostedTaus_cff::doc, submitPVValidationJobs::dump, RecoTauValidation_cfi::header, EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, EBDetId::MIN_HASH, AlCaHarvesting_cff::record, AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), cms::xerces::uStr(), EEDetId::validHashIndex(), xuti::WeightGroup_tag(), xuti::WeightGroups_tag(), xuti::writeCell(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cscNeutronWriter_cfi::writer.

◆ readXML()

int EcalWeightGroupXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalWeightXtalGroups record 
)
static

Definition at line 21 of file EcalWeightGroupXMLTranslator.cc.

23  {
25 
26  XercesDOMParser* parser = new XercesDOMParser;
27  parser->setValidationScheme(XercesDOMParser::Val_Never);
28  parser->setDoNamespaces(false);
29  parser->setDoSchema(false);
30 
31  parser->parse(filename.c_str());
32 
33  DOMDocument* xmlDoc = parser->getDocument();
34  if (!xmlDoc) {
35  std::cout << "EcalWeightGroupXMLTranslator::Error parsing document" << std::endl;
36  return -1;
37  }
38 
39  DOMElement* elementRoot = xmlDoc->getDocumentElement();
40 
41  xuti::readHeader(elementRoot, header);
42  // get the first cell node
43  DOMNode* cellnode = getChildNode(elementRoot, Cell_tag);
44 
45  // loop on cell nodes
46  while (cellnode) {
47  unsigned int group = 0;
48 
49  // read id
50  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
51 
52  // read constant
53  DOMNode* c_node = getChildNode(cellnode, WeightGroup_tag);
54  GetNodeData(c_node, group);
55 
56  // fill record
57  record[detid] = EcalXtalGroupId(group);
58 
59  // get next cell
60  cellnode = cellnode->getNextSibling();
61 
62  while (cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
63  cellnode = cellnode->getNextSibling();
64  }
65 
66  delete parser;
68  return 0;
69 }

References xuti::Cell_tag(), gather_cfg::cout, corrVsCorr::filename, xuti::getChildNode(), xuti::GetNodeData(), watchdog::group, RecoTauValidation_cfi::header, writedatasetfile::parser, xuti::readCellId(), xuti::readHeader(), AlCaHarvesting_cff::record, xuti::WeightGroup_tag(), cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

◆ writeXML()

int EcalWeightGroupXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalWeightXtalGroups record 
)
static
xuti::getChildNode
xercesc::DOMNode * getChildNode(xercesc::DOMNode *node, const std::string &nodename)
get the child of
submitPVValidationJobs.dump
dump
Definition: submitPVValidationJobs.py:55
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
boostedTaus_cff.doc
doc
Definition: boostedTaus_cff.py:20
EEDetId::unhashIndex
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
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
EcalWeightGroupXMLTranslator::dumpXML
static std::string dumpXML(const EcalCondHeader &header, const EcalWeightXtalGroups &record)
Definition: EcalWeightGroupXMLTranslator.cc:84
writedatasetfile.parser
parser
Definition: writedatasetfile.py:7
cscNeutronWriter_cfi.writer
writer
Definition: cscNeutronWriter_cfi.py:6
EcalXtalGroupId
Definition: EcalXtalGroupId.h:11
DetId
Definition: DetId.h:17
cms::xerces::toString
std::string toString(XMLCh const *toTranscode)
Definition: XercesStrUtils.h:35
xuti::WriteNodeWithValue
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
Definition: DOMHelperFunctions.h:46
EEDetId::kSizeForDenseIndexing
Definition: EEDetId.h:329
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
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:31
AlCaHarvesting_cff.record
record
Definition: AlCaHarvesting_cff.py:42
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
xuti::WeightGroups_tag
const std::string WeightGroups_tag("EcalWeightGroups")
impl
Definition: trackAlgoPriorityOrder.h:18
EBDetId::kSizeForDenseIndexing
Definition: EBDetId.h:155
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:291
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::WeightGroup_tag
const std::string WeightGroup_tag("EcalWeightGroup")
xuti::GetNodeData
void GetNodeData(xercesc::DOMNode *node, T &value)
get the node data
Definition: DOMHelperFunctions.h:38
watchdog.group
group
Definition: watchdog.py:82