CMS 3D CMS Logo

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

#include <EcalDCSTowerStatusXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

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

Member Function Documentation

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

Definition at line 83 of file EcalDCSTowerStatusXMLTranslator.cc.

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

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

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

130  {
131  std::ofstream fout(fn.c_str());
132  int valEB[34][72];
133  std::cout << " barrel size " << record.barrelItems().size() << std::endl;
134  if (record.barrelItems().empty()) return;
135  for(uint cellid = 0;
137  ++cellid) {
139  if (record.find(rawid) == record.end()) continue;
140  int ieta = rawid.ieta();
141  int line = 17 - ieta;
142  if(ieta < 0) line--;
143  int iphi = rawid.iphi() - 1; // 0 to 71
144  valEB[line][iphi] = record[rawid].getStatusCode();
145  }
146  for(int line = 0; line < 34; line++) {
147  for(int iphi = 0; iphi < 72; iphi++)
148  fout << valEB[line][iphi] << " ";
149  fout << std::endl;
150  if(line == 16) fout << std::endl;
151  }
152 
153  std::cout << " endcap size " << record.endcapItems().size() << std::endl;
154  if (record.endcapItems().empty()) return;
155  int valEE[2][20][20];
156  for(int k = 0 ; k < 2; k++ )
157  for(int ix = 0 ; ix < 20; ix++)
158  for(int iy = 0 ; iy < 20; iy++)
159  valEE[k][ix][iy] = -1;
160  for(uint cellid = 0;
162  ++cellid) {
163  if(EcalScDetId::validHashIndex(cellid)) {
164  EcalScDetId rawid = EcalScDetId::unhashIndex(cellid);
165  int ix = rawid.ix() - 1; // 0 to 19
166  int iy = 20 - rawid.iy(); // 0 to 19
167  int side = rawid.zside();
168  int iz = side;
169  if(side == -1) iz = 0;
170  if(ix < 0 || ix > 19) std::cout << " Pb in ix " << ix << std::endl;
171  if(iy < 0 || iy > 19) std::cout << " Pb in iy " << iy << std::endl;
172  valEE[iz][ix][iy] = record[rawid].getStatusCode();
173  }
174  }
175  for(int k = 0 ; k < 2; k++ ) {
176  int iz = -1;
177  if(k == 1) iz = 1;
178  fout << " Side : " << iz << std::endl;
179  for(int line = 0; line < 20; line++) {
180  for(int ix = 0 ; ix < 20; ix++) {
181  if(valEE[k][ix][line] < 0) fout << " . ";
182  else fout << setw(2) << valEE[k][ix][line] << " ";
183  }
184  fout << std::endl;
185  }
186  fout << std::endl;
187  }
188 
189  return;
190 }
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
static EcalScDetId unhashIndex(int hi)
Definition: EcalScDetId.h:117
const_iterator find(uint32_t rawId) const
int ieta() const
get the tower ieta
int ix() const
Definition: EcalScDetId.h:70
int iy() const
Definition: EcalScDetId.h:76
int k[5][pyjets_maxn]
int iphi() const
get the tower iphi
def uint(string)
int zside() const
Definition: EcalScDetId.h:64
static bool validHashIndex(int hi)
Definition: EcalScDetId.h:139
int EcalDCSTowerStatusXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalDCSTowerStatus record 
)
static

Definition at line 22 of file EcalDCSTowerStatusXMLTranslator.cc.

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

24  {
25 
26  std::cout << " DCSTowerStatus 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 << "EcalDCSTowerStatusXMLTranslator::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,DCSStatusCode_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 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
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 EcalDCSTowerStatusXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalDCSTowerStatus record 
)
static

Definition at line 70 of file EcalDCSTowerStatusXMLTranslator.cc.

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

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