File indexing completed on 2024-04-06 12:21:48
0001 #ifndef L1Trigger_TrackFindingTMTT_KFTrackletTrack_h
0002 #define L1Trigger_TrackFindingTMTT_KFTrackletTrack_h
0003
0004 #include "FWCore/Utilities/interface/Exception.h"
0005 #include "DataFormats/Math/interface/deltaPhi.h"
0006 #include "L1Trigger/TrackFindingTMTT/interface/L1trackBase.h"
0007 #include "L1Trigger/TrackFindingTMTT/interface/L1track3D.h"
0008 #include "L1Trigger/TrackFindingTMTT/interface/Settings.h"
0009 #include "L1Trigger/TrackFindingTMTT/interface/TP.h"
0010 #include "L1Trigger/TrackFindingTMTT/interface/Stub.h"
0011 #include "L1Trigger/TrackFindingTMTT/interface/DigitalTrack.h"
0012
0013 #include <vector>
0014 #include <utility>
0015 #include <string>
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 namespace tmtt {
0026
0027 class KFTrackletTrack {
0028 public:
0029
0030
0031
0032
0033
0034
0035 KFTrackletTrack(const L1track3D* l1track3D,
0036 const std::vector<const Stub*>& stubs,
0037 unsigned int hitPattern,
0038 float qOverPt,
0039 float d0,
0040 float phi0,
0041 float z0,
0042 float tanLambda,
0043 float chi2rphi,
0044 float chi2rz,
0045 unsigned int nHelixParam,
0046 unsigned int iPhiSec,
0047 unsigned int iEtaReg,
0048 bool accepted = true,
0049 bool done_bcon = false,
0050 float qOverPt_bcon = 0.,
0051 float d0_bcon = 0.,
0052 float phi0_bcon = 0.,
0053 float chi2rphi_bcon = 0.)
0054 : l1track3D_(l1track3D),
0055 stubs_(stubs),
0056 hitPattern_(hitPattern),
0057 qOverPt_(qOverPt),
0058 d0_(d0),
0059 phi0_(phi0),
0060 z0_(z0),
0061 tanLambda_(tanLambda),
0062 chi2rphi_(chi2rphi),
0063 chi2rz_(chi2rz),
0064 done_bcon_(done_bcon),
0065 qOverPt_bcon_(qOverPt_bcon),
0066 d0_bcon_(d0_bcon),
0067 phi0_bcon_(phi0_bcon),
0068 chi2rphi_bcon_(chi2rphi_bcon),
0069 nHelixParam_(nHelixParam),
0070 iPhiSec_(iPhiSec),
0071 iEtaReg_(iEtaReg),
0072 optoLinkID_(l1track3D->optoLinkID()),
0073 nSkippedLayers_(0),
0074 numUpdateCalls_(0),
0075 numIterations_(0),
0076 accepted_(accepted) {}
0077
0078
0079
0080
0081 void setInfoKF(unsigned int nSkippedLayers, unsigned int numUpdateCalls) {
0082 nSkippedLayers_ = nSkippedLayers;
0083 numUpdateCalls_ = numUpdateCalls;
0084 }
0085
0086 void infoKF(unsigned int& nSkippedLayers, unsigned int& numUpdateCalls) const {
0087 nSkippedLayers = nSkippedLayers_;
0088 numUpdateCalls = numUpdateCalls_;
0089 }
0090
0091 const L1track3D* l1track3D() const { return l1track3D_; }
0092
0093
0094 const std::vector<const Stub*>& stubs() const { return stubs_; }
0095
0096 unsigned int numStubs() const { return stubs_.size(); }
0097
0098 unsigned int numLayers() const { return nLayers_; }
0099
0100 unsigned int numKilledStubs() const { return l1track3D_->numStubs() - this->numStubs(); }
0101
0102
0103 unsigned int hitPattern() const { return hitPattern_; }
0104
0105
0106
0107 float qOverPt() const { return qOverPt_; }
0108 float charge() const { return (qOverPt_ > 0 ? 1 : -1); }
0109 float invPt() const { return std::abs(qOverPt_); }
0110
0111 float pt() const {
0112 constexpr float small = 1.0e-6;
0113 return 1. / (small + this->invPt());
0114 }
0115 float d0() const { return d0_; }
0116 float phi0() const { return phi0_; }
0117 float z0() const { return z0_; }
0118 float tanLambda() const { return tanLambda_; }
0119 float theta() const { return atan2(1., tanLambda_); }
0120 float eta() const { return -log(tan(0.5 * this->theta())); }
0121
0122
0123
0124
0125 bool done_bcon() const { return done_bcon_; }
0126 float qOverPt_bcon() const { return qOverPt_bcon_; }
0127 float charge_bcon() const { return (qOverPt_bcon_ > 0 ? 1 : -1); }
0128 float invPt_bcon() const { return std::abs(qOverPt_bcon_); }
0129 float pt_bcon() const { return 1. / (1.0e-6 + this->invPt_bcon()); }
0130 float phi0_bcon() const { return phi0_bcon_; }
0131 float d0_bcon() const { return d0_bcon_; }
0132
0133
0134
0135 float phiAtChosenR(bool beamConstraint) const {
0136 if (beamConstraint) {
0137 return reco::deltaPhi(phi0_bcon_ -
0138 asin((settings_->invPtToDphi() * settings_->chosenRofPhi()) * qOverPt_bcon_) -
0139 d0_bcon_ / (settings_->chosenRofPhi()),
0140 0.);
0141 } else {
0142 return reco::deltaPhi(phi0_ - asin((settings_->invPtToDphi() * settings_->chosenRofPhi()) * qOverPt_) -
0143 d0_ / (settings_->chosenRofPhi()),
0144 0.);
0145 }
0146 }
0147 float zAtChosenR() const {
0148 return (z0_ + (settings_->chosenRofZ()) * tanLambda_);
0149 }
0150
0151
0152 float nHelixParam() const { return nHelixParam_; }
0153
0154
0155 unsigned int numDOF() const { return 2 * this->numStubs() - nHelixParam_; }
0156 unsigned int numDOFrphi() const { return this->numStubs() - (nHelixParam_ - 2); }
0157 unsigned int numDOFrz() const { return this->numStubs() - 2; }
0158 float chi2rphi() const { return chi2rphi_; }
0159 float chi2rz() const { return chi2rz_; }
0160 float chi2() const { return chi2rphi_ + chi2rz_; }
0161 float chi2dof() const { return (this->chi2()) / this->numDOF(); }
0162
0163
0164
0165 unsigned int numDOF_bcon() const { return (this->numDOF() - 1); }
0166 unsigned int numDOFrphi_bcon() const { return (this->numDOFrphi() - 1); }
0167 float chi2rphi_bcon() const { return chi2rphi_bcon_; }
0168 float chi2_bcon() const { return chi2rphi_bcon_ + chi2rz_; }
0169 float chi2dof_bcon() const { return (this->chi2_bcon()) / this->numDOF_bcon(); }
0170
0171
0172 unsigned int iPhiSec() const { return iPhiSec_; }
0173 unsigned int iEtaReg() const { return iEtaReg_; }
0174
0175
0176 unsigned int optoLinkID() const { return optoLinkID_; }
0177
0178
0179
0180 bool accepted() const { return accepted_; }
0181
0182
0183 void digitizeTrack(const std::string& fitterName);
0184
0185
0186 const DigitalTrack* digitaltrack() const { return digitalTrack_.get(); }
0187
0188 private:
0189
0190 const Settings* settings_;
0191
0192
0193 const L1track3D* l1track3D_;
0194
0195
0196 std::vector<const Stub*> stubs_;
0197 unsigned int nLayers_;
0198
0199
0200 unsigned int hitPattern_;
0201
0202
0203 float qOverPt_;
0204 float d0_;
0205 float phi0_;
0206 float z0_;
0207 float tanLambda_;
0208 float chi2rphi_;
0209 float chi2rz_;
0210
0211
0212 bool done_bcon_;
0213 float qOverPt_bcon_;
0214 float d0_bcon_;
0215 float phi0_bcon_;
0216 float chi2rphi_bcon_;
0217
0218
0219 unsigned int nHelixParam_;
0220
0221
0222 unsigned int iPhiSec_;
0223 unsigned int iEtaReg_;
0224
0225 unsigned int optoLinkID_;
0226
0227
0228 const TP* matchedTP_;
0229 std::vector<const Stub*> matchedStubs_;
0230 unsigned int nMatchedLayers_;
0231
0232
0233 unsigned int nSkippedLayers_;
0234 unsigned int numUpdateCalls_;
0235
0236 int numIterations_;
0237 std::string lostMatchingState_;
0238 std::unordered_map<std::string, int> stateCalls_;
0239
0240 std::shared_ptr<DigitalTrack> digitalTrack_;
0241
0242
0243 bool accepted_;
0244 };
0245
0246 }
0247
0248 #endif