test
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  theCachedSurfaceDeformation(0)
20 {
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 
35 //__________________________________________________________________________________________________
37 {
39  delete theSurfaceDeformation;
41 }
42 
43 //__________________________________________________________________________________________________
45 {
46  throw cms::Exception("LogicError")
47  << "AlignableDetUnit cannot have components, but try to add one!";
48 }
49 
50 //__________________________________________________________________________________________________
51 void AlignableDetUnit::move( const GlobalVector& displacement)
52 {
53 
54  theSurface.move( displacement );
55  this->addDisplacement( displacement );
56 
57 }
58 
59 
60 //__________________________________________________________________________________________________
62 {
63 
64  theSurface.rotate( rotation );
65  this->addRotation( rotation );
66 
67 }
68 
69 
70 //__________________________________________________________________________________________________
72  bool /*propagateDown*/)
73 {
74 
77  else
79 
80 }
81 
82 
83 //__________________________________________________________________________________________________
85  bool propagateDown )
86 {
87 
89  this->setAlignmentPositionError( ape, propagateDown ); // 2nd argument w/o effect
90  else
92 }
93 
94 
95 //__________________________________________________________________________________________________
97  bool propagateDown )
98 {
99 
100  // average error calculated by movement of a local point at
101  // (xWidth/2,yLength/2,0) caused by the rotation rot
102  GlobalVector localPositionVector = surface().toGlobal( LocalVector(.5 * surface().width(),
103  .5 * surface().length(),
104  0.) );
105 
106  LocalVector::BasicVectorType lpvgf = localPositionVector.basicVector();
107  GlobalVector gv( rot.multiplyInverse(lpvgf) - lpvgf );
108 
109  AlignmentPositionError ape( gv.x(),gv.y(),gv.z() );
110  this->addAlignmentPositionError( ape, propagateDown ); // 2nd argument w/o effect
111 
112 }
113 
114 
115 //__________________________________________________________________________________________________
117  bool propagateDown )
118 {
119 
121  this->addAlignmentPositionErrorFromRotation(globalRot, propagateDown); // 2nd argument w/o effect
122 
123 }
124 
125 //__________________________________________________________________________________________________
127  bool /* propagateDown */ )
128 {
129  delete theSurfaceDeformation; // OK for zero pointers
130  if (deformation) {
131  theSurfaceDeformation = deformation->clone();
132  } else {
134  }
135 }
136 
137 //__________________________________________________________________________________________________
139  bool propagateDown)
140 {
141  if (!deformation) {
142  // nothing to do
143  } else if (!theSurfaceDeformation) {
144  this->setSurfaceDeformation(deformation, propagateDown); // fine since no components
145  } else if (!theSurfaceDeformation->add(*deformation)) {
146  edm::LogError("Alignment") << "@SUB=AlignableDetUnit::addSurfaceDeformation"
147  << "Cannot add deformation type " << deformation->type()
148  << " to type " << theSurfaceDeformation->type()
149  << ", so erase deformation information.";
150  delete theSurfaceDeformation;
152  }
153 }
154 
155 //__________________________________________________________________________________________________
157 {
158 
159  edm::LogInfo("AlignableDump")
160  << " AlignableDetUnit has position = " << this->globalPosition()
161  << ", orientation:" << std::endl << this->globalRotation() << std::endl
162  << " total displacement and rotation: " << this->displacement() << std::endl
163  << this->rotation();
164 
165 }
166 
167 
168 //__________________________________________________________________________________________________
170 {
171  Alignments* m_alignments = new Alignments();
172  RotationType rot( this->globalRotation() );
173 
174  // Get alignments (position, rotation, detId)
175  CLHEP::Hep3Vector clhepVector( globalPosition().x(), globalPosition().y(), globalPosition().z() );
176  CLHEP::HepRotation clhepRotation( CLHEP::HepRep3x3( rot.xx(), rot.xy(), rot.xz(),
177  rot.yx(), rot.yy(), rot.yz(),
178  rot.zx(), rot.zy(), rot.zz() ) );
179  uint32_t detId = this->geomDetId().rawId();
180 
181  AlignTransform transform( clhepVector, clhepRotation, detId );
182 
183  // Add to alignments container
184  m_alignments->m_align.push_back( transform );
185 
186  return m_alignments;
187 
188 }
189 
190 
191 //__________________________________________________________________________________________________
193 {
194 
195  AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
196 
197  uint32_t detId = this->geomDetId().rawId();
198 
199  CLHEP::HepSymMatrix clhepSymMatrix(6,0);
200  if ( theAlignmentPositionError ) // Might not be set
202 
203  AlignTransformErrorExtended transformError( clhepSymMatrix, detId );
204 
205  m_alignmentErrors->m_alignError.push_back( transformError );
206 
207  return m_alignmentErrors;
208 
209 }
210 
211 
212 //__________________________________________________________________________________________________
213 int AlignableDetUnit::surfaceDeformationIdPairs(std::vector<std::pair<int,SurfaceDeformation*> > & result) const
214 {
215  if ( theSurfaceDeformation ) {
216  result.push_back( std::pair<int,SurfaceDeformation*>(this->geomDetId().rawId(),theSurfaceDeformation) );
217  return 1;
218  }
219 
220  return 0;
221 }
222 
223 //__________________________________________________________________________________________________
225 {
229 
233  }
234 
237 }
238 
239 //__________________________________________________________________________________________________
241 {
245 
246  if (theSurfaceDeformation) {
247  delete theSurfaceDeformation;
249  }
250 
253  }
254 }
T xx() const
RotationType theCachedRotation
Definition: Alignable.h:234
CLHEP::HepMatrix asHepMatrix(const ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > &rm)
Definition: Migration.h:49
virtual void addAlignmentPositionErrorFromRotation(const RotationType &rot, bool)
RotationType theRotation
Definition: Alignable.h:230
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:140
T yx() const
void move(const GlobalVector &displacement)
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:137
virtual void addAlignmentPositionError(const AlignmentPositionError &ape, bool)
align::LocalVector LocalVector
Definition: Alignable.h:38
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
GlobalVector theDisplacement
Definition: Alignable.h:229
SurfaceDeformation * theCachedSurfaceDeformation
tuple result
Definition: mps_fire.py:83
const GlobalErrorExtended & globalError() const
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
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:143
AlignableDetUnit(const GeomDetUnit *geomDetUnit)
Constructor from GeomDetUnit - must not be NULL pointer!
virtual void addAlignmentPositionErrorFromLocalRotation(const RotationType &rot, bool)
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 AlgebraicSymMatrix66 & matrix() const
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:131
virtual int surfaceDeformationIdPairs(std::vector< std::pair< int, SurfaceDeformation * > > &) const
Return surface deformations.
AlignableSurface theCachedSurface
Definition: Alignable.h:232
virtual ~AlignableDetUnit()
Destructor.
virtual void addComponent(Alignable *)
No components here =&gt; exception!
std::vector< AlignTransformErrorExtended > m_alignError
void addRotation(const RotationType &rotation)
Definition: Alignable.cc:237
virtual SurfaceDeformation * clone() const =0
GlobalVector theCachedDisplacement
Definition: Alignable.h:233
virtual int type() const =0
specific type, i.e. SurfaceDeformationFactory::Type
void addDisplacement(const GlobalVector &displacement)
Definition: Alignable.cc:229
virtual void cacheTransformation()
cache the current position, rotation and other parameters (e.g. surface deformations) ...
virtual AlignmentErrorsExtended * alignmentErrors() const
Return vector of alignment errors.
virtual bool add(const SurfaceDeformation &other)=0
void rotate(const RotationType &rotation)
T xz() const
virtual const SurfaceDeformation * surfaceDeformation() const
Definition: GeomDet.h:108
virtual void restoreCachedTransformation()
restore the previously cached transformation
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:134
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
SurfaceDeformation * theSurfaceDeformation
AlignmentPositionError const * alignmentPositionError() const
Return pointer to alignment errors.
Definition: GeomDet.h:93
T yz() const
const DetId & geomDetId() const
Definition: Alignable.h:182
AlignableSurface theSurface
Definition: Alignable.h:227
Alignables theDeepComponents
Definition: Alignable.h:236