CMS 3D CMS Logo

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

#include <EcalPulseShapesXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

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

Detailed Description

Translates a EcalGainRatio record to XML and vice versa

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

Definition at line 15 of file EcalPulseShapesXMLTranslator.h.

Member Function Documentation

std::string EcalPulseShapesXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalPulseShapes record 
)
staticprivate

Definition at line 132 of file EcalPulseShapesXMLTranslator.cc.

References EcalCondObjectContainer< T >::barrelItems(), boostedTaus_cff::doc, FrontierConditions_GlobalTag_cff::dump, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::endcapItems(), EcalCondObjectContainer< T >::find(), EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, EBDetId::MIN_HASH, xuti::PulseShapes_tag(), xuti::sample0_tag(), xuti::sample10_tag(), xuti::sample11_tag(), xuti::sample1_tag(), xuti::sample2_tag(), xuti::sample3_tag(), xuti::sample4_tag(), xuti::sample5_tag(), xuti::sample6_tag(), xuti::sample7_tag(), xuti::sample8_tag(), xuti::sample9_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.

132  {
133 
134  unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
135 
136  DOMLSSerializer* writer = impl->createLSSerializer();
137  if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
138  writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );
139 
140  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr );
141  DOMDocument * doc =
142  impl->createDocument( nullptr, cms::xerces::uStr(PulseShapes_tag.c_str()).ptr(), doctype );
143 
144  DOMElement* root = doc->getDocumentElement();
145 
146  xuti::writeHeader(root,header);
147  if (record.barrelItems().empty()) return std::string();
148  for(int cellid = EBDetId::MIN_HASH;
150  ++cellid) {
151  uint32_t rawid = EBDetId::unhashIndex(cellid);
152 
153  if (record.find(rawid) == record.end()) continue;
154  if(!record[rawid].pdfval[5]) continue;
155 
156  DOMElement* cellnode=writeCell(root,rawid);
157 
158  WriteNodeWithValue(cellnode,sample0_tag,record[rawid].pdfval[0]);
159  WriteNodeWithValue(cellnode,sample1_tag,record[rawid].pdfval[1]);
160  WriteNodeWithValue(cellnode,sample2_tag,record[rawid].pdfval[2]);
161  WriteNodeWithValue(cellnode,sample3_tag,record[rawid].pdfval[3]);
162  WriteNodeWithValue(cellnode,sample4_tag,record[rawid].pdfval[4]);
163  WriteNodeWithValue(cellnode,sample5_tag,record[rawid].pdfval[5]);
164  WriteNodeWithValue(cellnode,sample6_tag,record[rawid].pdfval[6]);
165  WriteNodeWithValue(cellnode,sample7_tag,record[rawid].pdfval[7]);
166  WriteNodeWithValue(cellnode,sample8_tag,record[rawid].pdfval[8]);
167  WriteNodeWithValue(cellnode,sample9_tag,record[rawid].pdfval[9]);
168  WriteNodeWithValue(cellnode,sample10_tag,record[rawid].pdfval[10]);
169  WriteNodeWithValue(cellnode,sample11_tag,record[rawid].pdfval[11]);
170 
171  }
172 
173  if (record.endcapItems().empty()) return std::string();
174  for(int cellid = 0;
176  ++cellid) {
177  if(!EEDetId::validHashIndex(cellid)) continue;
178 
179  uint32_t rawid = EEDetId::unhashIndex(cellid);
180 
181  if (record.find(rawid) == record.end()) continue;
182  if(!record[rawid].pdfval[5]) continue;
183 
184  DOMElement* cellnode=writeCell(root,rawid);
185 
186  WriteNodeWithValue(cellnode,sample0_tag,record[rawid].pdfval[0]);
187  WriteNodeWithValue(cellnode,sample1_tag,record[rawid].pdfval[1]);
188  WriteNodeWithValue(cellnode,sample2_tag,record[rawid].pdfval[2]);
189  WriteNodeWithValue(cellnode,sample3_tag,record[rawid].pdfval[3]);
190  WriteNodeWithValue(cellnode,sample4_tag,record[rawid].pdfval[4]);
191  WriteNodeWithValue(cellnode,sample5_tag,record[rawid].pdfval[5]);
192  WriteNodeWithValue(cellnode,sample6_tag,record[rawid].pdfval[6]);
193  WriteNodeWithValue(cellnode,sample7_tag,record[rawid].pdfval[7]);
194  WriteNodeWithValue(cellnode,sample8_tag,record[rawid].pdfval[8]);
195  WriteNodeWithValue(cellnode,sample9_tag,record[rawid].pdfval[9]);
196  WriteNodeWithValue(cellnode,sample10_tag,record[rawid].pdfval[10]);
197  WriteNodeWithValue(cellnode,sample11_tag,record[rawid].pdfval[11]);
198 
199  }
200 
201  std::string dump = cms::xerces::toString(writer->writeToString( root ));
202  doc->release();
203  doctype->release();
204  writer->release();
205 
206  return dump;
207 }
const std::string sample9_tag("sample_9")
const std::string sample10_tag("sample_10")
const std::string sample0_tag("sample_0")
const std::string PulseShapes_tag("EcalPulseShapes")
const std::string sample2_tag("sample_2")
const Items & barrelItems() const
const std::string sample11_tag("sample_11")
const std::string sample5_tag("sample_5")
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
const std::string sample7_tag("sample_7")
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)
const std::string sample3_tag("sample_3")
static const int MIN_HASH
Definition: EBDetId.h:149
const std::string sample8_tag("sample_8")
const std::string sample1_tag("sample_1")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
const_iterator find(uint32_t rawId) const
const_iterator end() const
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
const std::string sample6_tag("sample_6")
const Items & endcapItems() const
const std::string sample4_tag("sample_4")
int EcalPulseShapesXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalPulseShapes record 
)
static

