CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCMotherboardME11.cc
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // Class: CSCMotherboardME11
4 //
5 // Description:
6 // Extended CSCMotherboard for ME11 to handle ME1a and ME1b separately
7 //
8 // Author List: Vadim Khotilovich 12 May 2009
9 //
10 // $Date: 2012/12/05 21:14:22 $
11 // $Revision: 1.2 $
12 //
13 //-----------------------------------------------------------------------------
14 
16 //#include <Utilities/Timing/interface/TimingReport.h>
19 
20 
21 
22 // LUT for which ME1/1 wire group can cross which ME1/a halfstrip
23 // 1st index: WG number
24 // 2nd index: inclusive HS range
25 const int CSCMotherboardME11::lut_wg_vs_hs_me1a[48][2] = {
26 {0, 95},{0, 95},{0, 95},{0, 95},{0, 95},
27 {0, 95},{0, 95},{0, 95},{0, 95},{0, 95},
28 {0, 95},{0, 95},{0, 77},{0, 61},{0, 39},
29 {0, 22},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
30 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
31 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
32 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
33 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
34 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
35 {-1,-1},{-1,-1},{-1,-1} };
36 // a modified LUT for ganged ME1a
37 const int CSCMotherboardME11::lut_wg_vs_hs_me1ag[48][2] = {
38 {0, 31},{0, 31},{0, 31},{0, 31},{0, 31},
39 {0, 31},{0, 31},{0, 31},{0, 31},{0, 31},
40 {0, 31},{0, 31},{0, 31},{0, 31},{0, 31},
41 {0, 22},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
42 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
43 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
44 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
45 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
46 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
47 {-1,-1},{-1,-1},{-1,-1} };
48 
49 // LUT for which ME1/1 wire group can cross which ME1/b halfstrip
50 // 1st index: WG number
51 // 2nd index: inclusive HS range
52 const int CSCMotherboardME11::lut_wg_vs_hs_me1b[48][2] = {
53 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
54 {-1,-1},{-1,-1},{-1,-1},{-1,-1},{-1,-1},
55 {100, 127},{73, 127},{47, 127},{22, 127},{0, 127},
56 {0, 127},{0, 127},{0, 127},{0, 127},{0, 127},
57 {0, 127},{0, 127},{0, 127},{0, 127},{0, 127},
58 {0, 127},{0, 127},{0, 127},{0, 127},{0, 127},
59 {0, 127},{0, 127},{0, 127},{0, 127},{0, 127},
60 {0, 127},{0, 127},{0, 127},{0, 127},{0, 127},
61 {0, 127},{0, 127},{0, 127},{0, 127},{0, 105},
62 {0, 93},{0, 78},{0, 63} };
63 
64 
66  unsigned sector, unsigned subsector,
67  unsigned chamber,
68  const edm::ParameterSet& conf) :
69  CSCMotherboard(endcap, station, sector, subsector, chamber, conf)
70 {
71  edm::ParameterSet commonParams = conf.getParameter<edm::ParameterSet>("commonParam");
72 
73  // special configuration parameters for ME11 treatment
74  smartME1aME1b = commonParams.getUntrackedParameter<bool>("smartME1aME1b", true);
75  disableME1a = commonParams.getUntrackedParameter<bool>("disableME1a", false);
76  gangedME1a = commonParams.getUntrackedParameter<bool>("gangedME1a", false);
77 
78  if (!isSLHC) edm::LogError("L1CSCTPEmulatorConfigError")
79  << "+++ Upgrade CSCMotherboardME11 constructed while isSLHC is not set! +++\n";
80  if (!smartME1aME1b) edm::LogError("L1CSCTPEmulatorConfigError")
81  << "+++ Upgrade CSCMotherboardME11 constructed while smartME1aME1b is not set! +++\n";
82 
83  edm::ParameterSet alctParams = conf.getParameter<edm::ParameterSet>("alctSLHC");
84  edm::ParameterSet clctParams = conf.getParameter<edm::ParameterSet>("clctSLHC");
85  edm::ParameterSet tmbParams = conf.getParameter<edm::ParameterSet>("tmbSLHC");
86 
87  clct1a = new CSCCathodeLCTProcessor(endcap, station, sector, subsector, chamber, clctParams, commonParams, tmbParams);
88  clct1a->setRing(4);
89 
90  match_earliest_alct_me11_only = tmbParams.getUntrackedParameter<bool>("matchEarliestAlctME11Only",true);
91  match_earliest_clct_me11_only = tmbParams.getUntrackedParameter<bool>("matchEarliestClctME11Only",true);
92 
93  // if true: use regular CLCT-to-ALCT matching in TMB
94  // if false: do ALCT-to-CLCT matching
95  clct_to_alct = tmbParams.getUntrackedParameter<bool>("clctToAlct",true);
96 
97  // whether to not reuse CLCTs that were used by previous matching ALCTs
98  // in ALCT-to-CLCT algorithm
99  drop_used_clcts = tmbParams.getUntrackedParameter<bool>("tmbDropUsedClcts",true);
100 
101  tmb_cross_bx_algo = tmbParams.getUntrackedParameter<unsigned int>("tmbCrossBxAlgorithm");
102 
103  // maximum lcts per BX in ME11: 2, 3, 4 or 999
104  max_me11_lcts = tmbParams.getUntrackedParameter<unsigned int>("maxME11LCTs",4);
105 
107  for (unsigned int m=2; m<match_trig_window_size; m+=2)
108  {
109  pref[m-1] = pref[0] - m/2;
110  pref[m] = pref[0] + m/2;
111  }
112 }
113 
114 
116 {
117  // Constructor used only for testing.
118 
120  clct1a->setRing(4);
121 
123  for (unsigned int m=2; m<match_trig_window_size; m+=2)
124  {
125  pref[m-1] = pref[0] - m/2;
126  pref[m] = pref[0] + m/2;
127  }
128 }
129 
130 
132 {
133  if (clct1a) delete clct1a;
134 }
135 
136 
138 {
140  if (clct1a) clct1a->clear();
141  for (int bx = 0; bx < MAX_LCT_BINS; bx++)
142  {
143  //firstLCT1a[bx].clear();
144  //secondLCT1a[bx].clear();
145  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
146  for (int i=0;i<2;i++)
147  {
148  allLCTs1b[bx][mbx][i].clear();
149  allLCTs1a[bx][mbx][i].clear();
150  }
151  }
152 }
153 
154 // Set configuration parameters obtained via EventSetup mechanism.
156 {
157  alct->setConfigParameters(conf);
158  clct->setConfigParameters(conf);
160  // No config. parameters in DB for the TMB itself yet.
161 }
162 
163 
165  const CSCComparatorDigiCollection* compdc)
166 {
167  clear();
168 
169  if (!( alct && clct && clct1a && smartME1aME1b))
170  {
171  if (infoV >= 0) edm::LogError("L1CSCTPEmulatorSetupError")
172  << "+++ run() called for non-existing ALCT/CLCT processor! +++ \n";
173  return;
174  }
175 
176  alctV = alct->run(wiredc); // run anodeLCT
177  clctV1b = clct->run(compdc); // run cathodeLCT in ME1/b
178  clctV1a = clct1a->run(compdc); // run cathodeLCT in ME1/a
179 
180  //int n_clct_a=0, n_clct_b=0;
181  //if (clct1a->bestCLCT[6].isValid() && clct1a->bestCLCT[6].getBX()==6) n_clct_a++;
182  //if (clct1a->secondCLCT[6].isValid() && clct1a->secondCLCT[6].getBX()==6) n_clct_a++;
183 
184  int used_alct_mask[20], used_alct_mask_1a[20];
185  int used_clct_mask[20], used_clct_mask_1a[20];
186  for (int b=0;b<20;b++)
187  used_alct_mask[b] = used_alct_mask_1a[b] = used_clct_mask[b] = used_clct_mask_1a[b] = 0;
188 
189  // CLCT-centric CLCT-to-ALCT matching
190  if (clct_to_alct) for (int bx_clct = 0; bx_clct < CSCCathodeLCTProcessor::MAX_CLCT_BINS; bx_clct++)
191  {
192  // matching in ME1b
193  if (clct->bestCLCT[bx_clct].isValid())
194  {
195  int bx_alct_start = bx_clct - match_trig_window_size/2;
196  int bx_alct_stop = bx_clct + match_trig_window_size/2;
197  for (int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++)
198  {
199  if (bx_alct < 0 || bx_alct >= CSCAnodeLCTProcessor::MAX_ALCT_BINS) continue;
200  if (drop_used_alcts && used_alct_mask[bx_alct]) continue;
201  if (alct->bestALCT[bx_alct].isValid())
202  {
203  if (infoV > 1) LogTrace("CSCMotherboard")
204  << "Successful CLCT-ALCT match in ME1b: bx_clct = " << bx_clct
205  << "; match window: [" << bx_alct_start << "; " << bx_alct_stop
206  << "]; bx_alct = " << bx_alct;
207  int mbx = bx_alct_stop - bx_alct;
208  correlateLCTs(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
209  clct->bestCLCT[bx_clct], clct->secondCLCT[bx_clct],
210  allLCTs1b[bx_alct][mbx][0], allLCTs1b[bx_alct][mbx][1], ME1B);
211  if (allLCTs1b[bx_alct][mbx][0].isValid())
212  {
213  used_alct_mask[bx_alct] += 1;
215  }
216  }
217  }
218  // Do not report CLCT-only LCT for ME1b
219  }
220  // matching in ME1a
221  if (clct1a->bestCLCT[bx_clct].isValid())
222  {
223  int bx_alct_start = bx_clct - match_trig_window_size/2;
224  int bx_alct_stop = bx_clct + match_trig_window_size/2;
225  for (int bx_alct = bx_alct_start; bx_alct <= bx_alct_stop; bx_alct++)
226  {
227  if (bx_alct < 0 || bx_alct >= CSCAnodeLCTProcessor::MAX_ALCT_BINS) continue;
228  if (drop_used_alcts && used_alct_mask_1a[bx_alct]) continue;
229  if (alct->bestALCT[bx_alct].isValid())
230  {
231  if (infoV > 1) LogTrace("CSCMotherboard")
232  << "Successful CLCT-ALCT match in ME1a: bx_clct = " << bx_clct
233  << "; match window: [" << bx_alct_start << "; " << bx_alct_stop
234  << "]; bx_alct = " << bx_alct;
235  int mbx = bx_alct_stop - bx_alct;
236  correlateLCTs(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
237  clct1a->bestCLCT[bx_clct], clct1a->secondCLCT[bx_clct],
238  allLCTs1a[bx_alct][mbx][0], allLCTs1a[bx_alct][mbx][1], ME1A);
239  if (allLCTs1a[bx_alct][mbx][0].isValid())
240  {
241  used_alct_mask_1a[bx_alct] += 1;
243  }
244  }
245  }
246  // Do not report CLCT-only LCT for ME1b
247  }
248  // Do not attempt to make ALCT-only LCT for ME1b
249  } // end of CLCT-centric matching
250 
251  // ALCT-centric ALCT-to-CLCT matching
252  else for (int bx_alct = 0; bx_alct < CSCAnodeLCTProcessor::MAX_ALCT_BINS; bx_alct++)
253  {
254  if (alct->bestALCT[bx_alct].isValid())
255  {
256  int bx_clct_start = bx_alct - match_trig_window_size/2;
257  int bx_clct_stop = bx_alct + match_trig_window_size/2;
258 
259  // matching in ME1b
260  for (int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++)
261  {
262  if (bx_clct < 0 || bx_clct >= CSCCathodeLCTProcessor::MAX_CLCT_BINS) continue;
263  if (drop_used_clcts && used_clct_mask[bx_clct]) continue;
264  if (clct->bestCLCT[bx_clct].isValid())
265  {
266  if (infoV > 1) LogTrace("CSCMotherboard")
267  << "Successful ALCT-CLCT match in ME1b: bx_alct = " << bx_alct
268  << "; match window: [" << bx_clct_start << "; " << bx_clct_stop
269  << "]; bx_clct = " << bx_clct;
270  int mbx = bx_clct-bx_clct_start;
271  correlateLCTs(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
272  clct->bestCLCT[bx_clct], clct->secondCLCT[bx_clct],
273  allLCTs1b[bx_alct][mbx][0], allLCTs1b[bx_alct][mbx][1], ME1B);
274  if (allLCTs1b[bx_alct][mbx][0].isValid())
275  {
276  used_clct_mask[bx_clct] += 1;
278  }
279  }
280  }
281 
282  // matching in ME1a
283  for (int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++)
284  {
285  if (bx_clct < 0 || bx_clct >= CSCCathodeLCTProcessor::MAX_CLCT_BINS) continue;
286  if (drop_used_clcts && used_clct_mask_1a[bx_clct]) continue;
287  if (clct1a->bestCLCT[bx_clct].isValid())
288  {
289  if (infoV > 1) LogTrace("CSCMotherboard")
290  << "Successful ALCT-CLCT match in ME1a: bx_alct = " << bx_alct
291  << "; match window: [" << bx_clct_start << "; " << bx_clct_stop
292  << "]; bx_clct = " << bx_clct;
293  int mbx = bx_clct-bx_clct_start;
294  correlateLCTs(alct->bestALCT[bx_alct], alct->secondALCT[bx_alct],
295  clct1a->bestCLCT[bx_clct], clct1a->secondCLCT[bx_clct],
296  allLCTs1a[bx_alct][mbx][0], allLCTs1a[bx_alct][mbx][1], ME1A);
297  if (allLCTs1a[bx_alct][mbx][0].isValid())
298  {
299  used_clct_mask_1a[bx_clct] += 1;
301  }
302  }
303  }
304  }
305  } // end of ALCT-centric matching
306 
307  // reduction of nLCTs per each BX
308  for (int bx = 0; bx < MAX_LCT_BINS; bx++)
309  {
310  // counting
311  unsigned int n1a=0, n1b=0;
312  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
313  for (int i=0;i<2;i++)
314  {
315  int cbx = bx + mbx - match_trig_window_size/2;
316  if (allLCTs1b[bx][mbx][i].isValid())
317  {
318  n1b++;
319  if (infoV > 0) LogDebug("CSCMotherboard") << "1b LCT"<<i+1<<" "<<bx<<"/"<<cbx<<": "<<allLCTs1b[bx][mbx][i];
320  }
321  if (allLCTs1a[bx][mbx][i].isValid())
322  {
323  n1a++;
324  if (infoV > 0) LogDebug("CSCMotherboard") << "1a LCT"<<i+1<<" "<<bx<<"/"<<cbx<<": "<<allLCTs1a[bx][mbx][i];
325  }
326  }
327  if (infoV > 0 && n1a+n1b>0) LogDebug("CSCMotherboard") <<"bx "<<bx<<" nLCT:"<<n1a<<" "<<n1b<<" "<<n1a+n1b;
328 
329  // some simple cross-bx sorting algorithms
330  if (tmb_cross_bx_algo == 1 && (n1a>2 || n1b>2) )
331  {
332  n1a=0, n1b=0;
333  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
334  for (int i=0;i<2;i++)
335  {
336  if (allLCTs1b[bx][pref[mbx]][i].isValid())
337  {
338  n1b++;
339  if (n1b>2) allLCTs1b[bx][pref[mbx]][i].clear();
340  }
341  if (allLCTs1a[bx][pref[mbx]][i].isValid())
342  {
343  n1a++;
344  if (n1a>2) allLCTs1a[bx][pref[mbx]][i].clear();
345  }
346  }
347 
348  if (infoV > 0) LogDebug("CSCMotherboard") <<"After x-bx sorting:";
349  n1a=0, n1b=0;
350  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
351  for (int i=0;i<2;i++)
352  {
353  int cbx = bx + mbx - match_trig_window_size/2;
354  if (allLCTs1b[bx][mbx][i].isValid())
355  {
356  n1b++;
357  if (infoV > 0) LogDebug("CSCMotherboard") << "1b LCT"<<i+1<<" "<<bx<<"/"<<cbx<<": "<<allLCTs1b[bx][mbx][i];
358  }
359  if (allLCTs1a[bx][mbx][i].isValid())
360  {
361  n1a++;
362  if (infoV > 0) LogDebug("CSCMotherboard") << "1a LCT"<<i+1<<" "<<bx<<"/"<<cbx<<": "<<allLCTs1a[bx][mbx][i];
363  }
364  }
365  if (infoV > 0 && n1a+n1b>0) LogDebug("CSCMotherboard") <<"bx "<<bx<<" nnLCT:"<<n1a<<" "<<n1b<<" "<<n1a+n1b;
366  } // x-bx sorting
367 
368  // Maximum 2 or 3 per whole ME11 per BX case:
369  // (supposedly, now we should have max 2 per bx in each 1a and 1b)
370  if ( n1a+n1b > max_me11_lcts )
371  {
372  // do it simple so far: take all low eta 1/b stubs
373  unsigned int nLCT=n1b;
374  n1a=0;
375  // right now nLCT<=2; cut 1a if necessary
376  for (unsigned int mbx=0; mbx<match_trig_window_size; mbx++)
377  for (int i=0;i<2;i++)
378  if (allLCTs1a[bx][mbx][i].isValid()) {
379  nLCT++;
380  if (nLCT>max_me11_lcts) allLCTs1a[bx][mbx][i].clear();
381  else n1a++;
382  }
383  if (infoV > 0 && nLCT>0) LogDebug("CSCMotherboard") <<"bx "<<bx<<" nnnLCT:"<<n1a<<" "<<n1b<<" "<<n1a+n1b;
384  }
385  }// reduction per bx
386 
387  //if (infoV > 1) LogTrace("CSCMotherboardME11")<<"clct_count E:"<<theEndcap<<"S:"<<theStation<<"R:"<<1<<"C:"
388  // <<CSCTriggerNumbering::chamberFromTriggerLabels(theSector,theSubsector, theStation, theTrigChamber)
389  // <<" a "<<n_clct_a<<" b "<<n_clct_b<<" ab "<<n_clct_a+n_clct_b;
390 }
391 
392 
393 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::readoutLCTs1a()
394 {
395  return readoutLCTs(ME1A);
396 }
397 
398 
399 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::readoutLCTs1b()
400 {
401  return readoutLCTs(ME1B);
402 }
403 
404 
405 // Returns vector of read-out correlated LCTs, if any. Starts with
406 // the vector of all found LCTs and selects the ones in the read-out
407 // time window.
408 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::readoutLCTs(int me1ab)
409 {
410  std::vector<CSCCorrelatedLCTDigi> tmpV;
411 
412  // The start time of the L1A*LCT coincidence window should be related
413  // to the fifo_pretrig parameter, but I am not completely sure how.
414  // Just choose it such that the window is centered at bx=7. This may
415  // need further tweaking if the value of tmb_l1a_window_size changes.
416  //static int early_tbins = 4;
417  // The number of LCT bins in the read-out is given by the
418  // tmb_l1a_window_size parameter, forced to be odd
419  static int lct_bins =
421  static int late_tbins = early_tbins + lct_bins;
422 
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  if (me1ab == ME1A) all_lcts = getLCTs1a();
429  if (me1ab == ME1B) all_lcts = getLCTs1b();
430  std::vector <CSCCorrelatedLCTDigi>::const_iterator plct = all_lcts.begin();
431  for (; plct != all_lcts.end(); plct++)
432  {
433  if (!plct->isValid()) continue;
434 
435  int bx = (*plct).getBX();
436  // Skip LCTs found too early relative to L1Accept.
437  if (bx <= early_tbins) continue;
438 
439  // Skip LCTs found too late relative to L1Accept.
440  if (bx > late_tbins) continue;
441 
442  // If (readout_earliest_2) take only LCTs in the earliest bx in the read-out window:
443  // in digi->raw step, LCTs have to be packed into the TMB header, and
444  // currently there is room just for two.
445  if (readout_earliest_2 && (bx_readout == -1 || bx == bx_readout) )
446  {
447  tmpV.push_back(*plct);
448  if (bx_readout == -1) bx_readout = bx;
449  }
450  else tmpV.push_back(*plct);
451  }
452  return tmpV;
453 }
454 
455 
456 // Returns vector of found correlated LCTs, if any.
457 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::getLCTs1b()
458 {
459  std::vector<CSCCorrelatedLCTDigi> tmpV;
460 
461  for (int bx = 0; bx < MAX_LCT_BINS; bx++)
462  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
463  for (int i=0;i<2;i++)
464  if (allLCTs1b[bx][mbx][i].isValid()) tmpV.push_back(allLCTs1b[bx][mbx][i]);
465  return tmpV;
466 }
467 
468 // Returns vector of found correlated LCTs, if any.
469 std::vector<CSCCorrelatedLCTDigi> CSCMotherboardME11::getLCTs1a()
470 {
471  std::vector<CSCCorrelatedLCTDigi> tmpV;
472 
473  // disabled ME1a
474  if (mpc_block_me1a || disableME1a) return tmpV;
475 
476  // Report all LCTs found.
477  for (int bx = 0; bx < MAX_LCT_BINS; bx++)
478  for (unsigned int mbx = 0; mbx < match_trig_window_size; mbx++)
479  for (int i=0;i<2;i++)
480  if (allLCTs1a[bx][mbx][i].isValid()) tmpV.push_back(allLCTs1a[bx][mbx][i]);
481  return tmpV;
482 }
483 
484 
486 {
487  if ( !c.isValid() || !a.isValid() ) return false;
488  int key_hs = c.getKeyStrip();
489  int key_wg = a.getKeyWG();
490  if ( me == ME1A )
491  {
492  if ( !gangedME1a )
493  {
494  // wrap around ME11 HS number for -z endcap
495  if (theEndcap==2) key_hs = 95 - key_hs;
496  if ( key_hs >= lut_wg_vs_hs_me1a[key_wg][0] &&
497  key_hs <= lut_wg_vs_hs_me1a[key_wg][1] ) return true;
498  return false;
499  }
500  else
501  {
502  if (theEndcap==2) key_hs = 31 - key_hs;
503  if ( key_hs >= lut_wg_vs_hs_me1ag[key_wg][0] &&
504  key_hs <= lut_wg_vs_hs_me1ag[key_wg][1] ) return true;
505  return false;
506  }
507  }
508  if ( me == ME1B)
509  {
510  if (theEndcap==2) key_hs = 127 - key_hs;
511  if ( key_hs >= lut_wg_vs_hs_me1b[key_wg][0] &&
512  key_hs <= lut_wg_vs_hs_me1b[key_wg][1] ) return true;
513  }
514  return false;
515 }
516 
517 
519  CSCALCTDigi secondALCT,
520  CSCCLCTDigi bestCLCT,
521  CSCCLCTDigi secondCLCT,
522  CSCCorrelatedLCTDigi& lct1,
523  CSCCorrelatedLCTDigi& lct2)
524 {
525  bool anodeBestValid = bestALCT.isValid();
526  bool anodeSecondValid = secondALCT.isValid();
527  bool cathodeBestValid = bestCLCT.isValid();
528  bool cathodeSecondValid = secondCLCT.isValid();
529 
530  if (anodeBestValid && !anodeSecondValid) secondALCT = bestALCT;
531  if (!anodeBestValid && anodeSecondValid) bestALCT = secondALCT;
532  if (cathodeBestValid && !cathodeSecondValid) secondCLCT = bestCLCT;
533  if (!cathodeBestValid && cathodeSecondValid) bestCLCT = secondCLCT;
534 
535  // ALCT-CLCT matching conditions are defined by "trig_enable" configuration
536  // parameters.
537  if ((alct_trig_enable && bestALCT.isValid()) ||
538  (clct_trig_enable && bestCLCT.isValid()) ||
539  (match_trig_enable && bestALCT.isValid() && bestCLCT.isValid()))
540  {
541  lct1 = constructLCTs(bestALCT, bestCLCT);
542  lct1.setTrknmb(1);
543  }
544 
545  if (((secondALCT != bestALCT) || (secondCLCT != bestCLCT)) &&
546  ((alct_trig_enable && secondALCT.isValid()) ||
547  (clct_trig_enable && secondCLCT.isValid()) ||
548  (match_trig_enable && secondALCT.isValid() && secondCLCT.isValid())))
549  {
550  lct2 = constructLCTs(secondALCT, secondCLCT);
551  lct2.setTrknmb(2);
552  }
553 }
554 
555 
557  CSCALCTDigi secondALCT,
558  CSCCLCTDigi bestCLCT,
559  CSCCLCTDigi secondCLCT,
560  CSCCorrelatedLCTDigi& lct1,
561  CSCCorrelatedLCTDigi& lct2,
562  int me)
563 {
564  // assume that always anodeBestValid && cathodeBestValid
565 
566  if (secondALCT == bestALCT) secondALCT.clear();
567  if (secondCLCT == bestCLCT) secondCLCT.clear();
568 
569  int ok11 = doesALCTCrossCLCT( bestALCT, bestCLCT, me);
570  int ok12 = doesALCTCrossCLCT( bestALCT, secondCLCT, me);
571  int ok21 = doesALCTCrossCLCT( secondALCT, bestCLCT, me);
572  int ok22 = doesALCTCrossCLCT( secondALCT, secondCLCT, me);
573  int code = (ok11<<3) | (ok12<<2) | (ok21<<1) | (ok22);
574 
575  int dbg=0;
576  int ring = me;
578  CSCDetId did(theEndcap, theStation, ring, chamb, 0);
579  if (dbg) LogTrace("CSCMotherboardME11")<<"debug correlateLCTs in "<<did<<std::endl
580  <<"ALCT1: "<<bestALCT<<std::endl
581  <<"ALCT2: "<<secondALCT<<std::endl
582  <<"CLCT1: "<<bestCLCT<<std::endl
583  <<"CLCT2: "<<secondCLCT<<std::endl
584  <<"ok 11 12 21 22 code = "<<ok11<<" "<<ok12<<" "<<ok21<<" "<<ok22<<" "<<code<<std::endl;
585 
586  if ( code==0 ) return;
587 
588  // LUT defines correspondence between possible ok## combinations
589  // and resulting lct1 and lct2
590  int lut[16][2] = {
591  //ok: 11 12 21 22
592  {0 ,0 }, // 0 0 0 0
593  {22,0 }, // 0 0 0 1
594  {21,0 }, // 0 0 1 0
595  {21,22}, // 0 0 1 1
596  {12,0 }, // 0 1 0 0
597  {12,22}, // 0 1 0 1
598  {12,21}, // 0 1 1 0
599  {12,21}, // 0 1 1 1
600  {11,0 }, // 1 0 0 0
601  {11,22}, // 1 0 0 1
602  {11,21}, // 1 0 1 0
603  {11,22}, // 1 0 1 1
604  {11,12}, // 1 1 0 0
605  {11,22}, // 1 1 0 1
606  {11,12}, // 1 1 1 0
607  {11,22}, // 1 1 1 1
608  };
609 
610  if (dbg) LogTrace("CSCMotherboardME11")<<"lut 0 1 = "<<lut[code][0]<<" "<<lut[code][1]<<std::endl;
611 
612  switch (lut[code][0]) {
613  case 11:
614  lct1 = constructLCTs(bestALCT, bestCLCT);
615  break;
616  case 12:
617  lct1 = constructLCTs(bestALCT, secondCLCT);
618  break;
619  case 21:
620  lct1 = constructLCTs(secondALCT, bestCLCT);
621  break;
622  case 22:
623  lct1 = constructLCTs(secondALCT, secondCLCT);
624  break;
625  default: return;
626  }
627  lct1.setTrknmb(1);
628 
629  if (dbg) LogTrace("CSCMotherboardME11")<<"lct1: "<<lct1<<std::endl;
630 
631  switch (lut[code][1])
632  {
633  case 12:
634  lct2 = constructLCTs(bestALCT, secondCLCT);
635  lct2.setTrknmb(2);
636  if (dbg) LogTrace("CSCMotherboardME11")<<"lct2: "<<lct2<<std::endl;
637  return;
638  case 21:
639  lct2 = constructLCTs(secondALCT, bestCLCT);
640  lct2.setTrknmb(2);
641  if (dbg) LogTrace("CSCMotherboardME11")<<"lct2: "<<lct2<<std::endl;
642  return;
643  case 22:
644  lct2 = constructLCTs(secondALCT, secondCLCT);
645  lct2.setTrknmb(2);
646  if (dbg) LogTrace("CSCMotherboardME11")<<"lct2: "<<lct2<<std::endl;
647  return;
648  default: return;
649  }
650  if (dbg) LogTrace("CSCMotherboardME11")<<"out of correlateLCTs"<<std::endl;
651 
652  return;
653 }
654 
#define LogDebug(id)
CSCCLCTDigi secondCLCT[MAX_CLCT_BINS]
const unsigned theSector
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< CSCCLCTDigi > clctV1a
int i
Definition: DBlmapReader.cc:9
CSCCorrelatedLCTDigi constructLCTs(const CSCALCTDigi &aLCT, const CSCCLCTDigi &cLCT)
CSCCorrelatedLCTDigi allLCTs1b[MAX_LCT_BINS][15][2]
void run(const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc)
unsigned int clct_trig_enable
void setConfigParameters(const CSCDBL1TPParameters *conf)
std::vector< CSCCorrelatedLCTDigi > readoutLCTs()
CSCALCTDigi bestALCT[MAX_ALCT_BINS]
unsigned int match_trig_window_size
CSCALCTDigi secondALCT[MAX_ALCT_BINS]
const unsigned theTrigChamber
bool isValid() const
check ALCT validity (1 - valid ALCT)
Definition: CSCALCTDigi.h:32
int pref[MAX_LCT_BINS]
unsigned int max_me11_lcts
const unsigned theEndcap
void clear()
clear this ALCT
Definition: CSCALCTDigi.cc:37
static const int lut_wg_vs_hs_me1a[48][2]
std::vector< CSCCorrelatedLCTDigi > getLCTs1b()
CSCCLCTDigi bestCLCT[MAX_CLCT_BINS]
void setConfigParameters(const CSCDBL1TPParameters *conf)
void correlateLCTs(CSCALCTDigi bestALCT, CSCALCTDigi secondALCT, CSCCLCTDigi bestCLCT, CSCCLCTDigi secondCLCT, CSCCorrelatedLCTDigi &lct1, CSCCorrelatedLCTDigi &lct2)
unsigned int mpc_block_me1a
unsigned int tmb_cross_bx_algo
CSCCorrelatedLCTDigi allLCTs1a[MAX_LCT_BINS][15][2]
const unsigned theStation
std::vector< CSCALCTDigi > alctV
const unsigned theSubsector
unsigned int tmb_l1a_window_size
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:32
unsigned int match_trig_enable
tuple lut
Definition: lumiPlot.py:244
static const int lut_wg_vs_hs_me1b[48][2]
static const int lut_wg_vs_hs_me1ag[48][2]
#define LogTrace(id)
CSCAnodeLCTProcessor * alct
tuple conf
Definition: dbtoconf.py:185
double b
Definition: hdecay.h:120
unsigned int alct_trig_enable
std::vector< CSCCorrelatedLCTDigi > getLCTs1a()
CSCCathodeLCTProcessor * clct
std::vector< CSCCLCTDigi > run(const CSCComparatorDigiCollection *compdc)
std::vector< CSCCLCTDigi > clctV1b
double a
Definition: hdecay.h:121
bool doesALCTCrossCLCT(CSCALCTDigi &a, CSCCLCTDigi &c, int me)
std::vector< CSCCorrelatedLCTDigi > readoutLCTs1b()
void clear()
clear this CLCT
Definition: CSCCLCTDigi.cc:60
CSCCathodeLCTProcessor * clct1a
int getKeyStrip() const
Definition: CSCCLCTDigi.h:67
std::vector< CSCALCTDigi > run(const CSCWireDigiCollection *wiredc)
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting LCTs.
int getKeyWG() const
return key wire group
Definition: CSCALCTDigi.h:47
static int chamberFromTriggerLabels(int TriggerSector, int TriggerSubSector, int station, int TriggerCSCID)
void setConfigParameters(const CSCDBL1TPParameters *conf)
std::vector< CSCCorrelatedLCTDigi > readoutLCTs1a()