CMS 3D CMS Logo

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