Skip to content

Commit

Permalink
Ian tidy up (#137)
Browse files Browse the repository at this point in the history
* Added function to convert ATCA slot to DTC name

* Moved dtcname to Settings.h and put underscore at end of settings

* Declared functions const if dont change data members

* Added comments to clarify params overridden by python cfg

* Added comment

* Removed duplicate function TCNAme
  • Loading branch information
tomalin committed Jul 8, 2022
1 parent 4503a95 commit 6b3e25a
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 94 deletions.
22 changes: 16 additions & 6 deletions L1Trigger/TrackFindingTracklet/interface/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ namespace trklet {
return bendcut;
}

// DTC in given ATCA crate slot.
std::string slotToDTCname(unsigned int slot) const {return slotToDTCname_.at(slot);}

// Tracker layers read by given DTC.
const std::vector<int>& dtcLayers(const std::string& dtcName) const {
auto iter = dtclayers_.find(dtcName);
assert(iter != dtclayers_.end());
Expand Down Expand Up @@ -497,6 +501,8 @@ namespace trklet {
{{3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2}},
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1}}}};

std::vector<std::string> slotToDTCname_{"PS10G_1","PS10G_2","PS10G_3","PS10G_4","PS_1","PS_2","2S_1","2S_2","2S_3","2S_4","2S_5","2S_6"};

