CMS 3D CMS Logo

GloballyPositioned.h
Go to the documentation of this file.
1 #ifndef Geom_GloballyPositioned_H
2 #define Geom_GloballyPositioned_H
3 
9 
17 template <class T>
19 public:
20  typedef T Scalar;
27 
28  static T iniPhi() { return 999.9978; }
29  static T iniEta() { return 999.9978; }
30 
33 
34  virtual ~GloballyPositioned() {}
35 
36  const PositionType& position() const { return thePos; }
37 
38  const RotationType& rotation() const { return theRot; }
39 
40  T phi() const { return thePhi; }
41  T eta() const { return theEta; }
42 
43  // multiply inverse is faster
44  class ToLocal {
45  public:
47 
48  LocalPoint operator()(const GlobalPoint& gp) const { return toLocal(gp); }
49 
50  LocalVector operator()(const GlobalVector& gv) const { return toLocal(gv); }
51 
52  LocalPoint toLocal(const GlobalPoint& gp) const {
53  return LocalPoint(theRot.multiplyInverse(gp.basicVector() - thePos.basicVector()));
54  }
55 
57 
58  // private:
61  };
62 
66  GlobalPoint toGlobal(const LocalPoint& lp) const {
67  return GlobalPoint(rotation().multiplyInverse(lp.basicVector()) + position().basicVector());
68  }
69 
74  template <class U>
77  }
78 
82  GlobalVector toGlobal(const LocalVector& lv) const {
83  return GlobalVector(rotation().multiplyInverse(lv.basicVector()));
84  }
85 
90  template <class U>
93  }
94 
98  LocalPoint toLocal(const GlobalPoint& gp) const {
99  return LocalPoint(rotation() * (gp.basicVector() - position().basicVector()));
100  }
101 
106  template <class U>
108  return Point3DBase<U, LocalTag>(rotation() * (gp.basicVector() - position().basicVector()));
109  }
110 
114  LocalVector toLocal(const GlobalVector& gv) const { return LocalVector(rotation() * gv.basicVector()); }
115 
120  template <class U>
123  }
124 
128  void move(const GlobalVector& displacement) {
129  thePos += displacement;
130  setCache();
131  }
132 
136  void rotate(const RotationType& rotation) {
137  theRot *= rotation;
138  setCache();
139  }
140 
141 private:
144 
145  /*
146  void resetCache() {
147  if ((thePos.x() == 0.) && (thePos.y() == 0.)) {
148  thePhi = theEta = 0.; // avoid FPE
149  } else {
150  thePhi = iniPhi();
151  theEta = iniEta();
152  }
153  }
154  */
155 
156  void setCache() {
157  if ((thePos.x() == 0.) && (thePos.y() == 0.)) {
158  thePhi = theEta = 0.; // avoid FPE
159  } else {
160  thePhi = thePos.barePhi();
161  theEta = thePos.eta();
162  }
163  }
164 
167 };
168 
169 #endif
GlobalPoint toGlobal(const LocalPoint &lp) const
ToLocal(GloballyPositioned const &frame)
LocalVector toLocal(const GlobalVector &gv) const
T eta() const
Definition: PV3DBase.h:73
LocalPoint operator()(const GlobalPoint &gp) const
void move(const GlobalVector &displacement)
Vector3DBase< T, GlobalTag > GlobalVector
LocalPoint toLocal(const GlobalPoint &gp) const
Vector3DBase< T, LocalTag > LocalVector
T barePhi() const
Definition: PV3DBase.h:65
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
GlobalVector toGlobal(const LocalVector &lv) const
LocalVector toLocal(const GlobalVector &gv) const
GloballyPositioned(const PositionType &pos, const RotationType &rot)
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
Point3DBase< T, GlobalTag > PositionType
Vector3DBase< U, GlobalTag > toGlobal(const Vector3DBase< U, LocalTag > &lv) const
LocalVector operator()(const GlobalVector &gv) const
const PositionType & position() const
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
Point3DBase< T, GlobalTag > GlobalPoint
Point3DBase< T, LocalTag > LocalPoint
void rotate(const RotationType &rotation)
Point3DBase< U, LocalTag > toLocal(const Point3DBase< U, GlobalTag > &gp) const
TkRotation< T > RotationType
LocalPoint toLocal(const GlobalPoint &gp) const
Vector3DBase< U, LocalTag > toLocal(const Vector3DBase< U, GlobalTag > &gv) const
const RotationType & rotation() const
long double T
Point3DBase< U, GlobalTag > toGlobal(const Point3DBase< U, LocalTag > &lp) const