CMS 3D CMS Logo

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

#include <AlignableDet.h>

Inheritance diagram for AlignableDet:
AlignableComposite Alignable AlignableCSCChamber AlignableDTChamber AlignableDTSuperLayer AlignableGEMChamber AlignableGEMSuperChamber AlignableSiStripDet AlignableStackDet

Public Member Functions

void addAlignmentPositionError (const AlignmentPositionError &ape, bool propagateDown) override
 
void addAlignmentPositionErrorFromRotation (const RotationType &rot, bool propagateDown) override
 
 AlignableDet (const GeomDet *geomDet, bool addComponents=true)
 
AlignmentErrorsExtendedalignmentErrors () const override
 Return vector of alignment errors. More...
 
const AlignmentPositionErroralignmentPositionError () const
 alignment position error - for checking only, otherwise use alignmentErrors() above! More...
 
Alignmentsalignments () const override
 Return vector of alignment data. More...
 
void setAlignmentPositionError (const AlignmentPositionError &ape, bool propagateDown) override
 Set the AlignmentPositionError and, if (propagateDown), to all components. More...
 
void update (const GeomDet *geomDet, bool updateComponents=true)
 
 ~AlignableDet () override
 Destructor. More...
 
- Public Member Functions inherited from AlignableComposite
void addAlignmentPositionErrorFromLocalRotation (const RotationType &rotation, bool propagateDown) override
 
void addComponent (Alignable *component) final
 
void addSurfaceDeformation (const SurfaceDeformation *deformation, bool propagateDown) override
 
 AlignableComposite (align::ID id, StructureType aType, const RotationType &rot=RotationType())
 
StructureType alignableObjectId () const override
 Return the alignable type identifier. More...
 
const Alignablescomponents () const override
 Return vector of direct components. More...
 
void dump () const override
 Recursive printout of alignable structure. More...
 
void move (const GlobalVector &displacement) override
 Move with respect to the global reference frame. More...
 
virtual void moveComponentLocal (const int i, const LocalVector &localDisplacement)
 Move a single component with respect to the local reference frame. More...
 
virtual void moveComponentsLocal (const LocalVector &localDisplacement)
 Move with respect to the local reference frame. More...
 
void recursiveComponents (Alignables &result) const override
 Provide all components, subcomponents etc. (cf. description in base class) More...
 
void rotateInGlobalFrame (const RotationType &rotation) override
 Rotation interpreted in global reference frame. More...
 
void setSurfaceDeformation (const SurfaceDeformation *deformation, bool propagateDown) override
 Set the surface deformation parameters - if (!propagateDown) do not affect daughters. More...
 
int surfaceDeformationIdPairs (std::vector< std::pair< int, SurfaceDeformation *> > &) const override
 Return surface deformations. More...
 
void update (align::ID, StructureType aType, const RotationType &rot=RotationType())
 
template<class T >
void update (T)=delete
 
 ~AlignableComposite () override
 deleting its components More...
 
- Public Member Functions inherited from Alignable
 Alignable (align::ID, const AlignableSurface &)
 
 Alignable (align::ID, const RotationType &)
 
AlignmentParametersalignmentParameters () const
 Get the AlignmentParameters. More...
 
virtual void cacheTransformation ()
 cache the current position, rotation and other parameters (e.g. surface deformations), also for possible components More...
 
virtual void cacheTransformation (const align::RunNumber &)
 
virtual CompConstraintType compConstraintType () const
 Return the alignable type of contraints wrt. its components. More...
 
const AlignablesdeepComponents () const
 
const GlobalVectordisplacement () const
 Return change of the global position since the creation of the object. More...
 
bool firstCompsWithParams (Alignables &paramComps) const
 
const DetIdgeomDetId () const
 
const PositionTypeglobalPosition () const
 Return the global position of the object. More...
 
const RotationTypeglobalRotation () const
 Return the global orientation of the object. More...
 
align::ID id () const
 Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit). More...
 
bool lastCompsWithParams (Alignables &paramComps) const
 
Alignablemother () const
 Return pointer to container alignable (if any) More...
 
virtual void recenterSurface ()
 Recenter surface object without moving possible components. More...
 
virtual void restoreCachedTransformation ()
 restore the previously cached transformation, also for possible components More...
 
virtual void restoreCachedTransformation (const align::RunNumber &)
 
virtual void rotateAroundGlobalAxis (const GlobalVector &axis, Scalar radians)
 Rotation around arbitratry global axis. More...
 
