CMS 3D CMS Logo

CSCMotherboardME11.cc
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // Class: CSCMotherboardME11
4 //
5 // Description:
6 // Extended CSCMotherboard for ME11 to handle ME1a and ME1b separately
7 //
8 // Author List: Vadim Khotilovich 12 May 2009
9 //
10 //
11 //-----------------------------------------------------------------------------
12 
16 
17 
18 
19 // LUT for which ME1/1 wire group can cross which ME1/a halfstrip
20 // 1st index: WG number
21 // 2nd index: inclusive HS range
23 {0, 95},{0, 95},{0, 95},{0, 95},{0, 95},
24 {0, 95},{0, 95},{0, 95},{0, 95},{0, 95},
25 {0, 95},{0, 95},{0, 77},{0, 61},{0, 39},
26 {0, 22},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
27 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
28 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
29 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
30 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
31 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
32 {-1,-1},{-1,-1},{-1,-1} };
33 // a modified LUT for ganged ME1a
35 {0, 31},{0, 31},{0, 31},{0, 31},{0, 31},
36 {0, 31},{0, 31},{0, 31},{0, 31},{0, 31},
37 {0, 31},{0, 31},{0, 31},{0, 31},{0, 31},
38 {0, 22},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
39 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
40 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
41 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
42 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
43 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
44 {-1,-1},{-1,-1},{-1,-1} };
45 
46 // LUT for which ME1/1 wire group can cross which ME1/b halfstrip
47 // 1st index: WG number
48 // 2nd index: inclusive HS range
50 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
51 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
52 {100, 127},{73, 127},{47, 127},{22, 127},{0, 127},
53 {0, 127},{0, 127},{0, 127},{0, 127},{0, 127},
54 {0, 127},{0, 127},{0, 127},{0, 127},{0, 127},
55 {0, 127},{0, 127},{0, 127},{0, 127},{0, 127},
56 {0, 127},{0, 127},{0, 127},{0, 127},{0, 127},
57 {0, 127},{0, 127},{0, 127},{0, 127},{0, 127},
58 {0, 127},{0, 127},{0, 127},{0, 127},{0, 105},
59 {0, 93},{0, 78},{0, 63} };
60 
61 
63  unsigned sector, unsigned subsector,
64  unsigned chamber,
65  const edm::ParameterSet& conf) :
66  CSCMotherboard(endcap, station, sector, subsector, chamber, conf)
67 {
68  edm::ParameterSet commonParams = conf.getParameter<edm::ParameterSet>("commonParam");
69 
70  // special configuration parameters for ME11 treatment
71  smartME1aME1b = commonParams.getParameter<bool>("smartME1aME1b");
72  disableME1a = commonParams.getParameter<bool>("disableME1a");
73  gangedME1a = commonParams.getParameter<bool>("gangedME1a");
74 
75  if (!isSLHC) edm::LogError("L1CSCTPEmulatorConfigError")
76  << "+++ Upgrade CSCMotherboardME11 constructed while isSLHC is not set! +++\n";
77  if (!smartME1aME1b) edm::LogError("L1CSCTPEmulatorConfigError")
78  << "+++ Upgrade CSCMotherboardME11 constructed while smartME1aME1b is not set! +++\n";
79 
80  edm::ParameterSet alctParams = conf.getParameter<edm::ParameterSet>("alctSLHC");
81  edm::ParameterSet clctParams = conf.getParameter<edm::ParameterSet>("clctSLHC");
82  edm::ParameterSet tmbParams = conf.getParameter<edm::ParameterSet>("tmbSLHC");
83 
84  clct1a.reset( new CSCCathodeLCTProcessor(endcap, station, sector, subsector, chamber, clctParams, commonParams, tmbParams) );
85  clct1a->setRing(4);
86 
87  match_earliest_alct_me11_only = tmbParams.getParameter<bool>("matchEarliestAlctME11Only");
88  match_earliest_clct_me11_only = tmbParams.getParameter<bool>("matchEarliestClctME11Only");
89 
90  // if true: use regular CLCT-to-ALCT matching in TMB
91  // if false: do ALCT-to-CLCT matching
92  clct_to_alct = tmbParams.getParameter<bool>("clctToAlct");
93 
94  // whether to not reuse CLCTs that were used by previous matching ALCTs
95  // in ALCT-to-CLCT algorithm
96  drop_used_clcts = tmbParams.getParameter<bool>("tmbDropUsedClcts");
97 
98  tmb_cross_bx_algo = tmbParams.getParameter<unsigned int>("tmbCrossBxAlgorithm");
99 
100  // maximum lcts per BX in ME11: 2, 3, 4 or 999
101  max_me11_lcts = tmbParams.getParameter<unsigned int>("maxME11LCTs");
102 
104  for (unsigned int m=2; m<match_trig_window_size; m+=2)
105  {
106  pref[m-1] = pref[0] - m/2;
107  pref[m] = pref[0] + m/2;
108  }
109 }
110 
111 
113 {
114  // Constructor used only for testing.
115 
116  clct1a.reset( new CSCCathodeLCTProcessor() );
117  clct1a->setRing(4);
118 
120  for (unsigned int m=2; m<match_trig_window_size; m+=2)
121  {
122  pref[m-1] = pref[0] - m/2;
123  pref[m] = pref[0] + m/2;
124  }
125 }
126 
127 
129 {
130 }
131 
132 
134 {
136  if (clct1a) clct1a->clear();
137  for (int bx = 0; bx < CSCConstants::MAX_LCT_TBINS; bx++)
138  {
139  //firstLCT1a[bx].clear();
140  //secondLCT1a[bx].clear();
141  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
142  for (int i=0;i<CSCConstants::MAX_LCTS_PER_CSC;i++)
143  {
144  allLCTs1b[bx][mbx][i].clear();
145  allLCTs1a[bx][mbx][i].clear();
146  }
147  }
148 }
149 
150 // Set configuration parameters obtained via EventSetup mechanism.
152 {
153  alct->setConfigParameters(conf);
154  clct->setConfigParameters(conf);
155  clct1a->setConfigParameters(conf);
156  // No config. parameters in DB for the TMB itself yet.
157 }
158 
159 
161  const CSCComparatorDigiCollection* compdc)
162 {
163  clear();
164 
165  if (!( alct && clct && clct1a && smartME1aME1b))
166  {
167  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorSetupError")
168  << "+++ run() called for non-existing ALCT/CLCT processor! +++ \n";
169  return;
170  }
171 
172  alct->setCSCGeometry(csc_g);
173  clct->setCSCGeometry(csc_g);
174  clct1a->setCSCGeometry(csc_g);
175 
176  alctV = alct->run(wiredc); // run anodeLCT
177  clctV1b = clct->run(compdc); // run cathodeLCT in ME1/b
178  clctV1a = clct1a->run(compdc); // run cathodeLCT in ME1/a
179 
180  //int n_clct_a=0, n_clct_b=0;
181  //if (clct1a->bestCLCT[6].isValid() && clct1a->bestCLCT[6].getBX()==6) n_clct_a++;
182  //if (clct1a->secondCLCT[6].isValid() && clct1a->secondCLCT[6].getBX()==6) n_clct_a++;
183 
184  int used_alct_mask[20], used_alct_mask_1a[20];
185  int used_clct_mask[20], used_clct_mask_1a[20];
186  for (int b=0;b<20;b++)
187  used_alct_mask[b] = used_alct_mask_1a[b] = used_clct_mask[b] = used_clct_mask_1a[b] = 0;
188 
189  // CLCT-centric CLCT-to-ALCT matching
190  if (clct_to_alct) for (int bx_clct = 0; bx_clct < CSCConstants::MAX_CLCT_TBINS; bx_clct++)
191  {
192  // matching in ME1b
193  if (clct->bestCLCT[bx_clct].isValid())
194  {
195  int bx_alct_start = bx_clct - match_trig_window_size/2;
196  int bx_alct_stop = bx_clct + match_trig_window_size/2;
197  for (int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++)
198  {
199  if (bx_alct < 0 || bx_alct >= CSCConstants::MAX_ALCT_TBINS) continue;
200  if (drop_used_alcts && used_alct_mask[bx_alct]) continue;
201  if (alct->bestALCT[bx_alct].isValid())
202  {
203  if (infoV > 1) LogTrace("CSCMotherboard")
204  << "Successful CLCT-ALCT match in ME1b: bx_clct = " << bx_clct
205  << "; match window: [" << bx_alct_start << "; " << bx_alct_stop
206  << "]; bx_alct = " << bx_alct;
207  int mbx = bx_alct_stop - bx_alct;
208  correlateLCTs(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
209  clct->bestCLCT[bx_clct], clct->secondCLCT[bx_clct],
210  allLCTs1b[bx_alct][mbx][0], allLCTs1b[bx_alct][mbx][1], ME1B);
211  if (allLCTs1b[bx_alct][mbx][0].isValid())
212  {
213  used_alct_mask[bx_alct] += 1;
215  }
216  }
217  }
218  // Do not report CLCT-only LCT for ME1b
219  }
220  // matching in ME1a
221  if (clct1a->bestCLCT[bx_clct].isValid())
222  {
223  int bx_alct_start = bx_clct - match_trig_window_size/2;
224  int bx_alct_stop = bx_clct + match_trig_window_size/2;
225  for (int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++)
226  {
227  if (bx_alct < 0 || bx_alct >= CSCConstants::MAX_ALCT_TBINS) continue;
228  if (drop_used_alcts && used_alct_mask_1a[bx_alct]) continue;
229  if (alct->bestALCT[bx_alct].isValid())
230  {
231  if (infoV > 1) LogTrace("CSCMotherboard")
232  << "Successful CLCT-ALCT match in ME1a: bx_clct = " << bx_clct
233  << "; match window: [" << bx_alct_start << "; " << bx_alct_stop
234  << "]; bx_alct = " << bx_alct;
235  int mbx = bx_alct_stop - bx_alct;
236  correlateLCTs(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
237  clct1a->bestCLCT[bx_clct], clct1a->secondCLCT[bx_clct],
238  allLCTs1a[bx_alct][mbx][0], allLCTs1a[bx_alct][mbx][1], ME1A);
239  if (allLCTs1a[bx_alct][mbx][0].isValid())
240  {
241  used_alct_mask_1a[bx_alct] += 1;
243  }
244  }
245  }
246  // Do not report CLCT-only LCT for ME1b
247  }
248  // Do not attempt to make ALCT-only LCT for ME1b
249  } // end of CLCT-centric matching
250 
251  // ALCT-centric ALCT-to-CLCT matching
252  else for (int bx_alct = 0; bx_alct < CSCConstants::MAX_ALCT_TBINS; bx_alct++)
253  {
254  if (alct->bestALCT[bx_alct].isValid())
255  {
256  int bx_clct_start = bx_alct - match_trig_window_size/2;
257  int bx_clct_stop = bx_alct + match_trig_window_size/2;
258 
259  // matching in ME1b
260  for (int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++)
261  {
262  if (bx_clct < 0 || bx_clct >= CSCConstants::MAX_CLCT_TBINS) continue;
263  if (drop_used_clcts && used_clct_mask[bx_clct]) continue;
264  if (clct->bestCLCT[bx_clct].isValid())
265  {
266  if (infoV > 1) LogTrace("CSCMotherboard")
267  << "Successful ALCT-CLCT match in ME1b: bx_alct = " << bx_alct
268  << "; match window: [" << bx_clct_start << "; " << bx_clct_stop
269  << "]; bx_clct = " << bx_clct;
270  int mbx = bx_clct-bx_clct_start;
271  correlateLCTs(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
272  clct->bestCLCT[bx_clct], clct->secondCLCT[bx_clct],
273  allLCTs1b[bx_alct][mbx][0], allLCTs1b[bx_alct][mbx][1], ME1B);
274  if (allLCTs1b[bx_alct][mbx][0].isValid())
275  {
276  used_clct_mask[bx_clct] += 1;
278  }
279  }
280  }
281 
282  // matching in ME1a
283  for (int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++)
284  {
285  if (bx_clct < 0 || bx_clct >= CSCConstants::MAX_CLCT_TBINS) continue;
286  if (drop_used_clcts && used_clct_mask_1a[bx_clct]) continue;
287  if (clct1a->bestCLCT[bx_clct].isValid())
288  {
289  if (infoV > 1) LogTrace("CSCMotherboard")
290  << "Successful ALCT-CLCT match in ME1a: bx_alct = " << bx_alct
291  << "; match window: [" << bx_clct_start << "; " << bx_clct_stop
292  << "]; bx_clct = " << bx_clct;
293  int mbx = bx_clct-bx_clct_start;
294  correlateLCTs(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
295  clct1a->bestCLCT[bx_clct], clct1a->secondCLCT[bx_clct],
296  allLCTs1a[bx_alct][mbx][0], allLCTs1a[bx_alct][mbx][1], ME1A);
297  if (allLCTs1a[bx_alct][mbx][0].isValid())
298  {
299  used_clct_mask_1a[bx_clct] += 1;
301  }
302  }
303  }
304  }
305  } // end of ALCT-centric matching
306 
307  // reduction of nLCTs per each BX
308  for (int bx = 0; bx < CSCConstants::MAX_LCT_TBINS; bx++)
309  {
310  // counting
311  unsigned int n1a=0, n1b=0;
312  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
313  for (int i=0;i<CSCConstants::MAX_LCTS_PER_CSC;i++)
314  {
315  int cbx = bx + mbx - match_trig_window_size/2;
316  if (allLCTs1b[bx][mbx][i].isValid())
317  {
318  n1b++;
319  if (infoV > 0) LogDebug("CSCMotherboard") << "1b LCT"<<i+1<<" "<<bx<<"/"<<cbx<<": "<<allLCTs1b[bx][mbx][i];
320  }
321  if (allLCTs1a[bx][mbx][i].isValid())
322  {
323  n1a++;
324  if (infoV > 0) LogDebug("CSCMotherboard") << "1a LCT"<<i+1<<" "<<bx<<"/"<<cbx<<": "<<allLCTs1a[bx][mbx][i];
325  }
326  }
327  if (infoV > 0 && n1a+n1b>0) LogDebug("CSCMotherboard") <<"bx "<<bx<<" nLCT:"<<n1a<<" "<<n1b<<" "<<n1a+n1b;
328 
329  // some simple cross-bx sorting algorithms
330  if (tmb_cross_bx_algo == 1 && (n1a>2 || n1b>2) )
331  {
332  n1a=0, n1b=0;
333  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
334  for (int i=0;i<CSCConstants::MAX_LCTS_PER_CSC;i++)
335  {
336  if (allLCTs1b[bx][pref[mbx]][i].isValid())
337  {
338  n1b++;
339  if (n1b>2) allLCTs1b[bx][pref[mbx]][i].clear();
340  }
341  if (allLCTs1a[bx][pref[mbx]][i].isValid())
342  {
343  n1a++;
344  if (n1a>2) allLCTs1a[bx][pref[mbx]][i].clear();
345  }
346  }
347 
348  if (infoV > 0) LogDebug("CSCMotherboard") <<"After x-bx sorting:";
349  n1a=0, n1b=0;
350  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
351  for (int i=0;i<CSCConstants::MAX_LCTS_PER_CSC;i++)
352  {
353  int cbx = bx + mbx - match_trig_window_size/2;
354  if (allLCTs1b[bx][mbx][i].isValid())
355  {
356  n1b++;
357  if (infoV > 0) LogDebug("CSCMotherboard") << "1b LCT"<<i+1<<" "<<bx<<"/"<<cbx<<": "<<allLCTs1b[bx][mbx][i];
358  }
359  if (allLCTs1a[bx][mbx][i].isValid())
360  {
361  n1a++;
362  if (infoV > 0) LogDebug("CSCMotherboard") << "1a LCT"<<i+1<<" "<<bx<<"/"<<cbx<<": "<<allLCTs1a[bx][mbx][i];
363  }
364  }
365  if (infoV > 0 && n1a+n1b>0) LogDebug("CSCMotherboard") <<"bx "<<bx<<" nnLCT:"<<n1a<<" "<<n1b<<" "<<n1a+n1b;
366  } // x-bx sorting
367 
368  // Maximum 2 or 3 per whole ME11 per BX case:
369  // (supposedly, now we should have max 2 per bx in each 1a and 1b)
370  if ( n1a+n1b > max_me11_lcts )
371  {
372  // do it simple so far: take all low eta 1/b stubs
373  unsigned int nLCT=n1b;
374  n1a=0;
375  // right now nLCT<=2; cut 1a if necessary
376  for (unsigned int mbx=0; mbx<match_trig_window_size; mbx++)
377  for (int i=0;i<CSCConstants::MAX_LCTS_PER_CSC;i++)
378  if (allLCTs1a[bx][mbx][i].isValid()) {
379  nLCT++;
380  if (nLCT>max_me11_lcts) allLCTs1a[bx][mbx][i].clear();
381  else n1a++;
382  }
383  if (infoV > 0 && nLCT>0) LogDebug("CSCMotherboard") <<"bx "<<bx<<" nnnLCT:"<<n1a<<" "<<n1b<<" "<<n1a+n1b;
384  }
385  }// reduction per bx
386 
387  //if (infoV > 1) LogTrace("CSCMotherboardME11")<<"clct_count E:"<<theEndcap<<"S:"<<theStation<<"R:"<<1<<"C:"
388  // <<CSCTriggerNumbering::chamberFromTriggerLabels(theSector,theSubsector, theStation, theTrigChamber)
389  // <<" a "<<n_clct_a<<" b "<<n_clct_b<<" ab "<<n_clct_a+n_clct_b;
390 }
391 
392 
393 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::readoutLCTs1a()
394 {
395  return readoutLCTs(ME1A);
396 }
397 
398 
399 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::readoutLCTs1b()
400 {
401  return readoutLCTs(ME1B);
402 }
403 
404 
405 // Returns vector of read-out correlated LCTs, if any. Starts with
406 // the vector of all found LCTs and selects the ones in the read-out
407 // time window.
408 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::readoutLCTs(int me1ab)
409 {
410  std::vector<CSCCorrelatedLCTDigi> tmpV;
411 
412  // The start time of the L1A*LCT coincidence window should be related
413  // to the fifo_pretrig parameter, but I am not completely sure how.
414  // Just choose it such that the window is centered at bx=7. This may
415  // need further tweaking if the value of tmb_l1a_window_size changes.
416  //static int early_tbins = 4;
417  // The number of LCT bins in the read-out is given by the
418  // tmb_l1a_window_size parameter, forced to be odd
419  const int lct_bins =
421  const int late_tbins = early_tbins + lct_bins;
422 
423 
424  // Start from the vector of all found correlated LCTs and select
425  // those within the LCT*L1A coincidence window.
426  int bx_readout = -1;
427  std::vector<CSCCorrelatedLCTDigi> all_lcts;
428  if (me1ab == ME1A) all_lcts = getLCTs1a();
429  if (me1ab == ME1B) all_lcts = getLCTs1b();
430  std::vector <CSCCorrelatedLCTDigi>::const_iterator plct = all_lcts.begin();
431  for (; plct != all_lcts.end(); plct++)
432  {
433  if (!plct->isValid()) continue;
434 
435  int bx = (*plct).getBX();
436  // Skip LCTs found too early relative to L1Accept.
437  if (bx <= early_tbins) continue;
438 
439  // Skip LCTs found too late relative to L1Accept.
440  if (bx > late_tbins) continue;
441 
442  // If (readout_earliest_2) take only LCTs in the earliest bx in the read-out window:
443  // in digi->raw step, LCTs have to be packed into the TMB header, and
444  // currently there is room just for two.
445  if (readout_earliest_2 && (bx_readout == -1 || bx == bx_readout) )
446  {
447  tmpV.push_back(*plct);
448  if (bx_readout == -1) bx_readout = bx;
449  }
450  else tmpV.push_back(*plct);
451  }
452  return tmpV;
453 }
454 
455 
456 // Returns vector of found correlated LCTs, if any.
457 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::getLCTs1b()
458 {
459  std::vector<CSCCorrelatedLCTDigi> tmpV;
460 
461  for (int bx = 0; bx < CSCConstants::MAX_LCT_TBINS; bx++)
462  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
463  for (int i=0;i<CSCConstants::MAX_LCTS_PER_CSC;i++)
464  if (allLCTs1b[bx][mbx][i].isValid()) tmpV.push_back(allLCTs1b[bx][mbx][i]);
465  return tmpV;
466 }
467 
468 // Returns vector of found correlated LCTs, if any.
469 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::getLCTs1a()
470 {
471  std::vector<CSCCorrelatedLCTDigi> tmpV;
472 
473  // disabled ME1a
474  if (mpc_block_me1a || disableME1a) return tmpV;
475 
476  // Report all LCTs found.
477  for (int bx = 0; bx < CSCConstants::MAX_LCT_TBINS; bx++)
478  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
479  for (int i=0;i<CSCConstants::MAX_LCTS_PER_CSC;i++)
480  if (allLCTs1a[bx][mbx][i].isValid()) tmpV.push_back(allLCTs1a[bx][mbx][i]);
481  return tmpV;
482 }
483 
484 
486 {
487  if ( !c.isValid() || !a.isValid() ) return false;
488  int key_hs = c.getKeyStrip();
489  int key_wg = a.getKeyWG();
490  if ( me == ME1A )
491  {
492  if ( !gangedME1a )
493  {
494  // wrap around ME11 HS number for -z endcap
495  if (theEndcap==2) key_hs = CSCConstants::MAX_HALF_STRIP_ME1A_UNGANGED - key_hs;
496  if ( key_hs >= lut_wg_vs_hs_me1a[key_wg][0] &&
497  key_hs <= lut_wg_vs_hs_me1a[key_wg][1] ) return true;
498  return false;
499  }
500  else
501  {
502  if (theEndcap==2) key_hs = CSCConstants::MAX_HALF_STRIP_ME1A_GANGED - key_hs;
503  if ( key_hs >= lut_wg_vs_hs_me1ag[key_wg][0] &&
504  key_hs <= lut_wg_vs_hs_me1ag[key_wg][1] ) return true;
505  return false;
506  }
507  }
508  if ( me == ME1B)
509  {
510  if (theEndcap==2) key_hs = CSCConstants::MAX_HALF_STRIP_ME1B - key_hs;
511  if ( key_hs >= lut_wg_vs_hs_me1b[key_wg][0] &&
512  key_hs <= lut_wg_vs_hs_me1b[key_wg][1] ) return true;
513  }
514  return false;
515 }
516 
517 
519  CSCALCTDigi secondALCT,
520  CSCCLCTDigi bestCLCT,
521  CSCCLCTDigi secondCLCT,
522  CSCCorrelatedLCTDigi& lct1,
523  CSCCorrelatedLCTDigi& lct2,
524  int me)
525 {
526  // assume that always anodeBestValid && cathodeBestValid
527 
528  if (secondALCT == bestALCT) secondALCT.clear();
529  if (secondCLCT == bestCLCT) secondCLCT.clear();
530 
531  int ok11 = doesALCTCrossCLCT( bestALCT, bestCLCT, me);
532  int ok12 = doesALCTCrossCLCT( bestALCT, secondCLCT, me);
533  int ok21 = doesALCTCrossCLCT( secondALCT, bestCLCT, me);
534  int ok22 = doesALCTCrossCLCT( secondALCT, secondCLCT, me);
535  int code = (ok11<<3) | (ok12<<2) | (ok21<<1) | (ok22);
536 
537  int dbg=0;
538  int ring = me;
540  CSCDetId did(theEndcap, theStation, ring, chamb, 0);
541  if (dbg) LogTrace("CSCMotherboardME11")<<"debug correlateLCTs in "<<did<<std::endl
542  <<"ALCT1: "<<bestALCT<<std::endl
543  <<"ALCT2: "<<secondALCT<<std::endl
544  <<"CLCT1: "<<bestCLCT<<std::endl
545  <<"CLCT2: "<<secondCLCT<<std::endl
546  <<"ok 11 12 21 22 code = "<<ok11<<" "<<ok12<<" "<<ok21<<" "<<ok22<<" "<<code<<std::endl;
547 
548  if ( code==0 ) return;
549 
550  // LUT defines correspondence between possible ok## combinations
551  // and resulting lct1 and lct2
552  int lut[16][2] = {
553  //ok: 11 12 21 22
554  {0 ,0 }, // 0 0 0 0
555  {22,0 }, // 0 0 0 1
556  {21,0 }, // 0 0 1 0
557  {21,22}, // 0 0 1 1
558  {12,0 }, // 0 1 0 0
559  {12,22}, // 0 1 0 1
560  {12,21}, // 0 1 1 0
561  {12,21}, // 0 1 1 1
562  {11,0 }, // 1 0 0 0
563  {11,22}, // 1 0 0 1
564  {11,21}, // 1 0 1 0
565  {11,22}, // 1 0 1 1
566  {11,12}, // 1 1 0 0
567  {11,22}, // 1 1 0 1
568  {11,12}, // 1 1 1 0
569  {11,22}, // 1 1 1 1
570  };
571 
572  if (dbg) LogTrace("CSCMotherboardME11")<<"lut 0 1 = "<<lut[code][0]<<" "<<lut[code][1]<<std::endl;
573 
574  switch (lut[code][0]) {
575  case 11:
576  lct1 = constructLCTs(bestALCT, bestCLCT, CSCCorrelatedLCTDigi::ALCTCLCT);
577  break;
578  case 12:
579  lct1 = constructLCTs(bestALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT);
580  break;
581  case 21:
582  lct1 = constructLCTs(secondALCT, bestCLCT, CSCCorrelatedLCTDigi::ALCTCLCT);
583  break;
584  case 22:
585  lct1 = constructLCTs(secondALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT);
586  break;
587  default: return;
588  }
589  lct1.setTrknmb(1);
590 
591  if (dbg) LogTrace("CSCMotherboardME11")<<"lct1: "<<lct1<<std::endl;
592 
593  switch (lut[code][1])
594  {
595  case 12:
596  lct2 = constructLCTs(bestALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT);
597  lct2.setTrknmb(2);
598  if (dbg) LogTrace("CSCMotherboardME11")<<"lct2: "<<lct2<<std::endl;
599  return;
600  case 21:
601  lct2 = constructLCTs(secondALCT, bestCLCT, CSCCorrelatedLCTDigi::ALCTCLCT);
602  lct2.setTrknmb(2);
603  if (dbg) LogTrace("CSCMotherboardME11")<<"lct2: "<<lct2<<std::endl;
604  return;
605  case 22:
606  lct2 = constructLCTs(secondALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT);
607  lct2.setTrknmb(2);
608  if (dbg) LogTrace("CSCMotherboardME11")<<"lct2: "<<lct2<<std::endl;
609  return;
610  default: return;
611  }
612  if (dbg) LogTrace("CSCMotherboardME11")<<"out of correlateLCTs"<<std::endl;
613 
614  return;
615 }
616 
#define LogDebug(id)
const unsigned theSector
T getParameter(std::string const &) const
CSCCorrelatedLCTDigi allLCTs1a[CSCConstants::MAX_LCT_TBINS][15][2]
std::vector< CSCCLCTDigi > clctV1a
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc)
void setConfigParameters(const CSCDBL1TPParameters *conf)
std::vector< CSCCorrelatedLCTDigi > readoutLCTs()
unsigned int match_trig_window_size
const unsigned theTrigChamber
bool isValid() const
check ALCT validity (1 - valid ALCT)
Definition: CSCALCTDigi.h:30
unsigned int max_me11_lcts
const unsigned theEndcap
void clear()
clear this ALCT
Definition: CSCALCTDigi.cc:35
static const int lut_wg_vs_hs_me1a[48][2]
std::vector< CSCCorrelatedLCTDigi > getLCTs1b()
const CSCGeometry * csc_g
std::unique_ptr< CSCCathodeLCTProcessor > clct1a
unsigned int mpc_block_me1a
unsigned int tmb_cross_bx_algo
const unsigned theStation
std::vector< CSCALCTDigi > alctV
const unsigned theSubsector
unsigned int tmb_l1a_window_size
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:30
int pref[CSCConstants::MAX_LCT_TBINS]
static const int lut_wg_vs_hs_me1b[48][2]
static const int lut_wg_vs_hs_me1ag[48][2]
#define LogTrace(id)
CSCCorrelatedLCTDigi allLCTs1b[CSCConstants::MAX_LCT_TBINS][15][2]
double b
Definition: hdecay.h:120
std::vector< CSCCorrelatedLCTDigi > getLCTs1a()
std::vector< CSCCLCTDigi > clctV1b
std::unique_ptr< CSCAnodeLCTProcessor > alct
double a
Definition: hdecay.h:121
bool doesALCTCrossCLCT(CSCALCTDigi &a, CSCCLCTDigi &c, int me)
std::unique_ptr< CSCCathodeLCTProcessor > clct
std::vector< CSCCorrelatedLCTDigi > readoutLCTs1b()
void clear()
clear this CLCT
Definition: CSCCLCTDigi.cc:58
int getKeyStrip() const
Definition: CSCCLCTDigi.h:65
CSCCorrelatedLCTDigi constructLCTs(const CSCALCTDigi &aLCT, const CSCCLCTDigi &cLCT, int type) const
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting LCTs.
int getKeyWG() const
return key wire group
Definition: CSCALCTDigi.h:45
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
std::vector< CSCCorrelatedLCTDigi > readoutLCTs1a()
void correlateLCTs(CSCALCTDigi bestALCT, CSCALCTDigi secondALCT, CSCCLCTDigi bestCLCT, CSCCLCTDigi secondCLCT, CSCCorrelatedLCTDigi &lct1, CSCCorrelatedLCTDigi &lct2, int me)