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
EcalAlignmentXMLTranslator Class Reference

#include <EcalAlignmentXMLTranslator.h>

Static Public Member Functions

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

Detailed Description

Definition at line 21 of file EcalAlignmentXMLTranslator.h.

Member Function Documentation

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

Definition at line 28 of file EcalAlignmentXMLTranslator.cc.

References xuti::AlignmentConstant_tag(), xuti::Cell_tag(), gather_cfg::cout, hcal_timing_source_file_cfg::dump, xuti::fromNative(), xuti::id_tag(), Alignments::m_align, phi(), xuti::Phi_tag(), xuti::Psi_tag(), pyrootRender::root, xuti::subdet_tag(), xuti::Theta_tag(), xuti::toNative(), xuti::writeHeader(), xuti::WriteNodeWithValue(), x(), xuti::x_tag(), cms::concurrency::xercesInitialize(), xuti::y_tag(), and xuti::z_tag().

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

Definition at line 20 of file EcalAlignmentXMLTranslator.cc.

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

22  {
23  fstream fs(filename.c_str(),ios::out);
24  fs<< dumpXML(header,record);
25  return 0;
26 }
static std::string dumpXML(const EcalCondHeader &header, const Alignments &record)
tuple filename
Definition: lut2db_cfg.py:20