virtual void rotateAroundGlobalX (Scalar radians)
 Rotation around global x-axis. More...
 
virtual void rotateAroundGlobalY (Scalar radians)
 Rotation around global y-axis. More...
 
virtual void rotateAroundGlobalZ (Scalar radians)
 Rotation around global z-axis. More...
 
virtual void rotateAroundLocalAxis (const LocalVector &axis, Scalar radians)
 Rotation around arbitratry local axis. More...
 
virtual void rotateAroundLocalX (Scalar radians)
 Rotation around local x-axis. More...
 
virtual void rotateAroundLocalY (Scalar radians)
 Rotation around local y-axis. More...
 
virtual void rotateAroundLocalZ (Scalar radians)
 Rotation around local z-axis. More...
 
virtual void rotateInLocalFrame (const RotationType &rotation)
 Rotation intepreted in the local reference frame. More...
 
const RotationTyperotation () const
 Return change of orientation since the creation of the object. More...
 
void setAlignmentParameters (AlignmentParameters *dap)
 Set the AlignmentParameters. More...
 
void setMother (Alignable *mother)
 Assign mother to alignable. More...
 
void setSurvey (const SurveyDet *)
 Set survey info. More...
 
int size () const
 Return number of direct components. More...
 
const AlignableSurfacesurface () const
 Return the Surface (global position and orientation) of the object. More...
 
AlignmentSurfaceDeformationssurfaceDeformations () const
 Return surface deformations, sorted by DetId. More...
 
const SurveyDetsurvey () const
 Return survey info. More...
 
void update (align::ID, const AlignableSurface &)
 
virtual ~Alignable ()
 Destructor. More...
 

Private Attributes

AlignmentPositionErrortheAlignmentPositionError
 

Additional Inherited Members

- Public Types inherited from Alignable
typedef align::Alignables Alignables
 
enum  CompConstraintType { CompConstraintType::NONE, CompConstraintType::POSITION, CompConstraintType::POSITION_Z }
 
typedef align::GlobalVector GlobalVector
 
typedef align::LocalVector LocalVector
 
typedef align::PositionType PositionType
 
typedef align::RotationType RotationType
 
typedef align::Scalar Scalar
 
typedef align::StructureType StructureType
 
- Protected Types inherited from Alignable
template<class T >
using Cache = std::map< align::RunNumber, T >
 
- Protected Member Functions inherited from AlignableComposite
 AlignableComposite (const GeomDet *geomDet)
 Constructor from GeomDet, only for use in AlignableDet. More...
 
void setSurface (const AlignableSurface &s)
 
void update (const GeomDet *geomDet)
 
- Protected Member Functions inherited from Alignable
void addDisplacement (const GlobalVector &displacement)
 
void addRotation (const RotationType &rotation)
 
virtual void updateMother (const GlobalVector &shift)
 
- Protected Attributes inherited from AlignableComposite
StructureType theStructureType
 
- Protected Attributes inherited from Alignable
CompConstraintType compConstraintType_ {CompConstraintType::NONE}
 
Cache< GlobalVectordisplacementsCache_
 
Cache< RotationTyperotationsCache_
 
Cache< AlignableSurfacesurfacesCache_
 
GlobalVector theCachedDisplacement
 
RotationType theCachedRotation
 
AlignableSurface theCachedSurface
 
Alignables theDeepComponents
 
DetId theDetId
 
GlobalVector theDisplacement
 
align::ID theId
 
RotationType theRotation
 
AlignableSurface theSurface
 

Detailed Description

An AlignableComposite corresponding to a composite GeomDet direct components are AlignableDetUnits or AlignableDets.

Definition at line 8 of file AlignableDet.h.

Constructor & Destructor Documentation

◆ AlignableDet()

AlignableDet::AlignableDet ( const GeomDet geomDet,
bool  addComponents = true 
)

Constructor: If addComponents = true, creates components for geomDet's components, assuming they are GeomDetUnits

Definition at line 14 of file AlignableDet.cc.

References AlignableComposite::addComponent(), align::AlignableDetUnit, GeomDet::alignmentPositionError(), Alignable::compConstraintType_, GeomDet::components(), Exception, GeomDet::geographicalId(), Alignable::NONE, DetId::rawId(), setAlignmentPositionError(), GeomDet::surface(), Alignable::theSurface, and unit().

