File indexing completed on 2024-04-06 11:56:13
0001
0002
0003
0004
0005
0006
0007 #include "Alignment/CommonAlignmentParametrization/interface/ParametersToParametersDerivatives.h"
0008
0009 #include "Alignment/CommonAlignment/interface/Alignable.h"
0010 #include "Alignment/CommonAlignment/interface/AlignmentParameters.h"
0011 #include "Alignment/CommonAlignmentParametrization/interface/AlignmentParametersFactory.h"
0012 #include "Alignment/CommonAlignmentParametrization/interface/BowedSurfaceAlignmentDerivatives.h"
0013 #include "Alignment/CommonAlignmentParametrization/interface/FrameToFrameDerivative.h"
0014 #include "Alignment/CommonAlignmentParametrization/interface/TwoBowedSurfacesAlignmentParameters.h"
0015 #include "CondFormats/Alignment/interface/Definitions.h"
0016
0017 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019
0020
0021
0022
0023 ParametersToParametersDerivatives ::ParametersToParametersDerivatives(const Alignable &component,
0024 const Alignable &mother)
0025 : isOK_(component.alignmentParameters() && mother.alignmentParameters()) {
0026 if (isOK_) {
0027 isOK_ =
0028 this->init(component, component.alignmentParameters()->type(), mother, mother.alignmentParameters()->type());
0029 }
0030 }
0031
0032
0033 bool ParametersToParametersDerivatives::init(const Alignable &component,
0034 int typeComponent,
0035 const Alignable &mother,
0036 int typeMother) {
0037 using namespace AlignmentParametersFactory;
0038 if ((typeMother == kRigidBody || typeMother == kRigidBody4D) &&
0039 (typeComponent == kRigidBody || typeComponent == kRigidBody4D)) {
0040 return this->initRigidRigid(component, mother);
0041 } else if ((typeMother == kRigidBody || typeMother == kRigidBody4D) && typeComponent == kBowedSurface) {
0042 return this->initBowedRigid(component, mother);
0043 } else if ((typeMother == kRigidBody || typeMother == kRigidBody4D) && typeComponent == kTwoBowedSurfaces) {
0044 return this->init2BowedRigid(component, mother);
0045 } else {
0046
0047
0048 edm::LogError("Alignment") << "@SUB=ParametersToParametersDerivatives::init"
0049 << "Mother " << parametersTypeName(parametersType(typeMother)) << ", component "
0050 << parametersTypeName(parametersType(typeComponent)) << ": not supported.";
0051 return false;
0052 }
0053 }
0054
0055
0056 bool ParametersToParametersDerivatives::initRigidRigid(const Alignable &component, const Alignable &mother) {
0057
0058
0059
0060
0061
0062 FrameToFrameDerivative f2f;
0063
0064
0065 AlgebraicMatrix66 m(asSMatrix<6, 6>(f2f.frameToFrameDerivative(&component, &mother)));
0066
0067 if (m.Invert()) {
0068
0069 derivatives_.ResizeTo(6, 6);
0070 derivatives_.SetMatrixArray(m.begin());
0071 return true;
0072 } else {
0073 return false;
0074 }
0075 }
0076
0077
0078 bool ParametersToParametersDerivatives::initBowedRigid(const Alignable &component, const Alignable &mother) {
0079
0080 FrameToFrameDerivative f2f;
0081
0082
0083 AlgebraicMatrix66 rigM2rigC(asSMatrix<6, 6>(f2f.frameToFrameDerivative(&component, &mother)));
0084 if (rigM2rigC.Invert()) {
0085 const double halfWidth = 0.5 * component.surface().width();
0086 const double halfLength = 0.5 * component.surface().length();
0087 const AlgebraicMatrix69 m(this->dRigid_dBowed(rigM2rigC, halfWidth, halfLength));
0088
0089
0090 derivatives_.ResizeTo(6, 9);
0091 derivatives_.SetMatrixArray(m.begin());
0092
0093 return true;
0094 } else {
0095 return false;
0096 }
0097 }
0098
0099
0100 bool ParametersToParametersDerivatives::init2BowedRigid(const Alignable &component, const Alignable &mother) {
0101
0102 const TwoBowedSurfacesAlignmentParameters *aliPar =
0103 dynamic_cast<TwoBowedSurfacesAlignmentParameters *>(component.alignmentParameters());
0104
0105 if (!aliPar) {
0106 edm::LogError("Alignment") << "@SUB=ParametersToParametersDerivatives::init2BowedRigid"
0107 << "dynamic_cast to TwoBowedSurfacesAlignmentParameters failed.";
0108 return false;
0109 }
0110
0111
0112
0113 const double ySplit = aliPar->ySplit();
0114 const double halfWidth = 0.5 * component.surface().width();
0115 const double halfLength = 0.5 * component.surface().length();
0116 const double halfLength1 = 0.5 * (halfLength + ySplit);
0117 const double halfLength2 = 0.5 * (halfLength - ySplit);
0118 const double yM1 = 0.5 * (ySplit - halfLength);
0119 const double yM2 = yM1 + halfLength;
0120
0121
0122
0123 const align::GlobalPoint posSurf1(component.surface().toGlobal(align::LocalPoint(0., yM1, 0.)));
0124 const align::GlobalPoint posSurf2(component.surface().toGlobal(align::LocalPoint(0., yM2, 0.)));
0125
0126
0127
0128 FrameToFrameDerivative f2fMaker;
0129 AlgebraicMatrix66 f2fSurf1(
0130 f2fMaker.getDerivative(component.globalRotation(), mother.globalRotation(), posSurf1, mother.globalPosition()));
0131 AlgebraicMatrix66 f2fSurf2(
0132 f2fMaker.getDerivative(component.globalRotation(), mother.globalRotation(), posSurf2, mother.globalPosition()));
0133
0134 if (!f2fSurf1.Invert() || !f2fSurf2.Invert())
0135 return false;
0136
0137 const AlgebraicMatrix69 derivs1(this->dRigid_dBowed(f2fSurf1, halfWidth, halfLength1));
0138 const AlgebraicMatrix69 derivs2(this->dRigid_dBowed(f2fSurf2, halfWidth, halfLength2));
0139
0140
0141 typedef ROOT::Math::SMatrix<double, 6, 18, ROOT::Math::MatRepStd<double, 6, 18>> AlgebraicMatrix6_18;
0142 AlgebraicMatrix6_18 derivs;
0143 derivs.Place_at(derivs1, 0, 0);
0144 derivs.Place_at(derivs2, 0, 9);
0145
0146
0147 derivatives_.ResizeTo(6, 18);
0148 derivatives_.SetMatrixArray(derivs.begin());
0149
0150 return true;
0151 }
0152
0153
0154 ParametersToParametersDerivatives::AlgebraicMatrix69 ParametersToParametersDerivatives::dRigid_dBowed(
0155 const AlgebraicMatrix66 &dRigidM2dRigidC, double halfWidth, double halfLength) {
0156 typedef BowedSurfaceAlignmentDerivatives BowedDerivs;
0157 const double gammaScale = BowedDerivs::gammaScale(2. * halfWidth, 2. * halfLength);
0158
0159
0160
0161
0162
0163 AlgebraicMatrix69 derivs;
0164 if (0. == gammaScale || 0. == halfWidth || 0. == halfLength) {
0165 isOK_ = false;
0166 edm::LogError("Alignment") << "@SUB=ParametersToParametersDerivatives::dRigid_dBowed"
0167 << "Some zero length as input.";
0168 return derivs;
0169 }
0170
0171 for (unsigned int iRow = 0; iRow < AlgebraicMatrix69::kRows; ++iRow) {
0172
0173
0174
0175 for (unsigned int iCol = 0; iCol < 3; ++iCol) {
0176 derivs(iRow, iCol) = dRigidM2dRigidC(iRow, iCol);
0177 }
0178
0179
0180
0181
0182
0183 derivs(iRow, 3) = -dRigidM2dRigidC(iRow, 4) / halfWidth;
0184
0185
0186
0187 derivs(iRow, 4) = dRigidM2dRigidC(iRow, 3) / halfLength;
0188
0189
0190
0191 derivs(iRow, 5) = dRigidM2dRigidC(iRow, 5) / gammaScale;
0192
0193
0194
0195 for (unsigned int iCol = 6; iCol < AlgebraicMatrix69::kCols; ++iCol) {
0196 derivs(iRow, iCol) = 0.;
0197 }
0198 }
0199
0200 return derivs;
0201 }
0202
0203
0204 double ParametersToParametersDerivatives::operator()(unsigned int indParMother, unsigned int indParComp) const {
0205
0206 return derivatives_(indParMother, indParComp);
0207 }