Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store anode wire hits in ALCT (ACLUT-3) #30301

Merged
merged 2 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion L1Trigger/CSCTriggerPrimitives/interface/CSCAnodeLCTProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,17 @@ 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<int, std::map<int, CSCALCTDigi::WireContainer> >& hits_in_patterns);

// 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
Expand Down
52 changes: 48 additions & 4 deletions L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ void CSCAnodeLCTProcessor::run(const std::vector<int> 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<int, std::map<int, CSCCLCTDigi::ComparatorContainer>> hits_in_patterns;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this is a map of a map of a vector of vectors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidlange6 So the type needs to be corrected (#30940), but it shouldn't have any effect. ComparatorContainer and WireContainer are both 2D vectors.

Yes, it maps wiregroups and pattern numbers onto 2D vectors with hits.

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.
Expand All @@ -307,7 +312,7 @@ void CSCAnodeLCTProcessor::run(const std::vector<int> 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);
Expand All @@ -320,7 +325,11 @@ void CSCAnodeLCTProcessor::run(const std::vector<int> 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);

// 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;
ALCTIndex_[bx]++;
Expand All @@ -331,7 +340,12 @@ void CSCAnodeLCTProcessor::run(const std::vector<int> 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);

// 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;
ALCTIndex_[bx]++;
Expand Down Expand Up @@ -589,7 +603,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<int, std::map<int, CSCALCTDigi::WireContainer>>& hits_in_patterns) {
bool trigger = false;
bool hit_layer[CSCConstants::NUM_LAYERS];
unsigned int temp_quality;
Expand All @@ -609,6 +624,14 @@ 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.clear();
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<int> mset_for_median;
mset_for_median.clear();
Expand All @@ -623,6 +646,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]) {
Expand Down Expand Up @@ -683,8 +709,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.
Expand Down Expand Up @@ -1357,3 +1385,19 @@ 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());
}
}

void CSCAnodeLCTProcessor::setWireContainer(CSCALCTDigi& alct, CSCALCTDigi::WireContainer& wireHits) const {
// clean the wire digi container
cleanWireContainer(wireHits);

// set the hit container
alct.setHits(wireHits);
}