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

#include <EcalTPGTowerStatusXMLTranslator.h>

Static Public Member Functions

static std::string dumpXML (const EcalCondHeader &header, const EcalTPGTowerStatus &record)
 
static void plot (std::string, const EcalTPGTowerStatus &record)
 
static int readXML (const std::string &filename, EcalCondHeader &header, EcalTPGTowerStatus &record)
 
static int writeXML (const std::string &filename, const EcalCondHeader &header, const EcalTPGTowerStatus &record)
 

Detailed Description

Definition at line 23 of file EcalTPGTowerStatusXMLTranslator.h.

Member Function Documentation

std::string EcalTPGTowerStatusXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalTPGTowerStatus record 
)
static

Definition at line 83 of file EcalTPGTowerStatusXMLTranslator.cc.

References gather_cfg::cout, asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::fromNative(), EcalTPGTowerStatus::getMap(), EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::iphi(), dbtoconf::root, xuti::toNative(), xuti::TPGTowerStatus_tag(), ecaldqm::ttId(), xuti::writeCell(), xuti::writeHeader(), and xuti::WriteNodeWithValue().

Referenced by cond::PayLoadInspector< DataT >::dump().

83  {
84 
85  XMLPlatformUtils::Initialize();
86  DOMImplementation* impl =
87  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
88 
89  DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
90  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
91 
92  DOMDocumentType* doctype = impl->createDocumentType(fromNative("XML").c_str(), 0, 0 );
93  DOMDocument * doc =
94  impl->createDocument( 0, fromNative(TPGTowerStatus_tag).c_str(), doctype );
95 
96  doc->setEncoding(fromNative("UTF-8").c_str() );
97  doc->setStandalone(true);
98  doc->setVersion(fromNative("1.0").c_str() );
99 
100  DOMElement* root = doc->getDocumentElement();
101 
102  xuti::writeHeader(root,header);
103  std::cout << "EcalTPGTowerStatusXMLTranslator::dumpXML" << std::endl;
104  const EcalTPGTowerStatusMap &towerMap = record.getMap();
105  std::cout << " tower map size " << towerMap.size() << std::endl;
107  for(it = towerMap.begin(); it != towerMap.end(); ++it) {
108  if((*it).second > 0) {
109  EcalTrigTowerDetId ttId((*it).first);
110  std::cout << " TTDetId " << ttId << " eta " << ttId.ieta() << " phi " << ttId.iphi() << std::endl;
111  uint32_t rawid = ttId;
112  DOMElement* cellnode=writeCell(root,rawid);
114  }
115  }
116 
117  std::string dump = toNative(writer->writeToString(*root));
118  doc->release();
119  return dump;
120 }
std::map< uint32_t, uint16_t >::const_iterator EcalTPGTowerStatusMapIterator
std::map< uint32_t, uint16_t > EcalTPGTowerStatusMap
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
const std::string TPGTowerStatus_tag("EcalTPGTowerStatus")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
tuple doc
Definition: asciidump.py:381
const std::map< uint32_t, uint16_t > & getMap() const
unsigned ttId(const DetId &)
XercesString fromNative(const char *str)
Definition: XercesString.h:31
tuple cout
Definition: gather_cfg.py:121
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
string root
initialization
Definition: dbtoconf.py:70
void EcalTPGTowerStatusXMLTranslator::plot ( std::string  fn,
const EcalTPGTowerStatus record 
)
static

Definition at line 122 of file EcalTPGTowerStatusXMLTranslator.cc.

References gather_cfg::cout, groupFilesInBlocks::fout, EcalTPGTowerStatus::getMap(), EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::iphi(), geometryCSVtoXML::line, and ecaldqm::ttId().

