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))
70 else if (str_relativeto ==
std::string(
"container")) {
74 throw cms::Exception(
"BadConfig") <<
"relativeto must be \"none\", \"ideal\", or \"container\"" << std::endl;
107 outputFile <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
108 outputFile <<
"<?xml-stylesheet type=\"text/xml\" href=\"MuonAlignment.xsl\"?>" << std::endl;
109 outputFile <<
"<MuonAlignment>" << std::endl << std::endl;
111 std::map<align::ID, CLHEP::HepSymMatrix>
errors;
114 for (std::vector<AlignTransformErrorExtended>::const_iterator dtError = dtErrors->
m_alignError.begin(); dtError != dtErrors->
m_alignError.end(); ++dtError) {
115 errors[dtError->rawId()] = dtError->matrix();
117 for (std::vector<AlignTransformErrorExtended>::const_iterator cscError = cscErrors->
m_alignError.begin(); cscError != cscErrors->
m_alignError.end(); ++cscError) {
118 errors[cscError->rawId()] = cscError->matrix();
133 auto dtGeometry = std::make_shared<DTGeometry>();
134 DTGeometryBuilder.
build(dtGeometry, &(*cpv), *mdc);
136 auto boost_cscGeometry = std::make_shared<CSCGeometry>();
137 CSCGeometryBuilder.
build(boost_cscGeometry, &(*cpv), *mdc);
139 AlignableMuon ideal_alignableMuon(&(*dtGeometry), &(*boost_cscGeometry));
154 outputFile <<
"</MuonAlignment>" << std::endl;
159 std::map<align::ID, CLHEP::HepSymMatrix>&
errors,
163 align::Alignables::const_iterator ideal = ideals.begin();
164 for (align::Alignables::const_iterator alignable = alignables.begin(); alignable != alignables.end(); ++alignable) {
166 throw cms::Exception(
"Alignment") <<
"SurveyDets must all be defined when writing to XML" << std::endl;
183 unsigned int rawId = (*alignable)->geomDetId().rawId();
184 outputFile <<
"<operation>" << std::endl;
191 outputFile <<
" <" << typeName <<
" rawId=\"" << rawId <<
"\" />" << std::endl;
196 outputFile <<
" <DTLayer wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\"" <<
id.sector() <<
"\" superlayer=\"" <<
id.superlayer() <<
"\" layer=\"" <<
id.layer() <<
"\" />" << std::endl;
200 outputFile <<
" <DTSuperLayer wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\"" <<
id.sector() <<
"\" superlayer=\"" <<
id.superlayer() <<
"\" />" << std::endl;
204 outputFile <<
" <DTChamber wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\"" <<
id.sector() <<
"\" />" << std::endl;
210 outputFile <<
" <DTStation wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" />" << std::endl;
213 outputFile <<
" <DTWheel wheel=\"" <<
id.wheel() <<
"\" />" << std::endl;
216 outputFile <<
" <DTBarrel />" << std::endl;
218 else throw cms::Exception(
"Alignment") <<
"Unknown DT Alignable StructureType" << std::endl;
228 outputFile <<
" <" << typeName <<
" rawId=\"" << rawId <<
"\" />" << std::endl;
233 outputFile <<
" <CSCLayer endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\"" <<
id.ring() <<
"\" chamber=\"" <<
id.chamber() <<
"\" layer=\"" <<
id.layer() <<
"\" />" << std::endl;
237 outputFile <<
" <CSCChamber endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\"" <<
id.ring() <<
"\" chamber=\"" <<
id.chamber() <<
"\" />" << std::endl;
242 outputFile <<
" <CSCRing endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\"" <<
id.ring() <<
"\" />" << std::endl;
245 outputFile <<
" <CSCStation endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" />" << std::endl;
248 outputFile <<
" <CSCEndcap endcap=\"" <<
id.endcap() <<
"\" />" << std::endl;
250 else throw cms::Exception(
"Alignment") <<
"Unknown CSC Alignable StructureType" << std::endl;
261 pos = (*alignable)->survey()->position();
262 rot = (*alignable)->survey()->rotation();
271 if (ideal == ideals.end() || (*ideal)->alignableObjectId() != alignableObjectId || (*ideal)->id() != (*alignable)->id()) {
272 throw cms::Exception(
"Alignment") <<
"AlignableMuon and ideal_AlignableMuon are out of sync!" << std::endl;
284 if (csc_debug && !DT) {
287 std::cout<<
" investigating "<<
id<<std::endl<<(*alignable)->globalRotation()<<std::endl<<std::endl
288 <<idealRotation.
transposed()<<std::endl<<std::endl<<rot<<std::endl<<std::endl;
289 double phix = atan2(rot.
yz(), rot.
zz());
290 double phiy = asin(-rot.
xz());
291 double phiz = atan2(rot.
xy(), rot.
xx());
293 std::cout <<
"phix=\"" << phix <<
"\" phiy=\"" << phiy <<
"\" phiz=\"" << phiz << std::endl;
296 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" << eulerAngles(3) << std::endl;
298 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" << eulerAngles(3) << std::endl;
300 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" << eulerAngles(3) << std::endl;
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) <<
"\" />" << std::endl;
328 double phix = atan2(rot.
yz(), rot.
zz());
329 double phiy = asin(-rot.
xz());
330 double phiz = atan2(rot.
xy(), rot.
xx());
332 outputFile <<
"phix=\"" << phix <<
"\" phiy=\"" << phiy <<
"\" phiz=\"" << phiz <<
"\" />" << std::endl;
338 outputFile <<
" <setsurveyerr" 339 <<
" xx=\"" << err(0,0) <<
"\" xy=\"" << err(0,1) <<
"\" xz=\"" << err(0,2) <<
"\" xa=\"" << err(0,3) <<
"\" xb=\"" << err(0,4) <<
"\" xc=\"" << err(0,5)
340 <<
"\" yy=\"" << err(1,1) <<
"\" yz=\"" << err(1,2) <<
"\" ya=\"" << err(1,3) <<
"\" yb=\"" << err(1,4) <<
"\" yc=\"" << err(1,5)
341 <<
"\" zz=\"" << err(2,2) <<
"\" za=\"" << err(2,3) <<
"\" zb=\"" << err(2,4) <<
"\" zc=\"" << err(2,5)
342 <<
"\" aa=\"" << err(3,3) <<
"\" ab=\"" << err(3,4) <<
"\" ac=\"" << err(3,5)
343 <<
"\" bb=\"" << err(4,4) <<
"\" bc=\"" << err(4,5)
344 <<
"\" cc=\"" << err(5,5) <<
"\" />" << std::endl;
347 else if (rawId != 0) {
349 CLHEP::HepSymMatrix err = errors[(*alignable)->id()];
351 outputFile <<
" <setape xx=\"" << err(0,0) <<
"\" xy=\"" << err(0,1) <<
"\" xz=\"" << err(0,2) <<
"\" xa=\"" << err(0,3) <<
"\" xb=\"" << err(0,4) <<
"\" xc=\"" << err(0,5)
352 <<
"\" yy=\"" << err(1,1) <<
"\" yz=\"" << err(1,2) <<
"\" ya=\"" << err(1,3) <<
"\" yb=\"" << err(1,4) <<
"\" yc=\"" << err(1,5)
353 <<
"\" zz=\"" << err(2,2) <<
"\" za=\"" << err(2,3) <<
"\" zb=\"" << err(2,4) <<
"\" zc=\"" << err(2,5)
354 <<
"\" aa=\"" << err(3,3) <<
"\" ab=\"" << err(3,4) <<
"\" ac=\"" << err(3,5)
355 <<
"\" bb=\"" << err(4,4) <<
"\" bc=\"" << err(4,5)
356 <<
"\" cc=\"" << err(5,5) <<
"\" />" << std::endl;
359 outputFile <<
"</operation>" << std::endl << std::endl;
364 if (ideal != ideals.end()) {
367 writeComponents(components, ideal_components, errors, outputFile, DT, objectIdProvider);
373 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
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
void build(std::shared_ptr< CSCGeometry > geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
Get DT alignment errors sorted by DetId.
std::vector< Alignable * > Alignables
void build(std::shared_ptr< DTGeometry > theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
TkRotation transposed() const
math::Error< 6 >::type ErrorMatrix
virtual ~MuonAlignmentOutputXML()
Constructor of the full muon geometry.
const BasicVectorType & basicVector() const