CMS 3D CMS Logo

TwoBowedSurfacesDeformation.cc
Go to the documentation of this file.
1 
6 
8 
9 // already included via header:
10 // #include <vector>
11 
12 //------------------------------------------------------------------------------
14  if (pars.size() != parameterSize()) {
15  edm::LogError("BadSetup") << "@SUB=TwoBowedSurfacesDeformation"
16  << "Input vector of wrong size " << pars.size() << " instead of " << parameterSize()
17  << ", add zeros to fill up!";
18  }
19  for (unsigned int i = 0; i != std::min((unsigned int)(pars.size()), parameterSize()); ++i)
20  theParameters[i] = pars[i];
21  for (unsigned int i = pars.size(); i != parameterSize(); ++i)
22  theParameters[i] = 0;
23 }
24 
25 //------------------------------------------------------------------------------
27  return new TwoBowedSurfacesDeformation(*this);
28 }
29 
30 //------------------------------------------------------------------------------
32 
33 //------------------------------------------------------------------------------
35  const LocalTrackAngles &localAngles,
36  double length,
37  double width) const {
38  const double ySplit = theParameters[k_ySplit()];
39 
40  // treatment of different widthes at high/low y could be done by theRelWidthLowY or so
41  // if (widthLowY > 0. && widthHighY != widthLowY) {
42  // edm::LogVerbatim("CommonTopologies") << "SurfaceDeformation::positionCorrection2Bowed: Cannot yet deal "
43  // << " with different widthes, take " << widthHighY << " not " << widthLowY;
44  // }
45  // const double width = widthHighY;
46 
47  // Some signs depend on whether we are in surface part below or above ySplit:
48  const double sign = (localPos.y() < ySplit ? +1. : -1.);
49  const double yMiddle = ySplit * 0.5 - sign * length * .25;
50  // 'calibrate' y length and transform y to be w.r.t. surface middle
51  const double myY = localPos.y() - yMiddle;
52  const double myLength = length * 0.5 + sign * ySplit;
53 
54  double uRel = 2. * localPos.x() / width; // relative u (-1 .. +1)
55  double vRel = 2. * myY / myLength; // relative v (-1 .. +1)
56  // 'range check':
57  const double cutOff = 1.5;
58  if (uRel < -cutOff) {
59  uRel = -cutOff;
60  } else if (uRel > cutOff) {
61  uRel = cutOff;
62  }
63  if (vRel < -cutOff) {
64  vRel = -cutOff;
65  } else if (vRel > cutOff) {
66  vRel = cutOff;
67  }
68 
69  auto pars = theParameters;
70  // 1st, get dw effect depending
71  // - on the surface sagittas (Legendre polynomials),
72  // see BowedSurfaceAlignmentDerivatives::operator()(..)
73  // - relative dw
74  // - surface specific dalpha (note that this shifts surface specific dw)
75  // - surface specific dbeta
76  const double dw = (uRel * uRel - 1. / 3.) * (pars[0] + sign * pars[9]) // sagittaX
77  + uRel * vRel * (pars[1] + sign * pars[10]) // sagittaXY
78  + (vRel * vRel - 1. / 3.) * (pars[2] + sign * pars[11]) // sagittaY
79  + sign * pars[5] // different dw
80  + myY * sign * pars[6] // different dalpha
81  - localPos.x() * sign * pars[7]; // different dbeta
82  // 2nd, translate the dw effect to shifts in x and y
83  // Positive dxdz/dydz and positive dw mean negative shift in x/y:
84  Local2DVector::ScalarType x = -dw * localAngles.dxdz();
85  Local2DVector::ScalarType y = -dw * localAngles.dydz();
86  // 3rd, treat in-plane differences depending on surface from xy-shifts...
87  x += (sign * pars[3]); // different du
88  y += (sign * pars[4]); // different dv
89  // ...and gamma-rotation
90  x -= myY * (sign * pars[8]); // different dgamma for u
91  y += localPos.x() * (sign * pars[8]); // different dgamma for v
92 
93  return Local2DVector(x, y);
94 }
95 
96 //------------------------------------------------------------------------------
98  if (this->type() == other.type()) {
99  const std::vector<double> otherParameters(other.parameters());
100  if (otherParameters.size() == parameterSize()) {
101  // Second check in case it is really adding, either way DO NOT check equality directly
102  if (fabs(theParameters[k_ySplit()] - otherParameters[k_ySplit()]) < 1e-5 ||
103  fabs(otherParameters[k_ySplit()]) < 1e-5) {
104  for (unsigned int i = 0; i != parameterSize() - 1; ++i) { // -1 for ySplit
105  // mean bows, delta shifts, delta angles and delta bows can simply be added up
106  theParameters[i] += otherParameters[i];
107  }
108  return true;
109  } else { // ySplit values are different!
110  edm::LogError("Alignment") << "@SUB=TwoBowedSurfacesDeformation::add"
111  << "Different ySplit: this " << theParameters[k_ySplit()] << ", to add "
112  << otherParameters[k_ySplit()];
113  }
114  } // same size
115  } // same type
116 
117  edm::LogError("Alignment") << "@SUB=TwoBowedSurfacesDeformation::add"
118  << "Types are different!";
119 
120  return false;
121 }
122 
123 //------------------------------------------------------------------------------
124 std::vector<double> TwoBowedSurfacesDeformation::parameters() const {
125  return std::vector<double>(theParameters, theParameters + parameterSize());
126 }
T x() const
Definition: PV2DBase.h:43
Log< level::Error, false > LogError
TwoBowedSurfacesDeformation * clone() const override
T y() const
Definition: PV2DBase.h:44
int type() const override
specific type, i.e. SurfaceDeformationFactory::kTwoBowedSurfaces
Local2DVector positionCorrection(const Local2DPoint &localPos, const LocalTrackAngles &localAngles, double length, double width) const override
static constexpr unsigned int k_ySplit()
TwoBowedSurfacesDeformation(const std::vector< double > &parameters)
static constexpr unsigned int parameterSize()
double dxdz() const
Definition: Topology.h:50
virtual int type() const =0
specific type, i.e. SurfaceDeformationFactory::Type
Vector2DBase< double, LocalTag > Local2DVector
bool add(const SurfaceDeformation &other) override
std::vector< double > parameters() const override
parameters - see constructor for meaning
double dydz() const
Definition: Topology.h:51