test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Static Public Member Functions
EcalTPGLinearizationConstXMLTranslator Class Reference

#include <EcalTPGLinearizationConstXMLTranslator.h>

Static Public Member Functions

static std::string dumpXML (const EcalCondHeader &header, const EcalTPGLinearizationConst &record)
 
static int writeXML (const std::string &filename, const EcalCondHeader &header, const EcalTPGLinearizationConst &record)
 

Detailed Description

Translates a EcalTPGLinearizationConst record to XML

Version
Id:
EcalTPGLinearizationConstXMLTranslator.h,v 1.0 2012/05/01 13:48:05 Exp
Date
01 May 2012

Definition at line 24 of file EcalTPGLinearizationConstXMLTranslator.h.

Member Function Documentation

std::string EcalTPGLinearizationConstXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalTPGLinearizationConst record 
)
static

Definition at line 23 of file EcalTPGLinearizationConstXMLTranslator.cc.

References hcal_timing_source_file_cfg::dump, groupFilesInBlocks::fout, xuti::fromNative(), EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, xuti::Linearization_m12_tag(), xuti::Linearization_m1_tag(), xuti::Linearization_m6_tag(), xuti::Linearization_s12_tag(), xuti::Linearization_s1_tag(), xuti::Linearization_s6_tag(), xuti::Linearization_tag(), EBDetId::MIN_HASH, record, pyrootRender::root, AlCaHLTBitMon_QueryRunRegistry::string, xuti::toNative(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), EEDetId::validHashIndex(), xuti::writeCell(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cms::concurrency::xercesInitialize().

24  {
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")
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 EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:114
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
int EcalTPGLinearizationConstXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalTPGLinearizationConst record 
)
static

Definition at line 15 of file EcalTPGLinearizationConstXMLTranslator.cc.

References EcalCondTools::dumpXML(), and GenerateHcalLaserBadRunList::out.

17  {
18  std::fstream fs(filename.c_str(),ios::out);
19  fs<< dumpXML(header,record);
20  return 0;
21 }
static std::string dumpXML(const EcalCondHeader &header, const EcalTPGLinearizationConst &record)
tuple filename
Definition: lut2db_cfg.py:20