15  : AlignableComposite(geomDet), theAlignmentPositionError(nullptr) {
16  // ensure that the surface is not constrained to the average position of the
17  // components:
19 
20  if (geomDet->alignmentPositionError()) {
21  // false: do not propagate APE to (anyway not yet existing) daughters
22  this->setAlignmentPositionError(*(geomDet->alignmentPositionError()), false);
23  }
24 
25  if (addComponents) {
26  if (geomDet->components().empty()) { // Is a DetUnit
27  throw cms::Exception("BadHierarchy") << "[AlignableDet] GeomDet with DetId " << geomDet->geographicalId().rawId()
28  << " has no components, use AlignableDetUnit.\n";
29  } else { // Push back all components
30  const std::vector<const GeomDet*>& geomDets = geomDet->components();
31  for (std::vector<const GeomDet*>::const_iterator idet = geomDets.begin(); idet != geomDets.end(); ++idet) {
32  const GeomDetUnit* unit = dynamic_cast<const GeomDetUnit*>(*idet);
33  if (!unit) {
34  throw cms::Exception("BadHierarchy")
35  << "[AlignableDet] component not GeomDetUnit, call with addComponents==false"
36  << " and build hierarchy yourself.\n"; // e.g. AlignableDTChamber
37  }
38  this->addComponent(new AlignableDetUnit(unit));
39  }
40  }
41  // Ensure that the surface is not screwed up by addComponent, it must stay the GeomDet's one:
42  theSurface = AlignableSurface(geomDet->surface());
43  } // end addComponents
44 }
virtual std::vector< const GeomDet * > components() const
Returns direct components, if any.
Definition: GeomDet.h:73
AlignableComposite()
default constructor hidden
AlignmentPositionError * theAlignmentPositionError
Definition: AlignableDet.h:47
AlignmentPositionError const * alignmentPositionError() const
Return pointer to alignment errors.
Definition: GeomDet.h:80
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
Basic3DVector unit() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
CompConstraintType compConstraintType_
Definition: Alignable.h:246
void setAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown) override
Set the AlignmentPositionError and, if (propagateDown), to all components.
Definition: AlignableDet.cc:98
void addComponent(Alignable *component) final
AlignableSurface theSurface
Definition: Alignable.h:237

◆ ~AlignableDet()

AlignableDet::~AlignableDet ( )
override

Destructor.

Definition at line 47 of file AlignableDet.cc.

References theAlignmentPositionError.

47 { delete theAlignmentPositionError; }
AlignmentPositionError * theAlignmentPositionError
Definition: AlignableDet.h:47

Member Function Documentation

◆ addAlignmentPositionError()

void AlignableDet::addAlignmentPositionError ( const AlignmentPositionError ape,
bool  propagateDown 
)
overridevirtual

Add (or set if it does not exist yet) the AlignmentPositionError, if (propagateDown), add also to all components

Reimplemented from AlignableComposite.

Definition at line 108 of file AlignableDet.cc.

References AlignableComposite::addAlignmentPositionError(), and theAlignmentPositionError.

Referenced by addAlignmentPositionErrorFromRotation().

108  {
111  } else {
113  }
114 
115  this->AlignableComposite::addAlignmentPositionError(ape, propagateDown);
116 }
void addAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown) override
AlignmentPositionError * theAlignmentPositionError
Definition: AlignableDet.h:47

◆ addAlignmentPositionErrorFromRotation()

void AlignableDet::addAlignmentPositionErrorFromRotation ( const RotationType rot,
bool  propagateDown 
)
overridevirtual

Add (or set if it does not exist yet) the AlignmentPositionError resulting from a rotation in the global reference frame, if (propagateDown), add also to all components

Reimplemented from AlignableComposite.

Definition at line 119 of file AlignableDet.cc.

References addAlignmentPositionError(), AlignableComposite::addAlignmentPositionErrorFromRotation(), PV3DBase< T, PVType, FrameType >::basicVector(), makeMuonMisalignmentScenario::rot, Alignable::surface(), AlignableSurface::toGlobal(), and ApeEstimator_cff::width.

119  {
120  // average error calculated by movement of a local point at
121  // (xWidth/2,yLength/2,0) caused by the rotation rot
122  GlobalVector localPositionVector =
123  surface().toGlobal(LocalVector(.5 * surface().width(), .5 * surface().length(), 0.));
124 
125  const LocalVector::BasicVectorType& lpvgf = localPositionVector.basicVector();
126  GlobalVector gv(rot.multiplyInverse(lpvgf) - lpvgf);
127 
128  AlignmentPositionError ape(gv.x(), gv.y(), gv.z());
129  this->addAlignmentPositionError(ape, propagateDown);
130 
132 }
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
void addAlignmentPositionErrorFromRotation(const RotationType &rotation, bool propagateDown) override
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
align::LocalVector LocalVector
Definition: Alignable.h:33
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
void addAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown) override

