CMS 3D CMS Logo

TrapezoidalGrouping.h
Go to the documentation of this file.
1 #ifndef Phase2L1Trigger_DTTrigger_TrapezoidalGrouping_h
2 #define Phase2L1Trigger_DTTrigger_TrapezoidalGrouping_h
3 
6 
12 
15 
17 
18 #include <iostream>
19 #include <fstream>
20 #include <stack>
21 
22 // ===============================================================================
23 // Previous definitions and declarations
24 // ===============================================================================
25 
26 /*
27  Channels are labeled following next schema:
28  ---------------------------------
29  | 6 | 7 | 8 | 9 |
30  ---------------------------------
31  | 3 | 4 | 5 |
32  -------------------------
33  | 1 | 2 |
34  -----------------
35  | 0 |
36  ---------
37 */
38 
39 inline bool hitWireSort(const DTPrimitive& hit1, const DTPrimitive& hit2) {
40  int wi1 = hit1.channelId();
41  int wi2 = hit2.channelId();
42 
43  if (wi1 < wi2)
44  return true;
45  else
46  return false;
47 }
48 
49 inline bool hitLayerSort(const DTPrimitive& hit1, const DTPrimitive& hit2) {
50  int lay1 = hit1.layerId();
51  int lay2 = hit2.layerId();
52 
53  if (lay1 < lay2)
54  return true;
55  else if (lay1 > lay2)
56  return false;
57  else
58  return hitWireSort(hit1, hit2);
59 }
60 
61 inline bool hitTimeSort(const DTPrimitive& hit1, const DTPrimitive& hit2) {
62  int tdc1 = hit1.tdcTimeStamp();
63  int tdc2 = hit2.tdcTimeStamp();
64 
65  if (tdc1 < tdc2)
66  return true;
67  else if (tdc1 > tdc2)
68  return false;
69  else
70  return hitLayerSort(hit1, hit2);
71 }
72 
73 namespace dtamgrouping {
74  /* Cell's combination, following previous labeling, to obtain every possible muon's path.
75  Others cells combinations imply non straight paths */
77  {0, 1, 3, 6}, {0, 1, 3, 7}, {0, 1, 4, 7}, {0, 1, 4, 8}, {0, 2, 4, 7}, {0, 2, 4, 8}, {0, 2, 5, 8}, {0, 2, 5, 9}};
78 
79  /* For each of the previous cell's combinations, this array stores the associated cell's
80  displacement, relative to lower layer cell, measured in semi-cell length units */
81 
82  constexpr int CELL_HORIZONTAL_LAYOUTS[8][4] = {{0, -1, -2, -3},
83  {0, -1, -2, -1},
84  {0, -1, 0, -1},
85  {0, -1, 0, 1},
86  {0, 1, 0, -1},
87  {0, 1, 0, 1},
88  {0, 1, 2, 1},
89  {0, 1, 2, 3}};
90 } // namespace dtamgrouping
91 
92 // ===============================================================================
93 // Class declarations
94 // ===============================================================================
95 
97 public:
98  // Constructors and destructor
100  ~TrapezoidalGrouping() override;
101 
102  // Main methods
103  void initialise(const edm::EventSetup& iEventSetup) override;
104  void run(edm::Event& iEvent,
105  const edm::EventSetup& iEventSetup,
106  const DTDigiCollection& digis,
107  MuonPathPtrs& outMpath) override;
108  void finish() override;
109 
110  // Other public methods
111 
112  // Public attributes
113 
114 private:
115  // Private methods
116  void setInChannels(const DTDigiCollection* digi, int sl);
117  std::vector<DTPrimitives> group_hits(DTPrimitive pivot_hit,
118  std::vector<DTPrimitives> input_paths,
119  DTPrimitives hits_per_cell,
120  DTPrimitives& hits_in_trapezoid);
121 
122  // Private attributes
123  const bool debug_;
124 
131 
132  // The trapezoid is as follows:
133  // [ 0 ][ 1 ][ 2 ][ 3 ][ 4 ][ 5 ][ 6 ][ 7 ][ 8 ]
134 
135  // And maps to the physical cells as follows:
136 
137  // Pivot in layer 1 = "00"
138  // [ 5 ][ 6 ][ 7 ][ 8 ] Layer C
139  // [ 2 ][ 3 ][ 4 ] Layer B
140  // [ 0 ][ 1 ] Layer A
141  // Pivot
142 
143  // Pivot in layer 2 = "01"
144  // [ 2 ][ 3 ][ 4 ] Layer B
145  // [ 0 ][ 1 ] Layer A
146  // Pivot
147  // [ 6,8 ][ 5,7 ] Layer C
148 
149  // Pivot in layer 3 = "10"
150  // [ 6,8 ][ 5,7 ] Layer C
151  // Pivot
152  // [ 0 ][ 1 ] Layer A
153  // [ 2 ][ 3 ][ 4 ] Layer B
154 
155  // Pivot in layer 4 = "11"
156  // Pivot
157  // [ 0 ][ 1 ] Layer A
158  // [ 2 ][ 3 ][ 4 ] Layer B
159  // [ 5 ][ 6 ][ 7 ][ 8 ] Layer C
160 
161  short trapezoid_vertical_mapping[4][9] = {{1, 1, 2, 2, 2, 3, 3, 3, 3},
162  {1, 1, 2, 2, 2, -1, -1, -1, -1},
163  {-1, -1, -2, -2, -2, 1, 1, 1, 1},
164  {-1, -1, -2, -2, -2, -3, -3, -3, -3}};
165 
166  short trapezoid_horizontal_mapping[4][9] = {{0, 1, -1, 0, 1, -1, 0, 1, 2},
167  {-1, 0, -1, 0, 1, 0, -1, 0, -1},
168  {0, 1, -1, 0, 1, 1, 0, 1, 0},
169  {-1, 0, -1, 0, 1, -2, -1, 0, 1}};
170 
171  // Task list
172  // 4 hit candidates
173  // 0 => (0,2,5), 1 => (0,2,6), 2 => (0,3,6), 3 => (0,3,7),
174  // 4 => (1,3,6), 5 => (1,3,7), 6 => (1,4,7), 7 => (1,4,8),
175  // the rest are 3-hit candidates, last value not used
176  // 8 => (0,2,0), 9 => (0,3,0), 10 => (1,3,0), 11 => (1,4,0),
177  // 12 => (0,5,0), 13 => (0,6,0), 14 => (0,7,0), 15 => (1,6,0),
178  // 16 => (1,7,0), 17 => (1,8,0), 18 => (2,5,0), 19 => (2,6,0),
179  // 20 => (3,6,0), 21 => (3,7,0), 22 => (4,7,0), 23 => (4,8,0)
180 
181  std::vector<std::vector<short>> task_list = {// 4-hit
182  {0, 2, 5},
183  {0, 2, 6},
184  {0, 3, 6},
185  {0, 3, 7},
186  {1, 3, 6},
187  {1, 3, 7},
188  {1, 4, 7},
189  {1, 4, 8},
190  // 3-hit
191  {0, 2},
192  {0, 3},
193  {1, 3},
194  {1, 4},
195  {0, 5},
196  {0, 6},
197  {0, 7},
198  {1, 6},
199  {1, 7},
200  {1, 8},
201  {2, 5},
202  {2, 6},
203  {3, 6},
204  {3, 7},
205  {4, 7},
206  {4, 8}};
207 
208  int CELL_HORIZONTAL_LAYOUTS_PER_TASK[4][24][4] = { // pivoting over layer 1
209  {// all layers available
210  {0, 0, 0, -1},
211  {0, 0, 1, -1},
212  {0, 1, 0, -1},
213  {0, 1, 1, -1},
214  {1, 0, 0, -1},
215  {1, 0, 1, -1},
216  {1, 1, 0, -1},
217  {1, 1, 1, -1},
218  // layer 4 missing
219  {0, 0, 0, -1},
220  {0, 1, 0, -1},
221  {1, 0, 0, -1},
222  {1, 1, 0, -1},
223  // layer 3 missing
224  {0, 0, 0, -1},
225  {0, 0, 1, -1},
226  {0, 1, 1, -1},
227  {1, 0, 0, -1},
228  {1, 0, 1, -1},
229  {1, 1, 1, -1},
230  // layer 2 missing
231  {0, 0, 0, -1},
232  {0, 0, 1, -1},
233  {0, 1, 0, -1},
234  {0, 1, 1, -1},
235  {1, 1, 0, -1},
236  {1, 1, 1, -1}},
237  // pivoting over layer 2
238  {// all layers available
239  {0, 0, 0, -1},
240  {1, 0, 0, -1},
241  {1, 0, 1, -1},
242  {0, 0, 1, -1},
243  {1, 1, 0, -1},
244  {0, 1, 0, -1},
245  {0, 1, 1, -1},
246  {1, 1, 1, -1},
247  // layer 1 missing
248  {0, 0, 0, -1},
249  {0, 0, 1, -1},
250  {0, 1, 0, -1},
251  {0, 1, 1, -1},
252  // layer 4 missing
253  {0, 0, 0, -1},
254  {1, 0, 0, -1},
255  {0, 0, 0, -1},
256  {1, 1, 0, -1},
257  {0, 1, 0, -1},
258  {1, 1, 0, -1},
259  // layer 3 missing
260  {0, 0, 0, -1},
261  {1, 0, 0, -1},
262  {1, 0, 1, -1},
263  {0, 0, 1, -1},
264  {0, 1, 1, -1},
265  {1, 1, 1, -1}},
266  // pivoting over layer 3
267  {// all layers available
268  {1, 1, 1, -1},
269  {1, 1, 0, -1},
270  {0, 1, 0, -1},
271  {0, 1, 1, -1},
272  {1, 0, 0, -1},
273  {1, 0, 1, -1},
274  {0, 0, 1, -1},
275  {0, 0, 0, -1},
276  // layer 4 missing
277  {1, 1, 0, -1},
278  {0, 1, 0, -1},
279  {1, 0, 0, -1},
280  {0, 0, 0, -1},
281  // layer 1 missing
282  {0, 1, 1, -1},
283  {0, 1, 0, -1},
284  {0, 1, 1, -1},
285  {0, 0, 0, -1},
286  {0, 0, 1, -1},
287  {0, 0, 0, -1},
288  // layer 2 missing
289  {1, 1, 1, -1},
290  {1, 1, 0, -1},
291  {0, 1, 0, -1},
292  {0, 1, 1, -1},
293  {0, 0, 1, -1},
294  {0, 0, 0, -1}},
295  // pivoting over layer 4
296  {// all layers available
297  {1, 1, 1, -1},
298  {0, 1, 1, -1},
299  {1, 0, 1, -1},
300  {0, 0, 1, -1},
301  {1, 1, 0, -1},
302  {0, 1, 0, -1},
303  {1, 0, 0, -1},
304  {0, 0, 0, -1},
305  // layer 1 missing
306  {0, 1, 1, -1},
307  {0, 0, 1, -1},
308  {0, 1, 0, -1},
309  {0, 0, 0, -1},
310  // layer 2 missing
311  {1, 1, 1, -1},
312  {0, 1, 1, -1},
313  {0, 0, 1, -1},
314  {1, 1, 0, -1},
315  {0, 1, 0, -1},
316  {0, 0, 0, -1},
317  // layer 3 missing
318  {1, 1, 1, -1},
319  {0, 1, 1, -1},
320  {1, 0, 1, -1},
321  {0, 0, 1, -1},
322  {1, 0, 0, -1},
323  {0, 0, 0, -1}}};
324 
326  {-1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1},
327  {-1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2},
328  {-1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1},
329  {-1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2}};
330 };
331 
332 #endif
std::vector< std::vector< short > > task_list
bool hitLayerSort(const DTPrimitive &hit1, const DTPrimitive &hit2)
const int channelId() const
Definition: DTprimitive.h:34
void setInChannels(const DTDigiCollection *digi, int sl)
int MISSING_LAYER_LAYOUTS_PER_TASK[4][24]
DTPrimitives muxInChannels_[cmsdt::NUM_CELLS_PER_BLOCK]
short trapezoid_horizontal_mapping[4][9]
std::vector< MuonPathPtr > MuonPathPtrs
Definition: MuonPath.h:132
bool hitTimeSort(const DTPrimitive &hit1, const DTPrimitive &hit2)
const int layerId() const
Definition: DTprimitive.h:35
constexpr int NUM_CELLS_PER_BLOCK
Definition: constants.h:381
int iEvent
Definition: GenABIO.cc:224
bool hitWireSort(const DTPrimitive &hit1, const DTPrimitive &hit2)
TrapezoidalGrouping(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
short trapezoid_vertical_mapping[4][9]
void run(edm::Event &iEvent, const edm::EventSetup &iEventSetup, const DTDigiCollection &digis, MuonPathPtrs &outMpath) override
const int tdcTimeStamp() const
Definition: DTprimitive.h:30
void initialise(const edm::EventSetup &iEventSetup) override
constexpr int CHANNELS_PATH_ARRANGEMENTS[8][4]
constexpr int NUM_CH_PER_LAYER
Definition: constants.h:357
constexpr int CELL_HORIZONTAL_LAYOUTS[8][4]
std::vector< DTPrimitives > group_hits(DTPrimitive pivot_hit, std::vector< DTPrimitives > input_paths, DTPrimitives hits_per_cell, DTPrimitives &hits_in_trapezoid)
std::vector< DTPrimitive > DTPrimitives
Definition: DTprimitive.h:58
DTPrimitives channelIn_[cmsdt::NUM_LAYERS][cmsdt::NUM_CH_PER_LAYER]
int CELL_HORIZONTAL_LAYOUTS_PER_TASK[4][24][4]
constexpr int NUM_LAYERS
Definition: constants.h:358