Skip to content

Commit

Permalink
Various fixes to comment on pull request (#68)
Browse files Browse the repository at this point in the history
Co-authored-by: Anders <[email protected]>
  • Loading branch information
skinnari and aryd authored Jan 22, 2021
1 parent 987904d commit ca9f4d8
Show file tree
Hide file tree
Showing 13 changed files with 161 additions and 139 deletions.
4 changes: 2 additions & 2 deletions L1Trigger/TrackFindingTracklet/interface/CircularBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ namespace trklet {
//Empty buffer is write ptr is same as read ptr
bool empty() const { return wptr_ == rptr_; }

T read() {
const T& read() {
assert(!empty());
unsigned int oldrptr = rptr_;
rptr_ = (rptr_ + 1) % size_;
return buffer_[oldrptr];
}

T peek() const {
const T& peek() const {
assert(!empty());
return buffer_[rptr_];
}
Expand Down
80 changes: 40 additions & 40 deletions L1Trigger/TrackFindingTracklet/interface/Sector.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,17 @@ namespace trklet {
double phimin() const { return phimin_; }
double phimax() const { return phimax_; }

template <typename TV>
void addMemToVec(std::vector<TV*>& memvec, TV* mem, const std::string& memName) {
memvec.push_back(mem);
Memories_[memName].reset(mem);
MemoriesV_.push_back(mem);
template <typename TV, typename... Args>
void addMemToVec(std::vector<std::unique_ptr<TV> >& memvec, const std::string& memName, Args&... args) {
memvec.push_back(std::make_unique<TV>(memName, std::forward<Args>(args)...));
Memories_[memName] = memvec.back().get();
MemoriesV_.push_back(memvec.back().get());
}

template <typename TV>
void addProcToVec(std::vector<TV*>& procvec, TV* proc, const std::string& procName) {
procvec.push_back(proc);
Processes_[procName].reset(proc);
template <typename TV, typename... Args>
void addProcToVec(std::vector<std::unique_ptr<TV> >& procvec, const std::string& procName, Args&... args) {
procvec.push_back(std::make_unique<TV>(procName, std::forward<Args>(args)...));
Processes_[procName] = procvec.back().get();
}

private:
Expand All @@ -135,38 +135,38 @@ namespace trklet {
double phimin_;
double phimax_;

std::map<std::string, std::unique_ptr<MemoryBase> > Memories_;
std::map<std::string, MemoryBase* > Memories_;
std::vector<MemoryBase*> MemoriesV_;
std::vector<InputLinkMemory*> IL_;
std::vector<AllStubsMemory*> AS_;
std::vector<VMStubsTEMemory*> VMSTE_;
std::vector<VMStubsMEMemory*> VMSME_;
std::vector<StubPairsMemory*> SP_;
std::vector<StubTripletsMemory*> ST_;
std::vector<TrackletParametersMemory*> TPAR_;
std::vector<TrackletProjectionsMemory*> TPROJ_;
std::vector<AllProjectionsMemory*> AP_;
std::vector<VMProjectionsMemory*> VMPROJ_;
std::vector<CandidateMatchMemory*> CM_;
std::vector<FullMatchMemory*> FM_;
std::vector<TrackFitMemory*> TF_;
std::vector<CleanTrackMemory*> CT_;

std::map<std::string, std::unique_ptr<ProcessBase> > Processes_;
std::vector<VMRouter*> VMR_;
std::vector<VMRouterCM*> VMRCM_;
std::vector<TrackletEngine*> TE_;
std::vector<TrackletEngineDisplaced*> TED_;
std::vector<TripletEngine*> TRE_;
std::vector<TrackletProcessor*> TP_;
std::vector<TrackletCalculator*> TC_;
std::vector<TrackletCalculatorDisplaced*> TCD_;
std::vector<ProjectionRouter*> PR_;
std::vector<MatchEngine*> ME_;
std::vector<MatchCalculator*> MC_;
std::vector<MatchProcessor*> MP_;
std::vector<FitTrack*> FT_;
std::vector<PurgeDuplicate*> PD_;
std::vector<std::unique_ptr<InputLinkMemory> > IL_;
std::vector<std::unique_ptr<AllStubsMemory> > AS_;
std::vector<std::unique_ptr<VMStubsTEMemory> > VMSTE_;
std::vector<std::unique_ptr<VMStubsMEMemory> > VMSME_;
std::vector<std::unique_ptr<StubPairsMemory> > SP_;
std::vector<std::unique_ptr<StubTripletsMemory> > ST_;
std::vector<std::unique_ptr<TrackletParametersMemory> > TPAR_;
std::vector<std::unique_ptr<TrackletProjectionsMemory> > TPROJ_;
std::vector<std::unique_ptr<AllProjectionsMemory> > AP_;
std::vector<std::unique_ptr<VMProjectionsMemory> > VMPROJ_;
std::vector<std::unique_ptr<CandidateMatchMemory> > CM_;
std::vector<std::unique_ptr<FullMatchMemory> > FM_;
std::vector<std::unique_ptr<TrackFitMemory> > TF_;
std::vector<std::unique_ptr<CleanTrackMemory> > CT_;

std::map<std::string, ProcessBase* > Processes_;
std::vector<std::unique_ptr<VMRouter> > VMR_;
std::vector<std::unique_ptr<VMRouterCM> > VMRCM_;
std::vector<std::unique_ptr<TrackletEngine> > TE_;
std::vector<std::unique_ptr<TrackletEngineDisplaced> > TED_;
std::vector<std::unique_ptr<TripletEngine> > TRE_;
std::vector<std::unique_ptr<TrackletProcessor> > TP_;
std::vector<std::unique_ptr<TrackletCalculator> > TC_;
std::vector<std::unique_ptr<TrackletCalculatorDisplaced> > TCD_;
std::vector<std::unique_ptr<ProjectionRouter> > PR_;
std::vector<std::unique_ptr<MatchEngine> > ME_;
std::vector<std::unique_ptr<MatchCalculator> > MC_;
std::vector<std::unique_ptr<MatchProcessor> > MP_;
std::vector<std::unique_ptr<FitTrack> > FT_;
std::vector<std::unique_ptr<PurgeDuplicate> > PD_;
};
}; // namespace trklet
#endif
5 changes: 5 additions & 0 deletions L1Trigger/TrackFindingTracklet/interface/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ namespace trklet {

constexpr unsigned int N_DSS_MOD = 5; // # of rings with 2S modules per disk

constexpr unsigned int NRINVBITS = 5; //number of bit for rinv in bend match table
constexpr unsigned int NFINERZBITS = 3; //number of bit for r or z within a r/z bin

constexpr double sixth = 1.0/6.0; //Commonly used factor

class Settings {
public:
Settings() {
Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/TrackFindingTracklet/interface/TrackletEngineUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ namespace trklet {

bool empty() const { return candpairs_.empty(); }

std::pair<const Stub*, const Stub*> read() { return candpairs_.read(); }
const std::pair<const Stub*, const Stub*>& read() { return candpairs_.read(); }

std::pair<const Stub*, const Stub*> peek() const { return candpairs_.peek(); }
const std::pair<const Stub*, const Stub*>& peek() const { return candpairs_.peek(); }

bool idle() const { return idle_; }

Expand Down
3 changes: 3 additions & 0 deletions L1Trigger/TrackFindingTracklet/interface/TrackletProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ namespace trklet {

VMStubsTEMemory* outervmstubs_;

// The use of a std::tuple here is awkward and should be fixed. This code is slotted for a significant
// overhaul to allign with the HLS implementation. At that point the use fo the tuple should be
// eliminated
// istub imem start imem end imem
std::vector<std::tuple<CircularBuffer<TEData>, unsigned int, unsigned int, unsigned int, unsigned int> >
tedatabuffers_;
Expand Down
2 changes: 1 addition & 1 deletion L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void MatchEngineUnit::step() {
usesecond_ = false;
istub_ = 0;
slot_++;
projfinerz_ -= 8;
projfinerz_ -= (1<<NFINERZBITS);
} else {
idle_ = true;
}
Expand Down
9 changes: 5 additions & 4 deletions L1Trigger/TrackFindingTracklet/src/MatchProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void MatchProcessor::execute() {

int projrinv = -1;
if (barrel_) {
projrinv = 16 + (proj->fpgarinv().value() >> (proj->fpgarinv().nbits() - 5));
projrinv = (1<<(NRINVBITS-1)) + (proj->fpgarinv().value() >> (proj->fpgarinv().nbits() - NRINVBITS));
} else {
//The next lines looks up the predicted bend based on:
// 1 - r projections
Expand All @@ -327,8 +327,9 @@ void MatchProcessor::execute() {

unsigned int slot = barrel_ ? proj->zbin1projvm(layer_) : proj->rbin1projvm(disk_);
bool second = (barrel_ ? proj->zbin2projvm(layer_) : proj->rbin2projvm(disk_));

unsigned int projfinephi = (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + 3))) & 7;

int nfinephi=3;
unsigned int projfinephi = (fpgaphi.value() >> (fpgaphi.nbits() - (nvmbits_ + nfinephi))) & ((1<<nfinephi)-1);
int projfinerz = barrel_ ? proj->finezvm(layer_) : proj->finervm(disk_);

bool isPSseed = proj->PSseed() == 1;
Expand Down Expand Up @@ -416,7 +417,7 @@ void MatchProcessor::execute() {
}

if (iMEbest != nMatchEngines_ && (!bestInPipeline)) {
std::pair<Tracklet*, const Stub*> candmatch = matchengines_[iMEbest].read();
const std::pair<Tracklet*, const Stub*>& candmatch = matchengines_[iMEbest].read();

const Stub* fpgastub = candmatch.second;
Tracklet* tracklet = candmatch.first;
Expand Down
66 changes: 33 additions & 33 deletions L1Trigger/TrackFindingTracklet/src/Sector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,33 +93,33 @@ bool Sector::addStub(L1TStub stub, string dtc) {

void Sector::addMem(string memType, string memName) {
if (memType == "InputLink:") {
addMemToVec(IL_, new InputLinkMemory(memName, settings_, isector_, phimin_, phimax_), memName);
addMemToVec(IL_, memName, settings_, isector_, phimin_, phimax_);
} else if (memType == "AllStubs:") {
addMemToVec(AS_, new AllStubsMemory(memName, settings_, isector_), memName);
addMemToVec(AS_, memName, settings_, isector_);
} else if (memType == "VMStubsTE:") {
addMemToVec(VMSTE_, new VMStubsTEMemory(memName, settings_, isector_), memName);
addMemToVec(VMSTE_, memName, settings_, isector_);
} else if (memType == "VMStubsME:") {
addMemToVec(VMSME_, new VMStubsMEMemory(memName, settings_, isector_), memName);
addMemToVec(VMSME_, memName, settings_, isector_);
} else if (memType == "StubPairs:" || memType == "StubPairsDisplaced:") {
addMemToVec(SP_, new StubPairsMemory(memName, settings_, isector_), memName);
addMemToVec(SP_, memName, settings_, isector_);
} else if (memType == "StubTriplets:") {
addMemToVec(ST_, new StubTripletsMemory(memName, settings_, isector_), memName);
addMemToVec(ST_, memName, settings_, isector_);
} else if (memType == "TrackletParameters:") {
addMemToVec(TPAR_, new TrackletParametersMemory(memName, settings_, isector_), memName);
addMemToVec(TPAR_, memName, settings_, isector_);
} else if (memType == "TrackletProjections:") {
addMemToVec(TPROJ_, new TrackletProjectionsMemory(memName, settings_, isector_), memName);
addMemToVec(TPROJ_, memName, settings_, isector_);
} else if (memType == "AllProj:") {
addMemToVec(AP_, new AllProjectionsMemory(memName, settings_, isector_), memName);
addMemToVec(AP_, memName, settings_, isector_);
} else if (memType == "VMProjections:") {
addMemToVec(VMPROJ_, new VMProjectionsMemory(memName, settings_, isector_), memName);
addMemToVec(VMPROJ_, memName, settings_, isector_);
} else if (memType == "CandidateMatch:") {
addMemToVec(CM_, new CandidateMatchMemory(memName, settings_, isector_), memName);
addMemToVec(CM_, memName, settings_, isector_);
} else if (memType == "FullMatch:") {
addMemToVec(FM_, new FullMatchMemory(memName, settings_, isector_), memName);
addMemToVec(FM_, memName, settings_, isector_);
} else if (memType == "TrackFit:") {
addMemToVec(TF_, new TrackFitMemory(memName, settings_, isector_, phimin_, phimax_), memName);
addMemToVec(TF_, memName, settings_, isector_, phimin_, phimax_);
} else if (memType == "CleanTrack:") {
addMemToVec(CT_, new CleanTrackMemory(memName, settings_, isector_, phimin_, phimax_), memName);
addMemToVec(CT_, memName, settings_, isector_, phimin_, phimax_);
} else {
edm::LogPrint("Tracklet") << "Don't know of memory type: " << memType;
exit(0);
Expand All @@ -128,34 +128,34 @@ void Sector::addMem(string memType, string memName) {

void Sector::addProc(string procType, string procName) {
if (procType == "VMRouter:") {
addProcToVec(VMR_, new VMRouter(procName, settings_, globals_, isector_), procName);
addProcToVec(VMR_, procName, settings_, globals_, isector_);
} else if (procType == "VMRouterCM:") {
addProcToVec(VMRCM_, new VMRouterCM(procName, settings_, globals_, isector_), procName);
addProcToVec(VMRCM_, procName, settings_, globals_, isector_);
} else if (procType == "TrackletEngine:") {
addProcToVec(TE_, new TrackletEngine(procName, settings_, globals_, isector_), procName);
addProcToVec(TE_, procName, settings_, globals_, isector_);
} else if (procType == "TrackletEngineDisplaced:") {
addProcToVec(TED_, new TrackletEngineDisplaced(procName, settings_, globals_, isector_), procName);
addProcToVec(TED_, procName, settings_, globals_, isector_);
} else if (procType == "TripletEngine:") {
addProcToVec(TRE_, new TripletEngine(procName, settings_, globals_, isector_), procName);
addProcToVec(TRE_, procName, settings_, globals_, isector_);
} else if (procType == "TrackletCalculator:") {
addProcToVec(TC_, new TrackletCalculator(procName, settings_, globals_, isector_), procName);
addProcToVec(TC_, procName, settings_, globals_, isector_);
} else if (procType == "TrackletProcessor:") {
addProcToVec(TP_, new TrackletProcessor(procName, settings_, globals_, isector_), procName);
addProcToVec(TP_, procName, settings_, globals_, isector_);
} else if (procType == "TrackletCalculatorDisplaced:") {
addProcToVec(TCD_, new TrackletCalculatorDisplaced(procName, settings_, globals_, isector_), procName);
addProcToVec(TCD_, procName, settings_, globals_, isector_);
} else if (procType == "ProjectionRouter:") {
addProcToVec(PR_, new ProjectionRouter(procName, settings_, globals_, isector_), procName);
addProcToVec(PR_, procName, settings_, globals_, isector_);
} else if (procType == "MatchEngine:") {
addProcToVec(ME_, new MatchEngine(procName, settings_, globals_, isector_), procName);
addProcToVec(ME_, procName, settings_, globals_, isector_);
} else if (procType == "MatchCalculator:" ||
procType == "DiskMatchCalculator:") { //TODO should not be used in configurations
addProcToVec(MC_, new MatchCalculator(procName, settings_, globals_, isector_), procName);
addProcToVec(MC_, procName, settings_, globals_, isector_);
} else if (procType == "MatchProcessor:") {
addProcToVec(MP_, new MatchProcessor(procName, settings_, globals_, isector_), procName);
addProcToVec(MP_, procName, settings_, globals_, isector_);
} else if (procType == "FitTrack:") {
addProcToVec(FT_, new FitTrack(procName, settings_, globals_, isector_), procName);
addProcToVec(FT_, procName, settings_, globals_, isector_);
} else if (procType == "PurgeDuplicate:") {
addProcToVec(PD_, new PurgeDuplicate(procName, settings_, globals_, isector_), procName);
addProcToVec(PD_, procName, settings_, globals_, isector_);
} else {
edm::LogPrint("Tracklet") << "Don't know of processing type: " << procType;
exit(0);
Expand Down Expand Up @@ -190,7 +190,7 @@ ProcessBase* Sector::getProc(string procName) {
auto it = Processes_.find(procName);

if (it != Processes_.end()) {
return it->second.get();
return it->second;
}
throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find process : " << procName << endl;
return nullptr;
Expand All @@ -200,7 +200,7 @@ MemoryBase* Sector::getMem(string memName) {
auto it = Memories_.find(memName);

if (it != Memories_.end()) {
return it->second.get();
return it->second;
}
throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find memory : " << memName;
return nullptr;
Expand Down Expand Up @@ -402,7 +402,7 @@ void Sector::executePD(std::vector<Track*>& tracks) {

std::vector<Tracklet*> Sector::getAllTracklets() const {
std::vector<Tracklet*> tmp;
for (auto tpar : TPAR_) {
for (auto& tpar : TPAR_) {
for (unsigned int j = 0; j < tpar->nTracklets(); j++) {
tmp.push_back(tpar->getTracklet(j));
}
Expand All @@ -413,7 +413,7 @@ std::vector<Tracklet*> Sector::getAllTracklets() const {
std::vector<const Stub*> Sector::getStubs() const {
std::vector<const Stub*> tmp;

for (auto imem : IL_) {
for (auto& imem : IL_) {
for (unsigned int istub = 0; istub < imem->nStubs(); istub++) {
tmp.push_back(imem->getStub(istub));
}
Expand All @@ -424,7 +424,7 @@ std::vector<const Stub*> Sector::getStubs() const {

std::unordered_set<int> Sector::seedMatch(int itp) const {
std::unordered_set<int> tmpSeeds;
for (auto i : TPAR_) {
for (auto& i : TPAR_) {
unsigned int nTracklet = i->nTracklets();
for (unsigned int j = 0; j < nTracklet; j++) {
if (i->getTracklet(j)->tpseed() == itp) {
Expand Down
Loading

0 comments on commit ca9f4d8

Please sign in to comment.