CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
MuonAlignmentOutputXML Class Reference

#include <Alignment/MuonAlignment/interface/MuonAlignmentOutputXML.h>

Public Member Functions

 MuonAlignmentOutputXML (const edm::ParameterSet &iConfig, const DTGeometry *dtGeometry, const CSCGeometry *cscGeometry, const GEMGeometry *gemGeometry)
 
 MuonAlignmentOutputXML (const MuonAlignmentOutputXML &)=delete
 
const MuonAlignmentOutputXMLoperator= (const MuonAlignmentOutputXML &)=delete
 
void write (AlignableMuon *alignableMuon) const
 
virtual ~MuonAlignmentOutputXML ()
 

Private Types

enum  { doDT, doCSC, doGEM }
 

Private Member Functions

void writeComponents (align::Alignables &alignables, align::Alignables &ideals, std::map< align::ID, CLHEP::HepSymMatrix > &errors, std::ofstream &outputFile, const int doDet, const AlignableObjectId &) const
 

Private Attributes

const CSCGeometrycscGeometry_
 
const DTGeometrydtGeometry_
 
const GEMGeometrygemGeometry_
 
bool m_eulerAngles
 
std::string m_fileName
 
int m_precision
 
bool m_rawIds
 
int m_relativeto
 
bool m_suppressCSCChambers
 
bool m_suppressCSCEndcaps
 
bool m_suppressCSCLayers
 
bool m_suppressCSCRings
 
bool m_suppressCSCStations
 
bool m_suppressDTBarrel
 
bool m_suppressDTChambers
 
bool m_suppressDTLayers
 
bool m_suppressDTStations
 
bool m_suppressDTSuperLayers
 
bool m_suppressDTWheels
 
bool m_suppressGEMChambers
 
bool m_suppressGEMEndcaps
 
bool m_suppressGEMEtaPartitions
 
bool m_suppressGEMRings
 
bool m_suppressGEMStations
 
bool m_suppressGEMSuperChambers
 
bool m_survey
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 37 of file MuonAlignmentOutputXML.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Constructor & Destructor Documentation

◆ MuonAlignmentOutputXML() [1/2]

MuonAlignmentOutputXML::MuonAlignmentOutputXML ( const edm::ParameterSet iConfig,
const DTGeometry dtGeometry,
const CSCGeometry cscGeometry,
const GEMGeometry gemGeometry 
)

Definition at line 42 of file MuonAlignmentOutputXML.cc.

References Exception, edm::ParameterSet::getParameter(), m_relativeto, and AlCaHLTBitMon_QueryRunRegistry::string.

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),
71  std::string str_relativeto = iConfig.getParameter<std::string>("relativeto");
72 
73  if (str_relativeto == std::string("none")) {
74  m_relativeto = 0;
75  } else if (str_relativeto == std::string("ideal")) {
76  m_relativeto = 1;
77  } else if (str_relativeto == std::string("container")) {
78  m_relativeto = 2;
79  } else {
80  throw cms::Exception("BadConfig") << "relativeto must be \"none\", \"ideal\", or \"container\"" << std::endl;
81  }
82 }
const GEMGeometry * gemGeometry_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const CSCGeometry * cscGeometry_
T getUntrackedParameter(std::string const &, T const &) const
const DTGeometry * dtGeometry_

◆ ~MuonAlignmentOutputXML()

MuonAlignmentOutputXML::~MuonAlignmentOutputXML ( )
virtual

Definition at line 89 of file MuonAlignmentOutputXML.cc.

89 {}

◆ MuonAlignmentOutputXML() [2/2]

MuonAlignmentOutputXML::MuonAlignmentOutputXML ( const MuonAlignmentOutputXML )
delete

Member Function Documentation

◆ operator=()

const MuonAlignmentOutputXML& MuonAlignmentOutputXML::operator= ( const MuonAlignmentOutputXML )
delete

◆ write()

void MuonAlignmentOutputXML::write ( AlignableMuon alignableMuon) const

Definition at line 107 of file MuonAlignmentOutputXML.cc.

