CMS 3D CMS Logo

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

#include <EcalDCSTowerStatusXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

static std::string dumpXML (const EcalCondHeader &header, const EcalDCSTowerStatus &record)
 
static void plot (std::string, const EcalDCSTowerStatus &record)
 

Detailed Description

Translates a EcalGainRatio record to XML and vice versa

Author
Francesco RUBBO
Version
Id
EcalDCSTowerStatusXMLTranslator.h,v 0 2010/06/3 fay Exp
Date
3 Jun 2010

Definition at line 15 of file EcalDCSTowerStatusXMLTranslator.h.

Member Function Documentation

◆ dumpXML()

std::string EcalDCSTowerStatusXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalDCSTowerStatus record 
)
staticprivate

Definition at line 82 of file EcalDCSTowerStatusXMLTranslator.cc.

References gather_cfg::cout, xuti::DCSStatusCode_tag(), xuti::DCSTowerStatus_tag(), EcalTrigTowerDetId::detIdFromDenseIndex(), boostedTaus_cff::doc, submitPVValidationJobs::dump, RecoTauValidation_cfi::header, EcalTrigTowerDetId::kEBTotalTowers, EcalTrigTowerDetId::kEETotalTowers, AlCaHarvesting_cff::record, AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), parallelization::uint, EcalScDetId::unhashIndex(), cms::xerces::uStr(), EcalScDetId::validHashIndex(), xuti::writeCell(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cscNeutronWriter_cfi::writer.

82  {
83  unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
84 
85  DOMLSSerializer* writer = impl->createLSSerializer();
86  if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
87  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
88 
89  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr);
90  DOMDocument* doc = impl->createDocument(nullptr, cms::xerces::uStr(DCSTowerStatus_tag.c_str()).ptr(), doctype);
91  DOMElement* root = doc->getDocumentElement();
92 
94  std::cout << " barrel size " << record.barrelItems().size() << std::endl;
95  if (record.barrelItems().empty())
96  return std::string();
97  for (uint cellid = 0; cellid < EcalTrigTowerDetId::kEBTotalTowers; ++cellid) {
98  uint32_t rawid = EcalTrigTowerDetId::detIdFromDenseIndex(cellid);
99  if (record.find(rawid) == record.end())
100  continue;
101  DOMElement* cellnode = writeCell(root, rawid);
102 
103  WriteNodeWithValue(cellnode, DCSStatusCode_tag, record[rawid].getStatusCode());
104  }
105 
106  std::cout << " endcap size " << record.endcapItems().size() << std::endl;
107  if (record.endcapItems().empty())
108  return std::string();
109  for (uint cellid = 0; cellid < EcalTrigTowerDetId::kEETotalTowers; ++cellid) {
110  if (!EcalScDetId::validHashIndex(cellid))
111  continue;
112  uint32_t rawid = EcalScDetId::unhashIndex(cellid);
113 
114  if (record.find(rawid) == record.end())
115  continue;
116  DOMElement* cellnode = writeCell(root, rawid);
117 
118  WriteNodeWithValue(cellnode, DCSStatusCode_tag, record[rawid].getStatusCode());
119  }
120 
121  std::string dump = cms::xerces::toString(writer->writeToString(root));
122  doc->release();
123  doctype->release();
124  writer->release();
125 
126  return dump;
127 }
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
const std::string DCSTowerStatus_tag("EcalDCSTowerStatus")
static EcalScDetId unhashIndex(int hi)
Definition: EcalScDetId.h:117
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
std::string toString(XMLCh const *toTranscode)
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)
const std::string DCSStatusCode_tag("DCSStatusCode")
static bool validHashIndex(int hi)
Definition: EcalScDetId.h:139
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.

◆ plot()

void EcalDCSTowerStatusXMLTranslator::plot ( std::string  fn,
const EcalDCSTowerStatus record 
)
staticprivate

Definition at line 129 of file EcalDCSTowerStatusXMLTranslator.cc.

References gather_cfg::cout, EcalTrigTowerDetId::detIdFromDenseIndex(), personalPlayback::fn, groupFilesInBlocks::fout, EcalTrigTowerDetId::ieta(), LEDCalibrationChannels::ieta, EcalTrigTowerDetId::iphi(), LEDCalibrationChannels::iphi, EcalScDetId::ix(), EcalScDetId::iy(), dqmdumpme::k, EcalTrigTowerDetId::kEBTotalTowers, EcalTrigTowerDetId::kEETotalTowers, mps_splice::line, AlCaHarvesting_cff::record, parallelization::uint, EcalScDetId::unhashIndex(), EcalScDetId::validHashIndex(), and EcalScDetId::zside().

