CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 init by choosing the correct detailed init method depending on parameter types More...
 
bool init2BowedRigid (const Alignable &component, const Alignable &mother)
 init for component with TwoBowedSurfaces and mother with RigidBody parameters More...
 
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 24 of file ParametersToParametersDerivatives.cc.

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

25  : isOK_(component.alignmentParameters() && mother.alignmentParameters())
26 {
27  if (isOK_) {
28  isOK_ = this->init(component, component.alignmentParameters()->type(),
29  mother, mother .alignmentParameters()->type());
30  }
31 }
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
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)
init by choosing the correct detailed init method depending on parameter types

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 163 of file ParametersToParametersDerivatives.cc.

References isOK_.

Referenced by init2BowedRigid(), and initBowedRigid().

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

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

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) &&
42  typeComponent == kBowedSurface) {
43  return this->initBowedRigid(component, mother);
44  } else if ((typeMother == kRigidBody || typeMother == kRigidBody4D) &&
45  typeComponent == kTwoBowedSurfaces) {
46  return this->init2BowedRigid(component, mother);
47  } else {
48  // missing: mother with bows and component without, i.e. having 'common' bow parameters
49  edm::LogError("Alignment") << "@SUB=ParametersToParametersDerivatives::init"
50  << "Mother " << parametersTypeName(parametersType(typeMother))
51  << ", component " << parametersTypeName(parametersType(typeComponent))
52  << ": not supported.";
53  return false;
54  }
55 
56 }
bool initRigidRigid(const Alignable &component, const Alignable &mother)
init for component and mother both with RigidBody parameters
std::string parametersTypeName(ParametersType parType)
convert ParametersType to string understood by parametersType(string &amp;typeString) ...
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)
init for component with TwoBowedSurfaces and mother with RigidBody parameters
bool ParametersToParametersDerivatives::init2BowedRigid ( const Alignable component,
const Alignable mother 
)
private

init for component with TwoBowedSurfaces and mother with RigidBody parameters

Definition at line 105 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().

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

References derivatives_, dRigid_dBowed(), FrameToFrameDerivative::frameToFrameDerivative(), AlignableSurface::length(), visualization-live-secondInstance_cfg::m, Alignable::surface(), and AlignableSurface::width().

Referenced by init().

84 {
85  // component is bowed surface, mother rigid body
87  // frame2frame returns dcomponent/dmother for both being rigid body, so we have to invert
88  AlgebraicMatrix66 rigM2rigC(asSMatrix<6,6>(f2f.frameToFrameDerivative(&component,&mother)));
89  if (rigM2rigC.Invert()) { // now matrix is d(rigid_mother)/d(rigid_component)
90  const double halfWidth = 0.5 * component.surface().width();
91  const double halfLength = 0.5 * component.surface().length();
92  const AlgebraicMatrix69 m(this->dRigid_dBowed(rigM2rigC, halfWidth, halfLength));
93 
94  // copy to TMatrix
95  derivatives_.ResizeTo(6,9);
96  derivatives_.SetMatrixArray(m.begin());
97 
98  return true;
99  } else {
100  return false;
101  }
102 }
align::Scalar width() const
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepStd< double, 6, 6 > > AlgebraicMatrix66
ROOT::Math::SMatrix< double, 6, 9, ROOT::Math::MatRepStd< double, 6, 9 > > AlgebraicMatrix69
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:131
align::Scalar length() const
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 59 of file ParametersToParametersDerivatives.cc.

References derivatives_, FrameToFrameDerivative::frameToFrameDerivative(), and visualization-live-secondInstance_cfg::m.

Referenced by init().

61 {
62  // See G. Flucke's presentation from 20 Feb 2007
63  // https://indico.cern.ch/contributionDisplay.py?contribId=15&sessionId=1&confId=10930
64  // and C. Kleinwort's one from 14 Feb 2013
65  // https://indico.cern.ch/contributionDisplay.py?contribId=14&sessionId=1&confId=224472
66 
68  // frame2frame returns dcomponent/dmother for both being rigid body, so we have to invert
69  AlgebraicMatrix66 m(asSMatrix<6,6>(f2f.frameToFrameDerivative(&component, &mother)));
70 
71  if (m.Invert()) { // now matrix is d(rigid_mother)/d(rigid_component)
72  // copy to TMatrix
73  derivatives_.ResizeTo(6,6);
74  derivatives_.SetMatrixArray(m.begin());
75  return true;
76  } else {
77  return false;
78  }
79 }
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 49 of file ParametersToParametersDerivatives.h.

References isOK_.

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 211 of file ParametersToParametersDerivatives.cc.

References derivatives_.

213 {
214  // Do range checks?
215  return derivatives_(indParMother, indParComp);
216 }
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(), and isOK().