CMS 3D CMS Logo

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

#include <EcalPedestalsXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

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

Detailed Description

Translates a EcalGainRatio record to XML and vice versa

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

Definition at line 15 of file EcalPedestalsXMLTranslator.h.

Member Function Documentation

std::string EcalPedestalsXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalPedestals record 
)
staticprivate

Definition at line 120 of file EcalPedestalsXMLTranslator.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, xuti::mean12_tag(), xuti::mean1_tag(), xuti::mean6_tag(), EBDetId::MIN_HASH, xuti::Pedestals_tag(), xuti::rms12_tag(), xuti::rms1_tag(), xuti::rms6_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.

120  {
121 
122  unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
123 
124  DOMLSSerializer* writer = impl->createLSSerializer();
125  if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
126  writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );
127 
128  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr );
129  DOMDocument * doc =
130  impl->createDocument( nullptr, cms::xerces::uStr(Pedestals_tag.c_str()).ptr(), doctype );
131 
132  DOMElement* root = doc->getDocumentElement();
133 
134  xuti::writeHeader(root,header);
135  if (record.barrelItems().empty()) return std::string();
136  for(int cellid = EBDetId::MIN_HASH;
138  ++cellid) {
139  uint32_t rawid = EBDetId::unhashIndex(cellid);
140 
141  if (record.find(rawid) == record.end()) continue;
142  if(!record[rawid].mean_x12 && !record[rawid].rms_x12) continue;
143 
144  DOMElement* cellnode=writeCell(root,rawid);
145 
146  WriteNodeWithValue(cellnode,mean12_tag,record[rawid].mean_x12);
147  WriteNodeWithValue(cellnode,mean6_tag,record[rawid].mean_x6);
148  WriteNodeWithValue(cellnode,mean1_tag,record[rawid].mean_x1);
149  WriteNodeWithValue(cellnode,rms12_tag,record[rawid].rms_x12);
150  WriteNodeWithValue(cellnode,rms6_tag,record[rawid].rms_x6);
151  WriteNodeWithValue(cellnode,rms1_tag,record[rawid].rms_x1);
152  }
153 
154  if (record.endcapItems().empty()) return std::string();
155  for(int cellid = 0;
157  ++cellid) {
158  if(!EEDetId::validHashIndex(cellid)) continue;
159 
160  uint32_t rawid = EEDetId::unhashIndex(cellid);
161 
162  if (record.find(rawid) == record.end()) continue;
163  if(!record[rawid].mean_x12 && !record[rawid].rms_x12) continue;
164 
165  DOMElement* cellnode=writeCell(root,rawid);
166 
167  WriteNodeWithValue(cellnode,mean12_tag,record[rawid].mean_x12);
168  WriteNodeWithValue(cellnode,mean6_tag,record[rawid].mean_x6);
169  WriteNodeWithValue(cellnode,mean1_tag,record[rawid].mean_x1);
170  WriteNodeWithValue(cellnode,rms12_tag,record[rawid].rms_x12);
171  WriteNodeWithValue(cellnode,rms6_tag,record[rawid].rms_x6);
172  WriteNodeWithValue(cellnode,rms1_tag,record[rawid].rms_x1);
173  }
174 
175  std::string dump = cms::xerces::toString(writer->writeToString( root ));
176  doc->release();
177  doctype->release();
178  writer->release();
179 
180  return dump;
181 }
const std::string mean12_tag("mean_x12")
const Items & barrelItems() const
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
const std::string mean1_tag("mean_x1")
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
const std::string Pedestals_tag("EcalPedestals")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)
const std::string mean6_tag("mean_x6")
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 std::string rms12_tag("rms_x12")
const std::string rms6_tag("rms_x6")
const_iterator end() const
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
const Items & endcapItems() const
const std::string rms1_tag("rms_x1")
int EcalPedestalsXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalPedestals record 
)
static

Definition at line 24 of file EcalPedestalsXMLTranslator.cc.

References xuti::Cell_tag(), officialStyle::chan, gather_cfg::cout, xuti::getChildNode(), xuti::GetNodeData(), xuti::mean12_tag(), xuti::mean1_tag(), xuti::mean6_tag(), writedatasetfile::parser, xuti::readCellId(), xuti::readHeader(), xuti::rms12_tag(), xuti::rms1_tag(), xuti::rms6_tag(), cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

