CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Alignable.cc
Go to the documentation of this file.
1 
10 
12 
15 
17 
18 //__________________________________________________________________________________________________
20  theDetId(id), // FIXME: inconsistent with other ctr., but needed for AlignableNavigator
21  theId(id), // (finally get rid of one of the IDs!)
22  theSurface(surf),
23  theCachedSurface(surf),
24  theAlignmentParameters(0),
25  theMother(0),
26  theSurvey(0)
27 {
28 }
29 
30 //__________________________________________________________________________________________________
32  theDetId(), // FIXME: inconsistent with other ctr., cf. above
33  theId(id),
34  theSurface(PositionType(), rot),
35  theCachedSurface(PositionType(), rot),
36  theAlignmentParameters(0),
37  theMother(0),
38  theSurvey(0)
39 {
40 }
41 
42 //__________________________________________________________________________________________________
44 {
46  delete theSurvey;
47 }
48 
49 //__________________________________________________________________________________________________
51 {
52  bool isConsistent = true;
53  bool hasAliComp = false; // whether there are any (grand-) daughters with parameters
54  bool first = true;
55  const Alignables comps(this->components());
56  for (Alignables::const_iterator iComp = comps.begin(), iCompEnd = comps.end();
57  iComp != iCompEnd; ++iComp) {
58  if ((*iComp)->alignmentParameters()) { // component has parameters itself
59  paramComps.push_back(*iComp);
60  if (!first && !hasAliComp) isConsistent = false;
61  hasAliComp = true;
62  } else {
63  const unsigned int nCompBefore = paramComps.size();
64  if (!(*iComp)->firstCompsWithParams(paramComps)) {
65  isConsistent = false; // problem down in hierarchy
66  }
67  if (paramComps.size() != nCompBefore) {
68  if (!first && !hasAliComp) isConsistent = false;
69  hasAliComp = true;
70  } else if (hasAliComp) { // no components with params, but previous component did have comps.
71  isConsistent = false;
72  }
73  }
74  first = false;
75  }
76 
77  return isConsistent;
78 }
79 
80 //__________________________________________________________________________________________________
82 {
83 
86 
87 }
88 
89 
90 //__________________________________________________________________________________________________
92 {
93 
94  // This is done by simply transforming the rotation from
95  // the local system O to the global one O^-1 * Rot * O
96  // and then applying the global rotation O * Rot
97 
98  rotateInGlobalFrame( surface().toGlobal(rotation) );
99 
100 }
101 
102 
103 //__________________________________________________________________________________________________
105 {
106 
107  rotateInGlobalFrame( RotationType(axis.basicVector(),radians) );
108 
109 }
110 
111 
112 //__________________________________________________________________________________________________
114 {
115 
116  rotateInLocalFrame(RotationType(axis.basicVector(), radians));
117 
118 }
119 
120 
121 //__________________________________________________________________________________________________
123 {
124 
125  RotationType rot( 1., 0., 0.,
126  0., std::cos(radians), std::sin(radians),
127  0., -std::sin(radians), std::cos(radians) );
128 
129  rotateInGlobalFrame(rot);
130 
131 }
132 
133 
134 //__________________________________________________________________________________________________
136 {
137 
138  RotationType rot( 1., 0., 0.,
139  0., std::cos(radians), std::sin(radians),
140  0., -std::sin(radians), std::cos(radians) );
141 
142  rotateInLocalFrame(rot);
143 
144 }
145 
146 
147 //__________________________________________________________________________________________________
149 {
150 
151  RotationType rot( std::cos(radians), 0., -std::sin(radians),
152  0., 1., 0.,
153  std::sin(radians), 0., std::cos(radians) );
154 
155  rotateInGlobalFrame(rot);
156 
157 }
158 
159 
160 //__________________________________________________________________________________________________
162 {
163 
164  RotationType rot( std::cos(radians), 0., -std::sin(radians),
165  0., 1., 0.,
166  std::sin(radians), 0., std::cos(radians) );
167 
168  rotateInLocalFrame(rot);
169 
170 }
171 
172 
173 //__________________________________________________________________________________________________
175 {
176 
177  RotationType rot( std::cos(radians), std::sin(radians), 0.,
178  -std::sin(radians), std::cos(radians), 0.,
179  0., 0., 1. );
180 
181  rotateInGlobalFrame(rot);
182 
183 }
184 
185 
186 //__________________________________________________________________________________________________
188 {
189 
190  RotationType rot( std::cos(radians), std::sin(radians), 0. ,
191  -std::sin(radians), std::cos(radians), 0. ,
192  0., 0., 1. );
193 
194  rotateInLocalFrame(rot);
195 
196 }
197 
198 
199 //__________________________________________________________________________________________________
200 void Alignable::addDisplacement( const GlobalVector& displacement )
201 {
202 
204 
205 }
206 
207 //__________________________________________________________________________________________________
209 {
210 
212 
213 }
214 
215 //__________________________________________________________________________________________________
217 {
218 
219  typedef std::pair<int,SurfaceDeformation*> IdSurfaceDeformationPtrPair;
220 
221  std::vector<IdSurfaceDeformationPtrPair> result;
223  std::sort( result.begin(),
224  result.end(),
226 
227  AlignmentSurfaceDeformations* allSurfaceDeformations = new AlignmentSurfaceDeformations();
228 
229  for ( std::vector<IdSurfaceDeformationPtrPair>::const_iterator iPair = result.begin();
230  iPair != result.end();
231  ++iPair) {
232 
233  // should we check for 'empty' parameters here (all zeros) and skip ?
234  // may be add 'empty' method to SurfaceDeformation
235  allSurfaceDeformations->add((*iPair).first,
236  (*iPair).second->type(),
237  (*iPair).second->parameters());
238  }
239 
240  return allSurfaceDeformations;
241 
242 }
243 
245 {
249 }
250 
252 {
253  // first treat itself
257 
258  // now treat components (a clean design would move that to AlignableComposite...)
259  const Alignables comps(this->components());
260 
261  for (auto it = comps.begin(); it != comps.end(); ++it) {
262  (*it)->restoreCachedTransformation();
263  }
264 
265 }
266 
267 //__________________________________________________________________________________________________
268 void Alignable::setSurvey( const SurveyDet* survey )
269 {
270 
271  delete theSurvey;
272  theSurvey = survey;
273 
274 }
RotationType theCachedRotation
Definition: Alignable.h:229
virtual void rotateInLocalFrame(const RotationType &rotation)
Rotation intepreted in the local reference frame.
Definition: Alignable.cc:91
RotationType theRotation
Definition: Alignable.h:225
virtual void rotateAroundLocalZ(Scalar radians)
Rotation around local z-axis.
Definition: Alignable.cc:187
virtual void rotateAroundLocalAxis(const LocalVector &axis, Scalar radians)
Rotation around arbitratry local axis.
Definition: Alignable.cc:113
Alignable()
private default ctr. to enforce usage of the specialised ones
Definition: Alignable.h:236
uint32_t ID
Definition: Definitions.h:26
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const SurveyDet * survey() const
Return survey info.
Definition: Alignable.h:205
const GlobalVector & displacement() const
Return change of the global position since the creation of the object.
Definition: Alignable.h:135
virtual void rotateAroundGlobalAxis(const GlobalVector &axis, Scalar radians)
Rotation around arbitratry global axis.
Definition: Alignable.cc:104
virtual Alignables components() const =0
Return vector of all direct components.
GlobalVector theDisplacement
Definition: Alignable.h:224
virtual void rotateAroundGlobalZ(Scalar radians)
Rotation around global z-axis.
Definition: Alignable.cc:174
const RotationType & rotation() const
Return change of orientation since the creation of the object.
Definition: Alignable.h:138
AlignmentParameters * theAlignmentParameters
Definition: Alignable.h:236
virtual int surfaceDeformationIdPairs(std::vector< std::pair< int, SurfaceDeformation * > > &) const =0
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:81
tuple result
Definition: query.py:137
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
bool firstCompsWithParams(Alignables &paramComps) const
Definition: Alignable.cc:50
AlignmentSurfaceDeformations * surfaceDeformations() const
Return surface deformations, sorted by DetId.
Definition: Alignable.cc:216
virtual void restoreCachedTransformation()
restore the previously cached transformation, also for possible components
Definition: Alignable.cc:251
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
AlignableSurface theCachedSurface
Definition: Alignable.h:227
virtual void rotateAroundGlobalX(Scalar radians)
Rotation around global x-axis.
Definition: Alignable.cc:122
bool add(align::ID rawId, int type, const std::vector< align::Scalar > &parameters)
Add a new item.
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
void setSurvey(const SurveyDet *)
Set survey info.
Definition: Alignable.cc:268
void addRotation(const RotationType &rotation)
Definition: Alignable.cc:208
align::RotationType RotationType
Definition: Alignable.h:36
GlobalVector theCachedDisplacement
Definition: Alignable.h:228
virtual void rotateAroundLocalY(Scalar radians)
Rotation around local y-axis.
Definition: Alignable.cc:161
virtual void rotateAroundGlobalY(Scalar radians)
Rotation around global y-axis.
Definition: Alignable.cc:148
void addDisplacement(const GlobalVector &displacement)
Definition: Alignable.cc:200
virtual void cacheTransformation()
cache the current position, rotation and other parameters (e.g. surface deformations) ...
Definition: Alignable.cc:244
virtual void rotateAroundLocalX(Scalar radians)
Rotation around local x-axis.
Definition: Alignable.cc:135
align::Scalar Scalar
Definition: Alignable.h:34
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
virtual ~Alignable()
Destructor.
Definition: Alignable.cc:43
const SurveyDet * theSurvey
Definition: Alignable.h:242
align::Alignables Alignables
Definition: Alignable.h:39
AlignableSurface theSurface
Definition: Alignable.h:222