References AlignableMuon::cscAlignmentErrorsExtended(), AlignableMuon::CSCEndcaps(), cscGeometry_, doCSC, doDT, doGEM, AlignableMuon::dtAlignmentErrorsExtended(), AlignableMuon::DTBarrel(), dtGeometry_, nano_mu_digi_cff::errors, alignBH_cfg::fixed, AlignableMuon::gemAlignmentErrorsExtended(), AlignableMuon::GEMEndcaps(), gemGeometry_, AlignmentErrorsExtended::m_alignError, m_fileName, m_precision, m_relativeto, AlignableMuon::objectIdProvider(), download_sqlite_cfg::outputFile, and writeComponents().

Referenced by pkg.AbstractPkg::generate(), querying.connection::write_and_commit(), and MuonAlignment::writeXML().

107  {
108  std::ofstream outputFile(m_fileName.c_str());
109  outputFile << std::setprecision(m_precision) << std::fixed;
110 
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;
114 
115  std::map<align::ID, CLHEP::HepSymMatrix> errors;
116  AlignmentErrorsExtended *dtErrors = alignableMuon->dtAlignmentErrorsExtended();
117  AlignmentErrorsExtended *cscErrors = alignableMuon->cscAlignmentErrorsExtended();
118  AlignmentErrorsExtended *gemErrors = alignableMuon->gemAlignmentErrorsExtended();
119  for (std::vector<AlignTransformErrorExtended>::const_iterator dtError = dtErrors->m_alignError.begin();
120  dtError != dtErrors->m_alignError.end();
121  ++dtError) {
122  errors[dtError->rawId()] = dtError->matrix();
123  }
124  for (std::vector<AlignTransformErrorExtended>::const_iterator cscError = cscErrors->m_alignError.begin();
125  cscError != cscErrors->m_alignError.end();
126  ++cscError) {
127  errors[cscError->rawId()] = cscError->matrix();
128  }
129  for (std::vector<AlignTransformErrorExtended>::const_iterator gemError = gemErrors->m_alignError.begin();
130  gemError != gemErrors->m_alignError.end();
131  ++gemError) {
132  errors[gemError->rawId()] = gemError->matrix();
133  }
134 
135  align::Alignables barrels = alignableMuon->DTBarrel();
136  align::Alignables endcaps = alignableMuon->CSCEndcaps();
137  align::Alignables endcaps_GEM = alignableMuon->GEMEndcaps();
138 
139  if (m_relativeto == 1) {
140  AlignableMuon ideal_alignableMuon(dtGeometry_, cscGeometry_, gemGeometry_);
141 
142  align::Alignables ideal_barrels = ideal_alignableMuon.DTBarrel();
143  align::Alignables ideal_endcaps = ideal_alignableMuon.CSCEndcaps();
144  align::Alignables ideal_endcaps_GEM = ideal_alignableMuon.GEMEndcaps();
145 
146  writeComponents(barrels, ideal_barrels, errors, outputFile, doDT, alignableMuon->objectIdProvider());
147  writeComponents(endcaps, ideal_endcaps, errors, outputFile, doCSC, alignableMuon->objectIdProvider());
148  writeComponents(endcaps_GEM, ideal_endcaps_GEM, errors, outputFile, doGEM, alignableMuon->objectIdProvider());
149  } else {
150  align::Alignables empty1, empty2, empty3;
151 
152  writeComponents(barrels, empty1, errors, outputFile, doDT, alignableMuon->objectIdProvider());
153  writeComponents(endcaps, empty2, errors, outputFile, doCSC, alignableMuon->objectIdProvider());
154  writeComponents(endcaps_GEM, empty3, errors, outputFile, doGEM, alignableMuon->objectIdProvider());
155  }
156 
157  outputFile << "</MuonAlignment>" << std::endl;
158 }
const GEMGeometry * gemGeometry_
const CSCGeometry * cscGeometry_
const AlignableObjectId & objectIdProvider() const
Return muon alignable object ID provider derived from the muon system geometry.
Definition: AlignableMuon.h:92
align::Alignables DTBarrel()
const DTGeometry * dtGeometry_
align::Alignables CSCEndcaps()
AlignmentErrorsExtended * cscAlignmentErrorsExtended()
Get CSC alignment errors sorted by DetId.
std::vector< AlignTransformErrorExtended > m_alignError
AlignmentErrorsExtended * dtAlignmentErrorsExtended()
Get DT alignment errors sorted by DetId.
AlignmentErrorsExtended * gemAlignmentErrorsExtended()
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
align::Alignables GEMEndcaps()
Definition: errors.py:1
void writeComponents(align::Alignables &alignables, align::Alignables &ideals, std::map< align::ID, CLHEP::HepSymMatrix > &errors, std::ofstream &outputFile, const int doDet, const AlignableObjectId &) const
Constructor of the full muon geometry.
Definition: AlignableMuon.h:38

