CMS 3D CMS Logo

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