Skip to content

Commit

Permalink
Add beam constraint to extended tracking (#75)
Browse files Browse the repository at this point in the history
* add beam spot constraint flag to save new bcon values

* add check on scaled chi2 value after beam constraint

* get rid of code duplication

* include comment on kalmanAddBeamConstr_ boolean

* take out unecessary function
  • Loading branch information
cgsavard authored and skinnari committed Jun 22, 2021
1 parent 4b244a9 commit 2e2faca
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 49 deletions.
26 changes: 12 additions & 14 deletions L1Trigger/TrackFindingTMTT/interface/KFTrackletTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ namespace tmtt {
unsigned int nHelixParam,
unsigned int iPhiSec,
unsigned int iEtaReg,
bool accepted = true)
bool accepted = true,
bool done_bcon = false,
float qOverPt_bcon = 0.,
float d0_bcon = 0.,
float phi0_bcon = 0.,
float chi2rphi_bcon = 0.)
: l1track3D_(l1track3D),
stubs_(stubs),
hitPattern_(hitPattern),
Expand All @@ -56,11 +61,11 @@ namespace tmtt {
tanLambda_(tanLambda),
chi2rphi_(chi2rphi),
chi2rz_(chi2rz),
done_bcon_(false),
qOverPt_bcon_(qOverPt),
d0_bcon_(d0),
phi0_bcon_(phi0),
chi2rphi_bcon_(chi2rphi),
done_bcon_(done_bcon),
qOverPt_bcon_(qOverPt_bcon),
d0_bcon_(d0_bcon),
phi0_bcon_(phi0_bcon),
chi2rphi_bcon_(chi2rphi_bcon),
nHelixParam_(nHelixParam),
iPhiSec_(iPhiSec),
iEtaReg_(iEtaReg),
Expand All @@ -70,14 +75,6 @@ namespace tmtt {
numIterations_(0),
accepted_(accepted) {}

//--- Optionally std::set track helix params & chi2 if beam-spot constraint is used (for 5-parameter fit).
void setBeamConstr(float qOverPt_bcon, float phi0_bcon, float chi2rphi_bcon) {
done_bcon_ = true;
qOverPt_bcon_ = qOverPt_bcon;
d0_bcon_ = 0.0, phi0_bcon_ = phi0_bcon;
chi2rphi_bcon_ = chi2rphi_bcon;
}

//--- Set/get additional info about fitted track that is specific to individual track fit algorithms (KF, LR, chi2)
//--- and is used for debugging/histogramming purposes.

Expand Down Expand Up @@ -131,6 +128,7 @@ namespace tmtt {
float invPt_bcon() const { return std::abs(qOverPt_bcon_); }
float pt_bcon() const { return 1. / (1.0e-6 + this->invPt_bcon()); }
float phi0_bcon() const { return phi0_bcon_; }
float d0_bcon() const { return d0_bcon_; }

// Phi and z coordinates at which track crosses "chosenR" values used by r-phi HT and rapidity sectors respectively.
// (Optionally with beam-spot constraint applied).
Expand Down
11 changes: 9 additions & 2 deletions L1Trigger/TrackFindingTMTT/interface/L1fittedTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ namespace tmtt {
~L1fittedTrack() override = default;

//--- Optionally std::set track helix params & chi2 if beam-spot constraint is used (for 5-parameter fit).
void setBeamConstr(float qOverPt_bcon, float phi0_bcon, float chi2rphi_bcon) {
void setBeamConstr(float qOverPt_bcon, float phi0_bcon, float chi2rphi_bcon, bool accepted) {
done_bcon_ = true;
qOverPt_bcon_ = qOverPt_bcon;
d0_bcon_ = 0.0, phi0_bcon_ = phi0_bcon;
chi2rphi_bcon_ = chi2rphi_bcon;
accepted_ = accepted;
}

//--- Set/get additional info about fitted track that is specific to individual track fit algorithms (KF, LR, chi2)
Expand Down Expand Up @@ -161,7 +162,12 @@ namespace tmtt {
nHelixParam(),
iPhiSec(),
iEtaReg(),
accepted());
accepted(),
done_bcon(),
qOverPt_bcon(),
d0_bcon(),
phi0_bcon(),
chi2rphi_bcon());
return trk_;
}

Expand Down Expand Up @@ -247,6 +253,7 @@ namespace tmtt {
return 1. / (small + this->invPt_bcon());
}
float phi0_bcon() const { return phi0_bcon_; }
float d0_bcon() const { return d0_bcon_; }

// Phi and z coordinates at which track crosses "chosenR" values used by r-phi HT and rapidity sectors respectively.
// (Optionally with beam-spot constraint applied).
Expand Down
10 changes: 9 additions & 1 deletion L1Trigger/TrackFindingTMTT/src/KFbase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ namespace tmtt {
if (nHelixPar_ == 5) {
double chi2rphi_bcon = 0.;
TVectorD trackPars_bcon = trackParams_BeamConstr(cand, chi2rphi_bcon);
fitTrk.setBeamConstr(trackPars_bcon[QOVERPT], trackPars_bcon[PHI0], chi2rphi_bcon);

// Check scaled chi2 cut
vector<double> kfLayerVsChiSqCut = settings_->kfLayerVsChiSq5();
double chi2scaled = chi2rphi_bcon / settings_->kalmanChi2RphiScale() + fitTrk.chi2rz();
bool accepted = true;
if (chi2scaled > kfLayerVsChiSqCut[cand->nStubLayers()])
accepted = false;

fitTrk.setBeamConstr(trackPars_bcon[QOVERPT], trackPars_bcon[PHI0], chi2rphi_bcon, accepted);
}
}

Expand Down
1 change: 1 addition & 0 deletions L1Trigger/TrackFindingTMTT/src/Settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace tmtt {
//kalmanDebugLevel_(2), // Good for debugging
kalmanMinNumStubs_(4),
kalmanMaxNumStubs_(6),
kalmanAddBeamConstr_(false), // Apply post-fit beam-spot constraint to 5-param fit
kalmanRemove2PScut_(true),
kalmanMaxSkipLayersHard_(1), // On "hard" input tracks
kalmanMaxSkipLayersEasy_(2), // On "easy" input tracks
Expand Down
71 changes: 39 additions & 32 deletions L1Trigger/TrackFindingTracklet/src/HybridFit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,29 @@ void HybridFit::Fit(Tracklet* tracklet, std::vector<const Stub*>& trackstublist)
<< ", phi0 = " << trk.phi0() << ", eta = " << trk.eta() << ", z0 = " << trk.z0()
<< ", chi2 = " << trk.chi2() << ", accepted = " << trk.accepted();

// Tracklet wants phi0 with respect to lower edge of sector, not global phi0.
double phi0fit = reco::reduceRange(trk.phi0() - iSector_ * 2 * M_PI / N_SECTOR + 0.5 * settings_.dphisectorHG());
double d0,chi2rphi,phi0,qoverpt = -999;
if (trk.done_bcon()) {
d0 = trk.d0_bcon();
chi2rphi = trk.chi2rphi_bcon();
phi0 = trk.phi0_bcon();
qoverpt = trk.qOverPt_bcon();
} else if (!trk.done_bcon()) {
d0 = trk.d0();
chi2rphi = trk.chi2rphi();
phi0 = trk.phi0();
qoverpt = trk.qOverPt();
}

double rinvfit = 0.01 * settings_.c() * settings_.bfield() * trk.qOverPt();
// Tracklet wants phi0 with respect to lower edge of sector, not global phi0.
double phi0fit = reco::reduceRange(phi0 - iSector_ * 2 * M_PI / N_SECTOR + 0.5 * settings_.dphisectorHG());
double rinvfit = 0.01 * settings_.c() * settings_.bfield() * qoverpt;

int irinvfit = rinvfit / settings_.krinvpars();
int iphi0fit = phi0fit / settings_.kphi0pars();
int itanlfit = trk.tanLambda() / settings_.ktpars();
int iz0fit = trk.z0() / settings_.kz0pars();
int id0fit = trk.d0() / settings_.kd0pars();
int ichi2rphifit = trk.chi2rphi() / 16;
int id0fit = d0 / settings_.kd0pars();
int ichi2rphifit = chi2rphi / 16;
int ichi2rzfit = trk.chi2rz() / 16;

const vector<const tmtt::Stub*>& stubsFromFit = trk.stubs();
Expand All @@ -216,34 +228,29 @@ void HybridFit::Fit(Tracklet* tracklet, std::vector<const Stub*>& trackstublist)
l1stubsFromFit.push_back(l1s);
}

if (settings_.printDebugKF()) {
edm::LogVerbatim("L1track") << "#stubs before/after KF fit = " << TMTTstubs.size() << "/"
<< l1stubsFromFit.size();
}

tracklet->setFitPars(rinvfit,
phi0fit,
trk.d0(),
trk.tanLambda(),
trk.z0(),
trk.chi2rphi(),
trk.chi2rz(),
rinvfit,
phi0fit,
trk.d0(),
trk.tanLambda(),
trk.z0(),
trk.chi2rphi(),
trk.chi2rz(),
irinvfit,
iphi0fit,
id0fit,
itanlfit,
iz0fit,
ichi2rphifit,
ichi2rzfit,
trk.hitPattern(),
l1stubsFromFit);
phi0fit,
d0,
trk.tanLambda(),
trk.z0(),
chi2rphi,
trk.chi2rz(),
rinvfit,
phi0fit,
d0,
trk.tanLambda(),
trk.z0(),
chi2rphi,
trk.chi2rz(),
irinvfit,
iphi0fit,
id0fit,
itanlfit,
iz0fit,
ichi2rphifit,
ichi2rzfit,
trk.hitPattern(),
l1stubsFromFit);
} else {
if (settings_.printDebugKF()) {
edm::LogVerbatim("L1track") << "FitTrack:KF rejected track";
Expand Down

0 comments on commit 2e2faca

Please sign in to comment.