◆ writeComponents()

void MuonAlignmentOutputXML::writeComponents ( align::Alignables alignables,
align::Alignables ideals,
std::map< align::ID, CLHEP::HepSymMatrix > &  errors,
std::ofstream &  outputFile,
const int  doDet,
const AlignableObjectId objectIdProvider 
) const
private

Definition at line 160 of file MuonAlignmentOutputXML.cc.

References align::AlignableCSCChamber, align::AlignableCSCEndcap, align::AlignableCSCRing, align::AlignableCSCStation, align::AlignableDetUnit, align::AlignableDTBarrel, align::AlignableDTChamber, align::AlignableDTStation, align::AlignableDTSuperLayer, align::AlignableDTWheel, align::AlignableGEMChamber, align::AlignableGEMEndcap, align::AlignableGEMEtaPartition, align::AlignableGEMRing, align::AlignableGEMStation, align::AlignableGEMSuperChamber, cms::cuda::assert(), PV3DBase< T, PVType, FrameType >::basicVector(), relativeConstraints::chamber, makeMuonMisalignmentScenario::components, gather_cfg::cout, doCSC, doDT, doGEM, makeMuonMisalignmentScenario::endcap, submitPVResolutionJobs::err, Exception, l1ctLayer2EG_cff::id, AlignableObjectId::idToString(), m_eulerAngles, m_rawIds, m_relativeto, m_suppressCSCChambers, m_suppressCSCEndcaps, m_suppressCSCLayers, m_suppressCSCRings, m_suppressCSCStations, m_suppressDTBarrel, m_suppressDTChambers, m_suppressDTLayers, m_suppressDTStations, m_suppressDTSuperLayers, m_suppressDTWheels, m_suppressGEMChambers, m_suppressGEMEndcaps, m_suppressGEMEtaPartitions, m_suppressGEMRings, m_suppressGEMStations, m_suppressGEMSuperChambers, m_survey, download_sqlite_cfg::outputFile, nano_mu_digi_cff::rawId, relativeConstraints::ring, makeMuonMisalignmentScenario::rot, relativeConstraints::station, AlCaHLTBitMon_QueryRunRegistry::string, align::toAngles(), TkRotation< T >::transposed(), and dqmiodumpindices::typeName.

Referenced by write().

