CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Static Public Member Functions
EcalLaserAPDPNRatiosXMLTranslator Class Reference

#include <EcalLaserAPDPNRatiosXMLTranslator.h>

Static Public Member Functions

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

Detailed Description

Definition at line 25 of file EcalLaserAPDPNRatiosXMLTranslator.h.

Member Function Documentation

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

Definition at line 124 of file EcalLaserAPDPNRatiosXMLTranslator.cc.

References asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::fromNative(), EcalLaserAPDPNRatios::getLaserMap(), EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, xuti::Laser_p1_tag(), xuti::Laser_p2_tag(), xuti::Laser_p3_tag(), xuti::Laser_tag(), EBDetId::MIN_HASH, p1, p2, p3, dbtoconf::root, xuti::toNative(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), EEDetId::validHashIndex(), xuti::writeCell(), xuti::writeHeader(), and xuti::WriteNodeWithValue().

Referenced by cond::PayLoadInspector< DataT >::dump().

126  {
127 
128 
129  XMLPlatformUtils::Initialize();
130 
131  DOMImplementation* impl =
132  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
133 
134  DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
135  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
136 
137  DOMDocumentType* doctype = impl->createDocumentType( fromNative("XML").c_str(), 0, 0 );
138  DOMDocument * doc =
139  impl->createDocument( 0, fromNative(Laser_tag).c_str(), doctype );
140 
141 
142  doc->setEncoding(fromNative("UTF-8").c_str() );
143  doc->setStandalone(true);
144  doc->setVersion(fromNative("1.0").c_str() );
145 
146 
147  DOMElement* root = doc->getDocumentElement();
148 
149  xuti::writeHeader(root,header);
150 
151  for(int cellid = EBDetId::MIN_HASH;
153  ++cellid)
154  {
155 
156  uint32_t rawid = EBDetId::unhashIndex(cellid);
157 
158  DOMElement* cellnode= writeCell(root,rawid);
159 
160  float p1=(record.getLaserMap())[rawid].p1;
161  float p2=(record.getLaserMap())[rawid].p2;
162  float p3=(record.getLaserMap())[rawid].p3;
163 
164 // edm::TimeStamp t1=(record.getTimeMap())[rawid].t1;
165 // edm::TimeStamp t2=(record.getTimeMap())[rawid].t2;
166 // edm::TimeStamp t3=(record.getTimeMap())[rawid].t3;
167 
168  WriteNodeWithValue(cellnode,Laser_p1_tag,p1);
169  WriteNodeWithValue(cellnode,Laser_p2_tag,p2);
170  WriteNodeWithValue(cellnode,Laser_p3_tag,p3);
171 // WriteNodeWithValue(cellnode,Laser_t1_tag,t1);
172 // WriteNodeWithValue(cellnode,Laser_t2_tag,t2);
173 // WriteNodeWithValue(cellnode,Laser_t3_tag,t3);
174 
175  }
176 
177 
178 
179 
180  for(int cellid = 0;
182  ++cellid)
183  {
184 
185  if(!EEDetId::validHashIndex(cellid)) continue;
186 
187  uint32_t rawid = EEDetId::unhashIndex(cellid);
188 
189 
190  DOMElement* cellnode=writeCell(root,rawid);
191 
192  float p1=(record.getLaserMap())[rawid].p1;
193  float p2=(record.getLaserMap())[rawid].p2;
194  float p3=(record.getLaserMap())[rawid].p3;
195 
196 // edm::TimeStamp t1=(record.getTimeMap())[rawid].t1;
197 // edm::TimeStamp t2=(record.getTimeMap())[rawid].t2;
198 // edm::TimeStamp t3=(record.getTimeMap())[rawid].t3;
199 
200  WriteNodeWithValue(cellnode,Laser_p1_tag,p1);
201  WriteNodeWithValue(cellnode,Laser_p2_tag,p2);
202  WriteNodeWithValue(cellnode,Laser_p3_tag,p3);
203 // WriteNodeWithValue(cellnode,Laser_t1_tag,t1);
204 // WriteNodeWithValue(cellnode,Laser_t2_tag,t2);
205 // WriteNodeWithValue(cellnode,Laser_t3_tag,t3);
206 
207 
208 
209  }
210 
211 
212  std::string dump= toNative(writer->writeToString(*root));
213  doc->release();
214  // XMLPlatformUtils::Terminate();
215 
216  return dump;
217 
218 }
const std::string Laser_p3_tag("p3")
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:115
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
static bool validHashIndex(int i)
Definition: EEDetId.h:234
const EcalLaserAPDPNRatiosMap & getLaserMap() const
static const int MIN_HASH
Definition: EBDetId.h:135
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
const std::string Laser_p1_tag("p1")
tuple doc
Definition: asciidump.py:381
double p2[4]
Definition: TauolaWrapper.h:90
const std::string Laser_tag("EcalLaserAPDPNRatios")
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.cc:12
double p1[4]
Definition: TauolaWrapper.h:89
const std::string Laser_p2_tag("p2")
XercesString fromNative(const char *str)
Definition: XercesString.h:31
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
std::string toNative(const XMLCh *str)
Definition: XercesString.h:42
double p3[4]
Definition: TauolaWrapper.h:91
string root
initialization
Definition: dbtoconf.py:70
int EcalLaserAPDPNRatiosXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalLaserAPDPNRatios record 
)
static

