Skip to content

Commit

Permalink
code format change
Browse files Browse the repository at this point in the history
  • Loading branch information
tahuang1991 committed Oct 5, 2022
1 parent 74c319c commit 3fac2a3
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class CSCCathodeLCTProcessor : public CSCBaseboard {
CSCShowerDigi cathode_showers_[CSCConstants::MAX_CLCT_TBINS];
//CSCShowerDigi shower_;

/* flag of shower around best CLCT in each BX */
/* flag of shower around best CLCT in each BX */
bool localShowerFlag[CSCConstants::MAX_CLCT_TBINS];

/** Access routines to comparator digis. */
Expand Down Expand Up @@ -169,8 +169,8 @@ class CSCCathodeLCTProcessor : public CSCBaseboard {
const std::vector<int> strip[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_HALF_STRIPS_RUN2_TRIGGER]) const;

/* check whether there is a shower around best CLCT */
void checkLocalShower(int zone,
const std::vector<int> strip[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_HALF_STRIPS_RUN2_TRIGGER]);
void checkLocalShower(
int zone, const std::vector<int> strip[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_HALF_STRIPS_RUN2_TRIGGER]);

void encodeHighMultiplicityBits();

Expand Down
2 changes: 1 addition & 1 deletion L1Trigger/CSCTriggerPrimitives/interface/CSCMotherboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class CSCMotherboard : public CSCBaseboard {
std::vector<int> preferred_bx_match_;

/* sort CLCT by bx if true, otherwise sort CLCT by quality+bending */
bool sort_clct_bx_;
bool sort_clct_bx_;

/** Default values of configuration parameters. */
static const unsigned int def_mpc_block_me1a;
Expand Down
14 changes: 8 additions & 6 deletions L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1278,14 +1278,16 @@ std::vector<CSCALCTDigi> CSCAnodeLCTProcessor::getALCTs() const {
return tmpV;
}

CSCALCTDigi CSCAnodeLCTProcessor::getBestALCT(int bx) const {
if (bx >= CSCConstants::MAX_CLCT_TBINS or bx < 0) return CSCALCTDigi();
return bestALCT[bx];
CSCALCTDigi CSCAnodeLCTProcessor::getBestALCT(int bx) const {
if (bx >= CSCConstants::MAX_CLCT_TBINS or bx < 0)
return CSCALCTDigi();
return bestALCT[bx];
}

CSCALCTDigi CSCAnodeLCTProcessor::getSecondALCT(int bx) const {
if (bx >= CSCConstants::MAX_CLCT_TBINS or bx < 0) return CSCALCTDigi();
return secondALCT[bx];
CSCALCTDigi CSCAnodeLCTProcessor::getSecondALCT(int bx) const {
if (bx >= CSCConstants::MAX_CLCT_TBINS or bx < 0)
return CSCALCTDigi();
return secondALCT[bx];
}

/** return vector of CSCShower digi **/
Expand Down
52 changes: 31 additions & 21 deletions L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CSCCathodeLCTProcessor::CSCCathodeLCTProcessor(unsigned endcap,

localShowerZone = clctParams_.getParameter<int>("clctLocalShowerZone");

localShowerThresh = clctParams_.getParameter<int>("clctLocalShowerThresh");
localShowerThresh = clctParams_.getParameter<int>("clctLocalShowerThresh");

// Motherboard parameters: common for all configurations.
tmb_l1a_window_size = // Common to CLCT and TMB
Expand Down Expand Up @@ -190,7 +190,7 @@ void CSCCathodeLCTProcessor::clear() {
bestCLCT[bx].clear();
secondCLCT[bx].clear();
cathode_showers_[bx].clear();
localShowerFlag[bx] = false;//init with no shower around CLCT
localShowerFlag[bx] = false; //init with no shower around CLCT
}
}

Expand Down Expand Up @@ -394,33 +394,40 @@ void CSCCathodeLCTProcessor::run(
// ALCTs and then get sent to the MotherBoard. -JM
}

void CSCCathodeLCTProcessor::checkLocalShower(int zone,
void CSCCathodeLCTProcessor::checkLocalShower(
int zone,
const std::vector<int> halfstrip[CSCConstants::NUM_LAYERS][CSCConstants::MAX_NUM_HALF_STRIPS_RUN2_TRIGGER]) {
// Fire half-strip one-shots for hit_persist bx's (4 bx's by default).
//check local shower after pulse extension
//check local shower after pulse extension
pulseExtension(halfstrip);

for (int bx = 0; bx < CSCConstants::MAX_CLCT_TBINS; bx++) {
if (not bestCLCT[bx].isValid()) continue;
if (not bestCLCT[bx].isValid())
continue;

//only check the region around best CLCT
int keyHS = bestCLCT[bx].getKeyStrip();
int minHS = (keyHS - zone) >= stagger[CSCConstants::KEY_CLCT_LAYER - 1] ? keyHS-zone : stagger[CSCConstants::KEY_CLCT_LAYER - 1];
int maxHS = (keyHS + zone) >= numHalfStrips_ ? numHalfStrips_ : keyHS+zone;
int minHS = (keyHS - zone) >= stagger[CSCConstants::KEY_CLCT_LAYER - 1] ? keyHS - zone
: stagger[CSCConstants::KEY_CLCT_LAYER - 1];
int maxHS = (keyHS + zone) >= numHalfStrips_ ? numHalfStrips_ : keyHS + zone;
int totalHits = 0;
for (int hstrip = minHS; hstrip < maxHS; hstrip++){
for (int hstrip = minHS; hstrip < maxHS; hstrip++) {
for (int this_layer = 0; this_layer < CSCConstants::NUM_LAYERS; this_layer++)
if (pulse_.isOneShotHighAtBX(this_layer, hstrip, bx+drift_delay)) totalHits++;
}
if (pulse_.isOneShotHighAtBX(this_layer, hstrip, bx + drift_delay))
totalHits++;
}

if (totalHits >= localShowerThresh) localShowerFlag[bx] = true;
else localShowerFlag[bx] = false;
if (infoV > 1) std::cout <<" bx "<< bx <<" bestCLCT key HS "<< keyHS <<" localshower zone: "<< minHS <<", "<< maxHS
<< " totalHits "<< totalHits << (localShowerFlag[bx] ? " Validlocalshower ": " NolocalShower ") << std::endl;
if (totalHits >= localShowerThresh)
localShowerFlag[bx] = true;
else
localShowerFlag[bx] = false;
if (infoV > 1)
LogDebug("CSCCathodeLCTProcessor") << " bx " << bx << " bestCLCT key HS " << keyHS
<< " localshower zone: " << minHS << ", " << maxHS << " totalHits "
<< totalHits
<< (localShowerFlag[bx] ? " Validlocalshower " : " NolocalShower ");
}

}

}

bool CSCCathodeLCTProcessor::getDigis(const CSCComparatorDigiCollection* compdc) {
bool hasDigis = false;
Expand Down Expand Up @@ -1231,21 +1238,24 @@ std::vector<CSCCLCTDigi> CSCCathodeLCTProcessor::getCLCTs() const {
// to make a proper comparison with ALCTs we need
// CLCT and ALCT to have the central BX in the same bin
CSCCLCTDigi CSCCathodeLCTProcessor::getBestCLCT(int bx) const {
if (bx >= CSCConstants::MAX_CLCT_TBINS or bx < 0) return CSCCLCTDigi();
if (bx >= CSCConstants::MAX_CLCT_TBINS or bx < 0)
return CSCCLCTDigi();
CSCCLCTDigi lct = bestCLCT[bx];
lct.setBX(lct.getBX() + CSCConstants::ALCT_CLCT_OFFSET);
return lct;
}

CSCCLCTDigi CSCCathodeLCTProcessor::getSecondCLCT(int bx) const {
if (bx >= CSCConstants::MAX_CLCT_TBINS or bx < 0) return CSCCLCTDigi();
if (bx >= CSCConstants::MAX_CLCT_TBINS or bx < 0)
return CSCCLCTDigi();
CSCCLCTDigi lct = secondCLCT[bx];
lct.setBX(lct.getBX() + CSCConstants::ALCT_CLCT_OFFSET);
return lct;
}

bool CSCCathodeLCTProcessor::getLocalShowerFlag(int bx) const{
if (bx >= CSCConstants::MAX_CLCT_TBINS or bx < 0) return false;
bool CSCCathodeLCTProcessor::getLocalShowerFlag(int bx) const {
if (bx >= CSCConstants::MAX_CLCT_TBINS or bx < 0)
return false;
return localShowerFlag[bx];
}

Expand Down
17 changes: 8 additions & 9 deletions L1Trigger/CSCTriggerPrimitives/src/CSCGEMMotherboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,15 @@ void CSCGEMMotherboard::matchALCTCLCTGEM() {
sortCLCTByQualBend(bx_alct, clctBx_qualbend_match);

bool hasLocalShower = false;
for (unsigned ibx = 1; ibx <= match_trig_window_size/2; ibx++)
hasLocalShower = (hasLocalShower or clctProc->getLocalShowerFlag(bx_alct-CSCConstants::ALCT_CLCT_OFFSET-ibx));
for (unsigned ibx = 1; ibx <= match_trig_window_size / 2; ibx++)
hasLocalShower = (hasLocalShower or clctProc->getLocalShowerFlag(bx_alct - CSCConstants::ALCT_CLCT_OFFSET - ibx));
// BestCLCT and secondCLCT
for (unsigned mbx = 0; mbx < match_trig_window_size; mbx++) {
//bx_clct_run2 would be overflow when bx_alct is small but it is okay
unsigned bx_clct_run2 = bx_alct + preferred_bx_match_[mbx] - CSCConstants::ALCT_CLCT_OFFSET;
unsigned bx_clct_qualbend = clctBx_qualbend_match[mbx];
bx_clct = (sort_clct_bx_ or not(hasLocalShower)) ? bx_clct_run2 : bx_clct_qualbend;
if (infoV > 1 and bx_clct_run2 != bx_clct_qualbend)
std::cout <<"GEMCSCOTMB CLCT bx sortting: run2 "<< bx_clct_run2 <<" qualbend "<< bx_clct_qualbend <<" selected "<< bx_clct << std::endl;


if (bx_clct >= CSCConstants::MAX_CLCT_TBINS)
continue;
matchingBX = mbx;
Expand All @@ -189,10 +187,11 @@ void CSCGEMMotherboard::matchALCTCLCTGEM() {
if (!build_lct_from_alct_gem_ and !bestCLCT.isValid())
continue;

if (infoV > 1) LogTrace("CSCGEMMotherboard") << "GEMCSCOTMB: Successful ALCT-CLCT match: bx_alct = " << bx_alct
<< "; bx_clct = " <<matching_clctbx << "; mbx = " << matchingBX
<< " bestALCT "<< bestALCT << " secondALCT "<< secondALCT
<< " bestCLCT "<< bestCLCT << " secondCLCT "<< secondCLCT;
if (infoV > 1)
LogTrace("CSCGEMMotherboard") << "GEMCSCOTMB: Successful ALCT-CLCT match: bx_alct = " << bx_alct
<< "; bx_clct = " << matching_clctbx << "; mbx = " << matchingBX << " bestALCT "
<< bestALCT << " secondALCT " << secondALCT << " bestCLCT " << bestCLCT
<< " secondCLCT " << secondCLCT;
// ALCT + CLCT + GEM

for (unsigned gmbx = 0; gmbx < alct_gem_bx_window_size_; gmbx++) {
Expand Down
31 changes: 16 additions & 15 deletions L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,15 @@ void CSCMotherboard::matchALCTCLCT() {
// need to access "full BX" words, which are not readily
// available.
bool is_matched = false;
// we can use single value to best CLCT but here use vector to keep the
// we can use single value to best CLCT but here use vector to keep the
// the future option to do multiple ALCT-CLCT matches wiht CLCT from different bx
std::vector<unsigned> clctBx_qualbend_match;
sortCLCTByQualBend(bx_alct, clctBx_qualbend_match);

bool hasLocalShower = false;
for (unsigned ibx = 1; ibx <= match_trig_window_size/2; ibx++)
hasLocalShower = (hasLocalShower or clctProc->getLocalShowerFlag(bx_alct-CSCConstants::ALCT_CLCT_OFFSET-ibx));
for (unsigned ibx = 1; ibx <= match_trig_window_size / 2; ibx++)
hasLocalShower =
(hasLocalShower or clctProc->getLocalShowerFlag(bx_alct - CSCConstants::ALCT_CLCT_OFFSET - ibx));

// loop on the preferred "delta BX" array
for (unsigned mbx = 0; mbx < match_trig_window_size; mbx++) {
Expand Down Expand Up @@ -570,41 +571,41 @@ void CSCMotherboard::selectLCTs() {
}
}

void CSCMotherboard::sortCLCTByQualBend(int bx_alct, std::vector<unsigned>& clctBxVector){
void CSCMotherboard::sortCLCTByQualBend(int bx_alct, std::vector<unsigned>& clctBxVector) {
//find clct bx range in [centerbx-window_size/2, center_bx+window_size/2]
//Then sort CLCT based quality+bend within the match window
//if two CLCTs from different BX has same qual+bend, the in-time one has higher priority
clctBxVector.clear();
int clctQualBendArray[CSCConstants::MAX_CLCT_TBINS+1] = {0};
for (unsigned mbx = 0; mbx < match_trig_window_size; mbx++){
unsigned bx_clct = bx_alct + preferred_bx_match_[mbx] - CSCConstants::ALCT_CLCT_OFFSET;
int clctQualBendArray[CSCConstants::MAX_CLCT_TBINS + 1] = {0};
for (unsigned mbx = 0; mbx < match_trig_window_size; mbx++) {
unsigned bx_clct = bx_alct + preferred_bx_match_[mbx] - CSCConstants::ALCT_CLCT_OFFSET;
int tempQualBend = 0;
if (bx_clct >= CSCConstants::MAX_CLCT_TBINS)
continue;
if (!clctProc->getBestCLCT(bx_clct).isValid()){
if (!clctProc->getBestCLCT(bx_clct).isValid()) {
clctQualBendArray[bx_clct] = tempQualBend;
continue;
}
CSCCLCTDigi bestCLCT = clctProc->getBestCLCT(bx_clct);
//for run2 pattern, ignore direction and use &0xe
//for run3, slope=0 is straighest pattern
int clctBend = bestCLCT.isRun3() ? (16-bestCLCT.getSlope()) : (bestCLCT.getPattern() & 0xe);
int clctBend = bestCLCT.isRun3() ? (16 - bestCLCT.getSlope()) : (bestCLCT.getPattern() & 0xe);
//shift quality to left for 4 bits
int clctQualBend = clctBend | (bestCLCT.getQuality() << 5);
clctQualBendArray[bx_clct] = clctQualBend;
if (clctBxVector.size() == 0) clctBxVector.push_back(bx_clct);
else{
for (auto it=clctBxVector.begin(); it != clctBxVector.end(); it++)
if (clctQualBend > clctQualBendArray[*it]){ //insert the
clctBxVector.insert(it, bx_clct);
if (clctBxVector.empty())
clctBxVector.push_back(bx_clct);
else {
for (auto it = clctBxVector.begin(); it != clctBxVector.end(); it++)
if (clctQualBend > clctQualBendArray[*it]) { //insert the Bx with better clct
clctBxVector.insert(it, bx_clct);
break;
}
}
}
//fill rest of vector with MAX_CLCT_TBINS
for (unsigned bx = clctBxVector.size(); bx < match_trig_window_size; bx++)
clctBxVector.push_back(CSCConstants::MAX_CLCT_TBINS);

}

void CSCMotherboard::checkConfigParameters() {
Expand Down

0 comments on commit 3fac2a3

Please sign in to comment.