CMS 3D CMS Logo

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