CMS 3D CMS Logo

BowedSurfaceDeformation.cc
Go to the documentation of this file.
1 
6 
8 
9 // already included via header:
10 // #include <vector>
11 
12 //------------------------------------------------------------------------------
13 BowedSurfaceDeformation::BowedSurfaceDeformation(const std::vector<double> &pars)
14  : theSagittaX(!pars.empty() ? pars[0] : 0.),
15  theSagittaY(pars.size() > 2 ? pars[2] : 0.),
16  theSagittaXY(pars.size() > 1 ? pars[1] : 0.) {
17  if (pars.size() != minParameterSize()) {
18  edm::LogError("BadSetup") << "@SUB=BowedSurfaceDeformation"
19  << "Input vector of wrong size " << pars.size() << " instead of " << minParameterSize()
20  << ", filled up with zeros!";
21  }
22 }
23 
24 //------------------------------------------------------------------------------
27 }
28 
29 //------------------------------------------------------------------------------
31 
32 //------------------------------------------------------------------------------
34  const LocalTrackAngles &localAngles,
35  double length,
36  double width) const {
37  // different widthes at high/low y could somehow be treated by theRelWidthLowY
38  // if (widthLowY > 0. && widthHighY != widthLowY) {
39  // // TEC would always create a warning...
40  // edm::LogWarning("UnusableData") << "@SUB=BowedSurfaceDeformation::positionCorrection"
41  // << "Cannot yet deal with different widthes, take "
42  // << widthHighY << " not " << widthLowY;
43  // }
44  // const double width = widthHighY;
45 
46  double uRel = (width ? 2. * localPos.x() / width : 0.); // relative u (-1 .. +1)
47  double vRel = (length ? 2. * localPos.y() / length : 0.); // relative v (-1 .. +1)
48  // 'range check':
49  const double cutOff = 1.5;
50  if (uRel < -cutOff) {
51  uRel = -cutOff;
52  } else if (uRel > cutOff) {
53  uRel = cutOff;
54  }
55  if (vRel < -cutOff) {
56  vRel = -cutOff;
57  } else if (vRel > cutOff) {
58  vRel = cutOff;
59  }
60 
61  // apply coefficients to Legendre polynomials
62  // to get local height relative to 'average'
63  const double dw =
64  (uRel * uRel - 1. / 3.) * theSagittaX + uRel * vRel * theSagittaXY + (vRel * vRel - 1. / 3.) * theSagittaY;
65 
66  // positive dxdz/dydz and positive dw mean negative shift in x/y:
67  return Local2DVector(-dw * localAngles);
68 }
69 
70 //------------------------------------------------------------------------------
72  if (other.type() == this->type()) {
73  const std::vector<double> otherParams(other.parameters());
74  if (otherParams.size() == parameterSize()) { // double check!
75  theSagittaX += otherParams[0]; // bows can simply be added up
76  theSagittaXY += otherParams[1];
77  theSagittaY += otherParams[2];
78 
79  return true;
80  }
81  }
82 
83  return false;
84 }
85 
86 //------------------------------------------------------------------------------
87 std::vector<double> BowedSurfaceDeformation::parameters() const {
88  std::vector<double> result(parameterSize());
89  result[0] = theSagittaX;
90  result[1] = theSagittaXY;
91  result[2] = theSagittaY;
92 
93  return result;
94 }
size
Write out results.
static constexpr unsigned int minParameterSize()
minimum size of vector that is accepted by constructor from vector
BowedSurfaceDeformation * clone() const override
T x() const
Definition: PV2DBase.h:43
Log< level::Error, false > LogError
T y() const
Definition: PV2DBase.h:44
static constexpr unsigned int parameterSize()
int type() const override
specific type, i.e. SurfaceDeformationFactory::kBowedSurface
std::vector< double > parameters() const override
parameters, i.e. sagittae as given in the constructor
bool add(const SurfaceDeformation &other) override
Local2DVector positionCorrection(const Local2DPoint &localPos, const LocalTrackAngles &localAngles, double length, double width) const override
Vector2DBase< double, LocalTag > Local2DVector
BowedSurfaceDeformation(double sagittaX, double sagittaXY, double sagittaY)
constructor from sagittae, i.e. coefficients of Legendre polynomials