CMS 3D CMS Logo

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

#include <EcalDAQTowerStatusXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

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

Detailed Description

Translates a EcalGainRatio record to XML and vice versa

Author
Francesco RUBBO
Version
Id
EcalDAQTowerStatusXMLTranslator.h,v 0 2010/05/31 fay Exp
Date
26 Apr 2010

Definition at line 15 of file EcalDAQTowerStatusXMLTranslator.h.

Member Function Documentation

◆ dumpXML()

std::string EcalDAQTowerStatusXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalDAQTowerStatus record 
)
staticprivate

Definition at line 79 of file EcalDAQTowerStatusXMLTranslator.cc.

References gather_cfg::cout, xuti::DAQStatusCode_tag(), xuti::DAQTowerStatus_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.

79  {
80  unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
81 
82  DOMLSSerializer* writer = impl->createLSSerializer();
83  if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
84  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
85 
86  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr);
87  DOMDocument* doc = impl->createDocument(nullptr, cms::xerces::uStr(DAQTowerStatus_tag.c_str()).ptr(), doctype);
88 
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, DAQStatusCode_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, DAQStatusCode_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 DAQTowerStatus_tag("EcalDAQTowerStatus")
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 DAQStatusCode_tag("DAQStatusCode")
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 EcalDAQTowerStatusXMLTranslator::plot ( std::string  fn,
const EcalDAQTowerStatus record 
)
staticprivate

Definition at line 127 of file EcalDAQTowerStatusXMLTranslator.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 << 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 EcalDAQTowerStatusXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalDAQTowerStatus record 
)
static

Definition at line 21 of file EcalDAQTowerStatusXMLTranslator.cc.

References xuti::Cell_tag(), gather_cfg::cout, xuti::DAQStatusCode_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().

23  {
24  std::cout << " DAQTowerStatus should not be filled out from an xml file ..." << std::endl;
26 
27  XercesDOMParser* parser = new XercesDOMParser;
28  parser->setValidationScheme(XercesDOMParser::Val_Never);
29  parser->setDoNamespaces(false);
30  parser->setDoSchema(false);
31 
32  parser->parse(filename.c_str());
33 
34  DOMDocument* xmlDoc = parser->getDocument();
35  if (!xmlDoc) {
36  std::cout << "EcalDAQTowerStatusXMLTranslator::Error parsing document" << std::endl;
37  return -1;
38  }
39 
40  DOMElement* elementRoot = xmlDoc->getDocumentElement();
41 
42  xuti::readHeader(elementRoot, header);
43 
44  DOMNode* cellnode = getChildNode(elementRoot, Cell_tag);
45 
46  while (cellnode) {
47  int status = -1;
48  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
49 
50  DOMNode* my_node = getChildNode(cellnode, DAQStatusCode_tag);
51  GetNodeData(my_node, status);
52 
53  record[detid] = status;
54 
55  cellnode = cellnode->getNextSibling();
56 
57  while (cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
58  cellnode = cellnode->getNextSibling();
59  }
60 
61  delete parser;
63  return 0;
64 }
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 DAQStatusCode_tag("DAQStatusCode")
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 EcalDAQTowerStatusXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalDAQTowerStatus record 
)
static