From 97ee80b78bde9d78e34a51c06377575c4fa7e32c Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Thu, 18 Jun 2020 22:11:07 -0500 Subject: [PATCH 1/2] Store anode wire hits in ALCT --- .../interface/CSCAnodeLCTProcessor.h | 8 ++- .../src/CSCAnodeLCTProcessor.cc | 55 +++++++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h index 165c8c3e52ee7..8a502189cf9d9 100644 --- a/L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h @@ -192,7 +192,13 @@ class CSCAnodeLCTProcessor : public CSCBaseboard { /* See if there is a pattern that satisfies nplanes_hit_pattern number of layers hit for either the accelerator or collision patterns. Use the pattern with the best quality. */ - bool patternDetection(const int key_wire); + bool patternDetection(const int key_wire, + std::map >& hits_in_patterns); + + // enum used in the wire hit assignment + enum ALCT_WireInfo { INVALID_WIRE = 65535 }; + + void cleanWireContainer(CSCALCTDigi::WireContainer& wireHits) const; /* This function looks for LCTs on the previous and next wires. If one exists and it has a better quality and a bx_time up to 4 clocks earlier diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc index 47f775ab568ed..ae9e16bcfe2bb 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc @@ -295,6 +295,11 @@ void CSCAnodeLCTProcessor::run(const std::vector wire[CSCConstants::NUM_LAY // Take the best MAX_CLCTS_PER_PROCESSOR candidates per bx. int ALCTIndex_[CSCConstants::MAX_ALCT_TBINS] = {}; + // define a new pattern map + // for each key half strip, and for each pattern, store the 2D collection of fired comparator digis + std::map> hits_in_patterns; + hits_in_patterns.clear(); + // Only do the rest of the processing if chamber is not empty. // Stop drift_delay bx's short of fifo_tbins since at later bx's we will // not have a full set of hits to start pattern search anyway. @@ -307,7 +312,7 @@ void CSCAnodeLCTProcessor::run(const std::vector wire[CSCConstants::NUM_LAY if (preTrigger(i_wire, start_bx)) { if (infoV > 2) showPatterns(i_wire); - if (patternDetection(i_wire)) { + if (patternDetection(i_wire, hits_in_patterns)) { trigger = true; int ghost_cleared[2] = {0, 0}; ghostCancellationLogicOneWire(i_wire, ghost_cleared); @@ -320,7 +325,17 @@ void CSCAnodeLCTProcessor::run(const std::vector wire[CSCConstants::NUM_LAY //acceleration mode if (quality[i_wire][0] > 0 and bx < CSCConstants::MAX_ALCT_TBINS) { int valid = (ghost_cleared[0] == 0) ? 1 : 0; //cancelled, valid=0, otherwise it is 1 - const auto& newALCT(CSCALCTDigi(valid, quality[i_wire][0], 1, 0, i_wire, bx)); + CSCALCTDigi newALCT(valid, quality[i_wire][0], 1, 0, i_wire, bx); + + // get the comparator hits for this pattern + auto wireHits = hits_in_patterns[i_wire][0]; + + // purge the wire digi collection + cleanWireContainer(wireHits); + + // set the hit collection + newALCT.setHits(wireHits); + lct_list.push_back(newALCT); ALCTContainer_[bx][ALCTIndex_[bx]] = newALCT; ALCTIndex_[bx]++; @@ -331,7 +346,18 @@ void CSCAnodeLCTProcessor::run(const std::vector wire[CSCConstants::NUM_LAY //collision mode if (quality[i_wire][1] > 0 and bx < CSCConstants::MAX_ALCT_TBINS) { int valid = (ghost_cleared[1] == 0) ? 1 : 0; //cancelled, valid=0, otherwise it is 1 - const auto& newALCT(CSCALCTDigi(valid, quality[i_wire][1], 0, quality[i_wire][2], i_wire, bx)); + + CSCALCTDigi newALCT(valid, quality[i_wire][1], 0, quality[i_wire][2], i_wire, bx); + + // get the comparator hits for this pattern + auto wireHits = hits_in_patterns[i_wire][1]; + + // purge the wire digi collection + cleanWireContainer(wireHits); + + // set the hit collection + newALCT.setHits(wireHits); + lct_list.push_back(newALCT); ALCTContainer_[bx][ALCTIndex_[bx]] = newALCT; ALCTIndex_[bx]++; @@ -589,7 +615,8 @@ bool CSCAnodeLCTProcessor::preTrigger(const int key_wire, const int start_bx) { return false; } -bool CSCAnodeLCTProcessor::patternDetection(const int key_wire) { +bool CSCAnodeLCTProcessor::patternDetection( + const int key_wire, std::map>& hits_in_patterns) { bool trigger = false; bool hit_layer[CSCConstants::NUM_LAYERS]; unsigned int temp_quality; @@ -609,6 +636,13 @@ bool CSCAnodeLCTProcessor::patternDetection(const int key_wire) { for (int i_layer = 0; i_layer < CSCConstants::NUM_LAYERS; i_layer++) hit_layer[i_layer] = false; + // clear a single pattern! + CSCALCTDigi::WireContainer hits_single_pattern; + hits_single_pattern.resize(CSCConstants::NUM_LAYERS); + for (auto& p : hits_single_pattern) { + p.resize(CSCConstants::ALCT_PATTERN_WIDTH, INVALID_WIRE); + } + double num_pattern_hits = 0., times_sum = 0.; std::multiset mset_for_median; mset_for_median.clear(); @@ -623,6 +657,9 @@ bool CSCAnodeLCTProcessor::patternDetection(const int key_wire) { // Wait a drift_delay time later and look for layers hit in // the pattern. if (((pulse[i_layer][this_wire] >> (first_bx[key_wire] + drift_delay)) & 1) == 1) { + // store hits in the temporary pattern vector + hits_single_pattern[i_layer][i_wire] = this_wire; + // If layer has never had a hit before, then increment number // of layer hits. if (!hit_layer[i_layer]) { @@ -683,8 +720,10 @@ bool CSCAnodeLCTProcessor::patternDetection(const int key_wire) { #endif } + // save the pattern information when a trigger was formed! if (temp_quality >= pattern_thresh[i_pattern]) { trigger = true; + hits_in_patterns[key_wire][i_pattern] = hits_single_pattern; // Quality definition changed on 22 June 2007: it no longer depends // on pattern_thresh. @@ -1357,3 +1396,11 @@ int CSCAnodeLCTProcessor::getTempALCTQuality(int temp_quality) const { return Q; } + +void CSCAnodeLCTProcessor::cleanWireContainer(CSCALCTDigi::WireContainer& wireHits) const { + for (auto& p : wireHits) { + p.erase( + std::remove_if(p.begin(), p.end(), [](unsigned i) -> bool { return i == CSCAnodeLCTProcessor::INVALID_WIRE; }), + p.end()); + } +} From 20851ca0b252e28afa17d3bbe729b16d64d754fb Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Thu, 18 Jun 2020 22:38:52 -0500 Subject: [PATCH 2/2] Improve documentation --- .../interface/CSCAnodeLCTProcessor.h | 4 +++ .../src/CSCAnodeLCTProcessor.cc | 29 +++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h index 8a502189cf9d9..f82397aa59d2e 100644 --- a/L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h @@ -198,8 +198,12 @@ class CSCAnodeLCTProcessor : public CSCBaseboard { // enum used in the wire hit assignment enum ALCT_WireInfo { INVALID_WIRE = 65535 }; + // remove the invalid wires from the container void cleanWireContainer(CSCALCTDigi::WireContainer& wireHits) const; + // set the wire hit container + void setWireContainer(CSCALCTDigi&, CSCALCTDigi::WireContainer& wireHits) const; + /* This function looks for LCTs on the previous and next wires. If one exists and it has a better quality and a bx_time up to 4 clocks earlier than the present, then the present LCT is cancelled. The present LCT diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc index ae9e16bcfe2bb..faab45720279f 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc @@ -327,14 +327,8 @@ void CSCAnodeLCTProcessor::run(const std::vector wire[CSCConstants::NUM_LAY int valid = (ghost_cleared[0] == 0) ? 1 : 0; //cancelled, valid=0, otherwise it is 1 CSCALCTDigi newALCT(valid, quality[i_wire][0], 1, 0, i_wire, bx); - // get the comparator hits for this pattern - auto wireHits = hits_in_patterns[i_wire][0]; - - // purge the wire digi collection - cleanWireContainer(wireHits); - - // set the hit collection - newALCT.setHits(wireHits); + // set the wire digis for this pattern + setWireContainer(newALCT, hits_in_patterns[i_wire][0]); lct_list.push_back(newALCT); ALCTContainer_[bx][ALCTIndex_[bx]] = newALCT; @@ -349,14 +343,8 @@ void CSCAnodeLCTProcessor::run(const std::vector wire[CSCConstants::NUM_LAY CSCALCTDigi newALCT(valid, quality[i_wire][1], 0, quality[i_wire][2], i_wire, bx); - // get the comparator hits for this pattern - auto wireHits = hits_in_patterns[i_wire][1]; - - // purge the wire digi collection - cleanWireContainer(wireHits); - - // set the hit collection - newALCT.setHits(wireHits); + // set the wire digis for this pattern + setWireContainer(newALCT, hits_in_patterns[i_wire][1]); lct_list.push_back(newALCT); ALCTContainer_[bx][ALCTIndex_[bx]] = newALCT; @@ -638,6 +626,7 @@ bool CSCAnodeLCTProcessor::patternDetection( // clear a single pattern! CSCALCTDigi::WireContainer hits_single_pattern; + hits_single_pattern.clear(); hits_single_pattern.resize(CSCConstants::NUM_LAYERS); for (auto& p : hits_single_pattern) { p.resize(CSCConstants::ALCT_PATTERN_WIDTH, INVALID_WIRE); @@ -1404,3 +1393,11 @@ void CSCAnodeLCTProcessor::cleanWireContainer(CSCALCTDigi::WireContainer& wireHi p.end()); } } + +void CSCAnodeLCTProcessor::setWireContainer(CSCALCTDigi& alct, CSCALCTDigi::WireContainer& wireHits) const { + // clean the wire digi container + cleanWireContainer(wireHits); + + // set the hit container + alct.setHits(wireHits); +}