CMS 3D CMS Logo

CaloNavigator.h
Go to the documentation of this file.
1 #ifndef RECOCALOTOOLS_NAVIGATION_CALONAVIGATOR_H
2 #define RECOCALOTOOLS_NAVIGATION_CALONAVIGATOR_H 1
3 
5 
6 template <class T, class TOPO = CaloSubdetectorTopology>
7 class CaloNavigator final {
8 public:
9  CaloNavigator(const T& home, const TOPO* topology) : myTopology_(topology) { setHome(home); }
10 
12  inline void setHome(const T& startingPoint);
13 
15  inline void setTopology(const TOPO*);
16 
18  const TOPO* getTopology() const { return myTopology_; }
19 
21  inline void home() const;
22 
24  T pos() const { return currentPoint_; }
25 
27  T operator*() const { return currentPoint_; }
28 
30  T north() const {
32  return currentPoint_;
33  };
34 
36  T south() const {
38  return currentPoint_;
39  };
40 
42  T east() const {
44  return currentPoint_;
45  };
46 
48  T west() const {
50  return currentPoint_;
51  };
52 
54  T up() const {
56  return currentPoint_;
57  };
58 
60  T down() const {
62  return currentPoint_;
63  };
64 
66  T offsetBy(int deltaX, int deltaY) const {
67  for (int x = 0; x < abs(deltaX) && currentPoint_ != T(0); x++) {
68  if (deltaX > 0)
69  east();
70  else
71  west();
72  }
73 
74  for (int y = 0; y < abs(deltaY) && currentPoint_ != T(0); y++) {
75  if (deltaY > 0)
76  north();
77  else
78  south();
79  }
80 
81  return currentPoint_;
82  }
83 
84 protected:
85  const TOPO* myTopology_;
87 };
88 
89 template <class T, class TOPO>
90 inline void CaloNavigator<T, TOPO>::setHome(const T& startingPoint) {
91  startingPoint_ = startingPoint;
92  home();
93 }
94 
95 template <class T, class TOPO>
96 inline void CaloNavigator<T, TOPO>::home() const {
97  currentPoint_ = startingPoint_;
98 }
99 
100 template <class T, class TOPO>
101 inline void CaloNavigator<T, TOPO>::setTopology(const TOPO* topology) {
102  if (myTopology_ == 0)
103  myTopology_ = topology;
104  else
105  return;
106 }
107 
108 #endif
CaloNavigator::up
T up() const
move the navigator west
Definition: CaloNavigator.h:54
DDAxes::y
CaloNavigator::north
T north() const
move the navigator north
Definition: CaloNavigator.h:30
CaloNavigator::east
T east() const
move the navigator east
Definition: CaloNavigator.h:42
CaloNavigator::setTopology
void setTopology(const TOPO *)
set the starting position
Definition: CaloNavigator.h:101
CaloNavigator::CaloNavigator
CaloNavigator(const T &home, const TOPO *topology)
Definition: CaloNavigator.h:9
DDAxes::x
CaloNavigator::myTopology_
const TOPO * myTopology_
Definition: CaloNavigator.h:85
CaloNavigator::setHome
void setHome(const T &startingPoint)
set the starting position
Definition: CaloNavigator.h:90
CaloNavigator::currentPoint_
T currentPoint_
Definition: CaloNavigator.h:86
CaloNavigator::home
void home() const
move the navigator back to the starting point
Definition: CaloNavigator.h:96
CaloNavigator::west
T west() const
move the navigator west
Definition: CaloNavigator.h:48
CaloNavigator::south
T south() const
move the navigator south
Definition: CaloNavigator.h:36
CaloNavigator::pos
T pos() const
get the current position
Definition: CaloNavigator.h:24
CaloNavigator::getTopology
const TOPO * getTopology() const
set the starting position
Definition: CaloNavigator.h:18
CaloSubdetectorTopology.h
CaloNavigator::startingPoint_
T startingPoint_
Definition: CaloNavigator.h:86
CaloNavigator
Definition: CaloNavigator.h:7
T
long double T
Definition: Basic3DVectorLD.h:48
CaloNavigator::down
T down() const
move the navigator west
Definition: CaloNavigator.h:60
CaloNavigator::operator*
T operator*() const
get the current position
Definition: CaloNavigator.h:27
CaloNavigator::offsetBy
T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
Definition: CaloNavigator.h:66
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22