165  {
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;
170  }
171 
172  align::StructureType alignableObjectId = (*alignable)->alignableObjectId();
173 
174  if ((alignableObjectId == align::AlignableDTBarrel && !m_suppressDTBarrel) ||
175  (alignableObjectId == align::AlignableDTWheel && !m_suppressDTWheels) ||
176  (alignableObjectId == align::AlignableDTStation && !m_suppressDTStations) ||
177  (alignableObjectId == align::AlignableDTChamber && !m_suppressDTChambers) ||
178  (doDet == doDT && alignableObjectId == align::AlignableDTSuperLayer && !m_suppressDTSuperLayers) ||
179  (doDet == doDT && alignableObjectId == align::AlignableDetUnit && !m_suppressDTLayers) ||
180  (alignableObjectId == align::AlignableCSCEndcap && !m_suppressCSCEndcaps) ||
181  (alignableObjectId == align::AlignableCSCStation && !m_suppressCSCStations) ||
182  (alignableObjectId == align::AlignableCSCRing && !m_suppressCSCRings) ||
183  (alignableObjectId == align::AlignableCSCChamber && !m_suppressCSCChambers) ||
184  (alignableObjectId == align::AlignableGEMEndcap && !m_suppressGEMEndcaps) ||
185  (alignableObjectId == align::AlignableGEMStation && !m_suppressGEMStations) ||
186  (alignableObjectId == align::AlignableGEMRing && !m_suppressGEMRings) ||
187  (alignableObjectId == align::AlignableGEMSuperChamber && !m_suppressGEMSuperChambers) ||
188  (alignableObjectId == align::AlignableGEMChamber && !m_suppressGEMChambers) ||
189  (alignableObjectId == align::AlignableGEMEtaPartition && !m_suppressGEMEtaPartitions) ||
190  (doDet != doDT && doDet != doGEM && doDet == doCSC && alignableObjectId == align::AlignableDetUnit &&
192  (doDet != doDT && doDet != doCSC && doDet == doGEM && alignableObjectId == align::AlignableDetUnit &&
194  unsigned int rawId = (*alignable)->geomDetId().rawId();
195  outputFile << "<operation>" << std::endl;
196 
197  if (doDet == doDT) {
198  if (m_rawIds && rawId != 0) {
199  std::string typeName = objectIdProvider.idToString(alignableObjectId);
200  if (alignableObjectId == align::AlignableDTSuperLayer)
201  typeName = std::string("DTSuperLayer");
202  if (alignableObjectId == align::AlignableDetUnit)
203  typeName = std::string("DTLayer");
204  outputFile << " <" << typeName << " rawId=\"" << rawId << "\" />" << std::endl;
205  } else {
206  if (alignableObjectId == align::AlignableDetUnit) {
207  DTLayerId id(rawId);
208  outputFile << " <DTLayer wheel=\"" << id.wheel() << "\" station=\"" << id.station() << "\" sector=\""
209  << id.sector() << "\" superlayer=\"" << id.superlayer() << "\" layer=\"" << id.layer() << "\" />"
210  << std::endl;
211  } else if (alignableObjectId == align::AlignableDTSuperLayer) {
213  outputFile << " <DTSuperLayer wheel=\"" << id.wheel() << "\" station=\"" << id.station() << "\" sector=\""
214  << id.sector() << "\" superlayer=\"" << id.superlayer() << "\" />" << std::endl;
215  } else if (alignableObjectId == align::AlignableDTChamber) {
217  outputFile << " <DTChamber wheel=\"" << id.wheel() << "\" station=\"" << id.station() << "\" sector=\""
218  << id.sector() << "\" />" << std::endl;
219  } else {
220  DTChamberId id((*alignable)->id());
221  if (alignableObjectId == align::AlignableDTStation) {
222  outputFile << " <DTStation wheel=\"" << id.wheel() << "\" station=\"" << id.station() << "\" />"
223  << std::endl;
224  } else if (alignableObjectId == align::AlignableDTWheel) {
225  outputFile << " <DTWheel wheel=\"" << id.wheel() << "\" />" << std::endl;
226  } else if (alignableObjectId == align::AlignableDTBarrel) {
227  outputFile << " <DTBarrel />" << std::endl;
228  } else
229  throw cms::Exception("Alignment") << "Unknown DT Alignable StructureType" << std::endl;
230  }
231 
232  } // end if not rawId
233  } // end if DT
234 
235  if (doDet == doCSC) { // CSC
236  if (m_rawIds && rawId != 0) {
237  std::string typeName = objectIdProvider.idToString(alignableObjectId);
238  if (alignableObjectId == align::AlignableDetUnit)
239  typeName = std::string("CSCLayer");
240  outputFile << " <" << typeName << " rawId=\"" << rawId << "\" />" << std::endl;
241  } else {
242  if (alignableObjectId == align::AlignableDetUnit) {
243  CSCDetId id(rawId);
244  outputFile << " <CSCLayer endcap=\"" << id.endcap() << "\" station=\"" << id.station() << "\" ring=\""
245  << id.ring() << "\" chamber=\"" << id.chamber() << "\" layer=\"" << id.layer() << "\" />"
246  << std::endl;
247  } else if (alignableObjectId == align::AlignableCSCChamber) {
248  CSCDetId id(rawId);
249  outputFile << " <CSCChamber endcap=\"" << id.endcap() << "\" station=\"" << id.station() << "\" ring=\""
250  << id.ring() << "\" chamber=\"" << id.chamber() << "\" />" << std::endl;
251  } else {
252  CSCDetId id((*alignable)->id());
253  if (alignableObjectId == align::AlignableCSCRing) {
254  outputFile << " <CSCRing endcap=\"" << id.endcap() << "\" station=\"" << id.station() << "\" ring=\""
255  << id.ring() << "\" />" << std::endl;
256  } else if (alignableObjectId == align::AlignableCSCStation) {
257  outputFile << " <CSCStation endcap=\"" << id.endcap() << "\" station=\"" << id.station() << "\" />"
258  << std::endl;
259  } else if (alignableObjectId == align::AlignableCSCEndcap) {
260  outputFile << " <CSCEndcap endcap=\"" << id.endcap() << "\" />" << std::endl;
261  } else
262  throw cms::Exception("Alignment") << "Unknown CSC Alignable StructureType" << std::endl;
263  }
264 
265  } // end if not rawId
266  } // end if CSC
267 
268  if (doDet == doGEM) { // GEM
269  if (m_rawIds && rawId != 0) {
270  std::string typeName = objectIdProvider.idToString(alignableObjectId);
271  if (alignableObjectId == align::AlignableDetUnit)
272  typeName = std::string("GEMChambers");
273  outputFile << " <" << typeName << " rawId=\"" << rawId << "\" />" << std::endl;
274  } else {
275  if (alignableObjectId == align::AlignableDetUnit) {
276  GEMDetId id(rawId);
277  outputFile << " <GEMSuperChambers endcap=\"" << id.region() << "\" station=\"" << id.station()
278  << "\" ring=\"" << id.ring() << "\" superchamber=\"" << id.chamber() << "\" layer=\""
279  << id.layer() << "\" />" << std::endl;
280  } else if (alignableObjectId == align::AlignableGEMSuperChamber) {
281  GEMDetId id(rawId);
282  outputFile << " <GEMSuperChamber endcap=\"" << id.region() << "\" station=\"" << id.station()
283  << "\" ring=\"" << id.ring() << "\" chamber=\"" << id.chamber() << "\" />" << std::endl;
284  } else {
285  GEMDetId id((*alignable)->id());
286  if (alignableObjectId == align::AlignableGEMRing) {
287  outputFile << " <GEMRing endcap=\"" << id.region() << "\" station=\"" << id.station() << "\" ring=\""
288  << id.ring() << "\" />" << std::endl;
289  } else if (alignableObjectId == align::AlignableGEMStation) {
290  outputFile << " <GEMStation endcap=\"" << id.region() << "\" station=\"" << id.station() << "\" />"
291  << std::endl;
292  } else if (alignableObjectId == align::AlignableGEMEndcap) {
293  outputFile << " <GEMEndcap endcap=\"" << id.region() << "\" />" << std::endl;
294  } else
295  throw cms::Exception("Alignment") << "Unknown GEM Alignable StructureType" << std::endl;
296  }
297 
298  } // end if not rawId
299  } // end if GEM
300 
301  align::PositionType pos = (*alignable)->globalPosition();
302  align::RotationType rot = (*alignable)->globalRotation();
303 
304  if (m_survey) {
305  pos = (*alignable)->survey()->position();
306  rot = (*alignable)->survey()->rotation();
307  }
308 
309  std::string str_relativeto;
310  if (m_relativeto == 0) {
311  str_relativeto = std::string("none");
312  }
313 
314  else if (m_relativeto == 1) {
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;
318  }
319 
320  align::PositionType idealPosition = (*ideal)->globalPosition();
321  align::RotationType idealRotation = (*ideal)->globalRotation();
322 
323  pos = align::PositionType(idealRotation * (pos.basicVector() - idealPosition.basicVector()));
324  rot = rot * idealRotation.transposed();
325 
326  str_relativeto = std::string("ideal");
327 
328  bool csc_debug = false;
329  if (csc_debug && doDet == doCSC) {
330  CSCDetId id(rawId);
331  if (id.endcap() == 1 && id.station() == 1 && id.ring() == 1 && id.chamber() == 33) {
332  std::cout << " investigating " << id << std::endl
333  << (*alignable)->globalRotation() << std::endl
334  << std::endl
335  << idealRotation.transposed() << std::endl
336  << std::endl
337  << rot << std::endl
338  << std::endl;
339  double phix = atan2(rot.yz(), rot.zz());
340  double phiy = asin(-rot.xz());
341  double phiz = atan2(rot.xy(), rot.xx());
342 
343  std::cout << "phix=\"" << phix << "\" phiy=\"" << phiy << "\" phiz=\"" << phiz << std::endl;
344 
345  align::EulerAngles eulerAngles = align::toAngles((*alignable)->globalRotation());
346  std::cout << "alpha=\"" << eulerAngles(1) << "\" beta=\"" << eulerAngles(2) << "\" gamma=\""
347  << eulerAngles(3) << std::endl;
348  eulerAngles = align::toAngles(idealRotation);
349  std::cout << "alpha=\"" << eulerAngles(1) << "\" beta=\"" << eulerAngles(2) << "\" gamma=\""
350  << eulerAngles(3) << std::endl;
351  eulerAngles = align::toAngles(rot);
352  std::cout << "alpha=\"" << eulerAngles(1) << "\" beta=\"" << eulerAngles(2) << "\" gamma=\""
353  << eulerAngles(3) << std::endl;
354  }
355  }
356  }
357 
358  else if (m_relativeto == 2 && (*alignable)->mother() != nullptr) {
359  align::PositionType globalPosition = (*alignable)->mother()->globalPosition();
360  align::RotationType globalRotation = (*alignable)->mother()->globalRotation();
361 
362  pos = align::PositionType(globalRotation * (pos.basicVector() - globalPosition.basicVector()));
363  rot = rot * globalRotation.transposed();
364 
365  str_relativeto = std::string("container");
366  }
367 
368  else
369  assert(false); // can't happen: see constructor
370 
371  outputFile << " <setposition relativeto=\"" << str_relativeto << "\" "
372  << "x=\"" << pos.x() << "\" y=\"" << pos.y() << "\" z=\"" << pos.z() << "\" ";
373 
374  if (m_eulerAngles) {
375  align::EulerAngles eulerAngles = align::toAngles(rot);
376  outputFile << "alpha=\"" << eulerAngles(1) << "\" beta=\"" << eulerAngles(2) << "\" gamma=\"" << eulerAngles(3)
377  << "\" />" << std::endl;
378  }
379 
380  else {
381  // the angle convention originally used in alignment, also known as "non-standard Euler angles with a Z-Y-X convention"
382  // // this also gets the sign convention right
383  double phix = atan2(rot.yz(), rot.zz());
384  double phiy = asin(-rot.xz());
385  double phiz = atan2(rot.xy(), rot.xx());
386 
387  outputFile << "phix=\"" << phix << "\" phiy=\"" << phiy << "\" phiz=\"" << phiz << "\" />" << std::endl;
388  }
389 
390  if (m_survey) {
391  align::ErrorMatrix err = (*alignable)->survey()->errors();
392 
393  outputFile << " <setsurveyerr"
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;
401  }
402 
403  else if (rawId != 0) {
404  CLHEP::HepSymMatrix err = errors[(*alignable)->id()];
405 
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;
413  }
414 
415  outputFile << "</operation>" << std::endl << std::endl;
416 
417  } // end if not suppressed
418 
419  // write superstructures before substructures: this is important because <setape> overwrites all substructures' APEs
420  if (ideal != ideals.end()) {
421  align::Alignables components = (*alignable)->components();
422  align::Alignables ideal_components = (*ideal)->components();
423  writeComponents(components, ideal_components, errors, outputFile, doDet, objectIdProvider);
424  ++ideal; // important for synchronization in the "for" loop!
425  } else {
426  align::Alignables components = (*alignable)->components();
428  writeComponents(components, dummy, errors, outputFile, doDet, objectIdProvider);
429  }
430  } // end loop over alignables
431 }
assert(be >=bs)
Point3DBase< Scalar, GlobalTag > PositionType
Definition: Definitions.h:28
TkRotation transposed() const
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:8
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
AlgebraicVector EulerAngles
Definition: Definitions.h:34
const char * idToString(align::StructureType type) const
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
Definition: errors.py:1
math::Error< 6 >::type ErrorMatrix
Definition: Definitions.h:37
void writeComponents(align::Alignables &alignables, align::Alignables &ideals, std::map< align::ID, CLHEP::HepSymMatrix > &errors, std::ofstream &outputFile, const int doDet, const AlignableObjectId &) const

