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 //_________________________________________________________________________________________________
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 }
32 
33 //_________________________________________________________________________________________________
34 bool ParametersToParametersDerivatives::init(const Alignable &component, int typeComponent,
35  const Alignable &mother, int typeMother)
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 }
57 
58 //_________________________________________________________________________________________________
60  const Alignable &mother)
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 }
80 
81 //_________________________________________________________________________________________________
83  const Alignable &mother)
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 }
103 
104 //_________________________________________________________________________________________________
106  const Alignable &mother)
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 }
160 
161 //_________________________________________________________________________________________________
164  double halfWidth, double halfLength)
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 }
209 
210 //_________________________________________________________________________________________________
211 double ParametersToParametersDerivatives::operator() (unsigned int indParMother,
212  unsigned int indParComp) const
213 {
214  // Do range checks?
215  return derivatives_(indParMother, indParComp);
216 }
align::Scalar width() const
bool initRigidRigid(const Alignable &component, const Alignable &mother)
init for component and mother both with RigidBody parameters
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepStd< double, 6, 6 > > AlgebraicMatrix66
int init
Definition: HydjetWrapper.h:67
ParametersToParametersDerivatives(const Alignable &component, const Alignable &mother)
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:141
std::string parametersTypeName(ParametersType parType)
convert ParametersType to string understood by parametersType(string &typeString) ...
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:61
virtual int type() const =0
tell type (AlignmentParametersFactory::ParametersType - but no circular dependency) ...
double operator()(unsigned int indParMother, unsigned int indParComp) const
bool initBowedRigid(const Alignable &component, const Alignable &mother)
init for component with BowedSurface and mother with RigidBody parameters
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:135
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.
ParametersType parametersType(const std::string &typeString)
convert string to ParametersType - exception if not known
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:138
TMatrixD derivatives_
can we provide the desired?
bool init2BowedRigid(const Alignable &component, const Alignable &mother)
init for component with TwoBowedSurfaces and mother with RigidBody parameters
bool init(const Alignable &component, int typeComponent, const Alignable &mother, int typeMother)
init by choosing the correct detailed init method depending on parameter types