CMS 3D CMS Logo

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