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
EcalFloatCondObjectContainerXMLTranslator Class Reference

#include <EcalFloatCondObjectContainerXMLTranslator.h>

Static Public Member Functions

static std::vector< float > barrelfromXML (const std::string &filename)
 
static std::string dumpXML (const EcalCondHeader &header, const EcalFloatCondObjectContainer &record)
 
static std::vector< float > endcapfromXML (const std::string &filename)
 
static int readXML (const std::string &filename, EcalCondHeader &header, EcalFloatCondObjectContainer &record)
 
static int writeXML (const std::string &filename, const EcalCondHeader &header, const EcalFloatCondObjectContainer &record)
 

Detailed Description

Translates a EcalFloatCondObjectContainer record to XML and vice versa

Author
Stefano ARGIRO
Version
Id:
EcalFloatCondObjectContainerXMLTranslator.h,v 1.2 2009/07/09 10:23:31 argiro Exp
Date
20 Jun 2008

Definition at line 21 of file EcalFloatCondObjectContainerXMLTranslator.h.

Member Function Documentation

std::vector< float > EcalFloatCondObjectContainerXMLTranslator::barrelfromXML ( const std::string &  filename)
static

Definition at line 86 of file EcalFloatCondObjectContainerXMLTranslator.cc.

References EcalCondObjectContainer< T >::barrelItems(), insertMaterial::readXML(), and record.

Referenced by BOOST_PYTHON_MODULE().

86  {
87  EcalCondHeader header;
89  readXML(filename,header,record);
90 
91  return record.barrelItems();
92 
93 }
JetCorrectorParameters::Record record
Definition: classes.h:11
const Items & barrelItems() const
static int readXML(const std::string &filename, EcalCondHeader &header, EcalFloatCondObjectContainer &record)
tuple filename
Definition: lut2db_cfg.py:20
std::string EcalFloatCondObjectContainerXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalFloatCondObjectContainer record 
)
static

Definition at line 108 of file EcalFloatCondObjectContainerXMLTranslator.cc.

References asciidump::doc, ExpressReco_HICollisions_FallBack::dump, xuti::EcalFloatCondObjectContainer_tag(), xuti::fromNative(), EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, EBDetId::MIN_HASH, dbtoconf::root, xuti::toNative(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), EEDetId::validHashIndex(), xuti::Value_tag(), xuti::writeCell(), xuti::writeHeader(), and xuti::WriteNodeWithValue().

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

110  {
111 
112 
113 
114 
115  XMLPlatformUtils::Initialize();
116 
117  DOMImplementation* impl =
118  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
119 
120  DOMWriter* writer =
121  static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
122  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
123 
124  DOMDocumentType* doctype =
125  impl->createDocumentType( fromNative("XML").c_str(), 0, 0 );
126  DOMDocument * doc =
127  impl->createDocument( 0, fromNative(EcalFloatCondObjectContainer_tag).c_str(), doctype );
128 
129 
130  doc->setEncoding(fromNative("UTF-8").c_str() );
131  doc->setStandalone(true);
132  doc->setVersion(fromNative("1.0").c_str() );
133 
134 
135  DOMElement* root = doc->getDocumentElement();
136  xuti::writeHeader(root, header);
137 
138  for (int cellid = EBDetId::MIN_HASH;
140  ++cellid){// loop on EB cells
141 
142  uint32_t rawid= EBDetId::unhashIndex(cellid);
143 
144  if (!record[rawid]) continue; // cell absent from original record
145 
146  DOMElement* cellnode=writeCell(root,rawid);
147 
148  WriteNodeWithValue(cellnode,Value_tag,record[rawid]);
149 
150 
151  } // loop on EB cells
152 
153 
154 
155  for (int cellid = 0;
157  ++cellid){// loop on EE cells
158 
159  if (!EEDetId::validHashIndex(cellid)) continue;
160 
161  uint32_t rawid= EEDetId::unhashIndex(cellid);
162  if (!record[rawid]) continue; // cell absent from original record
163 
164  DOMElement* cellnode= writeCell(root,rawid);
165  WriteNodeWithValue(cellnode,Value_tag,record[rawid]);
166 
167 
168  } // loop on EE cells
169 
170 
171  std::string dump= toNative(writer->writeToString(*root));
172  doc->release();
173  return dump;
174 }
const std::string EcalFloatCondObjectContainer_tag("EcalFloatCondObjectContainer")
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
const std::string Value_tag("Value")
static bool validHashIndex(int i)
Definition: EEDetId.h:234
static const int MIN_HASH
Definition: EBDetId.h:135
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
tuple doc
Definition: asciidump.py:381
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.cc:12
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
string root
initialization
Definition: dbtoconf.py:70
std::vector< float > EcalFloatCondObjectContainerXMLTranslator::endcapfromXML ( const std::string &  filename)
static

