Skip to content

Commit

Permalink
All remaining review comments addressed (cms-sw#16)
Browse files Browse the repository at this point in the history
* Replaced vector size with empty function

* Simplified DegradeBend and StubWindowSuggest

* Fixed more review comments

* More review comments

* code reformat

* Ran exhaustive clang tidy
  • Loading branch information
tomalin authored May 18, 2020
1 parent 167d60a commit c35b410
Show file tree
Hide file tree
Showing 50 changed files with 687 additions and 579 deletions.
8 changes: 4 additions & 4 deletions L1Trigger/TrackFindingTMTT/interface/ChiSquaredFit4.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ namespace tmtt {
ChiSquaredFit4(const Settings* settings, const uint nPar);

protected:
TVectorD seed(const L1track3D& l1track3D);
TVectorD residuals(const TVectorD& x);
TMatrixD D(const TVectorD& x);
TMatrixD Vinv();
TVectorD seed(const L1track3D& l1track3D) override;
TVectorD residuals(const TVectorD& x) override;
TMatrixD D(const TVectorD& x) override;
TMatrixD Vinv() override;
};

} // namespace tmtt
Expand Down
2 changes: 1 addition & 1 deletion L1Trigger/TrackFindingTMTT/interface/ChiSquaredFitBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace tmtt {
public:
ChiSquaredFitBase(const Settings* settings, const uint nPar);

L1fittedTrack fit(const L1track3D& l1track3D);
L1fittedTrack fit(const L1track3D& l1track3D) override;

protected:
/* Methods */
Expand Down
25 changes: 12 additions & 13 deletions L1Trigger/TrackFindingTMTT/interface/DegradeBend.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef L1Trigger_TrackFindingTMTT_DegradeBend_h
#define L1Trigger_TrackFindingTMTT_DegradeBend_h

#include "L1Trigger/TrackFindingTMTT/interface/StubFEWindows.h"

#include "L1Trigger/TrackTrigger/interface/TTStubAlgorithm_official.h"
#include "DataFormats/DetId/interface/DetId.h"

#include <vector>
Expand All @@ -15,9 +18,8 @@ namespace tmtt {
* Implements reduced bits to encode stub bend information: 3 bits for PS, 4 bits for 2S, since the Tracker
* doesn't have the bandwidth to output the unreduced data from the FE electronics.
*
* This obtains the stub window sizes from a hard-wired copy of L1Trigger/TrackTrigger/python/TTStubAlgorithmRegister_cfi.py .
* Whenever these window sizes are so large that not all bend values allowed within them with the available bits,
* then it automatically encodes the bend values within these windows.
* This obtains the stub window sizes from L1Trigger/TrackTrigger/python/TTStubAlgorithmRegister_cfi.py ,
* which must be loaded into the cfg file (with the same params used originally to make the stubs).
*
* The TMTT L1 tracking code can optionally tighten these windows further (cfg option "KillLowPtStubs").
* This gives slightly more granular encoding with Pt > 3 GeV.
Expand All @@ -27,9 +29,10 @@ namespace tmtt {
*/

public:
DegradeBend(const TrackerTopology* trackerTopo) : theTrackerTopo_(trackerTopo) {}
typedef TTStubAlgorithm_official<Ref_Phase2TrackerDigi_> StubAlgorithmOfficial;

DegradeBend() {}
DegradeBend(const TrackerTopology* trackerTopo, const StubFEWindows* sw, const StubAlgorithmOfficial* stubAlgo)
: theTrackerTopo_(trackerTopo), sw_(sw), stubAlgo_(stubAlgo) {}

// Given the original bend, flag indicating if this is a PS or 2S module, & detector identifier,
// this return the degraded stub bend, a boolean indicatng if stub bend was outside the assumed window
Expand Down Expand Up @@ -60,15 +63,11 @@ namespace tmtt {
private:
const TrackerTopology* theTrackerTopo_;

// Number of bits used to encoded bend output by FE electronics.
const unsigned int bitsPS_ = 3;
const unsigned int bits2S_ = 4;

// Stub window sizes as encoded in L1Trigger/TrackTrigger/interface/TTStubAlgorithm_official.h
static const std::vector<double> barrelCut_;
static const std::vector<std::vector<double> > ringCut_;
static const std::vector<std::vector<double> > tiltedCut_;
static const std::vector<double> barrelNTilt_;
const StubFEWindows* sw_;

// TTStub produce algo used to make stubs.
const StubAlgorithmOfficial* stubAlgo_;
};

} // namespace tmtt
Expand Down
4 changes: 3 additions & 1 deletion L1Trigger/TrackFindingTMTT/interface/DupFitTrkKiller.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace tmtt {

class DupFitTrkKiller {
public:
enum class DupAlgoName { None = 0, Algo1 = 1, Algo2 = 2 };

/**
* Make available cfg parameters & specify which algorithm is to be used for duplicate track removal.
*/
Expand Down Expand Up @@ -50,7 +52,7 @@ namespace tmtt {

private:
const Settings* settings_; // Configuration parameters.
unsigned int dupTrkAlg_; // Specifies choice of algorithm for duplicate track removal.
DupAlgoName dupTrkAlg_; // Specifies choice of algorithm for duplicate track removal.
};

} // namespace tmtt
Expand Down
6 changes: 3 additions & 3 deletions L1Trigger/TrackFindingTMTT/interface/GlobalCacheTMTT.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ namespace tmtt {

namespace {
std::mutex myMutex;
}
}

class GlobalCacheTMTT {
public:
GlobalCacheTMTT(const edm::ParameterSet& iConfig)
: settings_(iConfig), // Python configuration params
htRphiErrMon_(), // rphi HT error monitoring
htRphiErrMon_(), // rphi HT error monitoring
stubWindowSuggest_(&settings_), // Recommend FE stub window sizes.
hists_(&settings_) // Histograms
{
Expand All @@ -46,7 +46,7 @@ namespace tmtt {
std::lock_guard<std::mutex> myGuard(myMutex);

// Only need one copy of tracker geometry for histogramming.
if (listTrackerModule_.size() == 0)
if (listTrackerModule_.empty())
listTrackerModule_ = list;
}

Expand Down
18 changes: 9 additions & 9 deletions L1Trigger/TrackFindingTMTT/interface/HTrphi.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace tmtt {
float phiCentreSector,
ErrorMonitor* errMon = nullptr);

~HTrphi() {}
~HTrphi() override {}

// Add stub to HT array.
// If eta subsectors are being used within each sector, specify which ones the stub is compatible with.
Expand All @@ -64,21 +64,21 @@ namespace tmtt {
// Get the values of the track helix params corresponding to middle of a specified HT cell (i,j).
// The helix parameters returned will be those corresponding to the two axes of the HT array.
// So they might be (q/pt, phi0) or (q/pt, phi65) etc. depending on the configuration.
std::pair<float, float> helix2Dhough(unsigned int i, unsigned int j) const;
std::pair<float, float> helix2Dhough(unsigned int i, unsigned int j) const override;

// Get the values of the track helix params corresponding to middle of a specified HT cell (i,j).
// The helix parameters returned will be always be (q/pt, phi0), irrespective of how the axes
// of the HT array are defined.
std::pair<float, float> helix2Dconventional(unsigned int i, unsigned int j) const;
std::pair<float, float> helix2Dconventional(unsigned int i, unsigned int j) const override;

// Which cell in HT array should this TP be in, based on its true trajectory?
// (If TP is outside HT array, it it put in the closest bin inside it).
std::pair<unsigned int, unsigned int> trueCell(const TP* tp) const;
std::pair<unsigned int, unsigned int> trueCell(const TP* tp) const override;

// Which cell in HT array should this fitted track be in, based on its fitted trajectory?
// Always uses beam-spot constrained trajectory if available.
// (If fitted track is outside HT array, it it put in the closest bin inside it).
std::pair<unsigned int, unsigned int> cell(const L1fittedTrack* fitTrk) const;
std::pair<unsigned int, unsigned int> cell(const L1fittedTrack* fitTrk) const override;

// Check if specified cell has been merged with its 2x2 neighbours into a single cell,
// as it is in low Pt region.
Expand All @@ -104,17 +104,17 @@ namespace tmtt {
unsigned int jPhiTrkBinMinLast,
unsigned int jPhiTrkBinMaxLast);

// Calculate maximum |gradient| that any stub's line across this HT array could have, so can check it doesn't exceed 1.
float calcMaxLineGradArray() const;
// Calculate line |gradient| of stubs in HT array, so can check it doesn't exceed 1.
float calcLineGradArray(float r) const;

// If requested, kill those tracks in this sector that can't be read out during the time-multiplexed period, because
// the HT has associated too many stubs to tracks.
std::list<L1track2D> killTracksBusySec(const std::list<L1track2D>& tracks) const;
std::list<L1track2D> killTracksBusySec(const std::list<L1track2D>& tracks) const override;

// Define the order in which the hardware processes rows of the HT array when it outputs track candidates.
// Currently corresponds to highest Pt tracks first.
// If two tracks have the same Pt, the -ve charge one is output before the +ve charge one.
std::vector<unsigned int> rowOrder(unsigned int numRows) const;
std::vector<unsigned int> rowOrder(unsigned int numRows) const override;

private:
float invPtToDphi_; // conversion constant.
Expand Down
4 changes: 4 additions & 0 deletions L1Trigger/TrackFindingTMTT/interface/InputData.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace tmtt {

class Settings;
class StubWindowSuggest;
class DegradeBend;

//=== Unpacks stub & tracking particle (truth) data into user-friendlier format in Stub & TP classes.
//=== Also makes B-field available to Settings class.
Expand All @@ -23,6 +24,7 @@ namespace tmtt {
const edm::EventSetup& iSetup,
const Settings* settings,
StubWindowSuggest* stubWindowSuggest,
const DegradeBend* degradeBend,
const TrackerGeometry* trackerGeometry,
const TrackerTopology* trackerTopology,
const std::list<TrackerModule>& listTrackerModule,
Expand Down Expand Up @@ -63,6 +65,8 @@ namespace tmtt {

// Recommends optimal FE stub window sizes.
StubWindowSuggest* stubWindowSuggest_;
// Degrades bend to allow for FE stub bend encoding.
const DegradeBend* degradeBend_;
};

} // namespace tmtt
Expand Down
33 changes: 21 additions & 12 deletions L1Trigger/TrackFindingTMTT/interface/KFParamsComb.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "L1Trigger/TrackFindingTMTT/interface/L1track3D.h"
#include "TMatrixD.h"

#include <vector>

///=== This is the Kalman Combinatorial Filter for 4 & 5 helix parameters track fit algorithm.
///=== All variable names & equations come from Fruhwirth KF paper
///=== http://dx.doi.org/10.1016/0168-9002%2887%2990887-4
Expand All @@ -13,35 +15,42 @@ namespace tmtt {

class KFParamsComb : public KFbase {
public:
KFParamsComb(const Settings* settings, const uint nPar, const std::string& fitterName)
: KFbase(settings, nPar, fitterName) {}
KFParamsComb(const Settings* settings, const uint nHelixPar, const std::string& fitterName);

virtual ~KFParamsComb() {}
~KFParamsComb() override {}

protected:
//--- Input data

// Seed track helix params & covariance matrix
virtual TVectorD seedX(const L1track3D& l1track3D) const;
virtual TMatrixD seedC(const L1track3D& l1track3D) const;
TVectorD seedX(const L1track3D& l1track3D) const override;
TMatrixD seedC(const L1track3D& l1track3D) const override;

// Stub coordinate measurements & resolution
virtual TVectorD vectorM(const Stub* stub) const;
virtual TMatrixD matrixV(const Stub* stub, const KalmanState* state) const;
TVectorD vectorM(const Stub* stub) const override;
TMatrixD matrixV(const Stub* stub, const KalmanState* state) const override;

//--- KF maths matrix multiplications

// Derivate of helix intercept point w.r.t. helix params.
virtual TMatrixD matrixH(const Stub* stub) const;
TMatrixD matrixH(const Stub* stub) const override;
// Kalman helix ref point extrapolation matrix
virtual TMatrixD matrixF(const Stub* stub, const KalmanState* state) const;
TMatrixD matrixF(const Stub* stub, const KalmanState* state) const override;

// Convert to physical helix params instead of local ones used by KF
virtual TVectorD trackParams(const KalmanState* state) const;
virtual TVectorD trackParams_BeamConstr(const KalmanState* state, double& chi2rphi) const;
TVectorD trackParams(const KalmanState* state) const override;
TVectorD trackParams_BeamConstr(const KalmanState* state, double& chi2rphi) const override;

// Does helix state pass cuts?
virtual bool isGoodState(const KalmanState& state) const;
bool isGoodState(const KalmanState& state) const override;

protected:
std::vector<double> kfLayerVsPtToler_;
std::vector<double> kfLayerVsD0Cut5_;
std::vector<double> kfLayerVsZ0Cut5_;
std::vector<double> kfLayerVsZ0Cut4_;
std::vector<double> kfLayerVsChiSq5_;
std::vector<double> kfLayerVsChiSq4_;
};

} // namespace tmtt
Expand Down
10 changes: 5 additions & 5 deletions L1Trigger/TrackFindingTMTT/interface/KFbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ namespace tmtt {

public:
// Initialize configuration
KFbase(const Settings *settings, const uint nPar, const std::string &fitterName = "", const uint nMeas = 2);
KFbase(const Settings *settings, const uint nHelixPar, const std::string &fitterName = "", const uint nMeas = 2);

virtual ~KFbase() { this->resetStates(); }
~KFbase() override { this->resetStates(); }

KFbase(const KFbase &kf) = delete; // Disable copy & move of this class.
KFbase(KFbase &&kf) = delete;
KFbase &operator=(const KFbase &kf) = delete;
KFbase &operator=(KFbase &&kf) = delete;

// Do KF fit
L1fittedTrack fit(const L1track3D &l1track3D);
L1fittedTrack fit(const L1track3D &l1track3D) override;

protected:
// Do KF fit (internal)
Expand Down Expand Up @@ -84,7 +84,7 @@ namespace tmtt {
// Derivate of helix intercept point w.r.t. helix params.
virtual TMatrixD matrixH(const Stub *stub) const = 0;
// Kalman helix ref point extrapolation matrix
virtual TMatrixD matrixF(const Stub *stub = 0, const KalmanState *state = 0) const = 0;
virtual TMatrixD matrixF(const Stub *stub = nullptr, const KalmanState *state = nullptr) const = 0;
// Product of H*C*H(transpose) (where C = helix covariance matrix)
TMatrixD matrixHCHt(const TMatrixD &h, const TMatrixD &c) const;
// Get inverted Kalman R matrix: inverse(V + HCHt)
Expand Down Expand Up @@ -150,7 +150,7 @@ namespace tmtt {
void printStubs(const std::vector<Stub *> &stubs) const;

protected:
unsigned nPar_;
unsigned nHelixPar_;
unsigned nMeas_;
unsigned numEtaRegions_;

Expand Down
9 changes: 0 additions & 9 deletions L1Trigger/TrackFindingTMTT/interface/KalmanState.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ namespace tmtt {
chi2rz_ = chi2rz;
}

// If using HLS, note/get additional output produced by HLS core.
//void setHLSselect(unsigned int mBinHelix, unsigned int cBinHelix, bool consistent) { mBinHelixHLS_ = mBinHelix; cBinHelixHLS_ = cBinHelix; consistentHLS_ = consistent;}
//void getHLSselect(unsigned int& mBinHelix, unsigned int& cBinHelix, bool& consistent) const { mBinHelix = mBinHelixHLS_; cBinHelix = cBinHelixHLS_; consistent = consistentHLS_;}

private:
const Settings *settings_;
int kLayer_;
Expand All @@ -104,11 +100,6 @@ namespace tmtt {
unsigned nSkipped_;
L1track3D l1track3D_;
unsigned int hitPattern_;

// Additional output from HLS if using it.
unsigned int mBinHelixHLS_;
unsigned int cBinHelixHLS_;
bool consistentHLS_;
};

} // namespace tmtt
Expand Down
Loading

0 comments on commit c35b410

Please sign in to comment.