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