45 : m_fileName(iConfig.getParameter<
std::
string>(
"fileName")),
46 m_survey(iConfig.getParameter<
bool>(
"survey")),
47 m_rawIds(iConfig.getParameter<
bool>(
"rawIds")),
48 m_eulerAngles(iConfig.getParameter<
bool>(
"eulerAngles")),
49 m_precision(iConfig.getParameter<
int>(
"precision")),
50 m_suppressDTBarrel(iConfig.getUntrackedParameter<
bool>(
"suppressDTBarrel",
false)),
51 m_suppressDTWheels(iConfig.getUntrackedParameter<
bool>(
"suppressDTWheels",
false)),
52 m_suppressDTStations(iConfig.getUntrackedParameter<
bool>(
"suppressDTStations",
false)),
53 m_suppressDTChambers(iConfig.getUntrackedParameter<
bool>(
"suppressDTChambers",
false)),
54 m_suppressDTSuperLayers(iConfig.getUntrackedParameter<
bool>(
"suppressDTSuperLayers",
false)),
55 m_suppressDTLayers(iConfig.getUntrackedParameter<
bool>(
"suppressDTLayers",
false)),
56 m_suppressCSCEndcaps(iConfig.getUntrackedParameter<
bool>(
"suppressCSCEndcaps",
false)),
57 m_suppressCSCStations(iConfig.getUntrackedParameter<
bool>(
"suppressCSCStations",
false)),
58 m_suppressCSCRings(iConfig.getUntrackedParameter<
bool>(
"suppressCSCRings",
false)),
59 m_suppressCSCChambers(iConfig.getUntrackedParameter<
bool>(
"suppressCSCChambers",
false)),
60 m_suppressCSCLayers(iConfig.getUntrackedParameter<
bool>(
"suppressCSCLayers",
false)) {
65 }
else if (str_relativeto ==
std::string(
"ideal")) {
67 }
else if (str_relativeto ==
std::string(
"container")) {
70 throw cms::Exception(
"BadConfig") <<
"relativeto must be \"none\", \"ideal\", or \"container\"" << std::endl;
101 outputFile <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
102 outputFile <<
"<?xml-stylesheet type=\"text/xml\" href=\"MuonAlignment.xsl\"?>" << std::endl;
103 outputFile <<
"<MuonAlignment>" << std::endl << std::endl;
105 std::map<align::ID, CLHEP::HepSymMatrix>
errors;
108 for (std::vector<AlignTransformErrorExtended>::const_iterator dtError = dtErrors->
m_alignError.begin();
111 errors[dtError->rawId()] = dtError->matrix();
113 for (std::vector<AlignTransformErrorExtended>::const_iterator cscError = cscErrors->
m_alignError.begin();
116 errors[cscError->rawId()] = cscError->matrix();
131 auto dtGeometry = std::make_shared<DTGeometry>();
132 DTGeometryBuilder.
build(*dtGeometry, &(*cpv), *mdc);
134 auto boost_cscGeometry = std::make_shared<CSCGeometry>();
135 CSCGeometryBuilder.
build(*boost_cscGeometry, &(*cpv), *mdc);
137 AlignableMuon ideal_alignableMuon(&(*dtGeometry), &(*boost_cscGeometry));
151 outputFile <<
"</MuonAlignment>" << std::endl;
156 std::map<align::ID, CLHEP::HepSymMatrix> &
errors,
160 align::Alignables::const_iterator ideal = ideals.begin();
161 for (align::Alignables::const_iterator alignable = alignables.begin(); alignable != alignables.end(); ++alignable) {
162 if (
m_survey && (*alignable)->survey() ==
nullptr) {
163 throw cms::Exception(
"Alignment") <<
"SurveyDets must all be defined when writing to XML" << std::endl;
179 unsigned int rawId = (*alignable)->geomDetId().rawId();
180 outputFile <<
"<operation>" << std::endl;
189 outputFile <<
" <" << typeName <<
" rawId=\"" << rawId <<
"\" />" << std::endl;
193 outputFile <<
" <DTLayer wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\"" 194 <<
id.sector() <<
"\" superlayer=\"" <<
id.superlayer() <<
"\" layer=\"" <<
id.layer() <<
"\" />" 198 outputFile <<
" <DTSuperLayer wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\"" 199 <<
id.sector() <<
"\" superlayer=\"" <<
id.superlayer() <<
"\" />" << std::endl;
202 outputFile <<
" <DTChamber wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\"" 203 <<
id.sector() <<
"\" />" << std::endl;
209 outputFile <<
" <DTStation wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" />" 212 outputFile <<
" <DTWheel wheel=\"" <<
id.wheel() <<
"\" />" << std::endl;
214 outputFile <<
" <DTBarrel />" << std::endl;
216 throw cms::Exception(
"Alignment") <<
"Unknown DT Alignable StructureType" << std::endl;
227 outputFile <<
" <" << typeName <<
" rawId=\"" << rawId <<
"\" />" << std::endl;
231 outputFile <<
" <CSCLayer endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\"" 232 <<
id.ring() <<
"\" chamber=\"" <<
id.chamber() <<
"\" layer=\"" <<
id.layer() <<
"\" />" 236 outputFile <<
" <CSCChamber endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\"" 237 <<
id.ring() <<
"\" chamber=\"" <<
id.chamber() <<
"\" />" << std::endl;
241 outputFile <<
" <CSCRing endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\"" 242 <<
id.ring() <<
"\" />" << std::endl;
244 outputFile <<
" <CSCStation endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" />" 247 outputFile <<
" <CSCEndcap endcap=\"" <<
id.endcap() <<
"\" />" << std::endl;
249 throw cms::Exception(
"Alignment") <<
"Unknown CSC Alignable StructureType" << std::endl;
259 pos = (*alignable)->survey()->position();
260 rot = (*alignable)->survey()->rotation();
269 if (ideal == ideals.end() || (*ideal)->alignableObjectId() != alignableObjectId ||
270 (*ideal)->id() != (*alignable)->id()) {
271 throw cms::Exception(
"Alignment") <<
"AlignableMuon and ideal_AlignableMuon are out of sync!" << std::endl;
282 bool csc_debug =
false;
283 if (csc_debug && !DT) {
286 std::cout <<
" investigating " <<
id << std::endl
287 << (*alignable)->globalRotation() << std::endl
293 double phix = atan2(rot.
yz(), rot.
zz());
294 double phiy = asin(-rot.
xz());
295 double phiz = atan2(rot.
xy(), rot.
xx());
297 std::cout <<
"phix=\"" << phix <<
"\" phiy=\"" << phiy <<
"\" phiz=\"" << phiz << std::endl;
300 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" 301 << eulerAngles(3) << std::endl;
303 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" 304 << eulerAngles(3) << std::endl;
306 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" 307 << eulerAngles(3) << std::endl;
312 else if (
m_relativeto == 2 && (*alignable)->mother() !=
nullptr) {
325 outputFile <<
" <setposition relativeto=\"" << str_relativeto <<
"\" " 326 <<
"x=\"" << pos.
x() <<
"\" y=\"" << pos.
y() <<
"\" z=\"" << pos.
z() <<
"\" ";
330 outputFile <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" << eulerAngles(3)
331 <<
"\" />" << std::endl;
337 double phix = atan2(rot.
yz(), rot.
zz());
338 double phiy = asin(-rot.
xz());
339 double phiz = atan2(rot.
xy(), rot.
xx());
341 outputFile <<
"phix=\"" << phix <<
"\" phiy=\"" << phiy <<
"\" phiz=\"" << phiz <<
"\" />" << std::endl;
347 outputFile <<
" <setsurveyerr" 348 <<
" xx=\"" <<
err(0, 0) <<
"\" xy=\"" <<
err(0, 1) <<
"\" xz=\"" <<
err(0, 2) <<
"\" xa=\"" 349 <<
err(0, 3) <<
"\" xb=\"" <<
err(0, 4) <<
"\" xc=\"" <<
err(0, 5) <<
"\" yy=\"" <<
err(1, 1)
350 <<
"\" yz=\"" <<
err(1, 2) <<
"\" ya=\"" <<
err(1, 3) <<
"\" yb=\"" <<
err(1, 4) <<
"\" yc=\"" 351 <<
err(1, 5) <<
"\" zz=\"" <<
err(2, 2) <<
"\" za=\"" <<
err(2, 3) <<
"\" zb=\"" <<
err(2, 4)
352 <<
"\" zc=\"" <<
err(2, 5) <<
"\" aa=\"" <<
err(3, 3) <<
"\" ab=\"" <<
err(3, 4) <<
"\" ac=\"" 353 <<
err(3, 5) <<
"\" bb=\"" <<
err(4, 4) <<
"\" bc=\"" <<
err(4, 5) <<
"\" cc=\"" <<
err(5, 5)
354 <<
"\" />" << std::endl;
357 else if (rawId != 0) {
358 CLHEP::HepSymMatrix
err = errors[(*alignable)->id()];
360 outputFile <<
" <setape xx=\"" <<
err(1, 1) <<
"\" xy=\"" <<
err(1, 2) <<
"\" xz=\"" <<
err(1, 3) <<
"\" xa=\"" 361 <<
err(1, 4) <<
"\" xb=\"" <<
err(1, 5) <<
"\" xc=\"" <<
err(1, 6) <<
"\" yy=\"" <<
err(2, 2)
362 <<
"\" yz=\"" <<
err(2, 3) <<
"\" ya=\"" <<
err(2, 4) <<
"\" yb=\"" <<
err(2, 5) <<
"\" yc=\"" 363 <<
err(2, 6) <<
"\" zz=\"" <<
err(3, 3) <<
"\" za=\"" <<
err(3, 4) <<
"\" zb=\"" <<
err(3, 5)
364 <<
"\" zc=\"" <<
err(3, 6) <<
"\" aa=\"" <<
err(4, 4) <<
"\" ab=\"" <<
err(4, 5) <<
"\" ac=\"" 365 <<
err(4, 6) <<
"\" bb=\"" <<
err(5, 5) <<
"\" bc=\"" <<
err(5, 6) <<
"\" cc=\"" <<
err(6, 6)
366 <<
"\" />" << std::endl;
369 outputFile <<
"</operation>" << std::endl << std::endl;
374 if (ideal != ideals.end()) {
377 writeComponents(components, ideal_components, errors, outputFile, DT, objectIdProvider);
382 writeComponents(components, dummy, errors, outputFile, DT, objectIdProvider);
bool m_suppressCSCEndcaps
T getParameter(std::string const &) const
bool m_suppressDTStations
void write(AlignableMuon *alignableMuon, const edm::EventSetup &iSetup) const
bool m_suppressCSCChambers
align::Alignables DTBarrel()
const AlignableObjectId & objectIdProvider() const
Return muon alignable object ID provider derived from the muon system geometry.
Point3DBase< Scalar, GlobalTag > PositionType
align::Alignables CSCEndcaps()
bool m_suppressCSCStations
void build(CSCGeometry &geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
void build(DTGeometry &theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
bool m_suppressDTChambers
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).
AlignmentErrorsExtended * cscAlignmentErrorsExtended()
Get CSC alignment errors sorted by DetId.
MuonAlignmentOutputXML(const edm::ParameterSet &iConfig)
AlgebraicVector EulerAngles
const char * idToString(align::StructureType type) const
std::vector< AlignTransformErrorExtended > m_alignError
void writeComponents(align::Alignables &alignables, align::Alignables &ideals, std::map< align::ID, CLHEP::HepSymMatrix > &errors, std::ofstream &outputFile, bool DT, const AlignableObjectId &) const
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
Get DT alignment errors sorted by DetId.
std::vector< Alignable * > Alignables
TkRotation transposed() const
math::Error< 6 >::type ErrorMatrix
virtual ~MuonAlignmentOutputXML()
Constructor of the full muon geometry.
const BasicVectorType & basicVector() const