46 : m_fileName(iConfig.getParameter<
std::
string>(
"fileName")),
47 m_survey(iConfig.getParameter<
bool>(
"survey")),
48 m_rawIds(iConfig.getParameter<
bool>(
"rawIds")),
49 m_eulerAngles(iConfig.getParameter<
bool>(
"eulerAngles")),
50 m_precision(iConfig.getParameter<
int>(
"precision")),
51 m_suppressDTBarrel(iConfig.getUntrackedParameter<
bool>(
"suppressDTBarrel",
false)),
52 m_suppressDTWheels(iConfig.getUntrackedParameter<
bool>(
"suppressDTWheels",
false)),
53 m_suppressDTStations(iConfig.getUntrackedParameter<
bool>(
"suppressDTStations",
false)),
54 m_suppressDTChambers(iConfig.getUntrackedParameter<
bool>(
"suppressDTChambers",
false)),
55 m_suppressDTSuperLayers(iConfig.getUntrackedParameter<
bool>(
"suppressDTSuperLayers",
false)),
56 m_suppressDTLayers(iConfig.getUntrackedParameter<
bool>(
"suppressDTLayers",
false)),
57 m_suppressCSCEndcaps(iConfig.getUntrackedParameter<
bool>(
"suppressCSCEndcaps",
false)),
58 m_suppressCSCStations(iConfig.getUntrackedParameter<
bool>(
"suppressCSCStations",
false)),
59 m_suppressCSCRings(iConfig.getUntrackedParameter<
bool>(
"suppressCSCRings",
false)),
60 m_suppressCSCChambers(iConfig.getUntrackedParameter<
bool>(
"suppressCSCChambers",
false)),
61 m_suppressCSCLayers(iConfig.getUntrackedParameter<
bool>(
"suppressCSCLayers",
false)),
62 m_suppressGEMEndcaps(iConfig.getUntrackedParameter<
bool>(
"suppressGEMEndcaps",
false)),
63 m_suppressGEMStations(iConfig.getUntrackedParameter<
bool>(
"suppressGEMStations",
false)),
64 m_suppressGEMRings(iConfig.getUntrackedParameter<
bool>(
"suppressGEMRings",
false)),
65 m_suppressGEMSuperChambers(iConfig.getUntrackedParameter<
bool>(
"suppressGEMSuperChambers",
false)),
66 m_suppressGEMChambers(iConfig.getUntrackedParameter<
bool>(
"suppressGEMChambers",
false)),
67 m_suppressGEMEtaPartitions(iConfig.getUntrackedParameter<
bool>(
"suppressGEMEtaPartitions",
false)),
68 dtGeometry_(dtGeometry),
69 cscGeometry_(cscGeometry),
75 }
else if (str_relativeto ==
std::string(
"ideal")) {
77 }
else if (str_relativeto ==
std::string(
"container")) {
80 throw cms::Exception(
"BadConfig") <<
"relativeto must be \"none\", \"ideal\", or \"container\"" << std::endl;
111 outputFile <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
112 outputFile <<
"<?xml-stylesheet type=\"text/xml\" href=\"MuonAlignment.xsl\"?>" << std::endl;
113 outputFile <<
"<MuonAlignment>" << std::endl << std::endl;
115 std::map<align::ID, CLHEP::HepSymMatrix>
errors;
119 for (std::vector<AlignTransformErrorExtended>::const_iterator dtError = dtErrors->
m_alignError.begin();
122 errors[dtError->rawId()] = dtError->matrix();
124 for (std::vector<AlignTransformErrorExtended>::const_iterator cscError = cscErrors->
m_alignError.begin();
127 errors[cscError->rawId()] = cscError->matrix();
129 for (std::vector<AlignTransformErrorExtended>::const_iterator gemError = gemErrors->
m_alignError.begin();
132 errors[gemError->rawId()] = gemError->matrix();
157 outputFile <<
"</MuonAlignment>" << std::endl;
162 std::map<align::ID, CLHEP::HepSymMatrix> &
errors,
166 align::Alignables::const_iterator ideal = ideals.begin();
167 for (align::Alignables::const_iterator alignable = alignables.begin(); alignable != alignables.end(); ++alignable) {
168 if (
m_survey && (*alignable)->survey() ==
nullptr) {
169 throw cms::Exception(
"Alignment") <<
"SurveyDets must all be defined when writing to XML" << std::endl;
194 unsigned int rawId = (*alignable)->geomDetId().rawId();
208 outputFile <<
" <DTLayer wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\"" 209 <<
id.sector() <<
"\" superlayer=\"" <<
id.superlayer() <<
"\" layer=\"" <<
id.layer() <<
"\" />" 213 outputFile <<
" <DTSuperLayer wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\"" 214 <<
id.sector() <<
"\" superlayer=\"" <<
id.superlayer() <<
"\" />" << std::endl;
217 outputFile <<
" <DTChamber wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\"" 218 <<
id.sector() <<
"\" />" << std::endl;
222 outputFile <<
" <DTStation wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" />" 225 outputFile <<
" <DTWheel wheel=\"" <<
id.wheel() <<
"\" />" << std::endl;
229 throw cms::Exception(
"Alignment") <<
"Unknown DT Alignable StructureType" << std::endl;
235 if (doDet ==
doCSC) {
244 outputFile <<
" <CSCLayer endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\"" 245 <<
id.ring() <<
"\" chamber=\"" <<
id.chamber() <<
"\" layer=\"" <<
id.layer() <<
"\" />" 249 outputFile <<
" <CSCChamber endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\"" 250 <<
id.ring() <<
"\" chamber=\"" <<
id.chamber() <<
"\" />" << std::endl;
254 outputFile <<
" <CSCRing endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\"" 255 <<
id.ring() <<
"\" />" << std::endl;
257 outputFile <<
" <CSCStation endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" />" 260 outputFile <<
" <CSCEndcap endcap=\"" <<
id.endcap() <<
"\" />" << std::endl;
262 throw cms::Exception(
"Alignment") <<
"Unknown CSC Alignable StructureType" << std::endl;
268 if (doDet ==
doGEM) {
277 outputFile <<
" <GEMSuperChambers endcap=\"" <<
id.region() <<
"\" station=\"" <<
id.station()
278 <<
"\" ring=\"" <<
id.ring() <<
"\" superchamber=\"" <<
id.chamber() <<
"\" layer=\"" 279 <<
id.layer() <<
"\" />" << std::endl;
282 outputFile <<
" <GEMSuperChamber endcap=\"" <<
id.region() <<
"\" station=\"" <<
id.station()
283 <<
"\" ring=\"" <<
id.ring() <<
"\" chamber=\"" <<
id.chamber() <<
"\" />" << std::endl;
287 outputFile <<
" <GEMRing endcap=\"" <<
id.region() <<
"\" station=\"" <<
id.station() <<
"\" ring=\"" 288 <<
id.ring() <<
"\" />" << std::endl;
290 outputFile <<
" <GEMStation endcap=\"" <<
id.region() <<
"\" station=\"" <<
id.station() <<
"\" />" 293 outputFile <<
" <GEMEndcap endcap=\"" <<
id.region() <<
"\" />" << std::endl;
295 throw cms::Exception(
"Alignment") <<
"Unknown GEM Alignable StructureType" << std::endl;
305 pos = (*alignable)->survey()->position();
306 rot = (*alignable)->survey()->rotation();
315 if (ideal == ideals.end() || (*ideal)->alignableObjectId() != alignableObjectId ||
316 (*ideal)->id() != (*alignable)->id()) {
317 throw cms::Exception(
"Alignment") <<
"AlignableMuon and ideal_AlignableMuon are out of sync!" << std::endl;
328 bool csc_debug =
false;
329 if (csc_debug && doDet ==
doCSC) {
332 std::cout <<
" investigating " <<
id << std::endl
333 << (*alignable)->globalRotation() << std::endl
339 double phix = atan2(
rot.yz(),
rot.zz());
340 double phiy = asin(-
rot.xz());
341 double phiz = atan2(
rot.xy(),
rot.xx());
343 std::cout <<
"phix=\"" << phix <<
"\" phiy=\"" << phiy <<
"\" phiz=\"" << phiz << std::endl;
346 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" 347 << eulerAngles(3) << std::endl;
349 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" 350 << eulerAngles(3) << std::endl;
352 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" 353 << eulerAngles(3) << std::endl;
358 else if (
m_relativeto == 2 && (*alignable)->mother() !=
nullptr) {
371 outputFile <<
" <setposition relativeto=\"" << str_relativeto <<
"\" " 372 <<
"x=\"" <<
pos.x() <<
"\" y=\"" <<
pos.y() <<
"\" z=\"" <<
pos.z() <<
"\" ";
376 outputFile <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" << eulerAngles(3)
377 <<
"\" />" << std::endl;
383 double phix = atan2(
rot.yz(),
rot.zz());
384 double phiy = asin(-
rot.xz());
385 double phiz = atan2(
rot.xy(),
rot.xx());
387 outputFile <<
"phix=\"" << phix <<
"\" phiy=\"" << phiy <<
"\" phiz=\"" << phiz <<
"\" />" << std::endl;
394 <<
" xx=\"" <<
err(0, 0) <<
"\" xy=\"" <<
err(0, 1) <<
"\" xz=\"" <<
err(0, 2) <<
"\" xa=\"" 395 <<
err(0, 3) <<
"\" xb=\"" <<
err(0, 4) <<
"\" xc=\"" <<
err(0, 5) <<
"\" yy=\"" <<
err(1, 1)
396 <<
"\" yz=\"" <<
err(1, 2) <<
"\" ya=\"" <<
err(1, 3) <<
"\" yb=\"" <<
err(1, 4) <<
"\" yc=\"" 397 <<
err(1, 5) <<
"\" zz=\"" <<
err(2, 2) <<
"\" za=\"" <<
err(2, 3) <<
"\" zb=\"" <<
err(2, 4)
398 <<
"\" zc=\"" <<
err(2, 5) <<
"\" aa=\"" <<
err(3, 3) <<
"\" ab=\"" <<
err(3, 4) <<
"\" ac=\"" 399 <<
err(3, 5) <<
"\" bb=\"" <<
err(4, 4) <<
"\" bc=\"" <<
err(4, 5) <<
"\" cc=\"" <<
err(5, 5)
400 <<
"\" />" << std::endl;
403 else if (
rawId != 0) {
404 CLHEP::HepSymMatrix
err =
errors[(*alignable)->id()];
406 outputFile <<
" <setape xx=\"" <<
err(1, 1) <<
"\" xy=\"" <<
err(1, 2) <<
"\" xz=\"" <<
err(1, 3) <<
"\" xa=\"" 407 <<
err(1, 4) <<
"\" xb=\"" <<
err(1, 5) <<
"\" xc=\"" <<
err(1, 6) <<
"\" yy=\"" <<
err(2, 2)
408 <<
"\" yz=\"" <<
err(2, 3) <<
"\" ya=\"" <<
err(2, 4) <<
"\" yb=\"" <<
err(2, 5) <<
"\" yc=\"" 409 <<
err(2, 6) <<
"\" zz=\"" <<
err(3, 3) <<
"\" za=\"" <<
err(3, 4) <<
"\" zb=\"" <<
err(3, 5)
410 <<
"\" zc=\"" <<
err(3, 6) <<
"\" aa=\"" <<
err(4, 4) <<
"\" ab=\"" <<
err(4, 5) <<
"\" ac=\"" 411 <<
err(4, 6) <<
"\" bb=\"" <<
err(5, 5) <<
"\" bc=\"" <<
err(5, 6) <<
"\" cc=\"" <<
err(6, 6)
412 <<
"\" />" << std::endl;
415 outputFile <<
"</operation>" << std::endl << std::endl;
420 if (ideal != ideals.end()) {
bool m_suppressCSCEndcaps
const GEMGeometry * gemGeometry_
T getParameter(std::string const &) const
bool m_suppressDTStations
const CSCGeometry * cscGeometry_
bool m_suppressGEMStations
bool m_suppressCSCChambers
const AlignableObjectId & objectIdProvider() const
Return muon alignable object ID provider derived from the muon system geometry.
align::Alignables DTBarrel()
void write(AlignableMuon *alignableMuon) const
bool m_suppressGEMEndcaps
Point3DBase< Scalar, GlobalTag > PositionType
const DTGeometry * dtGeometry_
TkRotation transposed() const
align::Alignables CSCEndcaps()
bool m_suppressCSCStations
bool m_suppressDTChambers
bool m_suppressGEMEtaPartitions
Allows conversion between type and name, and vice-versa.
bool m_suppressDTSuperLayers
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
const BasicVectorType & basicVector() const
AlignmentErrorsExtended * cscAlignmentErrorsExtended()
Get CSC alignment errors sorted by DetId.
AlgebraicVector EulerAngles
std::vector< AlignTransformErrorExtended > m_alignError
const char * idToString(align::StructureType type) const
MuonAlignmentOutputXML(const edm::ParameterSet &iConfig, const DTGeometry *dtGeometry, const CSCGeometry *cscGeometry, const GEMGeometry *gemGeometry)
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
Get DT alignment errors sorted by DetId.
bool m_suppressGEMSuperChambers
AlignmentErrorsExtended * gemAlignmentErrorsExtended()
std::vector< Alignable * > Alignables
align::Alignables GEMEndcaps()
math::Error< 6 >::type ErrorMatrix
void writeComponents(align::Alignables &alignables, align::Alignables &ideals, std::map< align::ID, CLHEP::HepSymMatrix > &errors, std::ofstream &outputFile, const int doDet, const AlignableObjectId &) const
bool m_suppressGEMChambers
virtual ~MuonAlignmentOutputXML()
Constructor of the full muon geometry.