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 
156  // BestCLCT and secondCLCT
157  for (unsigned mbx = 0; mbx < match_trig_window_size; mbx++) {
158  unsigned bx_clct = bx_alct + preferred_bx_match_[mbx] - CSCConstants::ALCT_CLCT_OFFSET;
159  if (bx_clct >= CSCConstants::MAX_CLCT_TBINS)
160  continue;
161  bestCLCT = clctProc->getBestCLCT(bx_clct);
162  secondCLCT = clctProc->getSecondCLCT(bx_clct);
163  matchingBX = mbx;
164  if (bestCLCT.isValid())
165  break;
166  }
167 
168  if (!bestALCT.isValid() and !secondALCT.isValid() and !bestCLCT.isValid() and !secondCLCT.isValid())
169  continue;
170  if (!build_lct_from_clct_gem_ and !bestALCT.isValid())
171  continue;
172  if (!build_lct_from_alct_gem_ and !bestCLCT.isValid())
173  continue;
174 
175  // ALCT + CLCT + GEM
176 
177  for (unsigned gmbx = 0; gmbx < alct_gem_bx_window_size_; gmbx++) {
178  unsigned bx_gem = bx_alct + preferred_bx_match_[gmbx];
179  clustersGEM = clusterProc_->getClusters(bx_gem, GEMClusterProcessor::AllClusters);
180  if (!clustersGEM.empty()) {
181  correlateLCTsGEM(bestALCT, bestCLCT, clustersGEM, LCTbestAbestCgem);
182  correlateLCTsGEM(bestALCT, secondCLCT, clustersGEM, LCTbestAsecondCgem);
183  correlateLCTsGEM(secondALCT, bestCLCT, clustersGEM, LCTsecondAbestCgem);
184  correlateLCTsGEM(secondALCT, secondCLCT, clustersGEM, LCTsecondAsecondCgem);
185  break;
186  }
187  }
188 
189  // ALCT + CLCT
190 
191  correlateLCTsGEM(bestALCT, bestCLCT, LCTbestAbestC);
192  correlateLCTsGEM(bestALCT, secondCLCT, LCTbestAsecondC);
193  correlateLCTsGEM(secondALCT, bestCLCT, LCTsecondAbestC);
194  correlateLCTsGEM(secondALCT, secondCLCT, LCTsecondAsecondC);
195 
196  // CLCT + 2 GEM
197 
199  unsigned bx_gem = bx_alct;
200 
201  clustersGEM = clusterProc_->getClusters(bx_gem, GEMClusterProcessor::CoincidenceClusters);
202  correlateLCTsGEM(bestCLCT, clustersGEM, LCTbestCLCTgem);
203  clustersGEM = clusterProc_->getClusters(bx_gem, GEMClusterProcessor::CoincidenceClusters);
204  correlateLCTsGEM(secondCLCT, clustersGEM, LCTsecondCLCTgem);
205  }
206 
207  // ALCT + 2 GEM
208 
210  for (unsigned gmbx = 0; gmbx < alct_gem_bx_window_size_; gmbx++) {
211  unsigned bx_gem = bx_alct + preferred_bx_match_[gmbx];
212  clustersGEM = clusterProc_->getClusters(bx_gem, GEMClusterProcessor::CoincidenceClusters);
213  if (!clustersGEM.empty()) {
214  correlateLCTsGEM(bestALCT, clustersGEM, LCTbestALCTgem);
215  correlateLCTsGEM(secondALCT, clustersGEM, LCTsecondALCTgem);
216  break;
217  }
218  }
219  }
220 
221  // Select LCTs, following FW logic
222 
223  std::vector<CSCCorrelatedLCTDigi> selectedLCTs;
224 
225  // CASE => Only bestALCT is valid
226  if (bestALCT.isValid() and !secondALCT.isValid() and !bestCLCT.isValid() and !secondCLCT.isValid()) {
227  if (LCTbestALCTgem.isValid()) {
228  LCTbestALCTgem.setTrknmb(1);
229  allLCTs_(bx_alct, matchingBX, 0) = LCTbestALCTgem;
230  }
231  }
232 
233  // CASE => Only bestCLCT is valid
234  if (!bestALCT.isValid() and !secondALCT.isValid() and bestCLCT.isValid() and !secondCLCT.isValid()) {
235  if (LCTbestCLCTgem.isValid()) {
236  LCTbestCLCTgem.setTrknmb(1);
237  allLCTs_(bx_alct, matchingBX, 0) = LCTbestCLCTgem;
238  }
239  }
240 
241  // CASE => bestALCT and bestCLCT are valid
242  if (bestALCT.isValid() and !secondALCT.isValid() and bestCLCT.isValid() and !secondCLCT.isValid()) {
243  if (LCTbestAbestCgem.isValid()) {
244  LCTbestAbestCgem.setTrknmb(1);
245  allLCTs_(bx_alct, matchingBX, 0) = LCTbestAbestCgem;
246  } else if (LCTbestAbestC.isValid()) {
247  LCTbestAbestC.setTrknmb(1);
248  allLCTs_(bx_alct, matchingBX, 0) = LCTbestAbestC;
249  }
250  }
251 
252  // CASE => bestALCT, secondALCT, bestCLCT are valid
253  if (bestALCT.isValid() and secondALCT.isValid() and bestCLCT.isValid() and !secondCLCT.isValid()) {
254  CSCCorrelatedLCTDigi lctbb, lctsb;
255  if (LCTbestAbestCgem.isValid())
256  lctbb = LCTbestAbestCgem;
257  else if (LCTbestAbestC.isValid())
258  lctbb = LCTbestAbestC;
259  if (LCTsecondAbestCgem.isValid())
260  lctsb = LCTsecondAbestCgem;
261  else if (LCTsecondAbestC.isValid())
262  lctsb = LCTsecondAbestC;
263 
264  if (lctbb.getQuality() >= lctsb.getQuality() and lctbb.isValid()) {
265  selectedLCTs.push_back(lctbb);
266  if (LCTsecondALCTgem.isValid() and build_lct_from_alct_gem_)
267  selectedLCTs.push_back(LCTsecondALCTgem);
268  else if (LCTsecondAbestC.isValid())
269  selectedLCTs.push_back(LCTsecondAbestC);
270  } else if (lctbb.getQuality() < lctsb.getQuality() and lctsb.isValid()) {
271  selectedLCTs.push_back(lctsb);
272  if (LCTbestALCTgem.isValid() and build_lct_from_alct_gem_)
273  selectedLCTs.push_back(LCTbestALCTgem);
274  else if (LCTbestAbestC.isValid())
275  selectedLCTs.push_back(LCTbestAbestC);
276  }
277 
278  sortLCTs(selectedLCTs);
279 
280  for (unsigned iLCT = 0; iLCT < std::min(unsigned(selectedLCTs.size()), unsigned(CSCConstants::MAX_LCTS_PER_CSC));
281  iLCT++) {
282  if (selectedLCTs[iLCT].isValid()) {
283  selectedLCTs[iLCT].setTrknmb(iLCT + 1);
284  allLCTs_(bx_alct, matchingBX, iLCT) = selectedLCTs[iLCT];
285  }
286  }
287  }
288 
289  // CASE => bestALCT, bestCLCT, secondCLCT are valid
290  if (bestALCT.isValid() and !secondALCT.isValid() and bestCLCT.isValid() and secondCLCT.isValid()) {
291  CSCCorrelatedLCTDigi lctbb, lctbs;
292  if (LCTbestAbestCgem.isValid())
293  lctbb = LCTbestAbestCgem;
294  else if (LCTbestAbestC.isValid())
295  lctbb = LCTbestAbestC;
296  if (LCTbestAsecondCgem.isValid())
297  lctbs = LCTbestAsecondCgem;
298  else if (LCTbestAsecondC.isValid())
299  lctbs = LCTbestAsecondC;
300 
301  if (lctbb.getQuality() >= lctbs.getQuality() and lctbb.isValid()) {
302  selectedLCTs.push_back(lctbb);
303  if (LCTsecondCLCTgem.isValid() and build_lct_from_clct_gem_)
304  selectedLCTs.push_back(LCTsecondCLCTgem);
305  else if (LCTbestAsecondC.isValid())
306  selectedLCTs.push_back(LCTbestAsecondC);
307  } else if (lctbb.getQuality() < lctbs.getQuality() and lctbs.isValid()) {
308  selectedLCTs.push_back(lctbs);
309  if (LCTbestCLCTgem.isValid() and build_lct_from_alct_gem_)
310  selectedLCTs.push_back(LCTbestCLCTgem);
311  else if (LCTbestAbestC.isValid())
312  selectedLCTs.push_back(LCTbestAbestC);
313  }
314 
315  sortLCTs(selectedLCTs);
316 
317  for (unsigned iLCT = 0; iLCT < std::min(unsigned(selectedLCTs.size()), unsigned(CSCConstants::MAX_LCTS_PER_CSC));
318  iLCT++) {
319  if (selectedLCTs[iLCT].isValid()) {
320  selectedLCTs[iLCT].setTrknmb(iLCT + 1);
321  allLCTs_(bx_alct, matchingBX, iLCT) = selectedLCTs[iLCT];
322  }
323  }
324  }
325 
326  // CASE => bestALCT, secondALCT, bestCLCT, secondCLCT are valid
327  if (bestALCT.isValid() and secondALCT.isValid() and bestCLCT.isValid() and secondCLCT.isValid()) {
328  CSCCorrelatedLCTDigi lctbb, lctbs, lctsb, lctss;
329 
330  // compute LCT bestA-bestC
331  if (LCTbestAbestCgem.isValid())
332  lctbb = LCTbestAbestCgem;
333  else if (LCTbestAbestC.isValid())
334  lctbb = LCTbestAbestC;
335 
336  // compute LCT bestA-secondC
337  if (LCTbestAsecondCgem.isValid())
338  lctbs = LCTbestAsecondCgem;
339  else if (LCTbestAsecondC.isValid())
340  lctbs = LCTbestAsecondC;
341 
342  if (lctbb.getQuality() >= lctbs.getQuality()) {
343  // push back LCT bestA-bestC
344  selectedLCTs.push_back(lctbb);
345 
346  // compute LCT secondA-secondC
347  if (LCTsecondAsecondCgem.isValid())
348  lctss = LCTsecondAsecondCgem;
349  else if (LCTsecondAsecondC.isValid())
350  lctss = LCTsecondAsecondC;
351 
352  // push back LCT secondA-secondC
353  selectedLCTs.push_back(lctss);
354  } else {
355  // push back LCT bestA-secondC
356  selectedLCTs.push_back(lctbs);
357 
358  // compute LCT secondA-bestC
359  if (LCTsecondAbestCgem.isValid())
360  lctsb = LCTsecondAbestCgem;
361  else if (LCTsecondAbestC.isValid())
362  lctsb = LCTsecondAbestC;
363 
364  // push back LCT secondA-bestC
365  selectedLCTs.push_back(lctsb);
366  }
367 
368  sortLCTs(selectedLCTs);
369 
370  for (unsigned iLCT = 0; iLCT < std::min(unsigned(selectedLCTs.size()), unsigned(CSCConstants::MAX_LCTS_PER_CSC));
371  iLCT++) {
372  if (selectedLCTs[iLCT].isValid()) {
373  selectedLCTs[iLCT].setTrknmb(iLCT + 1);
374  allLCTs_(bx_alct, matchingBX, iLCT) = selectedLCTs[iLCT];
375  }
376  }
377  }
378  }
379 }
380 
381 // Correlate CSC and GEM information. Option ALCT-CLCT-GEM
383  const CSCCLCTDigi& CLCT,
385  CSCCorrelatedLCTDigi& lct) const {
386  // Sanity checks on ALCT, CLCT, GEM clusters
387  if (!ALCT.isValid()) {
388  LogTrace("CSCGEMMotherboard") << "Best ALCT invalid in correlateLCTsGEM";
389  return;
390  }
391 
392  if (!CLCT.isValid()) {
393  LogTrace("CSCGEMMotherboard") << "Best CLCT invalid in correlateLCTsGEM";
394  return;
395  }
396 
397  GEMInternalClusters ValidClusters;
398  for (const auto& cl : clusters)
399  if (cl.isValid())
400  ValidClusters.push_back(cl);
401  if (ValidClusters.empty())
402  return;
403 
404  // We can now check possible triplets and construct all LCTs with
405  // valid ALCT, valid CLCTs and GEM clusters
406  GEMInternalCluster bestCluster;
407  cscGEMMatcher_->bestClusterLoc(ALCT, CLCT, ValidClusters, bestCluster);
408  if (bestCluster.isValid())
409  constructLCTsGEM(ALCT, CLCT, bestCluster, lct);
410 }
411 
412 // Correlate CSC information. Option ALCT-CLCT
414  const CSCCLCTDigi& CLCT,
415  CSCCorrelatedLCTDigi& lct) const {
416  // Sanity checks on ALCT, CLCT
417  if (!ALCT.isValid() or (ALCT.getQuality() == 0 and drop_low_quality_alct_)) {
418  LogTrace("CSCGEMMotherboard") << "Best ALCT invalid in correlateLCTsGEM";
419  return;
420  }
421 
422  bool dropLowQualityCLCT = drop_low_quality_clct_;
424  dropLowQualityCLCT = drop_low_quality_clct_me1a_;
425 
426  if (!CLCT.isValid() or (CLCT.getQuality() <= 3 and dropLowQualityCLCT)) {
427  LogTrace("CSCGEMMotherboard") << "Best CLCT invalid in correlateLCTsGEM";
428  return;
429  }
430 
431  // construct LCT
432  if (match_trig_enable and doesALCTCrossCLCT(ALCT, CLCT)) {
433  constructLCTsGEM(ALCT, CLCT, lct);
434  }
435 }
436 
437 // Correlate CSC and GEM information. Option CLCT-GEM
440  CSCCorrelatedLCTDigi& lct) const {
441  // Sanity checks on CLCT, GEM clusters
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  GEMInternalClusters ValidClusters;
452  for (const auto& cl : clusters)
453  if (cl.isValid())
454  ValidClusters.push_back(cl);
455  if (ValidClusters.empty())
456  return;
457 
458  // get the best matching cluster
459  GEMInternalCluster bestCluster;
460  cscGEMMatcher_->bestClusterLoc(CLCT, ValidClusters, bestCluster);
461 
462  // construct all LCTs with valid CLCTs and coincidence clusters
463  if (bestCluster.isCoincidence()) {
464  constructLCTsGEM(CLCT, bestCluster, lct);
465  }
466 }
467 
468 // Correlate CSC and GEM information. Option ALCT-GEM
471  CSCCorrelatedLCTDigi& lct) const {
472  // Sanity checks on ALCT, GEM clusters
473  if (!ALCT.isValid() or (ALCT.getQuality() == 0 and drop_low_quality_alct_)) {
474  LogTrace("CSCGEMMotherboard") << "Best ALCT invalid in correlateLCTsGEM";
475  return;
476  }
477 
478  GEMInternalClusters ValidClusters;
479  for (const auto& cl : clusters)
480  if (cl.isValid())
481  ValidClusters.push_back(cl);
482  if (ValidClusters.empty())
483  return;
484 
485  // get the best matching cluster
486  GEMInternalCluster bestCluster;
487  cscGEMMatcher_->bestClusterLoc(ALCT, ValidClusters, bestCluster);
488 
489  // construct all LCTs with valid ALCTs and coincidence clusters
490  if (bestCluster.isCoincidence()) {
491  constructLCTsGEM(ALCT, bestCluster, lct);
492  }
493 }
494 
495 // Construct LCT from CSC and GEM information. Option ALCT-CLCT-GEM
497  const CSCCLCTDigi& clct,
498  const GEMInternalCluster& gem,
499  CSCCorrelatedLCTDigi& thisLCT) const {
500  thisLCT.setValid(true);
501  if (gem.isCoincidence())
503  else if (gem.isValid())
505  thisLCT.setQuality(qualityAssignment_->findQuality(alct, clct, gem));
506  thisLCT.setALCT(getBXShiftedALCT(alct));
507  thisLCT.setCLCT(getBXShiftedCLCT(clct));
508  // set pads if there are any
509  thisLCT.setGEM1(gem.mid1());
510  thisLCT.setGEM2(gem.mid2());
511  thisLCT.setPattern(encodePattern(clct.getPattern()));
512  thisLCT.setMPCLink(0);
513  thisLCT.setBX0(0);
514  thisLCT.setSyncErr(0);
515  thisLCT.setCSCID(theTrigChamber);
516  thisLCT.setTrknmb(0); // will be set later after sorting
517  thisLCT.setWireGroup(alct.getKeyWG());
518  thisLCT.setStrip(clct.getKeyStrip());
519  thisLCT.setBend(clct.getBend());
520  thisLCT.setBX(alct.getBX());
521  if (runCCLUT_) {
522  thisLCT.setRun3(true);
524  gem.isValid()) { //calculate new slope from strip difference between CLCT and associated GEM
525  int slope = cscGEMMatcher_->calculateGEMCSCBending(clct, gem);
526  thisLCT.setSlope(abs(slope));
527  thisLCT.setBend(std::signbit(slope));
529  } else
530  thisLCT.setSlope(clct.getSlope());
531  thisLCT.setQuartStripBit(clct.getQuartStripBit());
532  thisLCT.setEighthStripBit(clct.getEighthStripBit());
533  thisLCT.setRun3Pattern(clct.getRun3Pattern());
534  }
535 }
536 
537 // Construct LCT from CSC and GEM information. Option ALCT-CLCT
539  const CSCCLCTDigi& cLCT,
540  CSCCorrelatedLCTDigi& thisLCT) const {
541  thisLCT.setValid(true);
543  thisLCT.setALCT(getBXShiftedALCT(aLCT));
544  thisLCT.setCLCT(getBXShiftedCLCT(cLCT));
545  thisLCT.setPattern(encodePattern(cLCT.getPattern()));
546  thisLCT.setMPCLink(0);
547  thisLCT.setBX0(0);
548  thisLCT.setSyncErr(0);
549  thisLCT.setCSCID(theTrigChamber);
550  thisLCT.setTrknmb(0); // will be set later after sorting
551  thisLCT.setWireGroup(aLCT.getKeyWG());
552  thisLCT.setStrip(cLCT.getKeyStrip());
553  thisLCT.setBend(cLCT.getBend());
554  thisLCT.setBX(aLCT.getBX());
555  thisLCT.setQuality(qualityAssignment_->findQuality(aLCT, cLCT));
556  if (runCCLUT_) {
557  thisLCT.setRun3(true);
558  // 4-bit slope value derived with the CCLUT algorithm
559  thisLCT.setSlope(cLCT.getSlope());
560  thisLCT.setQuartStripBit(cLCT.getQuartStripBit());
561  thisLCT.setEighthStripBit(cLCT.getEighthStripBit());
562  thisLCT.setRun3Pattern(cLCT.getRun3Pattern());
563  }
564 }
565 
566 // Construct LCT from CSC and GEM information. Option CLCT-2GEM
568  const GEMInternalCluster& gem,
569  CSCCorrelatedLCTDigi& thisLCT) const {
570  thisLCT.setValid(true);
572  thisLCT.setQuality(qualityAssignment_->findQuality(clct, gem));
573  thisLCT.setCLCT(getBXShiftedCLCT(clct));
574  thisLCT.setGEM1(gem.mid1());
575  thisLCT.setGEM2(gem.mid2());
576  thisLCT.setPattern(encodePattern(clct.getPattern()));
577  thisLCT.setMPCLink(0);
578  thisLCT.setBX0(0);
579  thisLCT.setSyncErr(0);
580  thisLCT.setCSCID(theTrigChamber);
581  thisLCT.setTrknmb(0); // will be set later after sorting
582  thisLCT.setWireGroup(gem.getKeyWG());
583  thisLCT.setStrip(clct.getKeyStrip());
584  thisLCT.setBend(clct.getBend());
585  thisLCT.setBX(gem.bx());
586  if (runCCLUT_) {
587  thisLCT.setRun3(true);
589  gem.isValid()) { //calculate new slope from strip difference between CLCT and associated GEM
590  int slope = cscGEMMatcher_->calculateGEMCSCBending(clct, gem);
591  thisLCT.setSlope(abs(slope));
592  thisLCT.setBend(pow(-1, std::signbit(slope)));
594  } else
595  thisLCT.setSlope(clct.getSlope());
596  thisLCT.setQuartStripBit(clct.getQuartStripBit());
597  thisLCT.setEighthStripBit(clct.getEighthStripBit());
598  thisLCT.setRun3Pattern(clct.getRun3Pattern());
599  }
600 }
601 
602 // Construct LCT from CSC and GEM information. Option ALCT-2GEM
604  const GEMInternalCluster& gem,
605  CSCCorrelatedLCTDigi& thisLCT) const {
606  thisLCT.setValid(true);
608  thisLCT.setQuality(qualityAssignment_->findQuality(alct, gem));
609  thisLCT.setALCT(getBXShiftedALCT(alct));
610  thisLCT.setGEM1(gem.mid1());
611  thisLCT.setGEM2(gem.mid2());
612  thisLCT.setPattern(10);
613  thisLCT.setMPCLink(0);
614  thisLCT.setBX0(0);
615  thisLCT.setSyncErr(0);
616  thisLCT.setCSCID(theTrigChamber);
617  thisLCT.setTrknmb(0); // will be set later after sorting
618  thisLCT.setWireGroup(alct.getKeyWG());
619  thisLCT.setStrip(gem.getKeyStrip());
620  thisLCT.setBend(0);
621  thisLCT.setBX(alct.getBX());
622  if (runCCLUT_) {
623  thisLCT.setRun3(true);
624  thisLCT.setSlope(0);
625  thisLCT.setQuartStripBit(false);
626  thisLCT.setEighthStripBit(false);
627  // ALCT-2GEM type LCTs do not bend in the chamber
628  thisLCT.setRun3Pattern(4);
629  }
630 }
631 
632 void CSCGEMMotherboard::sortLCTs(std::vector<CSCCorrelatedLCTDigi>& lcts) const {
633  // LCTs are sorted by quality. If there are two with the same quality, then the sorting is done by the slope
634  std::sort(lcts.begin(), lcts.end(), [](const CSCCorrelatedLCTDigi& lct1, const CSCCorrelatedLCTDigi& lct2) -> bool {
635  if (lct1.getQuality() > lct2.getQuality())
636  return lct1.getQuality() > lct2.getQuality();
637  else if (lct1.getQuality() == lct2.getQuality())
638  return lct1.getSlope() < lct2.getSlope();
639  else
640  return false;
641  });
642 }
643 
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 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_