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