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

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

Definition at line 87 of file EcalDAQTowerStatusXMLTranslator.cc.

References EcalCondTowerObjectContainer< T >::barrelItems(), gather_cfg::cout, xuti::DAQStatusCode_tag(), xuti::DAQTowerStatus_tag(), EcalTrigTowerDetId::detIdFromDenseIndex(), common_cff::doc, FrontierConditions_GlobalTag_cff::dump, EcalCondTowerObjectContainer< T >::end(), EcalCondTowerObjectContainer< T >::endcapItems(), EcalCondTowerObjectContainer< T >::find(), EcalTrigTowerDetId::kEBTotalTowers, EcalTrigTowerDetId::kEETotalTowers, AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), parallelization::uint(), EcalScDetId::unhashIndex(), cms::xerces::uStr(), EcalScDetId::validHashIndex(), xuti::writeCell(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cscNeutronWriter_cfi::writer.

87  {
88 
89  unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation( cms::xerces::uStr("LS").ptr()));
90 
91  DOMLSSerializer* writer = impl->createLSSerializer();
92  if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
93  writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );
94 
95  DOMDocumentType* doctype = impl->createDocumentType( cms::xerces::uStr("XML").ptr(), nullptr, nullptr );
96  DOMDocument* doc =
97  impl->createDocument( nullptr, cms::xerces::uStr( DAQTowerStatus_tag.c_str()).ptr(), doctype );
98 
99  DOMElement* root = doc->getDocumentElement();
100 
101  xuti::writeHeader(root,header);
102  std::cout << " barrel size " << record.barrelItems().size() << std::endl;
103  if (record.barrelItems().empty()) return std::string();
104  for(uint cellid = 0;
106  ++cellid) {
107  uint32_t rawid = EcalTrigTowerDetId::detIdFromDenseIndex(cellid);
108  if (record.find(rawid) == record.end()) continue;
109  DOMElement* cellnode=writeCell(root,rawid);
110 
111  WriteNodeWithValue(cellnode, DAQStatusCode_tag, record[rawid].getStatusCode());
112  }
113 
114  std::cout << " endcap size " << record.endcapItems().size() << std::endl;
115  if (record.endcapItems().empty()) return std::string();
116  for(uint cellid = 0;
118  ++cellid) {
119  if(!EcalScDetId::validHashIndex(cellid)) continue;
120  uint32_t rawid = EcalScDetId::unhashIndex(cellid);
121 
122  if (record.find(rawid) == record.end()) continue;
123  DOMElement* cellnode = writeCell(root,rawid);
124 
125  WriteNodeWithValue(cellnode, DAQStatusCode_tag, record[rawid].getStatusCode());
126  }
127 
128  std::string dump = cms::xerces::toString(writer->writeToString( root ));
129  doc->release();
130  doctype->release();
131  writer->release();
132 
133  return dump;
134 }
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
const std::string DAQTowerStatus_tag("EcalDAQTowerStatus")
static EcalScDetId unhashIndex(int hi)
Definition: EcalScDetId.h:118
const_iterator find(uint32_t rawId) const
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")
def uint(string)
static bool validHashIndex(int hi)
Definition: EcalScDetId.h:140
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
void EcalDAQTowerStatusXMLTranslator::plot ( std::string  fn,
const EcalDAQTowerStatus record 
)
staticprivate

Definition at line 136 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(), gen::k, EcalTrigTowerDetId::kEBTotalTowers, EcalTrigTowerDetId::kEETotalTowers, mps_splice::line, parallelization::uint(), EcalScDetId::unhashIndex(), EcalScDetId::validHashIndex(), and EcalScDetId::zside().

136  {
137  std::ofstream fout(fn.c_str());
138  int valEB[34][72];
139  std::cout << " barrel size " << record.barrelItems().size() << std::endl;
140  if (record.barrelItems().empty()) return;
141  for(uint cellid = 0;
143  ++cellid) {
145  if (record.find(rawid) == record.end()) continue;
146  int ieta = rawid.ieta();
147  int line = 17 - ieta;
148  if(ieta < 0) line--;
149  int iphi = rawid.iphi() - 1; // 0 to 71
150  valEB[line][iphi] = record[rawid].getStatusCode();
151  }
152  for(int line = 0; line < 34; line++) {
153  for(int iphi = 0; iphi < 72; iphi++)
154  fout << valEB[line][iphi] << " ";
155  fout << std::endl;
156  if(line == 16) fout << std::endl;
157  }
158 
159  std::cout << " endcap size " << record.endcapItems().size() << std::endl;
160  if (record.endcapItems().empty()) return;
161  int valEE[2][20][20];
162  for(int k = 0 ; k < 2; k++ )
163  for(int ix = 0 ; ix < 20; ix++)
164  for(int iy = 0 ; iy < 20; iy++)
165  valEE[k][ix][iy] = -1;
166  for(uint cellid = 0;
168  ++cellid) {
169  if(EcalScDetId::validHashIndex(cellid)) {
170  EcalScDetId rawid = EcalScDetId::unhashIndex(cellid);
171  int ix = rawid.ix() - 1; // 0 to 19
172  int iy = 20 - rawid.iy(); // 0 to 19
173  int side = rawid.zside();
174  int iz = side;
175  if(side == -1) iz = 0;
176  if(ix < 0 || ix > 19) std::cout << " Pb in ix " << ix << std::endl;
177  if(iy < 0 || iy > 19) std::cout << " Pb in iy " << iy << std::endl;
178  valEE[iz][ix][iy] = record[rawid].getStatusCode();
179  }
180  }
181  for(int k = 0 ; k < 2; k++ ) {
182  int iz = -1;
183  if(k == 1) iz = 1;
184  fout << " Side : " << iz << std::endl;
185  for(int line = 0; line < 20; line++) {
186  for(int ix = 0 ; ix < 20; ix++) {
187  if(valEE[k][ix][line] < 0) fout << ". ";
188  else fout << valEE[k][ix][line] << " ";
189  }
190  fout << std::endl;
191  }
192  fout << std::endl;
193  }
194 
195  return;
196 }
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 k[5][pyjets_maxn]
int iphi() const
get the tower iphi
def uint(string)
int zside() const
Definition: EcalScDetId.h:65
static bool validHashIndex(int hi)
Definition: EcalScDetId.h:140
int EcalDAQTowerStatusXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalDAQTowerStatus record 
)
static

Definition at line 22 of file EcalDAQTowerStatusXMLTranslator.cc.

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

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

Definition at line 71 of file EcalDAQTowerStatusXMLTranslator.cc.

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

73  {
74 
76 
77  std::fstream fs(filename.c_str(),ios::out);
78  fs<< dumpXML(header,record);
79 
81 
82  return 0;
83 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
static std::string dumpXML(const EcalCondHeader &header, const EcalDAQTowerStatus &record)