◆ alignmentErrors()

AlignmentErrorsExtended * AlignableDet::alignmentErrors ( void  ) const
overridevirtual

Return vector of alignment errors.

Reimplemented from AlignableComposite.

Definition at line 159 of file AlignableDet.cc.

References AlignableComposite::alignmentErrors(), asHepMatrix(), filterCSVwithJSON::copy, Alignable::geomDetId(), AlignmentPositionError::globalError(), AlignmentErrorsExtended::m_alignError, GlobalErrorBaseExtended< T, ErrorWeightType >::matrix(), DetId::rawId(), and theAlignmentPositionError.

159  {
160  AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
161 
162  // Add associated alignment position error
163  uint32_t detId = this->geomDetId().rawId();
164  CLHEP::HepSymMatrix clhepSymMatrix(6, 0);
165  if (theAlignmentPositionError) // Might not be set
167  AlignTransformErrorExtended transformError(clhepSymMatrix, detId);
168  m_alignmentErrors->m_alignError.push_back(transformError);
169 
170  // Add those from components
172  std::copy(compAlignmentErrs->m_alignError.begin(),
173  compAlignmentErrs->m_alignError.end(),
174  std::back_inserter(m_alignmentErrors->m_alignError));
175  delete compAlignmentErrs;
176 
177  return m_alignmentErrors;
178 }
const AlgebraicSymMatrix66 & matrix() const
CLHEP::HepMatrix asHepMatrix(const ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > &rm)
Definition: Migration.h:60
AlignmentPositionError * theAlignmentPositionError
Definition: AlignableDet.h:47
AlignmentErrorsExtended * alignmentErrors() const override
Return vector of alignment errors.
std::vector< AlignTransformErrorExtended > m_alignError
const DetId & geomDetId() const
Definition: Alignable.h:177
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const GlobalErrorExtended & globalError() const

◆ alignmentPositionError()

const AlignmentPositionError* AlignableDet::alignmentPositionError ( ) const
inline

alignment position error - for checking only, otherwise use alignmentErrors() above!

Definition at line 44 of file AlignableDet.h.

References theAlignmentPositionError.

Referenced by AlignableDetOrUnitPtr::alignmentPositionError().

44 { return theAlignmentPositionError; }
AlignmentPositionError * theAlignmentPositionError
Definition: AlignableDet.h:47

◆ alignments()

Alignments * AlignableDet::alignments ( void  ) const
overridevirtual

Return vector of alignment data.

Reimplemented from AlignableComposite.

Reimplemented in AlignableSiStripDet, and AlignableStackDet.

Definition at line 135 of file AlignableDet.cc.

References AlignableComposite::alignments(), filterCSVwithJSON::copy, Alignable::geomDetId(), Alignable::globalPosition(), Alignable::globalRotation(), Alignments::m_align, DetId::rawId(), makeMuonMisalignmentScenario::rot, HcalDetIdTransform::transform(), x, y, and z.

Referenced by AlignableStackDet::alignments(), and AlignableSiStripDet::alignments().

135  {
136  Alignments* m_alignments = new Alignments();
138 
139  // Get position, rotation, detId
140  CLHEP::Hep3Vector clhepVector(globalPosition().x(), globalPosition().y(), globalPosition().z());
141  CLHEP::HepRotation clhepRotation(
142  CLHEP::HepRep3x3(rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz()));
143  uint32_t detId = this->geomDetId().rawId();
144 
145  AlignTransform transform(clhepVector, clhepRotation, detId);
146 
147  // Add to alignments container
148  m_alignments->m_align.push_back(transform);
149 
150  // Add those from components
151  Alignments* compAlignments = this->AlignableComposite::alignments();
152  std::copy(compAlignments->m_align.begin(), compAlignments->m_align.end(), std::back_inserter(m_alignments->m_align));
153  delete compAlignments;
154 
155  return m_alignments;
156 }
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:135
Alignments * alignments() const override
Return alignment data.
const DetId & geomDetId() const
Definition: Alignable.h:177
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
align::RotationType RotationType
Definition: Alignable.h:31
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:138
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ setAlignmentPositionError()

