CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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() { return innerFPGAStub_; }
62 
63  const Stub* middleFPGAStub() { return middleFPGAStub_; }
64 
65  const Stub* outerFPGAStub() { 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 
77  std::string trackletprojstrD(int disk) const;
78 
79  std::string trackletprojstrlayer(int layer) const { return trackletprojstr(layer); }
80  std::string trackletprojstrdisk(int disk) const { return trackletprojstrD(disk); }
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 
103  std::string fullmatchdiskstr(int disk);
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  void setFitPars(double rinvfit,
161  double phi0fit,
162  double d0fit,
163  double tfit,
164  double z0fit,
165  double chisqrphifit,
166  double chisqrzfit,
167  double rinvfitexact,
168  double phi0fitexact,
169  double d0fitexact,
170  double tfitexact,
171  double z0fitexact,
172  double chisqrphifitexact,
173  double chisqrzfitexact,
174  int irinvfit,
175  int iphi0fit,
176  int id0fit,
177  int itfit,
178  int iz0fit,
179  int ichisqrphifit,
180  int ichisqrzfit,
181  int hitpattern,
182  const std::vector<const L1TStub*>& l1stubs = std::vector<const L1TStub*>());
183 
184  const std::string layerstubstr(const unsigned layer) const;
185  const std::string diskstubstr(const unsigned disk) const;
186  std::string trackfitstr() const;
187 
188  Track makeTrack(const std::vector<const L1TStub*>& l1stubs);
189 
191  assert(fpgatrack_ != nullptr);
192  return fpgatrack_.get();
193  }
194 
195  bool fit() const { return ichisqrphifit_.value() != -1; }
196 
197  int layer() const;
198  int disk() const;
199 
200  bool isBarrel() const { return barrel_; }
201  bool isOverlap() const { return overlap_; }
202  int isDisk() const { return disk_; }
203 
204  void setTrackletIndex(unsigned int index);
205 
206  int trackletIndex() const { return trackletIndex_; }
207 
208  void setTCIndex(int index) { TCIndex_ = index; }
209 
210  int TCIndex() const { return TCIndex_; }
211 
212  int TCID() const { return TCIndex_ * (1 << settings_.nbitstrackletindex()) + trackletIndex_; }
213 
214  int getISeed() const;
215  int getITC() const;
216 
217  void setTrackIndex(int index);
218  int trackIndex() const;
219 
220  unsigned int PSseed() const { return ((layer() == 1) || (layer() == 2) || (disk() != 0)) ? 1 : 0; }
221 
222  unsigned int seedIndex() const { return seedIndex_; }
223 
224  private:
225  unsigned int seedIndex_;
226 
227  // three types of tracklets + one triplet
228  bool barrel_;
229  bool disk_;
230  bool overlap_;
231  bool triplet_;
232 
236 
238  int TCIndex_;
240 
241  //Tracklet track parameters
243 
246 
247  // the layer/disk ids that we project to (never project to >4 barrel layers)
248  int projlayer_[N_LAYER - 2];
250 
251  //Track parameters from track fit
255 
258  double chisqrzfit_;
259 
263 
265 
266  std::unique_ptr<Track> fpgatrack_;
267 
269 
271 
273  };
274 }; // namespace trklet
275 #endif
TrackPars< FPGAWord > fpgapars_
Definition: Tracklet.h:242
const FPGAWord & fpgat() const
Definition: Tracklet.h:135
FPGAWord ichiSqfit() const
Definition: Tracklet.h:156
const Stub * innerFPGAStub()
Definition: Tracklet.h:61
Projection proj_[N_LAYER+N_DISK]
Definition: Tracklet.h:268
constexpr int N_DISK
Definition: Settings.h:22
std::string fullmatchdiskstr(int disk)
Definition: Tracklet.cc:324
const Residual & resid(unsigned int layerdisk)
Definition: Tracklet.h:110
const Stub * outerFPGAStub()
Definition: Tracklet.h:65
int isDisk() const
Definition: Tracklet.h:202
const FPGAWord & fpgaphi0() const
Definition: Tracklet.h:133
double z0approx() const
Definition: Tracklet.h:130
double d0fitexact() const
Definition: Tracklet.h:147
const T & phi0() const
Definition: TrackPars.h:30
std::string fullmatchstr(int layer)
Definition: Tracklet.cc:308
int nbits() const
Definition: FPGAWord.h:25
double phi0fitexact() const
Definition: Tracklet.h:146
std::string vmstrlayer(int layer, unsigned int allstubindex)
Definition: Tracklet.cc:209
int getISeed() const
Definition: Tracklet.cc:798
double z0() const
Definition: Tracklet.h:124
Track makeTrack(const std::vector< const L1TStub * > &l1stubs)
Definition: Tracklet.cc:738
Projection & proj(int layerdisk)
Definition: Tracklet.h:87
bool fit() const
Definition: Tracklet.h:195
double z0fit() const
Definition: Tracklet.h:142
double chisqrzfit_
Definition: Tracklet.h:258
TrackPars< double > trackparsapprox_
Definition: Tracklet.h:245
double rinvfit() const
Definition: Tracklet.h:138
double phi0approx() const
Definition: Tracklet.h:127
std::string vmstrdisk(int disk, unsigned int allstubindex)
Definition: Tracklet.cc:244
double tfitexact() const
Definition: Tracklet.h:148
void setTrackIndex(int index)
Definition: Tracklet.cc:810
assert(be >=bs)
std::string trackletprojstrlayer(int layer) const
Definition: Tracklet.h:79
bool valid() const
Definition: Residual.h:30
double chisqrzfitexact_
Definition: Tracklet.h:262
std::vector< const L1TStub * > getL1Stubs()
Definition: Tracklet.cc:343
Settings const & settings_
Definition: Tracklet.h:272
FPGAWord ichisqrzfit_
Definition: Tracklet.h:254
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:515
bool validProj(int layerdisk) const
Definition: Tracklet.h:82
Track * getTrack()
Definition: Tracklet.h:190
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
FPGAWord ichisqrphifit_
Definition: Tracklet.h:253
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:295
unsigned int PSseed() const
Definition: Tracklet.h:220
double tapprox() const
Definition: Tracklet.h:129
std::string addressstr()
Definition: Tracklet.cc:177
TrackPars< double > fitpars_
Definition: Tracklet.h:256
const Stub * middleFPGAStub()
Definition: Tracklet.h:63
std::string trackletprojstr(int layer) const
Definition: Tracklet.cc:259
unsigned int nbitstrackletindex() const
Definition: Settings.h:271
double phi0fit() const
Definition: Tracklet.h:139
int value() const
Definition: FPGAWord.h:24
TrackPars< FPGAWord > fpgafitpars_
Definition: Tracklet.h:252
bool isOverlap() const
Definition: Tracklet.h:201
int projdisk_[N_DISK]
Definition: Tracklet.h:249
int getITC() const
Definition: Tracklet.cc:804
bool valid() const
Definition: Projection.h:32
int trackletIndex() const
Definition: Tracklet.h:206
bool isBarrel() const
Definition: Tracklet.h:200
const T & d0() const
Definition: TrackPars.h:31
int TCID() const
Definition: Tracklet.h:212
unsigned int seedIndex_
Definition: Tracklet.h:225
double tfit() const
Definition: Tracklet.h:141
std::unique_ptr< Track > fpgatrack_
Definition: Tracklet.h:266
const T & t() const
Definition: TrackPars.h:32
int trackIndex() const
Definition: Tracklet.cc:815
const std::string diskstubstr(const unsigned disk) const
Definition: Tracklet.cc:595
const FPGAWord & id0fit() const
Definition: Tracklet.h:153
~Tracklet()=default
int projlayer_[N_LAYER-2]
Definition: Tracklet.h:248
double t() const
Definition: Tracklet.h:123
void setTCIndex(int index)
Definition: Tracklet.h:208
double rinvfitexact() const
Definition: Tracklet.h:145
Residual resid_[N_LAYER+N_DISK]
Definition: Tracklet.h:270
double d0() const
Definition: Tracklet.h:122
int layer() const
Definition: Tracklet.cc:770
std::string trackletprojstrD(int disk) const
Definition: Tracklet.cc:275
bool stubtruthmatch(const L1TStub *stub)
Definition: Tracklet.cc:138
const std::string layerstubstr(const unsigned layer) const
Definition: Tracklet.cc:572
void setTrackletIndex(unsigned int index)
Definition: Tracklet.cc:793
const FPGAWord & irinvfit() const
Definition: Tracklet.h:151
double rinv() const
Definition: Tracklet.h:120
const FPGAWord & fpgarinv() const
Definition: Tracklet.h:132
double z0fitexact() const
Definition: Tracklet.h:149
TrackPars< double > fitparsexact_
Definition: Tracklet.h:260
const FPGAWord & itfit() const
Definition: Tracklet.h:154
const FPGAWord & fpgaz0() const
Definition: Tracklet.h:136
const FPGAWord & iz0fit() const
Definition: Tracklet.h:155
double d0approx() const
Definition: Tracklet.h:128
double chiSqfit() const
Definition: Tracklet.h:143
unsigned int seedIndex() const
Definition: Tracklet.h:222
bool match(unsigned int layerdisk)
Definition: Tracklet.h:105
const Stub * outerFPGAStub_
Definition: Tracklet.h:235
std::string trackletparstr()
Definition: Tracklet.cc:188
int TCIndex() const
Definition: Tracklet.h:210
const Stub * innerFPGAStub_
Definition: Tracklet.h:233
int disk() const
Definition: Tracklet.cc:779
const T & rinv() const
Definition: TrackPars.h:29
std::string trackletprojstrdisk(int disk) const
Definition: Tracklet.h:80
std::string trackfitstr() const
Definition: Tracklet.cc:620
const Stub * middleFPGAStub_
Definition: Tracklet.h:234
const FPGAWord & iphi0fit() const
Definition: Tracklet.h:152
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
const T & z0() const
Definition: TrackPars.h:33
TrackPars< double > trackpars_
Definition: Tracklet.h:244
double phi0() const
Definition: Tracklet.h:121
double chisqrphifitexact_
Definition: Tracklet.h:261
const FPGAWord & fpgad0() const
Definition: Tracklet.h:134
double chisqrphifit_
Definition: Tracklet.h:257
double rinvapprox() const
Definition: Tracklet.h:126
constexpr int N_LAYER
Definition: Settings.h:21
std::map< int, int > getStubIDs()
Definition: Tracklet.cc:361
double d0fit() const
Definition: Tracklet.h:140