std::map<std::string, std::vector<int> > dtclayers_{{"PS10G_1", {0, 6, 8, 10}},
{"PS10G_2", {0, 7, 9}},
{"PS10G_3", {1, 7}},
Expand Down Expand Up @@ -540,6 +546,7 @@ namespace trklet {

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

// VALUE AUTOMATICALLY INCREASED FOR EXTENDED TRACKING BY PYTHON CFG
unsigned int nbitstrackletindex_{7}; //Bits used to store the tracklet index

unsigned int nbitsitc_{4}; //Bits used to store the iTC, a unique
Expand Down Expand Up @@ -892,36 +899,39 @@ namespace trklet {
unsigned int minIndStubs_{3}; // not used with merge removal

#ifdef USEHYBRID
// Duplicate track removal algo. VALUE HERE OVERRIDDEN BY PYTHON CFG
std::string removalType_{"merge"};
// "CompareBest" (recommended) Compares only the best stub in each track for each region (best = smallest phi residual)
// and will merge the two tracks if stubs are shared in three or more regions
// "CompareAll" Compares all stubs in a region, looking for matches, and will merge the two tracks if stubs are shared in three or more regions
std::string mergeComparison_{"CompareBest"};
bool doKF_{true};
#endif

#ifndef USEHYBRID
bool doKF_{false};
#else
std::string removalType_{"ichi"};
std::string mergeComparison_{""};
bool doKF_{false};
#endif

// VALUE OVERRIDDEN BY PYTHON CFG
// When false, match calculator does not save multiple matches, even when doKF=true.
// This is a temporary fix for compatibilty with HLS. We will need to implement multiple match
// printing in emulator eventually, possibly after CMSSW-integration inspired rewrites
// Use false when generating HLS files, use true when doing full hybrid tracking
bool doMultipleMatches_{true};

// NEXT 2 VALUES OVERRIDDEN BY PYTHON CFG
// if true, run a dummy fit, producing TTracks directly from output of tracklet pattern reco stage
bool fakefit_{false};
// if true EDProducer fills additionaly bit and clock accurate TrackBuilder EDProduct
// if true, EDProducer fills additional bit & clock accurate TrackBuilder EDProduct
bool storeTrackBuilderOutput_{false};

// NEXT 3 VALUES OVERRIDDEN BY PYTHON CFG
unsigned int nHelixPar_{4}; // 4 or 5 param helix fit
bool extended_{false}; // turn on displaced tracking
bool combined_{false}; // use combined TP (TE+TC) and MP (PR+ME+MC) configuration
bool reduced_{false}; // use reduced (Summer Chain) config

bool combined_{false}; // use combined TP (TE+TC) and MP (PR+ME+MC) configuration

std::string skimfile_{""}; //if not empty events will be written out in ascii format to this file

double bfield_{3.8112}; //B-field in T
Expand Down
40 changes: 19 additions & 21 deletions L1Trigger/TrackFindingTracklet/interface/TrackletConfigBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@ namespace trklet {
//

//Seed string, eg. L1L2
std::string iSeedStr(unsigned int iSeed);
std::string iSeedStr(unsigned int iSeed) const;

//Return unsigned as string
static std::string numStr(unsigned int i);

//Retunr iTC as string - ie A, B, C, etc
std::string iTCStr(unsigned int iTC);
//Return iTC as string - ie A, B, C, etc
std::string iTCStr(unsigned int iTC) const;

//The region string A, B, C etc for layers and disks; X, Y, Z etc for overlap
std::string iRegStr(unsigned int iReg, unsigned int iSeed);
std::string iRegStr(unsigned int iReg, unsigned int iSeed) const;

//TC Name
std::string TCName(unsigned int iSeed, unsigned int iTC);
std::string TCName(unsigned int iSeed, unsigned int iTC) const;

//Name of layer or disk, e.g. L1 or D1
static std::string LayerName(unsigned int ilayer);

//Tracklet projection name
std::string TPROJName(unsigned int iSeed, unsigned int iTC, unsigned int ilayer, unsigned int ireg);
std::string TPROJName(unsigned int iSeed, unsigned int iTC, unsigned int ilayer, unsigned int ireg) const;

//Projection router name
std::string PRName(unsigned int ilayer, unsigned int ireg);
std::string PRName(unsigned int ilayer, unsigned int ireg) const;

private:
//
Expand Down Expand Up @@ -113,7 +113,7 @@ namespace trklet {
unsigned int l2,
unsigned int ireg2,
unsigned int ivm2,
unsigned int iseed);
unsigned int iseed) const;

//StubPaur displaced name
std::string SPDName(unsigned int l1,
Expand All @@ -125,7 +125,7 @@ namespace trklet {
unsigned int l3,
unsigned int ireg3,
unsigned int ivm3,
unsigned int iseed);
unsigned int iseed) const;

//Stub Triplet name
std::string STName(unsigned int l1,
Expand All @@ -135,7 +135,7 @@ namespace trklet {
unsigned int l3,
unsigned int ireg3,
unsigned int iseed,
unsigned int count);
unsigned int count) const;

//TrackletEngine name
std::string TEName(unsigned int l1,
Expand All @@ -144,15 +144,15 @@ namespace trklet {
unsigned int l2,
unsigned int ireg2,
unsigned int ivm2,
unsigned int iseed);
unsigned int iseed) const;

//Triplet engine name
std::string TREName(unsigned int l1,
unsigned int ireg1,
unsigned int l2,
unsigned int ireg2,
unsigned int iseed,
unsigned int count);
unsigned int count) const;

//TrackletEngine displaced name
std::string TEDName(unsigned int l1,
Expand All @@ -161,27 +161,24 @@ namespace trklet {
unsigned int l2,
unsigned int ireg2,
unsigned int ivm2,
unsigned int iseed);
unsigned int iseed) const;

//Tracklet parameter memory name
std::string TParName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc);
std::string TParName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc) const;

//TrackletCalculator displaced name
std::string TCDName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc);
std::string TCDName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc) const;

//TrackletProjection name
std::string TPROJName(unsigned int l1,
unsigned int l2,
unsigned int l3,
unsigned int itc,
unsigned int projlay,
unsigned int projreg);
unsigned int projreg) const;

//FitTrack module name
std::string FTName(unsigned int l1, unsigned int l2, unsigned int l3);

//TrackletCalculator name
std::string TCNAme(unsigned int iseed, unsigned int iTC);
std::string FTName(unsigned int l1, unsigned int l2, unsigned int l3) const;