Definition at line 22 of file EcalPulseShapesXMLTranslator.cc.

References xuti::Cell_tag(), officialStyle::chan, gather_cfg::cout, xuti::getChildNode(), xuti::GetNodeData(), writedatasetfile::parser, xuti::readCellId(), xuti::readHeader(), alignCSCRings::s, xuti::sample0_tag(), xuti::sample10_tag(), xuti::sample11_tag(), xuti::sample1_tag(), xuti::sample2_tag(), xuti::sample3_tag(), xuti::sample4_tag(), xuti::sample5_tag(), xuti::sample6_tag(), xuti::sample7_tag(), xuti::sample8_tag(), xuti::sample9_tag(), hcalTTPDigis_cfi::samples, EcalPulseShape::TEMPLATESAMPLES, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

24  {
25 
27 
28  XercesDOMParser* parser = new XercesDOMParser;
29  parser->setValidationScheme( XercesDOMParser::Val_Never );
30  parser->setDoNamespaces( false );
31  parser->setDoSchema( false );
32 
33  parser->parse(filename.c_str());
34 
35  DOMDocument* xmlDoc = parser->getDocument();
36  if (!xmlDoc) {
37  std::cout << "EcalPulseShapesXMLTranslator::Error parsing document" << std::endl;
38  return -1;
39  }
40 
41  DOMElement* elementRoot = xmlDoc->getDocumentElement();
42 
43  xuti::readHeader(elementRoot,header);
44 
45  DOMNode * cellnode = getChildNode(elementRoot,Cell_tag);
46 
47  int chan = 0;
48  while(cellnode) {
49  // std::cout << " Channel " << chan << std::endl;
51 
52  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
53  // std::cout << " readCell Id Channel " << chan << " tag " << mean12_tag << std::endl;
54 
55  DOMNode* sample0_node = getChildNode(cellnode,sample0_tag);
56  GetNodeData(sample0_node,samples[0]);
57  // std::cout << " tag " << sample0_tag << " sample0 " << sample0 << std::endl;
58 
59  DOMNode* sample1_node = getChildNode(cellnode,sample1_tag);
60  GetNodeData(sample1_node,samples[1]);
61  // std::cout << " tag " << sample1_tag << " sample1 " << sample1 << std::endl;
62 
63  DOMNode* sample2_node = getChildNode(cellnode,sample2_tag);
64  GetNodeData(sample2_node,samples[2]);
65  // std::cout << " tag " << sample2_tag << " sample2 " << sample2 << std::endl;
66 
67  DOMNode* sample3_node = getChildNode(cellnode,sample3_tag);
68  GetNodeData(sample3_node,samples[3]);
69  // std::cout << " tag " << sample3_tag << " sample3 " << sample3 << std::endl;
70 
71  DOMNode* sample4_node = getChildNode(cellnode,sample4_tag);
72  GetNodeData(sample4_node,samples[4]);
73  // std::cout << " tag " << sample4_tag << " sample4 " << sample4 << std::endl;
74 
75  DOMNode* sample5_node = getChildNode(cellnode,sample5_tag);
76  GetNodeData(sample5_node,samples[5]);
77  // std::cout << " tag " << sample5_tag << " sample5 " << sample5 << std::endl;
78 
79  DOMNode* sample6_node = getChildNode(cellnode,sample6_tag);
80  GetNodeData(sample6_node,samples[6]);
81  // std::cout << " tag " << sample6_tag << " sample6 " << sample6 << std::endl;
82 
83  DOMNode* sample7_node = getChildNode(cellnode,sample7_tag);
84  GetNodeData(sample7_node,samples[7]);
85  // std::cout << " tag " << sample7_tag << " sample7 " << sample7 << std::endl;
86 
87  DOMNode* sample8_node = getChildNode(cellnode,sample8_tag);
88  GetNodeData(sample8_node,samples[8]);
89  // std::cout << " tag " << sample8_tag << " sample8 " << sample8 << std::endl;
90 
91  DOMNode* sample9_node = getChildNode(cellnode,sample9_tag);
92  GetNodeData(sample9_node,samples[9]);
93  // std::cout << " tag " << sample9_tag << " sample9 " << sample9 << std::endl;
94 
95  DOMNode* sample10_node = getChildNode(cellnode,sample10_tag);
96  GetNodeData(sample10_node,samples[10]);
97  // std::cout << " tag " << sample10_tag << " sample10 " << sample10 << std::endl;
98 
99  DOMNode* sample11_node = getChildNode(cellnode,sample11_tag);
100  GetNodeData(sample11_node,samples[11]);
101  // std::cout << " tag " << sample11_tag << " sample11 " << sample11 << std::endl;
102 
103  for(int s = 0; s<EcalPulseShape::TEMPLATESAMPLES; ++s) record[detid].pdfval[s] = samples[s];
104 
105  cellnode = cellnode->getNextSibling();
106 
107  while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
108  cellnode = cellnode->getNextSibling();
109  chan++;
110  }
111 
112  delete parser;
114  std::cout << " nb of channels found in xml file " << chan << std::endl;
115  return 0;
116  }
const std::string sample9_tag("sample_9")
const std::string sample10_tag("sample_10")
const std::string sample0_tag("sample_0")
const std::string sample2_tag("sample_2")
void xercesTerminate()
Definition: Xerces.cc:23
static const int TEMPLATESAMPLES
const std::string sample11_tag("sample_11")
const std::string sample5_tag("sample_5")
void xercesInitialize()
Definition: Xerces.cc:18
const std::string sample7_tag("sample_7")
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
const std::string sample3_tag("sample_3")
const std::string Cell_tag("cell")
const std::string sample8_tag("sample_8")
const std::string sample1_tag("sample_1")
Definition: DetId.h:18
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 std::string sample6_tag("sample_6")
const std::string sample4_tag("sample_4")
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
int EcalPulseShapesXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalPulseShapes record 
)
static

Definition at line 118 of file EcalPulseShapesXMLTranslator.cc.

References EcalCondTools::dumpXML(), MillePedeFileConverter_cfg::out, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

120  {
122 
123  std::fstream fs(filename.c_str(),ios::out);
124  fs<< dumpXML(header,record);
125 
127 
128  return 0;
129 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
static std::string dumpXML(const EcalCondHeader &header, const EcalPulseShapes &record)