test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RigidBodyAlignmentParameters.cc
Go to the documentation of this file.
1 
9 
16 
17 // This class's header
19 
20 //__________________________________________________________________________________________________
22  AlignmentParameters(ali, displacementFromAlignable(calcMis ? ali : 0),
23  AlgebraicSymMatrix(N_PARAM, 0))
24 {
25 }
26 
27 //__________________________________________________________________________________________________
30  const AlgebraicSymMatrix& covMatrix) :
31  AlignmentParameters( alignable, parameters, covMatrix )
32 {
33 
34  if (parameters.num_row() != N_PARAM) {
35  throw cms::Exception("BadParameters") << "in RigidBodyAlignmentParameters(): "
36  << parameters.num_row() << " instead of " << N_PARAM
37  << " parameters.";
38  }
39 }
40 
41 //__________________________________________________________________________________________________
44  const AlgebraicSymMatrix& covMatrix,
45  const std::vector<bool>& selection ) :
46  AlignmentParameters( alignable, parameters, covMatrix, selection )
47 {
48  if (parameters.num_row() != N_PARAM) {
49  throw cms::Exception("BadParameters") << "in RigidBodyAlignmentParameters(): "
50  << parameters.num_row() << " instead of " << N_PARAM
51  << " parameters.";
52  }
53 }
54 
55 //__________________________________________________________________________________________________
58  const AlgebraicSymMatrix& covMatrix ) const
59 {
61  new RigidBodyAlignmentParameters( alignable(), parameters, covMatrix, selector());
62 
64  rbap->setValid(isValid());
65 
66  return rbap;
67 }
68 
69 //__________________________________________________________________________________________________
72  const AlgebraicSymMatrix& covMatrix ) const
73 {
76  expandSymMatrix(covMatrix, selector()), selector());
77 
79  rbap->setValid(isValid());
80 
81  return rbap;
82 }
83 
84 //__________________________________________________________________________________________________
87  const AlignableDetOrUnitPtr &alidet ) const
88 {
89  const Alignable *ali = this->alignable(); // Alignable of these parameters
90 
91  if (ali == alidet) { // same alignable => same frame
92  return KarimakiAlignmentDerivatives()(tsos);
93  } else { // different alignable => transform into correct frame
94  const AlgebraicMatrix deriv = KarimakiAlignmentDerivatives()(tsos);
96  return ftfd.frameToFrameDerivative(alidet, ali).T() * deriv;
97  }
98 }
99 
100 
101 //__________________________________________________________________________________________________
104  const AlignableDetOrUnitPtr &alignableDet ) const
105 {
106  const AlgebraicMatrix dev = this->derivatives( tsos, alignableDet );
107 
108  int ncols = dev.num_col();
109  int nrows = dev.num_row();
110  int nsel = numSelected();
111 
112  AlgebraicMatrix seldev( nsel, ncols );
113 
114  int ir2=0;
115  for ( int irow=0; irow<nrows; ++irow ) {
116  if (selector()[irow]) {
117  for ( int icol=0; icol<ncols; ++icol ) seldev[ir2][icol] = dev[irow][icol];
118  ++ir2;
119  }
120  }
121 
122  return seldev;
123 }
124 
125 
126 //__________________________________________________________________________________________________
128 {
130  for ( int i=0;i<3;++i ) shift[i]=theData->parameters()[i];
131 
132  return shift;
133 }
134 
135 
136 //__________________________________________________________________________________________________
138 {
139  AlgebraicVector rot(3);
140  for (int i=0;i<3;++i) rot[i] = theData->parameters()[i+3];
141 
142  return rot;
143 }
144 
145 //__________________________________________________________________________________________________
147 {
148  Alignable *alignable = this->alignable();
149  if (!alignable) {
150  throw cms::Exception("BadParameters")
151  << "RigidBodyAlignmentParameters::apply: parameters without alignable";
152  }
153 
154  // Translation in local frame
155  AlgebraicVector shift = this->translation(); // fixme: should be LocalVector
156 
157  // Translation local->global
158  align::LocalVector lv(shift[0], shift[1], shift[2]);
159  alignable->move( alignable->surface().toGlobal(lv) );
160 
161  // Rotation in local frame
162  align::EulerAngles angles = this->rotation();
163  // original code:
164  // alignable->rotateInLocalFrame( align::toMatrix(angles) );
165  // correct for rounding errors:
166  align::RotationType rot = alignable->surface().toGlobal( align::toMatrix(angles) );
167  align::rectify(rot);
168  alignable->rotateInGlobalFrame(rot);
169 }
170 
171 //__________________________________________________________________________________________________
173 {
175 }
176 
177 //__________________________________________________________________________________________________
179 {
180  AlgebraicVector m_GlobalParameters(N_PARAM, 0);
181 
182  const AlgebraicVector shift = translation(); // fixme: should return LocalVector
183 
184  const align::LocalVector lv(shift[0], shift[1], shift[2]);
186 
187  m_GlobalParameters[0] = dg.x();
188  m_GlobalParameters[1] = dg.y();
189  m_GlobalParameters[2] = dg.z();
190 
191  const align::EulerAngles eulerglob = theAlignable->surface().toGlobal( rotation() );
192 
193  m_GlobalParameters[3]=eulerglob(1);
194  m_GlobalParameters[4]=eulerglob(2);
195  m_GlobalParameters[5]=eulerglob(3);
196 
197  return m_GlobalParameters;
198 }
199 
200 
201 //__________________________________________________________________________________________________
203 {
204 
205  std::cout << "Contents of RigidBodyAlignmentParameters:"
206  << "\nParameters: " << theData->parameters()
207  << "\nCovariance: " << theData->covariance() << std::endl;
208 }
209 
210 
211 //__________________________________________________________________________________________________
213 {
214  AlgebraicVector displacement(N_PARAM);
215 
216  if (ali) {
217  const align::RotationType& dR = ali->rotation();
218 
219  const align::LocalVector shifts( ali->globalRotation() *
220  ( dR.transposed() * ali->displacement().basicVector() ) );
221 
222  const align::EulerAngles angles = align::toAngles( ali->surface().toLocal(dR) );
223 
224  displacement[0] = shifts.x();
225  displacement[1] = shifts.y();
226  displacement[2] = shifts.z();
227  displacement[3] = angles(1);
228  displacement[4] = angles(2);
229  displacement[5] = angles(3);
230  }
231 
232  return displacement;
233 }
int i
Definition: DBlmapReader.cc:9
virtual RigidBodyAlignmentParameters * clone(const AlgebraicVector &parameters, const AlgebraicSymMatrix &covMatrix) const
Clone all parameters (for update of parameters)
static AlgebraicVector displacementFromAlignable(const Alignable *ali)
const GlobalVector & displacement() const
Return change of the global position since the creation of the object.
Definition: Alignable.h:140
selection
main part
Definition: corrVsCorr.py:98
virtual AlgebraicMatrix selectedDerivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &) const
Get selected derivatives.
T y() const
Definition: PV3DBase.h:63
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:137
AlgebraicSymMatrix expandSymMatrix(const AlgebraicSymMatrix &m, const std::vector< bool > &sel) const
virtual void move(const GlobalVector &displacement)=0
Movement with respect to the global reference frame.
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
virtual AlgebraicMatrix derivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &) const
Get all derivatives.
virtual void apply()
apply parameters to alignable
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
const RotationType & rotation() const
Return change of orientation since the creation of the object.
Definition: Alignable.h:143
align::RotationType toLocal(const align::RotationType &) const
Return in local frame a rotation given in global frame.
CLHEP::HepMatrix AlgebraicMatrix
void rectify(RotationType &)
Correct a rotation matrix for rounding errors.
Definition: Utilities.cc:196
void setValid(bool v)
Set validity flag.
T z() const
Definition: PV3DBase.h:64
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
Definition: Utilities.cc:7
Alignable * alignable(void) const
Get pointer to corresponding alignable.
AlgebraicMatrix frameToFrameDerivative(const Alignable *object, const Alignable *composedObject) const
virtual int type() const
tell type (AlignmentParametersFactory::ParametersType - but no circular dependency) ...
void print(void) const
print parameters to screen
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:131
int numSelected(void) const
Get number of selected parameters.
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:36
AlgebraicVector expandVector(const AlgebraicVector &m, const std::vector< bool > &sel) const
void setUserVariables(AlignmentUserVariables *auv)
Set pointer to user variables.
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
AlgebraicVector translation(void) const
Get translation parameters.
bool isValid(void) const
Get validity flag.
TkRotation transposed() const
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
RotationType toMatrix(const EulerAngles &)
Convert rotation angles about x-, y-, z-axes to matrix.
Definition: Utilities.cc:40
CLHEP::HepSymMatrix AlgebraicSymMatrix
static unsigned int const shift
tuple cout
Definition: gather_cfg.py:145
virtual RigidBodyAlignmentParameters * cloneFromSelected(const AlgebraicVector &parameters, const AlgebraicSymMatrix &covMatrix) const
Clone selected parameters (for update of parameters)
AlgebraicVector rotation(void) const
Get rotation parameters.
AlgebraicVector globalParameters(void) const
calculate and return parameters in global frame
T x() const
Definition: PV3DBase.h:62
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
RigidBodyAlignmentParameters(Alignable *alignable, bool calcMis)