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