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.

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 }

References common_cff::doc, FrontierConditions_GlobalTag_cff::dump, RecoTauValidation_cfi::header, mps_fire::i, dqmiolumiharvest::j, dqmdumpme::k, EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, EBDetId::MIN_HASH, funct::pow(), xuti::PulseSymmCovariances_tag(), GlobalPosition_Frontier_DevDB_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 cscNeutronWriter_cfi::writer.

◆ readXML()

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

Definition at line 24 of file EcalPulseSymmCovariancesXMLTranslator.cc.

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 }

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(), GlobalPosition_Frontier_DevDB_cff::record, EcalPulseShape::TEMPLATESAMPLES, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

◆ writeXML()

int EcalPulseSymmCovariancesXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalPulseSymmCovariances record 
)
static
xuti::getChildNode
xercesc::DOMNode * getChildNode(xercesc::DOMNode *node, const std::string &nodename)
get the child of
EcalPulseSymmCovariancesXMLTranslator::dumpXML
static std::string dumpXML(const EcalCondHeader &header, const EcalPulseSymmCovariances &record)
Definition: EcalPulseSymmCovariancesXMLTranslator.cc:105
common_cff.doc
doc
Definition: common_cff.py:54
mps_fire.i
i
Definition: mps_fire.py:428
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
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::PulseSymmCovariances_tag
const std::string PulseSymmCovariances_tag("EcalPulseSymmCovariances")
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
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FrontierConditions_GlobalTag_cff.dump
dump
Definition: FrontierConditions_GlobalTag_cff.py:12
createfilelist.int
int
Definition: createfilelist.py:10
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
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
EcalPulseShape::TEMPLATESAMPLES
static const int TEMPLATESAMPLES
Definition: EcalPulseShapes.h:10
EBDetId::kSizeForDenseIndexing
Definition: EBDetId.h:155
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
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
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
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::GetNodeData
void GetNodeData(xercesc::DOMNode *node, T &value)
get the node data
Definition: DOMHelperFunctions.h:38