File indexing completed on 2021-02-14 13:07:53
0001
0002
0003
0004 #include "Geometry/CommonTopologies/interface/TwoBowedSurfacesDeformation.h"
0005 #include "Geometry/CommonTopologies/interface/SurfaceDeformationFactory.h"
0006
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008
0009
0010
0011
0012
0013 TwoBowedSurfacesDeformation::TwoBowedSurfacesDeformation(const std::vector<double> &pars) {
0014 if (pars.size() != parameterSize()) {
0015 edm::LogError("BadSetup") << "@SUB=TwoBowedSurfacesDeformation"
0016 << "Input vector of wrong size " << pars.size() << " instead of " << parameterSize()
0017 << ", add zeros to fill up!";
0018 }
0019 for (unsigned int i = 0; i != std::min((unsigned int)(pars.size()), parameterSize()); ++i)
0020 theParameters[i] = pars[i];
0021 for (unsigned int i = pars.size(); i != parameterSize(); ++i)
0022 theParameters[i] = 0;
0023 }
0024
0025
0026 TwoBowedSurfacesDeformation *TwoBowedSurfacesDeformation::clone() const {
0027 return new TwoBowedSurfacesDeformation(*this);
0028 }
0029
0030
0031 int TwoBowedSurfacesDeformation::type() const { return SurfaceDeformationFactory::kTwoBowedSurfaces; }
0032
0033
0034 SurfaceDeformation::Local2DVector TwoBowedSurfacesDeformation::positionCorrection(const Local2DPoint &localPos,
0035 const LocalTrackAngles &localAngles,
0036 double length,
0037 double width) const {
0038 const double ySplit = theParameters[k_ySplit()];
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 const double sign = (localPos.y() < ySplit ? +1. : -1.);
0050 const double yMiddle = ySplit * 0.5 - sign * length * .25;
0051
0052 const double myY = localPos.y() - yMiddle;
0053 const double myLength = length * 0.5 + sign * ySplit;
0054
0055 double uRel = 2. * localPos.x() / width;
0056 double vRel = 2. * myY / myLength;
0057
0058 const double cutOff = 1.5;
0059 if (uRel < -cutOff) {
0060 uRel = -cutOff;
0061 } else if (uRel > cutOff) {
0062 uRel = cutOff;
0063 }
0064 if (vRel < -cutOff) {
0065 vRel = -cutOff;
0066 } else if (vRel > cutOff) {
0067 vRel = cutOff;
0068 }
0069
0070 auto pars = theParameters;
0071
0072
0073
0074
0075
0076
0077 const double dw = (uRel * uRel - 1. / 3.) * (pars[0] + sign * pars[9])
0078 + uRel * vRel * (pars[1] + sign * pars[10])
0079 + (vRel * vRel - 1. / 3.) * (pars[2] + sign * pars[11])
0080 + sign * pars[5]
0081 + myY * sign * pars[6]
0082 - localPos.x() * sign * pars[7];
0083
0084
0085 Local2DVector::ScalarType x = -dw * localAngles.dxdz();
0086 Local2DVector::ScalarType y = -dw * localAngles.dydz();
0087
0088 x += (sign * pars[3]);
0089 y += (sign * pars[4]);
0090
0091 x -= myY * (sign * pars[8]);
0092 y += localPos.x() * (sign * pars[8]);
0093
0094 return Local2DVector(x, y);
0095 }
0096
0097
0098 bool TwoBowedSurfacesDeformation::add(const SurfaceDeformation &other) {
0099 if (this->type() == other.type()) {
0100 const std::vector<double> otherParameters(other.parameters());
0101 if (otherParameters.size() == parameterSize()) {
0102
0103 if (fabs(theParameters[k_ySplit()] - otherParameters[k_ySplit()]) < 1e-5 ||
0104 fabs(otherParameters[k_ySplit()]) < 1e-5) {
0105 for (unsigned int i = 0; i != parameterSize() - 1; ++i) {
0106
0107 theParameters[i] += otherParameters[i];
0108 }
0109 return true;
0110 } else {
0111 edm::LogError("Alignment") << "@SUB=TwoBowedSurfacesDeformation::add"
0112 << "Different ySplit: this " << theParameters[k_ySplit()] << ", to add "
0113 << otherParameters[k_ySplit()];
0114 }
0115 }
0116 }
0117
0118 edm::LogError("Alignment") << "@SUB=TwoBowedSurfacesDeformation::add"
0119 << "Types are different!";
0120
0121 return false;
0122 }
0123
0124
0125 std::vector<double> TwoBowedSurfacesDeformation::parameters() const {
0126 return std::vector<double>(theParameters, theParameters + parameterSize());
0127 }