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,
9  const edm::ParameterSet& conf)
10  : CSCMotherboard(endcap, station, sector, subsector, chamber, conf),
11  drop_low_quality_alct_no_gems_(tmbParams_.getParameter<bool>("dropLowQualityALCTsNoGEMs")),
12  drop_low_quality_clct_no_gems_(tmbParams_.getParameter<bool>("dropLowQualityCLCTsNoGEMs")),
13  build_lct_from_alct_gem_(tmbParams_.getParameter<bool>("buildLCTfromALCTandGEM")),
14  build_lct_from_clct_gem_(tmbParams_.getParameter<bool>("buildLCTfromCLCTandGEM")) {
15  // case for ME1/1
16  if (isME11_) {
17  drop_low_quality_clct_no_gems_me1a_ = tmbParams_.getParameter<bool>("dropLowQualityCLCTsNoGEMs_ME1a");
18  build_lct_from_clct_gem_me1a_ = tmbParams_.getParameter<bool>("buildLCTfromCLCTandGEM_ME1a");
19  }
20 
21  max_delta_bx_alct_gem_ = tmbParams_.getParameter<unsigned>("maxDeltaBXALCTGEM");
22  max_delta_bx_clct_gem_ = tmbParams_.getParameter<unsigned>("maxDeltaBXCLCTGEM");
23 
24  assign_gem_csc_bending_ = tmbParams_.getParameter<bool>("assignGEMCSCBending");
26 
27  drop_used_gems_ = tmbParams_.getParameter<bool>("tmbDropUsedGems");
28  match_earliest_gem_only_ = tmbParams_.getParameter<bool>("matchEarliestGemsOnly");
29 
30  // These LogErrors are sanity checks and should not be printed
31  if (isME11_ and !runME11ILT_) {
32  edm::LogError("CSCGEMMotherboard") << "TMB constructed while runME11ILT_ is not set!";
33  };
34 
35  if (isME21_ and !runME21ILT_) {
36  edm::LogError("CSCGEMMotherboard") << "TMB constructed while runME21ILT_ is not set!";
37  };
38 
39  // super chamber has layer=0!
41 
42  clusterProc_ = std::make_shared<GEMClusterProcessor>(theRegion, theStation, theChamber, conf);
43 
44  cscGEMMatcher_ = std::make_unique<CSCGEMMatcher>(theRegion, theStation, theChamber, tmbParams_, conf);
45 }
46 
48 
51  clusterProc_->clear();
52 }
53 
55  const CSCComparatorDigiCollection* compdc,
56  const GEMPadDigiClusterCollection* gemClusters) {
57  // Step 1: Setup
58  clear();
59 
60  // check for GEM geometry
61  if (gem_g == nullptr) {
62  edm::LogError("CSCGEMMotherboard") << "run() called for GEM-CSC integrated trigger without valid GEM geometry! \n";
63  return;
64  }
65 
66  // Check that the processors can deliver data
67  if (!(alctProc and clctProc)) {
68  edm::LogError("CSCGEMMotherboard") << "run() called for non-existing ALCT/CLCT processor! \n";
69  return;
70  }
71 
72  alctProc->setCSCGeometry(cscGeometry_);
73  clctProc->setCSCGeometry(cscGeometry_);
74 
75  // Step 2: Run the processors
76  const std::vector<CSCALCTDigi>& alctV = alctProc->run(wiredc); // run anodeLCT
77  const std::vector<CSCCLCTDigi>& clctV = clctProc->run(compdc); // run cathodeLCT
78 
79  // Step 2b: encode high multiplicity bits (independent of LCT construction)
81 
82  // if there are no ALCTs and no CLCTs, do not run the ALCT-CLCT correlation
83  if (alctV.empty() and clctV.empty())
84  return;
85 
86  // Step 3: run the GEM cluster processor to get the internal clusters
87  clusterProc_->run(gemClusters);
88  hasGE21Geometry16Partitions_ = clusterProc_->hasGE21Geometry16Partitions();
89 
90  /*
91  Mask for bunch crossings were LCTs were previously found
92  If LCTs were found in BXi for ALCT-CLCT-2GEM, ALCT-CLCT-1GEM
93  or ALCT-CLCT matches, we do not consider BXi in the future. This is
94  because we consider ALCT-CLCT-2GEM, ALCT-CLCT-1GEM, ALCT-CLCT of
95  higher quality than CLCT-2GEM and ALCT-2GEM LCTs. The mask is passsed
96  from one function to the next.
97  */
98  bool bunch_crossing_mask[CSCConstants::MAX_ALCT_TBINS] = {false};
99 
100  // Step 4: ALCT-centric matching
101  matchALCTCLCTGEM(bunch_crossing_mask);
102 
103  // Step 5: CLCT-2GEM matching for BX's that were not previously masked
105  matchCLCT2GEM(bunch_crossing_mask);
106  }
107 
108  // Step 6: ALCT-2GEM matching for BX's that were not previously masked
110  matchALCT2GEM(bunch_crossing_mask);
111  }
112 
113  // Step 7: Select at most 2 LCTs per BX
114  selectLCTs();
115 }
116 
118  // array to mask CLCTs
119  bool used_clct_mask[CSCConstants::MAX_CLCT_TBINS] = {false};
120 
121  for (int bx_alct = 0; bx_alct < CSCConstants::MAX_ALCT_TBINS; bx_alct++) {
122  // do not consider invalid ALCTs
123  if (alctProc->getBestALCT(bx_alct).isValid()) {
124  for (unsigned mbx = 0; mbx < match_trig_window_size; mbx++) {
125  // evaluate the preffered CLCT BX, taking into account that there is an offset in the simulation
126  unsigned bx_clct = bx_alct + preferred_bx_match_[mbx] - CSCConstants::ALCT_CLCT_OFFSET;
127 
128  // CLCT BX must be in the time window
129  if (bx_clct >= CSCConstants::MAX_CLCT_TBINS)
130  continue;
131  // drop this CLCT if it was previously matched to an ALCT
132  if (drop_used_clcts and used_clct_mask[bx_clct])
133  continue;
134  // do not consider invalid CLCTs
135  if (clctProc->getBestCLCT(bx_clct).isValid()) {
136  LogTrace("CSCMotherboard") << "Successful ALCT-CLCT match: bx_alct = " << bx_alct << "; bx_clct = " << bx_clct
137  << "; mbx = " << mbx;
138 
139  // now correlate the ALCT and CLCT into LCT.
140  // smaller mbx means more preferred!
141  correlateLCTsGEM(alctProc->getBestALCT(bx_alct),
142  alctProc->getSecondALCT(bx_alct),
143  clctProc->getBestCLCT(bx_clct),
144  clctProc->getSecondCLCT(bx_clct),
145  clusterProc_->getClusters(bx_alct, max_delta_bx_alct_gem_),
146  allLCTs_(bx_alct, mbx, 0),
147  allLCTs_(bx_alct, mbx, 1));
148 
149  if (allLCTs_(bx_alct, mbx, 0).isValid()) {
150  // mask this CLCT as used. If a flag is set, the CLCT may or may not be reused
151  used_clct_mask[bx_clct] = true;
152  // mask this bunch crossing for future considation
153  bunch_crossing_mask[bx_alct] = true;
154  // if we only consider the first valid CLCT, we move on to the next ALCT immediately
156  break;
157  }
158  }
159  }
160  }
161  }
162 }
163 
165  // no matching is done for GE2/1 geometries with 8 eta partitions
167  return;
168 
169  // array to mask CLCTs
170  bool used_clct_mask[CSCConstants::MAX_CLCT_TBINS] = {false};
171 
172  for (int bx_gem = 0; bx_gem < CSCConstants::MAX_ALCT_TBINS; bx_gem++) {
173  // do not consider LCT building in this BX if the mask was set
174  if (bunch_crossing_mask[bx_gem])
175  continue;
176 
177  // Check that there is at least one valid GEM coincidence cluster in this BX
178  if (!clusterProc_->getCoincidenceClusters(bx_gem).empty()) {
179  // GEM clusters will have central BX 8. So do ALCTs. But! CLCTs still have central BX 7
180  // therefore we need to make a correction. The correction is thus the same as for ALCT-CLCT
181  for (unsigned mbx = 0; mbx < 2 * max_delta_bx_clct_gem_ + 1; mbx++) {
182  // evaluate the preffered CLCT BX, taking into account that there is an offset in the simulation
183  int bx_clct = bx_gem + preferred_bx_match_[mbx] - CSCConstants::ALCT_CLCT_OFFSET;
184 
185  // CLCT BX must be in the time window
186  if (bx_clct < 0 or bx_clct >= CSCConstants::MAX_CLCT_TBINS)
187  continue;
188  // drop this CLCT if it was previously matched to a GEM coincidence cluster
189  if (drop_used_clcts and used_clct_mask[bx_clct])
190  continue;
191  // do not consider invalid CLCTs
192  if (clctProc->getBestCLCT(bx_clct).isValid()) {
193  // if this is an ME1/a CLCT, you could consider not building this LCT
195  clctProc->getBestCLCT(bx_clct).getKeyStrip() > CSCConstants::MAX_HALF_STRIP_ME1B)
196  continue;
197  // mbx is a relative time difference, which is used later in the
198  // cross-bunching sorting algorithm to determine the preferred LCTs
199  // to be sent to the MPC
200  correlateLCTsGEM(clctProc->getBestCLCT(bx_clct),
201  clctProc->getSecondCLCT(bx_clct),
202  clusterProc_->getCoincidenceClusters(bx_gem),
203  allLCTs_(bx_gem, mbx, 0),
204  allLCTs_(bx_gem, mbx, 1));
205 
206  if (allLCTs_(bx_gem, mbx, 0).isValid()) {
207  // do not consider GEM clusters
208  used_clct_mask[bx_clct] = true;
209  // mask this bunch crossing for future consideration
210  bunch_crossing_mask[bx_gem] = true;
211  // if we only consider the first valid GEM coincidence clusters,
212  // we move on to the next ALCT immediately
214  break;
215  }
216  }
217  }
218  }
219  }
220 }
221 
223  // no matching is done for GE2/1 geometries with 8 eta partitions
225  return;
226 
227  // clear the array to mask GEMs this window is quite wide.
228  // We don't expect GEM coincidence clusters to show up too far
229  // from the central BX (8)
230  bool used_gem_mask[CSCConstants::MAX_ALCT_TBINS] = {false};
231 
232  for (int bx_alct = 0; bx_alct < CSCConstants::MAX_ALCT_TBINS; bx_alct++) {
233  // do not consider LCT building in this BX if the mask was set
234  if (bunch_crossing_mask[bx_alct])
235  continue;
236 
237  if (alctProc->getBestALCT(bx_alct).isValid()) {
238  for (unsigned mbx = 0; mbx < 2 * max_delta_bx_alct_gem_ + 1; mbx++) {
239  // evaluate the preffered GEM BX
240  int bx_gem = bx_alct + preferred_bx_match_[mbx];
241 
242  if (bx_gem < 0 or bx_gem >= CSCConstants::MAX_ALCT_TBINS)
243  continue;
244  // drop GEMs in this BX if one of them was previously matched to an ALCT
245  if (drop_used_gems_ and used_gem_mask[bx_gem])
246  continue;
247  // check for at least one valid GEM cluster
248  if (!clusterProc_->getCoincidenceClusters(bx_gem).empty()) {
249  // now correlate the ALCT and GEM into LCT.
250  // smaller mbx means more preferred!
251  correlateLCTsGEM(alctProc->getBestALCT(bx_alct),
252  alctProc->getSecondALCT(bx_alct),
253  clusterProc_->getCoincidenceClusters(bx_gem),
254  allLCTs_(bx_alct, mbx, 0),
255  allLCTs_(bx_alct, mbx, 1));
256 
257  if (allLCTs_(bx_alct, mbx, 0).isValid()) {
258  // do not consider GEM clusters
259  used_gem_mask[bx_gem] = true;
260  // mask this bunch crossing for future consideration
261  bunch_crossing_mask[bx_alct] = true;
262  // if we only consider the first valid GEM coincidence clusters,
263  // we move on to the next ALCT immediately
265  break;
266  }
267  }
268  }
269  }
270  }
271 }
272 
274  const CSCALCTDigi& sALCT,
275  const CSCCLCTDigi& bCLCT,
276  const CSCCLCTDigi& sCLCT,
278  CSCCorrelatedLCTDigi& lct1,
279  CSCCorrelatedLCTDigi& lct2) const {
281  // This is an 8-eta partition GE2/1 geometry for which the GE2/1-ME2/1 integrated
282  // local trigger is not configured. Matching only ALCTs with CLCTs in ME2/1.
283 
284  // do regular ALCT-CLCT correlation
285  CSCMotherboard::correlateLCTs(bALCT, sALCT, bCLCT, sCLCT, lct1, lct2, CSCCorrelatedLCTDigi::ALCTCLCT);
286  } else {
287  // temporary container
288  std::vector<CSCCorrelatedLCTDigi> lcts;
289 
290  CSCALCTDigi bestALCT = bALCT;
291  CSCALCTDigi secondALCT = sALCT;
292  CSCCLCTDigi bestCLCT = bCLCT;
293  CSCCLCTDigi secondCLCT = sCLCT;
294 
295  if (!bestALCT.isValid()) {
296  edm::LogError("CSCGEMMotherboard") << "Best ALCT invalid in correlateLCTsGEM!";
297  return;
298  }
299 
300  if (!bestCLCT.isValid()) {
301  edm::LogError("CSCGEMMotherboard") << "Best CLCT invalid in correlateLCTsGEM!";
302  return;
303  }
304 
305  // case where there no valid clusters
306  if (clusters.empty()) {
307  // drop the low-quality ALCTs and CLCTs
312 
313  // do regular ALCT-CLCT correlation
314  CSCMotherboard::correlateLCTs(bALCT, sALCT, bCLCT, sCLCT, lct1, lct2, CSCCorrelatedLCTDigi::ALCTCLCT);
315  }
316  // case with at least one valid cluster
317  else {
318  // before matching ALCT-CLCT pairs with clusters, we check if we need
319  // to drop particular low quality ALCTs or CLCTs without matching clusters
320  // drop low quality CLCTs if no clusters and flags are set
321  GEMInternalCluster bestALCTCluster, secondALCTCluster;
322  GEMInternalCluster bestCLCTCluster, secondCLCTCluster;
323  cscGEMMatcher_->bestClusterBXLoc(bestALCT, clusters, bestALCTCluster);
324  cscGEMMatcher_->bestClusterBXLoc(secondALCT, clusters, secondALCTCluster);
325  cscGEMMatcher_->bestClusterBXLoc(bestCLCT, clusters, bestCLCTCluster);
326  cscGEMMatcher_->bestClusterBXLoc(secondCLCT, clusters, secondCLCTCluster);
327 
328  dropLowQualityALCTNoClusters(bestALCT, bestALCTCluster);
329  dropLowQualityALCTNoClusters(secondALCT, secondALCTCluster);
330  dropLowQualityCLCTNoClusters(bestCLCT, bestCLCTCluster);
331  dropLowQualityCLCTNoClusters(secondCLCT, secondCLCTCluster);
332 
333  // check which ALCTs and CLCTs are valid after dropping the low-quality ones
334  copyValidToInValid(bestALCT, secondALCT, bestCLCT, secondCLCT);
335 
336  // We can now check possible triplets and construct all LCTs with
337  // valid ALCT, valid CLCTs and coincidence clusters
338  GEMInternalCluster bbCluster, bsCluster, sbCluster, ssCluster;
339  cscGEMMatcher_->bestClusterBXLoc(bestALCT, bestCLCT, clusters, bbCluster);
340  cscGEMMatcher_->bestClusterBXLoc(bestALCT, secondCLCT, clusters, bsCluster);
341  cscGEMMatcher_->bestClusterBXLoc(secondALCT, bestCLCT, clusters, sbCluster);
342  cscGEMMatcher_->bestClusterBXLoc(secondALCT, secondCLCT, clusters, ssCluster);
343 
344  // At this point it is still possible that certain pairs with high-quality
345  // ALCTs and CLCTs do not have matching clusters. In that case we construct
346  // a regular ALCT-CLCT type LCT. For instance, it could be that two muons went
347  // through the chamber, produced 2 ALCTs, 2 CLCTs, but only 1 GEM cluster - because
348  // GEM cluster efficiency is not 100% (closer to 95%). So we don't require
349  // all clusters to be valid. If they are valid, the LCTs is constructed accordingly.
350  // But we do require that the ALCT and CLCT are valid for each pair.
351  CSCCorrelatedLCTDigi lctbb, lctbs, lctsb, lctss;
352  if (bestALCT.isValid() and bestCLCT.isValid()) {
353  constructLCTsGEM(bestALCT, bestCLCT, bbCluster, lctbb);
354  lcts.push_back(lctbb);
355  }
356  if (bestALCT.isValid() and secondCLCT.isValid() and (secondCLCT != bestCLCT)) {
357  constructLCTsGEM(bestALCT, secondCLCT, bsCluster, lctbs);
358  lcts.push_back(lctbs);
359  }
360  if (bestCLCT.isValid() and secondALCT.isValid() and (secondALCT != bestALCT)) {
361  constructLCTsGEM(secondALCT, bestCLCT, sbCluster, lctsb);
362  lcts.push_back(lctsb);
363  }
364  if (secondALCT.isValid() and secondCLCT.isValid() and (secondALCT != bestALCT) and (secondCLCT != bestCLCT)) {
365  constructLCTsGEM(secondALCT, secondCLCT, ssCluster, lctss);
366  lcts.push_back(lctss);
367  }
368 
369  // no LCTs
370  if (lcts.empty())
371  return;
372 
373  // sort by bending angle
374  sortLCTsByBending(lcts);
375 
376  // retain best two
377  lcts.resize(CSCConstants::MAX_LCTS_PER_CSC);
378 
379  // assign and set the track number
380  if (lcts[0].isValid()) {
381  lct1 = lcts[0];
382  lct1.setTrknmb(1);
383  }
384 
385  if (lcts[1].isValid()) {
386  lct2 = lcts[1];
387  lct2.setTrknmb(2);
388  }
389  }
390  }
391 }
392 
394  const CSCCLCTDigi& sCLCT,
396  CSCCorrelatedLCTDigi& lct1,
397  CSCCorrelatedLCTDigi& lct2) const {
398  CSCCLCTDigi bestCLCT = bCLCT;
399  CSCCLCTDigi secondCLCT = sCLCT;
400 
401  if (!bestCLCT.isValid()) {
402  edm::LogError("CSCGEMMotherboard") << "Best CLCT invalid in correlateLCTsGEM!";
403  return;
404  }
405 
406  // if the second best CLCT equals the best CLCT, clear it
407  if (secondCLCT == bestCLCT)
408  secondCLCT.clear();
409 
410  // get the best matching cluster
411  GEMInternalCluster bestCluster;
412  GEMInternalCluster secondCluster;
413  cscGEMMatcher_->bestClusterBXLoc(bestCLCT, clusters, bestCluster);
414  cscGEMMatcher_->bestClusterBXLoc(secondCLCT, clusters, secondCluster);
415 
416  // drop low quality CLCTs if no clusters and flags are set
417  dropLowQualityCLCTNoClusters(bestCLCT, bestCluster);
418  dropLowQualityCLCTNoClusters(secondCLCT, secondCluster);
419 
420  // construct all LCTs with valid CLCTs and coincidence clusters
421  if (bestCLCT.isValid() and bestCluster.isCoincidence()) {
422  constructLCTsGEM(bestCLCT, bestCluster, 1, lct1);
423  }
424  if (secondCLCT.isValid() and secondCluster.isCoincidence()) {
425  constructLCTsGEM(secondCLCT, secondCluster, 2, lct2);
426  }
427 }
428 
430  const CSCALCTDigi& sALCT,
432  CSCCorrelatedLCTDigi& lct1,
433  CSCCorrelatedLCTDigi& lct2) const {
434  CSCALCTDigi bestALCT = bALCT;
435  CSCALCTDigi secondALCT = sALCT;
436 
437  if (!bestALCT.isValid()) {
438  edm::LogError("CSCGEMMotherboard") << "Best ALCT invalid in correlateLCTsGEM!";
439  return;
440  }
441 
442  // if the second best ALCT equals the best ALCT, clear it
443  if (secondALCT == bestALCT)
444  secondALCT.clear();
445 
446  // get the best matching cluster
447  GEMInternalCluster bestCluster;
448  GEMInternalCluster secondCluster;
449  cscGEMMatcher_->bestClusterBXLoc(bestALCT, clusters, bestCluster);
450  cscGEMMatcher_->bestClusterBXLoc(secondALCT, clusters, secondCluster);
451 
452  // drop low quality ALCTs if no clusters and flags are set
453  dropLowQualityALCTNoClusters(bestALCT, bestCluster);
454  dropLowQualityALCTNoClusters(secondALCT, secondCluster);
455 
456  // construct all LCTs with valid ALCTs and coincidence clusters
457  if (bestALCT.isValid() and bestCluster.isCoincidence()) {
458  constructLCTsGEM(bestALCT, bestCluster, 1, lct1);
459  }
460  if (secondALCT.isValid() and secondCluster.isCoincidence()) {
461  constructLCTsGEM(secondALCT, secondCluster, 2, lct2);
462  }
463 }
464 
466  const CSCCLCTDigi& clct,
467  const GEMInternalCluster& gem,
468  CSCCorrelatedLCTDigi& thisLCT) const {
469  thisLCT.setValid(true);
470  if (gem.isCoincidence()) {
472  } else if (gem.isValid()) {
474  } else {
476  }
477  thisLCT.setQuality(qualityAssignment_->findQuality(alct, clct, gem));
478  thisLCT.setALCT(getBXShiftedALCT(alct));
479  thisLCT.setCLCT(getBXShiftedCLCT(clct));
480  // set pads if there are any
481  thisLCT.setGEM1(gem.mid1());
482  thisLCT.setGEM2(gem.mid2());
483  thisLCT.setPattern(encodePattern(clct.getPattern()));
484  thisLCT.setMPCLink(0);
485  thisLCT.setBX0(0);
486  thisLCT.setSyncErr(0);
487  thisLCT.setCSCID(theTrigChamber);
488  // track number to be set later in final sorting stage
489  thisLCT.setTrknmb(0);
490  thisLCT.setWireGroup(alct.getKeyWG());
491  thisLCT.setStrip(clct.getKeyStrip());
492  thisLCT.setBend(clct.getBend());
493  thisLCT.setBX(alct.getBX());
494  if (runCCLUT_) {
495  thisLCT.setRun3(true);
497  thisLCT.setSlope(cscGEMMatcher_->calculateGEMCSCBending(clct, gem));
498  else
499  thisLCT.setSlope(clct.getSlope());
500  thisLCT.setQuartStripBit(clct.getQuartStripBit());
501  thisLCT.setEighthStripBit(clct.getEighthStripBit());
502  thisLCT.setRun3Pattern(clct.getRun3Pattern());
503  }
504 }
505 
506 /* Construct LCT from CSC and GEM information. Option CLCT-2GEM */
508  const GEMInternalCluster& gem,
509  int trackNumber,
510  CSCCorrelatedLCTDigi& thisLCT) const {
511  thisLCT.setValid(true);
513  thisLCT.setQuality(qualityAssignment_->findQuality(clct, gem));
514  thisLCT.setCLCT(getBXShiftedCLCT(clct));
515  thisLCT.setGEM1(gem.mid1());
516  thisLCT.setGEM2(gem.mid2());
517  thisLCT.setPattern(encodePattern(clct.getPattern()));
518  thisLCT.setMPCLink(0);
519  thisLCT.setBX0(0);
520  thisLCT.setSyncErr(0);
521  thisLCT.setCSCID(theTrigChamber);
522  thisLCT.setTrknmb(trackNumber);
523  thisLCT.setWireGroup(gem.getKeyWG());
524  thisLCT.setStrip(clct.getKeyStrip());
525  thisLCT.setBend(clct.getBend());
526  thisLCT.setBX(gem.bx());
527  if (runCCLUT_) {
528  thisLCT.setRun3(true);
530  thisLCT.setSlope(cscGEMMatcher_->calculateGEMCSCBending(clct, gem));
531  else
532  thisLCT.setSlope(clct.getSlope());
533  thisLCT.setQuartStripBit(clct.getQuartStripBit());
534  thisLCT.setEighthStripBit(clct.getEighthStripBit());
535  thisLCT.setRun3Pattern(clct.getRun3Pattern());
536  }
537 }
538 
539 /* Construct LCT from CSC and GEM information. Option ALCT-2GEM */
541  const GEMInternalCluster& gem,
542  int trackNumber,
543  CSCCorrelatedLCTDigi& thisLCT) const {
544  thisLCT.setValid(true);
546  thisLCT.setQuality(qualityAssignment_->findQuality(alct, gem));
547  thisLCT.setALCT(getBXShiftedALCT(alct));
548  thisLCT.setGEM1(gem.mid1());
549  thisLCT.setGEM2(gem.mid2());
550  thisLCT.setPattern(10);
551  thisLCT.setMPCLink(0);
552  thisLCT.setBX0(0);
553  thisLCT.setSyncErr(0);
554  thisLCT.setCSCID(theTrigChamber);
555  thisLCT.setTrknmb(trackNumber);
556  thisLCT.setWireGroup(alct.getKeyWG());
557  thisLCT.setStrip(gem.getKeyStrip());
558  thisLCT.setBend(0);
559  thisLCT.setBX(alct.getBX());
560  if (runCCLUT_) {
561  thisLCT.setRun3(true);
562  thisLCT.setSlope(0);
563  thisLCT.setQuartStripBit(false);
564  thisLCT.setEighthStripBit(false);
565  // ALCT-2GEM type LCTs do not bend in the chamber
566  thisLCT.setRun3Pattern(4);
567  }
568 }
569 
571  // clear alct if they are of low quality without matching GEM clusters
572  if (alct.getQuality() == 0 and !cluster.isValid() and drop_low_quality_alct_no_gems_)
573  alct.clear();
574 }
575 
577  // Here, we need to check which could be an ME1/a LCT
578  bool dropLQCLCTNoGEMs = drop_low_quality_clct_no_gems_;
580  dropLQCLCTNoGEMs = drop_low_quality_clct_no_gems_me1a_;
581 
582  // clear clct if they are of low quality without matching GEM clusters
583  if (clct.getQuality() <= 3 and !cluster.isValid() and dropLQCLCTNoGEMs)
584  clct.clear();
585 }
586 
587 void CSCGEMMotherboard::sortLCTsByBending(std::vector<CSCCorrelatedLCTDigi>& lcts) const {
588  /*
589  For Run-2 GEM-CSC trigger primitives, which we temporarily have
590  to integrate with the Run-2 EMTF during LS2, we sort by quality.
591  Larger quality means smaller bending
592  */
593  if (!runCCLUT_) {
594  std::sort(lcts.begin(), lcts.end(), [](const CSCCorrelatedLCTDigi& lct1, const CSCCorrelatedLCTDigi& lct2) -> bool {
595  return lct1.getQuality() > lct2.getQuality();
596  });
597  }
598 
599  /*
600  For Run-3 GEM-CSC trigger primitives, which we have
601  to integrate with the Run-3 EMTF, we sort by slope.
602  Smaller slope means smaller bending
603  */
604  else {
605  std::sort(lcts.begin(), lcts.end(), [](const CSCCorrelatedLCTDigi& lct1, const CSCCorrelatedLCTDigi& lct2) -> bool {
606  return lct1.getSlope() < lct2.getSlope();
607  });
608  }
609 }
CSCALCTDigi::getBX
uint16_t getBX() const
return BX - five low bits of BXN counter tagged by the ALCT
Definition: CSCALCTDigi.h:73
CSCMotherboard::selectLCTs
void selectLCTs()
Definition: CSCMotherboard.cc:468
electrons_cff.bool
bool
Definition: electrons_cff.py:366
CSCMotherboard::match_trig_window_size
unsigned int match_trig_window_size
Definition: CSCMotherboard.h:124
CSCMotherboard::copyValidToInValid
void copyValidToInValid(CSCALCTDigi &, CSCALCTDigi &, CSCCLCTDigi &, CSCCLCTDigi &) const
Definition: CSCMotherboard.cc:405
CSCBaseboard::theRegion
int theRegion
Definition: CSCBaseboard.h:46
CSCCorrelatedLCTDigi::setValid
void setValid(const uint16_t v)
set valid
Definition: CSCCorrelatedLCTDigi.h:174
CSCGEMMotherboard::build_lct_from_alct_gem_
bool build_lct_from_alct_gem_
Definition: CSCGEMMotherboard.h:146
CSCCorrelatedLCTDigi::ALCT2GEM
Definition: CSCCorrelatedLCTDigi.h:31
CSCBaseboard::cscGeometry_
const CSCGeometry * cscGeometry_
Definition: CSCBaseboard.h:65
CSCGEMMotherboard::cscGEMMatcher_
std::unique_ptr< CSCGEMMatcher > cscGEMMatcher_
Definition: CSCGEMMotherboard.h:136
CSCConstants::MAX_ALCT_TBINS
Definition: CSCConstants.h:127
CSCGEMMotherboard::drop_low_quality_clct_no_gems_me1a_
bool drop_low_quality_clct_no_gems_me1a_
Definition: CSCGEMMotherboard.h:150
CSCBaseboard::tmbParams_
edm::ParameterSet tmbParams_
Definition: CSCBaseboard.h:72
CSCGEMMotherboard::match_earliest_gem_only_
bool match_earliest_gem_only_
Definition: CSCGEMMotherboard.h:163
relativeConstraints.station
station
Definition: relativeConstraints.py:67
CSCMotherboard::alctProc
std::unique_ptr< CSCAnodeLCTProcessor > alctProc
Definition: CSCMotherboard.h:98
CSCBaseboard::theStation
const unsigned theStation
Definition: CSCBaseboard.h:42
CSCGEMMotherboard::drop_used_gems_
bool drop_used_gems_
Definition: CSCGEMMotherboard.h:162
CSCALCTDigi::clear
void clear()
clear this ALCT
Definition: CSCALCTDigi.cc:49
CSCGEMMotherboard::matchALCT2GEM
void matchALCT2GEM(bool bunch_crossing_mask[CSCConstants::MAX_ALCT_TBINS])
Definition: CSCGEMMotherboard.cc:222
CSCCLCTDigi::getEighthStripBit
bool getEighthStripBit() const
get single eighth strip bit
Definition: CSCCLCTDigi.h:114
CSCCorrelatedLCTDigi::setQuality
void setQuality(const uint16_t q)
set quality code
Definition: CSCCorrelatedLCTDigi.h:171
CSCMotherboard::allLCTs_
LCTContainer allLCTs_
Definition: CSCMotherboard.h:110
CSCCorrelatedLCTDigi::setWireGroup
void setWireGroup(const uint16_t wiregroup)
set wiregroup number
Definition: CSCCorrelatedLCTDigi.h:168
CSCMotherboard
Definition: CSCMotherboard.h:47
CSCMotherboard::clear
void clear()
Definition: CSCMotherboard.cc:82
CSCConstants::ALCT_CLCT_OFFSET
Definition: CSCConstants.h:164
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
CSCCLCTDigi::getKeyStrip
uint16_t getKeyStrip(const uint16_t n=2) const
Definition: CSCCLCTDigi.cc:99
CSCGEMMotherboard.h
CSCCorrelatedLCTDigi::setBX0
void setBX0(const uint16_t b)
set bx0
Definition: CSCCorrelatedLCTDigi.h:195
CSCGEMMotherboard::hasGE21Geometry16Partitions_
bool hasGE21Geometry16Partitions_
Definition: CSCGEMMotherboard.h:167
CSCCLCTDigi
Definition: CSCCLCTDigi.h:17
CSCCorrelatedLCTDigi::ALCTCLCT
Definition: CSCCorrelatedLCTDigi.h:28
CSCBaseboard::runME11ILT_
bool runME11ILT_
Definition: CSCBaseboard.h:94
CSCCorrelatedLCTDigi::CLCT2GEM
Definition: CSCCorrelatedLCTDigi.h:32
CSCCorrelatedLCTDigi::setCLCT
void setCLCT(const CSCCLCTDigi &clct)
Definition: CSCCorrelatedLCTDigi.h:216
CSCMotherboard::clctV
std::vector< CSCCLCTDigi > clctV
Definition: CSCMotherboard.h:107
CSCMotherboard::match_earliest_clct_only_
bool match_earliest_clct_only_
Definition: CSCMotherboard.h:136
CSCMotherboard::clctProc
std::unique_ptr< CSCCathodeLCTProcessor > clctProc
Definition: CSCMotherboard.h:101
CSCGEMMotherboard::constructLCTsGEM
void constructLCTsGEM(const CSCALCTDigi &alct, const CSCCLCTDigi &clct, const GEMInternalCluster &gem, CSCCorrelatedLCTDigi &lct) const
Definition: CSCGEMMotherboard.cc:465
CSCCorrelatedLCTDigi::setALCT
void setALCT(const CSCALCTDigi &alct)
Definition: CSCCorrelatedLCTDigi.h:215
CSCALCTDigi::getKeyWG
uint16_t getKeyWG() const
return key wire group
Definition: CSCALCTDigi.h:67
CSCMotherboard::correlateLCTs
void correlateLCTs(const CSCALCTDigi &bestALCT, const CSCALCTDigi &secondALCT, const CSCCLCTDigi &bestCLCT, const CSCCLCTDigi &secondCLCT, CSCCorrelatedLCTDigi &bLCT, CSCCorrelatedLCTDigi &sLCT, int type) const
Definition: CSCMotherboard.cc:346
CSCCLCTDigi::getQuality
uint16_t getQuality() const
return quality of a pattern (number of layers hit!)
Definition: CSCCLCTDigi.h:56
CSCCorrelatedLCTDigi::setStrip
void setStrip(const uint16_t s)
set strip
Definition: CSCCorrelatedLCTDigi.h:177
CSCCLCTDigi::getQuartStripBit
bool getQuartStripBit() const
get single quart strip bit
Definition: CSCCLCTDigi.h:108
CSCCLCTDigi::getBend
uint16_t getBend() const
Definition: CSCCLCTDigi.h:93
CSCMotherboard::alctV
std::vector< CSCALCTDigi > alctV
Definition: CSCMotherboard.h:106
CSCConstants::MAX_LCTS_PER_CSC
Definition: CSCConstants.h:138
CSCConstants::MAX_HALF_STRIP_ME1B
Definition: CSCConstants.h:88
CSCCorrelatedLCTDigi::setMPCLink
void setMPCLink(const uint16_t &link)
Set mpc link number after MPC sorting.
Definition: CSCCorrelatedLCTDigi.h:158
CSCCorrelatedLCTDigi::setSlope
void setSlope(const uint16_t slope)
set the slope
Definition: CSCCorrelatedLCTDigi.h:186
CSCGEMMotherboard::build_lct_from_clct_gem_me1a_
bool build_lct_from_clct_gem_me1a_
Definition: CSCGEMMotherboard.h:153
CSCGEMMotherboard::matchCLCT2GEM
void matchCLCT2GEM(bool bunch_crossing_mask[CSCConstants::MAX_ALCT_TBINS])
Definition: CSCGEMMotherboard.cc:164
CSCGEMMotherboard::gemId
unsigned gemId
Definition: CSCGEMMotherboard.h:130
CSCGEMMotherboard::sortLCTsByBending
void sortLCTsByBending(std::vector< CSCCorrelatedLCTDigi > &lcts) const
Definition: CSCGEMMotherboard.cc:587
GEMPadDigiClusterCollection
sistrip::SpyUtilities::isValid
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
Definition: SiStripSpyUtilities.cc:124
CSCALCTDigi::getQuality
uint16_t getQuality() const
return quality of a pattern
Definition: CSCALCTDigi.h:46
CSCCorrelatedLCTDigi::ALCTCLCTGEM
Definition: CSCCorrelatedLCTDigi.h:29
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
CSCCorrelatedLCTDigi::setBend
void setBend(const uint16_t b)
set bend
Definition: CSCCorrelatedLCTDigi.h:189
CSCCorrelatedLCTDigi::setGEM1
void setGEM1(const GEMPadDigi &gem)
Definition: CSCCorrelatedLCTDigi.h:217
CSCCorrelatedLCTDigi::ALCTCLCT2GEM
Definition: CSCCorrelatedLCTDigi.h:30
CSCCorrelatedLCTDigi::setBX
void setBX(const uint16_t b)
set bx
Definition: CSCCorrelatedLCTDigi.h:192
CSCCorrelatedLCTDigi::setTrknmb
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting LCTs.
Definition: CSCCorrelatedLCTDigi.h:155
edm::ParameterSet
Definition: ParameterSet.h:47
CSCCorrelatedLCTDigi::setPattern
void setPattern(const uint16_t p)
set pattern
Definition: CSCCorrelatedLCTDigi.h:180
GEMInternalCluster::isCoincidence
bool isCoincidence() const
Definition: GEMInternalCluster.h:52
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
CSCCorrelatedLCTDigi::setGEM2
void setGEM2(const GEMPadDigi &gem)
Definition: CSCCorrelatedLCTDigi.h:218
GEMDetId
Definition: GEMDetId.h:18
CSCCorrelatedLCTDigi::setCSCID
void setCSCID(const uint16_t c)
set cscID
Definition: CSCCorrelatedLCTDigi.h:201
CSCMotherboard::preferred_bx_match_
std::vector< int > preferred_bx_match_
Definition: CSCMotherboard.h:146
CSCGEMMotherboard::max_delta_bx_clct_gem_
unsigned max_delta_bx_clct_gem_
Definition: CSCGEMMotherboard.h:157
CSCCorrelatedLCTDigi::setRun3Pattern
void setRun3Pattern(const uint16_t pattern)
set Run-3 pattern
Definition: CSCCorrelatedLCTDigi.h:183
CSCCLCTDigi::isValid
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:50
CSCComparatorDigiCollection
GEMInternalCluster::isValid
bool isValid() const
Definition: GEMInternalCluster.h:31
CSCGEMMotherboard::GEMInternalClusters
std::vector< GEMInternalCluster > GEMInternalClusters
Definition: CSCGEMMotherboard.h:23
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
CSCCLCTDigi::getSlope
uint16_t getSlope() const
return the slope
Definition: CSCCLCTDigi.h:74
CSCBaseboard::theChamber
unsigned theChamber
Definition: CSCBaseboard.h:48
CSCCorrelatedLCTDigi::setSyncErr
void setSyncErr(const uint16_t s)
set syncErr
Definition: CSCCorrelatedLCTDigi.h:198
CSCGEMMotherboard::dropLowQualityCLCTNoClusters
void dropLowQualityCLCTNoClusters(CSCCLCTDigi &clct, const GEMInternalCluster &cluster) const
Definition: CSCGEMMotherboard.cc:576
gem
Definition: AMC13Event.h:6
CSCGEMMotherboard::matchALCTCLCTGEM
void matchALCTCLCTGEM(bool bunch_crossing_mask[CSCConstants::MAX_ALCT_TBINS])
Definition: CSCGEMMotherboard.cc:117
CSCMotherboard::drop_used_clcts
bool drop_used_clcts
Definition: CSCMotherboard.h:127
CSCMotherboard::getBXShiftedCLCT
CSCCLCTDigi getBXShiftedCLCT(const CSCCLCTDigi &) const
Definition: CSCMotherboard.cc:543
CSCCorrelatedLCTDigi::setQuartStripBit
void setQuartStripBit(const bool quartStripBit)
set single quart strip bit
Definition: CSCCorrelatedLCTDigi.h:79
CSCGEMMotherboard::run
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const GEMPadDigiClusterCollection *gemPads)
Definition: CSCGEMMotherboard.cc:54
CSCGEMMotherboard::CSCGEMMotherboard
CSCGEMMotherboard(unsigned endcap, unsigned station, unsigned sector, unsigned subsector, unsigned chamber, const edm::ParameterSet &conf)
Definition: CSCGEMMotherboard.cc:4
CSCBaseboard::runME21ILT_
bool runME21ILT_
Definition: CSCBaseboard.h:97
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
CSCWireDigiCollection
CSCBaseboard::isME21_
bool isME21_
Definition: CSCBaseboard.h:52
CSCGEMMotherboard::correlateLCTsGEM
void correlateLCTsGEM(const CSCALCTDigi &bestALCT, const CSCALCTDigi &secondALCT, const CSCCLCTDigi &bestCLCT, const CSCCLCTDigi &secondCLCT, const GEMInternalClusters &clusters, CSCCorrelatedLCTDigi &lct1, CSCCorrelatedLCTDigi &lct2) const
Definition: CSCGEMMotherboard.cc:273
CSCCLCTDigi::clear
void clear()
clear this CLCT
Definition: CSCCLCTDigi.cc:61
CSCALCTDigi
Definition: CSCALCTDigi.h:17
CSCGEMMotherboard::max_delta_bx_alct_gem_
unsigned max_delta_bx_alct_gem_
Definition: CSCGEMMotherboard.h:156
CSCConstants::MAX_CLCT_TBINS
Definition: CSCConstants.h:126
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
CSCGEMMotherboard::dropLowQualityALCTNoClusters
void dropLowQualityALCTNoClusters(CSCALCTDigi &alct, const GEMInternalCluster &cluster) const
Definition: CSCGEMMotherboard.cc:570
CSCGEMMotherboard::clear
void clear()
Definition: CSCGEMMotherboard.cc:49
CSCBaseboard::theTrigChamber
const unsigned theTrigChamber
Definition: CSCBaseboard.h:45
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
GEMInternalCluster
Definition: GEMInternalCluster.h:18
CSCMotherboard::encodePattern
unsigned int encodePattern(const int clctPattern) const
Definition: CSCMotherboard.cc:459
CSCALCTDigi::isValid
bool isValid() const
check ALCT validity (1 - valid ALCT)
Definition: CSCALCTDigi.h:40
CSCCorrelatedLCTDigi::setEighthStripBit
void setEighthStripBit(const bool eighthStripBit)
set single eighth strip bit
Definition: CSCCorrelatedLCTDigi.h:85
CSCCorrelatedLCTDigi::setRun3
void setRun3(const bool isRun3)
Definition: CSCCorrelatedLCTDigi.cc:133
CSCGEMMotherboard::build_lct_from_clct_gem_
bool build_lct_from_clct_gem_
Definition: CSCGEMMotherboard.h:147
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
CSCMotherboard::getBXShiftedALCT
CSCALCTDigi getBXShiftedALCT(const CSCALCTDigi &) const
Definition: CSCMotherboard.cc:537
CSCCLCTDigi::getPattern
uint16_t getPattern() const
return pattern
Definition: CSCCLCTDigi.h:62
CSCCorrelatedLCTDigi::setType
void setType(int type)
Definition: CSCCorrelatedLCTDigi.h:213
CSCMotherboard::encodeHighMultiplicityBits
void encodeHighMultiplicityBits()
Definition: CSCMotherboard.cc:549
CSCMotherboard::qualityAssignment_
std::unique_ptr< LCTQualityAssignment > qualityAssignment_
Definition: CSCMotherboard.h:155
CSCGEMMotherboard::clusterProc_
std::shared_ptr< GEMClusterProcessor > clusterProc_
Definition: CSCGEMMotherboard.h:139
CSCCorrelatedLCTDigi::getQuality
uint16_t getQuality() const
return the Quality
Definition: CSCCorrelatedLCTDigi.h:70
CSCGEMMotherboard::assign_gem_csc_bending_
bool assign_gem_csc_bending_
Definition: CSCGEMMotherboard.h:160
CSCGEMMotherboard::~CSCGEMMotherboard
~CSCGEMMotherboard() override
Definition: CSCGEMMotherboard.cc:47
CSCBaseboard::isME11_
bool isME11_
Definition: CSCBaseboard.h:51
CSCGEMMotherboard::gem_g
const GEMGeometry * gem_g
Definition: CSCGEMMotherboard.h:131
CSCCorrelatedLCTDigi
Definition: CSCCorrelatedLCTDigi.h:19
CSCBaseboard::runCCLUT_
bool runCCLUT_
Definition: CSCBaseboard.h:105
CSCCorrelatedLCTDigi::getSlope
uint16_t getSlope() const
return the slope
Definition: CSCCorrelatedLCTDigi.h:116
CSCGEMMotherboard::drop_low_quality_alct_no_gems_
bool drop_low_quality_alct_no_gems_
Definition: CSCGEMMotherboard.h:142
CSCGEMMotherboard::drop_low_quality_clct_no_gems_
bool drop_low_quality_clct_no_gems_
Definition: CSCGEMMotherboard.h:143
CSCCLCTDigi::getRun3Pattern
uint16_t getRun3Pattern() const
return pattern
Definition: CSCCLCTDigi.h:68