129  {
130  std::ofstream fout(fn.c_str());
131  int valEB[34][72];
132  std::cout << " barrel size " << record.barrelItems().size() << std::endl;
133  if (record.barrelItems().empty())
134  return;
135  for (uint cellid = 0; cellid < EcalTrigTowerDetId::kEBTotalTowers; ++cellid) {
137  if (record.find(rawid) == record.end())
138  continue;
139  int ieta = rawid.ieta();
140  int line = 17 - ieta;
141  if (ieta < 0)
142  line--;
143  int iphi = rawid.iphi() - 1; // 0 to 71
144  valEB[line][iphi] = record[rawid].getStatusCode();
145  }
146  for (int line = 0; line < 34; line++) {
147  for (int iphi = 0; iphi < 72; iphi++)
148  fout << valEB[line][iphi] << " ";
149  fout << std::endl;
150  if (line == 16)
151  fout << std::endl;
152  }
153 
154  std::cout << " endcap size " << record.endcapItems().size() << std::endl;
155  if (record.endcapItems().empty())
156  return;
157  int valEE[2][20][20];
158  for (int k = 0; k < 2; k++)
159  for (int ix = 0; ix < 20; ix++)
160  for (int iy = 0; iy < 20; iy++)
161  valEE[k][ix][iy] = -1;
162  for (uint cellid = 0; cellid < EcalTrigTowerDetId::kEETotalTowers; ++cellid) {
163  if (EcalScDetId::validHashIndex(cellid)) {
164  EcalScDetId rawid = EcalScDetId::unhashIndex(cellid);
165  int ix = rawid.ix() - 1; // 0 to 19
166  int iy = 20 - rawid.iy(); // 0 to 19
167  int side = rawid.zside();
168  int iz = side;
169  if (side == -1)
170  iz = 0;
171  if (ix < 0 || ix > 19)
172  std::cout << " Pb in ix " << ix << std::endl;
173  if (iy < 0 || iy > 19)
174  std::cout << " Pb in iy " << iy << std::endl;
175  valEE[iz][ix][iy] = record[rawid].getStatusCode();
176  }
177  }
178  for (int k = 0; k < 2; k++) {
179  int iz = -1;
180  if (k == 1)
181  iz = 1;
182  fout << " Side : " << iz << std::endl;
183  for (int line = 0; line < 20; line++) {
184  for (int ix = 0; ix < 20; ix++) {
185  if (valEE[k][ix][line] < 0)
186  fout << " . ";
187  else
188  fout << setw(2) << valEE[k][ix][line] << " ";
189  }
190  fout << std::endl;
191  }
192  fout << std::endl;
193  }
194 
195  return;
196 }
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
int zside() const
Definition: EcalScDetId.h:64
int ieta() const
get the tower ieta
static EcalScDetId unhashIndex(int hi)
Definition: EcalScDetId.h:117
int iy() const
Definition: EcalScDetId.h:76
static bool validHashIndex(int hi)
Definition: EcalScDetId.h:139
int iphi() const
get the tower iphi
int ix() const
Definition: EcalScDetId.h:70

◆ readXML()

int EcalDCSTowerStatusXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalDCSTowerStatus record 
)
static

Definition at line 22 of file EcalDCSTowerStatusXMLTranslator.cc.

References xuti::Cell_tag(), officialStyle::chan, gather_cfg::cout, xuti::DCSStatusCode_tag(), corrVsCorr::filename, xuti::getChildNode(), xuti::GetNodeData(), RecoTauValidation_cfi::header, writedatasetfile::parser, xuti::readCellId(), xuti::readHeader(), AlCaHarvesting_cff::record, mps_update::status, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

24  {
25  std::cout << " DCSTowerStatus should not be filled out from an xml file ..." << std::endl;
27 
28  XercesDOMParser* parser = new XercesDOMParser;
29  parser->setValidationScheme(XercesDOMParser::Val_Never);
30  parser->setDoNamespaces(false);
31  parser->setDoSchema(false);
32 
33  parser->parse(filename.c_str());
34 
35  DOMDocument* xmlDoc = parser->getDocument();
36  if (!xmlDoc) {
37  std::cout << "EcalDCSTowerStatusXMLTranslator::Error parsing document" << std::endl;
38  return -1;
39  }
40 
41  DOMElement* elementRoot = xmlDoc->getDocumentElement();
42 
43  xuti::readHeader(elementRoot, header);
44 
45  DOMNode* cellnode = getChildNode(elementRoot, Cell_tag);
46 
47  int chan = 0;
48  while (cellnode) {
49  int status = -1;
50  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
51 
52  DOMNode* my_node = getChildNode(cellnode, DCSStatusCode_tag);
53  GetNodeData(my_node, status);
54 
55  record[detid] = status;
56 
57  cellnode = cellnode->getNextSibling();
58 
59  while (cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
60  cellnode = cellnode->getNextSibling();
61  chan++;
62  }
63 
64  delete parser;
66  return 0;
67 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
const std::string Cell_tag("cell")
const std::string DCSStatusCode_tag("DCSStatusCode")
Definition: DetId.h:17
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.

◆ writeXML()

int EcalDCSTowerStatusXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalDCSTowerStatus record 
)
static