CMS 3D CMS Logo

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

#include <EcalTPGTowerStatusXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

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

Detailed Description

Translates a Ecal record to XML and vice versa

Version
Id
EcalDAQTowerStatusXMLTranslator.h,v 1.1 2011/04/04 fay Exp
Date
4 Apr 2011

Definition at line 14 of file EcalTPGTowerStatusXMLTranslator.h.

Member Function Documentation

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

Definition at line 90 of file EcalTPGTowerStatusXMLTranslator.cc.

References gather_cfg::cout, FrontierConditions_GlobalTag_cff::dump, EcalTPGTowerStatus::getMap(), EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::iphi(), AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), xuti::TPGTowerStatus_tag(), ecaldqm::ttId(), cms::xerces::uStr(), xuti::writeCell(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cscNeutronWriter_cfi::writer.

90  {
91 
92  unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
93 
94  DOMLSSerializer* writer = impl->createLSSerializer();
95  if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
96  writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );
97 
98  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), 0, 0 );
99  DOMDocument * doc =
100  impl->createDocument( 0, cms::xerces::uStr(TPGTowerStatus_tag.c_str()).ptr(), doctype );
101 
102  DOMElement* root = doc->getDocumentElement();
103 
104  xuti::writeHeader(root,header);
105  std::cout << "EcalTPGTowerStatusXMLTranslator::dumpXML" << std::endl;
106  const EcalTPGTowerStatusMap &towerMap = record.getMap();
107  std::cout << " tower map size " << towerMap.size() << std::endl;
109  for(it = towerMap.begin(); it != towerMap.end(); ++it) {
110  if((*it).second > 0) {
111  EcalTrigTowerDetId ttId((*it).first);
112  std::cout << " TTDetId " << ttId << " eta " << ttId.ieta() << " phi " << ttId.iphi() << std::endl;
113  uint32_t rawid = ttId;
114  DOMElement* cellnode=writeCell(root,rawid);
116  }
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 }
std::map< uint32_t, uint16_t >::const_iterator EcalTPGTowerStatusMapIterator
std::map< uint32_t, uint16_t > EcalTPGTowerStatusMap
unsigned ttId(DetId const &)
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
const std::string TPGTowerStatus_tag("EcalTPGTowerStatus")
std::string toString(XMLCh const *toTranscode)
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)
const std::map< uint32_t, uint16_t > & getMap() const
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
void EcalTPGTowerStatusXMLTranslator::plot ( std::string  fn,
const EcalTPGTowerStatus record 
)
staticprivate

Definition at line 127 of file EcalTPGTowerStatusXMLTranslator.cc.

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

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

Definition at line 29 of file EcalTPGTowerStatusXMLTranslator.cc.

References gather_cfg::cout, createfilelist::parser, xuti::readHeader(), cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

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

Definition at line 77 of file EcalTPGTowerStatusXMLTranslator.cc.

References EcalCondTools::dumpXML(), MillePedeFileConverter_cfg::out, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

79  {
81 
82  std::fstream fs(filename.c_str(),ios::out);
83  fs<< dumpXML(header,record);
84 
86 
87  return 0;
88 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
static std::string dumpXML(const EcalCondHeader &header, const EcalTPGTowerStatus &record)