CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
ParametersToParametersDerivatives Class Reference

#include <ParametersToParametersDerivatives.h>

Public Member Functions

bool isOK () const
 Indicate whether able to provide the derivatives. More...
 
double operator() (unsigned int indParMother, unsigned int indParComp) const
 
 ParametersToParametersDerivatives (const Alignable &component, const Alignable &mother)
 

Private Types

typedef ROOT::Math::SMatrix< double, 6, 9, ROOT::Math::MatRepStd< double, 6, 9 > > AlgebraicMatrix69
 

Private Member Functions

AlgebraicMatrix69 dRigid_dBowed (const AlgebraicMatrix66 &dRigidM2dRigidC, double halfWidth, double halfLength)
 
bool init (const Alignable &component, int typeComponent, const Alignable &mother, int typeMother)
 
bool init2BowedRigid (const Alignable &component, const Alignable &mother)
 
bool initBowedRigid (const Alignable &component, const Alignable &mother)
 init for component with BowedSurface and mother with RigidBody parameters More...
 
bool initRigidRigid (const Alignable &component, const Alignable &mother)
 init for component and mother both with RigidBody parameters More...
 

Private Attributes

TMatrixD derivatives_
 can we provide the desired? More...
 
bool isOK_
 data members More...
 

Detailed Description

Class for getting the jacobian d_mother/d_component for various kinds of alignment parametrisations, i.e. the derivatives expressing the influence of the parameters of the 'component' on the parameters of its 'mother'. This is needed e.g. to formulate constraints to remove the additional degrees of freedom introduced if larger structures and their components are aligned simultaneously. The jacobian matrix is

/ dp1_l/dp1_i dp1_l/dp2_i ... dp1_l/dpn_i | | dp2_l/dp1_i dp2_l/dp2_i ... dp2_l/dpn_i | | . . . | | . . . | | . . . | \ dpm_l/dpm_i dpm_l/dpm_i ... dpm_l/dpn_i /

where p1_l, p2_l, ..., pn_l are the n parameters of the composite 'mother' object and p1_i, p2_i, ..., pm_i are the m parameters of its component.

Note that not all combinations of parameters are supported: Please check method isOK() before accessing the derivatives via operator(unsigned int indParMother, unsigned int indParComp).

Currently these parameters are supported:

Definition at line 43 of file ParametersToParametersDerivatives.h.

Member Typedef Documentation

typedef ROOT::Math::SMatrix<double, 6, 9, ROOT::Math::MatRepStd<double, 6, 9> > ParametersToParametersDerivatives::AlgebraicMatrix69
private

Definition at line 70 of file ParametersToParametersDerivatives.h.

Constructor & Destructor Documentation

ParametersToParametersDerivatives::ParametersToParametersDerivatives ( const Alignable component,
const Alignable mother 
)

Definition at line 23 of file ParametersToParametersDerivatives.cc.

References Alignable::alignmentParameters(), init(), isOK_, and AlignmentParameters::type().

