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 80 of file EcalDCSTowerStatusXMLTranslator.cc.

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

80  {
81  unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
82 
83  DOMLSSerializer* writer = impl->createLSSerializer();
84  if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
85  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
86 
87  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr);
88  DOMDocument* doc = impl->createDocument(nullptr, cms::xerces::uStr(DCSTowerStatus_tag.c_str()).ptr(), doctype);
89  DOMElement* root = doc->getDocumentElement();
90 
92  std::cout << " barrel size " << record.barrelItems().size() << std::endl;
93  if (record.barrelItems().empty())
94  return std::string();
95  for (uint cellid = 0; cellid < EcalTrigTowerDetId::kEBTotalTowers; ++cellid) {
96  uint32_t rawid = EcalTrigTowerDetId::detIdFromDenseIndex(cellid);
97  if (record.find(rawid) == record.end())
98  continue;
99  DOMElement* cellnode = writeCell(root, rawid);
100 
101  WriteNodeWithValue(cellnode, DCSStatusCode_tag, record[rawid].getStatusCode());
102  }
103 
104  std::cout << " endcap size " << record.endcapItems().size() << std::endl;
105  if (record.endcapItems().empty())
106  return std::string();
107  for (uint cellid = 0; cellid < EcalTrigTowerDetId::kEETotalTowers; ++cellid) {
108  if (!EcalScDetId::validHashIndex(cellid))
109  continue;
110  uint32_t rawid = EcalScDetId::unhashIndex(cellid);
111 
112  if (record.find(rawid) == record.end())
113  continue;
114  DOMElement* cellnode = writeCell(root, rawid);
115 
116  WriteNodeWithValue(cellnode, DCSStatusCode_tag, record[rawid].getStatusCode());
117  }
118 
119  std::string dump = cms::xerces::toString(writer->writeToString(root));
120  doc->release();
121  doctype->release();
122  writer->release();
123 
124  return dump;
125 }
static constexpr int kEBTotalTowers
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 constexpr int kEETotalTowers
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 127 of file EcalDCSTowerStatusXMLTranslator.cc.

References gather_cfg::cout, EcalTrigTowerDetId::detIdFromDenseIndex(), personalPlayback::fn, groupFilesInBlocks::fout, hcalRecHitTable_cff::ieta, EcalTrigTowerDetId::ieta(), hcalRecHitTable_cff::iphi, EcalTrigTowerDetId::iphi(), EcalScDetId::ix(), ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::endcap::ix(), EcalScDetId::iy(), ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::endcap::iy(), isotrackApplyRegressor::k, EcalTrigTowerDetId::kEBTotalTowers, EcalTrigTowerDetId::kEETotalTowers, mps_splice::line, Hcal_FrontierConditions_cff::record, ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::side(), parallelization::uint, EcalScDetId::unhashIndex(), EcalScDetId::validHashIndex(), and EcalScDetId::zside().

127  {
128  std::ofstream fout(fn.c_str());
129  int valEB[34][72];
130  std::cout << " barrel size " << record.barrelItems().size() << std::endl;
131  if (record.barrelItems().empty())
132  return;
133  for (uint cellid = 0; cellid < EcalTrigTowerDetId::kEBTotalTowers; ++cellid) {
135  if (record.find(rawid) == record.end())
136  continue;
137  int ieta = rawid.ieta();
138  int line = 17 - ieta;
139  if (ieta < 0)
140  line--;
141  int iphi = rawid.iphi() - 1; // 0 to 71
142  valEB[line][iphi] = record[rawid].getStatusCode();
143  }
144  for (int line = 0; line < 34; line++) {
145  for (int iphi = 0; iphi < 72; iphi++)
146  fout << valEB[line][iphi] << " ";
147  fout << std::endl;
148  if (line == 16)
149  fout << std::endl;
150  }
151 
152  std::cout << " endcap size " << record.endcapItems().size() << std::endl;
153  if (record.endcapItems().empty())
154  return;
155  int valEE[2][20][20];
156  for (int k = 0; k < 2; k++)
157  for (int ix = 0; ix < 20; ix++)
158  for (int iy = 0; iy < 20; iy++)
159  valEE[k][ix][iy] = -1;
160  for (uint cellid = 0; cellid < EcalTrigTowerDetId::kEETotalTowers; ++cellid) {
161  if (EcalScDetId::validHashIndex(cellid)) {
162  EcalScDetId rawid = EcalScDetId::unhashIndex(cellid);
163  int ix = rawid.ix() - 1; // 0 to 19
164  int iy = 20 - rawid.iy(); // 0 to 19
165  int side = rawid.zside();
166  int iz = side;
167  if (side == -1)
168  iz = 0;
169  if (ix < 0 || ix > 19)
170  std::cout << " Pb in ix " << ix << std::endl;
171  if (iy < 0 || iy > 19)
172  std::cout << " Pb in iy " << iy << std::endl;
173  valEE[iz][ix][iy] = record[rawid].getStatusCode();
174  }
175  }
176  for (int k = 0; k < 2; k++) {
177  int iz = -1;
178  if (k == 1)
179  iz = 1;
180  fout << " Side : " << iz << std::endl;
181  for (int line = 0; line < 20; line++) {
182  for (int ix = 0; ix < 20; ix++) {
183  if (valEE[k][ix][line] < 0)
184  fout << " . ";
185  else
186  fout << setw(2) << valEE[k][ix][line] << " ";
187  }
188  fout << std::endl;
189  }
190  fout << std::endl;
191  }
192 
193  return;
194 }
static constexpr int kEBTotalTowers
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
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ix(uint32_t id)
static constexpr int kEETotalTowers
static bool validHashIndex(int hi)
Definition: EcalScDetId.h:139
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)
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(), gather_cfg::cout, xuti::DCSStatusCode_tag(), ALCARECOPPSCalTrackBasedSel_cff::detid, corrVsCorr::filename, xuti::getChildNode(), xuti::GetNodeData(), RecoTauValidation_cfi::header, writedatasetfile::parser, xuti::readCellId(), xuti::readHeader(), Hcal_FrontierConditions_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  while (cellnode) {
48  int status = -1;
49  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
50 
51  DOMNode* my_node = getChildNode(cellnode, DCSStatusCode_tag);
52  GetNodeData(my_node, status);
53 
54  record[detid] = status;
55 
56  cellnode = cellnode->getNextSibling();
57 
58  while (cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
59  cellnode = cellnode->getNextSibling();
60  }
61 
62  delete parser;
64  return 0;
65 }
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
const DetId readCellId(xercesc::DOMElement *node)
Assuming.

◆ writeXML()

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