CMS 3D CMS Logo

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

#include <EcalAlignmentXMLTranslator.h>

Static Public Member Functions

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

Static Private Member Functions

static std::string dumpXML (const EcalCondHeader &header, const Alignments &record)
 

Detailed Description

Definition at line 18 of file EcalAlignmentXMLTranslator.h.

Member Function Documentation

◆ dumpXML()

string EcalAlignmentXMLTranslator::dumpXML ( const EcalCondHeader header,
const Alignments record 
)
staticprivate

Definition at line 33 of file EcalAlignmentXMLTranslator.cc.

References xuti::AlignmentConstant_tag(), xuti::Cell_tag(), gather_cfg::cout, boostedTaus_cff::doc, submitPVValidationJobs::dump, RecoTauValidation_cfi::header, xuti::id_tag(), xuti::Phi_tag(), xuti::Psi_tag(), AlCaHarvesting_cff::record, AlCaHLTBitMon_QueryRunRegistry::string, xuti::subdet_tag(), xuti::Theta_tag(), cms::xerces::toString(), cms::xerces::uStr(), xuti::writeHeader(), xuti::WriteNodeWithValue(), convertToRaw::writer, x, xuti::x_tag(), xuti::y_tag(), and xuti::z_tag().

33  {
34  unique_ptr<DOMImplementation> impl(DOMImplementationRegistry::getDOMImplementation(cms::xerces::uStr("LS").ptr()));
35 
36  DOMLSSerializer* writer = impl->createLSSerializer();
37  if (writer->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
38  writer->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
39 
40  DOMDocumentType* doctype = impl->createDocumentType(cms::xerces::uStr("XML").ptr(), nullptr, nullptr);
41  DOMDocument* doc = impl->createDocument(nullptr, cms::xerces::uStr(AlignmentConstant_tag.c_str()).ptr(), doctype);
42  DOMElement* root = doc->getDocumentElement();
43 
45 
46  for (vector<AlignTransform>::const_iterator it = record.m_align.begin(); it != record.m_align.end(); it++) {
47  int Id = (*it).rawId();
48  int sub = (Id >> 24) & 0xF;
49  stringstream subdet;
50  if (sub == 2) {
51  subdet << "EB";
52  int SM;
53  int phi = Id & 0x1FF;
54  // int eta = (Id>>9)&0x3F;
55  int side = (Id >> 16) & 1;
56  if (side == 0) {
57  subdet << "-";
58  SM = (phi + 19) / 20;
59  } else {
60  subdet << "+";
61  SM = phi / 20;
62  }
63  if (SM < 10)
64  subdet << "0" << SM;
65  else
66  subdet << SM;
67  } else if (sub == 4) {
68  subdet << "EE";
69  // int y = Id&0x7F;
70  int x = (Id >> 7) & 0x7F;
71  // int Dee = x/70 + 1;
72  int side = (Id >> 14) & 1;
73  if (side == 0) {
74  subdet << "-";
75  } else {
76  subdet << "+";
77  }
78  // subdet << "0" << Dee;
79  if (x == 20)
80  subdet << "F";
81  else if (x == 70)
82  subdet << "N";
83  else
84  cout << " strange value for x " << x << endl; // should never occur
85  } else if (sub == 6) {
86  subdet << "ES";
87  // int strip = Id&0x3F;
88  int x = (Id >> 6) & 0x3F;
89  // int y = (Id>>12)&0x3F;
90  int plane = (Id >> 18) & 1;
91  int side = (Id >> 19) & 1;
92  if (side == 0)
93  subdet << "-";
94  else
95  subdet << "+";
96  if (plane)
97  subdet << "F";
98  else
99  subdet << "R";
100  if (x / 30)
101  subdet << "F";
102  else
103  subdet << "N";
104  } else
105  cout << " problem sub = " << sub << endl;
106  cout << (*it).rawId() << " " << (*it).rotation().getPhi() << " " << (*it).rotation().getTheta() << " "
107  << (*it).rotation().getPsi() << " " << (*it).translation().x() << " " << (*it).translation().y() << " "
108  << (*it).translation().z() << endl;
109  uint32_t rawid = (*it).rawId();
110  DOMElement* cellnode = root->getOwnerDocument()->createElement(cms::xerces::uStr(Cell_tag.c_str()).ptr());
111  root->appendChild(cellnode);
112  cellnode->setAttribute(cms::xerces::uStr(subdet_tag.c_str()).ptr(), cms::xerces::uStr(subdet.str().c_str()).ptr());
113  xuti::WriteNodeWithValue(cellnode, id_tag, rawid);
114  xuti::WriteNodeWithValue(cellnode, x_tag, (*it).translation().x());
115  xuti::WriteNodeWithValue(cellnode, y_tag, (*it).translation().y());
116  xuti::WriteNodeWithValue(cellnode, z_tag, (*it).translation().z());
117  xuti::WriteNodeWithValue(cellnode, Phi_tag, (*it).rotation().getPhi());
118  xuti::WriteNodeWithValue(cellnode, Theta_tag, (*it).rotation().getTheta());
119  xuti::WriteNodeWithValue(cellnode, Psi_tag, (*it).rotation().getPsi());
120  }
121 
122  std::string dump = cms::xerces::toString(writer->writeToString(root));
123  doc->release();
124  doctype->release();
125  writer->release();
126 
127  return dump;
128 }
const std::string Phi_tag("Phi")
const std::string x_tag("x")
const std::string id_tag("id")
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
std::string toString(XMLCh const *toTranscode)
const std::string y_tag("y")
const std::string Cell_tag("cell")
const std::string subdet_tag("SubDet")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
ZStr< XMLCh > uStr(char const *str)
const std::string z_tag("z")
const std::string Psi_tag("Psi")
const std::string Theta_tag("Theta")
const std::string AlignmentConstant_tag("EcalAlignmentConstant")

◆ writeXML()

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