43 : m_fileName(iConfig.getParameter<
std::
string>(
"fileName")),
44 m_survey(iConfig.getParameter<
bool>(
"survey")),
45 m_rawIds(iConfig.getParameter<
bool>(
"rawIds")),
46 m_eulerAngles(iConfig.getParameter<
bool>(
"eulerAngles")),
47 m_precision(iConfig.getParameter<
int>(
"precision")),
48 m_suppressDTBarrel(iConfig.getUntrackedParameter<
bool>(
"suppressDTBarrel",
false)),
49 m_suppressDTWheels(iConfig.getUntrackedParameter<
bool>(
"suppressDTWheels",
false)),
50 m_suppressDTStations(iConfig.getUntrackedParameter<
bool>(
"suppressDTStations",
false)),
51 m_suppressDTChambers(iConfig.getUntrackedParameter<
bool>(
"suppressDTChambers",
false)),
52 m_suppressDTSuperLayers(iConfig.getUntrackedParameter<
bool>(
"suppressDTSuperLayers",
false)),
53 m_suppressDTLayers(iConfig.getUntrackedParameter<
bool>(
"suppressDTLayers",
false)),
54 m_suppressCSCEndcaps(iConfig.getUntrackedParameter<
bool>(
"suppressCSCEndcaps",
false)),
55 m_suppressCSCStations(iConfig.getUntrackedParameter<
bool>(
"suppressCSCStations",
false)),
56 m_suppressCSCRings(iConfig.getUntrackedParameter<
bool>(
"suppressCSCRings",
false)),
57 m_suppressCSCChambers(iConfig.getUntrackedParameter<
bool>(
"suppressCSCChambers",
false)),
58 m_suppressCSCLayers(iConfig.getUntrackedParameter<
bool>(
"suppressCSCLayers",
false)),
59 idealGeometryLabel(
"idealForOutputXML") {
64 }
else if (str_relativeto ==
std::string(
"ideal")) {
66 }
else if (str_relativeto ==
std::string(
"container")) {
69 throw cms::Exception(
"BadConfig") <<
"relativeto must be \"none\", \"ideal\", or \"container\"" << std::endl;
100 outputFile <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
101 outputFile <<
"<?xml-stylesheet type=\"text/xml\" href=\"MuonAlignment.xsl\"?>" << std::endl;
102 outputFile <<
"<MuonAlignment>" << std::endl << std::endl;
104 std::map<align::ID, CLHEP::HepSymMatrix>
errors;
107 for (std::vector<AlignTransformErrorExtended>::const_iterator dtError = dtErrors->
m_alignError.begin();
110 errors[dtError->rawId()] = dtError->matrix();
112 for (std::vector<AlignTransformErrorExtended>::const_iterator cscError = cscErrors->
m_alignError.begin();
115 errors[cscError->rawId()] = cscError->matrix();
143 outputFile <<
"</MuonAlignment>" << std::endl;
148 std::map<align::ID, CLHEP::HepSymMatrix> &
errors,
152 align::Alignables::const_iterator ideal = ideals.begin();
153 for (align::Alignables::const_iterator alignable = alignables.begin(); alignable != alignables.end(); ++alignable) {
154 if (
m_survey && (*alignable)->survey() ==
nullptr) {
155 throw cms::Exception(
"Alignment") <<
"SurveyDets must all be defined when writing to XML" << std::endl;
171 unsigned int rawId = (*alignable)->geomDetId().rawId();
185 outputFile <<
" <DTLayer wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\""
186 <<
id.sector() <<
"\" superlayer=\"" <<
id.superlayer() <<
"\" layer=\"" <<
id.layer() <<
"\" />"
190 outputFile <<
" <DTSuperLayer wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\""
191 <<
id.sector() <<
"\" superlayer=\"" <<
id.superlayer() <<
"\" />" << std::endl;
194 outputFile <<
" <DTChamber wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\""
195 <<
id.sector() <<
"\" />" << std::endl;
201 outputFile <<
" <DTStation wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" />"
204 outputFile <<
" <DTWheel wheel=\"" <<
id.wheel() <<
"\" />" << std::endl;
208 throw cms::Exception(
"Alignment") <<
"Unknown DT Alignable StructureType" << std::endl;
223 outputFile <<
" <CSCLayer endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\""
224 <<
id.ring() <<
"\" chamber=\"" <<
id.chamber() <<
"\" layer=\"" <<
id.layer() <<
"\" />"
228 outputFile <<
" <CSCChamber endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\""
229 <<
id.ring() <<
"\" chamber=\"" <<
id.chamber() <<
"\" />" << std::endl;
233 outputFile <<
" <CSCRing endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\""
234 <<
id.ring() <<
"\" />" << std::endl;
236 outputFile <<
" <CSCStation endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" />"
239 outputFile <<
" <CSCEndcap endcap=\"" <<
id.endcap() <<
"\" />" << std::endl;
241 throw cms::Exception(
"Alignment") <<
"Unknown CSC Alignable StructureType" << std::endl;
251 pos = (*alignable)->survey()->position();
252 rot = (*alignable)->survey()->rotation();
261 if (ideal == ideals.end() || (*ideal)->alignableObjectId() != alignableObjectId ||
262 (*ideal)->id() != (*alignable)->id()) {
263 throw cms::Exception(
"Alignment") <<
"AlignableMuon and ideal_AlignableMuon are out of sync!" << std::endl;
274 bool csc_debug =
false;
275 if (csc_debug && !
DT) {
278 std::cout <<
" investigating " <<
id << std::endl
279 << (*alignable)->globalRotation() << std::endl
285 double phix = atan2(
rot.yz(),
rot.zz());
286 double phiy = asin(-
rot.xz());
287 double phiz = atan2(
rot.xy(),
rot.xx());
289 std::cout <<
"phix=\"" << phix <<
"\" phiy=\"" << phiy <<
"\" phiz=\"" << phiz << std::endl;
292 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\""
293 << eulerAngles(3) << std::endl;
295 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\""
296 << eulerAngles(3) << std::endl;
298 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\""
299 << eulerAngles(3) << std::endl;
304 else if (
m_relativeto == 2 && (*alignable)->mother() !=
nullptr) {
317 outputFile <<
" <setposition relativeto=\"" << str_relativeto <<
"\" "
318 <<
"x=\"" <<
pos.x() <<
"\" y=\"" <<
pos.y() <<
"\" z=\"" <<
pos.z() <<
"\" ";
322 outputFile <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" << eulerAngles(3)
323 <<
"\" />" << std::endl;
329 double phix = atan2(
rot.yz(),
rot.zz());
330 double phiy = asin(-
rot.xz());
331 double phiz = atan2(
rot.xy(),
rot.xx());
333 outputFile <<
"phix=\"" << phix <<
"\" phiy=\"" << phiy <<
"\" phiz=\"" << phiz <<
"\" />" << std::endl;
340 <<
" xx=\"" <<
err(0, 0) <<
"\" xy=\"" <<
err(0, 1) <<
"\" xz=\"" <<
err(0, 2) <<
"\" xa=\""
341 <<
err(0, 3) <<
"\" xb=\"" <<
err(0, 4) <<
"\" xc=\"" <<
err(0, 5) <<
"\" yy=\"" <<
err(1, 1)
342 <<
"\" yz=\"" <<
err(1, 2) <<
"\" ya=\"" <<
err(1, 3) <<
"\" yb=\"" <<
err(1, 4) <<
"\" yc=\""
343 <<
err(1, 5) <<
"\" zz=\"" <<
err(2, 2) <<
"\" za=\"" <<
err(2, 3) <<
"\" zb=\"" <<
err(2, 4)
344 <<
"\" zc=\"" <<
err(2, 5) <<
"\" aa=\"" <<
err(3, 3) <<
"\" ab=\"" <<
err(3, 4) <<
"\" ac=\""
345 <<
err(3, 5) <<
"\" bb=\"" <<
err(4, 4) <<
"\" bc=\"" <<
err(4, 5) <<
"\" cc=\"" <<
err(5, 5)
346 <<
"\" />" << std::endl;
349 else if (rawId != 0) {
350 CLHEP::HepSymMatrix
err =
errors[(*alignable)->id()];
352 outputFile <<
" <setape xx=\"" <<
err(1, 1) <<
"\" xy=\"" <<
err(1, 2) <<
"\" xz=\"" <<
err(1, 3) <<
"\" xa=\""
353 <<
err(1, 4) <<
"\" xb=\"" <<
err(1, 5) <<
"\" xc=\"" <<
err(1, 6) <<
"\" yy=\"" <<
err(2, 2)
354 <<
"\" yz=\"" <<
err(2, 3) <<
"\" ya=\"" <<
err(2, 4) <<
"\" yb=\"" <<
err(2, 5) <<
"\" yc=\""
355 <<
err(2, 6) <<
"\" zz=\"" <<
err(3, 3) <<
"\" za=\"" <<
err(3, 4) <<
"\" zb=\"" <<
err(3, 5)
356 <<
"\" zc=\"" <<
err(3, 6) <<
"\" aa=\"" <<
err(4, 4) <<
"\" ab=\"" <<
err(4, 5) <<
"\" ac=\""
357 <<
err(4, 6) <<
"\" bb=\"" <<
err(5, 5) <<
"\" bc=\"" <<
err(5, 6) <<
"\" cc=\"" <<
err(6, 6)
358 <<
"\" />" << std::endl;
361 outputFile <<
"</operation>" << std::endl << std::endl;
366 if (ideal != ideals.end()) {