CMS 3D CMS Logo

TTTrack.h
Go to the documentation of this file.
1 
13 #ifndef L1_TRACK_TRIGGER_TRACK_FORMAT_H
14 #define L1_TRACK_TRIGGER_TRACK_FORMAT_H
15 
16 #include "CLHEP/Units/GlobalPhysicalConstants.h"
23 
24 namespace tttrack {
25  void errorSetTrackWordBits(unsigned int);
26 }
27 
28 template <typename T>
29 class TTTrack : public TTTrack_TrackWord {
30 private:
32  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > > theStubRefs;
35  double theRInv_;
36  double thePhi_;
37  double theTanL_;
38  double theD0_;
39  double theZ0_;
40  unsigned int thePhiSector_;
41  unsigned int theEtaSector_;
43  double theChi2_;
44  double theChi2_XY_;
45  double theChi2_Z_;
46  unsigned int theNumFitPars_;
47  unsigned int theHitPattern_;
48  double theTrkMVA1_;
49  double theTrkMVA2_;
50  double theTrkMVA3_;
52  double theBField_; // needed for unpacking
53  static constexpr unsigned int Npars4 = 4;
54  static constexpr unsigned int Npars5 = 5;
55  static constexpr float MagConstant =
56  CLHEP::c_light / 1.0E3; //constant is 0.299792458; who knew c_light was in mm/ns?
57 
58 public:
60  TTTrack();
61 
62  TTTrack(double aRinv,
63  double aphi,
64  double aTanLambda,
65  double az0,
66  double ad0,
67  double aChi2,
68  double trkMVA1,
69  double trkMVA2,
70  double trkMVA3,
71  unsigned int aHitpattern,
72  unsigned int nPar,
73  double Bfield);
74 
75  TTTrack(double aRinv,
76  double aphi,
77  double aTanLambda,
78  double az0,
79  double ad0,
80  double aChi2xyfit,
81  double aChi2zfit,
82  double trkMVA1,
83  double trkMVA2,
84  double trkMVA3,
85  unsigned int aHitpattern,
86  unsigned int nPar,
87  double Bfield);
88 
90  ~TTTrack();
91 
93  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > > getStubRefs() const { return theStubRefs; }
94  void addStubRef(edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > aStub) { theStubRefs.push_back(aStub); }
96  theStubRefs = aStubs;
97  }
98 
100  GlobalVector momentum() const;
101 
103  double rInv() const;
104 
106  double phi() const;
107 
109  double localPhi() const;
110 
112  double tanL() const;
113 
115  double d0() const;
116 
118  double z0() const;
119 
121  double eta() const;
122 
124  GlobalPoint POCA() const;
125 
127  double trkMVA1() const;
128  void settrkMVA1(double atrkMVA1);
129  double trkMVA2() const;
130  void settrkMVA2(double atrkMVA2);
131  double trkMVA3() const;
132  void settrkMVA3(double atrkMVA3);
133 
135  unsigned int phiSector() const { return thePhiSector_; }
136  void setPhiSector(unsigned int aSector) { thePhiSector_ = aSector; }
137 
139  unsigned int etaSector() const { return theEtaSector_; }
140  void setEtaSector(unsigned int aSector) { theEtaSector_ = aSector; }
141 
143  unsigned int trackSeedType() const { return theTrackSeedType_; }
144  void setTrackSeedType(int aSeed) { theTrackSeedType_ = aSeed; }
145 
147  double chi2() const;
148  double chi2Red() const;
149  double chi2Z() const;
150  double chi2ZRed() const;
151  double chi2XY() const;
152  double chi2XYRed() const;
153 
157  double stubPtConsistency() const;
158  void setStubPtConsistency(double aPtConsistency);
159  double chi2BendRed() { return stubPtConsistency(); }
160  void setChi2BendRed(double aChi2BendRed) { setStubPtConsistency(aChi2BendRed); }
161  double chi2Bend() { return chi2BendRed() * theStubRefs.size(); }
162 
163  void setFitParNo(unsigned int aFitParNo);
164  int nFitPars() const { return theNumFitPars_; }
165 
167  unsigned int hitPattern() const;
168 
170  void setBField(double aBField);
171 
172  void setTrackWordBits();
173  void testTrackWordBits();
174 
176  std::string print(unsigned int i = 0) const;
177 
178 };
179 
187 template <typename T>
190  theStubRefs.clear();
191  theMomentum_ = GlobalVector(0.0, 0.0, 0.0);
192  theRInv_ = 0.0;
193  thePOCA_ = GlobalPoint(0.0, 0.0, 0.0);
194  theD0_ = 0.;
195  theZ0_ = 0.;
196  theTanL_ = 0;
197  thePhi_ = 0;
198  theTrkMVA1_ = 0;
199  theTrkMVA2_ = 0;
200  theTrkMVA3_ = 0;
201  thePhiSector_ = 0;
202  theEtaSector_ = 0;
203  theTrackSeedType_ = 0;
204  theChi2_ = 0.0;
205  theChi2_XY_ = 0.0;
206  theChi2_Z_ = 0.0;
207  theStubPtConsistency_ = 0.0;
208  theNumFitPars_ = 0;
209 }
210 
212 template <typename T>
213 TTTrack<T>::TTTrack(double aRinv,
214  double aphi0,
215  double aTanlambda,
216  double az0,
217  double ad0,
218  double aChi2,
219  double trkMVA1,
220  double trkMVA2,
221  double trkMVA3,
222  unsigned int aHitPattern,
223  unsigned int nPar,
224  double aBfield) {
225  theStubRefs.clear();
226  double thePT = std::abs(MagConstant / aRinv * aBfield / 100.0); // Rinv is in cm-1
227  theMomentum_ = GlobalVector(GlobalVector::Cylindrical(thePT, aphi0, thePT * aTanlambda));
228  theRInv_ = aRinv;
229  thePOCA_ = GlobalPoint(ad0 * sin(aphi0), -ad0 * cos(aphi0), az0);
230  theD0_ = ad0;
231  theZ0_ = az0;
232  thePhi_ = aphi0;
233  theTanL_ = aTanlambda;
234  thePhiSector_ = 0; // must be set externally
235  theEtaSector_ = 0; // must be set externally
236  theTrackSeedType_ = 0; // must be set externally
237  theChi2_ = aChi2;
238  theTrkMVA1_ = trkMVA1;
239  theTrkMVA2_ = trkMVA2;
240  theTrkMVA3_ = trkMVA3;
241  theStubPtConsistency_ = 0.0; // must be set externally
242  theNumFitPars_ = nPar;
243  theHitPattern_ = aHitPattern;
244  theBField_ = aBfield;
245  theChi2_XY_ = -999.;
246  theChi2_Z_ = -999.;
247 }
248 
250 template <typename T>
251 TTTrack<T>::TTTrack(double aRinv,
252  double aphi0,
253  double aTanlambda,
254  double az0,
255  double ad0,
256  double aChi2XY,
257  double aChi2Z,
258  double trkMVA1,
259  double trkMVA2,
260  double trkMVA3,
261  unsigned int aHitPattern,
262  unsigned int nPar,
263  double aBfield)
264  : TTTrack(aRinv,
265  aphi0,
266  aTanlambda,
267  az0,
268  ad0,
269  aChi2XY + aChi2Z, // add chi2 values
270  trkMVA1,
271  trkMVA2,
272  trkMVA3,
273  aHitPattern,
274  nPar,
275  aBfield) {
276  this->theChi2_XY_ = aChi2XY;
277  this->theChi2_Z_ = aChi2Z;
278 }
279 
281 template <typename T>
283 
284 template <typename T>
285 void TTTrack<T>::setFitParNo(unsigned int nPar) {
286  theNumFitPars_ = nPar;
287 
288  return;
289 }
290 
291 // Note that these calls return the floating point values. If a TTTrack is made with only ditized values,
292 // the unpacked values must come from the TTTrack_Trackword member functions.
293 
294 template <typename T>
296  return theMomentum_;
297 }
298 
299 template <typename T>
300 double TTTrack<T>::rInv() const {
301  return theRInv_;
302 }
303 
304 template <typename T>
305 double TTTrack<T>::tanL() const {
306  return theTanL_;
307 }
308 
309 template <typename T>
310 double TTTrack<T>::eta() const {
311  return theMomentum_.eta();
312 }
313 
314 template <typename T>
315 double TTTrack<T>::phi() const {
316  return thePhi_;
317 }
318 
319 template <typename T>
320 double TTTrack<T>::localPhi() const {
321  return TTTrack_TrackWord::localPhi(thePhi_, thePhiSector_);
322 }
323 
324 template <typename T>
325 double TTTrack<T>::d0() const {
326  return theD0_;
327 }
328 
329 template <typename T>
330 double TTTrack<T>::z0() const {
331  return theZ0_;
332 }
333 
334 template <typename T>
336  return thePOCA_;
337 }
338 
340 template <typename T>
341 double TTTrack<T>::chi2() const {
342  return theChi2_;
343 }
344 
346 template <typename T>
347 double TTTrack<T>::chi2Z() const {
348  return theChi2_Z_;
349 }
350 
352 template <typename T>
353 double TTTrack<T>::chi2XY() const {
354  return theChi2_XY_;
355 }
356 
358 template <typename T>
359 double TTTrack<T>::chi2Red() const {
360  return theChi2_ / (2 * theStubRefs.size() - theNumFitPars_);
361 }
362 
364 template <typename T>
365 double TTTrack<T>::chi2XYRed() const {
366  return theChi2_XY_ / (theStubRefs.size() - (theNumFitPars_ - 2));
367 }
368 
370 template <typename T>
371 double TTTrack<T>::chi2ZRed() const {
372  return theChi2_Z_ / (theStubRefs.size() - 2.);
373 }
374 
376 template <typename T>
377 double TTTrack<T>::trkMVA1() const {
378  return theTrkMVA1_;
379 }
380 
381 template <typename T>
382 void TTTrack<T>::settrkMVA1(double atrkMVA1) {
383  theTrkMVA1_ = atrkMVA1;
384  return;
385 }
386 
387 template <typename T>
388 double TTTrack<T>::trkMVA2() const {
389  return theTrkMVA2_;
390 }
391 
392 template <typename T>
393 void TTTrack<T>::settrkMVA2(double atrkMVA2) {
394  theTrkMVA2_ = atrkMVA2;
395  return;
396 }
397 
398 template <typename T>
399 double TTTrack<T>::trkMVA3() const {
400  return theTrkMVA3_;
401 }
402 
403 template <typename T>
404 void TTTrack<T>::settrkMVA3(double atrkMVA3) {
405  theTrkMVA3_ = atrkMVA3;
406  return;
407 }
408 
410 template <typename T>
411 void TTTrack<T>::setStubPtConsistency(double aStubPtConsistency) {
412  theStubPtConsistency_ = aStubPtConsistency;
413  return;
414 }
415 
417 template <typename T>
419  return theStubPtConsistency_;
420 }
421 
423 template <typename T>
424 unsigned int TTTrack<T>::hitPattern() const {
425  return theHitPattern_;
426 }
427 
429 template <typename T>
430 void TTTrack<T>::setBField(double aBField) {
431  // if, for some reason, we want to change the value of the B-Field, recompute pT and momentum:
432  double thePT = std::abs(MagConstant / theRInv_ * aBField / 100.0); // Rinv is in cm-1
433  theMomentum_ = GlobalVector(GlobalVector::Cylindrical(thePT, thePhi_, thePT * theTanL_));
434 
435  return;
436 }
437 
439 template <typename T>
441  if (!(theNumFitPars_ == Npars4 || theNumFitPars_ == Npars5)) {
442  tttrack::errorSetTrackWordBits(theNumFitPars_);
443  return;
444  }
445 
446  unsigned int valid = true;
447  unsigned int mvaOther = 0;
448 
449  // missing conversion of global phi to difference from sector center phi
450 
451  if (theChi2_Z_ < 0) {
452  setTrackWord(valid,
453  theMomentum_,
454  thePOCA_,
455  theRInv_,
456  theChi2_,
457  0,
458  theStubPtConsistency_,
459  theHitPattern_,
460  theTrkMVA1_,
461  mvaOther,
462  thePhiSector_);
463  } else {
464  setTrackWord(valid,
465  theMomentum_,
466  thePOCA_,
467  theRInv_,
468  chi2XYRed(),
469  chi2ZRed(),
470  chi2BendRed(),
471  theHitPattern_,
472  theTrkMVA1_,
473  mvaOther,
474  thePhiSector_);
475  }
476  return;
477 }
478 
480 template <typename T>
482  // float rPhi = theMomentum_.phi(); // this needs to be phi relative to center of sector ****
483  //float rEta = theMomentum_.eta();
484  //float rZ0 = thePOCA_.z();
485  //float rD0 = thePOCA_.perp();
486 
487  //this is meant for debugging only.
488 
489  //std::cout << " phi " << rPhi << " " << get_iphi() << std::endl;
490  //std::cout << " eta " << rEta << " " << get_ieta() << std::endl;
491  //std::cout << " Z0 " << rZ0 << " " << get_iz0() << std::endl;
492  //std::cout << " D0 " << rD0 << " " << get_id0() << std::endl;
493  //std::cout << " Rinv " << theRInv_ << " " << get_iRinv() << std::endl;
494  //std::cout << " chi2 " << theChi2_ << " " << get_ichi2() << std::endl;
495 
496  return;
497 }
498 
500 template <typename T>
501 std::string TTTrack<T>::print(unsigned int i) const {
502  std::string padding("");
503  for (unsigned int j = 0; j != i; ++j) {
504  padding += "\t";
505  }
506 
507  std::stringstream output;
508  output << padding << "TTTrack:\n";
509  padding += '\t';
510  output << '\n';
511  unsigned int iStub = 0;
512 
513  typename std::vector<edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > >::const_iterator stubIter;
514  for (stubIter = theStubRefs.begin(); stubIter != theStubRefs.end(); ++stubIter) {
515  output << padding << "stub: " << iStub++ << ", DetId: " << ((*stubIter)->getDetId()).rawId() << '\n';
516  }
517 
518  return output.str();
519 }
520 
521 template <typename T>
522 std::ostream& operator<<(std::ostream& os, const TTTrack<T>& aTTTrack) {
523  return (os << aTTTrack.print());
524 }
525 
526 #endif
unsigned int thePhiSector_
Definition: TTTrack.h:40
double eta() const
Track eta.
Definition: TTTrack.h:310
double theStubPtConsistency_
Definition: TTTrack.h:42
void setBField(double aBField)
set new Bfield
Definition: TTTrack.h:430
void testTrackWordBits()
Test bits in 96-bit Track word.
Definition: TTTrack.h:481
double theTrkMVA2_
Definition: TTTrack.h:49
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double trkMVA1() const
MVA Track quality variables.
Definition: TTTrack.h:377
double thePhi_
Definition: TTTrack.h:36
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
unsigned int trackSeedType() const
Track seeding (for debugging)
Definition: TTTrack.h:143
double phi() const
Track phi.
Definition: TTTrack.h:315
double tanL() const
Track tanL.
Definition: TTTrack.h:305
void errorSetTrackWordBits(unsigned int)
Definition: TTTrack.cc:4
unsigned int hitPattern() const
Hit Pattern.
Definition: TTTrack.h:424
double chi2Z() const
Chi2Z.
Definition: TTTrack.h:347
~TTTrack()
Destructor.
Definition: TTTrack.h:282
GlobalVector momentum() const
Track momentum.
Definition: TTTrack.h:295
double theTanL_
Definition: TTTrack.h:37
std::vector< edm::Ref< edmNew::DetSetVector< TTStub< T > >, TTStub< T > > > theStubRefs
Data members.
Definition: TTTrack.h:32
TTTrack()
Constructors.
Definition: TTTrack.h:189
void setFitParNo(unsigned int aFitParNo)
Definition: TTTrack.h:285
int theTrackSeedType_
Definition: TTTrack.h:51
int nFitPars() const
Definition: TTTrack.h:164
double theRInv_
Definition: TTTrack.h:35
unsigned int theHitPattern_
Definition: TTTrack.h:47
double chi2ZRed() const
Chi2Z reduced.
Definition: TTTrack.h:371
void settrkMVA1(double atrkMVA1)
Definition: TTTrack.h:382
double chi2() const
Chi2.
Definition: TTTrack.h:341
void setEtaSector(unsigned int aSector)
Definition: TTTrack.h:140
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double theD0_
Definition: TTTrack.h:38
constexpr float Bfield
Definition: Config.h:60
double theBField_
Definition: TTTrack.h:52
GlobalVector theMomentum_
Definition: TTTrack.h:33
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned int phiSector() const
Phi Sector.
Definition: TTTrack.h:135
double rInv() const
Track curvature.
Definition: TTTrack.h:300
double chi2BendRed()
Definition: TTTrack.h:159
void addStubRef(edm::Ref< edmNew::DetSetVector< TTStub< T > >, TTStub< T > > aStub)
Definition: TTTrack.h:94
static constexpr unsigned int Npars4
Definition: TTTrack.h:53
double chi2XY() const
Chi2XY.
Definition: TTTrack.h:353
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
std::vector< edm::Ref< edmNew::DetSetVector< TTStub< T > >, TTStub< T > > > getStubRefs() const
Track components.
Definition: TTTrack.h:93
double trkMVA3() const
Definition: TTTrack.h:399
void setStubPtConsistency(double aPtConsistency)
StubPtConsistency.
Definition: TTTrack.h:411
double localPhi() const
Local track phi (within the sector)
Definition: TTTrack.h:320
void setChi2BendRed(double aChi2BendRed)
Definition: TTTrack.h:160
unsigned int theEtaSector_
Definition: TTTrack.h:41
static constexpr float MagConstant
Definition: TTTrack.h:55
void setStubRefs(std::vector< edm::Ref< edmNew::DetSetVector< TTStub< T > >, TTStub< T > > > aStubs)
Definition: TTTrack.h:95
void settrkMVA2(double atrkMVA2)
Definition: TTTrack.h:393
unsigned int theNumFitPars_
Definition: TTTrack.h:46
Class to store the L1 Track Trigger tracks.
Definition: TTTrack.h:29
void settrkMVA3(double atrkMVA3)
Definition: TTTrack.h:404
void setPhiSector(unsigned int aSector)
Definition: TTTrack.h:136
double stubPtConsistency() const
StubPtConsistency.
Definition: TTTrack.h:418
static constexpr unsigned int Npars5
Definition: TTTrack.h:54
double d0() const
Track d0.
Definition: TTTrack.h:325
double chi2Bend()
Definition: TTTrack.h:161
double theZ0_
Definition: TTTrack.h:39
double trkMVA2() const
Definition: TTTrack.h:388
GlobalPoint thePOCA_
Definition: TTTrack.h:34
double chi2Red() const
Chi2 reduced.
Definition: TTTrack.h:359
double z0() const
Track z0.
Definition: TTTrack.h:330
unsigned int etaSector() const
Eta Sector.
Definition: TTTrack.h:139
void setTrackSeedType(int aSeed)
Definition: TTTrack.h:144
Definition: output.py:1
double chi2XYRed() const
Chi2XY reduced.
Definition: TTTrack.h:365
double theChi2_
Definition: TTTrack.h:43
double theTrkMVA3_
Definition: TTTrack.h:50
std::string print(unsigned int i=0) const
Information.
Definition: TTTrack.h:501
void setTrackWordBits()
Set bits in 96-bit Track word.
Definition: TTTrack.h:440
GlobalPoint POCA() const
POCA.
Definition: TTTrack.h:335
double theChi2_Z_
Definition: TTTrack.h:45
double theTrkMVA1_
Definition: TTTrack.h:48
Global3DVector GlobalVector
Definition: GlobalVector.h:10
float localPhi(float globalPhi, unsigned int sector) const
double theChi2_XY_
Definition: TTTrack.h:44