CMS 3D CMS Logo

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

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

Definition at line 34 of file EcalAlignmentXMLTranslator.cc.

References xuti::AlignmentConstant_tag(), xuti::Cell_tag(), gather_cfg::cout, common_cff::doc, FrontierConditions_GlobalTag_cff::dump, xuti::id_tag(), Alignments::m_align, xuti::Phi_tag(), xuti::Psi_tag(), AlCaHLTBitMon_QueryRunRegistry::string, xuti::subdet_tag(), xuti::Theta_tag(), cms::xerces::toString(), cms::xerces::uStr(), xuti::writeHeader(), xuti::WriteNodeWithValue(), cscNeutronWriter_cfi::writer, xuti::x_tag(), xuti::y_tag(), and xuti::z_tag().

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

Definition at line 21 of file EcalAlignmentXMLTranslator.cc.

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

23  {
25 
26  fstream fs(filename.c_str(),ios::out);
27  fs<< dumpXML(header,record);
28 
30 
31  return 0;
32 }
void xercesTerminate()
Definition: Xerces.cc:23
void xercesInitialize()
Definition: Xerces.cc:18
static std::string dumpXML(const EcalCondHeader &header, const Alignments &record)