CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  // simply frame to frame!
63  FrameToFrameDerivative f2fDerivMaker;
64  AlgebraicMatrix66 m(asSMatrix<6,6>(f2fDerivMaker.frameToFrameDerivative(&component, &mother)));
65 
66  // copy to TMatrix
67  derivatives_.ResizeTo(6,6);
68  derivatives_.SetMatrixArray(m.begin());
69 
70  return true;
71 }
72 
73 //_________________________________________________________________________________________________
75  const Alignable &mother)
76 {
77  // component is bowed surface, mother rigid body
78  FrameToFrameDerivative f2fMaker;
79  const AlgebraicMatrix66 f2f(asSMatrix<6,6>(f2fMaker.frameToFrameDerivative(&component,&mother)));
80  const double halfWidth = 0.5 * component.surface().width();
81  const double halfLength = 0.5 * component.surface().length();
82  const AlgebraicMatrix69 m(this->dBowed_dRigid(f2f, halfWidth, halfLength));
83 
84  // copy to TMatrix
85  derivatives_.ResizeTo(6,9);
86  derivatives_.SetMatrixArray(m.begin());
87 
88  return true;
89 }
90 
91 //_________________________________________________________________________________________________
93  const Alignable &mother)
94 {
95  // component is two bowed surfaces, mother rigid body
97  dynamic_cast<TwoBowedSurfacesAlignmentParameters*>(component.alignmentParameters());
98 
99  if (!aliPar) {
100  edm::LogError("Alignment") << "@SUB=ParametersToParametersDerivatives::init2BowedRigid"
101  << "dynamic_cast to TwoBowedSurfacesAlignmentParameters failed.";
102  return false;
103  }
104 
105  // We treat the two surfaces as independent objects, i.e.
106  // 1) get the global position of each surface, depending on the ySplit value,
107  const double ySplit = aliPar->ySplit();
108  const double halfWidth = 0.5 * component.surface().width();
109  const double halfLength = 0.5 * component.surface().length();
110  const double halfLength1 = 0.5 * (halfLength + ySplit);
111  const double halfLength2 = 0.5 * (halfLength - ySplit);
112  const double yM1 = 0.5 * (ySplit - halfLength); // y_mean of surface 1
113  const double yM2 = yM1 + halfLength; // y_mean of surface 2
114  // The sensor positions and orientations could be adjusted using
115  // TwoBowedSurfacesDeformation attached to the component,
116  // but that should be 2nd order effect.
117  const align::GlobalPoint posSurf1(component.surface().toGlobal(align::LocalPoint(0.,yM1,0.)));
118  const align::GlobalPoint posSurf2(component.surface().toGlobal(align::LocalPoint(0.,yM2,0.)));
119 
120  // 2) get derivatives for both,
121  FrameToFrameDerivative f2fMaker;
122  const AlgebraicMatrix66 f2fSurf1(f2fMaker.getDerivative(component.globalRotation(),
123  mother.globalRotation(),
124  posSurf1, mother.globalPosition()));
125  const AlgebraicMatrix66 f2fSurf2(f2fMaker.getDerivative(component.globalRotation(),
126  mother.globalRotation(),
127  posSurf2, mother.globalPosition()));
128  const AlgebraicMatrix69 derivs1(this->dBowed_dRigid(f2fSurf1, halfWidth, halfLength1));
129  const AlgebraicMatrix69 derivs2(this->dBowed_dRigid(f2fSurf2, halfWidth, halfLength2));
130 
131  // 3) fill the common matrix by merging the two.
132  typedef ROOT::Math::SMatrix<double,6,18,ROOT::Math::MatRepStd<double,6,18> > AlgebraicMatrix6_18;
133  AlgebraicMatrix6_18 derivs;
134  derivs.Place_at(derivs1, 0, 0); // left half
135  derivs.Place_at(derivs2, 0, 9); // right half
136 
137  // copy to TMatrix
138  derivatives_.ResizeTo(6, 18);
139  derivatives_.SetMatrixArray(derivs.begin());
140 
141  return true;
142 }
143 
144 //_________________________________________________________________________________________________
147  double halfWidth, double halfLength) const
148 {
149  typedef BowedSurfaceAlignmentDerivatives BowedDerivs;
150  const double gammaScale = BowedDerivs::gammaScale(2.*halfWidth, 2.*halfLength);
151 
152  // 1st index (column) is parameter of the mother (<6),
153  // 2nd index (row) that of component (<9):
154  AlgebraicMatrix69 derivs;
155 
156  for (unsigned int iRow = 0; iRow < 6; ++iRow) { // 6 rigid body parameters of mother
157  // First copy the common rigid body part, e.g.:
158  // - (0,0): du_comp/du_moth
159  // - (0,1): dv_comp/du_moth
160  // - (1,2): dw_comp/dv_moth
161  for (unsigned int iCol = 0; iCol < 3; ++iCol) { // 3 movements of component
162  derivs(iRow, iCol) = f2f(iRow, iCol);
163  }
164 
165  // Now we have to take care of order and scales for rotation-like parameters:
166  // slopeX -> halfWidth * beta
167  derivs(iRow, 3) = halfWidth * f2f(iRow, 4); // = dslopeX_c/dpar_m = hw * db_c/dpar_m
168  // slopeY -> halfLength * alpha
169  derivs(iRow, 4) = halfLength * f2f(iRow, 3); // = dslopeY_c/dpar_m = hl * da_c/dpar_m
170  // rotZ -> gammaScale * gamma
171  derivs(iRow, 5) = gammaScale * f2f(iRow, 5); // = drotZ_c/dpar_m = gscale * dg_c/dpar_m
172 
173  // Finally, movements and rotations have no influence on surface internals:
174  for (unsigned int iCol = 6; iCol < 9; ++iCol) { // 3 sagittae of component
175  derivs(iRow, iCol) = 0.;
176  }
177  }
178 
179  return derivs;
180 }
181 
182 //_________________________________________________________________________________________________
183 double ParametersToParametersDerivatives::operator() (unsigned int indParMother,
184  unsigned int indParComp) const
185 {
186  // Do range checks?
187  return derivatives_(indParMother, indParComp);
188 }
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:63
ParametersToParametersDerivatives(const Alignable &component, const Alignable &mother)
const RotationType & globalRotation() const
Return the global orientation of the object.
Definition: Alignable.h:132
std::string parametersTypeName(ParametersType parType)
convert ParametersType to string understood by parametersType(string &amp;typeString) ...
AlignmentParameters * alignmentParameters() const
Get the AlignmentParameters.
Definition: Alignable.h:57
AlgebraicMatrix69 dBowed_dRigid(const AlgebraicMatrix66 &f2f, double halfWidth, double halfLength) const
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
Return the derivative DeltaFrame(object)/DeltaFrame(composedobject)
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
virtual int type() const =0
tell type (AlignmentParametersFactory::ParametersType - but no circular dependency) ...
align::Scalar length() const
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:129
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