CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlignableDetUnit.cc
Go to the documentation of this file.
2 
4 
7 #include "CLHEP/Vector/RotationInterfaces.h"
10 
13 
14 //__________________________________________________________________________________________________
15 AlignableDetUnit::AlignableDetUnit(const GeomDetUnit *geomDetUnit) : // rely on non-NULL pointer!
16  Alignable(geomDetUnit->geographicalId().rawId(), geomDetUnit->surface()),
17  theAlignmentPositionError(0),
18  theSurfaceDeformation(0)
19 {
20  if (geomDetUnit->alignmentPositionError()) { // take over APE from geometry
21  // 2nd argument w/o effect:
22  this->setAlignmentPositionError(*(geomDetUnit->alignmentPositionError()), false);
23  }
24 
25  if (geomDetUnit->surfaceDeformation()) { // take over surface modification
26  // 2nd argument w/o effect:
27  this->setSurfaceDeformation(geomDetUnit->surfaceDeformation(), false);
28  }
29 
30  theDeepComponents.push_back(this);
31 
32 }
33 
34 //__________________________________________________________________________________________________
36 {
38  delete theSurfaceDeformation;
39 }
40 
41 //__________________________________________________________________________________________________
43 {
44  throw cms::Exception("LogicError")
45  << "AlignableDetUnit cannot have components, but try to add one!";
46 }
47 
48 //__________________________________________________________________________________________________
49 void AlignableDetUnit::move( const GlobalVector& displacement)
50 {
51 
52  theSurface.move( displacement );
53  this->addDisplacement( displacement );
54 
55 }
56 
57 
58 //__________________________________________________________________________________________________
60 {
61 
62  theSurface.rotate( rotation );
63  this->addRotation( rotation );
64 
65 }
66 
67 
68 //__________________________________________________________________________________________________
70  bool /*propagateDown*/)
71 {
72 
75  else
77 
78 }
79 
80 
81 //__________________________________________________________________________________________________
83  bool propagateDown )
84 {
85 
87  this->setAlignmentPositionError( ape, propagateDown ); // 2nd argument w/o effect
88  else
90 }
91 
92 
93 //__________________________________________________________________________________________________
95  bool propagateDown )
96 {
97 
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 = surface().toGlobal( LocalVector(.5 * surface().width(),
101  .5 * surface().length(),
102  0.) );
103 
104  LocalVector::BasicVectorType lpvgf = localPositionVector.basicVector();
105  GlobalVector gv( rot.multiplyInverse(lpvgf) - lpvgf );
106 
107  AlignmentPositionError ape( gv.x(),gv.y(),gv.z() );
108  this->addAlignmentPositionError( ape, propagateDown ); // 2nd argument w/o effect
109 
110 }
111 
112 
113 //__________________________________________________________________________________________________
115  bool propagateDown )
116 {
117 
119  this->addAlignmentPositionErrorFromRotation(globalRot, propagateDown); // 2nd argument w/o effect
120 
121 }
122 
123 //__________________________________________________________________________________________________
125  bool /* propagateDown */ )
126 {
127  delete theSurfaceDeformation; // OK for zero pointers
128  if (deformation) {
129  theSurfaceDeformation = deformation->clone();
130  } else {
132  }
133 }
134 
135 //__________________________________________________________________________________________________
137  bool propagateDown)
138 {
139  if (!deformation) {
140  // nothing to do
141  } else if (!theSurfaceDeformation) {
142  this->setSurfaceDeformation(deformation, propagateDown); // fine since no components
143  } else if (!theSurfaceDeformation->add(*deformation)) {
144  edm::LogError("Alignment") << "@SUB=AlignableDetUnit::addSurfaceDeformation"
145  << "Cannot add deformation type " << deformation->type()
146  << " to type " << theSurfaceDeformation->type()
147  << ", so erase deformation information.";
148  delete theSurfaceDeformation;
150  }
151 }
152 
153 //__________________________________________________________________________________________________
155 {
156 
157  edm::LogInfo("AlignableDump")
158  << " AlignableDetUnit has position = " << this->globalPosition()
159  << ", orientation:" << std::endl << this->globalRotation() << std::endl
160  << " total displacement and rotation: " << this->displacement() << std::endl
161  << this->rotation();
162 
163 }
164 
165 
166 //__________________________________________________________________________________________________
168 {
169 
170  Alignments* m_alignments = new Alignments();
171  RotationType rot( this->globalRotation() );
172 
173  // Get alignments (position, rotation, detId)
174  CLHEP::Hep3Vector clhepVector( globalPosition().x(), globalPosition().y(), globalPosition().z() );
175  CLHEP::HepRotation clhepRotation( CLHEP::HepRep3x3( rot.xx(), rot.xy(), rot.xz(),
176  rot.yx(), rot.yy(), rot.yz(),
177  rot.zx(), rot.zy(), rot.zz() ) );
178  uint32_t detId = this->geomDetId().rawId();
179 
180  AlignTransform transform( clhepVector, clhepRotation, detId );
181 
182  // Add to alignments container
183  m_alignments->m_align.push_back( transform );
184 
185  return m_alignments;
186 
187 }
188 
189 
190 //__________________________________________________________________________________________________
192 {
193 
194  AlignmentErrors* m_alignmentErrors = new AlignmentErrors();
195 
196  uint32_t detId = this->geomDetId().rawId();
197 
198  CLHEP::HepSymMatrix clhepSymMatrix(3,0);
199  if ( theAlignmentPositionError ) // Might not be set
200  clhepSymMatrix = theAlignmentPositionError->globalError().matrix();
201 
202  AlignTransformError transformError( clhepSymMatrix, detId );
203 
204  m_alignmentErrors->m_alignError.push_back( transformError );
205 
206  return m_alignmentErrors;
207 
208 }
209 
210 
211 //__________________________________________________________________________________________________
212 int AlignableDetUnit::surfaceDeformationIdPairs(std::vector<std::pair<int,SurfaceDeformation*> > & result) const
213 {
214  if ( theSurfaceDeformation ) {
215  result.push_back( std::pair<int,SurfaceDeformation*>(this->geomDetId().rawId(),theSurfaceDeformation) );
216  return 1;
217  }
218 
219  return 0;
220 }
T xx() const
virtual void addAlignmentPositionErrorFromRotation(const RotationType &rot, bool)
virtual AlignmentPositionError * alignmentPositionError() const
Definition: GeomDet.h:81
virtual void rotateInGlobalFrame(const RotationType &rotation)
Rotation with respect to the global reference frame.
const GlobalVector & displacement() const
Return change of the global position since the creation of the object.
Definition: Alignable.h:135
std::vector< AlignTransformError > m_alignError
T yx() const
void move(const GlobalVector &displacement)
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:132
virtual void addAlignmentPositionError(const AlignmentPositionError &ape, bool)
align::LocalVector LocalVector
Definition: Alignable.h:38
virtual const SurfaceDeformation * surfaceDeformation() const
Definition: GeomDetUnit.h:37
std::vector< AlignTransform > m_align
Definition: Alignments.h:14
double double double z
AlgebraicSymMatrix matrix() const
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
T zx() const
T xy() const
virtual void move(const GlobalVector &displacement)
Move with respect to the global reference frame.
T zz() const
virtual void setSurfaceDeformation(const SurfaceDeformation *deformation, bool)
Set surface deformation parameters (2nd argument without effect)
const RotationType & rotation() const
Return change of orientation since the creation of the object.
Definition: Alignable.h:138
AlignableDetUnit(const GeomDetUnit *geomDetUnit)
Constructor from GeomDetUnit - must not be NULL pointer!
virtual void addAlignmentPositionErrorFromLocalRotation(const RotationType &rot, bool)
tuple result
Definition: query.py:137
T zy() const
virtual Alignments * alignments() const
Return vector of alignment data.
virtual void setAlignmentPositionError(const AlignmentPositionError &ape, bool)
Set the AlignmentPositionError (no components =&gt; second argument ignored)
virtual void addSurfaceDeformation(const SurfaceDeformation *deformation, bool)
Add surface deformation parameters to the existing ones (2nd argument without effect) ...
T yy() const
virtual void dump() const
Printout information about GeomDet.
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
virtual int surfaceDeformationIdPairs(std::vector< std::pair< int, SurfaceDeformation * > > &) const
Return surface deformations.
virtual ~AlignableDetUnit()
Destructor.
virtual void addComponent(Alignable *)
No components here =&gt; exception!
void addRotation(const RotationType &rotation)
Definition: Alignable.cc:206
virtual SurfaceDeformation * clone() const =0
const GlobalError & globalError() const
virtual int type() const =0
specific type, i.e. SurfaceDeformationFactory::Type
void addDisplacement(const GlobalVector &displacement)
Definition: Alignable.cc:198
virtual bool add(const SurfaceDeformation &other)=0
void rotate(const RotationType &rotation)
T xz() const
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
AlignmentPositionError * theAlignmentPositionError
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:129
Definition: DDAxes.h:10
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:54
SurfaceDeformation * theSurfaceDeformation
T yz() const
const DetId & geomDetId() const
Definition: Alignable.h:177
AlignableSurface theSurface
Definition: Alignable.h:216
Alignables theDeepComponents
Definition: Alignable.h:221
virtual AlignmentErrors * alignmentErrors() const
Return vector of alignment errors.