CMS 3D CMS Logo

KFTrackletTrack.h
Go to the documentation of this file.
1 #ifndef L1Trigger_TrackFindingTMTT_KFTrackletTrack_h
2 #define L1Trigger_TrackFindingTMTT_KFTrackletTrack_h
3 
12 
13 #include <vector>
14 #include <utility>
15 #include <string>
16 
17 //=== This is used uniquely for HYBRID TRACKING.
18 //=== It is the equivalent of class L1fittedTrack.
19 //===
20 //=== This represents a fitted L1 track candidate found in 3 dimensions.
21 //=== It gives access to the fitted helix parameters & chi2 etc.
22 //=== It also calculates & gives access to associated truth particle (Tracking Particle) if any.
23 //=== It also gives access to the 3D hough-transform track candidate (L1track3D) on which the fit was run.
24 
25 namespace tmtt {
26 
28  public:
29  // Store a new fitted track, specifying the input Hough transform track, the stubs used for the fit,
30  // bit-encoded hit layers,
31  // the fitted helix parameters & chi2,
32  // and the number of helix parameters being fitted (=5 if d0 is fitted, or =4 if d0 is not fitted).
33  // Also specify phi sector and eta region used by track-finding code that this track was in.
34  // And if track fit declared this to be a valid track (enough stubs left on track after fit etc.).
36  const std::vector<const Stub*>& stubs,
37  unsigned int hitPattern,
38  float qOverPt,
39  float d0,
40  float phi0,
41  float z0,
42  float tanLambda,
43  float chi2rphi,
44  float chi2rz,
45  unsigned int nHelixParam,
46  unsigned int iPhiSec,
47  unsigned int iEtaReg,
48  bool accepted = true)
50  stubs_(stubs),
53  d0_(d0),
54  phi0_(phi0),
55  z0_(z0),
58  chi2rz_(chi2rz),
61  d0_bcon_(d0),
68  nSkippedLayers_(0),
69  numUpdateCalls_(0),
70  numIterations_(0),
72 
73  //--- Optionally std::set track helix params & chi2 if beam-spot constraint is used (for 5-parameter fit).
74  void setBeamConstr(float qOverPt_bcon, float phi0_bcon, float chi2rphi_bcon) {
75  done_bcon_ = true;
77  d0_bcon_ = 0.0, phi0_bcon_ = phi0_bcon;
79  }
80 
81  //--- Set/get additional info about fitted track that is specific to individual track fit algorithms (KF, LR, chi2)
82  //--- and is used for debugging/histogramming purposes.
83 
84  void setInfoKF(unsigned int nSkippedLayers, unsigned int numUpdateCalls) {
85  nSkippedLayers_ = nSkippedLayers;
86  numUpdateCalls_ = numUpdateCalls;
87  }
88 
89  void infoKF(unsigned int& nSkippedLayers, unsigned int& numUpdateCalls) const {
90  nSkippedLayers = nSkippedLayers_;
91  numUpdateCalls = numUpdateCalls_;
92  }
93 
94  const L1track3D* l1track3D() const { return l1track3D_; }
95 
96  // Get stubs on fitted track (can differ from those on HT track if track fit kicked out stubs with bad residuals)
97  const std::vector<const Stub*>& stubs() const { return stubs_; }
98  // Get number of stubs on fitted track.
99  unsigned int numStubs() const { return stubs_.size(); }
100  // Get number of tracker layers these stubs are in.
101  unsigned int numLayers() const { return nLayers_; }
102  // Get number of stubs deleted from track candidate by fitter (because they had large residuals)
103  unsigned int numKilledStubs() const { return l1track3D_->numStubs() - this->numStubs(); }
104 
105  // Get bit-encoded hit pattern (where layer number assigned by increasing distance from origin, according to layers track expected to cross).
106  unsigned int hitPattern() const { return hitPattern_; }
107 
108  //--- Get the fitted track helix parameters.
109 
110  float qOverPt() const { return qOverPt_; }
111  float charge() const { return (qOverPt_ > 0 ? 1 : -1); }
112  float invPt() const { return std::abs(qOverPt_); }
113  // Protect pt against 1/pt = 0.
114  float pt() const {
115  constexpr float small = 1.0e-6;
116  return 1. / (small + this->invPt());
117  }
118  float d0() const { return d0_; }
119  float phi0() const { return phi0_; }
120  float z0() const { return z0_; }
121  float tanLambda() const { return tanLambda_; }
122  float theta() const { return atan2(1., tanLambda_); } // Use atan2 to ensure 0 < theta < pi.
123  float eta() const { return -log(tan(0.5 * this->theta())); }
124 
125  //--- Get the fitted helix parameters with beam-spot constraint.
126  //--- If constraint not applied (e.g. 4 param fit) then these are identical to unconstrained values.
127 
128  bool done_bcon() const { return done_bcon_; } // Was beam-spot constraint aplied?
129  float qOverPt_bcon() const { return qOverPt_bcon_; }
130  float charge_bcon() const { return (qOverPt_bcon_ > 0 ? 1 : -1); }
131  float invPt_bcon() const { return std::abs(qOverPt_bcon_); }
132  float pt_bcon() const { return 1. / (1.0e-6 + this->invPt_bcon()); }
133  float phi0_bcon() const { return phi0_bcon_; }
134 
135  // Phi and z coordinates at which track crosses "chosenR" values used by r-phi HT and rapidity sectors respectively.
136  // (Optionally with beam-spot constraint applied).
137  float phiAtChosenR(bool beamConstraint) const {
138  if (beamConstraint) {
139  return reco::deltaPhi(phi0_bcon_ -
142  0.);
143  } else {
145  d0_ / (settings_->chosenRofPhi()),
146  0.);
147  }
148  }
149  float zAtChosenR() const {
150  return (z0_ + (settings_->chosenRofZ()) * tanLambda_);
151  } // neglects transverse impact parameter & track curvature.
152 
153  // Get the number of helix parameters being fitted (=5 if d0 is fitted or =4 if d0 is not fitted).
154  float nHelixParam() const { return nHelixParam_; }
155 
156  // Get the fit degrees of freedom, chi2 & chi2/DOF
157  unsigned int numDOF() const { return 2 * this->numStubs() - nHelixParam_; }
158  unsigned int numDOFrphi() const { return this->numStubs() - (nHelixParam_ - 2); }
159  unsigned int numDOFrz() const { return this->numStubs() - 2; }
160  float chi2rphi() const { return chi2rphi_; }
161  float chi2rz() const { return chi2rz_; }
162  float chi2() const { return chi2rphi_ + chi2rz_; }
163  float chi2dof() const { return (this->chi2()) / this->numDOF(); }
164 
165  //--- Ditto, but if beam-spot constraint is applied.
166  //--- If constraint not applied (e.g. 4 param fit) then these are identical to unconstrained values.
167  unsigned int numDOF_bcon() const { return (this->numDOF() - 1); }
168  unsigned int numDOFrphi_bcon() const { return (this->numDOFrphi() - 1); }
169  float chi2rphi_bcon() const { return chi2rphi_bcon_; }
170  float chi2_bcon() const { return chi2rphi_bcon_ + chi2rz_; }
171  float chi2dof_bcon() const { return (this->chi2_bcon()) / this->numDOF_bcon(); }
172 
173  //--- Get phi sector and eta region used by track finding code that this track is in.
174  unsigned int iPhiSec() const { return iPhiSec_; }
175  unsigned int iEtaReg() const { return iEtaReg_; }
176 
177  //--- Opto-link ID used to send this track from HT to Track Fitter
178  unsigned int optoLinkID() const { return optoLinkID_; }
179 
180  //--- Get whether the track has been rejected or accepted by the fit
181 
182  bool accepted() const { return accepted_; }
183 
184  // Digitize track and degrade helix parameter resolution according to effect of digitisation.
185  void digitizeTrack(const std::string& fitterName);
186 
187  // Access to detailed info about digitized track
188  const DigitalTrack* digitaltrack() const { return digitalTrack_.get(); }
189 
190  private:
191  //--- Configuration parameters
193 
194  //--- The 3D hough-transform track candidate which was fitted.
196 
197  //--- The stubs on the fitted track (can differ from those on HT track if fit kicked off stubs with bad residuals)
198  std::vector<const Stub*> stubs_;
199  unsigned int nLayers_;
200 
201  //--- Bit-encoded hit pattern (where layer number assigned by increasing distance from origin, according to layers track expected to cross).
202  unsigned int hitPattern_;
203 
204  //--- The fitted helix parameters and fit chi-squared.
205  float qOverPt_;
206  float d0_;
207  float phi0_;
208  float z0_;
209  float tanLambda_;
210  float chi2rphi_;
211  float chi2rz_;
212 
213  //--- Ditto with beam-spot constraint applied in case of 5-parameter fit, plus boolean to indicate
216  float d0_bcon_;
217  float phi0_bcon_;
219 
220  //--- The number of helix parameters being fitted (=5 if d0 is fitted or =4 if d0 is not fitted).
221  unsigned int nHelixParam_;
222 
223  //--- Phi sector and eta region used track finding code that this track was in.
224  unsigned int iPhiSec_;
225  unsigned int iEtaReg_;
226  //--- Opto-link ID from HT to Track Fitter.
227  unsigned int optoLinkID_;
228 
229  //--- Information about its association (if any) to a truth Tracking Particle.
230  const TP* matchedTP_;
231  std::vector<const Stub*> matchedStubs_;
232  unsigned int nMatchedLayers_;
233 
234  //--- Info specific to KF fitter.
235  unsigned int nSkippedLayers_;
236  unsigned int numUpdateCalls_;
237  //--- Info specific to LR fitter.
240  std::unordered_map<std::string, int> stateCalls_;
241 
242  std::shared_ptr<DigitalTrack> digitalTrack_; // Class used to digitize track if required.
243 
244  //--- Has the track fit declared this to be a valid track?
245  bool accepted_;
246  };
247 
248 } // namespace tmtt
249 
250 #endif
tmtt::Settings::invPtToDphi
double invPtToDphi() const
Definition: Settings.h:397
tmtt::KFTrackletTrack::tanLambda_
float tanLambda_
Definition: KFTrackletTrack.h:209
tmtt::KFTrackletTrack::chi2
float chi2() const
Definition: KFTrackletTrack.h:162
tmtt::KFTrackletTrack::optoLinkID_
unsigned int optoLinkID_
Definition: KFTrackletTrack.h:227
tmtt::KFTrackletTrack::chi2rphi_
float chi2rphi_
Definition: KFTrackletTrack.h:210
funct::false
false
Definition: Factorize.h:29
DigitalTrack.h
tmtt::KFTrackletTrack::stubs
const std::vector< const Stub * > & stubs() const
Definition: KFTrackletTrack.h:97
tmtt::KFTrackletTrack::invPt_bcon
float invPt_bcon() const
Definition: KFTrackletTrack.h:131
tmtt::KFTrackletTrack::qOverPt_bcon_
float qOverPt_bcon_
Definition: KFTrackletTrack.h:215
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
Stub.h
deltaPhi.h
tmtt::KFTrackletTrack::chi2rphi_bcon
float chi2rphi_bcon() const
Definition: KFTrackletTrack.h:169
tmtt::KFTrackletTrack::hitPattern
unsigned int hitPattern() const
Definition: KFTrackletTrack.h:106
tmtt::KFTrackletTrack::chi2dof
float chi2dof() const
Definition: KFTrackletTrack.h:163
tmtt::KFTrackletTrack::lostMatchingState_
std::string lostMatchingState_
Definition: KFTrackletTrack.h:239
tmtt::KFTrackletTrack::charge_bcon
float charge_bcon() const
Definition: KFTrackletTrack.h:130
tmtt::KFTrackletTrack::numDOFrphi
unsigned int numDOFrphi() const
Definition: KFTrackletTrack.h:158
tmtt::KFTrackletTrack::numDOF
unsigned int numDOF() const
Definition: KFTrackletTrack.h:157
tmtt::KFTrackletTrack::charge
float charge() const
Definition: KFTrackletTrack.h:111
tmtt::KFTrackletTrack::iPhiSec
unsigned int iPhiSec() const
Definition: KFTrackletTrack.h:174
tmtt::KFTrackletTrack::digitaltrack
const DigitalTrack * digitaltrack() const
Definition: KFTrackletTrack.h:188
tmtt::KFTrackletTrack::optoLinkID
unsigned int optoLinkID() const
Definition: KFTrackletTrack.h:178
tmtt::TP
Definition: TP.h:23
tmtt::KFTrackletTrack::phi0_bcon
float phi0_bcon() const
Definition: KFTrackletTrack.h:133
L1track3D.h
tmtt::Settings::chosenRofPhi
double chosenRofPhi() const
Definition: Settings.h:112
tmtt::KFTrackletTrack::chi2dof_bcon
float chi2dof_bcon() const
Definition: KFTrackletTrack.h:171
tmtt::KFTrackletTrack::digitalTrack_
std::shared_ptr< DigitalTrack > digitalTrack_
Definition: KFTrackletTrack.h:242
tmtt::KFTrackletTrack::matchedTP_
const TP * matchedTP_
Definition: KFTrackletTrack.h:230
tmtt::KFTrackletTrack::infoKF
void infoKF(unsigned int &nSkippedLayers, unsigned int &numUpdateCalls) const
Definition: KFTrackletTrack.h:89
tmtt::KFTrackletTrack::phi0
float phi0() const
Definition: KFTrackletTrack.h:119
tmtt::KFTrackletTrack::nLayers_
unsigned int nLayers_
Definition: KFTrackletTrack.h:199
tmtt::KFTrackletTrack::chi2rphi
float chi2rphi() const
Definition: KFTrackletTrack.h:160
tmtt::KFTrackletTrack::phi0_
float phi0_
Definition: KFTrackletTrack.h:207
tmtt::KFTrackletTrack::d0_
float d0_
Definition: KFTrackletTrack.h:206
tmtt::KFTrackletTrack::nHelixParam_
unsigned int nHelixParam_
Definition: KFTrackletTrack.h:221
tmtt::KFTrackletTrack::numLayers
unsigned int numLayers() const
Definition: KFTrackletTrack.h:101
tmtt::KFTrackletTrack::setBeamConstr
void setBeamConstr(float qOverPt_bcon, float phi0_bcon, float chi2rphi_bcon)
Definition: KFTrackletTrack.h:74
tmtt::KFTrackletTrack::numDOFrphi_bcon
unsigned int numDOFrphi_bcon() const
Definition: KFTrackletTrack.h:168
tmtt::KFTrackletTrack::tanLambda
float tanLambda() const
Definition: KFTrackletTrack.h:121
tmtt::KFTrackletTrack::phi0_bcon_
float phi0_bcon_
Definition: KFTrackletTrack.h:217
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
tmtt::KFTrackletTrack::nHelixParam
float nHelixParam() const
Definition: KFTrackletTrack.h:154
TP.h
tmtt::KFTrackletTrack::chi2_bcon
float chi2_bcon() const
Definition: KFTrackletTrack.h:170
tmtt::KFTrackletTrack::zAtChosenR
float zAtChosenR() const
Definition: KFTrackletTrack.h:149
tmtt::KFTrackletTrack::chi2rz_
float chi2rz_
Definition: KFTrackletTrack.h:211
tmtt::KFTrackletTrack::d0_bcon_
float d0_bcon_
Definition: KFTrackletTrack.h:216
tmtt::KFTrackletTrack::z0_
float z0_
Definition: KFTrackletTrack.h:208
tmtt::Settings
Definition: Settings.h:17
tmtt::KFTrackletTrack::numStubs
unsigned int numStubs() const
Definition: KFTrackletTrack.h:99
tmtt::KFTrackletTrack::phiAtChosenR
float phiAtChosenR(bool beamConstraint) const
Definition: KFTrackletTrack.h:137
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
tmtt::Settings::chosenRofZ
double chosenRofZ() const
Definition: Settings.h:127
tmtt::KFTrackletTrack::iPhiSec_
unsigned int iPhiSec_
Definition: KFTrackletTrack.h:224
tmtt::KFTrackletTrack::invPt
float invPt() const
Definition: KFTrackletTrack.h:112
tmtt::KFTrackletTrack::nMatchedLayers_
unsigned int nMatchedLayers_
Definition: KFTrackletTrack.h:232
tmtt::KFTrackletTrack::theta
float theta() const
Definition: KFTrackletTrack.h:122
tmtt::KFTrackletTrack::hitPattern_
unsigned int hitPattern_
Definition: KFTrackletTrack.h:202
tmtt::KFTrackletTrack
Definition: KFTrackletTrack.h:27
tmtt::KFTrackletTrack::d0
float d0() const
Definition: KFTrackletTrack.h:118
tmtt::DigitalTrack
Definition: DigitalTrack.h:22
tmtt::KFTrackletTrack::chi2rphi_bcon_
float chi2rphi_bcon_
Definition: KFTrackletTrack.h:218
tmtt::KFTrackletTrack::numKilledStubs
unsigned int numKilledStubs() const
Definition: KFTrackletTrack.h:103
tmtt::KFTrackletTrack::l1track3D
const L1track3D * l1track3D() const
Definition: KFTrackletTrack.h:94
tmtt::KFTrackletTrack::iEtaReg
unsigned int iEtaReg() const
Definition: KFTrackletTrack.h:175
tmtt::KFTrackletTrack::pt
float pt() const
Definition: KFTrackletTrack.h:114
tmtt::KFTrackletTrack::l1track3D_
const L1track3D * l1track3D_
Definition: KFTrackletTrack.h:195
tmtt::KFTrackletTrack::done_bcon
bool done_bcon() const
Definition: KFTrackletTrack.h:128
tmtt::KFTrackletTrack::setInfoKF
void setInfoKF(unsigned int nSkippedLayers, unsigned int numUpdateCalls)
Definition: KFTrackletTrack.h:84
tmtt::KFTrackletTrack::numIterations_
int numIterations_
Definition: KFTrackletTrack.h:238
tmtt::KFTrackletTrack::numUpdateCalls_
unsigned int numUpdateCalls_
Definition: KFTrackletTrack.h:236
tmtt::KFTrackletTrack::settings_
const Settings * settings_
Definition: KFTrackletTrack.h:192
Settings.h
tmtt::KFTrackletTrack::done_bcon_
bool done_bcon_
Definition: KFTrackletTrack.h:214
tmtt::KFTrackletTrack::iEtaReg_
unsigned int iEtaReg_
Definition: KFTrackletTrack.h:225
Exception.h
tmtt::KFTrackletTrack::accepted_
bool accepted_
Definition: KFTrackletTrack.h:245
tmtt::KFTrackletTrack::chi2rz
float chi2rz() const
Definition: KFTrackletTrack.h:161
tmtt::KFTrackletTrack::qOverPt_bcon
float qOverPt_bcon() const
Definition: KFTrackletTrack.h:129
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
tmtt::KFTrackletTrack::z0
float z0() const
Definition: KFTrackletTrack.h:120
tmtt::KFTrackletTrack::qOverPt
float qOverPt() const
Definition: KFTrackletTrack.h:110
L1trackBase.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
tmtt::KFTrackletTrack::matchedStubs_
std::vector< const Stub * > matchedStubs_
Definition: KFTrackletTrack.h:231
tmtt::KFTrackletTrack::digitizeTrack
void digitizeTrack(const std::string &fitterName)
tmtt::KFTrackletTrack::numDOFrz
unsigned int numDOFrz() const
Definition: KFTrackletTrack.h:159
tmtt::KFTrackletTrack::accepted
bool accepted() const
Definition: KFTrackletTrack.h:182
tmtt::KFTrackletTrack::numDOF_bcon
unsigned int numDOF_bcon() const
Definition: KFTrackletTrack.h:167
tmtt::KFTrackletTrack::qOverPt_
float qOverPt_
Definition: KFTrackletTrack.h:205
tmtt::KFTrackletTrack::stubs_
std::vector< const Stub * > stubs_
Definition: KFTrackletTrack.h:198
tmtt::KFTrackletTrack::stateCalls_
std::unordered_map< std::string, int > stateCalls_
Definition: KFTrackletTrack.h:240
tmtt::KFTrackletTrack::eta
float eta() const
Definition: KFTrackletTrack.h:123
tmtt::L1track3D
Definition: L1track3D.h:24
tmtt::KFTrackletTrack::pt_bcon
float pt_bcon() const
Definition: KFTrackletTrack.h:132
tmtt
=== This is the base class for the linearised chi-squared track fit algorithms.
Definition: Array2D.h:16
tmtt::L1track3D::numStubs
unsigned int numStubs() const override
Definition: L1track3D.h:97
tmtt::KFTrackletTrack::KFTrackletTrack
KFTrackletTrack(const L1track3D *l1track3D, const std::vector< const Stub * > &stubs, unsigned int hitPattern, float qOverPt, float d0, float phi0, float z0, float tanLambda, float chi2rphi, float chi2rz, unsigned int nHelixParam, unsigned int iPhiSec, unsigned int iEtaReg, bool accepted=true)
Definition: KFTrackletTrack.h:35
tmtt::KFTrackletTrack::nSkippedLayers_
unsigned int nSkippedLayers_
Definition: KFTrackletTrack.h:235