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 
5 
6 template <class T>
7 class CaloNavigator {
8  public:
9 
12  {
13  }
14 
16  {
17  setHome(home);
18  };
19 
20 
21  CaloNavigator(const T& home, const CaloSubdetectorTopology* topology) : myTopology_(topology)
22  {
23  setHome(home);
24  };
25 
27  virtual ~CaloNavigator(){};
28 
30  void setHome(const T& startingPoint);
31 
34 
37  {
38  return myTopology_;
39  }
40 
42  void home() const ;
43 
45  T pos() const { return currentPoint_; }
46 
48  T operator*() const { return currentPoint_; }
49 
51  virtual T north() const
52  {
53  if ((myTopology_->north(currentPoint_)).size()==1)
55  else
56  currentPoint_=T(0);
57  return currentPoint_;
58  } ;
59 
61  virtual T south() const
62  {
63  if ((myTopology_->south(currentPoint_)).size()==1)
65  else
66  currentPoint_=T(0);
67  return currentPoint_;
68  } ;
69 
71  virtual T east() const
72  {
73  if ((myTopology_->east(currentPoint_)).size()==1)
75  else
76  currentPoint_=T(0);
77  return currentPoint_;
78  } ;
79 
81  virtual T west() const
82  {
83  if ((myTopology_->west(currentPoint_)).size()==1)
85  else
86  currentPoint_=T(0);
87  return currentPoint_;
88  } ;
89 
91  virtual T up() const
92  {
93  if ((myTopology_->up(currentPoint_)).size()==1)
95  else
96  currentPoint_=T(0);
97  return currentPoint_;
98  } ;
99 
101  virtual T down() const
102  {
103  if ((myTopology_->down(currentPoint_)).size()==1)
105  else
106  currentPoint_=T(0);
107  return currentPoint_;
108  } ;
109 
111  virtual T offsetBy(int deltaX, int deltaY) const
112  {
113  for(int x=0; x < abs(deltaX) && currentPoint_ != T(0); x++)
114  {
115  if(deltaX > 0) east();
116  else west();
117  }
118 
119  for(int y=0; y < abs(deltaY) && currentPoint_ != T(0); y++)
120  {
121  if(deltaY > 0) north();
122  else south();
123  }
124 
125  return currentPoint_;
126 
127  }
128 
129  protected:
130 
133 };
134 
135 template <class T>
136 void CaloNavigator<T>::setHome(const T& startingPoint)
137 {
138  startingPoint_=startingPoint;
139  home();
140 }
141 
142 template <class T>
144 {
145  currentPoint_=startingPoint_;
146 }
147 
148 template <class T>
150 {
151  if (myTopology_ == 0)
152  myTopology_=topology;
153  else
154  return;
155 }
156 
157 #endif
void setHome(const T &startingPoint)
set the starting position
void home() const
move the navigator back to the starting point
virtual T west() const
move the navigator west
Definition: CaloNavigator.h:81
virtual T up() const
move the navigator west
Definition: CaloNavigator.h:91
virtual std::vector< DetId > west(const DetId &id) const =0
const CaloSubdetectorTopology * myTopology_
#define abs(x)
Definition: mlp_lapack.h:159
virtual T north() const
move the navigator north
Definition: CaloNavigator.h:51
T pos() const
get the current position
Definition: CaloNavigator.h:45
virtual T east() const
move the navigator east
Definition: CaloNavigator.h:71
virtual T down() const
move the navigator west
CaloNavigator()
Default constructor.
Definition: CaloNavigator.h:11
CaloNavigator(const T &home, const CaloSubdetectorTopology *topology)
Definition: CaloNavigator.h:21
virtual T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
void setTopology(const CaloSubdetectorTopology *)
set the starting position
T operator*() const
get the current position
Definition: CaloNavigator.h:48
const CaloSubdetectorTopology * getTopology() const
set the starting position
Definition: CaloNavigator.h:36
virtual std::vector< DetId > north(const DetId &id) const =0
virtual std::vector< DetId > up(const DetId &id) const =0
virtual ~CaloNavigator()
Default constructor.
Definition: CaloNavigator.h:27
CaloNavigator(const T &home)
Definition: CaloNavigator.h:15
virtual std::vector< DetId > south(const DetId &id) const =0
x
Definition: VDTMath.h:216
virtual T south() const
move the navigator south
Definition: CaloNavigator.h:61
long double T
tuple size
Write out results.
virtual std::vector< DetId > east(const DetId &id) const =0
virtual std::vector< DetId > down(const DetId &id) const =0