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();
127 AlignableMuon ideal_alignableMuon(&(*dtGeometry), &(*cscGeometry));
141 outputFile <<
"</MuonAlignment>" << std::endl;
146 std::map<align::ID, CLHEP::HepSymMatrix> &
errors,
150 align::Alignables::const_iterator ideal = ideals.begin();
151 for (align::Alignables::const_iterator alignable = alignables.begin(); alignable != alignables.end(); ++alignable) {
152 if (
m_survey && (*alignable)->survey() ==
nullptr) {
153 throw cms::Exception(
"Alignment") <<
"SurveyDets must all be defined when writing to XML" << std::endl;
169 unsigned int rawId = (*alignable)->geomDetId().rawId();
183 outputFile <<
" <DTLayer wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\""
184 <<
id.sector() <<
"\" superlayer=\"" <<
id.superlayer() <<
"\" layer=\"" <<
id.layer() <<
"\" />"
188 outputFile <<
" <DTSuperLayer wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\""
189 <<
id.sector() <<
"\" superlayer=\"" <<
id.superlayer() <<
"\" />" << std::endl;
192 outputFile <<
" <DTChamber wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\""
193 <<
id.sector() <<
"\" />" << std::endl;
199 outputFile <<
" <DTStation wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" />"
202 outputFile <<
" <DTWheel wheel=\"" <<
id.wheel() <<
"\" />" << std::endl;
206 throw cms::Exception(
"Alignment") <<
"Unknown DT Alignable StructureType" << std::endl;
221 outputFile <<
" <CSCLayer endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\""
222 <<
id.ring() <<
"\" chamber=\"" <<
id.chamber() <<
"\" layer=\"" <<
id.layer() <<
"\" />"
226 outputFile <<
" <CSCChamber endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\""
227 <<
id.ring() <<
"\" chamber=\"" <<
id.chamber() <<
"\" />" << std::endl;
231 outputFile <<
" <CSCRing endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\""
232 <<
id.ring() <<
"\" />" << std::endl;
234 outputFile <<
" <CSCStation endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" />"
237 outputFile <<
" <CSCEndcap endcap=\"" <<
id.endcap() <<
"\" />" << std::endl;
239 throw cms::Exception(
"Alignment") <<
"Unknown CSC Alignable StructureType" << std::endl;
249 pos = (*alignable)->survey()->position();
250 rot = (*alignable)->survey()->rotation();
259 if (ideal == ideals.end() || (*ideal)->alignableObjectId() != alignableObjectId ||
260 (*ideal)->id() != (*alignable)->id()) {
261 throw cms::Exception(
"Alignment") <<
"AlignableMuon and ideal_AlignableMuon are out of sync!" << std::endl;
272 bool csc_debug =
false;
273 if (csc_debug && !
DT) {
276 std::cout <<
" investigating " <<
id << std::endl
277 << (*alignable)->globalRotation() << std::endl
283 double phix = atan2(
rot.yz(),
rot.zz());
284 double phiy = asin(-
rot.xz());
285 double phiz = atan2(
rot.xy(),
rot.xx());
287 std::cout <<
"phix=\"" << phix <<
"\" phiy=\"" << phiy <<
"\" phiz=\"" << phiz << std::endl;
290 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\""
291 << eulerAngles(3) << std::endl;
293 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\""
294 << eulerAngles(3) << std::endl;
296 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\""
297 << eulerAngles(3) << std::endl;
302 else if (
m_relativeto == 2 && (*alignable)->mother() !=
nullptr) {
315 outputFile <<
" <setposition relativeto=\"" << str_relativeto <<
"\" "
316 <<
"x=\"" <<
pos.x() <<
"\" y=\"" <<
pos.y() <<
"\" z=\"" <<
pos.z() <<
"\" ";
320 outputFile <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" << eulerAngles(3)
321 <<
"\" />" << std::endl;
327 double phix = atan2(
rot.yz(),
rot.zz());
328 double phiy = asin(-
rot.xz());
329 double phiz = atan2(
rot.xy(),
rot.xx());
331 outputFile <<
"phix=\"" << phix <<
"\" phiy=\"" << phiy <<
"\" phiz=\"" << phiz <<
"\" />" << std::endl;
338 <<
" xx=\"" <<
err(0, 0) <<
"\" xy=\"" <<
err(0, 1) <<
"\" xz=\"" <<
err(0, 2) <<
"\" xa=\""
339 <<
err(0, 3) <<
"\" xb=\"" <<
err(0, 4) <<
"\" xc=\"" <<
err(0, 5) <<
"\" yy=\"" <<
err(1, 1)
340 <<
"\" yz=\"" <<
err(1, 2) <<
"\" ya=\"" <<
err(1, 3) <<
"\" yb=\"" <<
err(1, 4) <<
"\" yc=\""
341 <<
err(1, 5) <<
"\" zz=\"" <<
err(2, 2) <<
"\" za=\"" <<
err(2, 3) <<
"\" zb=\"" <<
err(2, 4)
342 <<
"\" zc=\"" <<
err(2, 5) <<
"\" aa=\"" <<
err(3, 3) <<
"\" ab=\"" <<
err(3, 4) <<
"\" ac=\""
343 <<
err(3, 5) <<
"\" bb=\"" <<
err(4, 4) <<
"\" bc=\"" <<
err(4, 5) <<
"\" cc=\"" <<
err(5, 5)
344 <<
"\" />" << std::endl;
347 else if (rawId != 0) {
348 CLHEP::HepSymMatrix
err =
errors[(*alignable)->id()];
350 outputFile <<
" <setape xx=\"" <<
err(1, 1) <<
"\" xy=\"" <<
err(1, 2) <<
"\" xz=\"" <<
err(1, 3) <<
"\" xa=\""
351 <<
err(1, 4) <<
"\" xb=\"" <<
err(1, 5) <<
"\" xc=\"" <<
err(1, 6) <<
"\" yy=\"" <<
err(2, 2)
352 <<
"\" yz=\"" <<
err(2, 3) <<
"\" ya=\"" <<
err(2, 4) <<
"\" yb=\"" <<
err(2, 5) <<
"\" yc=\""
353 <<
err(2, 6) <<
"\" zz=\"" <<
err(3, 3) <<
"\" za=\"" <<
err(3, 4) <<
"\" zb=\"" <<
err(3, 5)
354 <<
"\" zc=\"" <<
err(3, 6) <<
"\" aa=\"" <<
err(4, 4) <<
"\" ab=\"" <<
err(4, 5) <<
"\" ac=\""
355 <<
err(4, 6) <<
"\" bb=\"" <<
err(5, 5) <<
"\" bc=\"" <<
err(5, 6) <<
"\" cc=\"" <<
err(6, 6)
356 <<
"\" />" << std::endl;
359 outputFile <<
"</operation>" << std::endl << std::endl;
364 if (ideal != ideals.end()) {