diff --git a/L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h b/L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h index 8cfd70636b5d4..6e36345a07550 100644 --- a/L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h +++ b/L1Trigger/TrackFindingTracklet/interface/ChannelAssignment.h @@ -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 channelEncoding() const { return channelEncoding_; } + const std::vector& 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 seedingLayers(int seedType) const { return seedTypesSeedLayers_.at(seedType); } + const std::vector& seedingLayers(int seedType) const { return seedTypesSeedLayers_.at(seedType); } // tt::SensorModule::Type type(const TTStubRef& ttStubRef) const { return setup_->type(ttStubRef); } // @@ -70,6 +72,8 @@ namespace trklet { std::vector> seedTypesSeedLayers_; // layers a seed types can project to using default layer id [barrel: 1-6, discs: 11-15] std::vector> seedTypesProjectionLayers_; + // max. number of layers to which any seed type projects + int maxNumProjectionLayers_; // map of used DTC tfp channels in InputRouter std::vector channelEncoding_; // accumulated number of projections layer from seed 0 to vector index diff --git a/L1Trigger/TrackFindingTracklet/interface/FitTrack.h b/L1Trigger/TrackFindingTracklet/interface/FitTrack.h index 422e9f6edfbef..50b4584d0d853 100644 --- a/L1Trigger/TrackFindingTracklet/interface/FitTrack.h +++ b/L1Trigger/TrackFindingTracklet/interface/FitTrack.h @@ -8,6 +8,7 @@ #include "L1Trigger/TrackFindingTracklet/interface/StubStreamData.h" #include +#include namespace trklet { @@ -38,8 +39,8 @@ namespace trklet { std::vector orderedMatches(std::vector& fullmatch); - void execute(std::vector& streamTrackRaw, - std::vector>& stubStream, + void execute(std::deque& streamTrackRaw, + std::vector>& stubStream, unsigned int iSector); private: diff --git a/L1Trigger/TrackFindingTracklet/interface/StubStreamData.h b/L1Trigger/TrackFindingTracklet/interface/StubStreamData.h index 5c1b9d460aed1..5bf2c488da1a6 100644 --- a/L1Trigger/TrackFindingTracklet/interface/StubStreamData.h +++ b/L1Trigger/TrackFindingTracklet/interface/StubStreamData.h @@ -5,7 +5,7 @@ #include -// 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 { @@ -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 diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index 7c8e46a1d3f06..7f2e1c4ef55d3 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -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. @@ -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 diff --git a/L1Trigger/TrackFindingTracklet/src/ChannelAssignment.cc b/L1Trigger/TrackFindingTracklet/src/ChannelAssignment.cc index 4578427951c45..1fb9c5dfbb4de 100644 --- a/L1Trigger/TrackFindingTracklet/src/ChannelAssignment.cc +++ b/L1Trigger/TrackFindingTracklet/src/ChannelAssignment.cc @@ -30,6 +30,10 @@ namespace trklet { seedTypesSeedLayers_.emplace_back(pSetSeedTypesSeedLayers.getParameter>(s)); seedTypesProjectionLayers_.emplace_back(pSetSeedTypesProjectionLayers.getParameter>(s)); } + maxNumProjectionLayers_ = 0; + for (const auto& v : seedTypesProjectionLayers_) { + maxNumProjectionLayers_ = max(maxNumProjectionLayers_, (int) v.size()); + } auto acc = [](int& sum, vector ints) { return sum += (int)ints.size(); }; numChannelsStub_ = accumulate(seedTypesProjectionLayers_.begin(), seedTypesProjectionLayers_.end(), 0, acc); offsetsStubs_.reserve(numSeedTypes_); diff --git a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc index 33504acc2e93e..82430b2847789 100644 --- a/L1Trigger/TrackFindingTracklet/src/FitTrack.cc +++ b/L1Trigger/TrackFindingTracklet/src/FitTrack.cc @@ -874,8 +874,8 @@ std::vector FitTrack::orderedMatches(vector& 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& streamTrackRaw, - vector>& streamsStubRaw, +void FitTrack::execute(deque& streamTrackRaw, + vector>& streamsStubRaw, unsigned int iSector) { // merge const std::vector& matches1 = orderedMatches(fullmatch1_); @@ -1070,12 +1070,12 @@ void FitTrack::execute(vector& 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(); } } diff --git a/L1Trigger/TrackFindingTracklet/src/Sector.cc b/L1Trigger/TrackFindingTracklet/src/Sector.cc index 97507896f23d6..21ad40e045be3 100644 --- a/L1Trigger/TrackFindingTracklet/src/Sector.cc +++ b/L1Trigger/TrackFindingTracklet/src/Sector.cc @@ -425,17 +425,17 @@ void Sector::executeFT(vector>& streamsTrackRaw, vector streamTrackTmp; - vector> streamsStubTmp(maxNumProjectionLayers); + deque streamTrackTmp; + vector> 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(streamTrackTmp.begin(), streamTrackTmp.end()); channelTrack++; int channelStub(0); for (auto& stream : streamsStubTmp) - streamsStubRaw[offsetStub + channelStub++] = stream; + streamsStubRaw[offsetStub + channelStub++] = vector(stream.begin(), stream.end()); } } diff --git a/L1Trigger/TrackFindingTracklet/test/fpga.cc b/L1Trigger/TrackFindingTracklet/test/fpga.cc index 7fe7d754ae3f0..4729e56b2ae59 100644 --- a/L1Trigger/TrackFindingTracklet/test/fpga.cc +++ b/L1Trigger/TrackFindingTracklet/test/fpga.cc @@ -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> tracksStream(N_SECTOR * 8); - std::vector> 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> tracksStream(numStreamsTrack); + std::vector> stubsStream(numStreamsStub); eventProcessor.event(ev, tracksStream, stubsStream);