CMS 3D CMS Logo

CSCGEMMotherboard.cc
Go to the documentation of this file.
1 #include <memory>
2 
5  unsigned station,
6  unsigned sector,
7  unsigned subsector,
8  unsigned chamber,
11  drop_low_quality_alct_(conf.tmbParams().getParameter<bool>("dropLowQualityALCTs")),
12  drop_low_quality_clct_(conf.tmbParams().getParameter<bool>("dropLowQualityCLCTs")),
13  build_lct_from_alct_gem_(conf.tmbParams().getParameter<bool>("buildLCTfromALCTandGEM")),
14  build_lct_from_clct_gem_(conf.tmbParams().getParameter<bool>("buildLCTfromCLCTandGEM")) {
15  // case for ME1/1
16  if (isME11_) {
17  drop_low_quality_clct_me1a_ = conf.tmbParams().getParameter<bool>("dropLowQualityCLCTs_ME1a");
18  }
19 
20  alct_gem_bx_window_size_ = conf.tmbParams().getParameter<unsigned>("windowBXALCTGEM");
21  clct_gem_bx_window_size_ = conf.tmbParams().getParameter<unsigned>("windowBXCLCTGEM");
22 
23  assign_gem_csc_bending_ = conf.tmbParams().getParameter<bool>("assignGEMCSCBending");
25 
26  // These LogErrors are sanity checks and should not be printed
27  if (isME11_ and !runME11ILT_) {
28  edm::LogError("CSCGEMMotherboard") << "TMB constructed while runME11ILT_ is not set!";
29  };
30 
31  if (isME21_ and !runME21ILT_) {
32  edm::LogError("CSCGEMMotherboard") << "TMB constructed while runME21ILT_ is not set!";
33  };
34 
35  // super chamber has layer=0!
37 
38  clusterProc_ = std::make_shared<GEMClusterProcessor>(theRegion, theStation, theChamber, conf.conf());
39 
40  cscGEMMatcher_ = std::make_unique<CSCGEMMatcher>(theRegion, theStation, theChamber, conf.tmbParams(), conf.conf());
41 }
42 
44 
46 
47 //function to convert GEM-CSC amended signed slope into Run2 legacy pattern number
49  unsigned sign = std::signbit(slope);
50  unsigned slope_ = abs(slope);
51  uint16_t Run2Pattern = 0;
52 
53  if (slope_ < 3)
54  Run2Pattern = 10;
55  else if (slope_ < 6)
56  Run2Pattern = 8 + sign;
57  else if (slope_ < 9)
58  Run2Pattern = 6 + sign;
59  else if (slope_ < 12)
60  Run2Pattern = 4 + sign;
61  else
62  Run2Pattern = 2 + sign;
63 
64  return Run2Pattern;
65 }
66 
68  const CSCComparatorDigiCollection* compdc,
69  const GEMPadDigiClusterCollection* gemClusters,
70  const RunContext& context) {
71  // Step 1: Setup
72  clear();
73 
74  // check for GEM geometry
75  if (context.gemGeometry_ == nullptr) {
76  edm::LogError("CSCGEMMotherboard") << "run() called for GEM-CSC integrated trigger without valid GEM geometry! \n";
77  return;
78  }
79 
80  // Step 2: Run the processors
81  CSCMotherboard::RunContext mbc{context.cscGeometry_,
82  context.lookupTableCCLUT_,
83  context.lookupTableME11ILT_,
84  context.lookupTableME21ILT_,
85  context.parameters_};
86  auto [alctV, clctV] = runCommon(wiredc, compdc, mbc);
87 
88  // if there are no ALCTs and no CLCTs, do not run the ALCT-CLCT correlation
89  if (alctV.empty() and clctV.empty())
90  return;
91 
92  // Step 3: run the GEM cluster processor to get the internal clusters
93  clusterProc_->run(gemClusters, context.lookupTableME11ILT_, context.lookupTableME21ILT_);
94  hasGE21Geometry16Partitions_ = clusterProc_->hasGE21Geometry16Partitions();
95 
96  // Step 4: ALCT-CLCT-GEM matching
97  matchALCTCLCTGEM(context.lookupTableME11ILT_, context.lookupTableME21ILT_);
98 
99  // Step 5: Select at most 2 LCTs per BX
100  selectLCTs();
101 }
102 
104  const CSCL1TPLookupTableME21ILT* lookupTableME21ILT) {
105  // no matching is done for GE2/1 geometries with 8 eta partitions
106  // this has been superseded by 16-eta partition geometries
108  return;
109 
110  for (int bx_alct = 0; bx_alct < CSCConstants::MAX_ALCT_TBINS; bx_alct++) {
111  // Declaration of all LCTs for this BX:
112 
113  // ALCT + CLCT + GEM
114  CSCCorrelatedLCTDigi LCTbestAbestCgem, LCTbestAsecondCgem, LCTsecondAbestCgem, LCTsecondAsecondCgem;
115  // ALCT + CLCT
116  CSCCorrelatedLCTDigi LCTbestAbestC, LCTbestAsecondC, LCTsecondAbestC, LCTsecondAsecondC;
117  // CLCT + 2 GEM
118  CSCCorrelatedLCTDigi LCTbestCLCTgem, LCTsecondCLCTgem;
119  // ALCT + 2 GEM
120  CSCCorrelatedLCTDigi LCTbestALCTgem, LCTsecondALCTgem;
121 
122  // Construct all the LCTs, selection will come later:
123 
124  CSCALCTDigi bestALCT = alctProc->getBestALCT(bx_alct), secondALCT = alctProc->getSecondALCT(bx_alct);
125  CSCCLCTDigi bestCLCT, secondCLCT;
126  GEMInternalClusters clustersGEM;
127 
128  // Find best and second CLCTs by preferred CLCT BX, taking into account that there is an offset in the simulation
129 
130  unsigned matchingBX = 0;
131  unsigned matching_clctbx = 0;
132  unsigned bx_clct = 0;
133 
134  std::vector<unsigned> clctBx_qualbend_match;
135  sortCLCTByQualBend(bx_alct, clctBx_qualbend_match);
136 
137  bool hasLocalShower = false;
138  for (unsigned ibx = 1; ibx <= match_trig_window_size() / 2; ibx++)
139  hasLocalShower = (hasLocalShower or clctProc->getLocalShowerFlag(bx_alct - CSCConstants::ALCT_CLCT_OFFSET - ibx));
140  // BestCLCT and secondCLCT
141  for (unsigned mbx = 0; mbx < match_trig_window_size(); mbx++) {
142  //bx_clct_run2 would be overflow when bx_alct is small but it is okay
143  unsigned bx_clct_run2 = bx_alct + preferred_bx_match(mbx) - CSCConstants::ALCT_CLCT_OFFSET;
144  unsigned bx_clct_qualbend = clctBx_qualbend_match[mbx];
145  bx_clct = (sort_clct_bx() or not(hasLocalShower)) ? bx_clct_run2 : bx_clct_qualbend;
146 
147  if (bx_clct >= CSCConstants::MAX_CLCT_TBINS)
148  continue;
149  matchingBX = mbx;
150  matching_clctbx = mbx;
151 
152  if ((clctProc->getBestCLCT(bx_clct)).isValid())
153  break;
154  }
155 
156  bestCLCT = clctProc->getBestCLCT(bx_clct);
157  secondCLCT = clctProc->getSecondCLCT(bx_clct);
158 
159  if (!bestALCT.isValid() and !secondALCT.isValid() and !bestCLCT.isValid() and !secondCLCT.isValid())
160  continue;
161  if (!build_lct_from_clct_gem_ and !bestALCT.isValid())
162  continue;
163  if (!build_lct_from_alct_gem_ and !bestCLCT.isValid())
164  continue;
165 
166  if (infoV > 1)
167  LogTrace("CSCGEMMotherboard") << "GEMCSCOTMB: Successful ALCT-CLCT match: bx_alct = " << bx_alct
168  << "; bx_clct = " << matching_clctbx << "; mbx = " << matchingBX << " bestALCT "
169  << bestALCT << " secondALCT " << secondALCT << " bestCLCT " << bestCLCT
170  << " secondCLCT " << secondCLCT;
171  // ALCT + CLCT + GEM
172 
173  for (unsigned gmbx = 0; gmbx < alct_gem_bx_window_size_; gmbx++) {
174  unsigned bx_gem = bx_alct + preferred_bx_match(gmbx);
175  clustersGEM = clusterProc_->getClusters(bx_gem, GEMClusterProcessor::AllClusters);
176  if (!clustersGEM.empty()) {
177  correlateLCTsGEM(bestALCT, bestCLCT, clustersGEM, lookupTableME11ILT, lookupTableME21ILT, LCTbestAbestCgem);
178  correlateLCTsGEM(bestALCT, secondCLCT, clustersGEM, lookupTableME11ILT, lookupTableME21ILT, LCTbestAsecondCgem);
179  correlateLCTsGEM(secondALCT, bestCLCT, clustersGEM, lookupTableME11ILT, lookupTableME21ILT, LCTsecondAbestCgem);
181  secondALCT, secondCLCT, clustersGEM, lookupTableME11ILT, lookupTableME21ILT, LCTsecondAsecondCgem);
182  break;
183  }
184  }
185 
186  // ALCT + CLCT
187 
188  correlateLCTsGEM(bestALCT, bestCLCT, LCTbestAbestC);
189  correlateLCTsGEM(bestALCT, secondCLCT, LCTbestAsecondC);
190  correlateLCTsGEM(secondALCT, bestCLCT, LCTsecondAbestC);
191  correlateLCTsGEM(secondALCT, secondCLCT, LCTsecondAsecondC);
192 
193  // CLCT + 2 GEM
194 
196  unsigned bx_gem = bx_alct;
197 
198  clustersGEM = clusterProc_->getClusters(bx_gem, GEMClusterProcessor::CoincidenceClusters);
199  correlateLCTsGEM(bestCLCT, clustersGEM, lookupTableME11ILT, lookupTableME21ILT, LCTbestCLCTgem);
200  clustersGEM = clusterProc_->getClusters(bx_gem, GEMClusterProcessor::CoincidenceClusters);
201  correlateLCTsGEM(secondCLCT, clustersGEM, lookupTableME11ILT, lookupTableME21ILT, LCTsecondCLCTgem);
202  }
203 
204  // ALCT + 2 GEM
205 
207  for (unsigned gmbx = 0; gmbx < alct_gem_bx_window_size_; gmbx++) {
208  unsigned bx_gem = bx_alct + preferred_bx_match(gmbx);
209  clustersGEM = clusterProc_->getClusters(bx_gem, GEMClusterProcessor::CoincidenceClusters);
210  if (!clustersGEM.empty()) {
211  correlateLCTsGEM(bestALCT, clustersGEM, LCTbestALCTgem);
212  correlateLCTsGEM(secondALCT, clustersGEM, LCTsecondALCTgem);
213  break;
214  }
215  }
216  }
217 
218  // Select LCTs, following FW logic
219 
220  std::vector<CSCCorrelatedLCTDigi> selectedLCTs;
221 
222  // CASE => Only bestALCT is valid
223  if (bestALCT.isValid() and !secondALCT.isValid() and !bestCLCT.isValid() and !secondCLCT.isValid()) {
224  if (LCTbestALCTgem.isValid()) {
225  LCTbestALCTgem.setTrknmb(1);
226  allLCTs_(bx_alct, matchingBX, 0) = LCTbestALCTgem;
227  }
228  }
229 
230  // CASE => Only bestCLCT is valid
231  if (!bestALCT.isValid() and !secondALCT.isValid() and bestCLCT.isValid() and !secondCLCT.isValid()) {
232  if (LCTbestCLCTgem.isValid()) {
233  LCTbestCLCTgem.setTrknmb(1);
234  allLCTs_(bx_alct, matchingBX, 0) = LCTbestCLCTgem;
235  }
236  }
237 
238  // CASE => bestALCT and bestCLCT are valid
239  if (bestALCT.isValid() and !secondALCT.isValid() and bestCLCT.isValid() and !secondCLCT.isValid()) {
240  if (LCTbestAbestCgem.isValid()) {
241  LCTbestAbestCgem.setTrknmb(1);
242  allLCTs_(bx_alct, matchingBX, 0) = LCTbestAbestCgem;
243  } else if (LCTbestAbestC.isValid()) {
244  LCTbestAbestC.setTrknmb(1);
245  allLCTs_(bx_alct, matchingBX, 0) = LCTbestAbestC;
246  }
247  }
248 
249  // CASE => bestALCT, secondALCT, bestCLCT are valid
250  if (bestALCT.isValid() and secondALCT.isValid() and bestCLCT.isValid() and !secondCLCT.isValid()) {
251  CSCCorrelatedLCTDigi lctbb, lctsb;
252  if (LCTbestAbestCgem.isValid())
253  lctbb = LCTbestAbestCgem;
254  else if (LCTbestAbestC.isValid())
255  lctbb = LCTbestAbestC;
256  if (LCTsecondAbestCgem.isValid())
257  lctsb = LCTsecondAbestCgem;
258  else if (LCTsecondAbestC.isValid())
259  lctsb = LCTsecondAbestC;
260 
261  if (lctbb.getQuality() >= lctsb.getQuality() and lctbb.isValid()) {
262  selectedLCTs.push_back(lctbb);
263  if (LCTsecondALCTgem.isValid() and build_lct_from_alct_gem_)
264  selectedLCTs.push_back(LCTsecondALCTgem);
265  else if (LCTsecondAbestC.isValid())
266  selectedLCTs.push_back(LCTsecondAbestC);
267  } else if (lctbb.getQuality() < lctsb.getQuality() and lctsb.isValid()) {
268  selectedLCTs.push_back(lctsb);
269  if (LCTbestALCTgem.isValid() and build_lct_from_alct_gem_)
270  selectedLCTs.push_back(LCTbestALCTgem);
271  else if (LCTbestAbestC.isValid())
272  selectedLCTs.push_back(LCTbestAbestC);
273  }
274 
275  sortLCTs(selectedLCTs);
276 
277  for (unsigned iLCT = 0; iLCT < std::min(unsigned(selectedLCTs.size()), unsigned(CSCConstants::MAX_LCTS_PER_CSC));
278  iLCT++) {
279  if (selectedLCTs[iLCT].isValid()) {
280  selectedLCTs[iLCT].setTrknmb(iLCT + 1);
281  allLCTs_(bx_alct, matchingBX, iLCT) = selectedLCTs[iLCT];
282  }
283  }
284  }
285 
286  // CASE => bestALCT, bestCLCT, secondCLCT are valid
287  if (bestALCT.isValid() and !secondALCT.isValid() and bestCLCT.isValid() and secondCLCT.isValid()) {
288  CSCCorrelatedLCTDigi lctbb, lctbs;
289  if (LCTbestAbestCgem.isValid())
290  lctbb = LCTbestAbestCgem;
291  else if (LCTbestAbestC.isValid())
292  lctbb = LCTbestAbestC;
293  if (LCTbestAsecondCgem.isValid())
294  lctbs = LCTbestAsecondCgem;
295  else if (LCTbestAsecondC.isValid())
296  lctbs = LCTbestAsecondC;
297 
298  if (lctbb.getQuality() >= lctbs.getQuality() and lctbb.isValid()) {
299  selectedLCTs.push_back(lctbb);
300  if (LCTsecondCLCTgem.isValid() and build_lct_from_clct_gem_)
301  selectedLCTs.push_back(LCTsecondCLCTgem);
302  else if (LCTbestAsecondC.isValid())
303  selectedLCTs.push_back(LCTbestAsecondC);
304  } else if (lctbb.getQuality() < lctbs.getQuality() and lctbs.isValid()) {
305  selectedLCTs.push_back(lctbs);
306  if (LCTbestCLCTgem.isValid() and build_lct_from_alct_gem_)
307  selectedLCTs.push_back(LCTbestCLCTgem);
308  else if (LCTbestAbestC.isValid())
309  selectedLCTs.push_back(LCTbestAbestC);
310  }
311 
312  sortLCTs(selectedLCTs);
313 
314  for (unsigned iLCT = 0; iLCT < std::min(unsigned(selectedLCTs.size()), unsigned(CSCConstants::MAX_LCTS_PER_CSC));
315  iLCT++) {
316  if (selectedLCTs[iLCT].isValid()) {
317  selectedLCTs[iLCT].setTrknmb(iLCT + 1);
318  allLCTs_(bx_alct, matchingBX, iLCT) = selectedLCTs[iLCT];
319  }
320  }
321  }
322 
323  // CASE => bestALCT, secondALCT, bestCLCT, secondCLCT are valid
324  if (bestALCT.isValid() and secondALCT.isValid() and bestCLCT.isValid() and secondCLCT.isValid()) {
325  CSCCorrelatedLCTDigi lctbb, lctbs, lctsb, lctss;
326 
327  // compute LCT bestA-bestC
328  if (LCTbestAbestCgem.isValid())
329  lctbb = LCTbestAbestCgem;
330  else if (LCTbestAbestC.isValid())
331  lctbb = LCTbestAbestC;
332 
333  // compute LCT bestA-secondC
334  if (LCTbestAsecondCgem.isValid())
335  lctbs = LCTbestAsecondCgem;
336  else if (LCTbestAsecondC.isValid())
337  lctbs = LCTbestAsecondC;
338 
339  if (lctbb.getQuality() >= lctbs.getQuality()) {
340  // push back LCT bestA-bestC
341  selectedLCTs.push_back(lctbb);
342 
343  // compute LCT secondA-secondC
344  if (LCTsecondAsecondCgem.isValid())
345  lctss = LCTsecondAsecondCgem;
346  else if (LCTsecondAsecondC.isValid())
347  lctss = LCTsecondAsecondC;
348 
349  // push back LCT secondA-secondC
350  selectedLCTs.push_back(lctss);
351  } else {
352  // push back LCT bestA-secondC
353  selectedLCTs.push_back(lctbs);
354 
355  // compute LCT secondA-bestC
356  if (LCTsecondAbestCgem.isValid())
357  lctsb = LCTsecondAbestCgem;
358  else if (LCTsecondAbestC.isValid())
359  lctsb = LCTsecondAbestC;
360 
361  // push back LCT secondA-bestC
362  selectedLCTs.push_back(lctsb);
363  }
364 
365  sortLCTs(selectedLCTs);
366 
367  for (unsigned iLCT = 0; iLCT < std::min(unsigned(selectedLCTs.size()), unsigned(CSCConstants::MAX_LCTS_PER_CSC));
368  iLCT++) {
369  if (selectedLCTs[iLCT].isValid()) {
370  selectedLCTs[iLCT].setTrknmb(iLCT + 1);
371  allLCTs_(bx_alct, matchingBX, iLCT) = selectedLCTs[iLCT];
372  }
373  }
374  }
375  }
376 }
377 
378 // Correlate CSC and GEM information. Option ALCT-CLCT-GEM
380  const CSCCLCTDigi& CLCT,
382  const CSCL1TPLookupTableME11ILT* lookupTableME11ILT,
383  const CSCL1TPLookupTableME21ILT* lookupTableME21ILT,
384  CSCCorrelatedLCTDigi& lct) const {
385  // Sanity checks on ALCT, CLCT, GEM clusters
386  if (!ALCT.isValid()) {
387  LogTrace("CSCGEMMotherboard") << "Best ALCT invalid in correlateLCTsGEM";
388  return;
389  }
390 
391  if (!CLCT.isValid()) {
392  LogTrace("CSCGEMMotherboard") << "Best CLCT invalid in correlateLCTsGEM";
393  return;
394  }
395 
396  GEMInternalClusters ValidClusters;
397  for (const auto& cl : clusters)
398  if (cl.isValid())
399  ValidClusters.push_back(cl);
400  if (ValidClusters.empty())
401  return;
402 
403  // We can now check possible triplets and construct all LCTs with
404  // valid ALCT, valid CLCTs and GEM clusters
405  GEMInternalCluster bestCluster;
406  cscGEMMatcher_->bestClusterLoc(ALCT, CLCT, ValidClusters, lookupTableME11ILT, lookupTableME21ILT, bestCluster);
407  if (bestCluster.isValid())
408  constructLCTsGEM(ALCT, CLCT, bestCluster, lookupTableME11ILT, lookupTableME21ILT, lct);
409 }
410 
411 // Correlate CSC information. Option ALCT-CLCT
413  const CSCCLCTDigi& CLCT,
414  CSCCorrelatedLCTDigi& lct) const {
415  // Sanity checks on ALCT, CLCT
416  if (!ALCT.isValid() or (ALCT.getQuality() == 0 and drop_low_quality_alct_)) {
417  LogTrace("CSCGEMMotherboard") << "Best ALCT invalid in correlateLCTsGEM";
418  return;
419  }
420 
421  bool dropLowQualityCLCT = drop_low_quality_clct_;
423  dropLowQualityCLCT = drop_low_quality_clct_me1a_;
424 
425  if (!CLCT.isValid() or (CLCT.getQuality() <= 3 and dropLowQualityCLCT)) {
426  LogTrace("CSCGEMMotherboard") << "Best CLCT invalid in correlateLCTsGEM";
427  return;
428  }
429 
430  // construct LCT
431  if (match_trig_enable() and doesALCTCrossCLCT(ALCT, CLCT)) {
432  constructLCTsGEM(ALCT, CLCT, lct);
433  }
434 }
435 
436 // Correlate CSC and GEM information. Option CLCT-GEM
439  const CSCL1TPLookupTableME11ILT* lookupTableME11ILT,
440  const CSCL1TPLookupTableME21ILT* lookupTableME21ILT,
441  CSCCorrelatedLCTDigi& lct) const {
442  // Sanity checks on CLCT, GEM clusters
443  bool dropLowQualityCLCT = drop_low_quality_clct_;
445  dropLowQualityCLCT = drop_low_quality_clct_me1a_;
446 
447  if (!CLCT.isValid() or (CLCT.getQuality() <= 3 and dropLowQualityCLCT)) {
448  LogTrace("CSCGEMMotherboard") << "Best CLCT invalid in correlateLCTsGEM";
449  return;
450  }
451 
452  GEMInternalClusters ValidClusters;
453  for (const auto& cl : clusters)
454  if (cl.isValid())
455  ValidClusters.push_back(cl);
456  if (ValidClusters.empty())
457  return;
458 
459  // get the best matching cluster
460  GEMInternalCluster bestCluster;
461  cscGEMMatcher_->bestClusterLoc(CLCT, ValidClusters, lookupTableME11ILT, lookupTableME21ILT, bestCluster);
462 
463  // construct all LCTs with valid CLCTs and coincidence clusters
464  if (bestCluster.isCoincidence()) {
465  constructLCTsGEM(CLCT, bestCluster, lookupTableME11ILT, lookupTableME21ILT, lct);
466  }
467 }
468 
469 // Correlate CSC and GEM information. Option ALCT-GEM
472  CSCCorrelatedLCTDigi& lct) const {
473  // Sanity checks on ALCT, GEM clusters
474  if (!ALCT.isValid() or (ALCT.getQuality() == 0 and drop_low_quality_alct_)) {
475  LogTrace("CSCGEMMotherboard") << "Best ALCT invalid in correlateLCTsGEM";
476  return;
477  }
478 
479  GEMInternalClusters ValidClusters;
480  for (const auto& cl : clusters)
481  if (cl.isValid())
482  ValidClusters.push_back(cl);
483  if (ValidClusters.empty())
484  return;
485 
486  // get the best matching cluster
487  GEMInternalCluster bestCluster;
488  cscGEMMatcher_->bestClusterLoc(ALCT, ValidClusters, bestCluster);
489 
490  // construct all LCTs with valid ALCTs and coincidence clusters
491  if (bestCluster.isCoincidence()) {
492  constructLCTsGEM(ALCT, bestCluster, lct);
493  }
494 }
495 
496 // Construct LCT from CSC and GEM information. Option ALCT-CLCT-GEM
498  const CSCCLCTDigi& clct,
499  const GEMInternalCluster& gem,
500  const CSCL1TPLookupTableME11ILT* lookupTableME11ILT,
501  const CSCL1TPLookupTableME21ILT* lookupTableME21ILT,
502  CSCCorrelatedLCTDigi& thisLCT) const {
503  thisLCT.setValid(true);
504  if (gem.isCoincidence())
506  else if (gem.isValid())
508  thisLCT.setQuality(qualityAssignment_->findQuality(alct, clct, gem));
509  thisLCT.setALCT(getBXShiftedALCT(alct));
510  thisLCT.setCLCT(getBXShiftedCLCT(clct));
511  // set pads if there are any
512  thisLCT.setGEM1(gem.mid1());
513  thisLCT.setGEM2(gem.mid2());
514  thisLCT.setPattern(encodePattern(clct.getPattern()));
515  thisLCT.setMPCLink(0);
516  thisLCT.setBX0(0);
517  thisLCT.setSyncErr(0);
518  thisLCT.setCSCID(theTrigChamber);
519  thisLCT.setTrknmb(0); // will be set later after sorting
520  thisLCT.setWireGroup(alct.getKeyWG());
521  thisLCT.setStrip(clct.getKeyStrip());
522  thisLCT.setBend(clct.getBend());
523  thisLCT.setBX(alct.getBX());
524  if (runCCLUT_) {
525  thisLCT.setRun3(true);
527  gem.isValid()) { //calculate new slope from strip difference between CLCT and associated GEM
528  int slope = cscGEMMatcher_->calculateGEMCSCBending(clct, gem, lookupTableME11ILT, lookupTableME21ILT);
529  thisLCT.setSlope(abs(slope));
530  thisLCT.setBend(std::signbit(slope));
532  } else
533  thisLCT.setSlope(clct.getSlope());
534  thisLCT.setQuartStripBit(clct.getQuartStripBit());
535  thisLCT.setEighthStripBit(clct.getEighthStripBit());
536  thisLCT.setRun3Pattern(clct.getRun3Pattern());
537  }
538 }
539 
540 // Construct LCT from CSC and GEM information. Option ALCT-CLCT
542  const CSCCLCTDigi& cLCT,
543  CSCCorrelatedLCTDigi& thisLCT) const {
544  thisLCT.setValid(true);
546  thisLCT.setALCT(getBXShiftedALCT(aLCT));
547  thisLCT.setCLCT(getBXShiftedCLCT(cLCT));
548  thisLCT.setPattern(encodePattern(cLCT.getPattern()));
549  thisLCT.setMPCLink(0);
550  thisLCT.setBX0(0);
551  thisLCT.setSyncErr(0);
552  thisLCT.setCSCID(theTrigChamber);
553  thisLCT.setTrknmb(0); // will be set later after sorting
554  thisLCT.setWireGroup(aLCT.getKeyWG());
555  thisLCT.setStrip(cLCT.getKeyStrip());
556  thisLCT.setBend(cLCT.getBend());
557  thisLCT.setBX(aLCT.getBX());
558  thisLCT.setQuality(qualityAssignment_->findQuality(aLCT, cLCT));
559  if (runCCLUT_) {
560  thisLCT.setRun3(true);
561  // 4-bit slope value derived with the CCLUT algorithm
562  thisLCT.setSlope(cLCT.getSlope());
563  thisLCT.setQuartStripBit(cLCT.getQuartStripBit());
564  thisLCT.setEighthStripBit(cLCT.getEighthStripBit());
565  thisLCT.setRun3Pattern(cLCT.getRun3Pattern());
566  }
567 }
568 
569 // Construct LCT from CSC and GEM information. Option CLCT-2GEM
571  const GEMInternalCluster& gem,
572  const CSCL1TPLookupTableME11ILT* lookupTableME11ILT,
573  const CSCL1TPLookupTableME21ILT* lookupTableME21ILT,
574  CSCCorrelatedLCTDigi& thisLCT) const {
575  thisLCT.setValid(true);
577  thisLCT.setQuality(qualityAssignment_->findQuality(clct, gem));
578  thisLCT.setCLCT(getBXShiftedCLCT(clct));
579  thisLCT.setGEM1(gem.mid1());
580  thisLCT.setGEM2(gem.mid2());
581  thisLCT.setPattern(encodePattern(clct.getPattern()));
582  thisLCT.setMPCLink(0);
583  thisLCT.setBX0(0);
584  thisLCT.setSyncErr(0);
585  thisLCT.setCSCID(theTrigChamber);
586  thisLCT.setTrknmb(0); // will be set later after sorting
587  thisLCT.setWireGroup(gem.getKeyWG());
588  thisLCT.setStrip(clct.getKeyStrip());
589  thisLCT.setBend(clct.getBend());
590  thisLCT.setBX(gem.bx());
591  if (runCCLUT_) {
592  thisLCT.setRun3(true);
594  gem.isValid()) { //calculate new slope from strip difference between CLCT and associated GEM
595  int slope = cscGEMMatcher_->calculateGEMCSCBending(clct, gem, lookupTableME11ILT, lookupTableME21ILT);
596  thisLCT.setSlope(abs(slope));
597  thisLCT.setBend(pow(-1, std::signbit(slope)));
599  } else
600  thisLCT.setSlope(clct.getSlope());
601  thisLCT.setQuartStripBit(clct.getQuartStripBit());
602  thisLCT.setEighthStripBit(clct.getEighthStripBit());
603  thisLCT.setRun3Pattern(clct.getRun3Pattern());
604  }
605 }
606 
607 // Construct LCT from CSC and GEM information. Option ALCT-2GEM
609  const GEMInternalCluster& gem,
610  CSCCorrelatedLCTDigi& thisLCT) const {
611  thisLCT.setValid(true);
613  thisLCT.setQuality(qualityAssignment_->findQuality(alct, gem));
614  thisLCT.setALCT(getBXShiftedALCT(alct));
615  thisLCT.setGEM1(gem.mid1());
616  thisLCT.setGEM2(gem.mid2());
617  thisLCT.setPattern(10);
618  thisLCT.setMPCLink(0);
619  thisLCT.setBX0(0);
620  thisLCT.setSyncErr(0);
621  thisLCT.setCSCID(theTrigChamber);
622  thisLCT.setTrknmb(0); // will be set later after sorting
623  thisLCT.setWireGroup(alct.getKeyWG());
624  thisLCT.setStrip(gem.getKeyStrip());
625  thisLCT.setBend(0);
626  thisLCT.setBX(alct.getBX());
627  if (runCCLUT_) {
628  thisLCT.setRun3(true);
629  thisLCT.setSlope(0);
630  thisLCT.setQuartStripBit(false);
631  thisLCT.setEighthStripBit(false);
632  // ALCT-2GEM type LCTs do not bend in the chamber
633  thisLCT.setRun3Pattern(4);
634  }
635 }
636 
637 void CSCGEMMotherboard::sortLCTs(std::vector<CSCCorrelatedLCTDigi>& lcts) const {
638  // LCTs are sorted by quality. If there are two with the same quality, then the sorting is done by the slope
639  std::sort(lcts.begin(), lcts.end(), [](const CSCCorrelatedLCTDigi& lct1, const CSCCorrelatedLCTDigi& lct2) -> bool {
640  if (lct1.getQuality() > lct2.getQuality())
641  return lct1.getQuality() > lct2.getQuality();
642  else if (lct1.getQuality() == lct2.getQuality())
643  return lct1.getSlope() < lct2.getSlope();
644  else
645  return false;
646  });
647 }
bool isCoincidence() const
uint16_t Run2PatternConverter(const int slope) const
bool isValid() const
check ALCT validity (1 - valid ALCT)
Definition: CSCALCTDigi.h:40
LCTContainer allLCTs_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void setPattern(const uint16_t p)
set pattern
void setALCT(const CSCALCTDigi &alct)
std::unique_ptr< CSCGEMMatcher > cscGEMMatcher_
uint16_t getBX() const
return BX - five low bits of BXN counter tagged by the ALCT
Definition: CSCALCTDigi.h:73
void setGEM2(const GEMPadDigi &gem)
int preferred_bx_match(unsigned int index) const
unsigned int encodePattern(const int clctPattern) const
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
unsigned alct_gem_bx_window_size_
std::tuple< std::vector< CSCALCTDigi >, std::vector< CSCCLCTDigi > > runCommon(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const RunContext &context)
uint16_t getSlope() const
return the slope
void setSlope(const uint16_t slope)
set the slope
static const double slope[3]
uint16_t getQuality() const
return quality of a pattern (number of layers hit!)
Definition: CSCCLCTDigi.h:56
uint16_t getKeyStrip(const uint16_t n=2) const
Definition: CSCCLCTDigi.cc:107
void setQuartStripBit(const bool quartStripBit)
set single quart strip bit
bool getEighthStripBit() const
get single eighth strip bit
Definition: CSCCLCTDigi.h:114
void setEighthStripBit(const bool eighthStripBit)
set single eighth strip bit
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const GEMPadDigiClusterCollection *gemPads, RunContext const &)
constexpr int pow(int x)
Definition: conifer.h:24
void setBend(const uint16_t b)
set bend
std::unique_ptr< CSCCathodeLCTProcessor > clctProc
Log< level::Error, false > LogError
void setValid(const uint16_t v)
set valid
#define LogTrace(id)
CSCCLCTDigi getBXShiftedCLCT(const CSCCLCTDigi &) const
void setMPCLink(const uint16_t &link)
Set mpc link number after MPC sorting.
void correlateLCTsGEM(const CSCALCTDigi &ALCT, const CSCCLCTDigi &CLCT, const GEMInternalClusters &clusters, const CSCL1TPLookupTableME11ILT *lookupTableME11ILT, const CSCL1TPLookupTableME21ILT *lookupTableME21ILT, CSCCorrelatedLCTDigi &lct) const
bool getQuartStripBit() const
get single quart strip bit
Definition: CSCCLCTDigi.h:108
const unsigned theTrigChamber
Definition: CSCBaseboard.h:78
void setWireGroup(const uint16_t wiregroup)
set wiregroup number
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
uint16_t getKeyWG() const
return key wire group
Definition: CSCALCTDigi.h:67
edm::ParameterSet const & tmbParams() const
Definition: CSCBaseboard.h:22
uint16_t getBend() const
Definition: CSCCLCTDigi.h:93
void constructLCTsGEM(const CSCALCTDigi &alct, const CSCCLCTDigi &clct, const GEMInternalCluster &gem, const CSCL1TPLookupTableME11ILT *lookupTableME11ILT, const CSCL1TPLookupTableME21ILT *lookupTableME21ILT, CSCCorrelatedLCTDigi &lct) const
bool isValid() const
return valid pattern bit
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< GEMInternalCluster > GEMInternalClusters
void setRun3Pattern(const uint16_t pattern)
set Run-3 pattern
unsigned theChamber
Definition: CSCBaseboard.h:81
void setBX0(const uint16_t b)
set bx0
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:50
uint16_t getQuality() const
return the Quality
unsigned int match_trig_window_size() const
void setCSCID(const uint16_t c)
set cscID
void setRun3(const bool isRun3)
void sortLCTs(std::vector< CSCCorrelatedLCTDigi > &lcts) const
bool doesALCTCrossCLCT(const CSCALCTDigi &, const CSCCLCTDigi &) const
void sortCLCTByQualBend(int alct_bx, std::vector< unsigned > &clctBxVector)
void setBX(const uint16_t b)
set bx
unsigned int match_trig_enable() const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const unsigned theStation
Definition: CSCBaseboard.h:75
uint16_t getPattern() const
return pattern
Definition: CSCCLCTDigi.h:62
std::shared_ptr< GEMClusterProcessor > clusterProc_
bool sort_clct_bx() const
edm::ParameterSet const & conf() const
Definition: CSCBaseboard.h:18
std::unique_ptr< CSCAnodeLCTProcessor > alctProc
uint16_t getSlope() const
return the slope
Definition: CSCCLCTDigi.h:74
void setStrip(const uint16_t s)
set strip
void matchALCTCLCTGEM(const CSCL1TPLookupTableME11ILT *lookupTableME11ILT, const CSCL1TPLookupTableME21ILT *lookupTableME21ILT)
uint16_t getRun3Pattern() const
return pattern
Definition: CSCCLCTDigi.h:68
unsigned clct_gem_bx_window_size_
void setQuality(const uint16_t q)
set quality code
CSCALCTDigi getBXShiftedALCT(const CSCALCTDigi &) const
~CSCGEMMotherboard() override
CSCGEMMotherboard(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, unsigned chamber, CSCBaseboard::Parameters &conf)
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting LCTs.
void setCLCT(const CSCCLCTDigi &clct)
void setGEM1(const GEMPadDigi &gem)
void setSyncErr(const uint16_t s)
set syncErr
std::unique_ptr< LCTQualityAssignment > qualityAssignment_