CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
NavigationSchool.h
Go to the documentation of this file.
1 #ifndef DetLayers_NavigationSchool_H
2 #define DetLayers_NavigationSchool_H
3 
4 #include <vector>
5 
6 #include "NavigableLayer.h"
7 #include "DetLayer.h"
8 
9 #include <iostream>
10 #include <typeinfo>
11 
19 public:
21  // std::cout << "NVSH: C "<< this << std::endl;
22  }
23 
24  virtual ~NavigationSchool() {}
25 
26  typedef std::vector<NavigableLayer*> StateType;
27 
28  virtual StateType navigableLayers() = 0;
29 
32  template <typename... Args>
33  std::vector<const DetLayer*> nextLayers(const DetLayer& detLayer, Args&&... args) const {
34  assert(detLayer.seqNum() >= 0);
35  auto nl = theAllNavigableLayer[detLayer.seqNum()];
36  return nl ? nl->nextLayers(std::forward<Args>(args)...) : std::vector<const DetLayer*>();
37  }
38 
40  template <typename... Args>
41  std::vector<const DetLayer*> compatibleLayers(const DetLayer& detLayer, Args&&... args) const {
42  auto nl = theAllNavigableLayer[detLayer.seqNum()];
43  return nl ? nl->compatibleLayers(std::forward<Args>(args)...) : std::vector<const DetLayer*>();
44  }
45 
46 protected:
47  void setState(const StateType& state) {
48  // std::cout << "NVSH: set "<< this << ' ' << typeid(*this).name()
49  // << ' ' << state.size() << ' ' << theAllNavigableLayer.size() << std::endl;
50 
51  for (auto nl : state) {
52  if (!nl)
53  continue;
54  theAllNavigableLayer[nl->detLayer()->seqNum()] = nl;
55  nl->setSchool(this);
56  }
57  }
58 
59  // index correspond to seqNum of DetLayers
61 
62  // will be obsoleted together with NAvigationSetter
63 public:
64  const std::vector<const DetLayer*>& allLayersInSystem() const { return *theAllDetLayersInSystem; }
65 
66 protected:
67  const std::vector<const DetLayer*>* theAllDetLayersInSystem;
68 };
69 
70 #endif // NavigationSchool_H
const std::vector< const DetLayer * > & allLayersInSystem() const
assert(be >=bs)
int seqNum() const
Definition: DetLayer.h:35
StateType theAllNavigableLayer
std::vector< const DetLayer * > compatibleLayers(const DetLayer &detLayer, Args &&...args) const
Returns all layers compatible.
std::vector< NavigableLayer * > StateType
virtual ~NavigationSchool()
const std::vector< const DetLayer * > * theAllDetLayersInSystem
virtual StateType navigableLayers()=0
std::vector< const DetLayer * > nextLayers(const DetLayer &detLayer, Args &&...args) const
void setState(const StateType &state)