CMS 3D CMS Logo

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

#include <EcalPulseSymmCovariancesXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

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

Detailed Description

Translates a EcalGainRatio record to XML and vice versa

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

Definition at line 15 of file EcalPulseSymmCovariancesXMLTranslator.h.

Member Function Documentation

◆ dumpXML()

std::string EcalPulseSymmCovariancesXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalPulseSymmCovariances record 
)
staticprivate

Definition at line 105 of file EcalPulseSymmCovariancesXMLTranslator.cc.

References hcalRecHitTable_cff::doc, GCP_Ntuples_cfg::dump, RecoTauValidation_cfi::header, mps_fire::i, dqmiolumiharvest::j, dqmdumpme::k, EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, EBDetId::MIN_HASH, funct::pow(), xuti::PulseSymmCovariances_tag(), AlCaHarvesting_cff::record, AlCaHLTBitMon_QueryRunRegistry::string, EcalPulseShape::TEMPLATESAMPLES, cms::xerces::toString(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), cms::xerces::uStr(), EEDetId::validHashIndex(), xuti::writeCell(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and convertToRaw::writer.

106  {
107  unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
108 
109  DOMLSSerializer* writer = impl->createLSSerializer();
110  if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
111  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
112 
113  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr);
114  DOMDocument* doc = impl->createDocument(nullptr, cms::xerces::uStr(PulseSymmCovariances_tag.c_str()).ptr(), doctype);
115 
116  DOMElement* root = doc->getDocumentElement();
117 
118  std::vector<std::string> pulsecov_tag(static_cast<size_t>(std::pow(EcalPulseShape::TEMPLATESAMPLES, 2)));
119  for (int k = 0; k < std::pow(EcalPulseShape::TEMPLATESAMPLES, 2); ++k) {
122  int linK = -1;
123  if (j >= i)
124  linK = j + (EcalPulseShape::TEMPLATESAMPLES - 1) * i;
125  else
126  linK = i + (EcalPulseShape::TEMPLATESAMPLES - 1) * j;
127  pulsecov_tag[linK] = Form("samplecov_%d_%d", i, j);
128  }
129 
131  if (record.barrelItems().empty())
132  return std::string();
133  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
134  uint32_t rawid = EBDetId::unhashIndex(cellid);
135 
136  if (record.find(rawid) == record.end())
137  continue;
138 
139  DOMElement* cellnode = writeCell(root, rawid);
140 
141  for (int k = 0; k < std::pow(EcalPulseShape::TEMPLATESAMPLES, 2); ++k) {
142  WriteNodeWithValue(cellnode, pulsecov_tag[k], record[rawid].covval[k]);
143  }
144  }
145  if (record.endcapItems().empty())
146  return std::string();
147  for (int cellid = 0; cellid < EEDetId::kSizeForDenseIndexing; ++cellid) {
148  if (!EEDetId::validHashIndex(cellid))
149  continue;
150 
151  uint32_t rawid = EEDetId::unhashIndex(cellid);
152 
153  if (record.find(rawid) == record.end())
154  continue;
155 
156  DOMElement* cellnode = writeCell(root, rawid);
157 
158  for (int k = 0; k < std::pow(EcalPulseShape::TEMPLATESAMPLES, 2); ++k) {
159  WriteNodeWithValue(cellnode, pulsecov_tag[k], record[rawid].covval[k]);
160  }
161  }
162 
163  std::string dump = cms::xerces::toString(writer->writeToString(root));
164  doc->release();
165  doctype->release();
166  writer->release();
167 
168  return dump;
169 }
static const int TEMPLATESAMPLES
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
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
std::string toString(XMLCh const *toTranscode)
static const int MIN_HASH
Definition: EBDetId.h:149
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)
const std::string PulseSymmCovariances_tag("EcalPulseSymmCovariances")
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ readXML()

int EcalPulseSymmCovariancesXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalPulseSymmCovariances record 
)
static

Definition at line 24 of file EcalPulseSymmCovariancesXMLTranslator.cc.

References xuti::Cell_tag(), officialStyle::chan, gather_cfg::cout, corrVsCorr::filename, xuti::getChildNode(), xuti::GetNodeData(), RecoTauValidation_cfi::header, mps_fire::i, createfilelist::int, dqmiolumiharvest::j, dqmdumpme::k, writedatasetfile::parser, xuti::readCellId(), xuti::readHeader(), AlCaHarvesting_cff::record, EcalPulseShape::TEMPLATESAMPLES, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

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 << "EcalPulseSymmCovariancesXMLTranslator::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;
52 
53  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
54  // std::cout << " readCell Id Channel " << chan << " tag " << mean12_tag << std::endl;
55 
56  std::vector<std::string> pulsecov_tag(
57  static_cast<size_t>(EcalPulseShape::TEMPLATESAMPLES * (EcalPulseShape::TEMPLATESAMPLES + 1) / 2));
58  for (int i = 0; i < EcalPulseShape::TEMPLATESAMPLES; ++i) {
59  for (int j = 0; j < EcalPulseShape::TEMPLATESAMPLES; ++j) {
60  int k = -1;
61  if (j >= i)
63  else
65  pulsecov_tag[k] = Form("samplecov_%d_%d", i, j);
66  }
67  }
68 
69  DOMNode** covs_node =
71  for (int k = 0; k < EcalPulseShape::TEMPLATESAMPLES * (EcalPulseShape::TEMPLATESAMPLES + 1) / 2; ++k) {
72  covs_node[k] = getChildNode(cellnode, pulsecov_tag[k]);
73  GetNodeData(covs_node[k], covs[k]);
74  }
75 
77  record[detid].covval[k] = covs[k];
78 
79  cellnode = cellnode->getNextSibling();
80 
81  while (cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
82  cellnode = cellnode->getNextSibling();
83  chan++;
84  }
85 
86  delete parser;
88  std::cout << " nb of channels found in xml file " << chan << std::endl;
89  return 0;
90 }
void xercesTerminate()
Definition: Xerces.cc:23
static const int TEMPLATESAMPLES
void xercesInitialize()
Definition: Xerces.cc:18
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
const std::string Cell_tag("cell")
Definition: DetId.h:17
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
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
const DetId readCellId(xercesc::DOMElement *node)
Assuming.

◆ writeXML()

int EcalPulseSymmCovariancesXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalPulseSymmCovariances record 
)
static