CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
21  typedef T Scalar;
28 
29  static T iniPhi() {
30  return 999.9978;
31  }
32  static T iniEta() {
33  return 999.9978;
34  }
35 
37  thePos(pos), theRot(rot) {resetCache();}
38 
39  virtual ~GloballyPositioned() {}
40 
41  const PositionType& position() const { return thePos;}
42 
43  const RotationType& rotation() const { return theRot;}
44 
45  T phi() const {
46  if (thePhi==iniPhi()) thePhi = thePos.barePhi();
47  return thePhi;
48  }
49  T eta() const {
50  if (theEta==iniEta()) theEta = thePos.eta();
51  return theEta;
52  }
53 
54 
55  // multiply inverse is faster
56  class ToLocal {
57  public:
58  ToLocal(GloballyPositioned const & frame) :
59  thePos(frame.position()), theRot(frame.rotation().transposed()){}
60 
61  LocalPoint toLocal( const GlobalPoint& gp) const {
64  );
65  }
66 
67  LocalVector toLocal( const GlobalVector& gv) const {
69  }
70 
71  private:
74 
75  };
76 
77 
78 
82  GlobalPoint toGlobal( const LocalPoint& lp) const {
83  return GlobalPoint( rotation().multiplyInverse( lp.basicVector()) +
84  position().basicVector());
85  }
86 
91  template <class U>
93  toGlobal( const Point3DBase< U, LocalTag>& lp) const {
95  position().basicVector());
96  }
97 
101  GlobalVector toGlobal( const LocalVector& lv) const {
102  return GlobalVector( rotation().multiplyInverse( lv.basicVector()));
103  }
104 
109  template <class U>
113  }
114 
118  LocalPoint toLocal( const GlobalPoint& gp) const {
119  return LocalPoint( rotation() * (gp.basicVector()-position().basicVector()));
120  }
121 
126  template <class U>
130  (gp.basicVector()-position().basicVector()));
131  }
132 
136  LocalVector toLocal( const GlobalVector& gv) const {
137  return LocalVector( rotation() * gv.basicVector());
138  }
139 
144  template <class U>
148  }
149 
153  void move( const GlobalVector& displacement) {
154  thePos += displacement;
155  resetCache();
156  }
157 
161  void rotate( const RotationType& rotation) {
162  theRot *= rotation;
163  resetCache();
164  }
165 
166 private:
167 
170 
171 
172  void resetCache() {
173  if ((thePos.x() == 0.) && (thePos.y() == 0.)) {
174  thePhi = theEta = 0.; // avoid FPE
175  } else {
176  thePhi = iniPhi();
177  theEta = iniEta();
178  }
179  }
180 
181 
182  void setCache() {
183  if ((thePos.x() == 0.) && (thePos.y() == 0.)) {
184  thePhi = theEta = 0.; // avoid FPE
185  } else {
186  thePhi = thePos.barePhi();
187  theEta = thePos.eta();
188  }
189  }
190 
191  mutable T thePhi;
192  mutable T theEta;
193 
194 };
195 
196 #endif
ToLocal(GloballyPositioned const &frame)
GlobalVector toGlobal(const LocalVector &lv) const
T y() const
Definition: PV3DBase.h:57
void move(const GlobalVector &displacement)
Vector3DBase< U, GlobalTag > toGlobal(const Vector3DBase< U, LocalTag > &lv) const
Vector3DBase< T, GlobalTag > GlobalVector
Vector3DBase< T, LocalTag > LocalVector
T barePhi() const
Definition: PV3DBase.h:62
def transposed
Definition: CommonUtil.py:52
LocalVector toLocal(const GlobalVector &gv) const
LocalPoint toLocal(const GlobalPoint &gp) const
Point3DBase< T, GlobalTag > GlobalPoint
GloballyPositioned(const PositionType &pos, const RotationType &rot)
LocalVector toLocal(const GlobalVector &gv) const
Vector3DBase< U, LocalTag > toLocal(const Vector3DBase< U, GlobalTag > &gv) const
GlobalPoint toGlobal(const LocalPoint &lp) const
Point3DBase< U, LocalTag > toLocal(const Point3DBase< U, GlobalTag > &gp) const
Point3DBase< T, LocalTag > LocalPoint
Point3DBase< T, GlobalTag > PositionType
T eta() const
Definition: PV3DBase.h:70
LocalPoint toLocal(const GlobalPoint &gp) const
void rotate(const RotationType &rotation)
TkRotation< T > RotationType
const RotationType & rotation() const
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
T x() const
Definition: PV3DBase.h:56
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:54
const PositionType & position() const
Point3DBase< U, GlobalTag > toGlobal(const Point3DBase< U, LocalTag > &lp) const