CMS 3D CMS Logo

CSCCathodeLCTProcessor.cc
Go to the documentation of this file.
2 
3 #include <iomanip>
4 #include <iostream>
5 #include <memory>
6 
7 // Default values of configuration parameters.
8 const unsigned int CSCCathodeLCTProcessor::def_fifo_tbins = 12;
9 const unsigned int CSCCathodeLCTProcessor::def_fifo_pretrig = 7;
10 const unsigned int CSCCathodeLCTProcessor::def_hit_persist = 6;
11 const unsigned int CSCCathodeLCTProcessor::def_drift_delay = 2;
15 const unsigned int CSCCathodeLCTProcessor::def_min_separation = 10;
17 
18 //----------------
19 // Constructors --
20 //----------------
21 
23  unsigned station,
24  unsigned sector,
25  unsigned subsector,
26  unsigned chamber,
27  const edm::ParameterSet& conf)
28  : CSCBaseboard(endcap, station, sector, subsector, chamber, conf) {
29  static std::atomic<bool> config_dumped{false};
30 
31  // CLCT configuration parameters.
32  fifo_tbins = clctParams_.getParameter<unsigned int>("clctFifoTbins");
33  hit_persist = clctParams_.getParameter<unsigned int>("clctHitPersist");
34  drift_delay = clctParams_.getParameter<unsigned int>("clctDriftDelay");
35  nplanes_hit_pretrig = clctParams_.getParameter<unsigned int>("clctNplanesHitPretrig");
36  nplanes_hit_pattern = clctParams_.getParameter<unsigned int>("clctNplanesHitPattern");
37 
38  // Not used yet.
39  fifo_pretrig = clctParams_.getParameter<unsigned int>("clctFifoPretrig");
40 
41  pid_thresh_pretrig = clctParams_.getParameter<unsigned int>("clctPidThreshPretrig");
42  min_separation = clctParams_.getParameter<unsigned int>("clctMinSeparation");
43 
44  start_bx_shift = clctParams_.getParameter<int>("clctStartBxShift");
45 
46  // Motherboard parameters: common for all configurations.
47  tmb_l1a_window_size = // Common to CLCT and TMB
48  tmbParams_.getParameter<unsigned int>("tmbL1aWindowSize");
49 
50  // separate handle for early time bins
51  early_tbins = tmbParams_.getParameter<int>("tmbEarlyTbins");
52  if (early_tbins < 0)
54 
55  // wether to readout only the earliest two LCTs in readout window
56  readout_earliest_2 = tmbParams_.getParameter<bool>("tmbReadoutEarliest2");
57 
58  // Verbosity level, set to 0 (no print) by default.
59  infoV = clctParams_.getParameter<int>("verbosity");
60 
61  // Do not exclude pattern 0 and 1 when the Run-3 patterns are enabled.
62  if (runCCLUT_) {
64  }
65 
66  // Check and print configuration parameters.
68  if ((infoV > 0) && !config_dumped) {
70  config_dumped = true;
71  }
72 
73  numStrips = 0; // Will be set later.
74  // Provisional, but should be OK for all stations except ME1.
75  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
76  if ((i_layer + 1) % 2 == 0)
77  stagger[i_layer] = 0;
78  else
79  stagger[i_layer] = 1;
80  }
81 
82  // which patterns should we use?
83  if (runCCLUT_) {
85  } else {
87  }
88 
89  if (runCCLUT_) {
90  positionLUTFiles_ = conf.getParameter<std::vector<std::string>>("positionLUTFiles");
91  slopeLUTFiles_ = conf.getParameter<std::vector<std::string>>("slopeLUTFiles");
92  patternConversionLUTFiles_ = conf.getParameter<std::vector<std::string>>("patternConversionLUTFiles");
93 
94  for (int i = 0; i < 5; ++i) {
95  lutpos_[i] = std::make_unique<CSCComparatorCodeLUT>(positionLUTFiles_[i]);
96  lutslope_[i] = std::make_unique<CSCComparatorCodeLUT>(slopeLUTFiles_[i]);
97  lutpatconv_[i] = std::make_unique<CSCComparatorCodeLUT>(patternConversionLUTFiles_[i]);
98  }
99  }
100 
101  thePreTriggerDigis.clear();
102 
103  // quality control of stubs
104  qualityControl_ = std::make_unique<LCTQualityControl>(endcap, station, sector, subsector, chamber, conf);
105 }
106 
108  // constructor for debugging.
109  static std::atomic<bool> config_dumped{false};
110 
111  // CLCT configuration parameters.
113  infoV = 2;
114 
115  early_tbins = 4;
116 
117  start_bx_shift = 0;
118 
119  // Check and print configuration parameters.
121  if (!config_dumped) {
123  config_dumped = true;
124  }
125 
127  // Should be OK for all stations except ME1.
128  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
129  if ((i_layer + 1) % 2 == 0)
130  stagger[i_layer] = 0;
131  else
132  stagger[i_layer] = 1;
133  }
134 
135  thePreTriggerDigis.clear();
136 }
137 
139  // Set default values for configuration parameters.
149 }
150 
151 // Set configuration parameters obtained via EventSetup mechanism.
153  static std::atomic<bool> config_dumped{false};
154 
155  fifo_tbins = conf->clctFifoTbins();
156  fifo_pretrig = conf->clctFifoPretrig();
157  hit_persist = conf->clctHitPersist();
158  drift_delay = conf->clctDriftDelay();
163 
164  // Check and print configuration parameters.
166  if (!config_dumped) {
168  config_dumped = true;
169  }
170 }
171 
173  // Make sure that the parameter values are within the allowed range.
174 
175  // Max expected values.
176  static const unsigned int max_fifo_tbins = 1 << 5;
177  static const unsigned int max_fifo_pretrig = 1 << 5;
178  static const unsigned int max_hit_persist = 1 << 4;
179  static const unsigned int max_drift_delay = 1 << 2;
180  static const unsigned int max_nplanes_hit_pretrig = 1 << 3;
181  static const unsigned int max_nplanes_hit_pattern = 1 << 3;
182  static const unsigned int max_pid_thresh_pretrig = 1 << 4;
183  static const unsigned int max_min_separation = CSCConstants::NUM_HALF_STRIPS_7CFEBS;
184  static const unsigned int max_tmb_l1a_window_size = 1 << 4;
185 
186  // Checks.
187  CSCBaseboard::checkConfigParameters(fifo_tbins, max_fifo_tbins, def_fifo_tbins, "fifo_tbins");
188  CSCBaseboard::checkConfigParameters(fifo_pretrig, max_fifo_pretrig, def_fifo_pretrig, "fifo_pretrig");
189  CSCBaseboard::checkConfigParameters(hit_persist, max_hit_persist, def_hit_persist, "hit_persist");
190  CSCBaseboard::checkConfigParameters(drift_delay, max_drift_delay, def_drift_delay, "drift_delay");
192  nplanes_hit_pretrig, max_nplanes_hit_pretrig, def_nplanes_hit_pretrig, "nplanes_hit_pretrig");
194  nplanes_hit_pattern, max_nplanes_hit_pattern, def_nplanes_hit_pattern, "nplanes_hit_pattern");
196  pid_thresh_pretrig, max_pid_thresh_pretrig, def_pid_thresh_pretrig, "pid_thresh_pretrig");
197  CSCBaseboard::checkConfigParameters(min_separation, max_min_separation, def_min_separation, "min_separation");
199  tmb_l1a_window_size, max_tmb_l1a_window_size, def_tmb_l1a_window_size, "tmb_l1a_window_size");
200 }
201 
203  thePreTriggerDigis.clear();
204  thePreTriggerBXs.clear();
205  for (int bx = 0; bx < CSCConstants::MAX_CLCT_TBINS; bx++) {
206  bestCLCT[bx].clear();
207  secondCLCT[bx].clear();
208  }
209 }
210 
211 std::vector<CSCCLCTDigi> CSCCathodeLCTProcessor::run(const CSCComparatorDigiCollection* compdc) {
212  // This is the version of the run() function that is called when running
213  // over the entire detector. It gets the comparator & timing info from the
214  // comparator digis and then passes them on to another run() function.
215 
216  static std::atomic<bool> config_dumped{false};
217  if ((infoV > 0) && !config_dumped) {
219  config_dumped = true;
220  }
221 
222  // Get the number of strips and stagger of layers for the given chamber.
223  // Do it only once per chamber.
224  if (numStrips <= 0 or numStrips > CSCConstants::MAX_NUM_STRIPS_7CFEBS) {
225  if (cscChamber_) {
227  // ME1/a is known to the readout hardware as strips 65-80 of ME1/1.
228  // Still need to decide whether we do any special adjustments to
229  // reconstruct LCTs in this region (3:1 ganged strips); for now, we
230  // simply allow for hits in ME1/a and apply standard reconstruction
231  // to them.
232  // For Phase2 ME1/1 is set to have 4 CFEBs in ME1/b and 3 CFEBs in ME1/a
233  if (isME11_) {
234  if (theRing == 4) {
235  edm::LogError("CSCCathodeLCTProcessor|SetupError")
236  << "+++ Invalid ring number for this processor " << theRing << " was set in the config."
237  << " +++\n"
238  << "+++ CSC geometry looks garbled; no emulation possible +++\n";
239  }
240  if (!disableME1a_ && theRing == 1 && !gangedME1a_)
242  if (!disableME1a_ && theRing == 1 && gangedME1a_)
244  if (disableME1a_ && theRing == 1)
246  }
247 
249  edm::LogError("CSCCathodeLCTProcessor|SetupError")
250  << "+++ Number of strips, " << numStrips << " found in " << theCSCName_ << " (sector " << theSector
251  << " subsector " << theSubsector << " trig id. " << theTrigChamber << ")"
252  << " exceeds max expected, " << CSCConstants::MAX_NUM_STRIPS_7CFEBS << " +++\n"
253  << "+++ CSC geometry looks garbled; no emulation possible +++\n";
254  numStrips = -1;
255  }
256  // The strips for a given layer may be offset from the adjacent layers.
257  // This was done in order to improve resolution. We need to find the
258  // 'staggering' for each layer and make necessary conversions in our
259  // arrays. -JM
260  // In the TMB-07 firmware, half-strips in odd layers (layers are
261  // counted as ly0-ly5) are shifted by -1 half-strip, whereas in
262  // the previous firmware versions half-strips in even layers
263  // were shifted by +1 half-strip. This difference is due to a
264  // change from ly3 to ly2 in the choice of the key layer, and
265  // the intention to keep half-strips in the key layer unchanged.
266  // In the emulator, we use the old way for both cases, to avoid
267  // negative half-strip numbers. This will necessitate a
268  // subtraction of 1 half-strip for TMB-07 later on. -SV.
269  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
270  stagger[i_layer] = (cscChamber_->layer(i_layer + 1)->geometry()->stagger() + 1) / 2;
271  }
272  } else {
273  edm::LogError("CSCCathodeLCTProcessor|ConfigError")
274  << " " << theCSCName_ << " (sector " << theSector << " subsector " << theSubsector << " trig id. "
275  << theTrigChamber << ")"
276  << " is not defined in current geometry! +++\n"
277  << "+++ CSC geometry looks garbled; no emulation possible +++\n";
278  numStrips = -1;
279  }
280  }
281 
282  if (numStrips <= 0 or 2 * (unsigned)numStrips > qualityControl_->get_csc_max_halfstrip(theStation, theRing)) {
283  edm::LogError("CSCCathodeLCTProcessor|ConfigError")
284  << " " << theCSCName_ << " (sector " << theSector << " subsector " << theSubsector << " trig id. "
285  << theTrigChamber << "):"
286  << " numStrips = " << numStrips << "; CLCT emulation skipped! +++";
287  std::vector<CSCCLCTDigi> emptyV;
288  return emptyV;
289  }
290 
291  // Get comparator digis in this chamber.
292  bool noDigis = getDigis(compdc);
293 
294  if (!noDigis) {
295  // Get halfstrip times from comparator digis.
297  readComparatorDigis(halfstrip);
298 
299  // Pass arrays of halfstrips on to another run() doing the
300  // LCT search.
301  // If the number of layers containing digis is smaller than that
302  // required to trigger, quit right away. (If LCT-based digi suppression
303  // is implemented one day, this condition will have to be changed
304  // to the number of planes required to pre-trigger.)
305  unsigned int layersHit = 0;
306  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
307  for (int i_hstrip = 0; i_hstrip < CSCConstants::NUM_HALF_STRIPS_7CFEBS; i_hstrip++) {
308  if (!halfstrip[i_layer][i_hstrip].empty()) {
309  layersHit++;
310  break;
311  }
312  }
313  }
314  // Run the algorithm only if the probability for the pre-trigger
315  // to fire is not null. (Pre-trigger decisions are used for the
316  // strip read-out conditions in DigiToRaw.)
317  if (layersHit >= nplanes_hit_pretrig)
318  run(halfstrip);
319  }
320 
321  // Return vector of CLCTs.
322  std::vector<CSCCLCTDigi> tmpV = getCLCTs();
323 
324  // shift the BX from 7 to 8
325  // the unpacked real data CLCTs have central BX at bin 7
326  // however in simulation the central BX is bin 8
327  // to make a proper comparison with ALCTs we need
328  // CLCT and ALCT to have the central BX in the same bin
329  // this shift does not affect the readout of the CLCTs
330  // emulated CLCTs put in the event should be centered at bin 7 (as in data)
331  for (auto& p : tmpV) {
332  p.setBX(p.getBX() + CSCConstants::ALCT_CLCT_OFFSET);
333  }
334 
335  return tmpV;
336 }
337 
339  const std::vector<int> halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS]) {
340  // This version of the run() function can either be called in a standalone
341  // test, being passed the halfstrip times, or called by the
342  // run() function above. It uses the findLCTs() method to find vectors
343  // of LCT candidates. These candidates are sorted and the best two per bx
344  // are returned.
345  std::vector<CSCCLCTDigi> CLCTlist = findLCTs(halfstrip);
346 
347  // LCT sorting.
348  if (CLCTlist.size() > 1)
349  sort(CLCTlist.begin(), CLCTlist.end(), std::greater<CSCCLCTDigi>());
350 
351  for (const auto& p : CLCTlist) {
352  const int bx = p.getBX();
354  if (infoV > 0)
355  edm::LogWarning("L1CSCTPEmulatorOutOfTimeCLCT")
356  << "+++ Bx of CLCT candidate, " << bx << ", exceeds max allowed, " << CSCConstants::MAX_CLCT_TBINS - 1
357  << "; skipping it... +++\n";
358  continue;
359  }
360 
361  if (!bestCLCT[bx].isValid()) {
362  bestCLCT[bx] = p;
363  } else if (!secondCLCT[bx].isValid()) {
364  secondCLCT[bx] = p;
365  }
366  }
367 
368  for (int bx = 0; bx < CSCConstants::MAX_CLCT_TBINS; bx++) {
369  if (bestCLCT[bx].isValid()) {
370  bestCLCT[bx].setTrknmb(1);
371 
372  // check if the LCT is valid
373  qualityControl_->checkValid(bestCLCT[bx]);
374 
375  if (infoV > 0)
376  LogDebug("CSCCathodeLCTProcessor")
378  << " (sector " << theSector << " subsector " << theSubsector << " trig id. " << theTrigChamber << ")"
379  << "\n";
380  }
381  if (secondCLCT[bx].isValid()) {
382  secondCLCT[bx].setTrknmb(2);
383 
384  // check if the LCT is valid
385  qualityControl_->checkValid(secondCLCT[bx]);
386 
387  if (infoV > 0)
388  LogDebug("CSCCathodeLCTProcessor")
390  << " (sector " << theSector << " subsector " << theSubsector << " trig id. " << theTrigChamber << ")"
391  << "\n";
392  }
393  }
394  // Now that we have our best CLCTs, they get correlated with the best
395  // ALCTs and then get sent to the MotherBoard. -JM
396 }
397 
399  bool noDigis = true;
400 
401  // Loop over layers and save comparator digis on each one into digiV[layer].
402  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
403  digiV[i_layer].clear();
404 
405  CSCDetId detid(theEndcap, theStation, theRing, theChamber, i_layer + 1);
406  getDigis(compdc, detid);
407 
408  if (isME11_ && !disableME1a_) {
409  CSCDetId detid_me1a(theEndcap, theStation, 4, theChamber, i_layer + 1);
410  getDigis(compdc, detid_me1a);
411  }
412 
413  if (!digiV[i_layer].empty()) {
414  noDigis = false;
415  if (infoV > 1) {
416  LogTrace("CSCCathodeLCTProcessor") << "found " << digiV[i_layer].size() << " comparator digi(s) in layer "
417  << i_layer << " of " << detid.chamberName() << " (trig. sector " << theSector
418  << " subsector " << theSubsector << " id " << theTrigChamber << ")";
419  }
420  }
421  }
422 
423  return noDigis;
424 }
425 
427  const bool me1a = (id.station() == 1) && (id.ring() == 4);
428  const CSCComparatorDigiCollection::Range rcompd = compdc->get(id);
429  for (CSCComparatorDigiCollection::const_iterator digiIt = rcompd.first; digiIt != rcompd.second; ++digiIt) {
430  const unsigned int origStrip = digiIt->getStrip();
431  const unsigned int maxStripsME1a =
433  // this special case can only be reached in MC
434  // in real data, the comparator digis have always ring==1
435  if (me1a && origStrip <= maxStripsME1a && !disableME1a_) {
436  // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
437  // been done already.
438  CSCComparatorDigi digi_corr(
439  origStrip + CSCConstants::MAX_NUM_STRIPS_ME1B, digiIt->getComparator(), digiIt->getTimeBinWord());
440  digiV[id.layer() - 1].push_back(digi_corr);
441  } else {
442  digiV[id.layer() - 1].push_back(*digiIt);
443  }
444  }
445 }
446 
448  std::vector<int> halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS]) {
449  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
450  int i_digi = 0; // digi counter, for dumps.
451  for (std::vector<CSCComparatorDigi>::iterator pld = digiV[i_layer].begin(); pld != digiV[i_layer].end();
452  pld++, i_digi++) {
453  // Dump raw digi info.
454  if (infoV > 1) {
455  std::ostringstream strstrm;
456  strstrm << "Comparator digi: comparator = " << pld->getComparator() << " strip #" << pld->getStrip()
457  << " time bins on:";
458  std::vector<int> bx_times = pld->getTimeBinsOn();
459  for (unsigned int tbin = 0; tbin < bx_times.size(); tbin++)
460  strstrm << " " << bx_times[tbin];
461  LogTrace("CSCCathodeLCTProcessor") << strstrm.str();
462  }
463 
464  // Get comparator: 0/1 for left/right halfstrip for each comparator
465  // that fired.
466  int thisComparator = pld->getComparator();
467  if (thisComparator != 0 && thisComparator != 1) {
468  if (infoV >= 0)
469  edm::LogWarning("L1CSCTPEmulatorWrongInput")
470  << "+++ station " << theStation << " ring " << theRing << " chamber " << theChamber
471  << " Found comparator digi with wrong comparator value = " << thisComparator << "; skipping it... +++\n";
472  continue;
473  }
474 
475  // Get strip number.
476  int thisStrip = pld->getStrip() - 1; // count from 0
477  if (thisStrip < 0 || thisStrip >= numStrips) {
478  if (infoV >= 0)
479  edm::LogWarning("L1CSCTPEmulatorWrongInput")
480  << "+++ station " << theStation << " ring " << theRing << " chamber " << theChamber
481  << " Found comparator digi with wrong strip number = " << thisStrip << " (max strips = " << numStrips
482  << "); skipping it... +++\n";
483  continue;
484  }
485  // 2*strip: convert strip to 1/2 strip
486  // comp : comparator output
487  // stagger: stagger for this layer
488  int thisHalfstrip = 2 * thisStrip + thisComparator + stagger[i_layer];
489  if (thisHalfstrip >= 2 * numStrips + 1) {
490  if (infoV >= 0)
491  edm::LogWarning("L1CSCTPEmulatorWrongInput")
492  << "+++ station " << theStation << " ring " << theRing << " chamber " << theChamber
493  << " Found wrong halfstrip number = " << thisHalfstrip << "; skipping this digi... +++\n";
494  continue;
495  }
496 
497  // Get bx times on this digi and check that they are within the bounds.
498  std::vector<int> bx_times = pld->getTimeBinsOn();
499  for (unsigned int i = 0; i < bx_times.size(); i++) {
500  // Total number of time bins in DAQ readout is given by fifo_tbins,
501  // which thus determines the maximum length of time interval.
502  //
503  // In data, only the CLCT in the time bin that was matched with L1A are read out
504  // while comparator digi is read out by 12 time bin, which includes 12 time bin info
505  // in other word, CLCTs emulated from comparator digis usually showed the OTMB behavior in 12 time bin
506  // while CLCT from data only showed 1 time bin OTMB behavior
507  // the CLCT emulated from comparator digis usually is centering at time bin 7 (BX7) and
508  // it is definitly safe to ignore any CLCTs in bx 0 or 1 and those CLCTs will never impacts on any triggers
509  if (bx_times[i] > 1 && bx_times[i] < static_cast<int>(fifo_tbins)) {
510  if (i == 0 || (i > 0 && bx_times[i] - bx_times[i - 1] >= static_cast<int>(hit_persist))) {
511  // A later hit on the same strip is ignored during the
512  // number of clocks defined by the "hit_persist" parameter
513  // (i.e., 6 bx's by default).
514  if (infoV > 1)
515  LogTrace("CSCCathodeLCTProcessor")
516  << "Comp digi: layer " << i_layer + 1 << " digi #" << i_digi + 1 << " strip " << thisStrip
517  << " halfstrip " << thisHalfstrip << " time " << bx_times[i] << " comparator " << thisComparator
518  << " stagger " << stagger[i_layer];
519  halfstrip[i_layer][thisHalfstrip].push_back(bx_times[i]);
520  } else if (i > 0) {
521  if (infoV > 1)
522  LogTrace("CSCCathodeLCTProcessor")
523  << "+++ station " << theStation << " ring " << theRing << " chamber " << theChamber
524  << " Skipping comparator digi: strip = " << thisStrip << ", layer = " << i_layer + 1
525  << ", bx = " << bx_times[i] << ", bx of previous hit = " << bx_times[i - 1];
526  }
527  } else {
528  if (infoV > 1)
529  LogTrace("CSCCathodeLCTProcessor") << "+++ station " << theStation << " ring " << theRing << " chamber "
530  << theChamber << "+++ Skipping comparator digi: strip = " << thisStrip
531  << ", layer = " << i_layer + 1 << ", bx = " << bx_times[i] << " +++";
532  }
533  }
534  }
535  }
536 }
537 
538 // TMB-07 version.
539 std::vector<CSCCLCTDigi> CSCCathodeLCTProcessor::findLCTs(
540  const std::vector<int> halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS]) {
541  std::vector<CSCCLCTDigi> lctList;
542 
543  // Max. number of half-strips for this chamber.
544  const int maxHalfStrips = 2 * numStrips + 1;
545 
546  if (infoV > 1)
547  dumpDigis(halfstrip, maxHalfStrips);
548 
549  // 2 possible LCTs per CSC x 7 LCT quantities
552 
553  // Fire half-strip one-shots for hit_persist bx's (4 bx's by default).
554  pulseExtension(halfstrip, maxHalfStrips, pulse);
555 
556  unsigned int start_bx = start_bx_shift;
557  // Stop drift_delay bx's short of fifo_tbins since at later bx's we will
558  // not have a full set of hits to start pattern search anyway.
559  unsigned int stop_bx = fifo_tbins - drift_delay;
560  // Allow for more than one pass over the hits in the time window.
561  while (start_bx < stop_bx) {
562  // All half-strip pattern envelopes are evaluated simultaneously, on every
563  // clock cycle.
564  int first_bx = 999;
565  bool pre_trig = preTrigger(pulse, start_bx, first_bx);
566 
567  // If any of half-strip envelopes has enough layers hit in it, TMB
568  // will pre-trigger.
569  if (pre_trig) {
570  thePreTriggerBXs.push_back(first_bx);
571  if (infoV > 1)
572  LogTrace("CSCCathodeLCTProcessor") << "..... pretrigger at bx = " << first_bx << "; waiting drift delay .....";
573 
574  // TMB latches LCTs drift_delay clocks after pretrigger.
575  // in the configuration the drift_delay is set to 2bx by default
576  // this is the time that is required for the electrons to drift to the
577  // cathode strips. 15ns drift time --> 45 ns is 3 sigma for the delay
578  // this corresponds to 2bx
579  int latch_bx = first_bx + drift_delay;
580 
581  // define a new pattern map
582  // for each key half strip, and for each pattern, store the 2D collection of fired comparator digis
583  std::map<int, std::map<int, CSCCLCTDigi::ComparatorContainer>> hits_in_patterns;
584  hits_in_patterns.clear();
585 
586  // We check if there is at least one key half strip for which at least
587  // one pattern id has at least the minimum number of hits
588  bool hits_in_time = patternFinding(pulse, maxHalfStrips, latch_bx, hits_in_patterns);
589  if (infoV > 1) {
590  if (hits_in_time) {
591  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER - 1]; hstrip < maxHalfStrips; hstrip++) {
592  if (nhits[hstrip] > 0) {
593  LogTrace("CSCCathodeLCTProcessor")
594  << " bx = " << std::setw(2) << latch_bx << " --->"
595  << " halfstrip = " << std::setw(3) << hstrip << " best pid = " << std::setw(2) << best_pid[hstrip]
596  << " nhits = " << nhits[hstrip];
597  }
598  }
599  }
600  }
601  // This trigger emulator does not have an active CFEB flag for DAQ (csc trigger hardware: AFF)
602  // This is a fundamental difference with the firmware where the TMB prepares the DAQ to
603  // read out the chamber
604 
605  // The pattern finder runs continuously, so another pre-trigger
606  // could occur already at the next bx.
607 
608  // Quality for sorting.
610  int best_halfstrip[CSCConstants::MAX_CLCTS_PER_PROCESSOR];
611  int best_quality[CSCConstants::MAX_CLCTS_PER_PROCESSOR];
612 
613  for (int ilct = 0; ilct < CSCConstants::MAX_CLCTS_PER_PROCESSOR; ilct++) {
614  best_halfstrip[ilct] = -1;
615  best_quality[ilct] = 0;
616  }
617 
618  // Calculate quality from pattern id and number of hits, and
619  // simultaneously select best-quality LCT.
620  if (hits_in_time) {
621  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER - 1]; hstrip < maxHalfStrips; hstrip++) {
622  // The bend-direction bit pid[0] is ignored (left and right
623  // bends have equal quality).
624  quality[hstrip] = (best_pid[hstrip] & 14) | (nhits[hstrip] << 5);
625  if (quality[hstrip] > best_quality[0]) {
626  best_halfstrip[0] = hstrip;
627  best_quality[0] = quality[hstrip];
628  }
629  if (infoV > 1 && quality[hstrip] > 0) {
630  LogTrace("CSCCathodeLCTProcessor")
631  << " 1st CLCT: halfstrip = " << std::setw(3) << hstrip << " quality = " << std::setw(3)
632  << quality[hstrip] << " nhits = " << std::setw(3) << nhits[hstrip] << " pid = " << std::setw(3)
633  << best_pid[hstrip] << " best halfstrip = " << std::setw(3) << best_halfstrip[0]
634  << " best quality = " << std::setw(3) << best_quality[0];
635  }
636  }
637  }
638 
639  // If 1st best CLCT is found, look for the 2nd best.
640  if (best_halfstrip[0] >= 0) {
641  // Mark keys near best CLCT as busy by setting their quality to
642  // zero, and repeat the search.
643  markBusyKeys(best_halfstrip[0], best_pid[best_halfstrip[0]], quality);
644 
645  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER - 1]; hstrip < maxHalfStrips; hstrip++) {
646  if (quality[hstrip] > best_quality[1]) {
647  best_halfstrip[1] = hstrip;
648  best_quality[1] = quality[hstrip];
649  }
650  if (infoV > 1 && quality[hstrip] > 0) {
651  LogTrace("CSCCathodeLCTProcessor")
652  << " 2nd CLCT: halfstrip = " << std::setw(3) << hstrip << " quality = " << std::setw(3)
653  << quality[hstrip] << " nhits = " << std::setw(3) << nhits[hstrip] << " pid = " << std::setw(3)
654  << best_pid[hstrip] << " best halfstrip = " << std::setw(3) << best_halfstrip[1]
655  << " best quality = " << std::setw(3) << best_quality[1];
656  }
657  }
658 
659  // Pattern finder.
660  for (int ilct = 0; ilct < CSCConstants::MAX_CLCTS_PER_PROCESSOR; ilct++) {
661  int best_hs = best_halfstrip[ilct];
662  if (best_hs >= 0 && nhits[best_hs] >= nplanes_hit_pattern) {
663  keystrip_data[ilct][CLCT_PATTERN] = best_pid[best_hs];
664  keystrip_data[ilct][CLCT_BEND] =
666  // Remove stagger if any.
667  keystrip_data[ilct][CLCT_STRIP] = best_hs - stagger[CSCConstants::KEY_CLCT_LAYER - 1];
668  keystrip_data[ilct][CLCT_BX] = first_bx;
669  keystrip_data[ilct][CLCT_STRIP_TYPE] = 1; // obsolete
670  keystrip_data[ilct][CLCT_QUALITY] = nhits[best_hs];
671  keystrip_data[ilct][CLCT_CFEB] = keystrip_data[ilct][CLCT_STRIP] / CSCConstants::NUM_HALF_STRIPS_PER_CFEB;
672  int halfstrip_in_cfeb = keystrip_data[ilct][CLCT_STRIP] -
673  CSCConstants::NUM_HALF_STRIPS_PER_CFEB * keystrip_data[ilct][CLCT_CFEB];
674 
675  if (infoV > 1)
676  LogTrace("CSCCathodeLCTProcessor")
677  << " Final selection: ilct " << ilct << " key halfstrip " << keystrip_data[ilct][CLCT_STRIP]
678  << " quality " << keystrip_data[ilct][CLCT_QUALITY] << " pattern "
679  << keystrip_data[ilct][CLCT_PATTERN] << " bx " << keystrip_data[ilct][CLCT_BX];
680 
681  CSCCLCTDigi thisLCT(1,
682  keystrip_data[ilct][CLCT_QUALITY],
683  keystrip_data[ilct][CLCT_PATTERN],
684  keystrip_data[ilct][CLCT_STRIP_TYPE],
685  keystrip_data[ilct][CLCT_BEND],
686  halfstrip_in_cfeb,
687  keystrip_data[ilct][CLCT_CFEB],
688  keystrip_data[ilct][CLCT_BX],
689  0,
690  // track number is assigned later
691  0,
692  // comparator code is assigned for Run-3 and Phase-2
693  -1,
694  // default version is legacy
696 
697  // get the comparator hits for this pattern
698  const auto& compHits = hits_in_patterns[best_hs][keystrip_data[ilct][CLCT_PATTERN]];
699 
700  // set the hit collection
701  thisLCT.setHits(compHits);
702 
703  // do the CCLUT procedures
704  if (runCCLUT_) {
705  runCCLUT(thisLCT);
706  }
707 
708  // purge the comparator digi collection from the obsolete "65535" entries...
709  cleanComparatorContainer(thisLCT);
710 
711  // useful debugging
712  if (infoV > 1) {
713  LogTrace("CSCCathodeLCTProcessor") << " Final selection: ilct " << ilct << " " << thisLCT << std::endl;
714  }
715  // put the CLCT into the collection
716  lctList.push_back(thisLCT);
717  }
718  }
719  } //find CLCT, end of best_halfstrip[0] >= 0
720 
721  // If there is a trigger, CLCT pre-trigger state machine
722  // checks the number of hits that lie within a pattern template
723  // at every bx, and waits for it to drop below threshold.
724  // The search for CLCTs resumes only when the number of hits
725  // drops below threshold.
726  start_bx = fifo_tbins;
727  // Stop checking drift_delay bx's short of fifo_tbins since
728  // at later bx's we won't have a full set of hits for a
729  // pattern search anyway.
730  unsigned int stop_time = fifo_tbins - drift_delay;
731  for (unsigned int bx = latch_bx + 1; bx < stop_time; bx++) {
732  bool return_to_idle = true;
733  bool hits_in_time = patternFinding(pulse, maxHalfStrips, bx, hits_in_patterns);
734  if (hits_in_time) {
735  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER - 1]; hstrip < maxHalfStrips; hstrip++) {
736  // the dead-time is done at the pre-trigger, not at the trigger
737  if (nhits[hstrip] >= nplanes_hit_pretrig) {
738  if (infoV > 1)
739  LogTrace("CSCCathodeLCTProcessor") << " State machine busy at bx = " << bx;
740  return_to_idle = false;
741  break;
742  }
743  }
744  }
745  if (return_to_idle) {
746  if (infoV > 1)
747  LogTrace("CSCCathodeLCTProcessor") << " State machine returns to idle state at bx = " << bx;
748  start_bx = bx;
749  break;
750  }
751  }
752  } //pre_trig
753  else {
754  start_bx = first_bx + 1; // no dead time
755  }
756  }
757 
758  return lctList;
759 } // findLCTs -- TMB-07 version.
760 
761 // Common to all versions.
764  const int nStrips,
765  PulseArray pulse) {
766  static const unsigned int bits_in_pulse = 8 * sizeof(pulse[0][0]);
767 
768  // Clear pulse array. This array will be used as a bit representation of
769  // hit times. For example: if strip[1][2] has a value of 3, then 1 shifted
770  // left 3 will be bit pattern of pulse[1][2]. This would make the pattern
771  // look like 0000000000001000. Then add on additional bits to signify
772  // the duration of a signal (hit_persist, formerly bx_width) to simulate
773  // the TMB's drift delay. So for the same pulse[1][2] with a hit_persist
774  // of 3 would look like 0000000000111000. This is similating the digital
775  // one-shot in the TMB.
776  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++)
777  for (int i_strip = 0; i_strip < nStrips; i_strip++)
778  pulse[i_layer][i_strip] = 0;
779 
780  // Loop over all layers and halfstrips.
781  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
782  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
783  // If there is a hit, simulate digital one-shot persistence starting
784  // in the bx of the initial hit. Fill this into pulse[][].
785  if (!time[i_layer][i_strip].empty()) {
786  std::vector<int> bx_times = time[i_layer][i_strip];
787  for (unsigned int i = 0; i < bx_times.size(); i++) {
788  // Check that min and max times are within the allowed range.
789  if (bx_times[i] < 0 || bx_times[i] + hit_persist >= bits_in_pulse) {
790  if (infoV > 0)
791  edm::LogWarning("L1CSCTPEmulatorOutOfTimeDigi")
792  << "+++ BX time of comparator digi (halfstrip = " << i_strip << " layer = " << i_layer
793  << ") bx = " << bx_times[i] << " is not within the range (0-" << bits_in_pulse
794  << "] allowed for pulse extension. Skip this digi! +++\n";
795  continue;
796  }
797  if (bx_times[i] >= start_bx_shift) {
798  for (unsigned int bx = bx_times[i]; bx < bx_times[i] + hit_persist; ++bx)
799  pulse[i_layer][i_strip] = pulse[i_layer][i_strip] | (1 << bx);
800  }
801  }
802  }
803  }
804  }
805 } // pulseExtension.
806 
807 // TMB-07 version.
808 bool CSCCathodeLCTProcessor::preTrigger(const PulseArray pulse, const int start_bx, int& first_bx) {
809  if (infoV > 1)
810  LogTrace("CSCCathodeLCTProcessor") << "....................PreTrigger...........................";
811 
812  // Max. number of half-strips for this chamber.
813  const int nStrips = 2 * numStrips + 1;
814 
815  int nPreTriggers = 0;
816 
817  bool pre_trig = false;
818  // Now do a loop over bx times to see (if/when) track goes over threshold
819  for (unsigned int bx_time = start_bx; bx_time < fifo_tbins; bx_time++) {
820  // For any given bunch-crossing, start at the lowest keystrip and look for
821  // the number of separate layers in the pattern for that keystrip that have
822  // pulses at that bunch-crossing time. Do the same for the next keystrip,
823  // etc. Then do the entire process again for the next bunch-crossing, etc
824  // until you find a pre-trigger.
825 
826  std::map<int, std::map<int, CSCCLCTDigi::ComparatorContainer>> hits_in_patterns;
827  hits_in_patterns.clear();
828 
829  bool hits_in_time = patternFinding(pulse, nStrips, bx_time, hits_in_patterns);
830  if (hits_in_time) {
831  for (int hstrip = stagger[CSCConstants::KEY_CLCT_LAYER - 1]; hstrip < nStrips; hstrip++) {
832  if (infoV > 1) {
833  if (nhits[hstrip] > 0) {
834  LogTrace("CSCCathodeLCTProcessor")
835  << " bx = " << std::setw(2) << bx_time << " --->"
836  << " halfstrip = " << std::setw(3) << hstrip << " best pid = " << std::setw(2) << best_pid[hstrip]
837  << " nhits = " << nhits[hstrip];
838  }
839  }
840  ispretrig[hstrip] = false;
841  if (nhits[hstrip] >= nplanes_hit_pretrig && best_pid[hstrip] >= pid_thresh_pretrig) {
842  pre_trig = true;
843  ispretrig[hstrip] = true;
844 
845  // write each pre-trigger to output
846  nPreTriggers++;
847  const int bend =
849  const int halfstrip = hstrip % CSCConstants::NUM_HALF_STRIPS_PER_CFEB;
850  const int cfeb = hstrip / CSCConstants::NUM_HALF_STRIPS_PER_CFEB;
852  1, nhits[hstrip], best_pid[hstrip], 1, bend, halfstrip, cfeb, bx_time, nPreTriggers, 0));
853  }
854  }
855 
856  if (pre_trig) {
857  first_bx = bx_time; // bx at time of pretrigger
858  return true;
859  }
860  }
861  } // end loop over bx times
862 
863  if (infoV > 1)
864  LogTrace("CSCCathodeLCTProcessor") << "no pretrigger, returning \n";
865  first_bx = fifo_tbins;
866  return false;
867 } // preTrigger -- TMB-07 version.
868 
869 // TMB-07 version.
871  const PulseArray pulse,
872  const int nStrips,
873  const unsigned int bx_time,
874  std::map<int, std::map<int, CSCCLCTDigi::ComparatorContainer>>& hits_in_patterns) {
875  if (bx_time >= fifo_tbins)
876  return false;
877 
878  // This loop is a quick check of a number of layers hit at bx_time: since
879  // most of the time it is 0, this check helps to speed-up the execution
880  // substantially.
881  unsigned int layers_hit = 0;
882  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
883  for (int i_hstrip = 0; i_hstrip < nStrips; i_hstrip++) {
884  if (((pulse[i_layer][i_hstrip] >> bx_time) & 1) == 1) {
885  layers_hit++;
886  break;
887  }
888  }
889  }
890  if (layers_hit < nplanes_hit_pretrig)
891  return false;
892 
893  for (int key_hstrip = 0; key_hstrip < nStrips; key_hstrip++) {
894  best_pid[key_hstrip] = 0;
895  nhits[key_hstrip] = 0;
896  first_bx_corrected[key_hstrip] = -999;
897  }
898 
899  bool hit_layer[CSCConstants::NUM_LAYERS];
900 
901  // Loop over candidate key strips.
902  for (int key_hstrip = stagger[CSCConstants::KEY_CLCT_LAYER - 1]; key_hstrip < nStrips; key_hstrip++) {
903  // Loop over patterns and look for hits matching each pattern.
904  for (unsigned int pid = clct_pattern_.size() - 1; pid >= pid_thresh_pretrig and pid < clct_pattern_.size(); pid--) {
905  layers_hit = 0;
906  // clear all layers
907  for (int ilayer = 0; ilayer < CSCConstants::NUM_LAYERS; ilayer++) {
908  hit_layer[ilayer] = false;
909  }
910 
911  // clear a single pattern!
912  CSCCLCTDigi::ComparatorContainer hits_single_pattern;
913  hits_single_pattern.resize(6);
914  for (auto& p : hits_single_pattern) {
916  }
917 
918  // clear all medians
919  double num_pattern_hits = 0., times_sum = 0.;
920  std::multiset<int> mset_for_median;
921  mset_for_median.clear();
922 
923  // Loop over halfstrips in trigger pattern mask and calculate the
924  // "absolute" halfstrip number for each.
925  for (int this_layer = 0; this_layer < CSCConstants::NUM_LAYERS; this_layer++) {
926  for (int strip_num = 0; strip_num < CSCConstants::CLCT_PATTERN_WIDTH; strip_num++) {
927  // ignore "0" half-strips in the pattern
928  if (clct_pattern_[pid][this_layer][strip_num] == 0)
929  continue;
930 
931  // the current strip is the key half-strip plus the offset (can be negative or positive)
932  int this_strip = CSCPatternBank::clct_pattern_offset_[strip_num] + key_hstrip;
933 
934  // current strip should be valid of course
935  if (this_strip >= 0 && this_strip < nStrips) {
936  if (infoV > 3) {
937  LogTrace("CSCCathodeLCTProcessor") << " In patternFinding: key_strip = " << key_hstrip << " pid = " << pid
938  << " layer = " << this_layer << " strip = " << this_strip << std::endl;
939  }
940  // Determine if "one shot" is high at this bx_time
941  if (((pulse[this_layer][this_strip] >> bx_time) & 1) == 1) {
942  if (hit_layer[this_layer] == false) {
943  hit_layer[this_layer] = true;
944  layers_hit++; // determines number of layers hit
945  // add this strip in this layer to the pattern we are currently considering
946  hits_single_pattern[this_layer][strip_num] = this_strip - stagger[this_layer];
947  }
948 
949  // find at what bx did pulse on this halsfstrip & layer have started
950  // use hit_persist constraint on how far back we can go
951  int first_bx_layer = bx_time;
952  for (unsigned int dbx = 0; dbx < hit_persist; dbx++) {
953  if (((pulse[this_layer][this_strip] >> (first_bx_layer - 1)) & 1) == 1)
954  first_bx_layer--;
955  else
956  break;
957  }
958  times_sum += (double)first_bx_layer;
959  num_pattern_hits += 1.;
960  mset_for_median.insert(first_bx_layer);
961  if (infoV > 2)
962  LogTrace("CSCCathodeLCTProcessor") << " 1st bx in layer: " << first_bx_layer << " sum bx: " << times_sum
963  << " #pat. hits: " << num_pattern_hits;
964  }
965  }
966  } // end loop over strips in pretrigger pattern
967  } // end loop over layers
968 
969  // save the pattern information when a trigger was formed!
970  if (layers_hit >= nplanes_hit_pattern) {
971  hits_in_patterns[key_hstrip][pid] = hits_single_pattern;
972  }
973 
974  // determine the current best pattern!
975  if (layers_hit > nhits[key_hstrip]) {
976  best_pid[key_hstrip] = pid;
977  nhits[key_hstrip] = layers_hit;
978 
979  // calculate median
980  const int sz = mset_for_median.size();
981  if (sz > 0) {
982  std::multiset<int>::iterator im = mset_for_median.begin();
983  if (sz > 1)
984  std::advance(im, sz / 2 - 1);
985  if (sz == 1)
986  first_bx_corrected[key_hstrip] = *im;
987  else if ((sz % 2) == 1)
988  first_bx_corrected[key_hstrip] = *(++im);
989  else
990  first_bx_corrected[key_hstrip] = ((*im) + (*(++im))) / 2;
991 
992 #if defined(EDM_ML_DEBUG)
993  //LogTrace only ever prints if EDM_ML_DEBUG is defined
994  if (infoV > 1) {
995  auto lt = LogTrace("CSCCathodeLCTProcessor")
996  << "bx=" << bx_time << " bx_cor=" << first_bx_corrected[key_hstrip] << " bxset=";
997  for (im = mset_for_median.begin(); im != mset_for_median.end(); im++) {
998  lt << " " << *im;
999  }
1000  }
1001 #endif
1002  }
1003  // Do not loop over the other (worse) patterns if max. numbers of
1004  // hits is found.
1005  if (nhits[key_hstrip] == CSCConstants::NUM_LAYERS)
1006  break;
1007  }
1008  } // end loop over pid
1009  } // end loop over candidate key strips
1010 
1011  // At this point there exists at least one halfstrip for which at least one pattern
1012  // has at least 3 layers --> definition of a pre-trigger
1013  return true;
1014 } // patternFinding -- TMB-07 version.
1015 
1016 // TMB-07 version.
1017 void CSCCathodeLCTProcessor::markBusyKeys(const int best_hstrip,
1018  const int best_patid,
1020  int nspan = min_separation;
1021  int pspan = min_separation;
1022 
1023  for (int hstrip = best_hstrip - nspan; hstrip <= best_hstrip + pspan; hstrip++) {
1024  if (hstrip >= 0 && hstrip < CSCConstants::NUM_HALF_STRIPS_7CFEBS) {
1025  quality[hstrip] = 0;
1026  }
1027  }
1028 } // markBusyKeys -- TMB-07 version.
1029 
1031  CSCCLCTDigi::ComparatorContainer newHits = clct.getHits();
1032  for (auto& p : newHits) {
1033  p.erase(std::remove_if(
1034  p.begin(), p.end(), [](unsigned i) -> bool { return i == CSCCathodeLCTProcessor::INVALID_HALFSTRIP; }),
1035  p.end());
1036  }
1037  clct.setHits(newHits);
1038 }
1039 
1040 // --------------------------------------------------------------------------
1041 // Auxiliary code.
1042 // --------------------------------------------------------------------------
1043 // Dump of configuration parameters.
1045  std::ostringstream strm;
1046  strm << "\n";
1047  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
1048  strm << "+ CLCT configuration parameters: +\n";
1049  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
1050  strm << " fifo_tbins [total number of time bins in DAQ readout] = " << fifo_tbins << "\n";
1051  strm << " fifo_pretrig [start time of cathode raw hits in DAQ readout] = " << fifo_pretrig << "\n";
1052  strm << " hit_persist [duration of signal pulse, in 25 ns bins] = " << hit_persist << "\n";
1053  strm << " drift_delay [time after pre-trigger before TMB latches LCTs] = " << drift_delay << "\n";
1054  strm << " nplanes_hit_pretrig [min. number of layers hit for pre-trigger] = " << nplanes_hit_pretrig << "\n";
1055  strm << " nplanes_hit_pattern [min. number of layers hit for trigger] = " << nplanes_hit_pattern << "\n";
1056  strm << " pid_thresh_pretrig [lower threshold on pattern id] = " << pid_thresh_pretrig << "\n";
1057  strm << " min_separation [region of busy key strips] = " << min_separation << "\n";
1058  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
1059  LogDebug("CSCCathodeLCTProcessor") << strm.str();
1060 }
1061 
1062 // Reasonably nice dump of digis on half-strips.
1065  const int nStrips) const {
1066  LogDebug("CSCCathodeLCTProcessor") << theCSCName_ << " strip type: half-strip, nStrips " << nStrips;
1067 
1068  std::ostringstream strstrm;
1069  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
1070  if (i_strip % 10 == 0) {
1071  if (i_strip < 100)
1072  strstrm << i_strip / 10;
1073  else
1074  strstrm << (i_strip - 100) / 10;
1075  } else
1076  strstrm << " ";
1077  if ((i_strip + 1) % CSCConstants::NUM_HALF_STRIPS_PER_CFEB == 0)
1078  strstrm << " ";
1079  }
1080  strstrm << "\n";
1081  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
1082  strstrm << i_strip % 10;
1083  if ((i_strip + 1) % CSCConstants::NUM_HALF_STRIPS_PER_CFEB == 0)
1084  strstrm << " ";
1085  }
1086  for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) {
1087  strstrm << "\n";
1088  for (int i_strip = 0; i_strip < nStrips; i_strip++) {
1089  if (!strip[i_layer][i_strip].empty()) {
1090  std::vector<int> bx_times = strip[i_layer][i_strip];
1091  // Dump only the first in time.
1092  strstrm << std::hex << bx_times[0] << std::dec;
1093  } else {
1094  strstrm << "-";
1095  }
1096  if ((i_strip + 1) % CSCConstants::NUM_HALF_STRIPS_PER_CFEB == 0)
1097  strstrm << " ";
1098  }
1099  }
1100  LogTrace("CSCCathodeLCTProcessor") << strstrm.str();
1101 }
1102 
1103 // Returns vector of read-out CLCTs, if any. Starts with the vector
1104 // of all found CLCTs and selects the ones in the read-out time window.
1105 std::vector<CSCCLCTDigi> CSCCathodeLCTProcessor::readoutCLCTs(int nMaxCLCTs) const {
1106  std::vector<CSCCLCTDigi> tmpV;
1107 
1108  // The start time of the L1A*CLCT coincidence window should be
1109  // related to the fifo_pretrig parameter, but I am not completely
1110  // sure how. For now, just choose it such that the window is
1111  // centered at bx=7. This may need further tweaking if the value of
1112  // tmb_l1a_window_size changes.
1113 
1114  // The number of CLCT bins in the read-out is given by the
1115  // tmb_l1a_window_size parameter, but made even by setting the LSB
1116  // of tmb_l1a_window_size to 0.
1117  //
1118  static std::atomic<int> lct_bins;
1119  lct_bins = (tmb_l1a_window_size % 2 == 0) ? tmb_l1a_window_size : tmb_l1a_window_size - 1;
1120  static std::atomic<int> late_tbins;
1121  late_tbins = early_tbins + lct_bins;
1122 
1123  static std::atomic<int> ifois{0};
1124  if (ifois == 0) {
1125  if (infoV >= 0 && early_tbins < 0) {
1126  edm::LogWarning("L1CSCTPEmulatorSuspiciousParameters")
1127  << "+++ early_tbins = " << early_tbins << "; in-time CLCTs are not getting read-out!!! +++"
1128  << "\n";
1129  }
1130 
1131  if (late_tbins > CSCConstants::MAX_CLCT_TBINS - 1) {
1132  if (infoV >= 0)
1133  edm::LogWarning("L1CSCTPEmulatorSuspiciousParameters")
1134  << "+++ Allowed range of time bins, [0-" << late_tbins << "] exceeds max allowed, "
1135  << CSCConstants::MAX_CLCT_TBINS - 1 << " +++\n"
1136  << "+++ Set late_tbins to max allowed +++\n";
1137  late_tbins = CSCConstants::MAX_CLCT_TBINS - 1;
1138  }
1139  ifois = 1;
1140  }
1141 
1142  // Start from the vector of all found CLCTs and select those within
1143  // the CLCT*L1A coincidence window.
1144  int bx_readout = -1;
1145  const std::vector<CSCCLCTDigi>& all_lcts = getCLCTs(nMaxCLCTs);
1146  for (const auto& p : all_lcts) {
1147  // only consider valid CLCTs
1148  if (!p.isValid())
1149  continue;
1150 
1151  const int bx = p.getBX();
1152  // Skip CLCTs found too early relative to L1Accept.
1153  if (bx <= early_tbins) {
1154  if (infoV > 1)
1155  LogDebug("CSCCathodeLCTProcessor")
1156  << " Do not report CLCT on key halfstrip " << p.getKeyStrip() << ": found at bx " << bx
1157  << ", whereas the earliest allowed bx is " << early_tbins + 1;
1158  continue;
1159  }
1160 
1161  // Skip CLCTs found too late relative to L1Accept.
1162  if (bx > late_tbins) {
1163  if (infoV > 1)
1164  LogDebug("CSCCathodeLCTProcessor")
1165  << " Do not report CLCT on key halfstrip " << p.getKeyStrip() << ": found at bx " << bx
1166  << ", whereas the latest allowed bx is " << late_tbins;
1167  continue;
1168  }
1169 
1170  // If (readout_earliest_2) take only CLCTs in the earliest bx in the read-out window:
1171  // in digi->raw step, LCTs have to be packed into the TMB header, and
1172  // currently there is room just for two.
1173  if (readout_earliest_2) {
1174  if (bx_readout == -1 || bx == bx_readout) {
1175  tmpV.push_back(p);
1176  if (bx_readout == -1)
1177  bx_readout = bx;
1178  }
1179  } else
1180  tmpV.push_back(p);
1181  }
1182 
1183  // do a final check on the CLCTs in readout
1184  qualityControl_->checkMultiplicityBX(tmpV);
1185  for (const auto& clct : tmpV) {
1186  qualityControl_->checkValid(clct, nMaxCLCTs);
1187  }
1188 
1189  return tmpV;
1190 }
1191 
1192 // Returns vector of read-out CLCTs, if any. Starts with the vector
1193 // of all found CLCTs and selects the ones in the read-out time window.
1194 std::vector<CSCCLCTDigi> CSCCathodeLCTProcessor::readoutCLCTsME1a(int nMaxCLCTs) const {
1195  std::vector<CSCCLCTDigi> tmpV;
1196  if (not(theStation == 1 and (theRing == 1 or theRing == 4)))
1197  return tmpV;
1198  const std::vector<CSCCLCTDigi>& allCLCTs = readoutCLCTs(nMaxCLCTs);
1199  for (const auto& clct : allCLCTs)
1200  if (clct.getCFEB() >= 4)
1201  tmpV.push_back(clct);
1202  return tmpV;
1203 }
1204 
1205 // Returns vector of read-out CLCTs, if any. Starts with the vector
1206 // of all found CLCTs and selects the ones in the read-out time window.
1207 std::vector<CSCCLCTDigi> CSCCathodeLCTProcessor::readoutCLCTsME1b(int nMaxCLCTs) const {
1208  std::vector<CSCCLCTDigi> tmpV;
1209  if (not(theStation == 1 and (theRing == 1 or theRing == 4)))
1210  return tmpV;
1211  const std::vector<CSCCLCTDigi>& allCLCTs = readoutCLCTs(nMaxCLCTs);
1212  for (const auto& clct : allCLCTs)
1213  if (clct.getCFEB() < 4)
1214  tmpV.push_back(clct);
1215  return tmpV;
1216 }
1217 
1218 std::vector<CSCCLCTPreTriggerDigi> CSCCathodeLCTProcessor::preTriggerDigisME1a() const {
1219  std::vector<CSCCLCTPreTriggerDigi> tmpV;
1220  if (not(theStation == 1 and (theRing == 1 or theRing == 4)))
1221  return tmpV;
1222  const std::vector<CSCCLCTPreTriggerDigi>& allPretriggerdigis = preTriggerDigis();
1223  for (const auto& preclct : allPretriggerdigis)
1224  if (preclct.getCFEB() >= 4)
1225  tmpV.push_back(preclct);
1226  return tmpV;
1227 }
1228 
1229 std::vector<CSCCLCTPreTriggerDigi> CSCCathodeLCTProcessor::preTriggerDigisME1b() const {
1230  std::vector<CSCCLCTPreTriggerDigi> tmpV;
1231  if (not(theStation == 1 and (theRing == 1 or theRing == 4)))
1232  return tmpV;
1233  const std::vector<CSCCLCTPreTriggerDigi>& allPretriggerdigis = preTriggerDigis();
1234  for (const auto& preclct : allPretriggerdigis)
1235  if (preclct.getCFEB() < 4)
1236  tmpV.push_back(preclct);
1237  return tmpV;
1238 }
1239 
1240 // Returns vector of all found CLCTs, if any. Used for ALCT-CLCT matching.
1241 std::vector<CSCCLCTDigi> CSCCathodeLCTProcessor::getCLCTs(unsigned nMaxCLCTs) const {
1242  std::vector<CSCCLCTDigi> tmpV;
1243  for (int bx = 0; bx < CSCConstants::MAX_CLCT_TBINS; bx++) {
1244  if (bestCLCT[bx].isValid())
1245  tmpV.push_back(bestCLCT[bx]);
1246  if (secondCLCT[bx].isValid())
1247  tmpV.push_back(secondCLCT[bx]);
1248  }
1249  return tmpV;
1250 }
1251 
1252 // shift the BX from 7 to 8
1253 // the unpacked real data CLCTs have central BX at bin 7
1254 // however in simulation the central BX is bin 8
1255 // to make a proper comparison with ALCTs we need
1256 // CLCT and ALCT to have the central BX in the same bin
1258  CSCCLCTDigi lct = bestCLCT[bx];
1260  return lct;
1261 }
1262 
1264  CSCCLCTDigi lct = secondCLCT[bx];
1266  return lct;
1267 }
1268 
1269 // --------Functions for the comparator code algorith for Run-3 ---------//
1270 
1271 int CSCCathodeLCTProcessor::calculateComparatorCode(const std::array<std::array<int, 3>, 6>& halfStripPattern) const {
1272  int id = 0;
1273 
1274  for (unsigned int column = 0; column < CSCConstants::NUM_LAYERS; column++) {
1275  int rowPat = 0; //physical arrangement of the three bits
1276  int rowCode = 0; //code used to identify the arrangement
1277 
1278  //use Firmware definition for comparator code definition
1279  for (int row = 2; row >= 0; row--) {
1280  rowPat = rowPat << 1; //bitshift the last number to the left
1281  rowPat += halfStripPattern[column][row];
1282  }
1283  switch (rowPat) {
1284  case 0: //000
1285  rowCode = 0;
1286  break;
1287  case 1: //00X
1288  rowCode = 1;
1289  break;
1290  case 2: //0X0
1291  rowCode = 2;
1292  break;
1293  case 4: //00X
1294  rowCode = 3;
1295  break;
1296  default:
1297  // default return value is -1
1298  return -1;
1299  }
1300  //each column has two bits of information, largest layer is most significant bit
1301  id += (rowCode << 2 * column);
1302  }
1303  return id;
1304 }
1305 
1307  std::tuple<uint16_t, bool, bool>& returnValue) const {
1308  /*
1309  | Value | Half-Strip Offset | Delta Half-Strip | Quarter-Strip Bit | Eighth-Strip Bit |
1310  |-------|--------------------|-------------------|--------------------|------------------|
1311  | 0 | -7/4 | -2 | 0 | 1 |
1312  | 1 | -3/2 | -2 | 1 | 0 |
1313  | 2 | -5/4 | -2 | 1 | 1 |
1314  | 3 | -1 | -1 | 0 | 0 |
1315  | 4 | -3/4 | -1 | 0 | 1 |
1316  | 5 | -1/2 | -1 | 1 | 0 |
1317  | 6 | -1/4 | -1 | 1 | 1 |
1318  | 7 | 0 | 0 | 0 | 0 |
1319  | 8 | 1/4 | 0 | 0 | 1 |
1320  | 9 | 1/2 | 0 | 1 | 0 |
1321  | 10 | 3/4 | 0 | 1 | 1 |
1322  | 11 | 1 | 1 | 0 | 0 |
1323  | 12 | 5/4 | 1 | 0 | 1 |
1324  | 13 | 3/2 | 1 | 1 | 0 |
1325  | 14 | 7/4 | 1 | 1 | 1 |
1326  | 15 | 2 | 2 | 0 | 0 |
1327  */
1328  std::vector<std::tuple<uint16_t, bool, bool>> my_tuple = {
1329  {-2, false, true},
1330  {-2, true, false},
1331  {-2, true, true},
1332  {-1, false, false},
1333  {-1, false, true},
1334  {-1, true, false},
1335  {-1, true, true},
1336  {0, false, false},
1337  {0, false, true},
1338  {0, true, false},
1339  {0, true, true},
1340  {1, false, false},
1341  {1, false, true},
1342  {1, true, false},
1343  {1, true, true},
1344  {2, false, false},
1345  };
1346  returnValue = my_tuple[offset];
1347 }
1348 
1350  // print out the old CLCT for debugging
1351  if (infoV > 2) {
1352  std::ostringstream strm;
1353  strm << "\n";
1354  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
1355  strm << "+ Before CCCLUT algorithm: +\n";
1356  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
1357  strm << " Old CLCT digi " << digi << "\n";
1358  strm << " 1/4 strip bit " << digi.getQuartStrip() << " 1/8 strip bit " << digi.getEightStrip() << "\n";
1359  strm << " 1/4 strip number " << digi.getKeyStrip(4) << " 1/8 strip number " << digi.getKeyStrip(8) << "\n";
1360  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
1361  LogDebug("CSCCathodeLCTProcessor") << strm.str();
1362  }
1363 
1364  // set Run-3 flag
1365  digi.setRun3(true);
1366 
1367  // Get the comparator hits
1368  auto compHits = digi.getHits();
1369 
1370  // Wrap the comparator code in a format for calculation
1371  std::array<std::array<int, 3>, CSCConstants::NUM_LAYERS> compHitsCC;
1372 
1373  for (int i = 0; i < CSCConstants::NUM_LAYERS; i++) {
1374  int iCC = 0;
1375  for (int j = 0; j < CSCConstants::CLCT_PATTERN_WIDTH; j++) {
1376  // only fill when the pattern is active
1377  if (clct_pattern_[digi.getPattern()][i][j]) {
1378  if (compHits[i][j] != INVALID_HALFSTRIP) {
1379  compHitsCC[i][iCC] = 1;
1380  } else {
1381  compHitsCC[i][iCC] = 0;
1382  }
1383  iCC++;
1384  }
1385  }
1386  }
1387 
1388  // calculate the comparator code
1389  const int comparatorCode(calculateComparatorCode(compHitsCC));
1390 
1391  // store the comparator code
1392  digi.setCompCode(comparatorCode);
1393 
1394  // calculate the slope and position offset
1395  const int pattern(digi.getPattern());
1396 
1397  // set the Run-3 pattern
1398  digi.setRun3Pattern(pattern);
1399 
1400  // look-up the unsigned values
1401  const unsigned positionCC(lutpos_[pattern]->lookup(comparatorCode));
1402  const unsigned slopeCC(lutslope_[pattern]->lookup(comparatorCode));
1403  unsigned run2PatternCC(lutpatconv_[pattern]->lookup(comparatorCode));
1404 
1405  // if the slope is negative, set bending to 0
1406  const bool slopeCCSign((slopeCC >> 4) & 0x1);
1407  const unsigned slopeCCValue(slopeCC & 0xf);
1408  digi.setBend(slopeCCSign);
1409 
1410  // calculate the new position
1411  uint16_t halfstrip = digi.getKeyStrip();
1412  std::tuple<uint16_t, bool, bool> halfstripoffset;
1413  assignPositionCC(positionCC, halfstripoffset);
1414  halfstrip += std::get<0>(halfstripoffset);
1415 
1416  // store the new 1/2, 1/4 and 1/8 strip positions
1417  digi.setStrip(halfstrip - digi.getCFEB() * 32);
1418  digi.setQuartStrip(std::get<1>(halfstripoffset));
1419  digi.setEightStrip(std::get<2>(halfstripoffset));
1420 
1421  // store the bending angle value in the pattern data member
1422  digi.setSlope(slopeCCValue);
1423 
1424  // set the quasi Run-2 pattern - to accommodate integration with EMTF/OMTF
1425  if (run2PatternCC == 0) {
1426  run2PatternCC = convertSlopeToRun2Pattern(slopeCC);
1427  }
1428  digi.setPattern(run2PatternCC);
1429 
1430  // now print out the new CLCT for debugging
1431  if (infoV > 2) {
1432  std::ostringstream strm;
1433  strm << "\n";
1434  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
1435  strm << "+ CCCLUT algorithm results: +\n";
1436  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
1437  strm << " New CLCT digi " << digi << "\n";
1438  strm << " 1/4 strip bit " << digi.getQuartStrip() << " 1/8 strip bit " << digi.getEightStrip() << "\n";
1439  strm << " 1/4 strip number " << digi.getKeyStrip(4) << " 1/8 strip number " << digi.getKeyStrip(8) << "\n";
1440  strm << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
1441  LogDebug("CSCCathodeLCTProcessor") << strm.str();
1442  }
1443 }
1444 
1446  const unsigned slopeList[32] = {2, 2, 2, 4, 4, 4, 6, 6, 6, 6, 8, 8, 8, 8, 10, 10,
1447  10, 10, 9, 9, 9, 9, 7, 7, 7, 7, 5, 5, 5, 3, 3, 3};
1448  return slopeList[slope];
1449 }
CSCDBL1TPParameters
Definition: CSCDBL1TPParameters.h:14
CSCCathodeLCTProcessor::assignPositionCC
void assignPositionCC(const unsigned offset, std::tuple< uint16_t, bool, bool > &returnValue) const
Definition: CSCCathodeLCTProcessor.cc:1306
CSCCathodeLCTProcessor::qualityControl_
std::unique_ptr< LCTQualityControl > qualityControl_
Definition: CSCCathodeLCTProcessor.h:235
CSCCathodeLCTProcessor::markBusyKeys
void markBusyKeys(const int best_hstrip, const int best_patid, int quality[CSCConstants::NUM_HALF_STRIPS_7CFEBS])
Definition: CSCCathodeLCTProcessor.cc:1017
CSCCLCTDigi::setTrknmb
void setTrknmb(const uint16_t number)
Set track number (1,2) after sorting CLCTs.
Definition: CSCCLCTDigi.h:160
mps_fire.i
i
Definition: mps_fire.py:428
CSCBaseboard::theEndcap
const unsigned theEndcap
Definition: CSCBaseboard.h:42
CSCBaseboard::clctParams_
edm::ParameterSet clctParams_
Definition: CSCBaseboard.h:79
CSCChamber::layer
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
Definition: CSCChamber.cc:30
CSCCathodeLCTProcessor::stagger
int stagger[CSCConstants::NUM_LAYERS]
Definition: CSCCathodeLCTProcessor.h:200
CSCCathodeLCTProcessor::getSecondCLCT
CSCCLCTDigi getSecondCLCT(int bx) const
Definition: CSCCathodeLCTProcessor.cc:1263
CSCBaseboard::cscChamber_
const CSCChamber * cscChamber_
Definition: CSCBaseboard.h:67
CSCBaseboard::theSector
const unsigned theSector
Definition: CSCBaseboard.h:44
CSCCathodeLCTProcessor::dumpConfigParams
void dumpConfigParams() const
Definition: CSCCathodeLCTProcessor.cc:1044
CSCBaseboard::tmbParams_
edm::ParameterSet tmbParams_
Definition: CSCBaseboard.h:73
relativeConstraints.station
station
Definition: relativeConstraints.py:67
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
CSCBaseboard::disableME1a_
bool disableME1a_
Definition: CSCBaseboard.h:89
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CSCCathodeLCTProcessor::fifo_tbins
unsigned int fifo_tbins
Definition: CSCCathodeLCTProcessor.h:207
CSCCathodeLCTProcessor::dumpDigis
void dumpDigis(const std::vector< int > strip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips) const
Definition: CSCCathodeLCTProcessor.cc:1063
CSCBaseboard::theStation
const unsigned theStation
Definition: CSCBaseboard.h:43
CSCDBL1TPParameters::clctNplanesHitPattern
unsigned int clctNplanesHitPattern() const
Definition: CSCDBL1TPParameters.h:65
CSCDBL1TPParameters::clctPidThreshPretrig
unsigned int clctPidThreshPretrig() const
Definition: CSCDBL1TPParameters.h:68
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
CSCBaseboard::theCSCName_
std::string theCSCName_
Definition: CSCBaseboard.h:82
pulse
double pulse(double x, double y, double z, double t)
Definition: SiStripPulseShape.cc:49
CSCCathodeLCTProcessor::readComparatorDigis
void readComparatorDigis(std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
Definition: CSCCathodeLCTProcessor.cc:447
CSCCLCTDigi::setEightStrip
void setEightStrip(const bool eightStrip)
set single eight strip bit
Definition: CSCCLCTDigi.cc:179
CSCCathodeLCTProcessor::readoutCLCTs
std::vector< CSCCLCTDigi > readoutCLCTs(int nMaxCLCTs=CSCConstants::MAX_CLCTS_READOUT) const
Definition: CSCCathodeLCTProcessor.cc:1105
mps_check.array
array
Definition: mps_check.py:216
CSCCLCTDigi::setBend
void setBend(const uint16_t bend)
set bend
Definition: CSCCLCTDigi.h:94
CSCCLCTDigi::setPattern
void setPattern(const uint16_t pattern)
set pattern
Definition: CSCCLCTDigi.cc:90
CSCCLCTDigi::setStrip
void setStrip(const uint16_t strip)
set strip
Definition: CSCCLCTDigi.h:100
CSCCathodeLCTProcessor::CLCT_PATTERN
Definition: CSCCathodeLCTProcessor.h:186
CSCCathodeLCTProcessor::getDigis
bool getDigis(const CSCComparatorDigiCollection *compdc)
Definition: CSCCathodeLCTProcessor.cc:398
CSCDBL1TPParameters::clctFifoTbins
unsigned int clctFifoTbins() const
Definition: CSCDBL1TPParameters.h:50
CSCBaseboard::checkConfigParameters
void checkConfigParameters(unsigned int &var, const unsigned int var_max, const unsigned int var_def, const std::string &var_str)
Definition: CSCBaseboard.cc:92
CSCCathodeLCTProcessor::def_nplanes_hit_pattern
static const unsigned int def_nplanes_hit_pattern
Definition: CSCCathodeLCTProcessor.h:226
CSCConstants::ALCT_CLCT_OFFSET
Definition: CSCConstants.h:81
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
CSCCLCTDigi::getKeyStrip
uint16_t getKeyStrip(const uint16_t n=2) const
Definition: CSCCLCTDigi.cc:133
CSCCLCTDigi::setQuartStrip
void setQuartStrip(const bool quartStrip)
set single quart strip bit
Definition: CSCCLCTDigi.cc:173
CSCCathodeLCTProcessor::patternConversionLUTFiles_
std::vector< std::string > patternConversionLUTFiles_
Definition: CSCCathodeLCTProcessor.h:232
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
CSCCathodeLCTProcessor::def_drift_delay
static const unsigned int def_drift_delay
Definition: CSCCathodeLCTProcessor.h:224
CSCCLCTDigi
Definition: CSCCLCTDigi.h:17
CSCConstants::MAX_CLCTS_PER_PROCESSOR
Definition: CSCConstants.h:69
CSCCathodeLCTProcessor::lutslope_
std::array< std::unique_ptr< CSCComparatorCodeLUT >, 5 > lutslope_
Definition: CSCCathodeLCTProcessor.h:103
CSCCathodeLCTProcessor::early_tbins
int early_tbins
Definition: CSCCathodeLCTProcessor.h:217
MuonDigiCollection::const_iterator
std::vector< DigiType >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
CSCCathodeLCTProcessor::setConfigParameters
void setConfigParameters(const CSCDBL1TPParameters *conf)
Definition: CSCCathodeLCTProcessor.cc:152
CSCCathodeLCTProcessor::def_fifo_tbins
static const unsigned int def_fifo_tbins
Definition: CSCCathodeLCTProcessor.h:223
CSCDBL1TPParameters::clctDriftDelay
unsigned int clctDriftDelay() const
Definition: CSCDBL1TPParameters.h:59
CSCCathodeLCTProcessor::slopeLUTFiles_
std::vector< std::string > slopeLUTFiles_
Definition: CSCCathodeLCTProcessor.h:231
CSCCathodeLCTProcessor::thePreTriggerDigis
std::vector< CSCCLCTPreTriggerDigi > thePreTriggerDigis
Definition: CSCCathodeLCTProcessor.h:204
CSCConstants::MAX_NUM_STRIPS
Definition: CSCConstants.h:24
CSCCathodeLCTProcessor::INVALID_HALFSTRIP
Definition: CSCCathodeLCTProcessor.h:141
CSCCathodeLCTProcessor::readout_earliest_2
bool readout_earliest_2
Definition: CSCCathodeLCTProcessor.h:220
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
CSCCathodeLCTProcessor::getBestCLCT
CSCCLCTDigi getBestCLCT(int bx) const
Definition: CSCCathodeLCTProcessor.cc:1257
CSCCathodeLCTProcessor::pulseExtension
void pulseExtension(const std::vector< int > time[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS], const int nStrips, PulseArray pulse)
Definition: CSCCathodeLCTProcessor.cc:762
CSCCathodeLCTProcessor::ispretrig
bool ispretrig[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
Definition: CSCCathodeLCTProcessor.h:178
CSCCathodeLCTProcessor::lutpos_
std::array< std::unique_ptr< CSCComparatorCodeLUT >, 5 > lutpos_
Definition: CSCCathodeLCTProcessor.h:102
CSCCathodeLCTProcessor::bestCLCT
CSCCLCTDigi bestCLCT[CSCConstants::MAX_CLCT_TBINS]
Definition: CSCCathodeLCTProcessor.h:96
CSCCathodeLCTProcessor::findLCTs
virtual std::vector< CSCCLCTDigi > findLCTs(const std::vector< int > halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS])
Definition: CSCCathodeLCTProcessor.cc:539
CSCConstants::NUM_LAYERS
Definition: CSCConstants.h:46
CSCCLCTDigi::setRun3
void setRun3(bool isRun3)
Definition: CSCCLCTDigi.cc:185
CSCCathodeLCTProcessor::first_bx_corrected
int first_bx_corrected[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
Definition: CSCCathodeLCTProcessor.h:175
CSCDBL1TPParameters::clctMinSeparation
unsigned int clctMinSeparation() const
Definition: CSCDBL1TPParameters.h:71
CSCDBL1TPParameters::clctHitPersist
unsigned int clctHitPersist() const
Definition: CSCDBL1TPParameters.h:56
CSCConstants::MAX_NUM_STRIPS_ME1B
Definition: CSCConstants.h:40
CSCCLCTPreTriggerDigi
Definition: CSCCLCTPreTriggerDigi.h:15
CSCCathodeLCTProcessor::thePreTriggerBXs
std::vector< int > thePreTriggerBXs
Definition: CSCCathodeLCTProcessor.h:203
CSCComparatorDigi
Definition: CSCComparatorDigi.h:16
CSCCathodeLCTProcessor::def_fifo_pretrig
static const unsigned int def_fifo_pretrig
Definition: CSCCathodeLCTProcessor.h:223
CSCCathodeLCTProcessor::def_hit_persist
static const unsigned int def_hit_persist
Definition: CSCCathodeLCTProcessor.h:224
CSCBaseboard::theSubsector
const unsigned theSubsector
Definition: CSCBaseboard.h:45
CSCLayer::geometry
const CSCLayerGeometry * geometry() const
Definition: CSCLayer.h:44
CSCCathodeLCTProcessor::preTrigger
virtual bool preTrigger(const PulseArray pulse, const int start_bx, int &first_bx)
Definition: CSCCathodeLCTProcessor.cc:808
CSCBaseboard::gangedME1a_
bool gangedME1a_
Definition: CSCBaseboard.h:89
CSCCathodeLCTProcessor::nhits
unsigned int nhits[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
Definition: CSCCathodeLCTProcessor.h:173
CSCCathodeLCTProcessor::def_min_separation
static const unsigned int def_min_separation
Definition: CSCCathodeLCTProcessor.h:227
CSCCathodeLCTProcessor::numStrips
int numStrips
Definition: CSCCathodeLCTProcessor.h:197
CSCCathodeLCTProcessor::convertSlopeToRun2Pattern
unsigned convertSlopeToRun2Pattern(const unsigned slope) const
Definition: CSCCathodeLCTProcessor.cc:1445
CSCDetId::chamberName
static std::string chamberName(int endcap, int station, int ring, int chamber)
Definition: CSCDetId.cc:62
CSCCathodeLCTProcessor.h
CSCCathodeLCTProcessor::CLCT_CFEB
Definition: CSCCathodeLCTProcessor.h:192
CSCCathodeLCTProcessor::run
std::vector< CSCCLCTDigi > run(const CSCComparatorDigiCollection *compdc)
Definition: CSCCathodeLCTProcessor.cc:211
CSCCathodeLCTProcessor::CLCT_STRIP
Definition: CSCCathodeLCTProcessor.h:188
CSCCLCTDigi::setRun3Pattern
void setRun3Pattern(const uint16_t pattern)
set pattern
Definition: CSCCLCTDigi.cc:100
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
CSCCLCTDigi::ComparatorContainer
std::vector< std::vector< uint16_t > > ComparatorContainer
Definition: CSCCLCTDigi.h:19
edm::ParameterSet
Definition: ParameterSet.h:47
CSCCathodeLCTProcessor::preTriggerDigis
std::vector< CSCCLCTPreTriggerDigi > preTriggerDigis() const
Definition: CSCCathodeLCTProcessor.h:90
CSCDBL1TPParameters::clctNplanesHitPretrig
unsigned int clctNplanesHitPretrig() const
Definition: CSCDBL1TPParameters.h:62
CSCCathodeLCTProcessor::lutpatconv_
std::array< std::unique_ptr< CSCComparatorCodeLUT >, 5 > lutpatconv_
Definition: CSCCathodeLCTProcessor.h:104
CSCCathodeLCTProcessor::CLCT_BEND
Definition: CSCCathodeLCTProcessor.h:187
CSCBaseboard
Definition: CSCBaseboard.h:15
CSCCathodeLCTProcessor::CLCT_QUALITY
Definition: CSCCathodeLCTProcessor.h:191
CSCCathodeLCTProcessor::secondCLCT
CSCCLCTDigi secondCLCT[CSCConstants::MAX_CLCT_TBINS]
Definition: CSCCathodeLCTProcessor.h:99
CSCDetId
Definition: CSCDetId.h:26
CSCCathodeLCTProcessor::digiV
std::vector< CSCComparatorDigi > digiV[CSCConstants::NUM_LAYERS]
Definition: CSCCathodeLCTProcessor.h:202
CSCCathodeLCTProcessor::cleanComparatorContainer
void cleanComparatorContainer(CSCCLCTDigi &lct) const
Definition: CSCCathodeLCTProcessor.cc:1030
CSCCLCTDigi::getQuartStrip
bool getQuartStrip() const
get single quart strip bit
Definition: CSCCLCTDigi.cc:161
CSCConstants::MAX_NUM_STRIPS_7CFEBS
Definition: CSCConstants.h:25
CSCCathodeLCTProcessor::def_pid_thresh_pretrig
static const unsigned int def_pid_thresh_pretrig
Definition: CSCCathodeLCTProcessor.h:227
CSCCathodeLCTProcessor::positionLUTFiles_
std::vector< std::string > positionLUTFiles_
Definition: CSCCathodeLCTProcessor.h:230
CSCCLCTDigi::setCompCode
void setCompCode(const int16_t code)
Definition: CSCCLCTDigi.h:171
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
CSCCathodeLCTProcessor::tmb_l1a_window_size
unsigned int tmb_l1a_window_size
Definition: CSCCathodeLCTProcessor.h:211
CSCCathodeLCTProcessor::readoutCLCTsME1a
std::vector< CSCCLCTDigi > readoutCLCTsME1a(int nMaxCLCTs=CSCConstants::MAX_CLCTS_READOUT) const
Definition: CSCCathodeLCTProcessor.cc:1194
CSCCLCTDigi::setSlope
void setSlope(const uint16_t slope)
set the slope
Definition: CSCCLCTDigi.cc:112
CSCComparatorDigiCollection
CSCLayerGeometry::stagger
int stagger() const
Definition: CSCLayerGeometry.h:124
CSCCathodeLCTProcessor::def_nplanes_hit_pretrig
static const unsigned int def_nplanes_hit_pretrig
Definition: CSCCathodeLCTProcessor.h:225
CSCCathodeLCTProcessor::hit_persist
unsigned int hit_persist
Definition: CSCCathodeLCTProcessor.h:208
CSCCLCTDigi::setHits
void setHits(const ComparatorContainer &hits)
Definition: CSCCLCTDigi.h:176
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
CSCBaseboard::theChamber
unsigned theChamber
Definition: CSCBaseboard.h:49
CSCCathodeLCTProcessor::calculateComparatorCode
int calculateComparatorCode(const std::array< std::array< int, 3 >, 6 > &halfStripPattern) const
Definition: CSCCathodeLCTProcessor.cc:1271
CSCCathodeLCTProcessor::pid_thresh_pretrig
unsigned int pid_thresh_pretrig
Definition: CSCCathodeLCTProcessor.h:210
CSCCathodeLCTProcessor::readoutCLCTsME1b
std::vector< CSCCLCTDigi > readoutCLCTsME1b(int nMaxCLCTs=CSCConstants::MAX_CLCTS_READOUT) const
Definition: CSCCathodeLCTProcessor.cc:1207
CSCCathodeLCTProcessor::PulseArray
unsigned int PulseArray[CSCConstants::NUM_LAYERS][CSCConstants::NUM_HALF_STRIPS_7CFEBS]
Definition: CSCCathodeLCTProcessor.h:116
CSCCathodeLCTProcessor::clear
void clear()
Definition: CSCCathodeLCTProcessor.cc:202
CSCCathodeLCTProcessor::setDefaultConfigParameters
void setDefaultConfigParameters()
Definition: CSCCathodeLCTProcessor.cc:138
CSCCLCTDigi::getBX
uint16_t getBX() const
return BX
Definition: CSCCLCTDigi.h:121
me0TriggerPseudoDigis_cff.nStrips
nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
Definition: me0TriggerPseudoDigis_cff.py:26
CSCCathodeLCTProcessor::preTriggerDigisME1b
std::vector< CSCCLCTPreTriggerDigi > preTriggerDigisME1b() const
Definition: CSCCathodeLCTProcessor.cc:1229
CSCCathodeLCTProcessor::def_tmb_l1a_window_size
static const unsigned int def_tmb_l1a_window_size
Definition: CSCCathodeLCTProcessor.h:228
CSCCathodeLCTProcessor::fifo_pretrig
unsigned int fifo_pretrig
Definition: CSCCathodeLCTProcessor.h:207
CSCCathodeLCTProcessor::best_pid
unsigned int best_pid[CSCConstants::NUM_HALF_STRIPS_7CFEBS]
Definition: CSCCathodeLCTProcessor.h:170
CSCCathodeLCTProcessor::start_bx_shift
int start_bx_shift
Definition: CSCCathodeLCTProcessor.h:214
CSCCathodeLCTProcessor::preTriggerDigisME1a
std::vector< CSCCLCTPreTriggerDigi > preTriggerDigisME1a() const
Definition: CSCCathodeLCTProcessor.cc:1218
qcdUeDQM_cfi.quality
quality
Definition: qcdUeDQM_cfi.py:31
CSCCathodeLCTProcessor::CSCCathodeLCTProcessor
CSCCathodeLCTProcessor()
Definition: CSCCathodeLCTProcessor.cc:107
trklet::bend
double bend(double r, double rinv, double stripPitch)
Definition: Util.h:160
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
CSCPatternBank::clct_pattern_run3_
static const LCTPatterns clct_pattern_run3_
Definition: CSCPatternBank.h:54
CSCConstants::MAX_NUM_STRIPS_ME1A_GANGED
Definition: CSCConstants.h:41
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
CSCCLCTDigi::clear
void clear()
clear this CLCT
Definition: CSCCLCTDigi.cc:68
CSCDetId::chamberName
std::string chamberName() const
Definition: CSCDetId.cc:67
CSCCathodeLCTProcessor::patternFinding
bool patternFinding(const PulseArray pulse, const int nStrips, const unsigned int bx_time, std::map< int, std::map< int, CSCCLCTDigi::ComparatorContainer > > &hits_in_patterns)
Definition: CSCCathodeLCTProcessor.cc:870
CSCCathodeLCTProcessor::nplanes_hit_pretrig
unsigned int nplanes_hit_pretrig
Definition: CSCCathodeLCTProcessor.h:209
CSCConstants::KEY_CLCT_LAYER
Definition: CSCConstants.h:46
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
CSCDBL1TPParameters::clctFifoPretrig
unsigned int clctFifoPretrig() const
Definition: CSCDBL1TPParameters.h:53
CSCConstants::MAX_CLCT_TBINS
Definition: CSCConstants.h:63
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
CSCCLCTDigi::Version::Legacy
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
CSCCLCTDigi::getCFEB
uint16_t getCFEB() const
return Key CFEB ID
Definition: CSCCLCTDigi.h:115
CSCBaseboard::theTrigChamber
const unsigned theTrigChamber
Definition: CSCBaseboard.h:46
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CSCCLCTDigi::setBX
void setBX(const uint16_t bx)
set bx
Definition: CSCCLCTDigi.h:127
CSCConstants::MAX_NUM_STRIPS_ME1A_UNGANGED
Definition: CSCConstants.h:42
CSCConstants::NUM_HALF_STRIPS_7CFEBS
Definition: CSCConstants.h:28
CSCCathodeLCTProcessor::min_separation
unsigned int min_separation
Definition: CSCCathodeLCTProcessor.h:210
genParticles_cff.map
map
Definition: genParticles_cff.py:11
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
CSCCathodeLCTProcessor::runCCLUT
void runCCLUT(CSCCLCTDigi &digi) const
Definition: CSCCathodeLCTProcessor.cc:1349
CSCPatternBank::clct_pattern_legacy_
static const LCTPatterns clct_pattern_legacy_
Definition: CSCPatternBank.h:38
CSCConstants::CLCT_PATTERN_WIDTH
Definition: CSCConstants.h:53
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CSCCLCTDigi::getPattern
uint16_t getPattern() const
return pattern
Definition: CSCCLCTDigi.cc:88
slope
static const double slope[3]
Definition: CastorTimeSlew.cc:6
CSCLayerGeometry::numberOfStrips
int numberOfStrips() const
Definition: CSCLayerGeometry.h:66
ntuplemaker.time
time
Definition: ntuplemaker.py:310
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
CSCCathodeLCTProcessor::getCLCTs
std::vector< CSCCLCTDigi > getCLCTs(unsigned nMaxCLCTs=CSCConstants::MAX_CLCTS_PER_PROCESSOR) const
Definition: CSCCathodeLCTProcessor.cc:1241
CSCConstants::NUM_HALF_STRIPS_PER_CFEB
Definition: CSCConstants.h:32
CSCCathodeLCTProcessor::checkConfigParameters
void checkConfigParameters()
Definition: CSCCathodeLCTProcessor.cc:172
CSCCathodeLCTProcessor::CLCT_STRIP_TYPE
Definition: CSCCathodeLCTProcessor.h:190
CSCCathodeLCTProcessor::drift_delay
unsigned int drift_delay
Definition: CSCCathodeLCTProcessor.h:208
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
CSCCathodeLCTProcessor::nplanes_hit_pattern
unsigned int nplanes_hit_pattern
Definition: CSCCathodeLCTProcessor.h:209
CSCBaseboard::isME11_
bool isME11_
Definition: CSCBaseboard.h:52
CSCCLCTDigi::getHits
const ComparatorContainer & getHits() const
Definition: CSCCLCTDigi.h:174
CSCCathodeLCTProcessor::CLCT_BX
Definition: CSCCathodeLCTProcessor.h:189
CSCPatternBank::clct_pattern_offset_
static const int clct_pattern_offset_[CSCConstants::CLCT_PATTERN_WIDTH]
Definition: CSCPatternBank.h:57
CSCConstants::CLCT_EMUL_TIME_OFFSET
Definition: CSCConstants.h:18
CSCBaseboard::runCCLUT_
bool runCCLUT_
Definition: CSCBaseboard.h:103
CSCCathodeLCTProcessor::clct_pattern_
CSCPatternBank::LCTPatterns clct_pattern_
Definition: CSCCathodeLCTProcessor.h:181
CSCCathodeLCTProcessor::CLCT_NUM_QUANTITIES
Definition: CSCCathodeLCTProcessor.h:193
CSCBaseboard::infoV
int infoV
Definition: CSCBaseboard.h:64
CSCBaseboard::theRing
unsigned theRing
Definition: CSCBaseboard.h:48