CMS 3D CMS Logo

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

#include <EcalLaserAPDPNRatiosXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

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

Detailed Description

Translates a EcalLaserAPDPNRatios record to XML and vice versa

Author
Stefano Argiro'
Version
Id
EcalLaserAPDPNRatiosXMLTranslator.h,v 1.1 2009/10/20 13:48:05 argiro Exp
Date
29 Jul 2008

Definition at line 16 of file EcalLaserAPDPNRatiosXMLTranslator.h.

Member Function Documentation

◆ dumpXML()

std::string EcalLaserAPDPNRatiosXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalLaserAPDPNRatios record 
)
staticprivate

Definition at line 109 of file EcalLaserAPDPNRatiosXMLTranslator.cc.

110  {
111  unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
112 
113  DOMLSSerializer* writer = impl->createLSSerializer();
114  if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
115  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
116 
117  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr);
118  DOMDocument* doc = impl->createDocument(nullptr, cms::xerces::uStr(WeightGroups_tag.c_str()).ptr(), doctype);
119  DOMElement* root = doc->getDocumentElement();
120 
122 
123  string Lasertag = "Laser", LMtag = "LM";
124  for (int cellid = 0; cellid < (int)record.getTimeMap().size(); cellid++) {
125  DOMElement* cellnode = doc->createElement(cms::xerces::uStr(Lasertag.c_str()).ptr());
126  root->appendChild(cellnode);
127  stringstream value_s;
128  value_s << cellid;
129  cellnode->setAttribute(cms::xerces::uStr(LMtag.c_str()).ptr(), cms::xerces::uStr(value_s.str().c_str()).ptr());
130 
131  long int t123[3];
132  t123[0] = (record.getTimeMap())[cellid].t1.value();
133  t123[1] = (record.getTimeMap())[cellid].t2.value();
134  t123[2] = (record.getTimeMap())[cellid].t3.value();
135  string Laser_t_tag[3] = {"t1", "t2", "t3"};
136  for (int i = 0; i < 3; i++) {
137  time_t t = t123[i] >> 32;
138  char buf[256];
139  struct tm lt;
140  localtime_r(&t, &lt);
141  strftime(buf, sizeof(buf), "%F %R:%S", &lt);
142  buf[sizeof(buf) - 1] = 0;
143  DOMDocument* subdoc = cellnode->getOwnerDocument();
144  DOMElement* new_node = subdoc->createElement(cms::xerces::uStr(Laser_t_tag[i].c_str()).ptr());
145  cellnode->appendChild(new_node);
146  std::stringstream value_ss;
147  value_ss << t123[i];
148  string newstr = value_ss.str() + " [" + string(buf) + "]";
149  DOMText* tvalue = subdoc->createTextNode(cms::xerces::uStr(newstr.c_str()).ptr());
150  new_node->appendChild(tvalue);
151  }
152  }
153 
154  for (int cellid = EBDetId::MIN_HASH; cellid < EBDetId::kSizeForDenseIndexing; ++cellid) {
155  uint32_t rawid = EBDetId::unhashIndex(cellid);
156 
157  DOMElement* cellnode = writeCell(root, rawid);
158 
159  float p1 = (record.getLaserMap())[rawid].p1;
160  float p2 = (record.getLaserMap())[rawid].p2;
161  float p3 = (record.getLaserMap())[rawid].p3;
162 
163  WriteNodeWithValue(cellnode, Laser_p1_tag, p1);
164  WriteNodeWithValue(cellnode, Laser_p2_tag, p2);
165  WriteNodeWithValue(cellnode, Laser_p3_tag, p3);
166  }
167 
168  for (int cellid = 0; cellid < EEDetId::kSizeForDenseIndexing; ++cellid) {
169  if (!EEDetId::validHashIndex(cellid))
170  continue;
171 
172  uint32_t rawid = EEDetId::unhashIndex(cellid);
173 
174  DOMElement* cellnode = writeCell(root, rawid);
175 
176  float p1 = (record.getLaserMap())[rawid].p1;
177  float p2 = (record.getLaserMap())[rawid].p2;
178  float p3 = (record.getLaserMap())[rawid].p3;
179 
180  WriteNodeWithValue(cellnode, Laser_p1_tag, p1);
181  WriteNodeWithValue(cellnode, Laser_p2_tag, p2);
182  WriteNodeWithValue(cellnode, Laser_p3_tag, p3);
183  }
184 
185  std::string dump = cms::xerces::toString(writer->writeToString(root));
186  doc->release();
187  doctype->release();
188  writer->release();
189 
190  return dump;
191 }

References visDQMUpload::buf, common_cff::doc, FrontierConditions_GlobalTag_cff::dump, RecoTauValidation_cfi::header, mps_fire::i, createfilelist::int, EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, xuti::Laser_p1_tag(), xuti::Laser_p2_tag(), xuti::Laser_p3_tag(), EBDetId::MIN_HASH, p1, p2, p3, GlobalPosition_Frontier_DevDB_cff::record, AlCaHLTBitMon_QueryRunRegistry::string, OrderedSet::t, RandomServiceHelper::t1, RandomServiceHelper::t2, RandomServiceHelper::t3, cms::xerces::toString(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), cms::xerces::uStr(), EEDetId::validHashIndex(), xuti::WeightGroups_tag(), xuti::writeCell(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cscNeutronWriter_cfi::writer.

◆ readXML()

int EcalLaserAPDPNRatiosXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalLaserAPDPNRatios record 
)
static