Definition at line 31 of file EcalLaserAPDPNRatiosXMLTranslator.cc.

References xuti::Cell_tag(), gather_cfg::cout, cond::rpcobgas::detid, xuti::getChildNode(), xuti::GetNodeData(), xuti::Laser_p1_tag(), xuti::Laser_p2_tag(), xuti::Laser_p3_tag(), EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p1, p1, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p2, p2, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p3, p3, geometryXMLtoCSV::parser, xuti::readCellId(), xuti::readHeader(), and EcalLaserAPDPNRatios::setValue().

33  {
34 
35 
36 
37  XMLPlatformUtils::Initialize();
38 
39  XercesDOMParser* parser = new XercesDOMParser;
40  parser->setValidationScheme( XercesDOMParser::Val_Never );
41  parser->setDoNamespaces( false );
42  parser->setDoSchema( false );
43 
44  parser->parse(filename.c_str());
45 
46  DOMDocument* xmlDoc = parser->getDocument();
47  if (!xmlDoc) {
48  std::cout << "EcalLaserAPDPNRatiosXMLTranslator::Error parsing document" << std::endl;
49  return -1;
50  }
51 
52  DOMElement* elementRoot = xmlDoc->getDocumentElement();
53 
54  xuti::readHeader(elementRoot,header);
55 
56  DOMNode * cellnode = getChildNode(elementRoot,Cell_tag);
57 
58  while(cellnode)
59  {
60  float p1 = 0;
61  float p2 = 0;
62  float p3 = 0;
63 // edm::TimeStamp t1=0;
64 // edm::TimeStamp t2=0;
65 // edm::TimeStamp t3=0;
66 
67 
68  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
69 
70  DOMNode* p1_node = getChildNode(cellnode,Laser_p1_tag);
71  GetNodeData(p1_node,p1);
72 
73  DOMNode* p2_node = getChildNode(cellnode,Laser_p2_tag);
74  GetNodeData(p2_node,p2);
75 
76  DOMNode* p3_node = getChildNode(cellnode,Laser_p3_tag);
77  GetNodeData(p3_node,p3);
78 
79 // DOMNode* t1_node = getChildNode(cellnode,Laser_t1_tag);
80 // GetNodeData(t1_node,t1);
81 
82 // DOMNode* t2_node = getChildNode(cellnode,Laser_t2_tag);
83 // GetNodeData(t3_node,t2);
84 
85 // DOMNode* p1_node = getChildNode(cellnode,Laser_t3_tag);
86 // GetNodeData(t3_node,t3);
87 
88 
90  pair.p1 =p1;
91  pair.p2 =p2;
92  pair.p3 =p3;
93 
94  record.setValue(detid,pair);
95 
96  cellnode = cellnode->getNextSibling();
97 
98  while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
99  cellnode = cellnode->getNextSibling();
100 
101 
102  }
103 
104  delete parser;
105  XMLPlatformUtils::Terminate();
106  return 0;
107 
108 
109 }
const std::string Laser_p3_tag("p3")
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
const std::string Cell_tag("cell")
const std::string Laser_p1_tag("p1")
double p2[4]
Definition: TauolaWrapper.h:90
Definition: DetId.h:20
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
void setValue(uint32_t rawId, const EcalLaserAPDPNpair &value)
double p1[4]
Definition: TauolaWrapper.h:89
tuple filename
Definition: lut2db_cfg.py:20
const std::string Laser_p2_tag("p2")
tuple cout
Definition: gather_cfg.py:121
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
double p3[4]
Definition: TauolaWrapper.h:91
int EcalLaserAPDPNRatiosXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalLaserAPDPNRatios record 
)
static

Definition at line 115 of file EcalLaserAPDPNRatiosXMLTranslator.cc.

References EcalCondTools::dumpXML(), and dbtoconf::out.

117  {
118  std::fstream fs(filename.c_str(),ios::out);
119  fs<< dumpXML(header,record);
120  return 0;
121  }
static std::string dumpXML(const EcalCondHeader &header, const EcalLaserAPDPNRatios &record)
tuple out
Definition: dbtoconf.py:99
tuple filename
Definition: lut2db_cfg.py:20