test
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
EcalDAQTowerStatusXMLTranslator Class Reference

#include <EcalDAQTowerStatusXMLTranslator.h>

Static Public Member Functions

static std::string dumpXML (const EcalCondHeader &header, const EcalDAQTowerStatus &record)
 
static void plot (std::string, const EcalDAQTowerStatus &record)
 
static int readXML (const std::string &filename, EcalCondHeader &header, EcalDAQTowerStatus &record)
 
static int writeXML (const std::string &filename, const EcalCondHeader &header, 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 21 of file EcalDAQTowerStatusXMLTranslator.h.

Member Function Documentation

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

Definition at line 77 of file EcalDAQTowerStatusXMLTranslator.cc.

References EcalCondTowerObjectContainer< T >::barrelItems(), gather_cfg::cout, xuti::DAQStatusCode_tag(), xuti::DAQTowerStatus_tag(), EcalTrigTowerDetId::detIdFromDenseIndex(), hcal_timing_source_file_cfg::dump, EcalCondTowerObjectContainer< T >::end(), EcalCondTowerObjectContainer< T >::endcapItems(), EcalCondTowerObjectContainer< T >::find(), xuti::fromNative(), EcalTrigTowerDetId::kEBTotalTowers, EcalTrigTowerDetId::kEETotalTowers, pyrootRender::root, AlCaHLTBitMon_QueryRunRegistry::string, xuti::toNative(), EcalScDetId::unhashIndex(), EcalScDetId::validHashIndex(), xuti::writeCell(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cms::concurrency::xercesInitialize().

77  {
78 
80  DOMImplementation* impl =
81  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
82 
83  DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
84  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
85 
86  DOMDocumentType* doctype = impl->createDocumentType(fromNative("XML").c_str(), 0, 0 );
87  DOMDocument * doc =
88  impl->createDocument( 0, fromNative(DAQTowerStatus_tag).c_str(), doctype );
89 
90  doc->setEncoding(fromNative("UTF-8").c_str() );
91  doc->setStandalone(true);
92  doc->setVersion(fromNative("1.0").c_str() );
93 
94  DOMElement* root = doc->getDocumentElement();
95 
96  xuti::writeHeader(root,header);
97  std::cout << " barrel size " << record.barrelItems().size() << std::endl;
98  if (!record.barrelItems().size()) return std::string();
99  for(uint cellid = 0;
101  ++cellid) {
102  uint32_t rawid = EcalTrigTowerDetId::detIdFromDenseIndex(cellid);
103  if (record.find(rawid) == record.end()) continue;
104  DOMElement* cellnode=writeCell(root,rawid);
105 
106  WriteNodeWithValue(cellnode, DAQStatusCode_tag, record[rawid].getStatusCode());
107  }
108 
109  std::cout << " endcap size " << record.endcapItems().size() << std::endl;
110  if (!record.endcapItems().size()) return std::string();
111  for(uint cellid = 0;
113  ++cellid) {
114  if(!EcalScDetId::validHashIndex(cellid)) continue;
115  uint32_t rawid = EcalScDetId::unhashIndex(cellid);
116 
117  if (record.find(rawid) == record.end()) continue;
118  DOMElement* cellnode=writeCell(root,rawid);
119 
120  WriteNodeWithValue(cellnode, DAQStatusCode_tag, record[rawid].getStatusCode());
121  }
122 
123  std::string dump = toNative(writer->writeToString(*root));
124  doc->release();
125  return dump;
126 }
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
const std::string DAQTowerStatus_tag("EcalDAQTowerStatus")
static EcalScDetId unhashIndex(int hi)
Definition: EcalScDetId.h:118
void xercesInitialize()
Definition: Xerces.cc:17
const_iterator find(uint32_t rawId) const
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
const std::string DAQStatusCode_tag("DAQStatusCode")
static bool validHashIndex(int hi)
Definition: EcalScDetId.h:140
XercesString fromNative(const char *str)
Definition: XercesString.h:31
tuple cout
Definition: gather_cfg.py:145
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
std::string toNative(const XMLCh *str)
Definition: XercesString.h:42
void EcalDAQTowerStatusXMLTranslator::plot ( std::string  fn,
const EcalDAQTowerStatus record 
)
static

Definition at line 128 of file EcalDAQTowerStatusXMLTranslator.cc.

References EcalCondTowerObjectContainer< T >::barrelItems(), gather_cfg::cout, EcalTrigTowerDetId::detIdFromDenseIndex(), EcalCondTowerObjectContainer< T >::end(), EcalCondTowerObjectContainer< T >::endcapItems(), EcalCondTowerObjectContainer< T >::find(), groupFilesInBlocks::fout, EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::iphi(), EcalScDetId::ix(), EcalScDetId::iy(), relval_2017::k, EcalTrigTowerDetId::kEBTotalTowers, EcalTrigTowerDetId::kEETotalTowers, geometryCSVtoXML::line, EcalScDetId::unhashIndex(), EcalScDetId::validHashIndex(), and EcalScDetId::zside().

Referenced by cuy.FindIssue::__init__().

128  {
129  std::ofstream fout(fn.c_str());
130  int valEB[34][72];
131  std::cout << " barrel size " << record.barrelItems().size() << std::endl;
132  if (!record.barrelItems().size()) return;
133  for(uint cellid = 0;
135  ++cellid) {
137  if (record.find(rawid) == record.end()) continue;
138  int ieta = rawid.ieta();
139  int line = 17 - ieta;
140  if(ieta < 0) 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) fout << std::endl;
149  }
150 
151  std::cout << " endcap size " << record.endcapItems().size() << std::endl;
152  if (!record.endcapItems().size()) return;
153  int valEE[2][20][20];
154  for(int k = 0 ; k < 2; k++ )
155  for(int ix = 0 ; ix < 20; ix++)
156  for(int iy = 0 ; iy < 20; iy++)
157  valEE[k][ix][iy] = -1;
158  for(uint cellid = 0;
160  ++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) iz = 0;
168  if(ix < 0 || ix > 19) std::cout << " Pb in ix " << ix << std::endl;
169  if(iy < 0 || iy > 19) std::cout << " Pb in iy " << iy << std::endl;
170  valEE[iz][ix][iy] = record[rawid].getStatusCode();
171  }
172  }
173  for(int k = 0 ; k < 2; k++ ) {
174  int iz = -1;
175  if(k == 1) iz = 1;
176  fout << " Side : " << iz << std::endl;
177  for(int line = 0; line < 20; line++) {
178  for(int ix = 0 ; ix < 20; ix++) {
179  if(valEE[k][ix][line] < 0) fout << ". ";
180  else fout << valEE[k][ix][line] << " ";
181  }
182  fout << std::endl;
183  }
184  fout << std::endl;
185  }
186 
187  return;
188 }
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
static EcalScDetId unhashIndex(int hi)
Definition: EcalScDetId.h:118
const_iterator find(uint32_t rawId) const
int ieta() const
get the tower ieta
int ix() const
Definition: EcalScDetId.h:71
int iy() const
Definition: EcalScDetId.h:77
int iphi() const
get the tower iphi
int zside() const
Definition: EcalScDetId.h:65
static bool validHashIndex(int hi)
Definition: EcalScDetId.h:140
tuple cout
Definition: gather_cfg.py:145
int EcalDAQTowerStatusXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalDAQTowerStatus record 
)
static

Definition at line 20 of file EcalDAQTowerStatusXMLTranslator.cc.

References xuti::Cell_tag(), gather_cfg::cout, xuti::DAQStatusCode_tag(), xuti::getChildNode(), xuti::GetNodeData(), mps_alisetup::parser, xuti::readCellId(), xuti::readHeader(), mps_update::status, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

22  {
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  int chan = 0;
47  while(cellnode) {
48  int status = -1;
49  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
50 
51  DOMNode* my_node = getChildNode(cellnode,DAQStatusCode_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  chan++;
61  }
62 
63  delete parser;
65  return 0;
66  }
void xercesTerminate()
Definition: Xerces.cc:22
void xercesInitialize()
Definition: Xerces.cc:17
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: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.
tuple status
Definition: mps_update.py:57
int EcalDAQTowerStatusXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalDAQTowerStatus record 
)
static

Definition at line 68 of file EcalDAQTowerStatusXMLTranslator.cc.

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

70  {
71  std::fstream fs(filename.c_str(),ios::out);
72  fs<< dumpXML(header,record);
73  return 0;
74 }
static std::string dumpXML(const EcalCondHeader &header, const EcalDAQTowerStatus &record)
tuple filename
Definition: lut2db_cfg.py:20