test
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  bool isConsistent = true;
84  bool hasAliComp = false;
85  bool first = true;
86  const Alignables comps(this->components());
87  for (const auto& iComp: comps) {
88  const auto nCompsBefore = paramComps.size();
89  isConsistent = iComp->lastCompsWithParams(paramComps);
90  if (paramComps.size() == nCompsBefore) {
91  if (iComp->alignmentParameters()) {
92  paramComps.push_back(iComp);
93  if (!first && !hasAliComp) isConsistent = false;
94  hasAliComp = true;
95  }
96  } else {
97  if (hasAliComp) {
98  isConsistent = false;
99  }
100  if (!first && !hasAliComp) isConsistent = false;
101  hasAliComp = true;
102  }
103  first = false;
104  }
105 
106  return isConsistent;
107 }
108 
109 //__________________________________________________________________________________________________
111 {
112 
113  delete theAlignmentParameters;
115 
116 }
117 
118 
119 //__________________________________________________________________________________________________
121 {
122 
123  // This is done by simply transforming the rotation from
124  // the local system O to the global one O^-1 * Rot * O
125  // and then applying the global rotation O * Rot
126 
127  rotateInGlobalFrame( surface().toGlobal(rotation) );
128 
129 }
130 
131 
132 //__________________________________________________________________________________________________
134 {
135 
136  rotateInGlobalFrame( RotationType(axis.basicVector(),radians) );
137 
138 }
139 
140 
141 //__________________________________________________________________________________________________
143 {
144 
145  rotateInLocalFrame(RotationType(axis.basicVector(), radians));
146 
147 }
148 
149 
150 //__________________________________________________________________________________________________
152 {
153 
154  RotationType rot( 1., 0., 0.,
155  0., std::cos(radians), std::sin(radians),
156  0., -std::sin(radians), std::cos(radians) );
157 
158  rotateInGlobalFrame(rot);
159 
160 }
161 
162 
163 //__________________________________________________________________________________________________
165 {
166 
167  RotationType rot( 1., 0., 0.,
168  0., std::cos(radians), std::sin(radians),
169  0., -std::sin(radians), std::cos(radians) );
170 
171  rotateInLocalFrame(rot);
172 
173 }
174 
175 
176 //__________________________________________________________________________________________________
178 {
179 
180  RotationType rot( std::cos(radians), 0., -std::sin(radians),
181  0., 1., 0.,
182  std::sin(radians), 0., std::cos(radians) );
183 
184  rotateInGlobalFrame(rot);
185 
186 }
187 
188 
189 //__________________________________________________________________________________________________
191 {
192 
193  RotationType rot( std::cos(radians), 0., -std::sin(radians),
194  0., 1., 0.,
195  std::sin(radians), 0., std::cos(radians) );
196 
197  rotateInLocalFrame(rot);
198 
199 }
200 
201 
202 //__________________________________________________________________________________________________
204 {
205 
206  RotationType rot( std::cos(radians), std::sin(radians), 0.,
207  -std::sin(radians), std::cos(radians), 0.,
208  0., 0., 1. );
209 
210  rotateInGlobalFrame(rot);
211 
212 }
213 
214 
215 //__________________________________________________________________________________________________
217 {
218 
219  RotationType rot( std::cos(radians), std::sin(radians), 0. ,
220  -std::sin(radians), std::cos(radians), 0. ,
221  0., 0., 1. );
222 
223  rotateInLocalFrame(rot);
224 
225 }
226 
227 
228 //__________________________________________________________________________________________________
229 void Alignable::addDisplacement( const GlobalVector& displacement )
230 {
231 
233 
234 }
235 
236 //__________________________________________________________________________________________________
238 {
239 
241 
242 }
243 
244 //__________________________________________________________________________________________________
246 {
247 
248  typedef std::pair<int,SurfaceDeformation*> IdSurfaceDeformationPtrPair;
249 
250  std::vector<IdSurfaceDeformationPtrPair> result;
252  std::sort( result.begin(),
253  result.end(),
255 
256  AlignmentSurfaceDeformations* allSurfaceDeformations = new AlignmentSurfaceDeformations();
257 
258  for ( std::vector<IdSurfaceDeformationPtrPair>::const_iterator iPair = result.begin();
259  iPair != result.end();
260  ++iPair) {
261 
262  // should we check for 'empty' parameters here (all zeros) and skip ?
263  // may be add 'empty' method to SurfaceDeformation
264  allSurfaceDeformations->add((*iPair).first,
265  (*iPair).second->type(),
266  (*iPair).second->parameters());
267  }
268 
269  return allSurfaceDeformations;
270 
271 }
272 
274 {
275  // first treat itself
279 
280  // now treat components (a clean design would move that to AlignableComposite...)
281  const Alignables comps(this->components());
282 
283  for (auto it = comps.begin(); it != comps.end(); ++it) {
284  (*it)->cacheTransformation();
285  }
286 
287 }
288 
290 {
291  // first treat itself
295 
296  // now treat components (a clean design would move that to AlignableComposite...)
297  const Alignables comps(this->components());
298 
299  for (auto it = comps.begin(); it != comps.end(); ++it) {
300  (*it)->restoreCachedTransformation();
301  }
302 
303 }
304 
305 //__________________________________________________________________________________________________
306 void Alignable::setSurvey( const SurveyDet* survey )
307 {
308 
309  delete theSurvey;
310  theSurvey = survey;
311 
312 }
RotationType theCachedRotation
Definition: Alignable.h:234
virtual void rotateInLocalFrame(const RotationType &rotation)
Rotation intepreted in the local reference frame.
Definition: Alignable.cc:120
RotationType theRotation
Definition: Alignable.h:230
virtual void rotateAroundLocalZ(Scalar radians)
Rotation around local z-axis.
Definition: Alignable.cc:216
virtual void rotateAroundLocalAxis(const LocalVector &axis, Scalar radians)
Rotation around arbitratry local axis.
Definition: Alignable.cc:142
Alignable()
private default ctr. to enforce usage of the specialised ones
Definition: Alignable.h:241
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:210
const GlobalVector & displacement() const
Return change of the global position since the creation of the object.
Definition: Alignable.h:140
virtual void rotateAroundGlobalAxis(const GlobalVector &axis, Scalar radians)
Rotation around arbitratry global axis.
Definition: Alignable.cc:133
virtual Alignables components() const =0
Return vector of all direct components.
GlobalVector theDisplacement
Definition: Alignable.h:229
tuple result
Definition: mps_fire.py:83
virtual void rotateAroundGlobalZ(Scalar radians)
Rotation around global z-axis.
Definition: Alignable.cc:203
const RotationType & rotation() const
Return change of orientation since the creation of the object.
Definition: Alignable.h:143
AlignmentParameters * theAlignmentParameters
Definition: Alignable.h:241
virtual int surfaceDeformationIdPairs(std::vector< std::pair< int, SurfaceDeformation * > > &) const =0
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:110
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:245
virtual void restoreCachedTransformation()
restore the previously cached transformation, also for possible components
Definition: Alignable.cc:289
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:131
AlignableSurface theCachedSurface
Definition: Alignable.h:232
virtual void rotateAroundGlobalX(Scalar radians)
Rotation around global x-axis.
Definition: Alignable.cc:151
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:306
void addRotation(const RotationType &rotation)
Definition: Alignable.cc:237
align::RotationType RotationType
Definition: Alignable.h:36
GlobalVector theCachedDisplacement
Definition: Alignable.h:233
virtual void rotateAroundLocalY(Scalar radians)
Rotation around local y-axis.
Definition: Alignable.cc:190
virtual void rotateAroundGlobalY(Scalar radians)
Rotation around global y-axis.
Definition: Alignable.cc:177
void addDisplacement(const GlobalVector &displacement)
Definition: Alignable.cc:229
virtual void cacheTransformation()
cache the current position, rotation and other parameters (e.g. surface deformations), also for possible components
Definition: Alignable.cc:273
virtual void rotateAroundLocalX(Scalar radians)
Rotation around local x-axis.
Definition: Alignable.cc:164
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:247
align::Alignables Alignables
Definition: Alignable.h:39
AlignableSurface theSurface
Definition: Alignable.h:227
bool lastCompsWithParams(Alignables &paramComps) const
Definition: Alignable.cc:81