CMS 3D CMS Logo

AlignableDetUnit.cc
Go to the documentation of this file.
2 
4 
7 #include "CLHEP/Vector/RotationInterfaces.h"
10 
13 
14 //__________________________________________________________________________________________________
16  : // rely on non-NULL pointer!
17  Alignable(geomDetUnit->geographicalId().rawId(), geomDetUnit->surface()),
18  theAlignmentPositionError(nullptr),
19  theSurfaceDeformation(nullptr),
20  theCachedSurfaceDeformation(nullptr) {
21  if (geomDetUnit->alignmentPositionError()) { // take over APE from geometry
22  // 2nd argument w/o effect:
23  this->setAlignmentPositionError(*(geomDetUnit->alignmentPositionError()), false);
24  }
25 
26  if (geomDetUnit->surfaceDeformation()) { // take over surface modification
27  // 2nd argument w/o effect:
28  this->setSurfaceDeformation(geomDetUnit->surfaceDeformation(), false);
29  }
30 
31  theDeepComponents.push_back(this);
32 }
33 
34 //__________________________________________________________________________________________________
37  delete theSurfaceDeformation;
40  delete surface.second;
41 }
42 
43 //__________________________________________________________________________________________________
44 void AlignableDetUnit::update(const GeomDetUnit* geomDetUnit) {
45  if (!geomDetUnit) {
46  throw cms::Exception("Alignment") << "@SUB=AlignableDetUnit::update\n"
47  << "Trying to update with GeomDetUnit* pointing to 'nullptr'.";
48  }
49 
50  Alignable::update(geomDetUnit->geographicalId().rawId(), geomDetUnit->surface());
51 
52  if (geomDetUnit->alignmentPositionError()) { // take over APE from geometry
53  // 2nd argument w/o effect:
54  this->setAlignmentPositionError(*(geomDetUnit->alignmentPositionError()), false);
55  }
56 
57  if (geomDetUnit->surfaceDeformation()) { // take over surface modification
58  // 2nd argument w/o effect:
59  this->setSurfaceDeformation(geomDetUnit->surfaceDeformation(), false);
60  }
61 }
62 
63 //__________________________________________________________________________________________________
65  throw cms::Exception("LogicError") << "AlignableDetUnit cannot have components, but try to add one!";
66 }
67 
68 //__________________________________________________________________________________________________
69 void AlignableDetUnit::move(const GlobalVector& displacement) {
71  this->addDisplacement(displacement);
72 }
73 
74 //__________________________________________________________________________________________________
77  this->addRotation(rotation);
78 }
79 
80 //__________________________________________________________________________________________________
81 void AlignableDetUnit::setAlignmentPositionError(const AlignmentPositionError& ape, bool /*propagateDown*/) {
84  else
86 }
87 
88 //__________________________________________________________________________________________________
91  this->setAlignmentPositionError(ape, propagateDown); // 2nd argument w/o effect
92  else
94 }
95 
96 //__________________________________________________________________________________________________
98  // average error calculated by movement of a local point at
99  // (xWidth/2,yLength/2,0) caused by the rotation rot
100  GlobalVector localPositionVector =
101  surface().toGlobal(LocalVector(.5 * surface().width(), .5 * surface().length(), 0.));
102 
103  const LocalVector::BasicVectorType& lpvgf = localPositionVector.basicVector();
104  GlobalVector gv(rot.multiplyInverse(lpvgf) - lpvgf);
105 
106  AlignmentPositionError ape(gv.x(), gv.y(), gv.z());
107  this->addAlignmentPositionError(ape, propagateDown); // 2nd argument w/o effect
108 }
109 
110 //__________________________________________________________________________________________________
113  this->addAlignmentPositionErrorFromRotation(globalRot, propagateDown); // 2nd argument w/o effect
114 }
115 
116 //__________________________________________________________________________________________________
117 void AlignableDetUnit::setSurfaceDeformation(const SurfaceDeformation* deformation, bool /* propagateDown */) {
118  delete theSurfaceDeformation; // OK for zero pointers
119  if (deformation) {
120  theSurfaceDeformation = deformation->clone();
121  } else {
122  theSurfaceDeformation = nullptr;
123  }
124 }
125 
126 //__________________________________________________________________________________________________
127 void AlignableDetUnit::addSurfaceDeformation(const SurfaceDeformation* deformation, bool propagateDown) {
128  if (!deformation) {
129  // nothing to do
130  } else if (!theSurfaceDeformation) {
131  this->setSurfaceDeformation(deformation, propagateDown); // fine since no components
132  } else if (!theSurfaceDeformation->add(*deformation)) {
133  edm::LogError("Alignment") << "@SUB=AlignableDetUnit::addSurfaceDeformation"
134  << "Cannot add deformation type " << deformation->type() << " to type "
135  << theSurfaceDeformation->type() << ", so erase deformation information.";
136  delete theSurfaceDeformation;
137  theSurfaceDeformation = nullptr;
138  }
139 }
140 
141 //__________________________________________________________________________________________________
143  std::ostringstream parameters;
144  if (theSurfaceDeformation) {
145  parameters << " surface deformation parameters:";
146  for (const auto& param : theSurfaceDeformation->parameters()) {
147  parameters << " " << param;
148  }
149  } else {
150  parameters << " no surface deformation parameters";
151  }
152 
153  edm::LogInfo("AlignableDump") << " AlignableDetUnit has position = " << this->globalPosition()
154  << ", orientation:" << std::endl
155  << this->globalRotation() << std::endl
156  << " total displacement and rotation: " << this->displacement() << std::endl
157  << this->rotation() << "\n"
158  << parameters.str();
159 }
160 
161 //__________________________________________________________________________________________________
163  Alignments* m_alignments = new Alignments();
165 
166  // Get alignments (position, rotation, detId)
167  CLHEP::Hep3Vector clhepVector(globalPosition().x(), globalPosition().y(), globalPosition().z());
168  CLHEP::HepRotation clhepRotation(
169  CLHEP::HepRep3x3(rot.xx(), rot.xy(), rot.xz(), rot.yx(), rot.yy(), rot.yz(), rot.zx(), rot.zy(), rot.zz()));
170  uint32_t detId = this->geomDetId().rawId();
171 
172  AlignTransform transform(clhepVector, clhepRotation, detId);
173 
174  // Add to alignments container
175  m_alignments->m_align.push_back(transform);
176 
177  return m_alignments;
178 }
179 
180 //__________________________________________________________________________________________________
182  AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
183 
184  uint32_t detId = this->geomDetId().rawId();
185 
186  CLHEP::HepSymMatrix clhepSymMatrix(6, 0);
187  if (theAlignmentPositionError) // Might not be set
189 
190  AlignTransformErrorExtended transformError(clhepSymMatrix, detId);
191 
192  m_alignmentErrors->m_alignError.push_back(transformError);
193 
194  return m_alignmentErrors;
195 }
196 
197 //__________________________________________________________________________________________________
198 int AlignableDetUnit::surfaceDeformationIdPairs(std::vector<std::pair<int, SurfaceDeformation*> >& result) const {
199  if (theSurfaceDeformation) {
200  result.push_back(std::pair<int, SurfaceDeformation*>(this->geomDetId().rawId(), theSurfaceDeformation));
201  return 1;
202  }
203 
204  return 0;
205 }
206 
207 //__________________________________________________________________________________________________
212 
215  theCachedSurfaceDeformation = nullptr;
216  }
217 
220 }
221 
222 //__________________________________________________________________________________________________
227 
228  auto existingCache = surfaceDeformationsCache_.find(run);
229  if (existingCache != surfaceDeformationsCache_.end()) {
230  delete existingCache->second;
231  existingCache->second = nullptr;
232  }
233 
234  if (theSurfaceDeformation) {
236  }
237 }
238 
239 //__________________________________________________________________________________________________
244 
245  if (theSurfaceDeformation) {
246  delete theSurfaceDeformation;
247  theSurfaceDeformation = nullptr;
248  }
249 
252  }
253 }
254 
255 //__________________________________________________________________________________________________
257  if (surfacesCache_.find(run) == surfacesCache_.end()) {
258  throw cms::Exception("Alignment") << "@SUB=Alignable::restoreCachedTransformation\n"
259  << "Trying to restore cached transformation for a run (" << run
260  << ") that has not been cached.";
261  } else {
265 
266  if (theSurfaceDeformation) {
267  delete theSurfaceDeformation;
268  theSurfaceDeformation = nullptr;
269  }
270 
273  }
274  }
275 }
276 
277 //______________________________________________________________________________
Vector3DBase< Scalar, GlobalTag >
AlignmentErrorsExtended.h
Alignable::theDisplacement
GlobalVector theDisplacement
Definition: Alignable.h:239
TkRotation< Scalar >
DDAxes::y
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:29
Alignable::theDeepComponents
Alignables theDeepComponents
Definition: Alignable.h:248
AlignableDetUnit::addAlignmentPositionErrorFromLocalRotation
void addAlignmentPositionErrorFromLocalRotation(const RotationType &rot, bool) final
Definition: AlignableDetUnit.cc:111
GloballyPositioned::rotate
void rotate(const RotationType &rotation)
Definition: GloballyPositioned.h:136
MessageLogger.h
AlignableDetUnit.h
AlignableDetUnit::~AlignableDetUnit
~AlignableDetUnit() override
Destructor.
Definition: AlignableDetUnit.cc:35
SurfaceDeformation::clone
virtual SurfaceDeformation * clone() const =0
SurfaceDeformation::add
virtual bool add(const SurfaceDeformation &other)=0
GeomDet
Definition: GeomDet.h:27
AlignableDetUnit::addSurfaceDeformation
void addSurfaceDeformation(const SurfaceDeformation *deformation, bool) final
Add surface deformation parameters to the existing ones (2nd argument without effect)
Definition: AlignableDetUnit.cc:127
Alignable::theCachedSurface
AlignableSurface theCachedSurface
Definition: Alignable.h:242
align::RunNumber
cond::RealTimeType< cond::runnumber >::type RunNumber
Definition: Utilities.h:37
Alignable
Definition: Alignable.h:27
AlignableDetUnit::alignments
Alignments * alignments() const override
Return vector of alignment data.
Definition: AlignableDetUnit.cc:162
AlignableDetUnit::theAlignmentPositionError
AlignmentPositionError * theAlignmentPositionError
Definition: AlignableDetUnit.h:93
Alignments.h
AlignableDetUnit::addComponent
void addComponent(Alignable *) final
No components here => exception!
Definition: AlignableDetUnit.cc:64
DDAxes::x
TkRotation::multiplyInverse
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
Definition: extTkRotation.h:178
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SurfaceDeformation::type
virtual int type() const =0
specific type, i.e. SurfaceDeformationFactory::Type
AlignableDetUnit::setAlignmentPositionError
void setAlignmentPositionError(const AlignmentPositionError &ape, bool) final
Set the AlignmentPositionError (no components => second argument ignored)
Definition: AlignableDetUnit.cc:81
SurfaceDeformation
Definition: SurfaceDeformation.h:18
AlignableDetUnit::theSurfaceDeformation
SurfaceDeformation * theSurfaceDeformation
Definition: AlignableDetUnit.h:94
Alignable::surfacesCache_
Cache< AlignableSurface > surfacesCache_
Definition: Alignable.h:251
AlignableDetUnit::alignmentErrors
AlignmentErrorsExtended * alignmentErrors() const override
Return vector of alignment errors.
Definition: AlignableDetUnit.cc:181
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
AlignableDetUnit::addAlignmentPositionErrorFromRotation
void addAlignmentPositionErrorFromRotation(const RotationType &rot, bool) final
Definition: AlignableDetUnit.cc:97
AlignmentPositionError::globalError
const GlobalErrorExtended & globalError() const
Definition: AlignmentPositionError.h:24
SurfaceDeformation::parameters
virtual std::vector< double > parameters() const =0
parameters - interpretation left to the concrete implementation
GeomDet::surfaceDeformation
virtual const SurfaceDeformation * surfaceDeformation() const
Definition: GeomDet.h:96
Alignable::update
void update(align::ID, const AlignableSurface &)
Definition: Alignable.cc:45
DDAxes::z
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
AlignableSurface::toGlobal
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
Definition: AlignableSurface.cc:15
Alignable::addRotation
void addRotation(const RotationType &rotation)
Definition: Alignable.cc:193
Alignable::surface
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
Alignable::displacement
const GlobalVector & displacement() const
Return change of the global position since the creation of the object.
Definition: Alignable.h:141
AlignTransform
Definition: AlignTransform.h:15
SurfaceDeformation.h
Alignable::displacementsCache_
Cache< GlobalVector > displacementsCache_
Definition: Alignable.h:252
AlignableDetUnit::setSurfaceDeformation
void setSurfaceDeformation(const SurfaceDeformation *deformation, bool) final
Set surface deformation parameters (2nd argument without effect)
Definition: AlignableDetUnit.cc:117
GeomDet::geographicalId
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
AlignableDetUnit::move
void move(const GlobalVector &displacement) override
Move with respect to the global reference frame.
Definition: AlignableDetUnit.cc:69
GeomDet::alignmentPositionError
AlignmentPositionError const * alignmentPositionError() const
Return pointer to alignment errors.
Definition: GeomDet.h:80
Alignable::rotation
const RotationType & rotation() const
Return change of orientation since the creation of the object.
Definition: Alignable.h:144
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
AlignableDetUnit::theCachedSurfaceDeformation
SurfaceDeformation * theCachedSurfaceDeformation
Definition: AlignableDetUnit.h:95
Alignable::geomDetId
const DetId & geomDetId() const
Definition: Alignable.h:177
GloballyPositioned::move
void move(const GlobalVector &displacement)
Definition: GloballyPositioned.h:128
AlignableDetUnit::rotateInGlobalFrame
void rotateInGlobalFrame(const RotationType &rotation) override
Rotation with respect to the global reference frame.
Definition: AlignableDetUnit.cc:75
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
AlignableDetUnit::dump
void dump() const override
Printout information about GeomDet.
Definition: AlignableDetUnit.cc:142
Alignable::theSurface
AlignableSurface theSurface
Definition: Alignable.h:237
Alignable::theCachedRotation
RotationType theCachedRotation
Definition: Alignable.h:244
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlignmentErrorsExtended
Definition: AlignmentErrorsExtended.h:10
PV3DBase::basicVector
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
AlignableDetUnit::update
void update(const GeomDetUnit *geomDetUnit)
Definition: AlignableDetUnit.cc:44
AlignableDetUnit::cacheTransformation
void cacheTransformation() override
cache the current position, rotation and other parameters (e.g. surface deformations)
Definition: AlignableDetUnit.cc:208
AlignableDetUnit::restoreCachedTransformation
void restoreCachedTransformation() override
restore the previously cached transformation
Definition: AlignableDetUnit.cc:240
GeomDet.h
align::Alignables
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
writedatasetfile.run
run
Definition: writedatasetfile.py:27
Alignable::rotationsCache_
Cache< RotationType > rotationsCache_
Definition: Alignable.h:253
AlignableDetUnit::AlignableDetUnit
AlignableDetUnit(const GeomDetUnit *geomDetUnit)
Constructor from GeomDetUnit - must not be NULL pointer!
Definition: AlignableDetUnit.cc:15
Exception
Definition: hltDiff.cc:246
Alignable::theCachedDisplacement
GlobalVector theCachedDisplacement
Definition: Alignable.h:243
Alignable::addDisplacement
void addDisplacement(const GlobalVector &displacement)
Definition: Alignable.cc:190
AlignmentPositionError.h
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
AlignTransformErrorExtended
Definition: AlignTransformErrorExtended.h:13
AlignableDetUnit::addAlignmentPositionError
void addAlignmentPositionError(const AlignmentPositionError &ape, bool) final
Definition: AlignableDetUnit.cc:89
Alignable::theRotation
RotationType theRotation
Definition: Alignable.h:240
Exception.h
GlobalErrorBaseExtended::matrix
const AlgebraicSymMatrix66 & matrix() const
Definition: GlobalErrorBaseExtended.h:153
Alignments::m_align
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
AlignmentErrorsExtended::m_alignError
std::vector< AlignTransformErrorExtended > m_alignError
Definition: AlignmentErrorsExtended.h:19
AlignableDetUnit::surfaceDeformationsCache_
Cache< SurfaceDeformation * > surfaceDeformationsCache_
Definition: AlignableDetUnit.h:96
mps_fire.result
result
Definition: mps_fire.py:311
Alignable::globalPosition
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:135
AlignmentPositionError
Definition: AlignmentPositionError.h:10
asHepMatrix
CLHEP::HepMatrix asHepMatrix(const ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > &rm)
Definition: Migration.h:59
Alignments
Definition: Alignments.h:10
Alignable::LocalVector
align::LocalVector LocalVector
Definition: Alignable.h:33
Basic3DVector
Definition: extBasic3DVector.h:30
AlignableDetUnit::surfaceDeformationIdPairs
int surfaceDeformationIdPairs(std::vector< std::pair< int, SurfaceDeformation * > > &) const override
Return surface deformations.
Definition: AlignableDetUnit.cc:198
Alignable::globalRotation
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:138
AlignableDetUnit::emptyComponents_
static const Alignables emptyComponents_
Definition: AlignableDetUnit.h:92