CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
HcalConstantsXMLWriter Class Reference

#include <HcalConstantsXMLWriter.h>

Public Member Functions

 HcalConstantsXMLWriter ()
 
void newCellLine (xercesc::DOMElement *, int, int, int, int, float)
 
void writeXML (std::string &, const std::vector< int > &, const std::vector< int > &, const std::vector< int > &, const std::vector< int > &, const std::vector< float > &)
 
virtual ~HcalConstantsXMLWriter ()
 

Private Attributes

std::string hcalfileOut_
 
xercesc::DOMDocument * mDoc
 

Detailed Description

Definition at line 18 of file HcalConstantsXMLWriter.h.

Constructor & Destructor Documentation

◆ HcalConstantsXMLWriter()

HcalConstantsXMLWriter::HcalConstantsXMLWriter ( )

Definition at line 22 of file HcalConstantsXMLWriter.cc.

22 {}

◆ ~HcalConstantsXMLWriter()

HcalConstantsXMLWriter::~HcalConstantsXMLWriter ( )
virtual

Definition at line 23 of file HcalConstantsXMLWriter.cc.

23 {}

Member Function Documentation

◆ newCellLine()

void HcalConstantsXMLWriter::newCellLine ( xercesc::DOMElement *  ,
int  ,
int  ,
int  ,
int  ,
float   
)

Definition at line 82 of file HcalConstantsXMLWriter.cc.

References hcalRecHitTable_cff::depth, PVValHelper::eta, phi, and l1tEGammaCrystalsEmulatorProducer_cfi::scale.

82  {
83  XMLCh tempStr[100];
84  XMLString::transcode("det_index", tempStr, 99);
85  DOMAttr* attrdet = mDoc->createAttribute(tempStr);
86 
87  XMLString::transcode("eta_index", tempStr, 99);
88  DOMAttr* attreta = mDoc->createAttribute(tempStr);
89 
90  XMLString::transcode("phi_index", tempStr, 99);
91  DOMAttr* attrphi = mDoc->createAttribute(tempStr);
92 
93  XMLString::transcode("depth_index", tempStr, 99);
94  DOMAttr* attrdepth = mDoc->createAttribute(tempStr);
95 
96  XMLString::transcode("scale_factor", tempStr, 99);
97  DOMAttr* attrscale = mDoc->createAttribute(tempStr);
98 
99  std::ostringstream ost;
100  ost << det;
101  attrdet->setValue(XMLString::transcode(ost.str().c_str()));
102  detelem->setAttributeNode(attrdet);
103 
104  std::ostringstream ost1;
105  ost1 << eta;
106  attreta->setValue(XMLString::transcode(ost1.str().c_str()));
107  //DOMAttr* attr3 = detelem->setAttributeNode(attreta);
108  detelem->setAttributeNode(attreta);
109 
110  std::ostringstream ost2;
111  ost2 << phi;
112  attrphi->setValue(XMLString::transcode(ost2.str().c_str()));
113  //DOMAttr* attr4 = detelem->setAttributeNode(attrphi);
114  detelem->setAttributeNode(attrphi);
115 
116  std::ostringstream ost3;
117  ost3 << depth;
118  attrdepth->setValue(XMLString::transcode(ost3.str().c_str()));
119  //DOMAttr* attr5 = detelem->setAttributeNode(attrdepth);
120  detelem->setAttributeNode(attrdepth);
121 
122  std::ostringstream ost4;
123  ost4 << scale;
124  attrscale->setValue(XMLString::transcode(ost4.str().c_str()));
125  //DOMAttr* attr6 = detelem->setAttributeNode(attrscale);
126  detelem->setAttributeNode(attrscale);
127 }
xercesc::DOMDocument * mDoc

◆ writeXML()

void HcalConstantsXMLWriter::writeXML ( std::string &  newfile0,
const std::vector< int > &  detvec,
const std::vector< int > &  etavec,
const std::vector< int > &  phivec,
const std::vector< int > &  depthvec,
const std::vector< float > &  scalevec 
)

Definition at line 24 of file HcalConstantsXMLWriter.cc.

References mps_fire::i, runonSM::newfile, groupFilesInBlocks::nn, and MillePedeFileConverter_cfg::out.

29  {
30  int nn = newfile0.size();
31  char newfile[99];
32  for (int i = 0; i < nn; i++) {
33  newfile[i] = newfile0[i];
34  }
35  char const* fend = "\0";
36  newfile[nn] = *fend;
37 
38  edm::LogVerbatim("HcalCalib") << " New file " << newfile << std::endl;
39 
40  std::filebuf fb;
41  fb.open(newfile, std::ios::out);
42  std::ostream fOut(&fb);
43 
44  XMLCh tempStr[100];
45 
46  XMLString::transcode("Core", tempStr, 99);
47  std::unique_ptr<DOMImplementation> mDom(DOMImplementationRegistry::getDOMImplementation(tempStr));
48 
49  XMLString::transcode("CalibrationConstants", tempStr, 99);
50  mDoc = mDom->createDocument(nullptr, // root element namespace URI.
51  tempStr, // root element name
52  nullptr); // document type object (DTD).
53 
54  StreamOutFormatTarget formTarget(fOut);
55  DOMLSSerializer* domWriter = mDom->createLSSerializer();
56  domWriter->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
57  DOMElement* root = mDoc->getDocumentElement();
58 
59  XMLString::transcode("Hcal", tempStr, 99);
60  DOMElement* rootelem = mDoc->createElement(tempStr);
61  root->appendChild(rootelem);
62 
63  XMLString::transcode("Cell", tempStr, 99);
64  std::vector<DOMElement*> theDOMVec;
65 
66  for (unsigned int i = 0; i < detvec.size(); i++) {
67  theDOMVec.push_back(mDoc->createElement(tempStr));
68  newCellLine(theDOMVec[i], detvec[i], etavec[i], phivec[i], depthvec[i], scalevec[i]);
69  rootelem->appendChild(theDOMVec[i]);
70  }
71 
72  edm::LogVerbatim("HcalCalib") << " Write Doc " << theDOMVec.size();
73  DOMLSOutput* output = mDom->createLSOutput();
74  output->setByteStream(&formTarget);
75  domWriter->write(mDoc, output);
76  edm::LogVerbatim("HcalCalib") << " End of Writting ";
77  mDoc->release();
78  output->release();
79  domWriter->release();
80 }
Log< level::Info, true > LogVerbatim
newfile
Definition: runonSM.py:49
void newCellLine(xercesc::DOMElement *, int, int, int, int, float)
Definition: output.py:1
xercesc::DOMDocument * mDoc

Member Data Documentation

◆ hcalfileOut_

std::string HcalConstantsXMLWriter::hcalfileOut_
private

Definition at line 32 of file HcalConstantsXMLWriter.h.

◆ mDoc

xercesc::DOMDocument* HcalConstantsXMLWriter::mDoc
private

Definition at line 33 of file HcalConstantsXMLWriter.h.