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<AlignTransformError>::const_iterator dtError = dtErrors->
m_alignError.begin(); dtError != dtErrors->
m_alignError.end(); ++dtError) {
115 errors[dtError->rawId()] = dtError->matrix();
117 for (std::vector<AlignTransformError>::const_iterator cscError = cscErrors->
m_alignError.begin(); cscError != cscErrors->
m_alignError.end(); ++cscError) {
118 errors[cscError->rawId()] = cscError->matrix();
133 boost::shared_ptr<DTGeometry> dtGeometry(
new DTGeometry );
134 DTGeometryBuilder.
build(dtGeometry, &(*cpv), *mdc);
136 boost::shared_ptr<CSCGeometry> boost_cscGeometry(
new CSCGeometry);
137 CSCGeometryBuilder.
build(boost_cscGeometry, &(*cpv), *mdc);
139 AlignableMuon ideal_alignableMuon(&(*dtGeometry), &(*boost_cscGeometry));
154 outputFile <<
"</MuonAlignment>" << std::endl;
158 std::map<align::ID, CLHEP::HepSymMatrix>&
errors, std::ofstream &
outputFile,
bool DT)
const {
159 align::Alignables::const_iterator ideal = ideals.begin();
160 for (align::Alignables::const_iterator alignable = alignables.begin(); alignable != alignables.end(); ++alignable) {
162 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;
187 outputFile <<
" <" << typeName <<
" rawId=\"" << rawId <<
"\" />" << std::endl;
192 outputFile <<
" <DTLayer wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\"" <<
id.sector() <<
"\" superlayer=\"" <<
id.superlayer() <<
"\" layer=\"" <<
id.layer() <<
"\" />" << std::endl;
196 outputFile <<
" <DTSuperLayer wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\"" <<
id.sector() <<
"\" superlayer=\"" <<
id.superlayer() <<
"\" />" << std::endl;
200 outputFile <<
" <DTChamber wheel=\"" <<
id.wheel() <<
"\" station=\"" <<
id.station() <<
"\" sector=\"" <<
id.sector() <<
"\" />" << std::endl;
206 outputFile <<
" <DTStation wheel=\"" <<
id.
wheel() <<
"\" station=\"" <<
id.station() <<
"\" />" << std::endl;
209 outputFile <<
" <DTWheel wheel=\"" <<
id.wheel() <<
"\" />" << std::endl;
212 outputFile <<
" <DTBarrel />" << std::endl;
214 else throw cms::Exception(
"Alignment") <<
"Unknown DT Alignable StructureType" << std::endl;
224 outputFile <<
" <" << typeName <<
" rawId=\"" << rawId <<
"\" />" << std::endl;
229 outputFile <<
" <CSCLayer endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\"" <<
id.ring() <<
"\" chamber=\"" <<
id.chamber() <<
"\" layer=\"" <<
id.layer() <<
"\" />" << std::endl;
233 outputFile <<
" <CSCChamber endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\"" <<
id.ring() <<
"\" chamber=\"" <<
id.chamber() <<
"\" />" << std::endl;
238 outputFile <<
" <CSCRing endcap=\"" <<
id.
endcap() <<
"\" station=\"" <<
id.station() <<
"\" ring=\"" <<
id.ring() <<
"\" />" << std::endl;
241 outputFile <<
" <CSCStation endcap=\"" <<
id.endcap() <<
"\" station=\"" <<
id.station() <<
"\" />" << std::endl;
244 outputFile <<
" <CSCEndcap endcap=\"" <<
id.endcap() <<
"\" />" << std::endl;
246 else throw cms::Exception(
"Alignment") <<
"Unknown CSC Alignable StructureType" << std::endl;
257 pos = (*alignable)->survey()->position();
258 rot = (*alignable)->survey()->rotation();
267 if (ideal == ideals.end() || (*ideal)->alignableObjectId() != alignableObjectId || (*ideal)->id() != (*alignable)->id()) {
268 throw cms::Exception(
"Alignment") <<
"AlignableMuon and ideal_AlignableMuon are out of sync!" << std::endl;
280 if (csc_debug && !DT) {
283 std::cout<<
" investigating "<<
id<<std::endl<<(*alignable)->globalRotation()<<std::endl<<std::endl
284 <<idealRotation.
transposed()<<std::endl<<std::endl<<rot<<std::endl<<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=\"" << eulerAngles(3) << std::endl;
294 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" << eulerAngles(3) << std::endl;
296 std::cout <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" << eulerAngles(3) << std::endl;
313 outputFile <<
" <setposition relativeto=\"" << str_relativeto <<
"\" "
314 <<
"x=\"" << pos.
x() <<
"\" y=\"" << pos.
y() <<
"\" z=\"" << pos.
z() <<
"\" ";
318 outputFile <<
"alpha=\"" << eulerAngles(1) <<
"\" beta=\"" << eulerAngles(2) <<
"\" gamma=\"" << eulerAngles(3) <<
"\" />" << std::endl;
324 double phix = atan2(rot.
yz(), rot.
zz());
325 double phiy = asin(-rot.
xz());
326 double phiz = atan2(rot.
xy(), rot.
xx());
328 outputFile <<
"phix=\"" << phix <<
"\" phiy=\"" << phiy <<
"\" phiz=\"" << phiz <<
"\" />" << std::endl;
334 outputFile <<
" <setsurveyerr"
335 <<
" xx=\"" << err(0,0) <<
"\" xy=\"" << err(0,1) <<
"\" xz=\"" << err(0,2) <<
"\" xa=\"" << err(0,3) <<
"\" xb=\"" << err(0,4) <<
"\" xc=\"" << err(0,5)
336 <<
"\" yy=\"" << err(1,1) <<
"\" yz=\"" << err(1,2) <<
"\" ya=\"" << err(1,3) <<
"\" yb=\"" << err(1,4) <<
"\" yc=\"" << err(1,5)
337 <<
"\" zz=\"" << err(2,2) <<
"\" za=\"" << err(2,3) <<
"\" zb=\"" << err(2,4) <<
"\" zc=\"" << err(2,5)
338 <<
"\" aa=\"" << err(3,3) <<
"\" ab=\"" << err(3,4) <<
"\" ac=\"" << err(3,5)
339 <<
"\" bb=\"" << err(4,4) <<
"\" bc=\"" << err(4,5)
340 <<
"\" cc=\"" << err(5,5) <<
"\" />" << std::endl;
343 else if (rawId != 0) {
344 CLHEP::HepSymMatrix err = errors[(*alignable)->id()];
346 outputFile <<
" <setape xx=\"" << err(1,1) <<
"\" xy=\"" << err(1,2) <<
"\" xz=\"" << err(1,3)
347 <<
"\" yy=\"" << err(2,2) <<
"\" yz=\"" << err(2,3) <<
"\" zz=\"" << err(3,3) <<
"\" />" << std::endl;
350 outputFile <<
"</operation>" << std::endl << std::endl;
355 if (ideal != ideals.end()) {
bool m_suppressCSCEndcaps
T getParameter(std::string const &) const
AlignmentErrors * dtAlignmentErrors()
bool m_suppressDTStations
void write(AlignableMuon *alignableMuon, const edm::EventSetup &iSetup) const
bool m_suppressCSCChambers
align::Alignables DTBarrel()
std::vector< AlignTransformError > m_alignError
void build(boost::shared_ptr< CSCGeometry > geom, const DDCompactView *fv, const MuonDDDConstants &muonConstants)
Build the geometry.
Point3DBase< Scalar, GlobalTag > PositionType
align::Alignables CSCEndcaps()
bool m_suppressCSCStations
bool m_suppressDTChambers
AlignmentErrors * cscAlignmentErrors()
bool m_suppressDTSuperLayers
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
MuonAlignmentOutputXML(const edm::ParameterSet &iConfig)
AlgebraicVector EulerAngles
void build(boost::shared_ptr< DTGeometry > theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
std::vector< Alignable * > Alignables
TkRotation transposed() const
math::Error< 6 >::type ErrorMatrix
volatile std::atomic< bool > shutdown_flag false
static const char * idToString(align::StructureType type)
int wheel() const
Return the wheel number.
virtual ~MuonAlignmentOutputXML()
Constructor of the full muon geometry.
const BasicVectorType & basicVector() const
void writeComponents(align::Alignables &alignables, align::Alignables &ideals, std::map< align::ID, CLHEP::HepSymMatrix > &errors, std::ofstream &outputFile, bool DT) const