CMS 3D CMS Logo

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

#include <EcalPulseSymmCovariancesXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

static std::string dumpXML (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 15 of file EcalPulseSymmCovariancesXMLTranslator.h.

Member Function Documentation

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

Definition at line 103 of file EcalPulseSymmCovariancesXMLTranslator.cc.

References EcalCondObjectContainer< T >::barrelItems(), boostedTaus_cff::doc, FrontierConditions_GlobalTag_cff::dump, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::endcapItems(), EcalCondObjectContainer< T >::find(), mps_fire::i, gen::k, EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, EBDetId::MIN_HASH, funct::pow(), xuti::PulseSymmCovariances_tag(), AlCaHLTBitMon_QueryRunRegistry::string, EcalPulseShape::TEMPLATESAMPLES, cms::xerces::toString(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), cms::xerces::uStr(), EEDetId::validHashIndex(), xuti::writeCell(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cscNeutronWriter_cfi::writer.

103  {
104 
105  unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
106 
107  DOMLSSerializer* writer = impl->createLSSerializer();
108  if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
109  writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );
110 
111  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr );
112  DOMDocument * doc =
113  impl->createDocument( nullptr, cms::xerces::uStr(PulseSymmCovariances_tag.c_str()).ptr(), doctype );
114 
115  DOMElement* root = doc->getDocumentElement();
116 
117  std::vector<std::string> pulsecov_tag(static_cast<size_t>(std::pow(EcalPulseShape::TEMPLATESAMPLES,2)));
118  for(int k=0; k<std::pow(EcalPulseShape::TEMPLATESAMPLES,2); ++k) {
121  int linK=-1;
122  if(j >= i) linK = j + (EcalPulseShape::TEMPLATESAMPLES-1)*i;
123  else linK = i + (EcalPulseShape::TEMPLATESAMPLES-1)*j;
124  pulsecov_tag[linK] = Form("samplecov_%d_%d",i,j);
125  }
126 
127  xuti::writeHeader(root,header);
128  if (record.barrelItems().empty()) return std::string();
129  for(int cellid = EBDetId::MIN_HASH;
131  ++cellid) {
132  uint32_t rawid = EBDetId::unhashIndex(cellid);
133 
134  if (record.find(rawid) == record.end()) continue;
135 
136  DOMElement* cellnode=writeCell(root,rawid);
137 
138  for(int k=0; k<std::pow(EcalPulseShape::TEMPLATESAMPLES,2); ++k) {
139  WriteNodeWithValue(cellnode,pulsecov_tag[k],record[rawid].covval[k]);
140  }
141 
142  }
143  if (record.endcapItems().empty()) return std::string();
144  for(int cellid = 0;
146  ++cellid) {
147  if(!EEDetId::validHashIndex(cellid)) continue;
148 
149  uint32_t rawid = EEDetId::unhashIndex(cellid);
150 
151  if (record.find(rawid) == record.end()) continue;
152 
153  DOMElement* cellnode=writeCell(root,rawid);
154 
155  for(int k=0; k<std::pow(EcalPulseShape::TEMPLATESAMPLES,2); ++k) {
156  WriteNodeWithValue(cellnode,pulsecov_tag[k],record[rawid].covval[k]);
157  }
158  }
159 
160  std::string dump = cms::xerces::toString(writer->writeToString( root ));
161  doc->release();
162  doctype->release();
163  writer->release();
164 
165  return dump;
166 }
const Items & barrelItems() const
static const int TEMPLATESAMPLES
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
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
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)
int k[5][pyjets_maxn]
const std::string PulseSymmCovariances_tag("EcalPulseSymmCovariances")
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 Items & endcapItems() const
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 25 of file EcalPulseSymmCovariancesXMLTranslator.cc.

References xuti::Cell_tag(), officialStyle::chan, gather_cfg::cout, xuti::getChildNode(), xuti::GetNodeData(), mps_fire::i, createfilelist::int, gen::k, writedatasetfile::parser, xuti::readCellId(), xuti::readHeader(), EcalPulseShape::TEMPLATESAMPLES, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

27  {
28 
30 
31  XercesDOMParser* parser = new XercesDOMParser;
32  parser->setValidationScheme( XercesDOMParser::Val_Never );
33  parser->setDoNamespaces( false );
34  parser->setDoSchema( false );
35 
36  parser->parse(filename.c_str());
37 
38  DOMDocument* xmlDoc = parser->getDocument();
39  if (!xmlDoc) {
40  std::cout << "EcalPulseSymmCovariancesXMLTranslator::Error parsing document" << std::endl;
41  return -1;
42  }
43 
44  DOMElement* elementRoot = xmlDoc->getDocumentElement();
45 
46  xuti::readHeader(elementRoot,header);
47 
48  DOMNode * cellnode = getChildNode(elementRoot,Cell_tag);
49 
50  int chan = 0;
51  while(cellnode) {
52  // std::cout << " Channel " << chan << std::endl;
54 
55  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
56  // std::cout << " readCell Id Channel " << chan << " tag " << mean12_tag << std::endl;
57 
58  std::vector<std::string> pulsecov_tag(static_cast<size_t>(EcalPulseShape::TEMPLATESAMPLES*(EcalPulseShape::TEMPLATESAMPLES+1)/2));
59  for(int i=0; i<EcalPulseShape::TEMPLATESAMPLES; ++i) {
60  for(int j=0; j<EcalPulseShape::TEMPLATESAMPLES; ++j) {
61  int k=-1;
62  if(j >= i) k = j + (EcalPulseShape::TEMPLATESAMPLES-1)*i;
63  else k = i + (EcalPulseShape::TEMPLATESAMPLES-1)*j;
64  pulsecov_tag[k] = Form("samplecov_%d_%d",i,j);
65  }
66  }
67 
68  DOMNode** covs_node = new DOMNode*[int(EcalPulseShape::TEMPLATESAMPLES*(EcalPulseShape::TEMPLATESAMPLES+1)/2)];
69  for(int k=0; k<EcalPulseShape::TEMPLATESAMPLES*(EcalPulseShape::TEMPLATESAMPLES+1)/2; ++k) {
70  covs_node[k] = getChildNode(cellnode,pulsecov_tag[k]);
71  GetNodeData(covs_node[k], covs[k]);
72  }
73 
74  for(int k=0; k<EcalPulseShape::TEMPLATESAMPLES*(EcalPulseShape::TEMPLATESAMPLES+1)/2; ++k) record[detid].covval[k] = covs[k];
75 
76  cellnode = cellnode->getNextSibling();
77 
78  while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
79  cellnode = cellnode->getNextSibling();
80  chan++;
81  }
82 
83  delete parser;
85  std::cout << " nb of channels found in xml file " << chan << std::endl;
86  return 0;
87  }
void xercesTerminate()
Definition: Xerces.cc:23
static const int TEMPLATESAMPLES
void xercesInitialize()
Definition: Xerces.cc:18
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
const std::string Cell_tag("cell")
int k[5][pyjets_maxn]
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 DetId readCellId(xercesc::DOMElement *node)
Assuming.
int EcalPulseSymmCovariancesXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalPulseSymmCovariances record 
)
static

Definition at line 89 of file EcalPulseSymmCovariancesXMLTranslator.cc.

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

91  {
93 
94  std::fstream fs(filename.c_str(),ios::out);
95  fs<< dumpXML(header,record);
96 
98 
99  return 0;
100 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
static std::string dumpXML(const EcalCondHeader &header, const EcalPulseSymmCovariances &record)