CMS 3D CMS Logo

ParametersToParametersDerivatives.cc
Go to the documentation of this file.
1 
8 
16 
19 // already in header:
20 // #include "DataFormats/Math/interface/AlgebraicROOTObjects.h"
21 
22 //_________________________________________________________________________________________________
24  const Alignable &mother)
25  : isOK_(component.alignmentParameters() && mother.alignmentParameters()) {
26  if (isOK_) {
27  isOK_ =
28  this->init(component, component.alignmentParameters()->type(), mother, mother.alignmentParameters()->type());
29  }
30 }
31 
32 //_________________________________________________________________________________________________
34  int typeComponent,
35  const Alignable &mother,
36  int typeMother) {
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 }
54 
55 //_________________________________________________________________________________________________
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 }
76 
77 //_________________________________________________________________________________________________
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 }
98 
99 //_________________________________________________________________________________________________
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 }
152 
153 //_________________________________________________________________________________________________
155  const AlgebraicMatrix66 &dRigidM2dRigidC, double halfWidth, double halfLength) {
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 }
202 
203 //_________________________________________________________________________________________________
204 double ParametersToParametersDerivatives::operator()(unsigned int indParMother, unsigned int indParComp) const {
205  // Do range checks?
206  return derivatives_(indParMother, indParComp);
207 }
align::GlobalPoints toGlobal(const align::LocalPoints &) const
Return in global coord given a set of local points.
bool initRigidRigid(const Alignable &component, const Alignable &mother)
init for component and mother both with RigidBody parameters
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:58
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:132
double operator()(unsigned int indParMother, unsigned int indParComp) const
ParametersToParametersDerivatives(const Alignable &component, const Alignable &mother)
align::Scalar width() const
std::string parametersTypeName(ParametersType parType)
Log< level::Error, false > LogError
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:135
bool initBowedRigid(const Alignable &component, const Alignable &mother)
init for component with BowedSurface and mother with RigidBody parameters
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepStd< double, 6, 6 > > AlgebraicMatrix66
virtual int type() const =0
tell type (AlignmentParametersFactory::ParametersType - but no circular dependency) ...
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)
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:138
ParametersType parametersType(const std::string &typeString)
convert string to ParametersType - exception if not known
TMatrixD derivatives_
can we provide the desired?
bool init2BowedRigid(const Alignable &component, const Alignable &mother)
AlgebraicMatrix frameToFrameDerivative(const Alignable *object, const Alignable *composedObject) const
bool init(const Alignable &component, int typeComponent, const Alignable &mother, int typeMother)