//
// This group of methods are used to print out the configuration as a file
Expand Down Expand Up @@ -213,8 +210,9 @@ namespace trklet {
void writeILMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);

//
// Store constants extracted from Settings
//--- Store constants extracted from Settings
//

unsigned int NSector_; //Number of sectors
double rcrit_; //critical radius that defines the sector

Expand Down
74 changes: 34 additions & 40 deletions L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class L1FPGATrackProducer : public edm::one::EDProducer<edm::one::WatchRuns> {
std::ofstream asciiEventOut_;

// settings containing various constants for the tracklet processing
trklet::Settings settings;
trklet::Settings settings_;

// event processor for the tracklet track finding
trklet::TrackletEventProcessor eventProcessor;
Expand Down Expand Up @@ -268,36 +268,36 @@ L1FPGATrackProducer::L1FPGATrackProducer(edm::ParameterSet const& iConfig)
// set options in Settings based on inputs from configuration files
// --------------------------------------------------------------------------------

settings.setExtended(extended_);
settings.setReduced(reduced_);
settings.setNHelixPar(nHelixPar_);
settings_.setExtended(extended_);
settings_.setReduced(reduced_);
settings_.setNHelixPar(nHelixPar_);

settings.setFitPatternFile(fitPatternFile.fullPath());
settings.setProcessingModulesFile(processingModulesFile.fullPath());
settings.setMemoryModulesFile(memoryModulesFile.fullPath());
settings.setWiresFile(wiresFile.fullPath());
settings_.setFitPatternFile(fitPatternFile.fullPath());
settings_.setProcessingModulesFile(processingModulesFile.fullPath());
settings_.setMemoryModulesFile(memoryModulesFile.fullPath());
settings_.setWiresFile(wiresFile.fullPath());

settings.setFakefit(iConfig.getParameter<bool>("Fakefit"));
settings.setStoreTrackBuilderOutput(iConfig.getParameter<bool>("StoreTrackBuilderOutput"));
settings.setRemovalType(iConfig.getParameter<string>("RemovalType"));
settings.setDoMultipleMatches(iConfig.getParameter<bool>("DoMultipleMatches"));
settings_.setFakefit(iConfig.getParameter<bool>("Fakefit"));
settings_.setStoreTrackBuilderOutput(iConfig.getParameter<bool>("StoreTrackBuilderOutput"));
settings_.setRemovalType(iConfig.getParameter<string>("RemovalType"));
settings_.setDoMultipleMatches(iConfig.getParameter<bool>("DoMultipleMatches"));

if (extended_) {
settings.setTableTEDFile(tableTEDFile.fullPath());
settings.setTableTREFile(tableTREFile.fullPath());
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);
settings_.setNbitstrackletindex(10);
}

eventnum = 0;
if (not asciiEventOutName_.empty()) {
asciiEventOut_.open(asciiEventOutName_.c_str());
}

