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  theAlignmentParameters(0),
24  theMother(0),
25  theSurvey(0)
26 {
27 }
28 
29 //__________________________________________________________________________________________________
31  theDetId(), // FIXME: inconsistent with other ctr., cf. above
32  theId(id),
33  theSurface(PositionType(), rot),
34  theAlignmentParameters(0),
35  theMother(0),
36  theSurvey(0)
37 {
38 }
39 
40 //__________________________________________________________________________________________________
42 {
44  delete theSurvey;
45 }
46 
47 //__________________________________________________________________________________________________
49 {
50  bool isConsistent = true;
51  bool hasAliComp = false; // whether there are any (grand-) daughters with parameters
52  bool first = true;
53  const Alignables comps(this->components());
54  for (Alignables::const_iterator iComp = comps.begin(), iCompEnd = comps.end();
55  iComp != iCompEnd; ++iComp) {
56  if ((*iComp)->alignmentParameters()) { // component has parameters itself
57  paramComps.push_back(*iComp);
58  if (!first && !hasAliComp) isConsistent = false;
59  hasAliComp = true;
60  } else {
61  const unsigned int nCompBefore = paramComps.size();
62  if (!(*iComp)->firstCompsWithParams(paramComps)) {
63  isConsistent = false; // problem down in hierarchy
64  }
65  if (paramComps.size() != nCompBefore) {
66  if (!first && !hasAliComp) isConsistent = false;
67  hasAliComp = true;
68  } else if (hasAliComp) { // no components with params, but previous component did have comps.
69  isConsistent = false;
70  }
71  }
72  first = false;
73  }
74 
75  return isConsistent;
76 }
77 
78 //__________________________________________________________________________________________________
80 {
81 
84 
85 }
86 
87 
88 //__________________________________________________________________________________________________
90 {
91 
92  // This is done by simply transforming the rotation from
93  // the local system O to the global one O^-1 * Rot * O
94  // and then applying the global rotation O * Rot
95 
96  rotateInGlobalFrame( surface().toGlobal(rotation) );
97 
98 }
99 
100 
101 //__________________________________________________________________________________________________
103 {
104 
105  rotateInGlobalFrame( RotationType(axis.basicVector(),radians) );
106 
107 }
108 
109 
110 //__________________________________________________________________________________________________
112 {
113 
114  rotateInLocalFrame(RotationType(axis.basicVector(), radians));
115 
116 }
117 
118 
119 //__________________________________________________________________________________________________
121 {
122 
123  RotationType rot( 1., 0., 0.,
124  0., std::cos(radians), std::sin(radians),
125  0., -std::sin(radians), std::cos(radians) );
126 
127  rotateInGlobalFrame(rot);
128 
129 }
130 
131 
132 //__________________________________________________________________________________________________
134 {
135 
136  RotationType rot( 1., 0., 0.,
137  0., std::cos(radians), std::sin(radians),
138  0., -std::sin(radians), std::cos(radians) );
139 
140  rotateInLocalFrame(rot);
141 
142 }
143 
144 
145 //__________________________________________________________________________________________________
147 {
148 
149  RotationType rot( std::cos(radians), 0., -std::sin(radians),
150  0., 1., 0.,
151  std::sin(radians), 0., std::cos(radians) );
152 
153  rotateInGlobalFrame(rot);
154 
155 }
156 
157 
158 //__________________________________________________________________________________________________
160 {
161 
162  RotationType rot( std::cos(radians), 0., -std::sin(radians),
163  0., 1., 0.,
164  std::sin(radians), 0., std::cos(radians) );
165 
166  rotateInLocalFrame(rot);
167 
168 }
169 
170 
171 //__________________________________________________________________________________________________
173 {
174 
175  RotationType rot( std::cos(radians), std::sin(radians), 0.,
176  -std::sin(radians), std::cos(radians), 0.,
177  0., 0., 1. );
178 
179  rotateInGlobalFrame(rot);
180 
181 }
182 
183 
184 //__________________________________________________________________________________________________
186 {
187 
188  RotationType rot( std::cos(radians), std::sin(radians), 0. ,
189  -std::sin(radians), std::cos(radians), 0. ,
190  0., 0., 1. );
191 
192  rotateInLocalFrame(rot);
193 
194 }
195 
196 
197 //__________________________________________________________________________________________________
198 void Alignable::addDisplacement( const GlobalVector& displacement )
199 {
200 
202 
203 }
204 
205 //__________________________________________________________________________________________________
206 void Alignable::addRotation( const RotationType& rotation )
207 {
208 
210 
211 }
212 
213 //__________________________________________________________________________________________________
215 {
216 
217  typedef std::pair<int,SurfaceDeformation*> IdSurfaceDeformationPtrPair;
218 
219  std::vector<IdSurfaceDeformationPtrPair> result;
221  std::sort( result.begin(),
222  result.end(),
224 
225  AlignmentSurfaceDeformations* allSurfaceDeformations = new AlignmentSurfaceDeformations();
226 
227  for ( std::vector<IdSurfaceDeformationPtrPair>::const_iterator iPair = result.begin();
228  iPair != result.end();
229  ++iPair) {
230 
231  // should we check for 'empty' parameters here (all zeros) and skip ?
232  // may be add 'empty' method to SurfaceDeformation
233  allSurfaceDeformations->add((*iPair).first,
234  (*iPair).second->type(),
235  (*iPair).second->parameters());
236  }
237 
238  return allSurfaceDeformations;
239 
240 }
241 
242 //__________________________________________________________________________________________________
243 void Alignable::setSurvey( const SurveyDet* survey )
244 {
245 
246  delete theSurvey;
247  theSurvey = survey;
248 
249 }
virtual void rotateInLocalFrame(const RotationType &rotation)
Rotation intepreted in the local reference frame.
Definition: Alignable.cc:89
RotationType theRotation
Definition: Alignable.h:219
virtual void rotateAroundLocalZ(Scalar radians)
Rotation around local z-axis.
Definition: Alignable.cc:185
virtual void rotateAroundLocalAxis(const LocalVector &axis, Scalar radians)
Rotation around arbitratry local axis.
Definition: Alignable.cc:111
Alignable()
private default ctr. to enforce usage of the specialised ones
Definition: Alignable.h:226
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:199
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:102
virtual Alignables components() const =0
Return vector of all direct components.
GlobalVector theDisplacement
Definition: Alignable.h:218
virtual void rotateAroundGlobalZ(Scalar radians)
Rotation around global z-axis.
Definition: Alignable.cc:172
const RotationType & rotation() const
Return change of orientation since the creation of the object.
Definition: Alignable.h:138
AlignmentParameters * theAlignmentParameters
Definition: Alignable.h:226
virtual int surfaceDeformationIdPairs(std::vector< std::pair< int, SurfaceDeformation * > > &) const =0
void setAlignmentParameters(AlignmentParameters *dap)
Set the AlignmentParameters.
Definition: Alignable.cc:79
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:48
AlignmentSurfaceDeformations * surfaceDeformations() const
Return surface deformations, sorted by DetId.
Definition: Alignable.cc:214
bool first
Definition: L1TdeRCT.cc:79
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
virtual void rotateAroundGlobalX(Scalar radians)
Rotation around global x-axis.
Definition: Alignable.cc:120
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:243
void addRotation(const RotationType &rotation)
Definition: Alignable.cc:206
align::RotationType RotationType
Definition: Alignable.h:36
virtual void rotateAroundLocalY(Scalar radians)
Rotation around local y-axis.
Definition: Alignable.cc:159
virtual void rotateAroundGlobalY(Scalar radians)
Rotation around global y-axis.
Definition: Alignable.cc:146
void addDisplacement(const GlobalVector &displacement)
Definition: Alignable.cc:198
virtual void rotateAroundLocalX(Scalar radians)
Rotation around local x-axis.
Definition: Alignable.cc:133
align::Scalar Scalar
Definition: Alignable.h:34
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:54
virtual ~Alignable()
Destructor.
Definition: Alignable.cc:41
const SurveyDet * theSurvey
Definition: Alignable.h:232
align::Alignables Alignables
Definition: Alignable.h:39