Definition at line 26 of file EcalLaserAPDPNRatiosXMLTranslator.cc.

28  {
30 
31  XercesDOMParser* parser = new XercesDOMParser;
32  parser->setValidationScheme(XercesDOMParser::Val_Never);
33  parser->setDoNamespaces(false);
34  parser->setDoSchema(false);
35 
36  parser->parse(filename.c_str());
37 
38  DOMDocument* xmlDoc = parser->getDocument();
39  if (!xmlDoc) {
40  std::cout << "EcalLaserAPDPNRatiosXMLTranslator::Error parsing document" << std::endl;
41  return -1;
42  }
43 
44  DOMElement* elementRoot = xmlDoc->getDocumentElement();
45 
46  xuti::readHeader(elementRoot, header);
47 
48  DOMNode* cellnode = getChildNode(elementRoot, Cell_tag);
49 
50  while (cellnode) {
51  float p1 = 0;
52  float p2 = 0;
53  float p3 = 0;
54  // edm::TimeStamp t1=0;
55  // edm::TimeStamp t2=0;
56  // edm::TimeStamp t3=0;
57 
58  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
59 
60  DOMNode* p1_node = getChildNode(cellnode, Laser_p1_tag);
61  GetNodeData(p1_node, p1);
62 
63  DOMNode* p2_node = getChildNode(cellnode, Laser_p2_tag);
64  GetNodeData(p2_node, p2);
65 
66  DOMNode* p3_node = getChildNode(cellnode, Laser_p3_tag);
67  GetNodeData(p3_node, p3);
68 
69  // DOMNode* t1_node = getChildNode(cellnode,Laser_t1_tag);
70  // GetNodeData(t1_node,t1);
71 
72  // DOMNode* t2_node = getChildNode(cellnode,Laser_t2_tag);
73  // GetNodeData(t3_node,t2);
74 
75  // DOMNode* p1_node = getChildNode(cellnode,Laser_t3_tag);
76  // GetNodeData(t3_node,t3);
77 
79  pair.p1 = p1;
80  pair.p2 = p2;
81  pair.p3 = p3;
82 
83  record.setValue(detid, pair);
84 
85  cellnode = cellnode->getNextSibling();
86 
87  while (cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
88  cellnode = cellnode->getNextSibling();
89  }
90 
91  delete parser;
93  return 0;
94 }

References xuti::Cell_tag(), gather_cfg::cout, corrVsCorr::filename, xuti::getChildNode(), xuti::GetNodeData(), RecoTauValidation_cfi::header, xuti::Laser_p1_tag(), xuti::Laser_p2_tag(), xuti::Laser_p3_tag(), EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p1, p1, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p2, p2, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p3, p3, writedatasetfile::parser, xuti::readCellId(), xuti::readHeader(), GlobalPosition_Frontier_DevDB_cff::record, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

◆ writeXML()

int EcalLaserAPDPNRatiosXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalLaserAPDPNRatios record 
)
static
xuti::getChildNode
xercesc::DOMNode * getChildNode(xercesc::DOMNode *node, const std::string &nodename)
get the child of
EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p1
float p1
Definition: EcalLaserAPDPNRatios.h:18
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
common_cff.doc
doc
Definition: common_cff.py:54
mps_fire.i
i
Definition: mps_fire.py:355
xuti::Laser_p3_tag
const std::string Laser_p3_tag("p3")
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::Laser_p2_tag
const std::string Laser_p2_tag("p2")
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::Laser_p1_tag
const std::string Laser_p1_tag("p1")
DetId
Definition: DetId.h:17
cms::xerces::toString
std::string toString(XMLCh const *toTranscode)
Definition: XercesStrUtils.h:34
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
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
p2
double p2[4]
Definition: TauolaWrapper.h:90
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
OrderedSet.t
t
Definition: OrderedSet.py:90
RandomServiceHelper.t3
t3
Definition: RandomServiceHelper.py:258
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalLaserAPDPNRatiosXMLTranslator::dumpXML
static std::string dumpXML(const EcalCondHeader &header, const EcalLaserAPDPNRatios &record)
Definition: EcalLaserAPDPNRatiosXMLTranslator.cc:109
EcalLaserAPDPNRatios::EcalLaserAPDPNpair
Definition: EcalLaserAPDPNRatios.h:16
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
p1
double p1[4]
Definition: TauolaWrapper.h:89
cms::xerces::uStr
ZStr< XMLCh > uStr(char const *str)
Definition: XercesStrUtils.h:30
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
xuti::WeightGroups_tag
const std::string WeightGroups_tag("EcalWeightGroups")
impl
Definition: trackAlgoPriorityOrder.h:18
EBDetId::kSizeForDenseIndexing
Definition: EBDetId.h:155
p3
double p3[4]
Definition: TauolaWrapper.h:91
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")
EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p2
float p2
Definition: EcalLaserAPDPNRatios.h:19
xuti::GetNodeData
void GetNodeData(xercesc::DOMNode *node, T &value)
get the node data
Definition: DOMHelperFunctions.h:38
EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p3
float p3
Definition: EcalLaserAPDPNRatios.h:20