void AlignableDet::setAlignmentPositionError ( const AlignmentPositionError ape,
bool  propagateDown 
)
overridevirtual

Set the AlignmentPositionError and, if (propagateDown), to all components.

Reimplemented from AlignableComposite.

Definition at line 98 of file AlignableDet.cc.

References AlignableComposite::setAlignmentPositionError(), and theAlignmentPositionError.

Referenced by AlignableDet(), and update().

98  {
101  else
103 
104  this->AlignableComposite::setAlignmentPositionError(ape, propagateDown);
105 }
AlignmentPositionError * theAlignmentPositionError
Definition: AlignableDet.h:47
void setAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown) override

◆ update()

void AlignableDet::update ( const GeomDet geomDet,
bool  updateComponents = true 
)

Updater from GeomDet The given GeomDet id has to match the current id.

Definition at line 50 of file AlignableDet.cc.

References GeomDet::alignmentPositionError(), HltBtagPostValidation_cff::c, AlCaHLTBitMon_QueryRunRegistry::comp, AlignableComposite::components(), GeomDet::components(), Exception, GeomDet::geographicalId(), DetId::rawId(), setAlignmentPositionError(), GeomDet::surface(), Alignable::theSurface, unit(), AlignableDetUnit::update(), and AlignableComposite::update().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), AlignableTrackerBuilder::buildOuterTrackerDetectorAlignable(), AlignableTrackerBuilder::buildStripDetectorAlignable(), dqm-mbProfile.Profile::finish(), progressbar.ProgressBar::finish(), MatrixUtil.Steps::overwrite(), AlignableGEMSuperChamber::update(), AlignableGEMChamber::update(), and AlignableCSCChamber::update().

50  {
52 
53  if (geomDet->alignmentPositionError()) {
54  // false: do not propagate APE to daughters (done by their update functions)
55  this->setAlignmentPositionError(*(geomDet->alignmentPositionError()), false);
56  }
57 
58  if (updateComponents) {
59  if (geomDet->components().empty()) { // Is a DetUnit
60  throw cms::Exception("BadHierarchy") << "[AlignableDet] GeomDet with DetId " << geomDet->geographicalId().rawId()
61  << " has no components, use AlignableDetUnit.\n";
62  } else { // Push back all components
63  const auto& geomDets = geomDet->components();
64  for (const auto& idet : geomDets) {
65  auto unit = dynamic_cast<const GeomDetUnit*>(idet);
66  if (!unit) {
67  throw cms::Exception("BadHierarchy") << "[AlignableDet] component not GeomDetUnit, call with "
68  << "updateComponents==false and build hierarchy yourself.\n";
69  // -> e.g. AlignableDTChamber
70  }
71 
72  const auto components = this->components();
73  auto comp = std::find_if(components.begin(), components.end(), [&unit](const auto& c) {
74  return c->id() == unit->geographicalId().rawId();
75  });
76 
77  if (comp != components.end()) {
78  auto aliDetUnit = dynamic_cast<AlignableDetUnit*>(*comp);
79  if (aliDetUnit) {
80  aliDetUnit->update(unit);
81  } else {
82  throw cms::Exception("LogicError") << "[AlignableDet::update] cast to 'AlignableDetUnit*' failed "
83  << "while it should not\n";
84  }
85  } else {
86  throw cms::Exception("GeometryMismatch")
87  << "[AlignableDet::update] GeomDet with DetId " << unit->geographicalId().rawId()
88  << " not found in current geometry.\n";
89  }
90  }
91  }
92  // Ensure that the surface is not screwed up by update of components, it must stay the GeomDet's one:
93  theSurface = AlignableSurface(geomDet->surface());
94  } // end updateComponents
95 }
virtual std::vector< const GeomDet * > components() const
Returns direct components, if any.
Definition: GeomDet.h:73
const Alignables & components() const override
Return vector of direct components.
void update(const GeomDetUnit *geomDetUnit)
AlignmentPositionError const * alignmentPositionError() const
Return pointer to alignment errors.
Definition: GeomDet.h:80
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
Basic3DVector unit() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void update(align::ID, StructureType aType, const RotationType &rot=RotationType())
void setAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown) override
Set the AlignmentPositionError and, if (propagateDown), to all components.
Definition: AlignableDet.cc:98
AlignableSurface theSurface
Definition: Alignable.h:237

Member Data Documentation

◆ theAlignmentPositionError

AlignmentPositionError* AlignableDet::theAlignmentPositionError
private