Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled the TED and TRE tables by default. #47

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions L1Trigger/TrackFindingTracklet/interface/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ namespace trklet {

unsigned int writememsect() const { return writememsect_; }

bool enableTripletTables() const { return enableTripletTables_; }
bool writeTripletTables() const { return writeTripletTables_; }

bool writeoutReal() const { return writeoutReal_; }
Expand Down Expand Up @@ -238,6 +239,9 @@ namespace trklet {
std::string skimfile() const { return skimfile_; }
void setSkimfile(std::string skimfile) { skimfile_ = skimfile; }

unsigned int nbitstrackletindex() const { return nbitstrackletindex_; }
void setNbitstrackletindex(unsigned int nbitstrackletindex) { nbitstrackletindex_ = nbitstrackletindex; }

double dphisectorHG() const {
return 2 * M_PI / N_SECTOR +
2 * std::max(std::abs(asin(0.5 * rinvmax() * rmean(0)) - asin(0.5 * rinvmax() * rcrit_)),
Expand Down Expand Up @@ -282,7 +286,7 @@ namespace trklet {
unsigned int NLONGVMBITS() const { return NLONGVMBITS_; }
unsigned int NLONGVMBINS() const { return (1 << NLONGVMBITS_); }

unsigned int ntrackletmax() const { return ntrackletmax_; }
unsigned int ntrackletmax() const { return ((1 << nbitstrackletindex_) - 1); }

//Bits used to store track parameter in tracklet
int nbitsrinv() const { return nbitsrinv_; }
Expand Down Expand Up @@ -434,7 +438,7 @@ namespace trklet {

double ptcutte_{1.8}; //Minimum pt in TE

unsigned int ntrackletmax_{127}; //maximum number of tracklets that can be stored
unsigned int nbitstrackletindex_{7}; //Bits used to store the tracklet index

//Bits used to store track parameter in tracklet
int nbitsrinv_{14};
Expand Down Expand Up @@ -672,10 +676,13 @@ namespace trklet {

unsigned int writememsect_{3}; //writemem only for this sector (note that the files will have _4 extension)

bool writeTripletTables_{false}; //Train and write the TED and TRE tables. N.B.: the tables
//cannot be applied while they are being trained, i.e.,
//this flag effectively turns off the cuts in
//TrackletEngineDisplaced and TripletEngine
bool enableTripletTables_{false}; //Enable the application of the TED and
//TRE tables; when this flag is false,
//the tables will not be read from disk
bool writeTripletTables_{false}; //Train and write the TED and TRE tables. N.B.: the tables
//cannot be applied while they are being trained, i.e.,
//this flag effectively turns off the cuts in
//TrackletEngineDisplaced and TripletEngine

bool writeoutReal_{false};

Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/TrackFindingTracklet/interface/Tracklet.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,15 +489,15 @@ namespace trklet {
bool isOverlap() const { return overlap_; }
int isDisk() const { return disk_; }

void setTrackletIndex(int index);
void setTrackletIndex(unsigned int index);

int trackletIndex() const { return trackletIndex_; }

void setTCIndex(int index) { TCIndex_ = index; }

int TCIndex() const { return TCIndex_; }

int TCID() const { return TCIndex_ * (1 << 7) + trackletIndex_; }
int TCID() const { return TCIndex_ * (1 << settings_.nbitstrackletindex()) + trackletIndex_; }

int getISeed() const;
int getITC() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ namespace trklet {

void readTables();

const short memNameToIndex(const std::string& name);

private:
int layer1_;
int layer2_;
Expand All @@ -41,7 +43,7 @@ namespace trklet {

std::vector<StubPairsMemory*> stubpairs_;

std::vector<std::set<std::string> > table_;
std::vector<std::set<short> > table_;

int firstphibits_;
int secondphibits_;
Expand Down
5 changes: 5 additions & 0 deletions L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ L1FPGATrackProducer::L1FPGATrackProducer(edm::ParameterSet const& iConfig)
if (extended_) {
settings.setTableTEDFile(tableTEDFile.fullPath());
settings.setTableTREFile(tableTREFile.fullPath());

//FIXME: The TED and TRE tables are currently disabled by default, so we
//need to allow for the additional tracklets that will eventually be
//removed by these tables, once they are finalized
settings.setNbitstrackletindex(10);
}

eventnum = 0;
Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/TrackFindingTracklet/src/FitTrack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -826,15 +826,15 @@ std::vector<Tracklet*> FitTrack::orderedMatches(vector<FullMatchMemory*>& fullma

int bestIndex = -1;
do {
int bestTCID = (1 << 16);
int bestTCID = -1;
bestIndex = -1;
for (unsigned int i = 0; i < fullmatch.size(); i++) {
if (indexArray[i] >= fullmatch[i]->nMatches()) {
//skip as we were at the end
continue;
}
int TCID = fullmatch[i]->getTracklet(indexArray[i])->TCID();
if (TCID < bestTCID) {
if (TCID < bestTCID || bestTCID < 0) {
bestTCID = TCID;
bestIndex = i;
}
Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ std::vector<std::pair<std::pair<Tracklet*, int>, const Stub*> > MatchCalculator:
int bestIndex = -1;
do {
int bestSector = 100;
int bestTCID = (1 << 16);
int bestTCID = -1;
bestIndex = -1;
for (unsigned int i = 0; i < candmatch.size(); i++) {
if (indexArray[i] >= candmatch[i]->nMatches()) {
Expand All @@ -523,7 +523,7 @@ std::vector<std::pair<std::pair<Tracklet*, int>, const Stub*> > MatchCalculator:
bestIndex = i;
}
if (dSector == bestSector) {
if (TCID < bestTCID) {
if (TCID < bestTCID || bestTCID < 0) {
bestTCID = TCID;
bestIndex = i;
}
Expand Down
12 changes: 6 additions & 6 deletions L1Trigger/TrackFindingTracklet/src/Tracklet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ std::string Tracklet::trackletprojstr(int layer) const {
if (trackletIndex_ < 0 || trackletIndex_ > (int)settings_.ntrackletmax()) {
throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " trackletIndex_ = " << trackletIndex_;
}
tmp.set(trackletIndex_, 7, true, __LINE__, __FILE__);
tmp.set(trackletIndex_, settings_.nbitstrackletindex(), true, __LINE__, __FILE__);
FPGAWord tcid;
if (settings_.extended()) {
tcid.set(TCIndex_, 8, true, __LINE__, __FILE__);
Expand All @@ -294,7 +294,7 @@ std::string Tracklet::trackletprojstrD(int disk) const {
if (trackletIndex_ < 0 || trackletIndex_ > (int)settings_.ntrackletmax()) {
throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " trackletIndex_ = " << trackletIndex_;
}
tmp.set(trackletIndex_, 7, true, __LINE__, __FILE__);
tmp.set(trackletIndex_, settings_.nbitstrackletindex(), true, __LINE__, __FILE__);
FPGAWord tcid;
if (settings_.extended()) {
tcid.set(TCIndex_, 8, true, __LINE__, __FILE__);
Expand Down Expand Up @@ -379,7 +379,7 @@ std::string Tracklet::fullmatchstr(int layer) {
if (trackletIndex_ < 0 || trackletIndex_ > (int)settings_.ntrackletmax()) {
throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " trackletIndex_ = " << trackletIndex_;
}
tmp.set(trackletIndex_, 7, true, __LINE__, __FILE__);
tmp.set(trackletIndex_, settings_.nbitstrackletindex(), true, __LINE__, __FILE__);
FPGAWord tcid;
if (settings_.extended()) {
tcid.set(TCIndex_, 8, true, __LINE__, __FILE__);
Expand All @@ -398,7 +398,7 @@ std::string Tracklet::fullmatchdiskstr(int disk) {
if (trackletIndex_ < 0 || trackletIndex_ > (int)settings_.ntrackletmax()) {
throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " trackletIndex_ = " << trackletIndex_;
}
tmp.set(trackletIndex_, 7, true, __LINE__, __FILE__);
tmp.set(trackletIndex_, settings_.nbitstrackletindex(), true, __LINE__, __FILE__);
FPGAWord tcid;
if (settings_.extended()) {
tcid.set(TCIndex_, 8, true, __LINE__, __FILE__);
Expand Down Expand Up @@ -841,9 +841,9 @@ int Tracklet::disk2() const {
return innerStub_->disk() - 1;
}

void Tracklet::setTrackletIndex(int index) {
void Tracklet::setTrackletIndex(unsigned int index) {
trackletIndex_ = index;
assert(index < 128);
assert(index <= settings_.ntrackletmax());
}

int Tracklet::getISeed() const {
Expand Down
46 changes: 26 additions & 20 deletions L1Trigger/TrackFindingTracklet/src/TrackletEngineDisplaced.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ TrackletEngineDisplaced::TrackletEngineDisplaced(string name,

firstphibits_ = settings_.nfinephi(0, iSeed_);
secondphibits_ = settings_.nfinephi(1, iSeed_);

readTables();
}

TrackletEngineDisplaced::~TrackletEngineDisplaced() { table_.clear(); }
Expand Down Expand Up @@ -100,6 +98,9 @@ void TrackletEngineDisplaced::execute() {
if (!settings_.useSeed(iSeed_))
return;

if (table_.empty() && (settings_.enableTripletTables() && !settings_.writeTripletTables()))
readTables();

unsigned int countall = 0;
unsigned int countpass = 0;
unsigned int nInnerStubs = 0;
Expand Down Expand Up @@ -170,23 +171,21 @@ void TrackletEngineDisplaced::execute() {
index = (index << firstbend.nbits()) + firstbend.value();
index = (index << secondbend.nbits()) + secondbend.value();

if (index >= table_.size())
table_.resize(index + 1);

if (table_.at(index).empty()) {
if ((settings_.enableTripletTables() && !settings_.writeTripletTables()) &&
(index >= table_.size() || table_.at(index).empty())) {
if (settings_.debugTracklet()) {
edm::LogVerbatim("Tracklet") << "Stub pair rejected because of stub pt cut bends : "
<< benddecode(firstvmstub.bend().value(), firstvmstub.isPSmodule()) << " "
<< benddecode(secondvmstub.bend().value(), secondvmstub.isPSmodule());
}
if (!settings_.writeTripletTables())
continue;
continue;
}

if (settings_.debugTracklet())
edm::LogVerbatim("Tracklet") << "Adding layer-layer pair in " << getName();
for (unsigned int isp = 0; isp < stubpairs_.size(); ++isp) {
if (settings_.writeTripletTables() || table_.at(index).count(stubpairs_.at(isp)->getName())) {
if ((!settings_.enableTripletTables() || settings_.writeTripletTables()) ||
(index < table_.size() && table_.at(index).count(isp))) {
if (settings_.writeMonitorData("Seeds")) {
ofstream fout("seeds.txt", ofstream::app);
fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << iSeed_ << endl;
Expand Down Expand Up @@ -252,21 +251,21 @@ void TrackletEngineDisplaced::execute() {
index = (index << firstbend.nbits()) + firstbend.value();
index = (index << secondbend.nbits()) + secondbend.value();

if (index >= table_.size())
table_.resize(index + 1);

if (table_.at(index).empty()) {
if ((settings_.enableTripletTables() && !settings_.writeTripletTables()) &&
(index >= table_.size() || table_.at(index).empty())) {
if (settings_.debugTracklet()) {
edm::LogVerbatim("Tracklet") << "Stub pair rejected because of stub pt cut bends : "
<< benddecode(firstvmstub.bend().value(), firstvmstub.isPSmodule()) << " "
<< benddecode(secondvmstub.bend().value(), secondvmstub.isPSmodule());
}
continue;
}

if (settings_.debugTracklet())
edm::LogVerbatim("Tracklet") << "Adding layer-layer pair in " << getName();
for (unsigned int isp = 0; isp < stubpairs_.size(); ++isp) {
if (settings_.writeTripletTables() || table_.at(index).count(stubpairs_.at(isp)->getName()) || true) {
if ((!settings_.enableTripletTables() || settings_.writeTripletTables()) ||
(index < table_.size() && table_.at(index).count(isp))) {
if (settings_.writeMonitorData("Seeds")) {
ofstream fout("seeds.txt", ofstream::app);
fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << iSeed_ << endl;
Expand Down Expand Up @@ -332,22 +331,22 @@ void TrackletEngineDisplaced::execute() {
index = (index << firstbend.nbits()) + firstbend.value();
index = (index << secondbend.nbits()) + secondbend.value();

if (index >= table_.size())
table_.resize(index + 1);

if (table_.at(index).empty()) {
if ((settings_.enableTripletTables() && !settings_.writeTripletTables()) &&
(index >= table_.size() || table_.at(index).empty())) {
if (settings_.debugTracklet()) {
edm::LogVerbatim("Tracklet") << "Stub pair rejected because of stub pt cut bends : "
<< benddecode(firstvmstub.bend().value(), firstvmstub.isPSmodule()) << " "
<< benddecode(secondvmstub.bend().value(), secondvmstub.isPSmodule());
}
continue;
}

if (settings_.debugTracklet())
edm::LogVerbatim("Tracklet") << "Adding disk-disk pair in " << getName();

for (unsigned int isp = 0; isp < stubpairs_.size(); ++isp) {
if (settings_.writeTripletTables() || table_.at(index).count(stubpairs_.at(isp)->getName()) || true) {
if ((!settings_.enableTripletTables() || settings_.writeTripletTables()) ||
(index < table_.size() && table_.at(index).count(isp))) {
if (settings_.writeMonitorData("Seeds")) {
ofstream fout("seeds.txt", ofstream::app);
fout << __FILE__ << ":" << __LINE__ << " " << name_ << "_" << iSector_ << " " << iSeed_ << endl;
Expand Down Expand Up @@ -408,7 +407,14 @@ void TrackletEngineDisplaced::readTables() {
table_.resize(table_.size() + 1);

while (iss >> word)
table_[table_.size() - 1].insert(word);
table_[table_.size() - 1].insert(memNameToIndex(word));
}
fin.close();
}

const short TrackletEngineDisplaced::memNameToIndex(const string& name) {
for (unsigned int isp = 0; isp < stubpairs_.size(); ++isp)
if (stubpairs_.at(isp)->getName() == name)
return isp;
return -1;
}
Loading