CMS 3D CMS Logo

EcalTPGLinearizationConstXMLTranslator.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <fstream>
4 
7 
12 
13 using namespace XERCES_CPP_NAMESPACE;
14 using namespace xuti;
15 using namespace std;
16 
18  const EcalCondHeader& header,
21 
22  std::fstream fs(filename.c_str(),ios::out);
23  fs<< dumpXML(header,record);
24 
26 
27  return 0;
28 }
29 
32 
33  unique_ptr<DOMImplementation> impl( DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
34 
35  DOMLSSerializer* writer = impl->createLSSerializer();
36  if( writer->getDomConfig()->canSetParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true ))
37  writer->getDomConfig()->setParameter( XMLUni::fgDOMWRTFormatPrettyPrint, true );
38 
39  DOMDocumentType* doctype = impl->createDocumentType( cms::xerces::uStr("XML").ptr(), nullptr, nullptr );
40  DOMDocument* doc =
41  impl->createDocument( nullptr, cms::xerces::uStr(Linearization_tag.c_str()).ptr(), doctype );
42  DOMElement* root = doc->getDocumentElement();
43 
44  xuti::writeHeader(root,header);
45 
46  // open also a flat text file
47  std::ofstream fout;
48  fout.open("Linearization.txt");
49 
50  for(int cellid = EBDetId::MIN_HASH;
52  ++cellid) {
53 
54  uint32_t rawid = EBDetId::unhashIndex(cellid);
55 
56  DOMElement* cellnode= writeCell(root,rawid);
57 
58  float m12=(record)[rawid].mult_x12;
59  float s12=(record)[rawid].shift_x12;
60  float m6 =(record)[rawid].mult_x6;
61  float s6 =(record)[rawid].shift_x6;
62  float m1 =(record)[rawid].mult_x1;
63  float s1 =(record)[rawid].shift_x1;
64 
71  fout << rawid << " " << m12 << " " << m6 << " " << m1 << " " << s12 << " " << s6 << " " << s1 << "\n";
72  }
73 
74  for(int cellid = 0;
76  ++cellid) {
77  if(!EEDetId::validHashIndex(cellid)) continue;
78 
79  uint32_t rawid = EEDetId::unhashIndex(cellid);
80 
81  DOMElement* cellnode=writeCell(root,rawid);
82 
83  float m12=(record)[rawid].mult_x12;
84  float s12=(record)[rawid].shift_x12;
85  float m6 =(record)[rawid].mult_x6;
86  float s6 =(record)[rawid].shift_x6;
87  float m1 =(record)[rawid].mult_x1;
88  float s1 =(record)[rawid].shift_x1;
89 
96  fout << rawid << " " << m12 << " " << m6 << " " << m1 << " " << s12 << " " << s6 << " " << s1 << "\n";
97 
98  }
99  fout.close();
100  std::string dump = cms::xerces::toString( writer->writeToString( root ));
101  doc->release();
102  doctype->release();
103  writer->release();
104 
105  return dump;
106 }
const std::string Linearization_m1_tag("mult1")
static std::string dumpXML(const EcalCondHeader &header, const EcalTPGLinearizationConst &record)
def dumpXML(db, tag, since, filename='dump.xml')
const std::string Linearization_s12_tag("shift12")
JetCorrectorParameters::Record record
Definition: classes.h:7
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
const std::string Linearization_m12_tag("mult12")
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
static bool validHashIndex(int i)
Definition: EEDetId.h:239
const std::string Linearization_m6_tag("mult6")
std::string toString(XMLCh const *toTranscode)
const std::string Linearization_s6_tag("shift6")
static const int MIN_HASH
Definition: EBDetId.h:149
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)
const std::string Linearization_s1_tag("shift1")
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalTPGLinearizationConst &record)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
const std::string Linearization_tag("EcalTPGLinearizationConts")
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.