25  : isOK_(component.alignmentParameters() && mother.alignmentParameters()) {
26  if (isOK_) {
27  isOK_ =
28  this->init(component, component.alignmentParameters()->type(), mother, mother.alignmentParameters()->type());
29  }
30 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:61
virtual int type() const =0
tell type (AlignmentParametersFactory::ParametersType - but no circular dependency) ...
bool init(const Alignable &component, int typeComponent, const Alignable &mother, int typeMother)

Member Function Documentation

ParametersToParametersDerivatives::AlgebraicMatrix69 ParametersToParametersDerivatives::dRigid_dBowed ( const AlgebraicMatrix66 dRigidM2dRigidC,
double  halfWidth,
double  halfLength 
)
private

from d(rigid_mother)/d(rigid_component) to d(rigid_mother)/d(bowed_component) for bad input (length or width zero), set object to invalid: isOK_ = false

Definition at line 154 of file ParametersToParametersDerivatives.cc.

References isOK_.

Referenced by init2BowedRigid(), and initBowedRigid().

155  {
156  typedef BowedSurfaceAlignmentDerivatives BowedDerivs;
157  const double gammaScale = BowedDerivs::gammaScale(2. * halfWidth, 2. * halfLength);
158 
159  // 'dRigidM2dRigidC' is dmother/dcomponent for both being rigid body
160  // final matrix will be dmother/dcomponent for mother as rigid body, component
161  // with bows 1st index (row) is parameter of the mother (0..5), 2nd index
162  // (column) that of component (0..8):
163  AlgebraicMatrix69 derivs;
164  if (0. == gammaScale || 0. == halfWidth || 0. == halfLength) {
165  isOK_ = false; // bad input - we would have to devide by that in the following!
166  edm::LogError("Alignment") << "@SUB=ParametersToParametersDerivatives::dRigid_dBowed"
167  << "Some zero length as input.";
168  return derivs;
169  }
170 
171  for (unsigned int iRow = 0; iRow < AlgebraicMatrix69::kRows; ++iRow) {
172  // loop on 6 rigid body parameters of mother
173  // First copy the common rigid body part, e.g.:
174  // (0,0): du_moth/du_comp, (0,1): dv_moth/du_comp, (1,2): dw_moth/dv_comp
175  for (unsigned int iCol = 0; iCol < 3; ++iCol) { // 3 movements of component
176  derivs(iRow, iCol) = dRigidM2dRigidC(iRow, iCol);
177  }
178 
179  // Now we have to take care of order, signs and scales for rotation-like
180  // parameters, see CMS AN-2011/531: slopeX = w10 = -halfWidth * beta
181  // => dpar_m/dslopeX_comp = dpar_m/d(-hw * beta_comp) =
182  // -(dpar_m/dbeta_comp)/hw
183  derivs(iRow, 3) = -dRigidM2dRigidC(iRow, 4) / halfWidth;
184  // slopeY = w10 = +halfLength * alpha
185  // => dpar_m/dslopeY_comp = dpar_m/d(+hl * alpha_comp) =
186  // (dpar_m/dalpha_comp)/hl
187  derivs(iRow, 4) = dRigidM2dRigidC(iRow, 3) / halfLength;
188  // rotZ = gammaScale * gamma
189  // => dpar_m/drotZ_comp = dpar_m/d(gamma_comp * gscale) =
190  // (dpar_m/dgamma)/gscale
191  derivs(iRow, 5) = dRigidM2dRigidC(iRow, 5) / gammaScale;
192 
193  // Finally, sensor internals like their curvatures have no influence on
194  // mother:
195  for (unsigned int iCol = 6; iCol < AlgebraicMatrix69::kCols; ++iCol) {
196  derivs(iRow, iCol) = 0.; // 3 sagittae of component
197  }
198  }
199 
200  return derivs;
201 }
ROOT::Math::SMatrix< double, 6, 9, ROOT::Math::MatRepStd< double, 6, 9 > > AlgebraicMatrix69
bool ParametersToParametersDerivatives::init ( const Alignable component,
int  typeComponent,
const Alignable mother,
int  typeMother 
)
private

init by choosing the correct detailed init method depending on parameter types

Definition at line 33 of file ParametersToParametersDerivatives.cc.

References init2BowedRigid(), initBowedRigid(), initRigidRigid(), AlignmentParametersFactory::kBowedSurface, AlignmentParametersFactory::kRigidBody, AlignmentParametersFactory::kRigidBody4D, AlignmentParametersFactory::kTwoBowedSurfaces, AlignmentParametersFactory::parametersType(), and AlignmentParametersFactory::parametersTypeName().

Referenced by isOK(), and ParametersToParametersDerivatives().

36  {
37  using namespace AlignmentParametersFactory; // for kRigidBody etc.
38  if ((typeMother == kRigidBody || typeMother == kRigidBody4D) &&
39  (typeComponent == kRigidBody || typeComponent == kRigidBody4D)) {
40  return this->initRigidRigid(component, mother);
41  } else if ((typeMother == kRigidBody || typeMother == kRigidBody4D) && typeComponent == kBowedSurface) {
42  return this->initBowedRigid(component, mother);
43  } else if ((typeMother == kRigidBody || typeMother == kRigidBody4D) && typeComponent == kTwoBowedSurfaces) {
44  return this->init2BowedRigid(component, mother);
45  } else {
46  // missing: mother with bows and component without, i.e. having 'common' bow
47  // parameters
48  edm::LogError("Alignment") << "@SUB=ParametersToParametersDerivatives::init"
49  << "Mother " << parametersTypeName(parametersType(typeMother)) << ", component "
50  << parametersTypeName(parametersType(typeComponent)) << ": not supported.";
51  return false;
52  }
53 }
bool initRigidRigid(const Alignable &component, const Alignable &mother)
init for component and mother both with RigidBody parameters
std::string parametersTypeName(ParametersType parType)
bool initBowedRigid(const Alignable &component, const Alignable &mother)
init for component with BowedSurface and mother with RigidBody parameters
ParametersType parametersType(const std::string &typeString)
convert string to ParametersType - exception if not known
bool init2BowedRigid(const Alignable &component, const Alignable &mother)
bool ParametersToParametersDerivatives::init2BowedRigid ( const Alignable component,
const Alignable mother 
)
private

init for component with TwoBowedSurfaces and mother with RigidBody parameters

Definition at line 100 of file ParametersToParametersDerivatives.cc.

References Alignable::alignmentParameters(), derivatives_, dRigid_dBowed(), Alignable::globalPosition(), Alignable::globalRotation(), AlignableSurface::length(), Alignable::surface(), AlignableSurface::toGlobal(), AlignableSurface::width(), and TwoBowedSurfacesAlignmentParameters::ySplit().

Referenced by init(), and isOK().

100  {
101  // component is two bowed surfaces, mother rigid body
103  dynamic_cast<TwoBowedSurfacesAlignmentParameters *>(component.alignmentParameters());
104 
105  if (!aliPar) {
106  edm::LogError("Alignment") << "@SUB=ParametersToParametersDerivatives::init2BowedRigid"
107  << "dynamic_cast to TwoBowedSurfacesAlignmentParameters failed.";
108  return false;
109  }
110 
111  // We treat the two surfaces as independent objects, i.e.
112  // 1) get the global position of each surface, depending on the ySplit value,
113  const double ySplit = aliPar->ySplit();
114  const double halfWidth = 0.5 * component.surface().width();
115  const double halfLength = 0.5 * component.surface().length();
116  const double halfLength1 = 0.5 * (halfLength + ySplit);
117  const double halfLength2 = 0.5 * (halfLength - ySplit);
118  const double yM1 = 0.5 * (ySplit - halfLength); // y_mean of surface 1
119  const double yM2 = yM1 + halfLength; // y_mean of surface 2
120  // The sensor positions and orientations could be adjusted using
121  // TwoBowedSurfacesDeformation attached to the component,
122  // but that should be 2nd order effect.
123  const align::GlobalPoint posSurf1(component.surface().toGlobal(align::LocalPoint(0., yM1, 0.)));
124  const align::GlobalPoint posSurf2(component.surface().toGlobal(align::LocalPoint(0., yM2, 0.)));
125 
126  // 2) get derivatives for both,
127  // getDerivative(..) returns dcomponent/dmother for both being rigid body
128  FrameToFrameDerivative f2fMaker;
129  AlgebraicMatrix66 f2fSurf1(
130  f2fMaker.getDerivative(component.globalRotation(), mother.globalRotation(), posSurf1, mother.globalPosition()));
131  AlgebraicMatrix66 f2fSurf2(
132  f2fMaker.getDerivative(component.globalRotation(), mother.globalRotation(), posSurf2, mother.globalPosition()));
133  // We have to invert matrices to get d(rigid_mother)/d(rigid_component):
134  if (!f2fSurf1.Invert() || !f2fSurf2.Invert())
135  return false; // bail out if bad inversion
136  // Now get d(rigid_mother)/d(bowed_component):
137  const AlgebraicMatrix69 derivs1(this->dRigid_dBowed(f2fSurf1, halfWidth, halfLength1));
138  const AlgebraicMatrix69 derivs2(this->dRigid_dBowed(f2fSurf2, halfWidth, halfLength2));
139 
140  // 3) fill the common matrix by merging the two.
141  typedef ROOT::Math::SMatrix<double, 6, 18, ROOT::Math::MatRepStd<double, 6, 18>> AlgebraicMatrix6_18;
142  AlgebraicMatrix6_18 derivs;
143  derivs.Place_at(derivs1, 0, 0); // left half
144  derivs.Place_at(derivs2, 0, 9); // right half
145 
146  // copy to TMatrix
147  derivatives_.ResizeTo(6, 18);
148  derivatives_.SetMatrixArray(derivs.begin());
149 
150  return true;
151 }
align::Scalar width() const
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepStd< double, 6, 6 > > AlgebraicMatrix66
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:141
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:61
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
align::Scalar length() const
ROOT::Math::SMatrix< double, 6, 9, ROOT::Math::MatRepStd< double, 6, 9 > > AlgebraicMatrix69
AlgebraicMatrix69 dRigid_dBowed(const AlgebraicMatrix66 &dRigidM2dRigidC, double halfWidth, double halfLength)
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:138
TMatrixD derivatives_
can we provide the desired?
bool ParametersToParametersDerivatives::initBowedRigid ( const Alignable component,
const Alignable mother 
)
private

init for component with BowedSurface and mother with RigidBody parameters

Definition at line 78 of file ParametersToParametersDerivatives.cc.

References derivatives_, dRigid_dBowed(), FrameToFrameDerivative::frameToFrameDerivative(), AlignableSurface::length(), funct::m, Alignable::surface(), and AlignableSurface::width().

Referenced by init(), and isOK().

78  {
79  // component is bowed surface, mother rigid body
81  // frame2frame returns dcomponent/dmother for both being rigid body, so we
82  // have to invert
83  AlgebraicMatrix66 rigM2rigC(asSMatrix<6, 6>(f2f.frameToFrameDerivative(&component, &mother)));
84  if (rigM2rigC.Invert()) { // now matrix is d(rigid_mother)/d(rigid_component)
85  const double halfWidth = 0.5 * component.surface().width();
86  const double halfLength = 0.5 * component.surface().length();
87  const AlgebraicMatrix69 m(this->dRigid_dBowed(rigM2rigC, halfWidth, halfLength));
88 
89  // copy to TMatrix
90  derivatives_.ResizeTo(6, 9);
91  derivatives_.SetMatrixArray(m.begin());
92 
93  return true;
94  } else {
95  return false;
96  }
97 }
align::Scalar width() const
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepStd< double, 6, 6 > > AlgebraicMatrix66
AlgebraicMatrix frameToFrameDerivative(const Alignable *object, const Alignable *composedObject) const
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:135
align::Scalar length() const
ROOT::Math::SMatrix< double, 6, 9, ROOT::Math::MatRepStd< double, 6, 9 > > AlgebraicMatrix69
AlgebraicMatrix69 dRigid_dBowed(const AlgebraicMatrix66 &dRigidM2dRigidC, double halfWidth, double halfLength)
TMatrixD derivatives_
can we provide the desired?
bool ParametersToParametersDerivatives::initRigidRigid ( const Alignable component,
const Alignable mother 
)
private

init for component and mother both with RigidBody parameters

Definition at line 56 of file ParametersToParametersDerivatives.cc.

References derivatives_, FrameToFrameDerivative::frameToFrameDerivative(), and funct::m.

Referenced by init(), and isOK().

56  {
57  // See G. Flucke's presentation from 20 Feb 2007
58  // https://indico.cern.ch/contributionDisplay.py?contribId=15&sessionId=1&confId=10930
59  // and C. Kleinwort's one from 14 Feb 2013
60  // https://indico.cern.ch/contributionDisplay.py?contribId=14&sessionId=1&confId=224472
61 
63  // frame2frame returns dcomponent/dmother for both being rigid body, so we
64  // have to invert
65  AlgebraicMatrix66 m(asSMatrix<6, 6>(f2f.frameToFrameDerivative(&component, &mother)));
66 
67  if (m.Invert()) { // now matrix is d(rigid_mother)/d(rigid_component)
68  // copy to TMatrix
69  derivatives_.ResizeTo(6, 6);
70  derivatives_.SetMatrixArray(m.begin());
71  return true;
72  } else {
73  return false;
74  }
75 }
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepStd< double, 6, 6 > > AlgebraicMatrix66
AlgebraicMatrix frameToFrameDerivative(const Alignable *object, const Alignable *composedObject) const
TMatrixD derivatives_
can we provide the desired?
bool ParametersToParametersDerivatives::isOK ( ) const
inline

Indicate whether able to provide the derivatives.

Definition at line 48 of file ParametersToParametersDerivatives.h.

References init(), init2BowedRigid(), initBowedRigid(), initRigidRigid(), isOK_, and operator()().

Referenced by AlignmentParameterStore::hierarchyConstraints().

double ParametersToParametersDerivatives::operator() ( unsigned int  indParMother,
unsigned int  indParComp 
) const

Return the derivative DeltaParam(mother)/DeltaParam(component). Indices start with 0 - but check isOK() first! See class description about matrix.

Definition at line 204 of file ParametersToParametersDerivatives.cc.

References derivatives_.

Referenced by isOK().

204  {
205  // Do range checks?
206  return derivatives_(indParMother, indParComp);
207 }
TMatrixD derivatives_
can we provide the desired?

Member Data Documentation

TMatrixD ParametersToParametersDerivatives::derivatives_
private

can we provide the desired?

Definition at line 78 of file ParametersToParametersDerivatives.h.

Referenced by init2BowedRigid(), initBowedRigid(), initRigidRigid(), and operator()().

bool ParametersToParametersDerivatives::isOK_
private

data members

Definition at line 77 of file ParametersToParametersDerivatives.h.

Referenced by dRigid_dBowed(), isOK(), and ParametersToParametersDerivatives().