Skip to content

Commit

Permalink
Merge pull request #35888 from Dr15Jones/fastCSCCLCTDigi_clear
Browse files Browse the repository at this point in the history
Faster CSCCLCTDigi::clear()
  • Loading branch information
cmsbuild committed Oct 30, 2021
2 parents febc9d3 + 87133c0 commit 89572d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions DataFormats/CSCDigi/interface/CSCCLCTDigi.h
Expand Up @@ -173,7 +173,7 @@ class CSCCLCTDigi {
void setCompCode(const int16_t code) { compCode_ = code; }

// comparator hits in this CLCT
const ComparatorContainer& getHits() const { return hits_; }
const ComparatorContainer& getHits() const { return hits_.empty() ? emptyContainer() : hits_; }

void setHits(const ComparatorContainer& hits) { hits_ = hits; }

Expand All @@ -197,6 +197,7 @@ class CSCCLCTDigi {
void setRun3(bool isRun3);

private:
static const ComparatorContainer& emptyContainer();
uint16_t valid_;
uint16_t quality_;
// Run-1/2 pattern number.
Expand Down Expand Up @@ -232,7 +233,6 @@ class CSCCLCTDigi {

// which hits are in this CLCT?
ComparatorContainer hits_;

Version version_;
};

Expand Down
28 changes: 18 additions & 10 deletions DataFormats/CSCDigi/src/CSCCLCTDigi.cc
Expand Up @@ -13,6 +13,22 @@

enum Pattern_Info { NUM_LAYERS = 6, CLCT_PATTERN_WIDTH = 11 };

namespace {
CSCCLCTDigi::ComparatorContainer makeEmptyContainer() {
CSCCLCTDigi::ComparatorContainer ret;
ret.resize(NUM_LAYERS);
for (auto& p : ret) {
p.resize(CLCT_PATTERN_WIDTH);
}
return ret;
}
} // namespace

CSCCLCTDigi::ComparatorContainer const& CSCCLCTDigi::emptyContainer() {
static ComparatorContainer const s_container = makeEmptyContainer();
return s_container;
}

/// Constructors
CSCCLCTDigi::CSCCLCTDigi(const uint16_t valid,
const uint16_t quality,
Expand Down Expand Up @@ -45,12 +61,8 @@ CSCCLCTDigi::CSCCLCTDigi(const uint16_t valid,
run3_eighth_strip_bit_(run3_eighth_strip_bit),
run3_pattern_(run3_pattern),
run3_slope_(run3_slope),
version_(version) {
hits_.resize(NUM_LAYERS);
for (auto& p : hits_) {
p.resize(CLCT_PATTERN_WIDTH);
}
}
hits_(),
version_(version) {}

/// Default
CSCCLCTDigi::CSCCLCTDigi() {
Expand All @@ -77,10 +89,6 @@ void CSCCLCTDigi::clear() {
run3_slope_ = 0;
version_ = Version::Legacy;
hits_.clear();
hits_.resize(NUM_LAYERS);
for (auto& p : hits_) {
p.resize(CLCT_PATTERN_WIDTH);
}
}

// slope in number of half-strips/layer
Expand Down

0 comments on commit 89572d7

Please sign in to comment.