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

#include <EcalPulseSymmCovariancesXMLTranslator.h>

Static Public Member Functions

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

Detailed Description

Translates a EcalGainRatio record to XML and vice versa

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

Definition at line 20 of file EcalPulseSymmCovariancesXMLTranslator.h.

Member Function Documentation

std::string EcalPulseSymmCovariancesXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalPulseSymmCovariances record 
)
static

Definition at line 97 of file EcalPulseSymmCovariancesXMLTranslator.cc.

References EcalCondObjectContainer< T >::barrelItems(), hcal_timing_source_file_cfg::dump, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::endcapItems(), EcalCondObjectContainer< T >::find(), xuti::fromNative(), i, j, relval_2017::k, EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, EBDetId::MIN_HASH, funct::pow(), xuti::PulseSymmCovariances_tag(), pyrootRender::root, AlCaHLTBitMon_QueryRunRegistry::string, EcalPulseShape::TEMPLATESAMPLES, xuti::toNative(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), EEDetId::validHashIndex(), xuti::writeCell(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cms::concurrency::xercesInitialize().

97  {
98 
100  DOMImplementation* impl =
101  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
102 
103  DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
104  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
105 
106  DOMDocumentType* doctype = impl->createDocumentType(fromNative("XML").c_str(), 0, 0 );
107  DOMDocument * doc =
108  impl->createDocument( 0, fromNative(PulseSymmCovariances_tag).c_str(), doctype );
109 
110  doc->setEncoding(fromNative("UTF-8").c_str() );
111  doc->setStandalone(true);
112  doc->setVersion(fromNative("1.0").c_str() );
113 
114  DOMElement* root = doc->getDocumentElement();
115 
116  std::vector<std::string> pulsecov_tag(static_cast<size_t>(std::pow(EcalPulseShape::TEMPLATESAMPLES,2)));
117  for(int k=0; k<std::pow(EcalPulseShape::TEMPLATESAMPLES,2); ++k) {
120  int linK=-1;
121  if(j >= i) linK = j + (EcalPulseShape::TEMPLATESAMPLES-1)*i;
122  else linK = i + (EcalPulseShape::TEMPLATESAMPLES-1)*j;
123  pulsecov_tag[linK] = Form("samplecov_%d_%d",i,j);
124  }
125 
126  xuti::writeHeader(root,header);
127  if (!record.barrelItems().size()) return std::string();
128  for(int cellid = EBDetId::MIN_HASH;
130  ++cellid) {
131  uint32_t rawid = EBDetId::unhashIndex(cellid);
132 
133  if (record.find(rawid) == record.end()) continue;
134 
135  DOMElement* cellnode=writeCell(root,rawid);
136 
137  for(int k=0; k<std::pow(EcalPulseShape::TEMPLATESAMPLES,2); ++k) {
138  WriteNodeWithValue(cellnode,pulsecov_tag[k],record[rawid].covval[k]);
139  }
140 
141  }
142  if (!record.endcapItems().size()) return std::string();
143  for(int cellid = 0;
145  ++cellid) {
146  if(!EEDetId::validHashIndex(cellid)) continue;
147 
148  uint32_t rawid = EEDetId::unhashIndex(cellid);
149 
150  if (record.find(rawid) == record.end()) continue;
151 
152  DOMElement* cellnode=writeCell(root,rawid);
153 
154  for(int k=0; k<std::pow(EcalPulseShape::TEMPLATESAMPLES,2); ++k) {
155  WriteNodeWithValue(cellnode,pulsecov_tag[k],record[rawid].covval[k]);
156  }
157  }
158 
159  std::string dump= toNative(writer->writeToString(*root));
160  doc->release();
161  return dump;
162 }
int i
Definition: DBlmapReader.cc:9
const Items & barrelItems() const
static const int TEMPLATESAMPLES
void xercesInitialize()
Definition: Xerces.cc:17
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:99
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
static const int MIN_HASH
Definition: EBDetId.h:156
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
int j
Definition: DBlmapReader.cc:9
const std::string PulseSymmCovariances_tag("EcalPulseSymmCovariances")
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:114
const_iterator find(uint32_t rawId) const
XercesString fromNative(const char *str)
Definition: XercesString.h:31
const_iterator end() const
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
const Items & endcapItems() const
std::string toNative(const XMLCh *str)
Definition: XercesString.h:42
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
int EcalPulseSymmCovariancesXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalPulseSymmCovariances record 
)
static

Definition at line 24 of file EcalPulseSymmCovariancesXMLTranslator.cc.

References xuti::Cell_tag(), gather_cfg::cout, xuti::getChildNode(), xuti::GetNodeData(), i, j, relval_2017::k, createfilelist::parser, xuti::readCellId(), xuti::readHeader(), EcalPulseShape::TEMPLATESAMPLES, 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 << "EcalPulseSymmCovariancesXMLTranslator::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;
53 
54  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
55  // std::cout << " readCell Id Channel " << chan << " tag " << mean12_tag << std::endl;
56 
57  std::vector<std::string> pulsecov_tag(static_cast<size_t>(EcalPulseShape::TEMPLATESAMPLES*(EcalPulseShape::TEMPLATESAMPLES+1)/2));
58  for(int i=0; i<EcalPulseShape::TEMPLATESAMPLES; ++i) {
59  for(int j=0; j<EcalPulseShape::TEMPLATESAMPLES; ++j) {
60  int k=-1;
61  if(j >= i) k = j + (EcalPulseShape::TEMPLATESAMPLES-1)*i;
62  else k = i + (EcalPulseShape::TEMPLATESAMPLES-1)*j;
63  pulsecov_tag[k] = Form("samplecov_%d_%d",i,j);
64  }
65  }
66 
67  DOMNode** covs_node = new DOMNode*[int(EcalPulseShape::TEMPLATESAMPLES*(EcalPulseShape::TEMPLATESAMPLES+1)/2)];
68  for(int k=0; k<EcalPulseShape::TEMPLATESAMPLES*(EcalPulseShape::TEMPLATESAMPLES+1)/2; ++k) {
69  covs_node[k] = getChildNode(cellnode,pulsecov_tag[k]);
70  GetNodeData(covs_node[k], covs[k]);
71  }
72 
73  for(int k=0; k<EcalPulseShape::TEMPLATESAMPLES*(EcalPulseShape::TEMPLATESAMPLES+1)/2; ++k) record[detid].covval[k] = covs[k];
74 
75  cellnode = cellnode->getNextSibling();
76 
77  while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
78  cellnode = cellnode->getNextSibling();
79  chan++;
80  }
81 
82  delete parser;
84  std::cout << " nb of channels found in xml file " << chan << std::endl;
85  return 0;
86  }
int i
Definition: DBlmapReader.cc:9
void xercesTerminate()
Definition: Xerces.cc:22
static const int TEMPLATESAMPLES
void xercesInitialize()
Definition: Xerces.cc:17
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
const std::string Cell_tag("cell")
int j
Definition: DBlmapReader.cc:9
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
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:145
const DetId readCellId(xercesc::DOMElement *node)
Assuming.
int EcalPulseSymmCovariancesXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalPulseSymmCovariances record 
)
static

Definition at line 88 of file EcalPulseSymmCovariancesXMLTranslator.cc.

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

90  {
91  std::fstream fs(filename.c_str(),ios::out);
92  fs<< dumpXML(header,record);
93  return 0;
94 }
tuple filename
Definition: lut2db_cfg.py:20
static std::string dumpXML(const EcalCondHeader &header, const EcalPulseSymmCovariances &record)