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