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 21 of file HcalConstantsXMLWriter.cc.

21 {}

◆ ~HcalConstantsXMLWriter()

HcalConstantsXMLWriter::~HcalConstantsXMLWriter ( )
virtual

Definition at line 22 of file HcalConstantsXMLWriter.cc.

22 {}

Member Function Documentation

◆ newCellLine()

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

Definition at line 81 of file HcalConstantsXMLWriter.cc.

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

References LEDCalibrationChannels::depth, PVValHelper::eta, and L1EGammaCrystalsEmulatorProducer_cfi::scale.

◆ writeXML()

void HcalConstantsXMLWriter::writeXML ( std::string &  ,
const std::vector< int > &  ,
const std::vector< int > &  ,
const std::vector< int > &  ,
const std::vector< int > &  ,
const std::vector< float > &   
)

Definition at line 23 of file HcalConstantsXMLWriter.cc.

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

References gather_cfg::cout, benchmark_cfg::fb, mps_fire::i, runonSM::newfile, groupFilesInBlocks::nn, MillePedeFileConverter_cfg::out, and convertSQLitetoXML_cfg::output.

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.

mps_fire.i
i
Definition: mps_fire.py:428
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
gather_cfg.cout
cout
Definition: gather_cfg.py:144
runonSM.newfile
newfile
Definition: runonSM.py:49
StreamOutFormatTarget
Definition: StreamOutFormatTarget.h:30
HcalConstantsXMLWriter::mDoc
xercesc::DOMDocument * mDoc
Definition: HcalConstantsXMLWriter.h:33
PVValHelper::eta
Definition: PVValidationHelpers.h:69
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
root
Definition: RooFitFunction.h:10
HcalConstantsXMLWriter::newCellLine
void newCellLine(xercesc::DOMElement *, int, int, int, int, float)
Definition: HcalConstantsXMLWriter.cc:81
groupFilesInBlocks.nn
nn
Definition: groupFilesInBlocks.py:150
DDAxes::phi
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
benchmark_cfg.fb
fb
Definition: benchmark_cfg.py:14