Skip to content

Commit

Permalink
Thomas PR review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tomalin committed May 13, 2022
1 parent a465123 commit 63c53ff
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 26 deletions.
8 changes: 6 additions & 2 deletions L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ namespace trklet {
int trackletLayerId(const TTStubRef& ttStubRef) const;
// number layers a given seed type projects to
int numProjectionLayers(int seedType) const { return (int)seedTypesProjectionLayers_.at(seedType).size(); }
// max. no. layers that any seed type projects to
int maxNumProjectionLayers() const { return maxNumProjectionLayers_; }
// map of used DTC tfp channels in InputRouter
std::vector<int> channelEncoding() const { return channelEncoding_; }
const std::vector<int>& channelEncoding() const { return channelEncoding_; }
// index of first stub channel belonging to given track channel
int offsetStub(int channelTrack) const;
// seed layers for given seed type id
std::vector<int> seedingLayers(int seedType) const { return seedTypesSeedLayers_.at(seedType); }
const std::vector<int>& seedingLayers(int seedType) const { return seedTypesSeedLayers_.at(seedType); }
//
tt::SensorModule::Type type(const TTStubRef& ttStubRef) const { return setup_->type(ttStubRef); }
//
Expand Down Expand Up @@ -70,6 +72,8 @@ namespace trklet {
std::vector<std::vector<int>> seedTypesSeedLayers_;
// layers a seed types can project to using default layer id [barrel: 1-6, discs: 11-15]
std::vector<std::vector<int>> seedTypesProjectionLayers_;
// max. number of layers to which any seed type projects
int maxNumProjectionLayers_;
// map of used DTC tfp channels in InputRouter
std::vector<int> channelEncoding_;
// accumulated number of projections layer from seed 0 to vector index
Expand Down
5 changes: 3 additions & 2 deletions L1Trigger/TrackFindingTracklet/interface/FitTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "L1Trigger/TrackFindingTracklet/interface/StubStreamData.h"

#include <vector>
#include <deque>

namespace trklet {

Expand Down Expand Up @@ -38,8 +39,8 @@ namespace trklet {

std::vector<Tracklet*> orderedMatches(std::vector<FullMatchMemory*>& fullmatch);

void execute(std::vector<std::string>& streamTrackRaw,
std::vector<std::vector<StubStreamData>>& stubStream,
void execute(std::deque<std::string>& streamTrackRaw,
std::vector<std::deque<StubStreamData>>& stubStream,
unsigned int iSector);

private:
Expand Down
12 changes: 6 additions & 6 deletions L1Trigger/TrackFindingTracklet/interface/StubStreamData.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <string>

// Used to generate bit-accurate stub stream from TrackBuilder output
// Represents an element of the bit-accurate stub stream from TrackBuilder output
// (This class only needed to support stand-alone running of this code).

namespace trklet {
Expand All @@ -16,21 +16,21 @@ namespace trklet {
public:
StubStreamData() {}

StubStreamData(int iSeed, const L1TStub& stub, const std::string& residuals)
: iSeed_(iSeed), stub_(stub), residuals_(residuals) {}
StubStreamData(int iSeed, const L1TStub& stub, const std::string& dataBits)
: iSeed_(iSeed), stub_(stub), dataBits_(dataBits) {}

~StubStreamData() = default;

int iSeed() const { return iSeed_; } // Seed type
bool valid() const { return (iSeed_ >= 0); } // Valid stub
const L1TStub& stub() const { return stub_; }
// String containing valid bit + r coordinate + phi residual + r or z residual.
const std::string& residuals() const { return residuals_; }
// String with bits of valid bit + r coordinate + phi residual + r or z residual.
const std::string& dataBits() const { return dataBits_; }

private:
int iSeed_{-1};
L1TStub stub_;
std::string residuals_{""};
std::string dataBits_{""};
};
}; // namespace trklet
#endif
8 changes: 2 additions & 6 deletions L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,7 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
// number of stub channels
const unsigned int numStreamsStub = N_SECTOR * channelAssignment_->numChannelsStub();
// number of stub channels if all seed types streams padded to have same number of stub channels (for coding simplicity)
unsigned int maxNumProjectionLayers = 0;
for (int iSeedType = 0; iSeedType < channelAssignment_->numSeedTypes(); iSeedType++) {
maxNumProjectionLayers =
max(maxNumProjectionLayers, (unsigned int)channelAssignment_->numProjectionLayers(iSeedType));
}
const unsigned int maxNumProjectionLayers = channelAssignment_->maxNumProjectionLayers();
const unsigned int numStreamsStubRaw = numStreamsTrack * maxNumProjectionLayers;

// Streams formatted to allow this code to run outside CMSSW.
Expand Down Expand Up @@ -734,7 +730,7 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
if (!channelAssignment_->layerId(stubdata.iSeed(), ttStubRef, layerId))
continue;
hitMap.set(layerId);
streamsStub[chanStubOffsetOut + layerId].emplace_back(ttStubRef, stubdata.residuals());
streamsStub[chanStubOffsetOut + layerId].emplace_back(ttStubRef, stubdata.dataBits());
}
}
for (int layerId : hitMap.ids(false)) { // invalid stubs
Expand Down
4 changes: 4 additions & 0 deletions L1Trigger/TrackFindingTracklet/src/ChannelAssignment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ namespace trklet {
seedTypesSeedLayers_.emplace_back(pSetSeedTypesSeedLayers.getParameter<vector<int>>(s));
seedTypesProjectionLayers_.emplace_back(pSetSeedTypesProjectionLayers.getParameter<vector<int>>(s));
}
maxNumProjectionLayers_ = 0;
for (const auto& v : seedTypesProjectionLayers_) {
maxNumProjectionLayers_ = max(maxNumProjectionLayers_, (int) v.size());
}
auto acc = [](int& sum, vector<int> ints) { return sum += (int)ints.size(); };
numChannelsStub_ = accumulate(seedTypesProjectionLayers_.begin(), seedTypesProjectionLayers_.end(), 0, acc);
offsetsStubs_.reserve(numSeedTypes_);
Expand Down
8 changes: 4 additions & 4 deletions L1Trigger/TrackFindingTracklet/src/FitTrack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -874,8 +874,8 @@ std::vector<Tracklet*> FitTrack::orderedMatches(vector<FullMatchMemory*>& fullma
// Also create output streams, that bypass these memories, (so can include gaps in time),
// to be used by Hybrid case with exact New KF emulation.

void FitTrack::execute(vector<string>& streamTrackRaw,
vector<vector<StubStreamData>>& streamsStubRaw,
void FitTrack::execute(deque<string>& streamTrackRaw,
vector<deque<StubStreamData>>& streamsStubRaw,
unsigned int iSector) {
// merge
const std::vector<Tracklet*>& matches1 = orderedMatches(fullmatch1_);
Expand Down Expand Up @@ -1070,12 +1070,12 @@ void FitTrack::execute(vector<string>& streamTrackRaw,
if (disk2S)
r = string(widthDisk2Sidentifier, '0') + r;
// store seed, L1TStub, and bit accurate 64 bit word in clock accurate output
streamsStubRaw[ihit++].emplace_back(StubStreamData(seedType, *stub, valid + r + phi + rz));
streamsStubRaw[ihit++].emplace_back(seedType, *stub, valid + r + phi + rz);
}
}
// fill all layer with no stubs with gaps
while (ihit < streamsStubRaw.size()) {
streamsStubRaw[ihit++].emplace_back(StubStreamData());
streamsStubRaw[ihit++].emplace_back();
}
}

Expand Down
8 changes: 4 additions & 4 deletions L1Trigger/TrackFindingTracklet/src/Sector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -425,17 +425,17 @@ void Sector::executeFT(vector<vector<string>>& streamsTrackRaw, vector<vector<St

for (auto& i : FT_) {
// Temporary streams for a single TrackBuilder (i.e. seed type)
vector<string> streamTrackTmp;
vector<vector<StubStreamData>> streamsStubTmp(maxNumProjectionLayers);
deque<string> streamTrackTmp;
vector<deque<StubStreamData>> streamsStubTmp(maxNumProjectionLayers);
i->execute(streamTrackTmp, streamsStubTmp, isector_);
if (!settings_.storeTrackBuilderOutput())
continue;
const int offsetStub = (offsetTrack + channelTrack) * maxNumProjectionLayers;
streamsTrackRaw[offsetTrack + channelTrack] = streamTrackTmp;
streamsTrackRaw[offsetTrack + channelTrack] = vector<string>(streamTrackTmp.begin(), streamTrackTmp.end());
channelTrack++;
int channelStub(0);
for (auto& stream : streamsStubTmp)
streamsStubRaw[offsetStub + channelStub++] = stream;
streamsStubRaw[offsetStub + channelStub++] = vector<StubStreamData>(stream.begin(), stream.end());
}
}

Expand Down
10 changes: 8 additions & 2 deletions L1Trigger/TrackFindingTracklet/test/fpga.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,14 @@ int main(const int argc, const char **argv) {
edm::LogVerbatim("Tracklet") << "Process event: " << eventnum << " with " << ev.nstubs() << " stubs and "
<< ev.nsimtracks() << " simtracks";

std::vector<std::vector<std::string>> tracksStream(N_SECTOR * 8);
std::vector<std::vector<StubStreamData>> stubsStream(N_SECTOR * 8 * 8);
// Output track streams per nonant from track-builders.
constexpr unsigned int numStubStreamsPerTrack = settings.extended() ? N_SEED : N_SEED_PROMPT;
// Max. number of projection layers for any tracklet seed.
constexpr unsigned int maxNumProjectionLayers = 8;
constexpr unsigned int numStreamsTrack = N_SECTOR * numStubStreamsTrack;
constexpr unsigned int numStreamsStub = numStreamsTrack * maxNumProjectionLayers;
std::vector<std::vector<std::string>> tracksStream(numStreamsTrack);
std::vector<std::vector<StubStreamData>> stubsStream(numStreamsStub);

eventProcessor.event(ev, tracksStream, stubsStream);

Expand Down

0 comments on commit 63c53ff

Please sign in to comment.