CMS 3D CMS Logo

List of all members | Static Public Member Functions | Static Private Member Functions
EcalTPGLinearizationConstXMLTranslator Class Reference

#include <EcalTPGLinearizationConstXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

static std::string dumpXML (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 14 of file EcalTPGLinearizationConstXMLTranslator.h.

Member Function Documentation

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

Definition at line 30 of file EcalTPGLinearizationConstXMLTranslator.cc.

References common_cff::doc, FrontierConditions_GlobalTag_cff::dump, groupFilesInBlocks::fout, 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, AlCaHLTBitMon_QueryRunRegistry::string, cms::xerces::toString(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), cms::xerces::uStr(), EEDetId::validHashIndex(), xuti::writeCell(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cscNeutronWriter_cfi::writer.

31  {
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")
const std::string Linearization_s12_tag("shift12")
JetCorrectorParameters::Record record
Definition: classes.h:7
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 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.
int EcalTPGLinearizationConstXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalTPGLinearizationConst record 
)
static

Definition at line 17 of file EcalTPGLinearizationConstXMLTranslator.cc.

References EcalCondTools::dumpXML(), MillePedeFileConverter_cfg::out, cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

19  {
21 
22  std::fstream fs(filename.c_str(),ios::out);
23  fs<< dumpXML(header,record);
24 
26 
27  return 0;
28 }
static std::string dumpXML(const EcalCondHeader &header, const EcalTPGLinearizationConst &record)
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18