122  {
123  std::ofstream fout(fn.c_str());
124  int valEB[34][72];
125  for(int line = 0; line < 34; line++)
126  for(int iphi = 0; iphi < 72; iphi++)
127  valEB[line][iphi] = 0;
128 
129  const EcalTPGTowerStatusMap &towerMap = record.getMap();
130  std::cout << " tower map size " << towerMap.size() << std::endl;
132  for(it = towerMap.begin(); it != towerMap.end(); ++it) {
133  if((*it).second > 0) {
134  EcalTrigTowerDetId ttId((*it).first);
135  int ieta = ttId.ieta();
136  int line = 17 - ieta;
137  if(ieta < 0) line--;
138  int iphi = ttId.iphi() - 1; // 0 to 71
139  valEB[line][iphi] = (*it).second;
140  }
141  }
142  for(int line = 0; line < 34; line++) {
143  for(int iphi = 0; iphi < 72; iphi++)
144  fout << valEB[line][iphi] << " ";
145  fout << std::endl;
146  if(line == 16) fout << std::endl;
147  }
148  /*
149 
150  std::cout << " endcap size " << record.endcapItems().size() << std::endl;
151  if (!record.endcapItems().size()) return;
152  int valEE[2][20][20];
153  for(int k = 0 ; k < 2; k++ )
154  for(int ix = 0 ; ix < 20; ix++)
155  for(int iy = 0 ; iy < 20; iy++)
156  valEE[k][ix][iy] = -1;
157  for(uint cellid = 0;
158  cellid < EcalTrigTowerDetId::kEETotalTowers;
159  ++cellid) {
160  if(EcalScDetId::validHashIndex(cellid)) {
161  EcalScDetId rawid = EcalScDetId::unhashIndex(cellid);
162  int ix = rawid.ix() - 1; // 0 to 19
163  int iy = 20 - rawid.iy(); // 0 to 19
164  int side = rawid.zside();
165  int iz = side;
166  if(side == -1) iz = 0;
167  if(ix < 0 || ix > 19) std::cout << " Pb in ix " << ix << std::endl;
168  if(iy < 0 || iy > 19) std::cout << " Pb in iy " << iy << std::endl;
169  valEE[iz][ix][iy] = record[rawid].getStatusCode();
170  }
171  }
172  for(int k = 0 ; k < 2; k++ ) {
173  int iz = -1;
174  if(k == 1) iz = 1;
175  fout << " Side : " << iz << std::endl;
176  for(int line = 0; line < 20; line++) {
177  for(int ix = 0 ; ix < 20; ix++) {
178  if(valEE[k][ix][line] < 0) fout << ". ";
179  else fout << valEE[k][ix][line] << " ";
180  }
181  fout << std::endl;
182  }
183  fout << std::endl;
184  }
185  */
186  return;
187 }
std::map< uint32_t, uint16_t >::const_iterator EcalTPGTowerStatusMapIterator
std::map< uint32_t, uint16_t > EcalTPGTowerStatusMap
const std::map< uint32_t, uint16_t > & getMap() const
unsigned ttId(const DetId &)
tuple cout
Definition: gather_cfg.py:121
int EcalTPGTowerStatusXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalTPGTowerStatus record 
)
static

Definition at line 27 of file EcalTPGTowerStatusXMLTranslator.cc.

References gather_cfg::cout, geometryXMLtoCSV::parser, and xuti::readHeader().

29  {
30 
31  std::cout << " TPGTowerStatus should not be filled out from an xml file ..." << std::endl;
32  XMLPlatformUtils::Initialize();
33 
34  XercesDOMParser* parser = new XercesDOMParser;
35  parser->setValidationScheme( XercesDOMParser::Val_Never );
36  parser->setDoNamespaces( false );
37  parser->setDoSchema( false );
38 
39  parser->parse(filename.c_str());
40 
41  DOMDocument* xmlDoc = parser->getDocument();
42  if (!xmlDoc) {
43  std::cout << "EcalTPGTowerStatusXMLTranslator::Error parsing document" << std::endl;
44  return -1;
45  }
46 
47  DOMElement* elementRoot = xmlDoc->getDocumentElement();
48 
49  xuti::readHeader(elementRoot,header);
50 
51  /*
52  int chan = 0;
53  while(cellnode) {
54  int status = -1;
55  DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));
56 
57  DOMNode* my_node = getChildNode(cellnode,TPGTowerStatusCode_tag);
58  GetNodeData(my_node, status);
59 
60  record[detid] = status;
61 
62  cellnode = cellnode->getNextSibling();
63 
64  while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
65  cellnode = cellnode->getNextSibling();
66  chan++;
67  }
68  */
69  delete parser;
70  XMLPlatformUtils::Terminate();
71  return 0;
72  }
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
int EcalTPGTowerStatusXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalTPGTowerStatus record 
)
static

Definition at line 74 of file EcalTPGTowerStatusXMLTranslator.cc.

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

76  {
77  std::fstream fs(filename.c_str(),ios::out);
78  fs<< dumpXML(header,record);
79  return 0;
80 }
static std::string dumpXML(const EcalCondHeader &header, const EcalTPGTowerStatus &record)
tuple out
Definition: dbtoconf.py:99
tuple filename
Definition: lut2db_cfg.py:20