test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlignableComposite.cc
Go to the documentation of this file.
1 // Framework
4 
9 
11 
12 
13 //__________________________________________________________________________________________________
15  Alignable( geomDet->geographicalId().rawId(), geomDet->surface() ),
16  theStructureType(align::AlignableDet)
17 {
18 }
19 
22  const RotationType& rot):
23  Alignable(id, rot),
24  theStructureType(type)
25 {
26 }
27 
29 {
30  for (unsigned int i = 0; i < theComponents.size(); ++i) delete theComponents[i];
31 }
32 
34 {
35  const Alignables& newComps = ali->deepComponents();
36 
37  theDeepComponents.insert( theDeepComponents.end(), newComps.begin(), newComps.end() );
38 
39  Scalar k = static_cast<Scalar>( newComps.size() ) / theDeepComponents.size();
40 
41  theSurface.move( ( ali->globalPosition() - globalPosition() ) * k );
42 
43  ali->setMother(this);
44  theComponents.push_back(ali);
45 }
46 
47 //__________________________________________________________________________________________________
49 {
50 
53  && components.size() <= 1) { // Non-glued AlignableDets (still) contain themselves
54  return; // (would be better to implement AlignableDet::recursiveComponents!)
55  }
56  for (Alignables::const_iterator iter = components.begin();
57  iter != components.end(); ++iter) {
58  result.push_back(*iter); // could use std::copy(..), but here we build a real hierarchy
59  (*iter)->recursiveComponents(result);
60  }
61 }
62 
63 //__________________________________________________________________________________________________
64 void AlignableComposite::move( const GlobalVector& displacement )
65 {
66 
67  // Move components
68  Alignables comp = this->components();
69  for ( Alignables::iterator i=comp.begin(); i!=comp.end(); ++i )
70  (**i).move( displacement);
71 
72  // Move surface
73  this->addDisplacement( displacement );
74  theSurface.move( displacement );
75 
76 }
77 
78 
79 //__________________________________________________________________________________________________
80 void AlignableComposite::moveComponentsLocal( const LocalVector& localDisplacement )
81 {
82 
83  this->move( this->surface().toGlobal(localDisplacement) );
84 
85 }
86 
87 //__________________________________________________________________________________________________
88 void AlignableComposite::moveComponentLocal( const int i, const LocalVector& localDisplacement )
89 {
90 
91  if (i >= size() )
92  throw cms::Exception("LogicError")
93  << "AlignableComposite index (" << i << ") out of range";
94 
95  Alignables comp = this->components();
96  comp[i]->move( this->surface().toGlobal( localDisplacement ) );
97 
98 }
99 
100 
101 //__________________________________________________________________________________________________
107 {
108 
109  Alignables comp = this->components();
110 
111  PositionType myPosition = this->globalPosition();
112 
113  for ( Alignables::iterator i=comp.begin(); i!=comp.end(); ++i )
114  {
115 
116  // It is much simpler to calculate the local position given in coordinates
117  // of the GLOBAL frame and then just apply the rotation matrix given in the
118  // GLOBAL frame as well. ONLY this is somewhat tricky... as Teddy's frames
119  // don't like this kind of mixing...
120 
121  // Rotations are defined for "Basic3DVector" types, without any FrameTAG,
122  // because Rotations usually switch between different frames. You get
123  // this by using the method .basicVector()
124 
125  // localPosition = globalPosition (Component) - globalPosition(Composite)
126  // moveVector = rotated localPosition - original localposition
127  // LocalVector localPositionVector = (**i).globalPosition()-myPosition;
128 
129 
130  // Local Position given in coordinates of the GLOBAL Frame
131  const GlobalVector localPositionVector = (**i).globalPosition() - myPosition;
132  GlobalVector::BasicVectorType lpvgf = localPositionVector.basicVector();
133 
134  // rotate with GLOBAL rotation matrix and subtract => moveVector in
135  // global Coordinates
136  // apparently... you have to use the inverse of the rotation here
137  // (rotate the VECTOR rather than the frame)
138  GlobalVector moveVector( rotation.multiplyInverse(lpvgf) - lpvgf );
139 
140 
141  (**i).move( moveVector );
142  (**i).rotateInGlobalFrame( rotation );
143 
144  }
145 
146  this->addRotation( rotation );
147 
148  theSurface.rotate( rotation );
149 
150 }
151 
152 
153 //__________________________________________________________________________________________________
155  bool propagateDown )
156 {
157 
158  // Since no geomDet is attached, alignable composites do not have an APE
159  // The APE is, therefore, just propagated down
160  if (!propagateDown) return;
161 
162  Alignables comp = this->components();
163  for (Alignables::const_iterator i = comp.begin(); i != comp.end(); ++i) {
164  (*i)->setAlignmentPositionError(ape, propagateDown);
165  }
166 }
167 
168 
169 //__________________________________________________________________________________________________
170 void
172  bool propagateDown )
173 {
174 
175  // Since no geomDet is attached, alignable composites do not have an APE
176  // The APE is, therefore, just propagated down
177  if (!propagateDown) return;
178 
179  Alignables comp = this->components();
180  for (Alignables::const_iterator i = comp.begin(); i != comp.end(); ++i) {
181  (*i)->addAlignmentPositionError(ape, propagateDown);
182  }
183 
184 }
185 
186 
187 //__________________________________________________________________________________________________
192  bool propagateDown )
193 {
194 
195  if (!propagateDown) return;
196 
197  Alignables comp = this->components();
198  PositionType myPosition=this->globalPosition();
199 
200  for ( Alignables::const_iterator i=comp.begin(); i!=comp.end(); ++i )
201  {
202 
203  // It is just similar to to the "movement" that results to the components
204  // when the composite is rotated.
205  // Local Position given in coordinates of the GLOBAL Frame
206  const GlobalVector localPositionVector = (**i).globalPosition()-myPosition;
207  GlobalVector::BasicVectorType lpvgf = localPositionVector.basicVector();
208 
209  // rotate with GLOBAL rotation matrix and subtract => moveVector in global coordinates
210  // apparently... you have to use the inverse of the rotation here
211  // (rotate the VECTOR rather than the frame)
212  GlobalVector moveVector( rotation.multiplyInverse(lpvgf) - lpvgf );
213 
214  AlignmentPositionError ape( moveVector.x(), moveVector.y(), moveVector.z() );
215  (*i)->addAlignmentPositionError( ape, propagateDown );
216  (*i)->addAlignmentPositionErrorFromRotation( rotation, propagateDown );
217 
218  }
219 
220 }
221 
222 
223 //__________________________________________________________________________________________________
228  bool propagateDown )
229 {
230  // if (!propagateDown) return; // No! Cannot yet jump out since
231  // addAlignmentPositionErrorFromRotation(..) below might be overwritten in derived
232  // classes to do something on 'this' (and in fact does so in AlignableDet).
233 
235  this->addAlignmentPositionErrorFromRotation(globalRot, propagateDown);
236 
237 }
238 
239 //__________________________________________________________________________________________________
241  bool propagateDown)
242 {
243  // Only DetUnits have surface deformations.
244  // The parameters are, therefore, just propagated down.
245  if (!propagateDown) return;
246 
247  Alignables comp(this->components());
248  for (Alignables::const_iterator i = comp.begin(); i != comp.end(); ++i) {
249  (*i)->setSurfaceDeformation(deformation, propagateDown);
250  }
251 }
252 
253 //__________________________________________________________________________________________________
255  bool propagateDown)
256 {
257  // Only DetUnits have surface deformations.
258  // The parameters are, therefore, just propagated down.
259  if (!propagateDown) return;
260 
261  Alignables comp(this->components());
262  for (Alignables::const_iterator i = comp.begin(); i != comp.end(); ++i) {
263  (*i)->addSurfaceDeformation(deformation, propagateDown);
264  }
265 }
266 
267 //__________________________________________________________________________________________________
268 void AlignableComposite::dump( void ) const
269 {
270 
271  // A simple printout method. Could be specialized in the implementation classes.
272 
273  Alignables comp = this->components();
274 
275  // Dump this
276  edm::LogInfo("AlignableDump")
277  << " Alignable of type " << this->alignableObjectId()
278  << " has " << comp.size() << " components" << std::endl
279  << " position = " << this->globalPosition() << ", orientation:" << std::endl
280  << this->globalRotation();
281 
282  // Dump components
283  for ( Alignables::iterator i=comp.begin(); i!=comp.end(); ++i )
284  (*i)->dump();
285 
286 }
287 
288 
289 
290 //__________________________________________________________________________________________________
292 {
293 
294  // Recursively call alignments, until we get to an AlignableDetUnit
295  Alignables comp = this->components();
296 
297  Alignments* m_alignments = new Alignments();
298 
299  // Add components recursively
300  for ( Alignables::iterator i=comp.begin(); i!=comp.end(); ++i )
301  {
302  Alignments* tmpAlignments = (*i)->alignments();
303  std::copy( tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(),
304  std::back_inserter(m_alignments->m_align) );
305  delete tmpAlignments;
306  }
307 
308 
309  return m_alignments;
310 
311 }
312 
313 
314 //__________________________________________________________________________________________________
316 {
317 
318  // Recursively call alignmentsErrors, until we get to an AlignableDetUnit
319  Alignables comp = this->components();
320 
321  AlignmentErrorsExtended* m_alignmentErrors = new AlignmentErrorsExtended();
322 
323  // Add components recursively
324  for ( Alignables::iterator i=comp.begin(); i!=comp.end(); ++i )
325  {
326  AlignmentErrorsExtended* tmpAlignmentErrorsExtended = (*i)->alignmentErrors();
327  std::copy( tmpAlignmentErrorsExtended->m_alignError.begin(), tmpAlignmentErrorsExtended->m_alignError.end(),
328  std::back_inserter(m_alignmentErrors->m_alignError) );
329  delete tmpAlignmentErrorsExtended;
330  }
331 
332 
333  return m_alignmentErrors;
334 
335 }
336 
337 
338 //__________________________________________________________________________________________________
339 int AlignableComposite::surfaceDeformationIdPairs(std::vector<std::pair<int,SurfaceDeformation*> > & result) const
340 {
341 
342  Alignables comp = this->components();
343 
344  int count = 0;
345 
346  // Add components recursively
347  for ( Alignables::iterator i=comp.begin(); i!=comp.end(); ++i) {
348  count += (*i)->surfaceDeformationIdPairs(result);
349  }
350 
351  return count;
352 
353 }
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
AlignableComposite()
default constructor hidden
uint32_t ID
Definition: Definitions.h:26
virtual void addAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown)
void move(const GlobalVector &displacement)
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:137
virtual void setAlignmentPositionError(const AlignmentPositionError &ape, bool propagateDown)
std::vector< AlignTransform > m_align
Definition: Alignments.h:19
virtual void dump() const
Recursive printout of alignable structure.
virtual void recursiveComponents(Alignables &result) const
Provide all components, subcomponents etc. (cf. description in base class)
virtual void moveComponentsLocal(const LocalVector &localDisplacement)
Move with respect to the local reference frame.
tuple result
Definition: query.py:137
virtual void move(const GlobalVector &displacement)
Move with respect to the global reference frame.
virtual StructureType alignableObjectId() const
Return the alignable type identifier.
virtual Alignments * alignments() const
Return alignment data.
virtual void moveComponentLocal(const int i, const LocalVector &localDisplacement)
Move a single component with respect to the local reference frame.
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:131
void setMother(Alignable *mother)
Assign mother to alignable.
Definition: Alignable.h:93
virtual void addAlignmentPositionErrorFromLocalRotation(const RotationType &rotation, bool propagateDown)
const Alignables & deepComponents() const
Definition: Alignable.h:71
virtual int surfaceDeformationIdPairs(std::vector< std::pair< int, SurfaceDeformation * > > &) const
Return surface deformations.
std::vector< AlignTransformErrorExtended > m_alignError
void addRotation(const RotationType &rotation)
Definition: Alignable.cc:237
void addDisplacement(const GlobalVector &displacement)
Definition: Alignable.cc:229
virtual void addSurfaceDeformation(const SurfaceDeformation *deformation, bool propagateDown)
virtual void setSurfaceDeformation(const SurfaceDeformation *deformation, bool propagateDown)
Set the surface deformation parameters - if (!propagateDown) do not affect daughters.
void rotate(const RotationType &rotation)
virtual ~AlignableComposite()
deleting its components
virtual void addAlignmentPositionErrorFromRotation(const RotationType &rotation, bool propagateDown)
align::Scalar Scalar
Definition: Alignable.h:34
virtual Alignables components() const
Return vector of direct components.
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
align::Alignables Alignables
Definition: Alignable.h:39
virtual void rotateInGlobalFrame(const RotationType &rotation)
Rotation interpreted in global reference frame.
virtual AlignmentErrorsExtended * alignmentErrors() const
Return vector of alignment errors.
AlignableSurface theSurface
Definition: Alignable.h:227
int size() const
Return number of direct components.
Definition: Alignable.h:67
virtual void addComponent(Alignable *component)
Alignables theDeepComponents
Definition: Alignable.h:236