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 
38  thePos(pos), theRot(rot) {resetCache();}
39 
40  virtual ~GloballyPositioned() {}
41 
42  const PositionType& position() const { return thePos;}
43 
44  const RotationType& rotation() const { return theRot;}
45 
46  T phi() const {
47  if (thePhi==iniPhi()) thePhi = thePos.barePhi();
48  return thePhi;
49  }
50  T eta() const {
51  if (theEta==iniEta()) theEta = thePos.eta();
52  return theEta;
53  }
54 
55 
56  // multiply inverse is faster
57  class ToLocal {
58  public:
59  ToLocal(GloballyPositioned const & frame) :
60  thePos(frame.position()), theRot(frame.rotation().transposed()){}
61 
62  LocalPoint toLocal( const GlobalPoint& gp) const {
65  );
66  }
67 
68  LocalVector toLocal( const GlobalVector& gv) const {
70  }
71 
72  private:
75 
76  };
77 
78 
79 
83  GlobalPoint toGlobal( const LocalPoint& lp) const {
84  return GlobalPoint( rotation().multiplyInverse( lp.basicVector()) +
85  position().basicVector());
86  }
87 
92  template <class U>
94  toGlobal( const Point3DBase< U, LocalTag>& lp) const {
96  position().basicVector());
97  }
98 
102  GlobalVector toGlobal( const LocalVector& lv) const {
103  return GlobalVector( rotation().multiplyInverse( lv.basicVector()));
104  }
105 
110  template <class U>
114  }
115 
119  LocalPoint toLocal( const GlobalPoint& gp) const {
120  return LocalPoint( rotation() * (gp.basicVector()-position().basicVector()));
121  }
122 
127  template <class U>
131  (gp.basicVector()-position().basicVector()));
132  }
133 
137  LocalVector toLocal( const GlobalVector& gv) const {
138  return LocalVector( rotation() * gv.basicVector());
139  }
140 
145  template <class U>
149  }
150 
154  void move( const GlobalVector& displacement) {
155  thePos += displacement;
156  resetCache();
157  }
158 
162  void rotate( const RotationType& rotation) {
163  theRot *= rotation;
164  resetCache();
165  }
166 
167 private:
168 
171 
172 
173  void resetCache() {
174  if ((thePos.x() == 0.) && (thePos.y() == 0.)) {
175  thePhi = theEta = 0.; // avoid FPE
176  } else {
177  thePhi = iniPhi();
178  theEta = iniEta();
179  }
180  }
181 
182 
183  void setCache() {
184  if ((thePos.x() == 0.) && (thePos.y() == 0.)) {
185  thePhi = theEta = 0.; // avoid FPE
186  } else {
187  thePhi = thePos.barePhi();
188  theEta = thePos.eta();
189  }
190  }
191 
192  mutable T thePhi;
193  mutable T theEta;
194 
195 };
196 
197 #endif
ToLocal(GloballyPositioned const &frame)
GlobalVector toGlobal(const LocalVector &lv) const
T y() const
Definition: PV3DBase.h:63
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:68
def transposed
Definition: CommonUtil.py:146
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:76
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
long double T
T x() const
Definition: PV3DBase.h:62
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
const PositionType & position() const
Point3DBase< U, GlobalTag > toGlobal(const Point3DBase< U, LocalTag > &lp) const