File indexing completed on 2024-09-07 04:36:28
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 const double sign = (localPos.y() < ySplit ? +1. : -1.);
0049 const double yMiddle = ySplit * 0.5 - sign * length * .25;
0050
0051 const double myY = localPos.y() - yMiddle;
0052 const double myLength = length * 0.5 + sign * ySplit;
0053
0054 double uRel = 2. * localPos.x() / width;
0055 double vRel = 2. * myY / myLength;
0056
0057 const double cutOff = 1.5;
0058 if (uRel < -cutOff) {
0059 uRel = -cutOff;
0060 } else if (uRel > cutOff) {
0061 uRel = cutOff;
0062 }
0063 if (vRel < -cutOff) {
0064 vRel = -cutOff;
0065 } else if (vRel > cutOff) {
0066 vRel = cutOff;
0067 }
0068
0069 auto pars = theParameters;
0070
0071
0072
0073
0074
0075
0076 const double dw = (uRel * uRel - 1. / 3.) * (pars[0] + sign * pars[9])
0077 + uRel * vRel * (pars[1] + sign * pars[10])
0078 + (vRel * vRel - 1. / 3.) * (pars[2] + sign * pars[11])
0079 + sign * pars[5]
0080 + myY * sign * pars[6]
0081 - localPos.x() * sign * pars[7];
0082
0083
0084 Local2DVector::ScalarType x = -dw * localAngles.dxdz();
0085 Local2DVector::ScalarType y = -dw * localAngles.dydz();
0086
0087 x += (sign * pars[3]);
0088 y += (sign * pars[4]);
0089
0090 x -= myY * (sign * pars[8]);
0091 y += localPos.x() * (sign * pars[8]);
0092
0093 return Local2DVector(x, y);
0094 }
0095
0096
0097 bool TwoBowedSurfacesDeformation::add(const SurfaceDeformation &other) {
0098 if (this->type() == other.type()) {
0099 const std::vector<double> otherParameters(other.parameters());
0100 if (otherParameters.size() == parameterSize()) {
0101
0102 if (fabs(theParameters[k_ySplit()] - otherParameters[k_ySplit()]) < 1e-5 ||
0103 fabs(otherParameters[k_ySplit()]) < 1e-5) {
0104 for (unsigned int i = 0; i != parameterSize() - 1; ++i) {
0105
0106 theParameters[i] += otherParameters[i];
0107 }
0108 return true;
0109 } else {
0110 edm::LogError("Alignment") << "@SUB=TwoBowedSurfacesDeformation::add"
0111 << "Different ySplit: this " << theParameters[k_ySplit()] << ", to add "
0112 << otherParameters[k_ySplit()];
0113 }
0114 }
0115 }
0116
0117 edm::LogError("Alignment") << "@SUB=TwoBowedSurfacesDeformation::add"
0118 << "Types are different!";
0119
0120 return false;
0121 }
0122
0123
0124 std::vector<double> TwoBowedSurfacesDeformation::parameters() const {
0125 return std::vector<double>(theParameters, theParameters + parameterSize());
0126 }