CMS 3D CMS Logo

Tracklet.h
Go to the documentation of this file.
1 #ifndef L1Trigger_TrackFindingTracklet_interface_Tracklet_h
2 #define L1Trigger_TrackFindingTracklet_interface_Tracklet_h
3 
4 #include <iostream>
5 #include <fstream>
6 #include <cassert>
7 #include <cmath>
8 #include <vector>
9 #include <memory>
10 #include <set>
11 
20 
21 namespace trklet {
22 
23  class Settings;
24  class Stub;
25  class Track;
26 
27  class Tracklet {
28  public:
29  Tracklet(Settings const& settings,
30  unsigned int iSeed,
31  const Stub* innerFPGAStub,
32  const Stub* middleFPGAStub,
33  const Stub* outerFPGAStub,
34  double rinv,
35  double phi0,
36  double d0,
37  double z0,
38  double t,
39  double rinvapprox,
40  double phi0approx,
41  double d0approx,
42  double z0approx,
43  double tapprox,
44  int irinv,
45  int iphi0,
46  int id0,
47  int iz0,
48  int it,
49  Projection projs[N_LAYER + N_DISK],
50  bool disk,
51  bool overlap = false);
52 
53  ~Tracklet() = default;
54 
55  //Find tp corresponding to seed.
56  //Will require 'tight match' such that tp is part of each of the four clustes returns 0 if no tp matches
57  int tpseed();
58 
59  bool stubtruthmatch(const L1TStub* stub);
60 
61  const Stub* innerFPGAStub() const { return innerFPGAStub_; }
62 
63  const Stub* middleFPGAStub() const { return middleFPGAStub_; }
64 
65  const Stub* outerFPGAStub() const { return outerFPGAStub_; }
66 
68 
69  //Tracklet parameters print out
71 
72  std::string vmstrlayer(int layer, unsigned int allstubindex);
73 
74  std::string vmstrdisk(int disk, unsigned int allstubindex);
75 
78 
81 
82  bool validProj(int layerdisk) const {
83  assert(layerdisk >= 0 && layerdisk < N_LAYER + N_DISK);
84  return proj_[layerdisk].valid();
85  }
86 
87  Projection& proj(int layerdisk) {
88  assert(validProj(layerdisk));
89  return proj_[layerdisk];
90  }
91 
92  void addMatch(unsigned int layerdisk,
93  int ideltaphi,
94  int ideltarz,
95  double dphi,
96  double drz,
97  double dphiapprox,
98  double drzapprox,
99  int stubid,
100  const trklet::Stub* stubptr);
101 
104 
105  bool match(unsigned int layerdisk) {
106  assert(layerdisk < N_LAYER + N_DISK);
107  return resid_[layerdisk].valid();
108  }
109 
110  const Residual& resid(unsigned int layerdisk) {
111  assert(layerdisk < N_LAYER + N_DISK);
112  assert(resid_[layerdisk].valid());
113  return resid_[layerdisk];
114  }
115 
116  std::vector<const L1TStub*> getL1Stubs();
117 
118  std::map<int, int> getStubIDs();
119 
120  double rinv() const { return trackpars_.rinv(); }
121  double phi0() const { return trackpars_.phi0(); }
122  double d0() const { return trackpars_.d0(); }
123  double t() const { return trackpars_.t(); }
124  double z0() const { return trackpars_.z0(); }
125 
126  double rinvapprox() const { return trackparsapprox_.rinv(); }
127  double phi0approx() const { return trackparsapprox_.phi0(); }
128  double d0approx() const { return trackparsapprox_.d0(); }
129  double tapprox() const { return trackparsapprox_.t(); }
130  double z0approx() const { return trackparsapprox_.z0(); }
131 
132  const FPGAWord& fpgarinv() const { return fpgapars_.rinv(); }
133  const FPGAWord& fpgaphi0() const { return fpgapars_.phi0(); }
134  const FPGAWord& fpgad0() const { return fpgapars_.d0(); }
135  const FPGAWord& fpgat() const { return fpgapars_.t(); }
136  const FPGAWord& fpgaz0() const { return fpgapars_.z0(); }
137 
138  double rinvfit() const { return fitpars_.rinv(); }
139  double phi0fit() const { return fitpars_.phi0(); }
140  double d0fit() const { return fitpars_.d0(); }
141  double tfit() const { return fitpars_.t(); }
142  double z0fit() const { return fitpars_.z0(); }
143  double chiSqfit() const { return chisqrphifit_ + chisqrzfit_; }
144 
145  double rinvfitexact() const { return fitparsexact_.rinv(); }
146  double phi0fitexact() const { return fitparsexact_.phi0(); }
147  double d0fitexact() const { return fitparsexact_.d0(); }
148  double tfitexact() const { return fitparsexact_.t(); }
149  double z0fitexact() const { return fitparsexact_.z0(); }
150 
151  const FPGAWord& irinvfit() const { return fpgafitpars_.rinv(); }
152  const FPGAWord& iphi0fit() const { return fpgafitpars_.phi0(); }
153  const FPGAWord& id0fit() const { return fpgafitpars_.d0(); }
154  const FPGAWord& itfit() const { return fpgafitpars_.t(); }
155  const FPGAWord& iz0fit() const { return fpgafitpars_.z0(); }
156  FPGAWord ichiSqfit() const {
158  }
159 
160  // Note floating & digitized helix params after track fit.
161  void setFitPars(double rinvfit,
162  double phi0fit,
163  double d0fit,
164  double tfit,
165  double z0fit,
166  double chisqrphifit,
167  double chisqrzfit,
168  double rinvfitexact,
169  double phi0fitexact,
170  double d0fitexact,
171  double tfitexact,
172  double z0fitexact,
173  double chisqrphifitexact,
174  double chisqrzfitexact,
175  int irinvfit,
176  int iphi0fit,
177  int id0fit,
178  int itfit,
179  int iz0fit,
180  int ichisqrphifit,
181  int ichisqrzfit,
182  int hitpattern,
183  const std::vector<const L1TStub*>& l1stubs = std::vector<const L1TStub*>());
184 
185  const std::string layerstubstr(const unsigned layer) const;
186  const std::string diskstubstr(const unsigned disk) const;
187  std::string trackfitstr() const;
188 
189  // Create a Track object from stubs & digitized track helix params
190  Track makeTrack(const std::vector<const L1TStub*>& l1stubs);
191 
193  assert(fpgatrack_ != nullptr);
194  return fpgatrack_.get();
195  }
196 
197  bool fit() const { return ichisqrphifit_.value() != -1; }
198 
199  int layer() const;
200  int disk() const;
201 
202  bool isBarrel() const { return barrel_; }
203  bool isOverlap() const { return overlap_; }
204  int isDisk() const { return disk_; }
205 
206  void setTrackletIndex(unsigned int index);
207 
208  int trackletIndex() const { return trackletIndex_; }
209 
210  void setTCIndex(int index) { TCIndex_ = index; }
211 
212  int TCIndex() const { return TCIndex_; }
213 
214  int TCID() const { return TCIndex_ * (1 << settings_.nbitstrackletindex()) + trackletIndex_; }
215 
216  int getISeed() const;
217  int getITC() const;
218 
219  void setTrackIndex(int index);
220  int trackIndex() const;
221 
222  unsigned int PSseed() const { return ((layer() == 1) || (layer() == 2) || (disk() != 0)) ? 1 : 0; }
223 
224  unsigned int seedIndex() const { return seedIndex_; }
225 
226  private:
227  unsigned int seedIndex_;
228 
229  // three types of tracklets + one triplet
230  bool barrel_;
231  bool disk_;
232  bool overlap_;
233  bool triplet_;
234 
238 
240  int TCIndex_;
242 
243  //Tracklet track parameters
245 
248 
249  // the layer/disk ids that we project to (never project to >4 barrel layers)
250  int projlayer_[N_LAYER - 2];
252 
253  //Track parameters from track fit
257 
260  double chisqrzfit_;
261 
265 
267 
268  std::unique_ptr<Track> fpgatrack_;
269 
271 
273 
275  };
276 }; // namespace trklet
277 #endif
TrackPars< FPGAWord > fpgapars_
Definition: Tracklet.h:244
const T & z0() const
Definition: TrackPars.h:33
unsigned int seedIndex() const
Definition: Tracklet.h:224
double d0fitexact() const
Definition: Tracklet.h:147
const FPGAWord & fpgarinv() const
Definition: Tracklet.h:132
double t() const
Definition: Tracklet.h:123
const FPGAWord & iz0fit() const
Definition: Tracklet.h:155
Projection proj_[N_LAYER+N_DISK]
Definition: Tracklet.h:270
constexpr int N_DISK
Definition: Settings.h:26
double rinvfitexact() const
Definition: Tracklet.h:145
std::string fullmatchdiskstr(int disk)
Definition: Tracklet.cc:332
const Residual & resid(unsigned int layerdisk)
Definition: Tracklet.h:110
double d0fit() const
Definition: Tracklet.h:140
int disk() const
Definition: Tracklet.cc:792
const std::string layerstubstr(const unsigned layer) const
Definition: Tracklet.cc:580
bool isOverlap() const
Definition: Tracklet.h:203
unsigned int nbitstrackletindex() const
Definition: Settings.h:309
std::string fullmatchstr(int layer)
Definition: Tracklet.cc:316
int trackIndex() const
Definition: Tracklet.cc:828
std::string trackfitstr() const
Definition: Tracklet.cc:628
double tfit() const
Definition: Tracklet.h:141
std::string vmstrlayer(int layer, unsigned int allstubindex)
Definition: Tracklet.cc:217
const FPGAWord & fpgaz0() const
Definition: Tracklet.h:136
const T & phi0() const
Definition: TrackPars.h:30
const FPGAWord & fpgaphi0() const
Definition: Tracklet.h:133
Projection & proj(int layerdisk)
Definition: Tracklet.h:87
double phi0() const
Definition: Tracklet.h:121
int getITC() const
Definition: Tracklet.cc:817
double chisqrzfit_
Definition: Tracklet.h:260
TrackPars< double > trackparsapprox_
Definition: Tracklet.h:247
const FPGAWord & fpgat() const
Definition: Tracklet.h:135
std::string vmstrdisk(int disk, unsigned int allstubindex)
Definition: Tracklet.cc:252
void setTrackIndex(int index)
Definition: Tracklet.cc:823
assert(be >=bs)
double chisqrzfitexact_
Definition: Tracklet.h:264
int TCID() const
Definition: Tracklet.h:214
std::vector< const L1TStub * > getL1Stubs()
Definition: Tracklet.cc:351
const FPGAWord & iphi0fit() const
Definition: Tracklet.h:152
int TCIndex() const
Definition: Tracklet.h:212
Settings const & settings_
Definition: Tracklet.h:274
FPGAWord ichisqrzfit_
Definition: Tracklet.h:256
Track * getTrack()
Definition: Tracklet.h:192
bool fit() const
Definition: Tracklet.h:197
FPGAWord ichisqrphifit_
Definition: Tracklet.h:255
void addMatch(unsigned int layerdisk, int ideltaphi, int ideltarz, double dphi, double drz, double dphiapprox, double drzapprox, int stubid, const trklet::Stub *stubptr)
Definition: Tracklet.cc:303
std::string addressstr()
Definition: Tracklet.cc:177
TrackPars< double > fitpars_
Definition: Tracklet.h:258
const T & rinv() const
Definition: TrackPars.h:29
double phi0approx() const
Definition: Tracklet.h:127
int trackletIndex() const
Definition: Tracklet.h:208
double z0fitexact() const
Definition: Tracklet.h:149
std::string trackletprojstrlayer(int layer) const
Definition: Tracklet.h:79
const FPGAWord & id0fit() const
Definition: Tracklet.h:153
double rinv() const
Definition: Tracklet.h:120
TrackPars< FPGAWord > fpgafitpars_
Definition: Tracklet.h:254
int projdisk_[N_DISK]
Definition: Tracklet.h:251
const Stub * outerFPGAStub() const
Definition: Tracklet.h:65
bool valid() const
Definition: Projection.h:32
int projlayer_[N_LAYER - 2]
Definition: Tracklet.h:250
unsigned int seedIndex_
Definition: Tracklet.h:227
std::string trackletprojstr(int layer) const
Definition: Tracklet.cc:267
std::unique_ptr< Track > fpgatrack_
Definition: Tracklet.h:268
int value() const
Definition: FPGAWord.h:24
double tfitexact() const
Definition: Tracklet.h:148
const Stub * middleFPGAStub() const
Definition: Tracklet.h:63
double tapprox() const
Definition: Tracklet.h:129
double phi0fitexact() const
Definition: Tracklet.h:146
~Tracklet()=default
const FPGAWord & fpgad0() const
Definition: Tracklet.h:134
bool isBarrel() const
Definition: Tracklet.h:202
void setTCIndex(int index)
Definition: Tracklet.h:210
std::string trackletprojstrD(int disk) const
Definition: Tracklet.cc:283
double rinvapprox() const
Definition: Tracklet.h:126
Residual resid_[N_LAYER+N_DISK]
Definition: Tracklet.h:272
double d0() const
Definition: Tracklet.h:122
const T & d0() const
Definition: TrackPars.h:31
const std::string diskstubstr(const unsigned disk) const
Definition: Tracklet.cc:603
bool stubtruthmatch(const L1TStub *stub)
Definition: Tracklet.cc:138
double z0approx() const
Definition: Tracklet.h:130
int nbits() const
Definition: FPGAWord.h:25
void setTrackletIndex(unsigned int index)
Definition: Tracklet.cc:806
int getISeed() const
Definition: Tracklet.cc:811
double z0fit() const
Definition: Tracklet.h:142
FPGAWord ichiSqfit() const
Definition: Tracklet.h:156
double d0approx() const
Definition: Tracklet.h:128
TrackPars< double > fitparsexact_
Definition: Tracklet.h:262
bool valid() const
Definition: Residual.h:30
double z0() const
Definition: Tracklet.h:124
const FPGAWord & itfit() const
Definition: Tracklet.h:154
bool match(unsigned int layerdisk)
Definition: Tracklet.h:105
const Stub * outerFPGAStub_
Definition: Tracklet.h:237
int isDisk() const
Definition: Tracklet.h:204
std::string trackletparstr()
Definition: Tracklet.cc:188
const T & t() const
Definition: TrackPars.h:32
void setFitPars(double rinvfit, double phi0fit, double d0fit, double tfit, double z0fit, double chisqrphifit, double chisqrzfit, double rinvfitexact, double phi0fitexact, double d0fitexact, double tfitexact, double z0fitexact, double chisqrphifitexact, double chisqrzfitexact, int irinvfit, int iphi0fit, int id0fit, int itfit, int iz0fit, int ichisqrphifit, int ichisqrzfit, int hitpattern, const std::vector< const L1TStub *> &l1stubs=std::vector< const L1TStub *>())
Definition: Tracklet.cc:523
Track makeTrack(const std::vector< const L1TStub *> &l1stubs)
Definition: Tracklet.cc:750
std::string trackletprojstrdisk(int disk) const
Definition: Tracklet.h:80
const Stub * innerFPGAStub_
Definition: Tracklet.h:235
double chiSqfit() const
Definition: Tracklet.h:143
const Stub * middleFPGAStub_
Definition: Tracklet.h:236
int layer() const
Definition: Tracklet.cc:783
Tracklet(Settings const &settings, unsigned int iSeed, const Stub *innerFPGAStub, const Stub *middleFPGAStub, const Stub *outerFPGAStub, double rinv, double phi0, double d0, double z0, double t, double rinvapprox, double phi0approx, double d0approx, double z0approx, double tapprox, int irinv, int iphi0, int id0, int iz0, int it, Projection projs[N_LAYER+N_DISK], bool disk, bool overlap=false)
Definition: Tracklet.cc:16
unsigned int PSseed() const
Definition: Tracklet.h:222
TrackPars< double > trackpars_
Definition: Tracklet.h:246
double chisqrphifitexact_
Definition: Tracklet.h:263
const FPGAWord & irinvfit() const
Definition: Tracklet.h:151
double phi0fit() const
Definition: Tracklet.h:139
double rinvfit() const
Definition: Tracklet.h:138
double chisqrphifit_
Definition: Tracklet.h:259
bool validProj(int layerdisk) const
Definition: Tracklet.h:82
constexpr int N_LAYER
Definition: Settings.h:25
std::map< int, int > getStubIDs()
Definition: Tracklet.cc:369
const Stub * innerFPGAStub() const
Definition: Tracklet.h:61