Skip to content

Commit

Permalink
Merge pull request #42148 from iarspider/fix-l1trigger_trackertfp-cpp20
Browse files Browse the repository at this point in the history
Make L1Trigger/TrackerTFP compile with C++20
  • Loading branch information
cmsbuild authored Jun 30, 2023
2 parents 74f255b + 61a7581 commit df68cfc
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 49 deletions.
4 changes: 2 additions & 2 deletions L1Trigger/TrackerTFP/plugins/ProducerKFin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ namespace trackerTFP {
for (int channel = 0; channel < dataFormats_->numChannel(Process::zht); channel++) {
const int index = region * dataFormats_->numChannel(Process::zht) + channel;
const StreamStub& stream = streams[index];
nStubsZHR += accumulate(stream.begin(), stream.end(), 0, [](int& sum, const FrameStub& frame) {
return sum += frame.first.isNonnull() ? 1 : 0;
nStubsZHR += accumulate(stream.begin(), stream.end(), 0, [](int sum, const FrameStub& frame) {
return sum + (frame.first.isNonnull() ? 1 : 0);
});
}
vector<StubZHT> stubsZHT;
Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/TrackerTFP/plugins/ProducerTT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ namespace trackerTFP {
const StreamsStub& streamsStubs = *handleStubs.product();
int nTracks(0);
for (const StreamTrack& stream : streamsTracks)
nTracks += accumulate(stream.begin(), stream.end(), 0, [](int& sum, const FrameTrack& frame) {
return sum += frame.first.isNonnull() ? 1 : 0;
nTracks += accumulate(stream.begin(), stream.end(), 0, [](int sum, const FrameTrack& frame) {
return sum + (frame.first.isNonnull() ? 1 : 0);
});
ttTracks.reserve(nTracks);
for (int channel = 0; channel < dataFormats_->numStreamsTracks(Process::kf); channel++) {
Expand Down
8 changes: 4 additions & 4 deletions L1Trigger/TrackerTFP/src/GeometricProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace trackerTFP {

// read in and organize input product (fill vector input_)
void GeometricProcessor::consume(const TTDTC& ttDTC) {
auto validFrame = [](int& sum, const FrameStub& frame) { return sum += frame.first.isNonnull() ? 1 : 0; };
auto validFrame = [](int sum, const FrameStub& frame) { return sum + (frame.first.isNonnull() ? 1 : 0); };
int nStubsPP(0);
for (int channel = 0; channel < dataFormats_->numChannel(Process::pp); channel++) {
const StreamStub& stream = ttDTC.stream(region_, channel);
Expand All @@ -48,7 +48,7 @@ namespace trackerTFP {
for (deque<StubPP*>& stubs : input)
for (auto it = stubs.end(); it != stubs.begin();)
it = (*--it) ? stubs.begin() : stubs.erase(it);
auto validStub = [](int& sum, StubPP* stub) { return sum += stub ? 1 : 0; };
auto validStub = [](int sum, StubPP* stub) { return sum + (stub ? 1 : 0); };
int nStubsGP(0);
for (const vector<deque<StubPP*>>& sector : input_)
for (const deque<StubPP*>& channel : sector)
Expand All @@ -63,7 +63,7 @@ namespace trackerTFP {
vector<deque<StubGP*>> stacks(dataFormats_->numChannel(Process::pp));
const int sectorPhi = sector % setup_->numSectorsPhi();
const int sectorEta = sector / setup_->numSectorsPhi();
auto size = [](int& sum, const deque<StubPP*>& stubs) { return sum += stubs.size(); };
auto size = [](int sum, const deque<StubPP*>& stubs) { return sum + stubs.size(); };
const int nStubs = accumulate(inputs.begin(), inputs.end(), 0, size);
vector<StubGP*> acceptedSector;
vector<StubGP*> lostSector;
Expand Down Expand Up @@ -128,4 +128,4 @@ namespace trackerTFP {
return t;
}

} // namespace trackerTFP
} // namespace trackerTFP
8 changes: 4 additions & 4 deletions L1Trigger/TrackerTFP/src/HoughTransform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace trackerTFP {
// read in and organize input product (fill vector input_)
void HoughTransform::consume(const StreamsStub& streams) {
const int offset = region_ * dataFormats_->numChannel(Process::gp);
auto validFrame = [](int& sum, const FrameStub& frame) { return sum += frame.first.isNonnull() ? 1 : 0; };
auto validFrame = [](int sum, const FrameStub& frame) { return sum + (frame.first.isNonnull() ? 1 : 0); };
int nStubsGP(0);
for (int sector = 0; sector < dataFormats_->numChannel(Process::gp); sector++) {
const StreamStub& stream = streams[offset + sector];
Expand All @@ -56,7 +56,7 @@ namespace trackerTFP {
for (deque<StubGP*>& stubs : input)
for (auto it = stubs.end(); it != stubs.begin();)
it = (*--it) ? stubs.begin() : stubs.erase(it);
auto validStub = [](int& sum, StubGP* stub) { return sum += stub ? 1 : 0; };
auto validStub = [](int sum, StubGP* stub) { return sum + (stub ? 1 : 0); };
int nStubsHT(0);
for (const vector<deque<StubGP*>>& binInv2R : input_)
for (const deque<StubGP*>& sector : binInv2R)
Expand Down Expand Up @@ -163,7 +163,7 @@ namespace trackerTFP {
vector<vector<StubHT*>> tracks(setup_->htNumBinsPhiT());
for (int binPhiT = 0; binPhiT < setup_->htNumBinsPhiT(); binPhiT++) {
const int phiT = phiT_.toSigned(binPhiT);
auto samePhiT = [phiT](int& sum, StubHT* stub) { return sum += stub->phiT() == phiT; };
auto samePhiT = [phiT](int sum, StubHT* stub) { return sum + (stub->phiT() == phiT); };
const int numAccepted = accumulate(acceptedSector.begin(), acceptedSector.end(), 0, samePhiT);
const int numLost = accumulate(lostSector.begin(), lostSector.end(), 0, samePhiT);
tracks[binPhiT].reserve(numAccepted + numLost);
Expand Down Expand Up @@ -211,4 +211,4 @@ namespace trackerTFP {
return t;
}

} // namespace trackerTFP
} // namespace trackerTFP
8 changes: 4 additions & 4 deletions L1Trigger/TrackerTFP/src/KalmanFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace trackerTFP {
// read in and organize input product (fill vector input_)
void KalmanFilter::consume(const StreamsTrack& streamsTrack, const StreamsStub& streamsStub) {
auto valid = [](const auto& frame) { return frame.first.isNonnull(); };
auto acc = [](int& sum, const auto& frame) { return sum += (frame.first.isNonnull() ? 1 : 0); };
auto acc = [](int sum, const auto& frame) { return sum + (frame.first.isNonnull() ? 1 : 0); };
int nTracks(0);
int nStubs(0);
const int offset = region_ * dataFormats_->numChannel(Process::kf);
Expand Down Expand Up @@ -155,8 +155,8 @@ namespace trackerTFP {
streamsStubs[offset + layer].emplace_back(FrameStub());
}
};
auto count = [this](int& sum, const State* state) {
return sum += state && state->hitPattern().count() >= setup_->kfMinLayers() ? 1 : 0;
auto count = [this](int sum, const State* state) {
return sum + ((state && state->hitPattern().count() >= setup_->kfMinLayers()) ? 1 : 0);
};
for (int channel = 0; channel < dataFormats_->numChannel(Process::kf); channel++) {
deque<State*> stream;
Expand Down Expand Up @@ -451,4 +451,4 @@ namespace trackerTFP {
return t;
}

} // namespace trackerTFP
} // namespace trackerTFP
10 changes: 5 additions & 5 deletions L1Trigger/TrackerTFP/src/MiniHoughTransform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace trackerTFP {

// read in and organize input product (fill vector input_)
void MiniHoughTransform::consume(const StreamsStub& streams) {
auto valid = [](int& sum, const FrameStub& frame) { return sum += (frame.first.isNonnull() ? 1 : 0); };
auto valid = [](int sum, const FrameStub& frame) { return sum + (frame.first.isNonnull() ? 1 : 0); };
int nStubsHT(0);
for (int binInv2R = 0; binInv2R < numBinsInv2R_; binInv2R++) {
const StreamStub& stream = streams[region_ * numBinsInv2R_ + binInv2R];
Expand Down Expand Up @@ -216,7 +216,7 @@ namespace trackerTFP {
void MiniHoughTransform::slb(vector<deque<StubMHT*>>& inputs, vector<StubMHT*>& accepted, StreamStub& lost) const {
if (all_of(inputs.begin(), inputs.end(), [](const deque<StubMHT*>& stubs) { return stubs.empty(); }))
return;
auto size = [](int& sum, const deque<StubMHT*>& stubs) { return sum += stubs.size(); };
auto size = [](int sum, const deque<StubMHT*>& stubs) { return sum = stubs.size(); };
const int nFrames = accumulate(inputs.begin(), inputs.end(), 0, size);
accepted.reserve(nFrames);
// input fifos
Expand Down Expand Up @@ -255,7 +255,7 @@ namespace trackerTFP {
// perform truncation if desired
if (enableTruncation_ && (int)accepted.size() > setup_->numFrames()) {
const auto limit = next(accepted.begin(), setup_->numFrames());
auto valid = [](int& sum, StubMHT* stub) { return sum += stub ? 1 : 0; };
auto valid = [](int sum, StubMHT* stub) { return sum + (stub ? 1 : 0); };
const int nLost = accumulate(limit, accepted.end(), 0, valid);
lost.reserve(nLost);
for (auto it = limit; it != accepted.end(); it++)
Expand All @@ -272,7 +272,7 @@ namespace trackerTFP {
void MiniHoughTransform::dlb(vector<vector<StubMHT*>>& streams) const {
if (all_of(streams.begin(), streams.end(), [](const vector<StubMHT*>& stubs) { return stubs.empty(); }))
return;
auto maxSize = [](int& size, const vector<StubMHT*>& stream) { return size = max(size, (int)stream.size()); };
auto maxSize = [](int size, const vector<StubMHT*>& stream) { return size = max(size, (int)stream.size()); };
const int nMax = accumulate(streams.begin(), streams.end(), 0, maxSize);
for (vector<StubMHT*>& stream : streams)
stream.resize(nMax, nullptr);
Expand Down Expand Up @@ -314,4 +314,4 @@ namespace trackerTFP {
return t;
}

} // namespace trackerTFP
} // namespace trackerTFP
6 changes: 3 additions & 3 deletions L1Trigger/TrackerTFP/src/State.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ namespace trackerTFP {

// Determine quality of completed state
void State::finish() {
auto consistent = [this](int& sum, const StubKF& stub) {
auto consistent = [this](int sum, const StubKF& stub) {
static const DataFormat& phi = dataFormats_->format(Variable::phi, Process::kf);
static const DataFormat& z = dataFormats_->format(Variable::z, Process::kf);
// Check stub consistent with helix, allowing for stub uncertainty
const bool inRange0 = 2. * abs(stub.phi()) - stub.dPhi() < phi.base();
const bool inRange1 = 2. * abs(stub.z()) - stub.dZ() < z.base();
return sum += (inRange0 && inRange1 ? 1 : 0);
return sum + (inRange0 && inRange1 ? 1 : 0);
};
vector<StubKF> stubs;
fill(stubs);
Expand All @@ -122,4 +122,4 @@ namespace trackerTFP {
numSkippedLayers_ = pattern.count(0, hitPattern_.pmEncode(), false);
}

} // namespace trackerTFP
} // namespace trackerTFP
10 changes: 5 additions & 5 deletions L1Trigger/TrackerTFP/src/ZHoughTransform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace trackerTFP {

// read in and organize input product (fill vector input_)
void ZHoughTransform::consume(const StreamsStub& streams) {
auto valid = [](int& sum, const FrameStub& frame) { return sum += (frame.first.isNonnull() ? 1 : 0); };
auto valid = [](int sum, const FrameStub& frame) { return sum + (frame.first.isNonnull() ? 1 : 0); };
const int offset = region_ * dataFormats_->numChannel(Process::mht);
int nStubsMHT(0);
for (int channel = 0; channel < dataFormats_->numChannel(Process::mht); channel++) {
Expand Down Expand Up @@ -249,7 +249,7 @@ namespace trackerTFP {
// perform truncation if desired
if (enableTruncation_ && (int)accepted.size() > setup_->numFrames()) {
const auto limit = next(accepted.begin(), setup_->numFrames());
auto valid = [](int& sum, StubZHT* stub) { return sum += stub ? 1 : 0; };
auto valid = [](int sum, StubZHT* stub) { return sum + (stub ? 1 : 0); };
const int nLost = accumulate(limit, accepted.end(), 0, valid);
lost.reserve(nLost);
for (auto it = limit; it != accepted.end(); it++)
Expand Down Expand Up @@ -299,8 +299,8 @@ namespace trackerTFP {
track.push_back(stub.frame());
}
}
const int size = accumulate(tracks.begin(), tracks.end(), 0, [](int& sum, const deque<FrameStub>& stubs) {
return sum += (int)stubs.size();
const int size = accumulate(tracks.begin(), tracks.end(), 0, [](int sum, const deque<FrameStub>& stubs) {
return sum + (int)stubs.size();
});
stream.reserve(size);
for (deque<FrameStub>& track : tracks)
Expand All @@ -319,4 +319,4 @@ namespace trackerTFP {
return t;
}

} // namespace trackerTFP
} // namespace trackerTFP
14 changes: 7 additions & 7 deletions L1Trigger/TrackerTFP/test/AnalyzerKF.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,20 +258,20 @@ namespace trackerTFP {
hisChannel_->Fill(accepted.size());
profChannel_->Fill(channel, accepted.size());
TTTracks tracks;
const int nTracks = accumulate(accepted.begin(), accepted.end(), 0, [](int& sum, const FrameTrack& frame) {
return sum += frame.first.isNonnull() ? 1 : 0;
const int nTracks = accumulate(accepted.begin(), accepted.end(), 0, [](int sum, const FrameTrack& frame) {
return sum + (frame.first.isNonnull() ? 1 : 0);
});
nTracksRegion += nTracks;
tracks.reserve(nTracks);
consume(accepted, acceptedStubs, index, tracks);
for (const TTTrack<Ref_Phase2TrackerDigi_>& ttTrack : tracks)
hisPhi_->Fill(ttTrack.momentum().phi());
nStubsRegion += accumulate(tracks.begin(), tracks.end(), 0, [](int& sum, const auto& ttTrack) {
return sum += (int)ttTrack.getStubRefs().size();
nStubsRegion += accumulate(tracks.begin(), tracks.end(), 0, [](int sum, const auto& ttTrack) {
return sum + (int)ttTrack.getStubRefs().size();
});
TTTracks tracksLost;
const int nLost = accumulate(lost.begin(), lost.end(), 0, [](int& sum, const FrameTrack& frame) {
return sum += frame.first.isNonnull() ? 1 : 0;
const int nLost = accumulate(lost.begin(), lost.end(), 0, [](int sum, const FrameTrack& frame) {
return sum + (frame.first.isNonnull() ? 1 : 0);
});
nLostRegion += nLost;
tracksLost.reserve(nLost);
Expand Down Expand Up @@ -387,4 +387,4 @@ namespace trackerTFP {

} // namespace trackerTFP

DEFINE_FWK_MODULE(trackerTFP::AnalyzerKF);
DEFINE_FWK_MODULE(trackerTFP::AnalyzerKF);
14 changes: 7 additions & 7 deletions L1Trigger/TrackerTFP/test/AnalyzerKFin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ namespace trackerTFP {
vector<vector<TTStubRef>> lost;
formTracks(lostTracks, lostStubs, lost, offset + channel);
nTracks += tracks.size();
nStubs += accumulate(tracks.begin(), tracks.end(), 0, [](int& sum, const vector<TTStubRef>& track) {
return sum += (int)track.size();
nStubs += accumulate(tracks.begin(), tracks.end(), 0, [](int sum, const vector<TTStubRef>& track) {
return sum + (int)track.size();
});
nLost += lost.size();
allTracks += tracks.size();
Expand Down Expand Up @@ -262,8 +262,8 @@ namespace trackerTFP {
int channel) const {
const int offset = channel * setup_->numLayers();
const StreamTrack& streamTrack = streamsTrack[channel];
const int numTracks = accumulate(streamTrack.begin(), streamTrack.end(), 0, [](int& sum, const FrameTrack& frame) {
return sum += (frame.first.isNonnull() ? 1 : 0);
const int numTracks = accumulate(streamTrack.begin(), streamTrack.end(), 0, [](int sum, const FrameTrack& frame) {
return sum + (frame.first.isNonnull() ? 1 : 0);
});
tracks.reserve(numTracks);
for (int frame = 0; frame < (int)streamTrack.size(); frame++) {
Expand All @@ -278,8 +278,8 @@ namespace trackerTFP {
for (int layer = 0; layer < setup_->numLayers(); layer++) {
const StreamStub& stream = streamsStubs[offset + layer];
numStubs +=
accumulate(stream.begin() + frame, stream.begin() + frame + size, 0, [](int& sum, const FrameStub& frame) {
return sum += (frame.first.isNonnull() ? 1 : 0);
accumulate(stream.begin() + frame, stream.begin() + frame + size, 0, [](int sum, const FrameStub& frame) {
return sum + (frame.first.isNonnull() ? 1 : 0);
});
}
vector<TTStubRef> stubs;
Expand Down Expand Up @@ -311,4 +311,4 @@ namespace trackerTFP {

} // namespace trackerTFP

DEFINE_FWK_MODULE(trackerTFP::AnalyzerKFin);
DEFINE_FWK_MODULE(trackerTFP::AnalyzerKFin);
6 changes: 3 additions & 3 deletions L1Trigger/TrackerTFP/test/AnalyzerMHT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ namespace trackerTFP {
const StreamStub& accepted = handleAccepted->at(index);
hisChannel_->Fill(accepted.size());
profChannel_->Fill(channel, accepted.size());
nStubs += accumulate(accepted.begin(), accepted.end(), 0, [](int& sum, const FrameStub& frame) {
return sum += frame.first.isNonnull() ? 1 : 0;
nStubs += accumulate(accepted.begin(), accepted.end(), 0, [](int sum, const FrameStub& frame) {
return sum + (frame.first.isNonnull() ? 1 : 0);
});
vector<vector<TTStubRef>> tracks;
vector<vector<TTStubRef>> lost;
Expand Down Expand Up @@ -289,4 +289,4 @@ namespace trackerTFP {

} // namespace trackerTFP

DEFINE_FWK_MODULE(trackerTFP::AnalyzerMHT);
DEFINE_FWK_MODULE(trackerTFP::AnalyzerMHT);
6 changes: 3 additions & 3 deletions L1Trigger/TrackerTFP/test/AnalyzerZHT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ namespace trackerTFP {
const StreamStub& accepted = handleAccepted->at(index);
hisChannel_->Fill(accepted.size());
profChannel_->Fill(channel, accepted.size());
nStubs += accumulate(accepted.begin(), accepted.end(), 0, [](int& sum, const FrameStub& frame) {
return sum += frame.first.isNonnull() ? 1 : 0;
nStubs += accumulate(accepted.begin(), accepted.end(), 0, [](int sum, const FrameStub& frame) {
return sum + (frame.first.isNonnull() ? 1 : 0);
});
vector<vector<TTStubRef>> tracks;
vector<vector<TTStubRef>> lost;
Expand Down Expand Up @@ -291,4 +291,4 @@ namespace trackerTFP {

} // namespace trackerTFP

DEFINE_FWK_MODULE(trackerTFP::AnalyzerZHT);
DEFINE_FWK_MODULE(trackerTFP::AnalyzerZHT);

0 comments on commit df68cfc

Please sign in to comment.