CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloNavigator.h
Go to the documentation of this file.
1 #ifndef RECOCALOTOOLS_NAVIGATION_CALONAVIGATOR_H
2 #define RECOCALOTOOLS_NAVIGATION_CALONAVIGATOR_H 1
3 
6 
7 template <class T, class TOPO = CaloSubdetectorTopology>
8 class CaloNavigator final {
9 public:
10  CaloNavigator(const T& home, const TOPO* topology) : myTopology_(topology) { setHome(home); }
11 
13  inline void setHome(const T& startingPoint);
14 
16  inline void setTopology(const TOPO*);
17 
19  const TOPO* getTopology() const { return myTopology_; }
20 
22  inline void home() const;
23 
25  T pos() const { return currentPoint_; }
26 
28  T operator*() const { return currentPoint_; }
29 
31  T north() const {
33  return currentPoint_;
34  };
35 
37  T south() const {
39  return currentPoint_;
40  };
41 
43  T east() const {
45  return currentPoint_;
46  };
47 
49  T west() const {
51  return currentPoint_;
52  };
53 
55  T up() const {
57  return currentPoint_;
58  };
59 
61  T down() const {
63  return currentPoint_;
64  };
65 
67  T offsetBy(int deltaX, int deltaY) const {
68  for (int x = 0; x < abs(deltaX) && currentPoint_ != T(0); x++) {
69  if (deltaX > 0)
70  east();
71  else
72  west();
73  }
74 
75  for (int y = 0; y < abs(deltaY) && currentPoint_ != T(0); y++) {
76  if (deltaY > 0)
77  north();
78  else
79  south();
80  }
81 
82  return currentPoint_;
83  }
84 
85 protected:
86  const TOPO* myTopology_;
88 };
89 
90 template <class T, class TOPO>
91 inline void CaloNavigator<T, TOPO>::setHome(const T& startingPoint) {
92  startingPoint_ = startingPoint;
93  home();
94 }
95 
96 template <class T, class TOPO>
97 inline void CaloNavigator<T, TOPO>::home() const {
99 }
100 
101 template <class T, class TOPO>
103  if (myTopology_ == 0)
105  else
106  return;
107 }
108 
109 #endif
CaloTopology const * topology(0)
void setHome(const T &startingPoint)
set the starting position
Definition: CaloNavigator.h:91
T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
Definition: CaloNavigator.h:67
T down() const
move the navigator west
Definition: CaloNavigator.h:61
T west() const
move the navigator west
Definition: CaloNavigator.h:49
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T south() const
move the navigator south
Definition: CaloNavigator.h:37
T pos() const
get the current position
Definition: CaloNavigator.h:25
T operator*() const
get the current position
Definition: CaloNavigator.h:28
T east() const
move the navigator east
Definition: CaloNavigator.h:43
void home() const
move the navigator back to the starting point
Definition: CaloNavigator.h:97
T up() const
move the navigator west
Definition: CaloNavigator.h:55
const TOPO * myTopology_
Definition: CaloNavigator.h:86
T north() const
move the navigator north
Definition: CaloNavigator.h:31
const TOPO * getTopology() const
set the starting position
Definition: CaloNavigator.h:19
CaloNavigator(const T &home, const TOPO *topology)
Definition: CaloNavigator.h:10
long double T
void setTopology(const TOPO *)
set the starting position