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
EcalDCSTowerStatusXMLTranslator Class Reference

#include <EcalDCSTowerStatusXMLTranslator.h>

Static Public Member Functions

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

Member Function Documentation

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

Definition at line 78 of file EcalDCSTowerStatusXMLTranslator.cc.

References EcalCondTowerObjectContainer< T >::barrelItems(), gather_cfg::cout, xuti::DCSStatusCode_tag(), xuti::DCSTowerStatus_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().

78  {
79 
81  DOMImplementation* impl =
82  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
83 
84  DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
85  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
86 
87  DOMDocumentType* doctype = impl->createDocumentType(fromNative("XML").c_str(), 0, 0 );
88  DOMDocument * doc =
89  impl->createDocument( 0, fromNative(DCSTowerStatus_tag).c_str(), doctype );
90 
91  doc->setEncoding(fromNative("UTF-8").c_str() );
92  doc->setStandalone(true);
93  doc->setVersion(fromNative("1.0").c_str() );
94 
95  DOMElement* root = doc->getDocumentElement();
96 
97  xuti::writeHeader(root,header);
98  std::cout << " barrel size " << record.barrelItems().size() << std::endl;
99  if (!record.barrelItems().size()) return std::string();
100  for(uint cellid = 0;
102  ++cellid) {
103  uint32_t rawid = EcalTrigTowerDetId::detIdFromDenseIndex(cellid);
104  if (record.find(rawid) == record.end()) continue;
105  DOMElement* cellnode=writeCell(root,rawid);
106 
107  WriteNodeWithValue(cellnode, DCSStatusCode_tag, record[rawid].getStatusCode());
108  }
109 
110  std::cout << " endcap size " << record.endcapItems().size() << std::endl;
111  if (!record.endcapItems().size()) return std::string();
112  for(uint cellid = 0;
114  ++cellid) {
115  if(!EcalScDetId::validHashIndex(cellid)) continue;
116  uint32_t rawid = EcalScDetId::unhashIndex(cellid);
117 
118  if (record.find(rawid) == record.end()) continue;
119  DOMElement* cellnode=writeCell(root,rawid);
120 
121  WriteNodeWithValue(cellnode, DCSStatusCode_tag, record[rawid].getStatusCode());
122  }
123 
124  std::string dump = toNative(writer->writeToString(*root));
125  doc->release();
126  return dump;
127 }
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
const std::string DCSTowerStatus_tag("EcalDCSTowerStatus")
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 DCSStatusCode_tag("DCSStatusCode")
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 EcalDCSTowerStatusXMLTranslator::plot ( std::string  fn,
const EcalDCSTowerStatus record 
)
static

Definition at line 129 of file EcalDCSTowerStatusXMLTranslator.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__().

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().size()) return;
134  for(uint cellid = 0;
136  ++cellid) {
138  if (record.find(rawid) == record.end()) continue;
139  int ieta = rawid.ieta();
140  int line = 17 - ieta;
141  if(ieta < 0) line--;
142  int iphi = rawid.iphi() - 1; // 0 to 71
143  valEB[line][iphi] = record[rawid].getStatusCode();
144  }
145  for(int line = 0; line < 34; line++) {
146  for(int iphi = 0; iphi < 72; iphi++)
147  fout << valEB[line][iphi] << " ";
148  fout << std::endl;
149  if(line == 16) fout << std::endl;
150  }
151 
152  std::cout << " endcap size " << record.endcapItems().size() << std::endl;
153  if (!record.endcapItems().size()) return;
154  int valEE[2][20][20];
155  for(int k = 0 ; k < 2; k++ )
156  for(int ix = 0 ; ix < 20; ix++)
157  for(int iy = 0 ; iy < 20; iy++)
158  valEE[k][ix][iy] = -1;
159  for(uint cellid = 0;
161  ++cellid) {
162  if(EcalScDetId::validHashIndex(cellid)) {
163  EcalScDetId rawid = EcalScDetId::unhashIndex(cellid);
164  int ix = rawid.ix() - 1; // 0 to 19
165  int iy = 20 - rawid.iy(); // 0 to 19
166  int side = rawid.zside();
167  int iz = side;
168  if(side == -1) iz = 0;
169  if(ix < 0 || ix > 19) std::cout << " Pb in ix " << ix << std::endl;
170  if(iy < 0 || iy > 19) std::cout << " Pb in iy " << iy << std::endl;
171  valEE[iz][ix][iy] = record[rawid].getStatusCode();
172  }
173  }
174  for(int k = 0 ; k < 2; k++ ) {
175  int iz = -1;
176  if(k == 1) iz = 1;
177  fout << " Side : " << iz << std::endl;
178  for(int line = 0; line < 20; line++) {
179  for(int ix = 0 ; ix < 20; ix++) {
180  if(valEE[k][ix][line] < 0) fout << " . ";
181  else fout << setw(2) << valEE[k][ix][line] << " ";
182  }
183  fout << std::endl;
184  }
185  fout << std::endl;
186  }
187 
188  return;
189 }
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 EcalDCSTowerStatusXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalDCSTowerStatus record 
)
static

Definition at line 21 of file EcalDCSTowerStatusXMLTranslator.cc.

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

23  {
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: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 DCSStatusCode_tag("DCSStatusCode")
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 EcalDCSTowerStatusXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalDCSTowerStatus record 
)
static

Definition at line 69 of file EcalDCSTowerStatusXMLTranslator.cc.

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

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