test
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) {setCache();}
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  return thePhi;
48  }
49  T eta() const {
50  return theEta;
51  }
52 
53 
54  // multiply inverse is faster
55  class ToLocal {
56  public:
57  ToLocal(GloballyPositioned const & frame) :
58  thePos(frame.position()), theRot(frame.rotation().transposed()){}
59 
60  LocalPoint operator()(const GlobalPoint& gp) const {
61  return toLocal(gp);
62  }
63 
64  LocalVector operator()(const GlobalVector& gv) const {
65  return toLocal(gv);
66  }
67 
68  LocalPoint toLocal( const GlobalPoint& gp) const {
71  );
72  }
73 
74  LocalVector toLocal( const GlobalVector& gv) const {
76  }
77 
78  // private:
81 
82  };
83 
84 
85 
89  GlobalPoint toGlobal( const LocalPoint& lp) const {
90  return GlobalPoint( rotation().multiplyInverse( lp.basicVector()) +
91  position().basicVector());
92  }
93 
98  template <class U>
102  position().basicVector());
103  }
104 
108  GlobalVector toGlobal( const LocalVector& lv) const {
109  return GlobalVector( rotation().multiplyInverse( lv.basicVector()));
110  }
111 
116  template <class U>
120  }
121 
125  LocalPoint toLocal( const GlobalPoint& gp) const {
126  return LocalPoint( rotation() * (gp.basicVector()-position().basicVector()));
127  }
128 
133  template <class U>
137  (gp.basicVector()-position().basicVector()));
138  }
139 
143  LocalVector toLocal( const GlobalVector& gv) const {
144  return LocalVector( rotation() * gv.basicVector());
145  }
146 
151  template <class U>
155  }
156 
160  void move( const GlobalVector& displacement) {
161  thePos += displacement;
162  setCache();
163  }
164 
168  void rotate( const RotationType& rotation) {
169  theRot *= rotation;
170  setCache();
171  }
172 
173 private:
174 
177 
178  /*
179  void resetCache() {
180  if ((thePos.x() == 0.) && (thePos.y() == 0.)) {
181  thePhi = theEta = 0.; // avoid FPE
182  } else {
183  thePhi = iniPhi();
184  theEta = iniEta();
185  }
186  }
187  */
188 
189  void setCache() {
190  if ((thePos.x() == 0.) & (thePos.y() == 0.)) {
191  thePhi = theEta = 0.; // avoid FPE
192  } else {
193  thePhi = thePos.barePhi();
194  theEta = thePos.eta();
195  }
196  }
197 
200 
201 };
202 
203 #endif
ToLocal(GloballyPositioned const &frame)
GlobalVector toGlobal(const LocalVector &lv) const
T y() const
Definition: PV3DBase.h:63
LocalPoint operator()(const GlobalPoint &gp) const
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
LocalVector operator()(const GlobalVector &gv) const