CMS 3D CMS Logo

KMTFTrack.h
Go to the documentation of this file.
1 #ifndef DataFormats_L1TMuonPhase2_KMTFTrack_h
2 #define DataFormats_L1TMuonPhase2_KMTFTrack_h
3 
7 
8 namespace l1t {
9 
10  class KMTFTrack;
11  typedef std::vector<KMTFTrack> KMTFTrackCollection;
13 
14  class KMTFTrack : public reco::LeafCandidate {
15  public:
17  : reco::LeafCandidate(-1, reco::LeafCandidate::PolarLorentzVector(0.1, 0.0, 0.0, 0.105)),
18  unconstrainedP4_(reco::LeafCandidate::PolarLorentzVector(0.1, 0.0, 0.0, 0.105)),
19  covariance_(std::vector<double>(6, 0.0)),
20  curvVertex_(0),
21  ptC_(0),
22  phiVertex_(0),
23  dxy_(0),
24  curvMuon_(0),
25  ptU_(0),
26  phiMuon_(0),
27  phiBMuon_(0),
28  curv_(0),
29  phi_(0),
30  phiB_(0),
31  coarseEta_(0),
34  approxDispChi2_(0),
36  hitPattern_(0),
37  step_(1),
38  sector_(0),
39  wheel_(0),
40  quality_(0),
42  bx_(0),
43  rankPrompt_(0),
44  rankDisp_(0),
45  idFlag_(0) {}
46 
47  ~KMTFTrack() override = default;
48 
49  KMTFTrack(const l1t::MuonStubRef& seed, int phi, int phiB)
50  : reco::LeafCandidate(-1, reco::LeafCandidate::PolarLorentzVector(0.1, 0.0, 0.0, 0.105)),
51  unconstrainedP4_(reco::LeafCandidate::PolarLorentzVector(0.1, 0.0, 0.0, 0.105)),
52  covariance_(std::vector<double>(6, 0.0)),
53  curvVertex_(0),
54  ptC_(0),
55  phiVertex_(0),
56  dxy_(0),
57  curvMuon_(0),
58  ptU_(0),
59  phiMuon_(0),
60  phiBMuon_(0),
61  curv_(0),
62  phi_(phi),
63  phiB_(phiB),
64  coarseEta_(0),
67  approxDispChi2_(0),
69  hitPattern_(0),
70  step_(seed->depthRegion()),
71  sector_(seed->phiRegion()),
72  wheel_(seed->etaRegion()),
73  quality_(seed->quality()),
75  bx_(seed->bxNum()),
76  rankPrompt_(0),
77  rankDisp_(0),
78  idFlag_(0) {
79  stubs_.push_back(seed);
80  residuals_.push_back(0);
81  residuals_.push_back(0);
82  residuals_.push_back(0);
83  }
84 
86 
87  //unconstrained pt
88  int ptDisplaced() const { return ptU_; }
89  //unconstrained curvature at station 1
90  int curvatureAtMuon() const { return curvMuon_; }
91  //unconstrained phi at station 1
92  int phiAtMuon() const { return phiMuon_; }
93  //unconstrained phiB at station 1
94  int phiBAtMuon() const { return phiBMuon_; }
95 
96  //constrained pt
97  int ptPrompt() const { return ptC_; }
98  //Constrained curvature at vertex
99  int curvatureAtVertex() const { return curvVertex_; }
100  //constrained phi at the vertex
101  int phiAtVertex() const { return phiVertex_; }
102  //Impact parameter as calculated from the muon track
103  int dxy() const { return dxy_; }
104  //Unconstrained curvature at the Muon systen
105  int curvature() const { return curv_; }
106  //Unconstrained phi at the Muon systen
107  int positionAngle() const { return phi_; }
108  //Unconstrained bending angle at the Muon systen
109  int bendingAngle() const { return phiB_; }
110  //Coarse eta caluclated only using phi segments
111  int coarseEta() const { return coarseEta_; }
112  //Approximate Chi2 metrics
113  int approxPromptChi2() const { return approxPromptChi2_; }
115  int approxDispChi2() const { return approxDispChi2_; }
116  int approxDispErrChi2() const { return approxDispErrChi2_; }
117 
118  int hitPattern() const { return hitPattern_; }
119  //step;
120  int step() const { return step_; }
121  //sector;
122  int sector() const { return sector_; }
123  //wheel
124  int wheel() const { return wheel_; }
125  //quality
126  int quality() const { return quality_; }
127 
128  //fine eta
129  int fineEta() const { return fineEta_; }
130  bool hasFineEta() const { return hasFineEta_; }
131 
132  //BX
133  int bx() const { return bx_; }
134 
135  //rank
136  int rankPrompt() const { return rankPrompt_; }
137  int rankDisp() const { return rankDisp_; }
138 
139  int id() const { return idFlag_; }
140 
141  //Associated stubs
142  const l1t::MuonStubRefVector& stubs() const { return stubs_; }
143 
144  //get Kalman gain
145  const std::vector<float>& kalmanGain(unsigned int step) const {
146  switch (step) {
147  case 3:
148  return kalmanGain3_;
149  case 2:
150  return kalmanGain2_;
151  case 1:
152  return kalmanGain1_;
153  case 0:
154  return kalmanGain0_;
155  }
156  return kalmanGain0_;
157  }
158 
159  //get covariance
160  const std::vector<double>& covariance() const { return covariance_; }
161 
162  //get residual
163  int residual(uint i) const { return residuals_[i]; }
164 
165  //check overlap
166  bool overlapTrack(const KMTFTrack& other) const {
167  for (const auto& s1 : stubs_) {
168  for (const auto& s2 : other.stubs()) {
169  if (s1->phiRegion() == s2->phiRegion() && s1->etaRegion() == s2->etaRegion() &&
170  s1->depthRegion() == s2->depthRegion() && s1->id() == s2->id())
171  return true;
172  }
173  }
174  return false;
175  }
176 
177  bool operator==(const KMTFTrack& t2) const {
178  if (this->stubs().size() != t2.stubs().size())
179  return false;
180  for (unsigned int i = 0; i < this->stubs().size(); ++i) {
181  const l1t::MuonStubRef& s1 = this->stubs()[i];
182  const l1t::MuonStubRef& s2 = t2.stubs()[i];
183  if (s1->phiRegion() != s2->phiRegion() || s1->etaRegion() != s2->etaRegion() ||
184  s1->depthRegion() != s2->depthRegion() || s1->id() != s2->id() || s1->tfLayer() != s2->tfLayer())
185  return false;
186  }
187  return true;
188  }
189 
190  //Set coordinates general
191  void setCoordinates(int step, int curv, int phi, int phiB) {
192  step_ = step;
193  curv_ = curv;
194  phiB_ = phiB;
195  phi_ = phi;
196  }
197 
198  void setCoordinatesAtVertex(int curv, int phi, int dxy) {
199  curvVertex_ = curv;
200  phiVertex_ = phi;
201  dxy_ = dxy;
202  }
203 
204  void setCoordinatesAtMuon(int curv, int phi, int phiB) {
205  curvMuon_ = curv;
206  phiMuon_ = phi;
207  phiBMuon_ = phiB;
208  }
209 
210  void setPt(int ptC, int ptU) {
211  ptC_ = ptC;
212  ptU_ = ptU;
213  }
214 
215  void setCoarseEta(int eta) { coarseEta_ = eta; }
216 
218 
219  void setApproxChi2(int chi, int chiErr, bool prompt) {
220  if (prompt) {
221  approxPromptChi2_ = chi;
222  approxPromptErrChi2_ = chiErr;
223  } else {
224  approxDispChi2_ = chi;
225  approxDispErrChi2_ = chiErr;
226  }
227  }
228 
229  void setPtEtaPhi(double pt, double eta, double phi) {
230  PolarLorentzVector v(pt, eta, phi, 0.105);
231  setP4(v);
232  }
233  void setPtEtaPhiDisplaced(double pt, double eta, double phi) {
234  unconstrainedP4_.SetPt(pt);
235  unconstrainedP4_.SetEta(eta);
236  unconstrainedP4_.SetPhi(phi);
237  }
238 
239  void addStub(const l1t::MuonStubRef& stub) {
240  if (stub->quality() < quality_)
241  quality_ = stub->quality();
242  stubs_.push_back(stub);
243  }
244 
246 
247  void setRank(int rank, bool vertex) {
248  if (vertex)
249  rankPrompt_ = rank;
250  else
251  rankDisp_ = rank;
252  }
253 
254  void setIDFlag(bool passPrompt, bool passDisp) {
255  unsigned p0 = 0;
256  unsigned p1 = 0;
257 
258  if (passPrompt)
259  p0 = 1;
260  if (passDisp)
261  p1 = 2;
262 
263  idFlag_ = p0 | p1;
264  }
265 
267  unsigned int step, unsigned int K, float a1, float a2, float a3 = 0, float a4 = 0, float a5 = 0, float a6 = 0) {
268  switch (step) {
269  case 3:
270  kalmanGain3_.push_back(K);
271  kalmanGain3_.push_back(a1);
272  kalmanGain3_.push_back(a2);
273  kalmanGain3_.push_back(a3);
274  kalmanGain3_.push_back(a4);
275  kalmanGain3_.push_back(a5);
276  kalmanGain3_.push_back(a6);
277  break;
278  case 2:
279  kalmanGain2_.push_back(K);
280  kalmanGain2_.push_back(a1);
281  kalmanGain2_.push_back(a2);
282  kalmanGain2_.push_back(a3);
283  kalmanGain2_.push_back(a4);
284  kalmanGain2_.push_back(a5);
285  kalmanGain2_.push_back(a6);
286  break;
287  case 1:
288  kalmanGain1_.push_back(K);
289  kalmanGain1_.push_back(a1);
290  kalmanGain1_.push_back(a2);
291  kalmanGain1_.push_back(a3);
292  kalmanGain1_.push_back(a4);
293  kalmanGain1_.push_back(a5);
294  kalmanGain1_.push_back(a6);
295  break;
296  case 0:
297  kalmanGain0_.push_back(K);
298  kalmanGain0_.push_back(a1);
299  kalmanGain0_.push_back(a2);
300  kalmanGain0_.push_back(a3);
301  break;
302 
303  default:
304  throw cms::Exception("WrongCondition") << "Critical ERROR on setting the Kalman gain\n";
305  }
306  }
307 
308  //set covariance
310  covariance_[0] = c(0, 0);
311  covariance_[1] = c(0, 1);
312  covariance_[2] = c(1, 1);
313  covariance_[3] = c(0, 2);
314  covariance_[4] = c(1, 2);
315  covariance_[5] = c(2, 2);
316  }
317 
318  //set fine eta
319  void setFineEta(int eta) {
320  fineEta_ = eta;
321  hasFineEta_ = true;
322  }
323 
324  //set residual
325  void setResidual(uint i, int val) { residuals_[i] = val; }
326 
327  private:
329 
330  //Covariance matrix for studies
331  std::vector<double> covariance_;
333 
334  //vertex coordinates
336  int ptC_;
338  int dxy_;
339 
340  //muon coordinates
342  int ptU_;
343  int phiMuon_;
345 
346  //generic coordinates
347  int curv_;
348  int phi_;
349  int phiB_;
350  //common coordinates
352 
353  //Approximate Chi2 metric
358 
359  //phi bitmask
361 
362  //propagation step
363  int step_;
364 
365  //sector
366  int sector_;
367  //wheel
368  int wheel_;
369 
370  //quality
371  int quality_;
372 
373  //Fine eta
374  int fineEta_;
375 
376  //has fine eta?
378 
379  //BX
380  int bx_;
381 
382  //rank
385 
386  //flag
387  int idFlag_;
388 
389  //Kalman Gain for making LUTs
390  std::vector<float> kalmanGain0_;
391  std::vector<float> kalmanGain1_;
392  std::vector<float> kalmanGain2_;
393  std::vector<float> kalmanGain3_;
394 
395  std::vector<int> residuals_;
396  };
397 
398 } // namespace l1t
399 #endif
int positionAngle() const
Definition: KMTFTrack.h:107
int id() const
Definition: KMTFTrack.h:139
void addStub(const l1t::MuonStubRef &stub)
Definition: KMTFTrack.h:239
l1t::MuonStubRefVector stubs_
Definition: KMTFTrack.h:332
void setCoarseEta(int eta)
Definition: KMTFTrack.h:215
void setPtEtaPhiDisplaced(double pt, double eta, double phi)
Definition: KMTFTrack.h:233
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
void setApproxChi2(int chi, int chiErr, bool prompt)
Definition: KMTFTrack.h:219
double pt() const final
transverse momentum
bool hasFineEta() const
Definition: KMTFTrack.h:130
int quality() const
Definition: KMTFTrack.h:126
void setCovariance(const CovarianceMatrix &c)
Definition: KMTFTrack.h:309
int phiBAtMuon() const
Definition: KMTFTrack.h:94
void setStubs(const l1t::MuonStubRefVector &stubs)
Definition: KMTFTrack.h:245
int approxPromptChi2() const
Definition: KMTFTrack.h:113
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: LeafCandidate.h:25
std::vector< double > covariance_
Definition: KMTFTrack.h:331
int approxDispErrChi2_
Definition: KMTFTrack.h:357
int ptPrompt() const
Definition: KMTFTrack.h:97
void setCoordinatesAtMuon(int curv, int phi, int phiB)
Definition: KMTFTrack.h:204
int sector() const
Definition: KMTFTrack.h:122
void setRank(int rank, bool vertex)
Definition: KMTFTrack.h:247
delete x;
Definition: CaloConfig.h:22
const Point & vertex() const override
vertex position (overwritten by PF...)
reco::LeafCandidate::PolarLorentzVector unconstrainedP4_
Definition: KMTFTrack.h:328
int dxy() const
Definition: KMTFTrack.h:103
std::vector< KMTFTrack > KMTFTrackCollection
Definition: KMTFTrack.h:10
int hitPattern() const
Definition: KMTFTrack.h:118
int approxDispErrChi2() const
Definition: KMTFTrack.h:116
int approxPromptChi2_
Definition: KMTFTrack.h:354
bool operator==(const KMTFTrack &t2) const
Definition: KMTFTrack.h:177
int bendingAngle() const
Definition: KMTFTrack.h:109
std::vector< edm::Ref< MuonStubCollection > > MuonStubRefVector
Definition: MuonStub.h:44
int ptDisplaced() const
Definition: KMTFTrack.h:88
int approxDispChi2_
Definition: KMTFTrack.h:356
int wheel() const
Definition: KMTFTrack.h:124
bool overlapTrack(const KMTFTrack &other) const
Definition: KMTFTrack.h:166
void setFineEta(int eta)
Definition: KMTFTrack.h:319
int curvatureAtVertex() const
Definition: KMTFTrack.h:99
void setKalmanGain(unsigned int step, unsigned int K, float a1, float a2, float a3=0, float a4=0, float a5=0, float a6=0)
Definition: KMTFTrack.h:266
int approxPromptErrChi2_
Definition: KMTFTrack.h:355
int approxDispChi2() const
Definition: KMTFTrack.h:115
void setIDFlag(bool passPrompt, bool passDisp)
Definition: KMTFTrack.h:254
int rankPrompt() const
Definition: KMTFTrack.h:136
void setPt(int ptC, int ptU)
Definition: KMTFTrack.h:210
int residual(uint i) const
Definition: KMTFTrack.h:163
int phiAtVertex() const
Definition: KMTFTrack.h:101
int curvature() const
Definition: KMTFTrack.h:105
~KMTFTrack() override=default
void setHitPattern(int pattern)
Definition: KMTFTrack.h:217
std::vector< float > kalmanGain3_
Definition: KMTFTrack.h:393
void setCoordinatesAtVertex(int curv, int phi, int dxy)
Definition: KMTFTrack.h:198
std::vector< float > kalmanGain1_
Definition: KMTFTrack.h:391
std::vector< float > kalmanGain0_
Definition: KMTFTrack.h:390
const std::vector< double > & covariance() const
Definition: KMTFTrack.h:160
std::vector< float > kalmanGain2_
Definition: KMTFTrack.h:392
int rankDisp() const
Definition: KMTFTrack.h:137
fixed size matrix
void setPtEtaPhi(double pt, double eta, double phi)
Definition: KMTFTrack.h:229
BXVector< KMTFTrack > KMTFTrackBxCollection
Definition: KMTFTrack.h:12
const std::vector< float > & kalmanGain(unsigned int step) const
Definition: KMTFTrack.h:145
const l1t::MuonStubRefVector & stubs() const
Definition: KMTFTrack.h:142
void setCoordinates(int step, int curv, int phi, int phiB)
Definition: KMTFTrack.h:191
int bx() const
Definition: KMTFTrack.h:133
step
Definition: StallMonitor.cc:83
std::vector< int > residuals_
Definition: KMTFTrack.h:395
int coarseEta() const
Definition: KMTFTrack.h:111
int phiAtMuon() const
Definition: KMTFTrack.h:92
double phi() const final
momentum azimuthal angle
int approxPromptErrChi2() const
Definition: KMTFTrack.h:114
reco::LeafCandidate::PolarLorentzVector displacedP4() const
Definition: KMTFTrack.h:85
int curvatureAtMuon() const
Definition: KMTFTrack.h:90
void setResidual(uint i, int val)
Definition: KMTFTrack.h:325
void setP4(const LorentzVector &p4) final
set 4-momentum
KMTFTrack(const l1t::MuonStubRef &seed, int phi, int phiB)
Definition: KMTFTrack.h:49
int fineEta() const
Definition: KMTFTrack.h:129
int step() const
Definition: KMTFTrack.h:120
bool hasFineEta_
Definition: KMTFTrack.h:377
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38
double eta() const final
momentum pseudorapidity