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>
9  public:
10 
11  CaloNavigator(const T& home, const TOPO * topology) : myTopology_(topology)
12  {
13  setHome(home);
14  }
15 
17  inline void setHome(const T& startingPoint);
18 
20  inline void setTopology(const TOPO *);
21 
23  const TOPO * getTopology() const
24  {
25  return myTopology_;
26  }
27 
29  inline void home() const ;
30 
32  T pos() const { return currentPoint_; }
33 
35  T operator*() const { return currentPoint_; }
36 
38  T north() const
39  {
41  return currentPoint_;
42  } ;
43 
45  T south() const
46  {
48  return currentPoint_;
49  } ;
50 
52  T east() const
53  {
55  return currentPoint_;
56  } ;
57 
59  T west() const
60  {
62  return currentPoint_;
63  } ;
64 
66  T up() const
67  {
69  return currentPoint_;
70  } ;
71 
73  T down() const
74  {
76  return currentPoint_;
77  } ;
78 
80  T offsetBy(int deltaX, int deltaY) const
81  {
82  for(int x=0; x < abs(deltaX) && currentPoint_ != T(0); x++)
83  {
84  if(deltaX > 0) east();
85  else west();
86  }
87 
88  for(int y=0; y < abs(deltaY) && currentPoint_ != T(0); y++)
89  {
90  if(deltaY > 0) north();
91  else south();
92  }
93 
94  return currentPoint_;
95 
96  }
97 
98  protected:
99 
100  const TOPO * myTopology_;
102 };
103 
104 template <class T, class TOPO>
105 inline
106 void CaloNavigator<T,TOPO>::setHome(const T& startingPoint)
107 {
108  startingPoint_=startingPoint;
109  home();
110 }
111 
112 template <class T, class TOPO>
113 inline
115 {
116  currentPoint_=startingPoint_;
117 }
118 
119 template <class T, class TOPO>
120 inline
122 {
123  if (myTopology_ == 0)
124  myTopology_=topology;
125  else
126  return;
127 }
128 
129 #endif
#define GCC11_FINAL
CaloTopology const * topology(0)
void setHome(const T &startingPoint)
set the starting position
T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
Definition: CaloNavigator.h:80
T down() const
move the navigator west
Definition: CaloNavigator.h:73
T west() const
move the navigator west
Definition: CaloNavigator.h:59
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T south() const
move the navigator south
Definition: CaloNavigator.h:45
T pos() const
get the current position
Definition: CaloNavigator.h:32
T operator*() const
get the current position
Definition: CaloNavigator.h:35
T east() const
move the navigator east
Definition: CaloNavigator.h:52
void home() const
move the navigator back to the starting point
T up() const
move the navigator west
Definition: CaloNavigator.h:66
const TOPO * myTopology_
T north() const
move the navigator north
Definition: CaloNavigator.h:38
const TOPO * getTopology() const
set the starting position
Definition: CaloNavigator.h:23
CaloNavigator(const T &home, const TOPO *topology)
Definition: CaloNavigator.h:11
long double T
void setTopology(const TOPO *)
set the starting position