26  {
27 
29 
30  XercesDOMParser* parser = new XercesDOMParser;
31  parser->setValidationScheme( XercesDOMParser::Val_Never );
32  parser->setDoNamespaces( false );
33  parser->setDoSchema( false );
34 
35  parser->parse(filename.c_str());
36 
37  DOMDocument* xmlDoc = parser->getDocument();
38  if (!xmlDoc) {
39  std::cout << "EcalPedestalsXMLTranslator::Error parsing document" << std::endl;
40  return -1;
41  }
42 
43  DOMElement* elementRoot = xmlDoc->getDocumentElement();
44 
45  xuti::readHeader(elementRoot,header);
46 
47  DOMNode * cellnode = getChildNode(elementRoot,Cell_tag);
48 
49  int chan = 0;
50  while(cellnode) {
51  // std::cout << " Channel " << chan << std::endl;
52  float mean12 = 0;
53  float mean6 = 0;
54  float mean1 = 0;
55  float rms12 = 0;
56  float rms6 = 0;
57  float rms1 = 0;
58  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
59  // std::cout << " readCell Id Channel " << chan << " tag " << mean12_tag << std::endl;
60 
61  DOMNode* mean12_node = getChildNode(cellnode,mean12_tag);
62  GetNodeData(mean12_node,mean12);
63  // std::cout << " tag " << mean12_tag << " mean12 " << mean12 << std::endl;
64 
65  DOMNode* mean6_node = getChildNode(cellnode,mean6_tag);
66  GetNodeData(mean6_node,mean6);
67  // std::cout << " tag " << mean6_tag << " mean6 " << mean6 << std::endl;
68 
69  DOMNode* mean1_node = getChildNode(cellnode,mean1_tag);
70  GetNodeData(mean1_node,mean1);
71  // std::cout << " tag " << mean1_tag << " mean1 " << mean1 << std::endl;
72 
73  DOMNode* rms12_node = getChildNode(cellnode,rms12_tag);
74  GetNodeData(rms12_node,rms12);
75  // std::cout << " tag 12 " << rms12_tag << " rms 12 " << rms12 << std::endl;
76 
77  DOMNode* rms6_node = getChildNode(cellnode,rms6_tag);
78  GetNodeData(rms6_node,rms6);
79  // std::cout << " tag 6 " << rms6_tag << " rms 6 " << rms6 << std::endl;
80 
81  DOMNode* rms1_node = getChildNode(cellnode,rms1_tag);
82  // std::cout << " tag 1 " << rms1_tag << std::endl;
83 
84  GetNodeData(rms1_node,rms1);
85  // std::cout << " Channel " << chan << " mean12 " << mean12 << " rms 1 " << rms1 << std::endl;
86  record[detid].mean_x12 = mean12;
87  record[detid].mean_x6 = mean6;
88  record[detid].mean_x1 = mean1;
89  record[detid].rms_x12 = rms12;
90  record[detid].rms_x6 = rms6;
91  record[detid].rms_x1 = rms1;
92 
93  cellnode = cellnode->getNextSibling();
94 
95  while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
96  cellnode = cellnode->getNextSibling();
97  chan++;
98  }
99 
100  delete parser;
102  std::cout << " nb of channels found in xml file " << chan << std::endl;
103  return 0;
104  }
const std::string mean12_tag("mean_x12")
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
const std::string mean1_tag("mean_x1")
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
const std::string Cell_tag("cell")
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
const std::string mean6_tag("mean_x6")
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
const std::string rms12_tag("rms_x12")
const std::string rms6_tag("rms_x6")
const std::string rms1_tag("rms_x1")
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
int EcalPedestalsXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalPedestals record 
)
static

Definition at line 106 of file EcalPedestalsXMLTranslator.cc.

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

108  {
110 
111  std::fstream fs(filename.c_str(),ios::out);
112  fs<< dumpXML(header,record);
113 
115 
116  return 0;
117 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
static std::string dumpXML(const EcalCondHeader &header, const EcalPedestals &record)