if (settings.debugTracklet()) {
if (settings_.debugTracklet()) {
edm::LogVerbatim("Tracklet") << "fit pattern : " << fitPatternFile.fullPath()
<< "\n process modules : " << processingModulesFile.fullPath()
<< "\n memory modules : " << memoryModulesFile.fullPath()
Expand All @@ -312,12 +312,12 @@ L1FPGATrackProducer::L1FPGATrackProducer(edm::ParameterSet const& iConfig)
if (trackQuality_) {
trackQualityModel_ = std::make_unique<L1TrackQuality>(iConfig.getParameter<edm::ParameterSet>("TrackQualityPSet"));
}
if (settings.storeTrackBuilderOutput() && (settings.doMultipleMatches() || settings.removalType() != "")) {
if (settings_.storeTrackBuilderOutput() && (settings_.doMultipleMatches() || settings_.removalType() != "")) {
cms::Exception exception("ConfigurationNotSupported.");
exception.addContext("L1FPGATrackProducer::produce");
if (settings.doMultipleMatches())
if (settings_.doMultipleMatches())
exception << "Storing of TrackBuilder output does not support doMultipleMatches.";
if (settings.removalType() != "")
if (settings_.removalType() != "")
exception << "Storing of TrackBuilder output does not support duplicate removal.";
throw exception;
}
Expand All @@ -342,12 +342,12 @@ void L1FPGATrackProducer::beginRun(const edm::Run& run, const edm::EventSetup& i
// GET MAGNETIC FIELD //
const MagneticField* theMagneticField = &iSetup.getData(magneticFieldToken_);
double mMagneticFieldStrength = theMagneticField->inTesla(GlobalPoint(0, 0, 0)).z();
settings.setBfield(mMagneticFieldStrength);
settings_.setBfield(mMagneticFieldStrength);

setup_ = iSetup.getData(esGetToken_);
channelAssignment_ = &iSetup.getData(esGetTokenChannelAssignment_);
// initialize the tracklet event processing (this sets all the processing & memory modules, wiring, etc)
eventProcessor.init(settings, channelAssignment_);
eventProcessor.init(settings_, channelAssignment_);
}

//////////
Expand Down Expand Up @@ -442,20 +442,14 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
/// READ DTC STUB INFORMATION ///
/////////////////////////////////

// Process stubs in each region and channel within that region
// Process stubs in each region and channel within that tracking region
for (const int& region : handleDTC->tfpRegions()) {
for (const int& channel : handleDTC->tfpChannels()) {
// Get the DTC name form the channel

static string dtcbasenames[12] = {
"PS10G_1", "PS10G_2", "PS10G_3", "PS10G_4", "PS_1", "PS_2", "2S_1", "2S_2", "2S_3", "2S_4", "2S_5", "2S_6"};

string dtcname = dtcbasenames[channel % 12];

if (channel % 24 >= 12)
dtcname = "neg" + dtcname;

dtcname += (channel < 24) ? "_A" : "_B";
unsigned int atcaSlot = channel % 12;
string dtcname = settings_.slotToDTCname(atcaSlot);
if (channel % 24 >= 12) dtcname = "neg" + dtcname;
dtcname += (channel < 24) ? "_A" : "_B"; // which detector region

// Get the stubs from the DTC
const tt::StreamStub& streamFromDTC{handleDTC->stream(region, channel)};
Expand Down Expand Up @@ -607,11 +601,11 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
ntracks++;

// this is where we create the TTTrack object
double tmp_rinv = track.rinv(settings);
double tmp_phi = track.phi0(settings);
double tmp_tanL = track.tanL(settings);
double tmp_z0 = track.z0(settings);
double tmp_d0 = track.d0(settings);
double tmp_rinv = track.rinv(settings_);
double tmp_phi = track.phi0(settings_);
double tmp_tanL = track.tanL(settings_);
double tmp_z0 = track.z0(settings_);
double tmp_d0 = track.d0(settings_);
double tmp_chi2rphi = track.chisqrphi();
double tmp_chi2rz = track.chisqrz();
unsigned int tmp_hit = track.hitpattern();
Expand All @@ -627,8 +621,8 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
0,
0,
tmp_hit,
settings.nHelixPar(),
settings.bfield());
settings_.nHelixPar(),
settings_.bfield());

unsigned int trksector = track.sector();
unsigned int trkseed = (unsigned int)abs(track.seed());
Expand Down Expand Up @@ -656,7 +650,7 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe

// pt consistency
aTrack.setStubPtConsistency(
StubPtConsistency::getConsistency(aTrack, theTrackerGeom, tTopo, settings.bfield(), settings.nHelixPar()));
StubPtConsistency::getConsistency(aTrack, theTrackerGeom, tTopo, settings_.bfield(), settings_.nHelixPar()));

// set TTTrack word
aTrack.setTrackWordBits();
Expand Down
Loading

0 comments on commit 6b3e25a

Please sign in to comment.