CMS 3D CMS Logo

EcalTPGCrystalStatusXMLTranslator.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <fstream>
4 #include <xercesc/dom/DOMNode.hpp>
5 #include <xercesc/dom/DOM.hpp>
6 #include <xercesc/parsers/XercesDOMParser.hpp>
9 #include <xercesc/util/XMLString.hpp>
10 #include <xercesc/sax/SAXException.hpp>
11 #include <xercesc/framework/LocalFileFormatTarget.hpp>
12 
15 
19 
22 
23 using namespace XERCES_CPP_NAMESPACE;
24 using namespace xuti;
25 using namespace std;
26 
28  const EcalCondHeader& header,
31 
32  std::fstream fs(filename.c_str(), ios::out);
33  fs << dumpXML(header, record);
34 
36 
37  return 0;
38 }
39 
42  unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
43 
44  DOMLSSerializer* writer = impl->createLSSerializer();
45  if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
46  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
47  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr);
48  DOMDocument* doc = impl->createDocument(nullptr, cms::xerces::uStr(TPGCrystalStatus_tag.c_str()).ptr(), doctype);
49 
50  DOMElement* root = doc->getDocumentElement();
51 
53 
54  const int kSides = 2;
55  const int kBarlRings = EBDetId::MAX_IETA;
56  const int kBarlWedges = EBDetId::MAX_IPHI;
57  const int kEndcWedgesX = EEDetId::IX_MAX;
58  const int kEndcWedgesY = EEDetId::IY_MAX;
59 
60  std::cout << "EcalTPGCrystalStatusXMLTranslator::dumpXML" << std::endl;
61  for (int sign = 0; sign < kSides; sign++) {
62  int thesign = sign == 1 ? 1 : -1;
63 
64  for (int ieta = 0; ieta < kBarlRings; ieta++) {
65  for (int iphi = 0; iphi < kBarlWedges; iphi++) {
66  EBDetId id((ieta + 1) * thesign, iphi + 1);
67  if (record[id.rawId()].getStatusCode() > 0) {
68  DOMElement* cellnode = writeCell(root, id);
69  WriteNodeWithValue(cellnode, TPGCrystalStatus_tag, record[id.rawId()].getStatusCode());
70  }
71  } // iphi
72  } // ieta
73 
74  for (int ix = 0; ix < kEndcWedgesX; ix++) {
75  for (int iy = 0; iy < kEndcWedgesY; iy++) {
76  if (!EEDetId::validDetId(ix + 1, iy + 1, thesign))
77  continue;
78  EEDetId id(ix + 1, iy + 1, thesign);
79  if (record[id.rawId()].getStatusCode() > 0) {
80  DOMElement* cellnode = writeCell(root, id);
81  WriteNodeWithValue(cellnode, TPGCrystalStatus_tag, record[id.rawId()].getStatusCode());
82  }
83  } // iy
84  } // ix
85  } // side
86 
88  doc->release();
89  doctype->release();
90  writer->release();
91 
92  return dump;
93 }
XercesStrUtils.h
kBarlRings
static const int kBarlRings
Definition: EcalGeomPhiSymHelper.h:7
common_cff.doc
doc
Definition: common_cff.py:54
EcalCondTools.dumpXML
def dumpXML(db, tag, since, filename='dump.xml')
Definition: EcalCondTools.py:44
xuti::writeHeader
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
Definition: DOMHelperFunctions.cc:151
xuti::writeCell
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
Definition: DOMHelperFunctions.cc:71
EBDetId
Definition: EBDetId.h:17
gather_cfg.cout
cout
Definition: gather_cfg.py:144
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
cscNeutronWriter_cfi.writer
writer
Definition: cscNeutronWriter_cfi.py:6
EcalTPGCrystalStatusRcd.h
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
kEndcWedgesY
static const int kEndcWedgesY
Definition: EcalGeomPhiSymHelper.h:12
EcalTPGCrystalStatusXMLTranslator::dumpXML
static std::string dumpXML(const EcalCondHeader &header, const EcalTPGCrystalStatus &record)
Definition: EcalTPGCrystalStatusXMLTranslator.cc:40
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
cms::xerces::toString
std::string toString(XMLCh const *toTranscode)
Definition: XercesStrUtils.h:34
xuti::WriteNodeWithValue
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
Definition: DOMHelperFunctions.h:46
XERCES_CPP_NAMESPACE
Definition: XmlConfigParser.h:12
xuti::TPGCrystalStatus_tag
const std::string TPGCrystalStatus_tag("EcalTPGCrystalStatus")
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
EBDetId::MAX_IPHI
static const int MAX_IPHI
Definition: EBDetId.h:137
EEDetId::IY_MAX
static const int IY_MAX
Definition: EEDetId.h:302
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalSubdetector.h
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
DOMHelperFunctions.h
EcalCondHeader
Definition: EcalCondHeader.h:16
EEDetId::IX_MAX
static const int IX_MAX
Definition: EEDetId.h:298
FrontierConditions_GlobalTag_cff.dump
dump
Definition: FrontierConditions_GlobalTag_cff.py:12
Xerces.h
EcalTPGCrystalStatusXMLTranslator::writeXML
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalTPGCrystalStatus &record)
Definition: EcalTPGCrystalStatusXMLTranslator.cc:27
cms::concurrency::xercesTerminate
void xercesTerminate()
Definition: Xerces.cc:23
xuti
Definition: DOMHelperFunctions.h:21
root
Definition: RooFitFunction.h:10
cms::xerces::uStr
ZStr< XMLCh > uStr(char const *str)
Definition: XercesStrUtils.h:30
kSides
static const int kSides
Definition: EcalGeomPhiSymHelper.h:9
kEndcWedgesX
static const int kEndcWedgesX
Definition: EcalGeomPhiSymHelper.h:11
impl
Definition: trackAlgoPriorityOrder.h:18
std
Definition: JetResolutionObject.h:76
DetId.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
EcalTPGCrystalStatusXMLTranslator.h
EcalTPGCrystalStatus.h
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
kBarlWedges
static const int kBarlWedges
Definition: EcalGeomPhiSymHelper.h:8
XMLTags.h
cms::concurrency::xercesInitialize
void xercesInitialize()
Definition: Xerces.cc:18
EBDetId::MAX_IETA
static const int MAX_IETA
Definition: EBDetId.h:136