CMS 3D CMS Logo

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