Definition at line 97 of file EcalFloatCondObjectContainerXMLTranslator.cc.

References EcalCondObjectContainer< T >::endcapItems(), insertMaterial::readXML(), and record.

Referenced by BOOST_PYTHON_MODULE().

97  {
98  EcalCondHeader header;
100  readXML(filename,header,record);
101 
102  return record.endcapItems();
103 
104 }
JetCorrectorParameters::Record record
Definition: classes.h:11
static int readXML(const std::string &filename, EcalCondHeader &header, EcalFloatCondObjectContainer &record)
tuple filename
Definition: lut2db_cfg.py:20
const Items & endcapItems() const
int EcalFloatCondObjectContainerXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalFloatCondObjectContainer record 
)
static

Definition at line 24 of file EcalFloatCondObjectContainerXMLTranslator.cc.

References xuti::Cell_tag(), gather_cfg::cout, cond::rpcobgas::detid, xuti::getChildNode(), xuti::GetNodeData(), geometryXMLtoCSV::parser, xuti::readCellId(), xuti::readHeader(), and xuti::Value_tag().

Referenced by EcalFloatCondObjectContainerHandler::getNewObjects(), popcon::EcalIntercalibHandler::getNewObjects(), PhiSymmetryCalibration_step2::setUp(), PhiSymmetryCalibration_step2_SM::setUp(), and PhiSymmetryCalibration::setUp().

26  {
27 
28  XMLPlatformUtils::Initialize();
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 
39 
40  if (!xmlDoc) {
41  std::cout << "EcalFloatCondObjectContainerXMLTranslator::Error parsing document" << std::endl;
42  return -1;
43  }
44 
45  DOMElement* elementRoot = xmlDoc->getDocumentElement();
46 
47  xuti::readHeader(elementRoot, header);
48 
49  // get the first cell node
50  DOMNode * cellnode=getChildNode(elementRoot,Cell_tag);
51 
52  // loop on cell nodes
53  while (cellnode){
54 
55  float val=0;
56 
57  // read id
58  DetId detid= readCellId(dynamic_cast<DOMElement*>(cellnode));
59 
60  // read value
61  DOMNode * c_node = getChildNode(cellnode,Value_tag);
62  GetNodeData(c_node,val);
63 
64  // fill record
65  record[detid]=val;
66 
67  // get next cell
68  cellnode= cellnode->getNextSibling();
69 
70  while (cellnode&& cellnode->getNodeType( ) != DOMNode::ELEMENT_NODE)
71  cellnode= cellnode->getNextSibling();
72 
73 
74  }
75 
76 
77  delete parser;
78  XMLPlatformUtils::Terminate();
79  return 0;
80 
81 }
const std::string Value_tag("Value")
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
const std::string Cell_tag("cell")
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
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:41
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
int EcalFloatCondObjectContainerXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalFloatCondObjectContainer record 
)
static

Definition at line 179 of file EcalFloatCondObjectContainerXMLTranslator.cc.

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

Referenced by PhiSymmetryCalibration_step2::endJob(), PhiSymmetryCalibration_step2_SM::endJob(), and main().

181  {
182 
183  std::fstream fs(filename.c_str(),ios::out);
184  fs<< dumpXML(header,record);
185  return 0;
186 }
static std::string dumpXML(const EcalCondHeader &header, const EcalFloatCondObjectContainer &record)
tuple out
Definition: dbtoconf.py:99
tuple filename
Definition: lut2db_cfg.py:20