CMS 3D CMS Logo

BowedSurfaceAlignmentParameters.cc
Go to the documentation of this file.
1 
10 
12 
19 
20 
21 // This class's header
23 
24 #include <iostream>
25 //_________________________________________________________________________________________________
27  AlignmentParameters(ali, AlgebraicVector(N_PARAM), AlgebraicSymMatrix(N_PARAM, 0))
28 {
29 }
30 
31 //_________________________________________________________________________________________________
35  const AlgebraicSymMatrix &covMatrix) :
36  AlignmentParameters(alignable, parameters, covMatrix)
37 {
38  if (parameters.num_row() != N_PARAM) {
39  throw cms::Exception("BadParameters") << "in BowedSurfaceAlignmentParameters(): "
40  << parameters.num_row() << " instead of " << N_PARAM
41  << " parameters.";
42  }
43 }
44 
45 //_________________________________________________________________________________________________
49  const AlgebraicSymMatrix &covMatrix,
50  const std::vector<bool> &selection) :
51  AlignmentParameters(alignable, parameters, covMatrix, selection)
52 {
53  if (parameters.num_row() != N_PARAM) {
54  throw cms::Exception("BadParameters") << "in BowedSurfaceAlignmentParameters(): "
55  << parameters.num_row() << " instead of " << N_PARAM
56  << " parameters.";
57  }
58 }
59 
60 //_________________________________________________________________________________________________
63  const AlgebraicSymMatrix &covMatrix) const
64 {
66  new BowedSurfaceAlignmentParameters(this->alignable(), parameters, covMatrix, selector());
67 
68  if (this->userVariables()) rbap->setUserVariables(this->userVariables()->clone());
69  rbap->setValid(this->isValid());
70 
71  return rbap;
72 }
73 
74 //_________________________________________________________________________________________________
77  const AlgebraicSymMatrix &covMatrix) const
78 {
79  return this->clone(this->expandVector(parameters, this->selector()),
80  this->expandSymMatrix(covMatrix, this->selector()));
81 
82 }
83 
84 //_________________________________________________________________________________________________
87  const AlignableDetOrUnitPtr &alidet) const
88 {
89  const Alignable *ali = this->alignable(); // Alignable of these parameters
90 
91  if (ali == alidet) {
92  const AlignableSurface &surf = ali->surface();
93  return BowedDerivs()(tsos, surf.width(), surf.length());
94  } else {
95  // We could give this a meaning by applying frame-to-frame derivatives
96  // to the first six parameters (be careful that alpha and beta changed
97  // their scale and switched their place compared to RigidBody!) and
98  // keep the remaining three untouched in local meaning.
99  // In this way we could do higher level alignment and determine 'average'
100  // surface structures for the components.
101  throw cms::Exception("MisMatch")
102  << "BowedSurfaceAlignmentParameters::derivatives: The hit alignable must match the "
103  << "aligned one (i.e. bowed surface parameters cannot be used for composed alignables)\n";
104  return AlgebraicMatrix(N_PARAM, 2); // please compiler
105  }
106 
107 }
108 
109 //_________________________________________________________________________________________________
111 {
112  // align::LocalVector uses double while LocalVector uses float only!
113  const AlgebraicVector &params = theData->parameters();
114  return align::LocalVector(params[dx], params[dy], params[dz]);
115 }
116 
117 
118 //_________________________________________________________________________________________________
120 {
121  const AlgebraicVector &params = theData->parameters();
122  const Alignable *alignable = this->alignable();
123  const AlignableSurface &surface = alignable->surface();
124 
125  align::EulerAngles eulerAngles(3);
126  // Note that dslopeX <-> -beta and dslopeY <-> alpha:
127  // Should we use atan of these values? Anyway it is small...
128  eulerAngles[0] = params[dslopeY] * 2. / surface.length();
129  eulerAngles[1] = -params[dslopeX] * 2. / surface.width();
130  const double aScale = BowedDerivs::gammaScale(surface.width(), surface.length());
131  eulerAngles[2] = params[drotZ] / aScale;
132 
133  return eulerAngles;
134 }
135 
136 //_________________________________________________________________________________________________
138 {
139  Alignable *alignable = this->alignable();
140  if (!alignable) {
141  throw cms::Exception("BadParameters")
142  << "BowedSurfaceAlignmentParameters::apply: parameters without alignable";
143  }
144 
145  // Get translation in local frame, transform to global and apply:
146  alignable->move(alignable->surface().toGlobal(this->translation()));
147 
148  // Rotation in local frame
149  const align::EulerAngles angles(this->rotation());
150  // original code:
151  // alignable->rotateInLocalFrame( align::toMatrix(angles) );
152  // correct for rounding errors:
153  align::RotationType rot(alignable->surface().toGlobal(align::toMatrix(angles)));
155  alignable->rotateInGlobalFrame(rot);
156 
157  const AlgebraicVector &params = theData->parameters();
158  const BowedSurfaceDeformation deform(params[dsagittaX], params[dsagittaXY], params[dsagittaY]);
159 
160  // FIXME: true to propagate down?
161  // Needed for hierarchy with common deformation parameter,
162  // but that is not possible now anyway.
163  alignable->addSurfaceDeformation(&deform, false);
164 }
165 
166 //_________________________________________________________________________________________________
168 {
170 }
171 
172 //_________________________________________________________________________________________________
174 {
175  std::cout << "Contents of BowedSurfaceAlignmentParameters:"
176  << "\nParameters: " << theData->parameters()
177  << "\nCovariance: " << theData->covariance() << std::endl;
178 }
align::Scalar width() const
virtual AlgebraicMatrix derivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &aliDet) const
Get all derivatives.
virtual BowedSurfaceAlignmentParameters * cloneFromSelected(const AlgebraicVector &parameters, const AlgebraicSymMatrix &covMatrix) const
Clone selected parameters (for update of parameters)
selection
main part
Definition: corrVsCorr.py:98
virtual void apply()
apply parameters to alignable
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.
BowedSurfaceAlignmentParameters(Alignable *alignable)
Constructor with empty parameters/covariance.
virtual int type() const
tell type (AlignmentParametersFactory::ParametersType - but no circular dependency) ...
align::LocalVector translation() const
Get translation parameters in double precision.
const AlgebraicVector & parameters(void) const
Get alignment parameters.
AlignmentUserVariables * userVariables(void) const
Get pointer to user variables.
void print() const
print parameters to screen
align::EulerAngles rotation() const
Get rotation parameters.
CLHEP::HepMatrix AlgebraicMatrix
void rectify(RotationType &)
Correct a rotation matrix for rounding errors.
Definition: Utilities.cc:198
void setValid(bool v)
Set validity flag.
virtual void addSurfaceDeformation(const SurfaceDeformation *deformation, bool propagateDown)=0
static double gammaScale(double width, double splitLength)
Alignable * alignable(void) const
Get pointer to corresponding alignable.
Vector3DBase< Scalar, LocalTag > LocalVector
Definition: Definitions.h:34
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
CLHEP::HepVector AlgebraicVector
AlgebraicVector EulerAngles
Definition: Definitions.h:36
align::Scalar length() const
AlgebraicVector expandVector(const AlgebraicVector &m, const std::vector< bool > &sel) const
virtual BowedSurfaceAlignmentParameters * clone(const AlgebraicVector &parameters, const AlgebraicSymMatrix &covMatrix) const
Clone all parameters (for update of parameters)
void setUserVariables(AlignmentUserVariables *auv)
Set pointer to user variables.
virtual void rotateInGlobalFrame(const RotationType &rotation)=0
BowedSurfaceAlignmentDerivatives BowedDerivs
Give parameters a name.
bool isValid(void) const
Get validity flag.
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:42
CLHEP::HepSymMatrix AlgebraicSymMatrix