Member Data Documentation

◆ cscGeometry_

const CSCGeometry* MuonAlignmentOutputXML::cscGeometry_
private

Definition at line 78 of file MuonAlignmentOutputXML.h.

Referenced by write().

◆ dtGeometry_

const DTGeometry* MuonAlignmentOutputXML::dtGeometry_
private

Definition at line 77 of file MuonAlignmentOutputXML.h.

Referenced by write().

◆ gemGeometry_

const GEMGeometry* MuonAlignmentOutputXML::gemGeometry_
private

Definition at line 79 of file MuonAlignmentOutputXML.h.

Referenced by write().

◆ m_eulerAngles

bool MuonAlignmentOutputXML::m_eulerAngles
private

Definition at line 69 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_fileName

std::string MuonAlignmentOutputXML::m_fileName
private

Definition at line 67 of file MuonAlignmentOutputXML.h.

Referenced by write().

◆ m_precision

int MuonAlignmentOutputXML::m_precision
private

Definition at line 70 of file MuonAlignmentOutputXML.h.

Referenced by write().

◆ m_rawIds

bool MuonAlignmentOutputXML::m_rawIds
private

Definition at line 69 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_relativeto

int MuonAlignmentOutputXML::m_relativeto
private

Definition at line 68 of file MuonAlignmentOutputXML.h.

