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>
76  return Point3DBase<U, GlobalTag>(rotation().multiplyInverse(lp.basicVector()) + position().basicVector());
77  }
78 
82  GlobalVector toGlobal(const LocalVector& lv) const {
83  return GlobalVector(rotation().multiplyInverse(lv.basicVector()));
84  }
85 
90  template <class U>
92  return Vector3DBase<U, GlobalTag>(rotation().multiplyInverse(lv.basicVector()));
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
Vector3DBase
Definition: Vector3DBase.h:8
GloballyPositioned
Definition: GloballyPositioned.h:18
GloballyPositioned::LocalPoint
Point3DBase< T, LocalTag > LocalPoint
Definition: GloballyPositioned.h:24
TkRotation
Definition: extTkRotation.h:13
GloballyPositioned::GlobalPoint
Point3DBase< T, GlobalTag > GlobalPoint
Definition: GloballyPositioned.h:23
GloballyPositioned::rotate
void rotate(const RotationType &rotation)
Definition: GloballyPositioned.h:136
GloballyPositioned::ToLocal::operator()
LocalVector operator()(const GlobalVector &gv) const
Definition: GloballyPositioned.h:50
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
pos
Definition: PixelAliasList.h:18
GloballyPositioned::GloballyPositioned
GloballyPositioned()
Definition: GloballyPositioned.h:31
GloballyPositioned::ToLocal::thePos
PositionType thePos
Definition: GloballyPositioned.h:59
GloballyPositioned::iniPhi
static T iniPhi()
Definition: GloballyPositioned.h:28
Point3DBase.h
TkRotation::multiplyInverse
Basic3DVector< T > multiplyInverse(const Basic3DVector< T > &v) const
Definition: extTkRotation.h:178
GloballyPositioned::GlobalVector
Vector3DBase< T, GlobalTag > GlobalVector
Definition: GloballyPositioned.h:25
GloballyPositioned::RotationType
TkRotation< T > RotationType
Definition: GloballyPositioned.h:22
GloballyPositioned::toLocal
LocalVector toLocal(const GlobalVector &gv) const
Definition: GloballyPositioned.h:114
GloballyPositioned::toGlobal
GlobalVector toGlobal(const LocalVector &lv) const
Definition: GloballyPositioned.h:82
GloballyPositioned::toLocal
Point3DBase< U, LocalTag > toLocal(const Point3DBase< U, GlobalTag > &gp) const
Definition: GloballyPositioned.h:107
GloballyPositioned::~GloballyPositioned
virtual ~GloballyPositioned()
Definition: GloballyPositioned.h:34
GloballyPositioned::toGlobal
Point3DBase< U, GlobalTag > toGlobal(const Point3DBase< U, LocalTag > &lp) const
Definition: GloballyPositioned.h:75
LocalTag.h
GloballyPositioned::ToLocal::toLocal
LocalVector toLocal(const GlobalVector &gv) const
Definition: GloballyPositioned.h:56
GloballyPositioned::ToLocal::operator()
LocalPoint operator()(const GlobalPoint &gp) const
Definition: GloballyPositioned.h:48
GloballyPositioned::thePhi
T thePhi
Definition: GloballyPositioned.h:165
Vector3DBase.h
TkRotation.h
Point3DBase< T, GlobalTag >
GloballyPositioned::setCache
void setCache()
Definition: GloballyPositioned.h:156
GloballyPositioned::ToLocal::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: GloballyPositioned.h:52
GlobalTag.h
GloballyPositioned::LocalVector
Vector3DBase< T, LocalTag > LocalVector
Definition: GloballyPositioned.h:26
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
GloballyPositioned::ToLocal
Definition: GloballyPositioned.h:44
PV3DBase::barePhi
T barePhi() const
Definition: PV3DBase.h:65
GloballyPositioned::toGlobal
Vector3DBase< U, GlobalTag > toGlobal(const Vector3DBase< U, LocalTag > &lv) const
Definition: GloballyPositioned.h:91
GloballyPositioned::theRot
RotationType theRot
Definition: GloballyPositioned.h:143
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
GloballyPositioned::eta
T eta() const
Definition: GloballyPositioned.h:41
GloballyPositioned::phi
T phi() const
Definition: GloballyPositioned.h:40
GloballyPositioned::move
void move(const GlobalVector &displacement)
Definition: GloballyPositioned.h:128
GloballyPositioned::ToLocal::ToLocal
ToLocal(GloballyPositioned const &frame)
Definition: GloballyPositioned.h:46
PV3DBase::basicVector
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
GloballyPositioned::position
const PositionType & position() const
Definition: GloballyPositioned.h:36
GloballyPositioned::PositionType
Point3DBase< T, GlobalTag > PositionType
Definition: GloballyPositioned.h:21
GloballyPositioned::toLocal
Vector3DBase< U, LocalTag > toLocal(const Vector3DBase< U, GlobalTag > &gv) const
Definition: GloballyPositioned.h:121
GloballyPositioned::ToLocal::theRot
RotationType theRot
Definition: GloballyPositioned.h:60
T
long double T
Definition: Basic3DVectorLD.h:48
GloballyPositioned::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: GloballyPositioned.h:98
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
GloballyPositioned::theEta
T theEta
Definition: GloballyPositioned.h:166
GloballyPositioned::thePos
PositionType thePos
Definition: GloballyPositioned.h:142
GloballyPositioned::rotation
const RotationType & rotation() const
Definition: GloballyPositioned.h:38
GloballyPositioned::iniEta
static T iniEta()
Definition: GloballyPositioned.h:29
GloballyPositioned::toGlobal
GlobalPoint toGlobal(const LocalPoint &lp) const
Definition: GloballyPositioned.h:66
GloballyPositioned::Scalar
T Scalar
Definition: GloballyPositioned.h:20
GloballyPositioned::GloballyPositioned
GloballyPositioned(const PositionType &pos, const RotationType &rot)
Definition: GloballyPositioned.h:32