test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalTPGLinearizationConstXMLTranslator.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <fstream>
4 
7 
10 
11 using namespace XERCES_CPP_NAMESPACE;
12 using namespace xuti;
13 using namespace std;
14 
16  const EcalCondHeader& header,
18  std::fstream fs(filename.c_str(),ios::out);
19  fs<< dumpXML(header,record);
20  return 0;
21 }
22 
25 
27 
28  DOMImplementation* impl =
29  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
30 
31  DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
32  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
33 
34  DOMDocumentType* doctype = impl->createDocumentType( fromNative("XML").c_str(), 0, 0 );
35  DOMDocument * doc =
36  impl->createDocument( 0, fromNative(Linearization_tag).c_str(), doctype );
37 
38 
39  doc->setEncoding(fromNative("UTF-8").c_str() );
40  doc->setStandalone(true);
41  doc->setVersion(fromNative("1.0").c_str() );
42 
43  DOMElement* root = doc->getDocumentElement();
44 
45  xuti::writeHeader(root,header);
46 
47  // open also a flat text file
48  std::ofstream fout;
49  fout.open("Linearization.txt");
50 
51  for(int cellid = EBDetId::MIN_HASH;
53  ++cellid) {
54 
55  uint32_t rawid = EBDetId::unhashIndex(cellid);
56 
57  DOMElement* cellnode= writeCell(root,rawid);
58 
59  float m12=(record)[rawid].mult_x12;
60  float s12=(record)[rawid].shift_x12;
61  float m6 =(record)[rawid].mult_x6;
62  float s6 =(record)[rawid].shift_x6;
63  float m1 =(record)[rawid].mult_x1;
64  float s1 =(record)[rawid].shift_x1;
65 
72  fout << rawid << " " << m12 << " " << m6 << " " << m1 << " " << s12 << " " << s6 << " " << s1 << "\n";
73  }
74 
75  for(int cellid = 0;
77  ++cellid) {
78  if(!EEDetId::validHashIndex(cellid)) continue;
79 
80  uint32_t rawid = EEDetId::unhashIndex(cellid);
81 
82  DOMElement* cellnode=writeCell(root,rawid);
83 
84  float m12=(record)[rawid].mult_x12;
85  float s12=(record)[rawid].shift_x12;
86  float m6 =(record)[rawid].mult_x6;
87  float s6 =(record)[rawid].shift_x6;
88  float m1 =(record)[rawid].mult_x1;
89  float s1 =(record)[rawid].shift_x1;
90 
97  fout << rawid << " " << m12 << " " << m6 << " " << m1 << " " << s12 << " " << s6 << " " << s1 << "\n";
98 
99  }
100  fout.close();
101  std::string dump= toNative(writer->writeToString(*root));
102  doc->release();
103 
104  return dump;
105 }
const std::string Linearization_m1_tag("mult1")
static std::string dumpXML(const EcalCondHeader &header, const EcalTPGLinearizationConst &record)
const std::string Linearization_s12_tag("shift12")
JetCorrectorParameters::Record record
Definition: classes.h:7
void xercesInitialize()
Definition: Xerces.cc:17
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:99
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")
const std::string Linearization_s6_tag("shift6")
static const int MIN_HASH
Definition: EBDetId.h:156
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
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:114
tuple filename
Definition: lut2db_cfg.py:20
XercesString fromNative(const char *str)
Definition: XercesString.h:31
const std::string Linearization_tag("EcalTPGLinearizationConts")
xercesc::DOMElement * writeCell(xercesc::DOMNode *node, const DetId &detid)
Append a Cell node with attributes to.
std::string toNative(const XMLCh *str)
Definition: XercesString.h:42