Referenced by MuonAlignmentOutputXML(), write(), and writeComponents().

◆ m_suppressCSCChambers

bool MuonAlignmentOutputXML::m_suppressCSCChambers
private

Definition at line 73 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressCSCEndcaps

bool MuonAlignmentOutputXML::m_suppressCSCEndcaps
private

Definition at line 73 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressCSCLayers

bool MuonAlignmentOutputXML::m_suppressCSCLayers
private

Definition at line 73 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressCSCRings

bool MuonAlignmentOutputXML::m_suppressCSCRings
private

Definition at line 73 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressCSCStations

bool MuonAlignmentOutputXML::m_suppressCSCStations
private

Definition at line 73 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressDTBarrel

bool MuonAlignmentOutputXML::m_suppressDTBarrel
private

Definition at line 71 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressDTChambers

bool MuonAlignmentOutputXML::m_suppressDTChambers
private

Definition at line 71 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressDTLayers

bool MuonAlignmentOutputXML::m_suppressDTLayers
private

Definition at line 71 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressDTStations

bool MuonAlignmentOutputXML::m_suppressDTStations
private

Definition at line 71 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressDTSuperLayers

bool MuonAlignmentOutputXML::m_suppressDTSuperLayers
private

Definition at line 71 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressDTWheels

bool MuonAlignmentOutputXML::m_suppressDTWheels
private

Definition at line 71 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressGEMChambers

bool MuonAlignmentOutputXML::m_suppressGEMChambers
private

Definition at line 74 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressGEMEndcaps

bool MuonAlignmentOutputXML::m_suppressGEMEndcaps
private

Definition at line 74 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressGEMEtaPartitions

bool MuonAlignmentOutputXML::m_suppressGEMEtaPartitions
private

Definition at line 74 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressGEMRings

bool MuonAlignmentOutputXML::m_suppressGEMRings
private

Definition at line 74 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressGEMStations

bool MuonAlignmentOutputXML::m_suppressGEMStations
private

Definition at line 74 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_suppressGEMSuperChambers

bool MuonAlignmentOutputXML::m_suppressGEMSuperChambers
private

Definition at line 74 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().

◆ m_survey

bool MuonAlignmentOutputXML::m_survey
private

Definition at line 69 of file MuonAlignmentOutputXML.h.

Referenced by writeComponents().