Skip to content

Commit

Permalink
tidied up Anders branch
Browse files Browse the repository at this point in the history
  • Loading branch information
tomalin committed May 12, 2022
1 parent afe3c3b commit cf61c91
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 37 deletions.
2 changes: 1 addition & 1 deletion L1Trigger/TrackFindingTracklet/interface/FitTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace trklet {

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

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

Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/TrackFindingTracklet/interface/Sector.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ namespace trklet {
void executeME();
void executeMC();
void executeMP();
void executeFT(std::vector<std::vector<std::string>>& tracksStream,
std::vector<std::vector<StubStreamData>>& stubsStream);
void executeFT(std::vector<std::vector<std::string>>& streamsTrackRaw,
std::vector<std::vector<StubStreamData>>& streamsStubRaw);
void executePD(std::vector<Track>& tracks);

std::vector<Tracklet*> getAllTracklets() const;
Expand Down
4 changes: 3 additions & 1 deletion L1Trigger/TrackFindingTracklet/interface/StubStreamData.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@
#include <string>

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

namespace trklet {

class L1TStub;

class StubStreamData {
public:
StubStreamData() {}
StubStreamData() {}

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

~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_;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ namespace trklet {
const tt::Setup* setup = nullptr);

void event(SLHCEvent& ev,
std::vector<std::vector<std::string>>& tracksStream,
std::vector<std::vector<StubStreamData>>& stubsStream);
std::vector<std::vector<std::string>>& streamsTrackRaw,
std::vector<std::vector<StubStreamData>>& streamsStubRaw);

void printSummary();

Expand Down
24 changes: 13 additions & 11 deletions L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -622,14 +622,14 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
for (int iSeedType = 0; iSeedType < channelAssignment_->numSeedTypes(); iSeedType++) {
maxNumProjectionLayers = max(maxNumProjectionLayers, (unsigned int) channelAssignment_->numProjectionLayers(iSeedType));
}
const unsigned int numStreamsPaddedStub = numStreamsTrack * maxNumProjectionLayers;
const unsigned int numStreamsStubRaw = numStreamsTrack * maxNumProjectionLayers;

// Streams allowing running outside CMSSW.
vector<vector<string>> tracksStream(numStreamsTrack);
vector<vector<StubStreamData>> stubsStream(numStreamsPaddedStub);
// Streams formatted to allow this code to run outside CMSSW.
vector<vector<string>> streamsTrackRaw(numStreamsTrack);
vector<vector<StubStreamData>> streamsStubRaw(numStreamsStubRaw);

// this performs the actual tracklet event processing
eventProcessor.event(ev, tracksStream, stubsStream);
eventProcessor.event(ev, streamsTrackRaw, streamsStubRaw);

int ntracks = 0;

Expand Down Expand Up @@ -706,14 +706,16 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe

iEvent.put(std::move(L1TkTracksForOutput), "Level1TTTracks");

// produce clock and bit accurate stream output tracks and stubs,
// converting from the streams created above.
// produce clock and bit accurate stream output tracks and stubs.
// from end of tracklet pattern recognition.
// Convertion here is from stream format that allows this code to run
// outside CMSSW to the EDProduct one.
Streams streamsTrack(numStreamsTrack);
StreamsStub streamsStub(numStreamsStub);

for(unsigned int chanTrk=0; chanTrk<numStreamsTrack; chanTrk++) {
for(unsigned int itk=0; itk<tracksStream[chanTrk].size(); itk++) {
std::string bitsTrk = tracksStream[chanTrk][itk];
for(unsigned int itk=0; itk<streamsTrackRaw[chanTrk].size(); itk++) {
std::string bitsTrk = streamsTrackRaw[chanTrk][itk];
int iSeed = chanTrk%channelAssignment_->numChannelsTrack(); // seed type
// TO DO: CHECK -- THESE LINES NO LONGER NEEDED AS FITTRACK ADDS VALID+SEED TO trackStream.
//if (bitsTrk != "0")
Expand All @@ -728,9 +730,9 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
// remove padding from stub stream
for(unsigned int iproj=0; iproj<maxNumProjectionLayers; iproj++) {
// FW current has one (perhaps invalid) stub per layer per track.
const StubStreamData& stubdata = stubsStream[chanStubOffsetIn+iproj][itk];
const StubStreamData& stubdata = streamsStubRaw[chanStubOffsetIn+iproj][itk];
const L1TStub& stub = stubdata.stub();
if (stubdata.iSeed()!=-1) { // valid stub
if (stubdata.valid()) {
const TTStubRef ttStubRef = stubMap[stub];
int layerId(-1);
if (!channelAssignment_->layerId(stubdata.iSeed(), ttStubRef, layerId)) continue;
Expand Down
16 changes: 8 additions & 8 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>& trackStream,
vector<vector<StubStreamData>>& stubStream,
void FitTrack::execute(vector<string>& streamTrackRaw,
vector<vector<StubStreamData>>& streamsStubRaw,
unsigned int iSector) {
// merge
const std::vector<Tracklet*>& matches1 = orderedMatches(fullmatch1_);
Expand Down Expand Up @@ -1040,8 +1040,8 @@ void FitTrack::execute(vector<string>& trackStream,
// add gap if enough layer to form track
if (!bestTracklet->fit()) {
static const string invalid = "0";
trackStream.emplace_back(invalid);
for (auto& stream : stubStream)
streamTrackRaw.emplace_back(invalid);
for (auto& stream : streamsStubRaw)
stream.emplace_back(StubStreamData());
continue;
}
Expand All @@ -1053,7 +1053,7 @@ void FitTrack::execute(vector<string>& trackStream,
const int seedType = bestTracklet->getISeed();
const string seed = TTBV(seedType, settings_.nbitsseed()).str();
const string valid("1");
trackStream.emplace_back(valid + seed + rinv + phi0 + z0 + t);
streamTrackRaw.emplace_back(valid + seed + rinv + phi0 + z0 + t);

unsigned int ihit(0);
for(unsigned int ilayer = 0 ; ilayer < N_LAYER + N_DISK ; ilayer++){
Expand All @@ -1071,12 +1071,12 @@ void FitTrack::execute(vector<string>& trackStream,
bool disk2S = (stub->disk() != 0) && (stub->isPSmodule() == 0);
if (disk2S) r = string(widthDisk2Sidentifier, '0') + r;
// store seed, L1TStub, and bit accurate 64 bit word in clock accurate output
stubStream[ihit++].emplace_back(StubStreamData(seedType,*stub,valid + r + phi + rz));
streamsStubRaw[ihit++].emplace_back(StubStreamData(seedType,*stub,valid + r + phi + rz));
}
}
// fill all layer with no stubs with gaps
while (ihit<stubStream.size()) {
stubStream[ihit++].emplace_back(StubStreamData());
while (ihit<streamsStubRaw.size()) {
streamsStubRaw[ihit++].emplace_back(StubStreamData());
}
}

Expand Down
18 changes: 9 additions & 9 deletions L1Trigger/TrackFindingTracklet/src/Sector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -417,25 +417,25 @@ void Sector::executeMP() {
// If using Hybrid, then PurgeDuplicates runs both duplicate removal & KF steps.
// (unless duplicate removal disabled, in which case FitTrack runs KF).

void Sector::executeFT(vector<vector<string>>& tracksStream, vector<vector<StubStreamData>>& stubsStream) {
const int numChannels = tracksStream.size() / N_SECTOR;
const int maxNumProjectionLayers = stubsStream.size()/tracksStream.size();
void Sector::executeFT(vector<vector<string>>& streamsTrackRaw, vector<vector<StubStreamData>>& streamsStubRaw) {
const int numChannels = streamsTrackRaw.size() / N_SECTOR;
const int maxNumProjectionLayers = streamsStubRaw.size()/streamsTrackRaw.size();
const int offsetTrack = isector_ * numChannels;
int channelTrack(0);

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

Expand Down
6 changes: 3 additions & 3 deletions L1Trigger/TrackFindingTracklet/src/TrackletEventProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ void TrackletEventProcessor::configure(istream& inwire, istream& inmem, istream&
}

void TrackletEventProcessor::event(SLHCEvent& ev,
vector<vector<string>>& tracksStream,
vector<vector<StubStreamData>>& stubsStream) {
vector<vector<string>>& streamsTrackRaw,
vector<vector<StubStreamData>>& streamsStubRaw) {
globals_->event() = &ev;

tracks_.clear();
Expand Down Expand Up @@ -367,7 +367,7 @@ void TrackletEventProcessor::event(SLHCEvent& ev,

// fit track
FTTimer_.start();
sector_->executeFT(tracksStream, stubsStream);
sector_->executeFT(streamsTrackRaw, streamsStubRaw);
if ((settings_->writeMem() || settings_->writeMonitorData("IFit")) && k == settings_->writememsect()) {
sector_->writeTF(first);
}
Expand Down

0 comments on commit cf61c91

Please sign in to comment.