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  theSagittaY (pars.size() > 2 ? pars[2] : 0.),
19  theSagittaXY(pars.size() > 1 ? pars[1] : 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  return Local2DVector(-dw * localAngles);
72 }
73 
74 //------------------------------------------------------------------------------
76 {
77  if (other.type() == this->type()) {
78  const std::vector<double> otherParams(other.parameters());
79  if (otherParams.size() == 3) { // double check!
80  theSagittaX += otherParams[0]; // bows can simply be added up
81  theSagittaXY += otherParams[1];
82  theSagittaY += otherParams[2];
83 
84  return true;
85  }
86  }
87 
88  return false;
89 }
90 
91 //------------------------------------------------------------------------------
92 std::vector<double> BowedSurfaceDeformation::parameters() const
93 {
94  std::vector<double> result(3);
95  result[0] = theSagittaX;
96  result[1] = theSagittaXY;
97  result[2] = theSagittaY;
98 
99  return result;
100 }
T y() const
Definition: PV2DBase.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
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:44
BowedSurfaceDeformation(double sagittaX, double sagittaXY, double sagittaY)
constructor from sagittae, i.e. coefficients of Legendre polynomials
tuple size
Write out results.