CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SteeringParams.h
Go to the documentation of this file.
1 #ifndef RecoTracker_MkFitCore_interface_SteeringParams_h
2 #define RecoTracker_MkFitCore_interface_SteeringParams_h
3 
4 #include <vector>
5 #include <stdexcept>
6 
7 namespace mkfit {
8 
9  //==============================================================================
10  // LayerControl
11  //==============================================================================
12 
13  struct LayerControl {
14  int m_layer;
15 
16  // Idea only ... need some parallel structure for candidates to make sense (where i can store it).
17  // Or have per layer containers where I place track indices to enable. Or something. Sigh.
18  // int m_on_miss_jump_to = -999;
19  // int m_on_hit_jump_to = -999;
20 
21  // Used to have pickup-only / bk-fit only bools etc.
22  // Moved to SteeringParams as layer indices where pickup/bkfit/bksrch start/end/start.
23 
24  //----------------------------------------------------------------------------
25 
26  LayerControl() : m_layer(-1) {}
27  LayerControl(int lay) : m_layer(lay) {}
28  };
29 
30  //==============================================================================
31  // SteeringParams
32  //==============================================================================
33 
35  public:
37 
38  class iterator {
39  friend class SteeringParams;
40 
43  int m_cur_index = -1;
44  int m_end_index = -1;
45 
47 
48  public:
50  int layer() const { return layer_control().m_layer; }
51  int index() const { return m_cur_index; }
52  int region() const { return m_steering_params.m_region; }
53 
54  bool is_valid() const { return m_cur_index != -1; }
55 
56  const LayerControl& operator->() const { return layer_control(); }
57 
58  bool is_pickup_only() const {
59  if (m_type == IT_FwdSearch)
61  else if (m_type == IT_BkwSearch)
63  else
64  throw std::runtime_error("invalid iteration type");
65  }
66 
67  bool operator++() {
68  if (!is_valid())
69  return false;
70  if (m_type == IT_FwdSearch) {
71  if (++m_cur_index == m_end_index)
72  m_cur_index = -1;
73  } else {
74  if (--m_cur_index == m_end_index)
75  m_cur_index = -1;
76  }
77  return is_valid();
78  }
79 
80  // Functions for debug printouts
81  int end_index() const { return m_end_index; }
82  int next_layer() const {
83  if (m_type == IT_FwdSearch)
84  return m_steering_params.m_layer_plan[m_cur_index + 1].m_layer;
85  else
86  return m_steering_params.m_layer_plan[m_cur_index - 1].m_layer;
87  }
88  int last_layer() const {
89  if (m_type == IT_FwdSearch)
90  return m_steering_params.m_layer_plan[m_end_index - 1].m_layer;
91  else
92  return m_steering_params.m_layer_plan[m_end_index + 1].m_layer;
93  }
94  };
95 
96  std::vector<LayerControl> m_layer_plan;
97 
98  int m_region;
99 
101  int m_bkw_fit_last = 0;
103 
104  //----------------------------------------------------------------------------
105 
107 
108  void reserve_plan(int n) { m_layer_plan.reserve(n); }
109 
110  void append_plan(int layer) { m_layer_plan.emplace_back(LayerControl(layer)); }
111 
112  void fill_plan(int first, int last) {
113  for (int i = first; i <= last; ++i)
114  append_plan(i);
115  }
116 
117  void set_iterator_limits(int fwd_search_pu, int bkw_fit_last, int bkw_search_pu = -1) {
118  m_fwd_search_pickup = fwd_search_pu;
119  m_bkw_fit_last = bkw_fit_last;
120  m_bkw_search_pickup = bkw_search_pu;
121  }
122 
123  bool has_bksearch_plan() const { return m_bkw_search_pickup != -1; }
124 
126  iterator it(*this, type);
127 
128  if (type == IT_FwdSearch) {
130  it.m_end_index = m_layer_plan.size();
131  } else if (type == IT_BkwFit) {
132  it.m_cur_index = m_layer_plan.size() - 1;
133  it.m_end_index = m_bkw_fit_last - 1;
134  } else if (type == IT_BkwSearch) {
136  it.m_end_index = -1;
137  } else
138  throw std::invalid_argument("unknown iteration type");
139 
140  if (!it.is_valid())
141  throw std::runtime_error("invalid iterator constructed");
142 
143  return it;
144  }
145  };
146 
147 } // end namespace mkfit
148 
149 #endif
bool has_bksearch_plan() const
const LayerControl & operator->() const
void append_plan(int layer)
const SteeringParams & m_steering_params
const LayerControl & layer_control() const
void set_iterator_limits(int fwd_search_pu, int bkw_fit_last, int bkw_search_pu=-1)
constexpr std::array< uint8_t, layerIndexSize > layer
iterator make_iterator(IterationType_e type) const
void fill_plan(int first, int last)
iterator(const SteeringParams &sp, IterationType_e t)
std::vector< LayerControl > m_layer_plan
tuple last
Definition: dqmdumpme.py:56