CMS 3D CMS Logo

CSCGEMMotherboardME11.cc
Go to the documentation of this file.
1 #include <memory>
2 
4 
6  unsigned station,
7  unsigned sector,
8  unsigned subsector,
9  unsigned chamber,
10  const edm::ParameterSet& conf)
11  : CSCGEMMotherboard(endcap, station, sector, subsector, chamber, conf)
12  // special configuration parameters for ME11 treatment
13  ,
14  dropLowQualityCLCTsNoGEMs_ME1a_(tmbParams_.getParameter<bool>("dropLowQualityCLCTsNoGEMs_ME1a")),
15  dropLowQualityCLCTsNoGEMs_ME1b_(tmbParams_.getParameter<bool>("dropLowQualityCLCTsNoGEMs_ME1b")),
16  dropLowQualityALCTsNoGEMs_ME1a_(tmbParams_.getParameter<bool>("dropLowQualityALCTsNoGEMs_ME1a")),
17  dropLowQualityALCTsNoGEMs_ME1b_(tmbParams_.getParameter<bool>("dropLowQualityALCTsNoGEMs_ME1b")),
18  buildLCTfromALCTandGEM_ME1a_(tmbParams_.getParameter<bool>("buildLCTfromALCTandGEM_ME1a")),
19  buildLCTfromALCTandGEM_ME1b_(tmbParams_.getParameter<bool>("buildLCTfromALCTandGEM_ME1b")),
20  buildLCTfromCLCTandGEM_ME1a_(tmbParams_.getParameter<bool>("buildLCTfromCLCTandGEM_ME1a")),
21  buildLCTfromCLCTandGEM_ME1b_(tmbParams_.getParameter<bool>("buildLCTfromCLCTandGEM_ME1b")),
22  promoteCLCTGEMquality_ME1a_(tmbParams_.getParameter<bool>("promoteCLCTGEMquality_ME1a")),
23  promoteCLCTGEMquality_ME1b_(tmbParams_.getParameter<bool>("promoteCLCTGEMquality_ME1b")) {
24  if (!runPhase2_) {
25  edm::LogError("CSCGEMMotherboardME11|SetupError") << "+++ TMB constructed while runPhase2 is not set! +++\n";
26  }
27 
28  if (!runME11ILT_) {
29  edm::LogError("CSCGEMMotherboardME11|SetupError") << "+++ TMB constructed while runME11ILT_ is not set! +++\n";
30  };
31 
32  // set LUTs
33  tmbLUT_ = std::make_unique<CSCGEMMotherboardLUTME11>();
34  cscTmbLUT_ = std::make_unique<CSCMotherboardLUTME11>();
35 }
36 
38  // Constructor used only for testing.
39  if (!runPhase2_) {
40  edm::LogError("CSCGEMMotherboardME11|SetupError") << "+++ TMB constructed while runPhase2 is not set! +++\n";
41  }
42 
43  if (!runME11ILT_) {
44  edm::LogError("CSCGEMMotherboardME11|SetupError") << "+++ TMB constructed while runME11ILT_ is not set! +++\n";
45  }
46 }
47 
49 
50 //===============================================
51 //use ALCTs, CLCTs, GEMs to build LCTs
52 //loop over each BX to find valid ALCT in ME1b, try ALCT-CLCT match, if ALCT-CLCT match failed, try ALCT-GEM match
53 //do the same in ME1a
54 //sort LCTs according to different algorithm, and send out number of LCTs up to max_lcts
55 //===============================================
56 
58  const CSCComparatorDigiCollection* compdc,
59  const GEMPadDigiClusterCollection* gemClusters) {
61 
62  // encode high multiplicity bits
63  unsigned alctBits = alctProc->getHighMultiplictyBits();
65 
66  if (gem_g != nullptr) {
67  if (infoV >= 0)
68  edm::LogInfo("CSCGEMMotherboardME11|SetupInfo") << "+++ run() called for GEM-CSC integrated trigger! +++ \n";
69  gemGeometryAvailable = true;
70  }
71 
72  // check for GEM geometry
73  if (not gemGeometryAvailable) {
74  edm::LogError("CSCGEMMotherboardME11|SetupError")
75  << "+++ run() called for GEM-CSC integrated trigger without valid GEM geometry! +++ \n";
76  return;
77  }
78 
79  if (!(alctProc and clctProc)) {
80  edm::LogError("CSCGEMMotherboardME11|SetupError")
81  << "+++ run() called for non-existing ALCT/CLCT processor! +++ \n";
82  return;
83  }
84 
85  alctProc->setCSCGeometry(cscGeometry_);
86  clctProc->setCSCGeometry(cscGeometry_);
87 
88  alctV = alctProc->run(wiredc); // run anodeLCT
89  clctV = clctProc->run(compdc); // run cathodeLCT
90 
91  processGEMClusters(gemClusters);
92 
93  // if there are no ALCTs and no CLCTs, it does not make sense to run this TMB
94  if (alctV.empty() and clctV.empty())
95  return;
96 
97  int used_clct_mask[20];
98  for (int b = 0; b < 20; b++)
99  used_clct_mask[b] = 0;
100 
101  const bool hasPads(!pads_.empty());
102  const bool hasCoPads(hasPads and !coPads_.empty());
103 
104  if (debug_matching)
105  LogTrace("CSCGEMMotherboardME11") << "hascopads " << hasCoPads << std::endl;
106 
107  // ALCT-centric matching
108  for (int bx_alct = 0; bx_alct < CSCConstants::MAX_ALCT_TBINS; bx_alct++) {
109  if (alctProc->getBestALCT(bx_alct).isValid()) {
110  const int bx_clct_start(bx_alct - match_trig_window_size / 2 - CSCConstants::ALCT_CLCT_OFFSET);
111  const int bx_clct_stop(bx_alct + match_trig_window_size / 2 - CSCConstants::ALCT_CLCT_OFFSET);
112  const int bx_copad_start(bx_alct - maxDeltaBXCoPad_);
113  const int bx_copad_stop(bx_alct + maxDeltaBXCoPad_);
114 
115  if (debug_matching) {
116  LogTrace("CSCGEMMotherboardME11")
117  << "========================================================================\n"
118  << "ALCT-CLCT matching in ME1/1 chamber: " << cscId_ << "\n"
119  << "------------------------------------------------------------------------\n"
120  << "+++ Best ALCT Details: " << alctProc->getBestALCT(bx_alct) << "\n"
121  << "+++ Second ALCT Details: " << alctProc->getSecondALCT(bx_alct) << std::endl;
122 
123  printGEMTriggerPads(bx_clct_start, bx_clct_stop, CSCPart::ME11);
124  printGEMTriggerCoPads(bx_clct_start, bx_clct_stop, CSCPart::ME11);
125 
126  LogTrace("CSCGEMMotherboardME11")
127  << "------------------------------------------------------------------------ \n"
128  << "Attempt ALCT-CLCT matching in ME1/b in bx range: [" << bx_clct_start << "," << bx_clct_stop << "]"
129  << std::endl;
130  }
131 
132  // ALCT-to-CLCT matching in ME1b
133  int nSuccesFulMatches = 0;
134  for (int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++) {
135  if (bx_clct < 0 or bx_clct >= CSCConstants::MAX_CLCT_TBINS)
136  continue;
137  if (drop_used_clcts and used_clct_mask[bx_clct])
138  continue;
139  if (clctProc->getBestCLCT(bx_clct).isValid()) {
140  if (debug_matching)
141  LogTrace("CSCGEMMotherboardME11") << "++Valid ME1b CLCT: " << clctProc->getBestCLCT(bx_clct) << std::endl;
142 
143  // pick the pad that corresponds
144  matches<GEMPadDigi> mPads;
145  matchingPads<GEMPadDigi>(clctProc->getBestCLCT(bx_clct),
146  clctProc->getSecondCLCT(bx_clct),
147  alctProc->getBestALCT(bx_alct),
148  alctProc->getSecondALCT(bx_alct),
149  mPads);
150  matches<GEMCoPadDigi> mCoPads;
151  matchingPads<GEMCoPadDigi>(clctProc->getBestCLCT(bx_clct),
152  clctProc->getSecondCLCT(bx_clct),
153  alctProc->getBestALCT(bx_alct),
154  alctProc->getSecondALCT(bx_alct),
155  mCoPads);
156 
157  const bool lowQualityCLCT(clctProc->getBestCLCT(bx_clct).getQuality() <= 3);
158  const bool hasMatchingPads(!mPads.empty() or !mCoPads.empty());
159  // Low quality LCTs have at most 3 layers. Check if there is a matching GEM pad to keep the CLCT
160  if (dropLowQualityCLCTsNoGEMs_ME1b_ and lowQualityCLCT and !hasMatchingPads) {
161  LogTrace("CSCGEMMotherboardME11") << "Dropping low quality CLCT without matching GEM pads "
162  << clctProc->getBestCLCT(bx_clct) << std::endl;
163  continue;
164  }
165 
166  if (debug_matching) {
167  LogTrace("CSCGEMMotherboardME11") << "mPads " << mPads.size() << " "
168  << " mCoPads " << mCoPads.size() << std::endl;
169  for (auto p : mPads) {
170  LogTrace("CSCGEMMotherboardME11") << p.first << " " << p.second << std::endl;
171  }
172  for (auto p : mCoPads) {
173  LogTrace("CSCGEMMotherboardME11") << p.first << " " << p.second << std::endl;
174  }
175  }
176  // if (infoV > 1) LogTrace("CSCMotherboard")
177  int mbx = bx_clct - bx_clct_start;
178  correlateLCTsGEM(alctProc->getBestALCT(bx_alct),
179  alctProc->getSecondALCT(bx_alct),
180  clctProc->getBestCLCT(bx_clct),
181  clctProc->getSecondCLCT(bx_clct),
182  mPads,
183  mCoPads,
184  allLCTs(bx_alct, mbx, 0),
185  allLCTs(bx_alct, mbx, 1));
186 
187  if (allLCTs(bx_alct, mbx, 0).isValid()) {
188  ++nSuccesFulMatches;
189  used_clct_mask[bx_clct] += 1;
190 
191  if (debug_matching) {
192  LogTrace("CSCGEMMotherboardME11")
193  << "Successful ALCT-CLCT match in ME1b: bx_alct = " << bx_alct << "; match window: [" << bx_clct_start
194  << "; " << bx_clct_stop << "]; bx_clct = " << bx_clct << "\n"
195  << "+++ Best CLCT Details: " << clctProc->getBestCLCT(bx_clct) << "\n"
196  << "+++ Second CLCT Details: " << clctProc->getSecondCLCT(bx_clct) << std::endl;
197  if (allLCTs(bx_alct, mbx, 0).isValid()) {
198  LogTrace("CSCGEMMotherboardME11") << "LCT #1 " << allLCTs(bx_alct, mbx, 0) << std::endl;
199  LogTrace("CSCGEMMotherboardME11") << allLCTs(bx_alct, mbx, 0).getALCT() << std::endl;
200  LogTrace("CSCGEMMotherboardME11") << allLCTs(bx_alct, mbx, 0).getCLCT() << std::endl;
201  if (allLCTs(bx_alct, mbx, 0).getType() == 2)
202  LogTrace("CSCGEMMotherboardME11") << allLCTs(bx_alct, mbx, 0).getGEM1() << std::endl;
203  if (allLCTs(bx_alct, mbx, 0).getType() == 3)
204  LogTrace("CSCGEMMotherboardME11")
205  << allLCTs(bx_alct, mbx, 0).getGEM1() << " " << allLCTs(bx_alct, mbx, 0).getGEM2() << std::endl;
206  }
207 
208  if (allLCTs(bx_alct, mbx, 1).isValid()) {
209  LogTrace("CSCGEMMotherboardME11") << "LCT #2 " << allLCTs(bx_alct, mbx, 1) << std::endl;
210  LogTrace("CSCGEMMotherboardME11") << allLCTs(bx_alct, mbx, 1).getALCT() << std::endl;
211  LogTrace("CSCGEMMotherboardME11") << allLCTs(bx_alct, mbx, 1).getCLCT() << std::endl;
212  if (allLCTs(bx_alct, mbx, 1).getType() == 2)
213  LogTrace("CSCGEMMotherboardME11") << allLCTs(bx_alct, mbx, 1).getGEM1() << std::endl;
214  if (allLCTs(bx_alct, mbx, 1).getType() == 3)
215  LogTrace("CSCGEMMotherboardME11")
216  << allLCTs(bx_alct, mbx, 1).getGEM1() << " " << allLCTs(bx_alct, mbx, 1).getGEM2() << std::endl;
217  }
218  }
219 
221  break;
222  } else
223  LogTrace("CSCGEMMotherboardME11") << "No valid LCT is built from ALCT-CLCT matching in ME1b" << std::endl;
224  }
225  }
226 
227  // ALCT-to-GEM matching in ME1b
228  int nSuccesFulGEMMatches = 0;
229  if (nSuccesFulMatches == 0 and buildLCTfromALCTandGEM_ME1b_) {
230  if (debug_matching)
231  LogTrace("CSCGEMMotherboardME11") << "++No valid ALCT-CLCT matches in ME1b" << std::endl;
232  for (int bx_gem = bx_copad_start; bx_gem <= bx_copad_stop; bx_gem++) {
233  if (not hasCoPads) {
234  continue;
235  }
236 
237  // find the best matching copad
238  matches<GEMCoPadDigi> copads;
239  matchingPads<CSCALCTDigi, GEMCoPadDigi>(
240  alctProc->getBestALCT(bx_alct), alctProc->getSecondALCT(bx_alct), copads);
241 
242  if (debug_matching)
243  LogTrace("CSCGEMMotherboardME11")
244  << "\t++Number of matching GEM CoPads in BX " << bx_alct << " : " << copads.size() << std::endl;
245  if (copads.empty()) {
246  continue;
247  }
248 
249  CSCGEMMotherboard::correlateLCTsGEM(alctProc->getBestALCT(bx_alct),
250  alctProc->getSecondALCT(bx_alct),
251  copads,
252  allLCTs(bx_alct, 0, 0),
253  allLCTs(bx_alct, 0, 1));
254 
255  if (allLCTs(bx_alct, 0, 0).isValid()) {
256  ++nSuccesFulGEMMatches;
257 
258  if (debug_matching) {
259  LogTrace("CSCGEMMotherboardME11")
260  << "Successful ALCT-GEM CoPad match in ME1b: bx_alct = " << bx_alct << "\n\n"
261  << "------------------------------------------------------------------------" << std::endl
262  << std::endl;
263  if (allLCTs(bx_alct, 0, 0).isValid()) {
264  LogTrace("CSCGEMMotherboardME11") << "LCT #1 " << allLCTs(bx_alct, 0, 0) << std::endl;
265  LogTrace("CSCGEMMotherboardME11") << allLCTs(bx_alct, 0, 0).getALCT() << std::endl;
266  if (allLCTs(bx_alct, 0, 0).getType() == 4)
267  LogTrace("CSCGEMMotherboardME11")
268  << allLCTs(bx_alct, 0, 0).getGEM1() << " " << allLCTs(bx_alct, 0, 0).getGEM2() << std::endl
269  << std::endl;
270  } else {
271  LogTrace("CSCGEMMotherboardME11")
272  << "No valid LCT is built from ALCT-GEM matching in ME1b" << std::endl;
273  }
274  if (allLCTs(bx_alct, 0, 1).isValid()) {
275  LogTrace("CSCGEMMotherboardME11") << "LCT #2 " << allLCTs(bx_alct, 0, 1) << std::endl;
276  LogTrace("CSCGEMMotherboardME11") << allLCTs(bx_alct, 0, 1).getALCT() << std::endl;
277  if (allLCTs(bx_alct, 0, 1).getType() == 4)
278  LogTrace("CSCGEMMotherboardME11")
279  << allLCTs(bx_alct, 0, 1).getGEM1() << " " << allLCTs(bx_alct, 0, 1).getGEM2() << std::endl
280  << std::endl;
281  }
282  }
283 
285  break;
286  }
287  }
288  }
289 
290  if (debug_matching) {
291  LogTrace("CSCGEMMotherboardME11")
292  << "========================================================================" << std::endl
293  << "Summary: " << std::endl;
294  if (nSuccesFulMatches > 1)
295  LogTrace("CSCGEMMotherboardME11")
296  << "Too many successful ALCT-CLCT matches in ME1/1: " << nSuccesFulMatches << ", CSCDetId " << cscId_
297  << ", bx_alct = " << bx_alct << "; match window: [" << bx_clct_start << "; " << bx_clct_stop << "]"
298  << std::endl;
299  else if (nSuccesFulMatches == 1)
300  LogTrace("CSCGEMMotherboardME11")
301  << "1 successful ALCT-CLCT match in ME1/1: "
302  << " CSCDetId " << cscId_ << ", bx_alct = " << bx_alct << "; match window: [" << bx_clct_start << "; "
303  << bx_clct_stop << "]" << std::endl;
304  else if (nSuccesFulGEMMatches == 1)
305  LogTrace("CSCGEMMotherboardME11")
306  << "1 successful ALCT-GEM match in ME1/1: "
307  << " CSCDetId " << cscId_ << ", bx_alct = " << bx_alct << "; match window: [" << bx_clct_start << "; "
308  << bx_clct_stop << "]" << std::endl;
309  else
310  LogTrace("CSCGEMMotherboardME11") << "Unsuccessful ALCT-CLCT match in ME1/1: "
311  << "CSCDetId " << cscId_ << ", bx_alct = " << bx_alct << "; match window: ["
312  << bx_clct_start << "; " << bx_clct_stop << "]" << std::endl;
313  }
314  } // end of ALCT valid block
315  else {
316  auto coPads(coPads_[bx_alct]);
317  if (!coPads.empty()) {
318  // keep it simple for the time being, only consider the first copad
319  const int bx_clct_start(bx_alct - match_trig_window_size / 2 - CSCConstants::ALCT_CLCT_OFFSET);
320  const int bx_clct_stop(bx_alct + match_trig_window_size / 2 - CSCConstants::ALCT_CLCT_OFFSET);
321 
322  // matching in ME1b
324  for (int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++) {
325  if (bx_clct < 0 or bx_clct >= CSCConstants::MAX_CLCT_TBINS)
326  continue;
327  if (drop_used_clcts and used_clct_mask[bx_clct])
328  continue;
329  if (clctProc->getBestCLCT(bx_clct).isValid()) {
330  const int quality(clctProc->getBestCLCT(bx_clct).getQuality());
331  // only use high-Q stubs for the time being
332  if (quality < 4)
333  continue;
334  int mbx = bx_clct - bx_clct_start;
335  CSCGEMMotherboard::correlateLCTsGEM(clctProc->getBestCLCT(bx_clct),
336  clctProc->getSecondCLCT(bx_clct),
337  coPads,
338  allLCTs(bx_alct, mbx, 0),
339  allLCTs(bx_alct, mbx, 1));
340  if (allLCTs(bx_alct, mbx, 0).isValid()) {
341  used_clct_mask[bx_clct] += 1;
342 
343  if (debug_matching) {
344  // if (infoV > 1) LogTrace("CSCMotherboard")
345  LogTrace("CSCGEMMotherboardME11")
346  << "Successful GEM-CLCT match in ME1b: bx_alct = " << bx_alct << "; match window: ["
347  << bx_clct_start << "; " << bx_clct_stop << "]; bx_clct = " << bx_clct << "\n"
348  << "+++ Best CLCT Details: " << clctProc->getBestCLCT(bx_clct) << "\n"
349  << "+++ Second CLCT Details: " << clctProc->getSecondCLCT(bx_clct) << std::endl;
350 
351  LogTrace("CSCGEMMotherboardME11") << "LCT #1 " << allLCTs(bx_alct, mbx, 0) << std::endl;
352  LogTrace("CSCGEMMotherboardME11") << allLCTs(bx_alct, mbx, 0).getALCT() << std::endl;
353  if (allLCTs(bx_alct, mbx, 0).getType() == 5)
354  LogTrace("CSCGEMMotherboardME11")
355  << allLCTs(bx_alct, mbx, 0).getGEM1() << " " << allLCTs(bx_alct, mbx, 0).getGEM2() << std::endl
356  << std::endl;
357 
358  LogTrace("CSCGEMMotherboardME11") << "LCT #2 " << allLCTs(bx_alct, mbx, 1) << std::endl;
359  LogTrace("CSCGEMMotherboardME11") << allLCTs(bx_alct, mbx, 1).getALCT() << std::endl;
360  if (allLCTs(bx_alct, mbx, 1).getType() == 5)
361  LogTrace("CSCGEMMotherboardME11")
362  << allLCTs(bx_alct, mbx, 1).getGEM1() << " " << allLCTs(bx_alct, mbx, 1).getGEM2() << std::endl
363  << std::endl;
364  }
365 
367  break;
368  }
369  }
370  } //end of clct loop
371  }
372  } // if (!coPads.empty())
373  }
374  } // end of ALCT-centric matching
375 
376  if (debug_matching) {
377  LogTrace("CSCGEMMotherboardME11") << "======================================================================== \n"
378  << "Counting the final LCTs in CSCGEMMotherboard ME11\n"
379  << "======================================================================== \n"
380  << "tmb_cross_bx_algo: " << tmb_cross_bx_algo << std::endl;
381  unsigned int n1b = 0, n1a = 0;
382  for (const auto& p : readoutLCTs1b()) {
383  n1b++;
384  LogTrace("CSCGEMMotherboardME11") << "1b LCT " << n1b << " " << p << std::endl;
385  }
386 
387  for (const auto& p : readoutLCTs1a()) {
388  n1a++;
389  LogTrace("CSCGEMMotherboardME11") << "1a LCT " << n1a << " " << p << std::endl;
390  }
391  }
392 }
393 
394 std::vector<CSCCorrelatedLCTDigi> CSCGEMMotherboardME11::readoutLCTs1a() const { return readoutLCTsME11(ME1A); }
395 
396 std::vector<CSCCorrelatedLCTDigi> CSCGEMMotherboardME11::readoutLCTs1b() const { return readoutLCTsME11(ME1B); }
397 
398 // Returns vector of read-out correlated LCTs, if any. Starts with
399 // the vector of all found LCTs and selects the ones in the read-out
400 // time window.
401 std::vector<CSCCorrelatedLCTDigi> CSCGEMMotherboardME11::readoutLCTsME11(enum CSCPart me1ab) const {
402  std::vector<CSCCorrelatedLCTDigi> tmpV;
403 
404  // The start time of the L1A*LCT coincidence window should be related
405  // to the fifo_pretrig parameter, but I am not completely sure how.
406  // Just choose it such that the window is centered at bx=7. This may
407  // need further tweaking if the value of tmb_l1a_window_size changes.
408  //static int early_tbins = 4;
409  // The number of LCT bins in the read-out is given by the
410  // tmb_l1a_window_size parameter, forced to be odd
411  const int lct_bins = (tmb_l1a_window_size % 2 == 0) ? tmb_l1a_window_size + 1 : tmb_l1a_window_size;
412  const int late_tbins = early_tbins + lct_bins;
413 
414  // Start from the vector of all found correlated LCTs and select
415  // those within the LCT*L1A coincidence window.
416  int bx_readout = -1;
417  std::vector<CSCCorrelatedLCTDigi> all_lcts;
418  switch (tmb_cross_bx_algo) {
419  case 0:
420  case 1:
421  allLCTs.getMatched(all_lcts);
422  break;
423  case 2:
425  break;
426  case 3:
428  break;
429  default:
430  LogTrace("CSCGEMMotherboardME11") << "tmb_cross_bx_algo error" << std::endl;
431  break;
432  }
433 
434  for (const auto& lct : all_lcts) {
435  if (!lct.isValid())
436  continue;
437 
438  int bx = lct.getBX();
439  // Skip LCTs found too early relative to L1Accept.
440  if (bx <= early_tbins)
441  continue;
442 
443  // Skip LCTs found too late relative to L1Accept.
444  if (bx > late_tbins)
445  continue;
446 
447  if ((me1ab == CSCPart::ME1B and lct.getStrip() > CSCConstants::MAX_HALF_STRIP_ME1B) or
448  (me1ab == CSCPart::ME1A and lct.getStrip() <= CSCConstants::MAX_HALF_STRIP_ME1B))
449  continue;
450 
451  // If (readout_earliest_2) take only LCTs in the earliest bx in the read-out window:
452  // in digi->raw step, LCTs have to be packed into the TMB header, and
453  // currently there is room just for two.
454  if (readout_earliest_2 and (bx_readout == -1 or bx == bx_readout)) {
455  tmpV.push_back(lct);
456  if (bx_readout == -1)
457  bx_readout = bx;
458  } else
459  tmpV.push_back(lct);
460  }
461 
462  // do a final check on the LCTs in readout
463  qualityControl_->checkMultiplicityBX(tmpV);
464  for (const auto& lct : tmpV) {
465  qualityControl_->checkValid(lct);
466  }
467 
468  return tmpV;
469 }
470 
471 //sort LCTs in each BX
472 //
473 void CSCGEMMotherboardME11::sortLCTs(std::vector<CSCCorrelatedLCTDigi>& LCTs,
474  int bx,
475  bool (*sorter)(const CSCCorrelatedLCTDigi&, const CSCCorrelatedLCTDigi&)) const {
476  allLCTs.getTimeMatched(bx, LCTs);
477 
479 
480  if (LCTs.size() > max_lcts)
481  LCTs.erase(LCTs.begin() + max_lcts, LCTs.end());
482 }
483 
484 //sort LCTs in whole LCTs BX window
485 void CSCGEMMotherboardME11::sortLCTs(std::vector<CSCCorrelatedLCTDigi>& LCTs,
486  bool (*sorter)(const CSCCorrelatedLCTDigi&, const CSCCorrelatedLCTDigi&)) const {
487  for (int bx = 0; bx < CSCConstants::MAX_LCT_TBINS; bx++) {
488  // temporary collection with all LCTs in the whole chamber
489  std::vector<CSCCorrelatedLCTDigi> LCTs_tmp;
491 
492  // Add the LCTs
493  for (const auto& p : LCTs_tmp) {
494  LCTs.push_back(p);
495  }
496  }
497 }
498 
500  return cscTmbLUT_->doesALCTCrossCLCT(a, c, theEndcap, gangedME1a_);
501 }
502 
503 bool CSCGEMMotherboardME11::doesWiregroupCrossStrip(int key_wg, int key_strip) const {
504  return cscTmbLUT_->doesWiregroupCrossStrip(key_wg, key_strip, theEndcap, gangedME1a_);
505 }
506 
508  const CSCALCTDigi& sALCT,
509  const CSCCLCTDigi& bCLCT,
510  const CSCCLCTDigi& sCLCT,
511  const GEMPadDigiIds& pads,
512  const GEMCoPadDigiIds& copads,
513  CSCCorrelatedLCTDigi& lct1,
514  CSCCorrelatedLCTDigi& lct2) const {
515  const CSCALCTDigi& bestALCT = bALCT;
516  CSCALCTDigi secondALCT = sALCT;
517  const CSCCLCTDigi& bestCLCT = bCLCT;
518  CSCCLCTDigi secondCLCT = sCLCT;
519 
520  // assume that always anodeBestValid and cathodeBestValid
521  if (secondALCT == bestALCT)
522  secondALCT.clear();
523  if (secondCLCT == bestCLCT)
524  secondCLCT.clear();
525 
526  const bool ok_bb = bestALCT.isValid() and bestCLCT.isValid();
527  const bool ok_bs = bestALCT.isValid() and secondCLCT.isValid();
528  const bool ok_sb = secondALCT.isValid() and bestCLCT.isValid();
529  const bool ok_ss = secondALCT.isValid() and secondCLCT.isValid();
530 
531  const int ok11 = doesALCTCrossCLCT(bestALCT, bestCLCT);
532  const int ok12 = doesALCTCrossCLCT(bestALCT, secondCLCT);
533  const int ok21 = doesALCTCrossCLCT(secondALCT, bestCLCT);
534  const int ok22 = doesALCTCrossCLCT(secondALCT, secondCLCT);
535  const int code = (ok11 << 3) | (ok12 << 2) | (ok21 << 1) | (ok22);
536 
537  int dbg = 0;
538  if (dbg)
539  LogTrace("CSCGEMMotherboardME11") << "debug correlateLCTs in ME11" << cscId_ << "\n"
540  << "ALCT1: " << bestALCT << "\n"
541  << "ALCT2: " << secondALCT << "\n"
542  << "CLCT1: " << bestCLCT << "\n"
543  << "CLCT2: " << secondCLCT << "\n"
544  << "ok 11 12 21 22 code = " << ok11 << " " << ok12 << " " << ok21 << " " << ok22
545  << " " << code << std::endl;
546 
547  if (code == 0)
548  return;
549 
550  // LUT defines correspondence between possible ok## combinations
551  // and resulting lct1 and lct2
552  int lut[16][2] = {
553  //ok: 11 12 21 22
554  {0, 0}, // 0 0 0 0
555  {22, 0}, // 0 0 0 1
556  {21, 0}, // 0 0 1 0
557  {21, 22}, // 0 0 1 1
558  {12, 0}, // 0 1 0 0
559  {12, 22}, // 0 1 0 1
560  {12, 21}, // 0 1 1 0
561  {12, 21}, // 0 1 1 1
562  {11, 0}, // 1 0 0 0
563  {11, 22}, // 1 0 0 1
564  {11, 21}, // 1 0 1 0
565  {11, 22}, // 1 0 1 1
566  {11, 12}, // 1 1 0 0
567  {11, 22}, // 1 1 0 1
568  {11, 12}, // 1 1 1 0
569  {11, 22}, // 1 1 1 1
570  };
571 
572  if (dbg)
573  LogTrace("CSCGEMMotherboardME11") << "lut 0 1 = " << lut[code][0] << " " << lut[code][1] << std::endl;
574 
575  // check matching copads
576  const GEMCoPadDigi& bb_copad = bestMatchingPad<GEMCoPadDigi>(bestALCT, bestCLCT, copads);
577  const GEMCoPadDigi& bs_copad = bestMatchingPad<GEMCoPadDigi>(bestALCT, secondCLCT, copads);
578  const GEMCoPadDigi& sb_copad = bestMatchingPad<GEMCoPadDigi>(secondALCT, bestCLCT, copads);
579  const GEMCoPadDigi& ss_copad = bestMatchingPad<GEMCoPadDigi>(secondALCT, secondCLCT, copads);
580 
581  // check matching pads
582  const GEMPadDigi& bb_pad = bestMatchingPad<GEMPadDigi>(bestALCT, bestCLCT, pads);
583  const GEMPadDigi& bs_pad = bestMatchingPad<GEMPadDigi>(bestALCT, secondCLCT, pads);
584  const GEMPadDigi& sb_pad = bestMatchingPad<GEMPadDigi>(secondALCT, bestCLCT, pads);
585  const GEMPadDigi& ss_pad = bestMatchingPad<GEMPadDigi>(secondALCT, secondCLCT, pads);
586 
587  // evaluate possible combinations
588  const bool ok_bb_copad = ok11 == 1 and ok_bb and bb_copad.isValid();
589  const bool ok_bs_copad = ok12 == 1 and ok_bs and bs_copad.isValid();
590  const bool ok_sb_copad = ok21 == 1 and ok_sb and sb_copad.isValid();
591  const bool ok_ss_copad = ok22 == 1 and ok_ss and ss_copad.isValid();
592 
593  const bool ok_bb_pad = ok11 == 1 and ok_bb and bb_pad.isValid();
594  const bool ok_bs_pad = ok12 == 1 and ok_bs and bs_pad.isValid();
595  const bool ok_sb_pad = ok21 == 1 and ok_sb and sb_pad.isValid();
596  const bool ok_ss_pad = ok22 == 1 and ok_ss and ss_pad.isValid();
597 
598  switch (lut[code][0]) {
599  case 11:
600  if (ok_bb_copad)
601  lct1 = CSCGEMMotherboard::constructLCTsGEM(bestALCT, bestCLCT, bb_copad, 1);
602  else if (ok_bb_pad)
603  lct1 = CSCGEMMotherboard::constructLCTsGEM(bestALCT, bestCLCT, bb_pad, 1);
604  else
605  lct1 = constructLCTs(bestALCT, bestCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 1);
606  break;
607  case 12:
608  if (ok_bs_copad)
609  lct1 = CSCGEMMotherboard::constructLCTsGEM(bestALCT, secondCLCT, bs_copad, 1);
610  else if (ok_bs_pad)
611  lct1 = CSCGEMMotherboard::constructLCTsGEM(bestALCT, secondCLCT, bs_pad, 1);
612  else
613  lct1 = constructLCTs(bestALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 1);
614  break;
615  case 21:
616  if (ok_sb_copad)
617  lct1 = CSCGEMMotherboard::constructLCTsGEM(secondALCT, bestCLCT, sb_copad, 1);
618  else if (ok_sb_pad)
619  lct1 = CSCGEMMotherboard::constructLCTsGEM(secondALCT, bestCLCT, sb_pad, 1);
620  else
621  lct1 = constructLCTs(secondALCT, bestCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 1);
622  break;
623  case 22:
624  if (ok_ss_copad)
625  lct1 = CSCGEMMotherboard::constructLCTsGEM(secondALCT, secondCLCT, ss_copad, 1);
626  else if (ok_ss_pad)
627  lct1 = CSCGEMMotherboard::constructLCTsGEM(secondALCT, secondCLCT, ss_pad, 1);
628  else
629  lct1 = constructLCTs(secondALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 1);
630  break;
631  default:
632  return;
633  }
634 
635  if (dbg)
636  LogTrace("CSCGEMMotherboardME11") << "lct1: " << lct1 << std::endl;
637 
638  switch (lut[code][1]) {
639  case 12:
640  if (ok_bs_copad)
641  lct2 = CSCGEMMotherboard::constructLCTsGEM(bestALCT, secondCLCT, bs_copad, 2);
642  else if (ok_bs_pad)
643  lct2 = CSCGEMMotherboard::constructLCTsGEM(bestALCT, secondCLCT, bs_pad, 2);
644  else
645  lct2 = constructLCTs(bestALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 2);
646  break;
647  case 21:
648  if (ok_sb_copad)
649  lct2 = CSCGEMMotherboard::constructLCTsGEM(secondALCT, bestCLCT, sb_copad, 2);
650  else if (ok_sb_pad)
651  lct2 = CSCGEMMotherboard::constructLCTsGEM(secondALCT, bestCLCT, sb_pad, 2);
652  else
653  lct2 = constructLCTs(secondALCT, bestCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 2);
654  break;
655  case 22:
656  if (ok_bb_copad)
657  lct2 = CSCGEMMotherboard::constructLCTsGEM(secondALCT, secondCLCT, bb_copad, 2);
658  else if (ok_bb_pad)
659  lct2 = CSCGEMMotherboard::constructLCTsGEM(secondALCT, secondCLCT, bb_pad, 2);
660  else
661  lct2 = constructLCTs(secondALCT, secondCLCT, CSCCorrelatedLCTDigi::ALCTCLCT, 2);
662  break;
663  default:
664  return;
665  }
666 
667  if (dbg)
668  LogTrace("CSCGEMMotherboardME11") << "lct2: " << lct2 << std::endl;
669 
670  if (dbg)
671  LogTrace("CSCGEMMotherboardME11") << "out of correlateLCTs" << std::endl;
672  return;
673 }
CSCMotherboard::qualityControl_
std::unique_ptr< LCTQualityControl > qualityControl_
Definition: CSCMotherboard.h:128
ME11
Definition: CSCUpgradeMotherboardLUT.h:12
electrons_cff.bool
bool
Definition: electrons_cff.py:366
CSCBaseboard::theEndcap
const unsigned theEndcap
Definition: CSCBaseboard.h:41
CSCMotherboard::match_trig_window_size
unsigned int match_trig_window_size
Definition: CSCMotherboard.h:99
CSCGEMMotherboardME11::clctV
std::vector< CSCCLCTDigi > clctV
Definition: CSCGEMMotherboardME11.h:76
GEMPadDigi
Definition: GEMPadDigi.h:17
CSCBaseboard::cscGeometry_
const CSCGeometry * cscGeometry_
Definition: CSCBaseboard.h:65
CSCConstants::MAX_ALCT_TBINS
Definition: CSCConstants.h:64
relativeConstraints.station
station
Definition: relativeConstraints.py:67
CSCMotherboard::alctProc
std::unique_ptr< CSCAnodeLCTProcessor > alctProc
Definition: CSCMotherboard.h:75
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CSCALCTDigi::clear
void clear()
clear this ALCT
Definition: CSCALCTDigi.cc:50
CSCGEMMotherboard::gemGeometryAvailable
bool gemGeometryAvailable
Definition: CSCGEMMotherboard.h:212
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
CSCGEMMotherboardME11::run
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, const GEMPadDigiClusterCollection *gemPads) override
Definition: CSCGEMMotherboardME11.cc:57
CSCGEMMotherboardME11::~CSCGEMMotherboardME11
~CSCGEMMotherboardME11() override
Definition: CSCGEMMotherboardME11.cc:48
CSCGEMMotherboard::constructLCTsGEM
CSCCorrelatedLCTDigi constructLCTsGEM(const CSCALCTDigi &alct, const GEMCoPadDigi &gem, int i) const
Definition: CSCGEMMotherboard.cc:91
CSCGEMMotherboardME11::readoutLCTs1a
std::vector< CSCCorrelatedLCTDigi > readoutLCTs1a() const
Definition: CSCGEMMotherboardME11.cc:394
CSCGEMMotherboard::coPads_
GEMCoPadDigiIdsBX coPads_
Definition: CSCGEMMotherboard.h:218
CSCUpgradeMotherboard::tmb_cross_bx_algo
unsigned int tmb_cross_bx_algo
Definition: CSCUpgradeMotherboard.h:103
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
CSCConstants::ALCT_CLCT_OFFSET
Definition: CSCConstants.h:81
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
CSCCLCTDigi
Definition: CSCCLCTDigi.h:17
CSCCorrelatedLCTDigi::ALCTCLCT
Definition: CSCCorrelatedLCTDigi.h:203
CSCGEMMotherboardME11::dropLowQualityCLCTsNoGEMs_ME1b_
bool dropLowQualityCLCTsNoGEMs_ME1b_
Definition: CSCGEMMotherboardME11.h:80
CSCBaseboard::runME11ILT_
bool runME11ILT_
Definition: CSCBaseboard.h:91
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:109
CSCMotherboard::clctProc
std::unique_ptr< CSCCathodeLCTProcessor > clctProc
Definition: CSCMotherboard.h:78
LCTContainer::getMatched
void getMatched(std::vector< CSCCorrelatedLCTDigi > &) const
Definition: LCTContainer.cc:23
CSCMotherboard::alctV
std::vector< CSCALCTDigi > alctV
Definition: CSCMotherboard.h:83
CSCGEMMotherboardME11::CSCGEMMotherboardME11
CSCGEMMotherboardME11()
Definition: CSCGEMMotherboardME11.cc:37
CSCMotherboard::constructLCTs
CSCCorrelatedLCTDigi constructLCTs(const CSCALCTDigi &aLCT, const CSCCLCTDigi &cLCT, int type, int trknmb) const
Definition: CSCMotherboard.cc:486
CSCPart
CSCPart
Definition: CSCUpgradeMotherboardLUT.h:12
CSCGEMMotherboard::correlateLCTsGEM
void correlateLCTsGEM(const T &best, const T &second, const GEMCoPadDigiIds &coPads, CSCCorrelatedLCTDigi &lct1, CSCCorrelatedLCTDigi &lct2) const
Definition: CSCGEMMotherboard.h:463
CSCGEMMotherboardME11::tmbLUT_
std::unique_ptr< CSCGEMMotherboardLUTME11 > tmbLUT_
Definition: CSCGEMMotherboardME11.h:45
CSCUpgradeMotherboard::match_earliest_clct_only
bool match_earliest_clct_only
Definition: CSCUpgradeMotherboard.h:100
CSCGEMMotherboard::processGEMClusters
void processGEMClusters(const GEMPadDigiClusterCollection *pads)
Definition: CSCGEMMotherboard.cc:41
CSCUpgradeMotherboard::sortLCTsByGEMDphi
static bool sortLCTsByGEMDphi(const CSCCorrelatedLCTDigi &, const CSCCorrelatedLCTDigi &)
Definition: CSCUpgradeMotherboard.cc:303
CSCConstants::MAX_LCT_TBINS
Definition: CSCConstants.h:65
CSCGEMMotherboard::printGEMTriggerCoPads
void printGEMTriggerCoPads(int bx_start, int bx_stop, enum CSCPart)
Definition: CSCGEMMotherboard.cc:358
GEMPadDigiClusterCollection
CSCBaseboard::gangedME1a_
bool gangedME1a_
Definition: CSCBaseboard.h:88
sistrip::SpyUtilities::isValid
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
Definition: SiStripSpyUtilities.cc:124
b
double b
Definition: hdecay.h:118
CSCBaseboard::runPhase2_
bool runPhase2_
Definition: CSCBaseboard.h:84
CSCGEMMotherboardME11::cscTmbLUT_
std::unique_ptr< CSCMotherboardLUTME11 > cscTmbLUT_
Definition: CSCGEMMotherboardME11.h:46
GEMCoPadDigiIds
matches< GEMCoPadDigi > GEMCoPadDigiIds
Definition: CSCGEMMotherboard.h:26
GEMCoPadDigi
Definition: GEMCoPadDigi.h:16
CSCGEMMotherboardME11.h
CSCGEMMotherboardME11::readoutLCTs1b
std::vector< CSCCorrelatedLCTDigi > readoutLCTs1b() const
Definition: CSCGEMMotherboardME11.cc:396
edm::ParameterSet
Definition: ParameterSet.h:47
a
double a
Definition: hdecay.h:119
ME1A
Definition: CSCUpgradeMotherboardLUT.h:12
CSCUpgradeMotherboard::debug_matching
bool debug_matching
Definition: CSCUpgradeMotherboard.h:109
sorter
Definition: SETFilter.cc:31
CSCConstants::MAX_HALF_STRIP_ME1B
Definition: CSCConstants.h:39
LCTContainer::getTimeMatched
void getTimeMatched(const int bx, std::vector< CSCCorrelatedLCTDigi > &) const
Definition: LCTContainer.cc:7
CSCMotherboard::early_tbins
int early_tbins
Definition: CSCMotherboard.h:108
CSCCLCTDigi::isValid
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:50
CSCGEMMotherboardME11::sortLCTs
void sortLCTs(std::vector< CSCCorrelatedLCTDigi > &, int bx, bool(*sorter)(const CSCCorrelatedLCTDigi &, const CSCCorrelatedLCTDigi &)) const
Definition: CSCGEMMotherboardME11.cc:473
CSCUpgradeMotherboard::sortLCTs
void sortLCTs(std::vector< CSCCorrelatedLCTDigi > &lcts, bool(*sorter)(const CSCCorrelatedLCTDigi &, const CSCCorrelatedLCTDigi &)) const
Definition: CSCUpgradeMotherboard.cc:307
CSCGEMMotherboardME11::correlateLCTsGEM
void correlateLCTsGEM(const CSCALCTDigi &bestALCT, const CSCALCTDigi &secondALCT, const CSCCLCTDigi &bestCLCT, const CSCCLCTDigi &secondCLCT, const GEMPadDigiIds &pads, const GEMCoPadDigiIds &copads, CSCCorrelatedLCTDigi &lct1, CSCCorrelatedLCTDigi &lct2) const
Definition: CSCGEMMotherboardME11.cc:507
CSCComparatorDigiCollection
CSCGEMMotherboardME11::doesALCTCrossCLCT
bool doesALCTCrossCLCT(const CSCALCTDigi &a, const CSCCLCTDigi &c) const
Definition: CSCGEMMotherboardME11.cc:499
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
CSCMotherboard::readout_earliest_2
bool readout_earliest_2
Definition: CSCMotherboard.h:111
CSCMotherboard::drop_used_clcts
bool drop_used_clcts
Definition: CSCMotherboard.h:105
CSCMotherboard::encodeHighMultiplicityBits
void encodeHighMultiplicityBits(unsigned alctBits)
Definition: CSCMotherboard.cc:711
CSCUpgradeMotherboard::sortLCTsByQuality
static bool sortLCTsByQuality(const CSCCorrelatedLCTDigi &, const CSCCorrelatedLCTDigi &)
Definition: CSCUpgradeMotherboard.cc:299
CSCGEMMotherboard
Definition: CSCGEMMotherboard.h:29
CSCUpgradeMotherboard::allLCTs
LCTContainer allLCTs
Definition: CSCUpgradeMotherboard.h:94
CSCMotherboard::tmb_l1a_window_size
unsigned int tmb_l1a_window_size
Definition: CSCMotherboard.h:99
CSCWireDigiCollection
CSCCLCTDigi::clear
void clear()
clear this CLCT
Definition: CSCCLCTDigi.cc:68
CSCALCTDigi
Definition: CSCALCTDigi.h:17
CSCGEMMotherboard::printGEMTriggerPads
void printGEMTriggerPads(int bx_start, int bx_stop, enum CSCPart)
Definition: CSCGEMMotherboard.cc:337
CSCGEMMotherboardME11::readoutLCTsME11
std::vector< CSCCorrelatedLCTDigi > readoutLCTsME11(enum CSCPart me1ab) const
Definition: CSCGEMMotherboardME11.cc:401
CSCConstants::MAX_CLCT_TBINS
Definition: CSCConstants.h:63
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
or
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
CSCGEMMotherboard::clear
void clear()
Definition: CSCGEMMotherboard.cc:33
CSCGEMMotherboardME11::buildLCTfromCLCTandGEM_ME1b_
bool buildLCTfromCLCTandGEM_ME1b_
Definition: CSCGEMMotherboardME11.h:88
CSCGEMMotherboard::pads_
GEMPadDigiIdsBX pads_
Definition: CSCGEMMotherboard.h:217
CSCGEMMotherboard::maxDeltaBXCoPad_
int maxDeltaBXCoPad_
Definition: CSCGEMMotherboard.h:222
CSCBaseboard::cscId_
CSCDetId cscId_
Definition: CSCBaseboard.h:57
CSCALCTDigi::isValid
bool isValid() const
check ALCT validity (1 - valid ALCT)
Definition: CSCALCTDigi.h:40
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
GEMPadDigi::isValid
bool isValid() const
Definition: GEMPadDigi.cc:26
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
CSCUpgradeMotherboard::max_lcts
unsigned int max_lcts
Definition: CSCUpgradeMotherboard.h:106
GEMPadDigiIds
matches< GEMPadDigi > GEMPadDigiIds
Definition: CSCGEMMotherboard.h:22
CSCGEMMotherboardME11::doesWiregroupCrossStrip
bool doesWiregroupCrossStrip(int key_wg, int key_hs) const override
Definition: CSCGEMMotherboardME11.cc:503
CSCGEMMotherboard::gem_g
const GEMGeometry * gem_g
Definition: CSCGEMMotherboard.h:211
CSCGEMMotherboardME11::buildLCTfromALCTandGEM_ME1b_
bool buildLCTfromALCTandGEM_ME1b_
Definition: CSCGEMMotherboardME11.h:86
CSCCorrelatedLCTDigi
Definition: CSCCorrelatedLCTDigi.h:19
GEMCoPadDigi::isValid
bool isValid() const
Definition: GEMCoPadDigi.cc:18
ME1B
Definition: CSCUpgradeMotherboardLUT.h:12
CSCBaseboard::infoV
int infoV
Definition: CSCBaseboard.h:63