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 tanL() const;
110 
112  double d0() const;
113 
115  double z0() const;
116 
118  double eta() const;
119 
121  GlobalPoint POCA() const;
122 
124  double trkMVA1() const;
125  void settrkMVA1(double atrkMVA1);
126  double trkMVA2() const;
127  void settrkMVA2(double atrkMVA2);
128  double trkMVA3() const;
129  void settrkMVA3(double atrkMVA3);
130 
132  unsigned int phiSector() const { return thePhiSector_; }
133  void setPhiSector(unsigned int aSector) { thePhiSector_ = aSector; }
134 
136  unsigned int etaSector() const { return theEtaSector_; }
137  void setEtaSector(unsigned int aSector) { theEtaSector_ = aSector; }
138 
140  unsigned int trackSeedType() const { return theTrackSeedType_; }
141  void setTrackSeedType(int aSeed) { theTrackSeedType_ = aSeed; }
142 
144  double chi2() const;
145  double chi2Red() const;
146  double chi2Z() const;
147  double chi2ZRed() const;
148  double chi2XY() const;
149  double chi2XYRed() const;
150 
152  double stubPtConsistency() const;
153  void setStubPtConsistency(double aPtConsistency);
154 
155  void setFitParNo(unsigned int aFitParNo);
156  int nFitPars() const { return theNumFitPars_; }
157 
159  unsigned int hitPattern() const;
160 
162  void setBField(double aBField);
163 
164  void setTrackWordBits();
165  void testTrackWordBits();
166 
168  std::string print(unsigned int i = 0) const;
169 
170 };
171 
179 template <typename T>
182  theStubRefs.clear();
183  theMomentum_ = GlobalVector(0.0, 0.0, 0.0);
184  theRInv_ = 0.0;
185  thePOCA_ = GlobalPoint(0.0, 0.0, 0.0);
186  theD0_ = 0.;
187  theZ0_ = 0.;
188  theTanL_ = 0;
189  thePhi_ = 0;
190  theTrkMVA1_ = 0;
191  theTrkMVA2_ = 0;
192  theTrkMVA3_ = 0;
193  thePhiSector_ = 0;
194  theEtaSector_ = 0;
195  theTrackSeedType_ = 0;
196  theChi2_ = 0.0;
197  theChi2_XY_ = 0.0;
198  theChi2_Z_ = 0.0;
199  theStubPtConsistency_ = 0.0;
200  theNumFitPars_ = 0;
201 }
202 
204 template <typename T>
205 TTTrack<T>::TTTrack(double aRinv,
206  double aphi0,
207  double aTanlambda,
208  double az0,
209  double ad0,
210  double aChi2,
211  double trkMVA1,
212  double trkMVA2,
213  double trkMVA3,
214  unsigned int aHitPattern,
215  unsigned int nPar,
216  double aBfield) {
217  theStubRefs.clear();
218  double thePT = std::abs(MagConstant / aRinv * aBfield / 100.0); // Rinv is in cm-1
219  theMomentum_ = GlobalVector(GlobalVector::Cylindrical(thePT, aphi0, thePT * aTanlambda));
220  theRInv_ = aRinv;
221  thePOCA_ = GlobalPoint(ad0 * sin(aphi0), -ad0 * cos(aphi0), az0);
222  theD0_ = ad0;
223  theZ0_ = az0;
224  thePhi_ = aphi0;
225  theTanL_ = aTanlambda;
226  thePhiSector_ = 0; // must be set externally
227  theEtaSector_ = 0; // must be set externally
228  theTrackSeedType_ = 0; // must be set externally
229  theChi2_ = aChi2;
230  theTrkMVA1_ = trkMVA1;
231  theTrkMVA2_ = trkMVA2;
232  theTrkMVA3_ = trkMVA3;
233  theStubPtConsistency_ = 0.0; // must be set externally
234  theNumFitPars_ = nPar;
235  theHitPattern_ = aHitPattern;
236  theBField_ = aBfield;
237  theChi2_XY_ = -999.;
238  theChi2_Z_ = -999.;
239 }
240 
242 template <typename T>
243 TTTrack<T>::TTTrack(double aRinv,
244  double aphi0,
245  double aTanlambda,
246  double az0,
247  double ad0,
248  double aChi2XY,
249  double aChi2Z,
250  double trkMVA1,
251  double trkMVA2,
252  double trkMVA3,
253  unsigned int aHitPattern,
254  unsigned int nPar,
255  double aBfield)
256  : TTTrack(aRinv,
257  aphi0,
258  aTanlambda,
259  az0,
260  ad0,
261  aChi2XY + aChi2Z, // add chi2 values
262  trkMVA1,
263  trkMVA2,
264  trkMVA3,
265  aHitPattern,
266  nPar,
267  aBfield) {
268  this->theChi2_XY_ = aChi2XY;
269  this->theChi2_Z_ = aChi2Z;
270 }
271 
273 template <typename T>
275 
276 template <typename T>
277 void TTTrack<T>::setFitParNo(unsigned int nPar) {
278  theNumFitPars_ = nPar;
279 
280  return;
281 }
282 
283 // Note that these calls return the floating point values. If a TTTrack is made with only ditized values,
284 // the unpacked values must come from the TTTrack_Trackword member functions.
285 
286 template <typename T>
288  return theMomentum_;
289 }
290 
291 template <typename T>
292 double TTTrack<T>::rInv() const {
293  return theRInv_;
294 }
295 
296 template <typename T>
297 double TTTrack<T>::tanL() const {
298  return theTanL_;
299 }
300 
301 template <typename T>
302 double TTTrack<T>::eta() const {
303  return theMomentum_.eta();
304 }
305 
306 template <typename T>
307 double TTTrack<T>::phi() const {
308  return thePhi_;
309 }
310 
311 template <typename T>
312 double TTTrack<T>::d0() const {
313  return theD0_;
314 }
315 
316 template <typename T>
317 double TTTrack<T>::z0() const {
318  return theZ0_;
319 }
320 
321 template <typename T>
323  return thePOCA_;
324 }
325 
327 template <typename T>
328 double TTTrack<T>::chi2() const {
329  return theChi2_;
330 }
331 
333 template <typename T>
334 double TTTrack<T>::chi2Z() const {
335  return theChi2_Z_;
336 }
337 
339 template <typename T>
340 double TTTrack<T>::chi2XY() const {
341  return theChi2_XY_;
342 }
343 
345 template <typename T>
346 double TTTrack<T>::chi2Red() const {
347  return theChi2_ / (2 * theStubRefs.size() - theNumFitPars_);
348 }
349 
351 template <typename T>
352 double TTTrack<T>::chi2XYRed() const {
353  return theChi2_XY_ / (theStubRefs.size() - (theNumFitPars_ - 2));
354 }
355 
357 template <typename T>
358 double TTTrack<T>::chi2ZRed() const {
359  return theChi2_Z_ / (theStubRefs.size() - 2.);
360 }
361 
362 template <typename T>
363 double TTTrack<T>::trkMVA1() const {
364  return theTrkMVA1_;
365 }
366 
367 template <typename T>
368 void TTTrack<T>::settrkMVA1(double atrkMVA1) {
369  theTrkMVA1_ = atrkMVA1;
370  return;
371 }
372 
373 template <typename T>
374 double TTTrack<T>::trkMVA2() const {
375  return theTrkMVA2_;
376 }
377 
378 template <typename T>
379 void TTTrack<T>::settrkMVA2(double atrkMVA2) {
380  theTrkMVA2_ = atrkMVA2;
381  return;
382 }
383 
384 template <typename T>
385 double TTTrack<T>::trkMVA3() const {
386  return theTrkMVA3_;
387 }
388 
389 template <typename T>
390 void TTTrack<T>::settrkMVA3(double atrkMVA3) {
391  theTrkMVA3_ = atrkMVA3;
392  return;
393 }
394 
396 template <typename T>
397 void TTTrack<T>::setStubPtConsistency(double aStubPtConsistency) {
398  theStubPtConsistency_ = aStubPtConsistency;
399  return;
400 }
401 
403 template <typename T>
405  return theStubPtConsistency_;
406 }
407 
409 template <typename T>
410 unsigned int TTTrack<T>::hitPattern() const {
411  return theHitPattern_;
412 }
413 
415 template <typename T>
416 void TTTrack<T>::setBField(double aBField) {
417  // if, for some reason, we want to change the value of the B-Field, recompute pT and momentum:
418  double thePT = std::abs(MagConstant / theRInv_ * aBField / 100.0); // Rinv is in cm-1
419  theMomentum_ = GlobalVector(GlobalVector::Cylindrical(thePT, thePhi_, thePT * theTanL_));
420 
421  return;
422 }
423 
425 template <typename T>
427  if (!(theNumFitPars_ == Npars4 || theNumFitPars_ == Npars5)) {
428  tttrack::errorSetTrackWordBits(theNumFitPars_);
429  return;
430  }
431 
432  unsigned int sparebits = 0;
433 
434  // missing conversion of global phi to difference from sector center phi
435 
436  if (theChi2_Z_ < 0) {
437  setTrackWord(theMomentum_, thePOCA_, theRInv_, theChi2_, 0, theStubPtConsistency_, theHitPattern_, sparebits);
438 
439  } else {
440  setTrackWord(
441  theMomentum_, thePOCA_, theRInv_, theChi2_XY_, theChi2_Z_, theStubPtConsistency_, theHitPattern_, sparebits);
442  }
443  return;
444 }
445 
447 template <typename T>
449  // float rPhi = theMomentum_.phi(); // this needs to be phi relative to center of sector ****
450  //float rEta = theMomentum_.eta();
451  //float rZ0 = thePOCA_.z();
452  //float rD0 = thePOCA_.perp();
453 
454  //this is meant for debugging only.
455 
456  //std::cout << " phi " << rPhi << " " << get_iphi() << std::endl;
457  //std::cout << " eta " << rEta << " " << get_ieta() << std::endl;
458  //std::cout << " Z0 " << rZ0 << " " << get_iz0() << std::endl;
459  //std::cout << " D0 " << rD0 << " " << get_id0() << std::endl;
460  //std::cout << " Rinv " << theRInv_ << " " << get_iRinv() << std::endl;
461  //std::cout << " chi2 " << theChi2_ << " " << get_ichi2() << std::endl;
462 
463  return;
464 }
465 
467 template <typename T>
468 std::string TTTrack<T>::print(unsigned int i) const {
469  std::string padding("");
470  for (unsigned int j = 0; j != i; ++j) {
471  padding += "\t";
472  }
473 
474  std::stringstream output;
475  output << padding << "TTTrack:\n";
476  padding += '\t';
477  output << '\n';
478  unsigned int iStub = 0;
479 
480  typename std::vector<edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > >::const_iterator stubIter;
481  for (stubIter = theStubRefs.begin(); stubIter != theStubRefs.end(); ++stubIter) {
482  output << padding << "stub: " << iStub++ << ", DetId: " << ((*stubIter)->getDetId()).rawId() << '\n';
483  }
484 
485  return output.str();
486 }
487 
488 template <typename T>
489 std::ostream& operator<<(std::ostream& os, const TTTrack<T>& aTTTrack) {
490  return (os << aTTTrack.print());
491 }
492 
493 #endif
Vector3DBase
Definition: Vector3DBase.h:8
TTTrack::theTrkMVA1_
double theTrkMVA1_
Definition: TTTrack.h:48
TTTrack::chi2XY
double chi2XY() const
Chi2XY.
Definition: TTTrack.h:340
mps_fire.i
i
Definition: mps_fire.py:428
TTTrack::chi2XYRed
double chi2XYRed() const
Chi2XY reduced.
Definition: TTTrack.h:352
TTTrack::chi2Red
double chi2Red() const
Chi2 reduced.
Definition: TTTrack.h:346
TTTrack::chi2
double chi2() const
Chi2.
Definition: TTTrack.h:328
TTTrack::theEtaSector_
unsigned int theEtaSector_
Definition: TTTrack.h:41
TTTrack::momentum
GlobalVector momentum() const
Track momentum.
Definition: TTTrack.h:287
TTTrack::setStubPtConsistency
void setStubPtConsistency(double aPtConsistency)
StubPtConsistency.
Definition: TTTrack.h:397
TTTrack::nFitPars
int nFitPars() const
Definition: TTTrack.h:156
TTTrack::chi2Z
double chi2Z() const
Chi2Z.
Definition: TTTrack.h:334
TTTrack::~TTTrack
~TTTrack()
Destructor.
Definition: TTTrack.h:274
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
TTTrack::addStubRef
void addStubRef(edm::Ref< edmNew::DetSetVector< TTStub< T > >, TTStub< T > > aStub)
Definition: TTTrack.h:94
TTTrack
Class to store the L1 Track Trigger tracks.
Definition: TTTrack.h:29
TTTrack::phi
double phi() const
Track phi.
Definition: TTTrack.h:307
TTTrack::setStubRefs
void setStubRefs(std::vector< edm::Ref< edmNew::DetSetVector< TTStub< T > >, TTStub< T > > > aStubs)
Definition: TTTrack.h:95
TTTrack::theHitPattern_
unsigned int theHitPattern_
Definition: TTTrack.h:47
TTTrack::Npars4
static constexpr unsigned int Npars4
Definition: TTTrack.h:53
TTTrack::setTrackSeedType
void setTrackSeedType(int aSeed)
Definition: TTTrack.h:141
TTTrack::settrkMVA3
void settrkMVA3(double atrkMVA3)
Definition: TTTrack.h:390
TTTrack_TrackWord.h
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
TTTrack::theTrkMVA2_
double theTrkMVA2_
Definition: TTTrack.h:49
TTTrack::rInv
double rInv() const
Track curvature.
Definition: TTTrack.h:292
tttrack::errorSetTrackWordBits
void errorSetTrackWordBits(unsigned int)
Definition: TTTrack.cc:4
TTTrack::TTTrack
TTTrack()
Constructors.
Definition: TTTrack.h:181
edm::Ref
Definition: AssociativeIterator.h:58
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
HcalResponse_cfi.nPar
nPar
Definition: HcalResponse_cfi.py:33
TTTrack::POCA
GlobalPoint POCA() const
POCA.
Definition: TTTrack.h:322
TTTrack::hitPattern
unsigned int hitPattern() const
Hit Pattern.
Definition: TTTrack.h:410
TTTrack::getStubRefs
std::vector< edm::Ref< edmNew::DetSetVector< TTStub< T > >, TTStub< T > > > getStubRefs() const
Track components.
Definition: TTTrack.h:93
TrackerTopology.h
TTTrack::theNumFitPars_
unsigned int theNumFitPars_
Definition: TTTrack.h:46
tttrack
Definition: TTTrack.h:24
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TTTrack::chi2ZRed
double chi2ZRed() const
Chi2Z reduced.
Definition: TTTrack.h:358
TTTrack::setTrackWordBits
void setTrackWordBits()
Set bits in 96-bit Track word.
Definition: TTTrack.h:426
Geom::Cylindrical2Cartesian
Definition: CoordinateSets.h:34
TTStub
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
TTTrack::MagConstant
static constexpr float MagConstant
Definition: TTTrack.h:55
TTTrack::theZ0_
double theZ0_
Definition: TTTrack.h:39
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TTTrack::setFitParNo
void setFitParNo(unsigned int aFitParNo)
Definition: TTTrack.h:277
TTTrack::theBField_
double theBField_
Definition: TTTrack.h:52
Phase2TrackerDigi.h
TTTrack::d0
double d0() const
Track d0.
Definition: TTTrack.h:312
TTTrack::stubPtConsistency
double stubPtConsistency() const
Stub Pt consistency.
Definition: TTTrack.h:404
operator<<
std::ostream & operator<<(std::ostream &os, const TTTrack< T > &aTTTrack)
Definition: TTTrack.h:489
TTTrack::theChi2_
double theChi2_
Definition: TTTrack.h:43
TTTrack::trackSeedType
unsigned int trackSeedType() const
Track seeding (for debugging)
Definition: TTTrack.h:140
TTTrack::tanL
double tanL() const
Track tanL.
Definition: TTTrack.h:297
TTTrack::thePhiSector_
unsigned int thePhiSector_
Definition: TTTrack.h:40
TTTrack::z0
double z0() const
Track z0.
Definition: TTTrack.h:317
TTTrack::theMomentum_
GlobalVector theMomentum_
Definition: TTTrack.h:33
TTTrack::testTrackWordBits
void testTrackWordBits()
Test bits in 96-bit Track word.
Definition: TTTrack.h:448
TTTrack::trkMVA1
double trkMVA1() const
MVA Track quality variables.
Definition: TTTrack.h:363
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
TTTrack::theTrackSeedType_
int theTrackSeedType_
Definition: TTTrack.h:51
TTTrack::Npars5
static constexpr unsigned int Npars5
Definition: TTTrack.h:54
TTTrack::theD0_
double theD0_
Definition: TTTrack.h:38
TTTrack::setEtaSector
void setEtaSector(unsigned int aSector)
Definition: TTTrack.h:137
TTTrack::settrkMVA2
void settrkMVA2(double atrkMVA2)
Definition: TTTrack.h:379
TTTrack::theChi2_Z_
double theChi2_Z_
Definition: TTTrack.h:45
TTTrack::print
std::string print(unsigned int i=0) const
Information.
Definition: TTTrack.h:468
edmNew::DetSetVector
Definition: DetSetNew.h:13
TTTrack::theRInv_
double theRInv_
Definition: TTTrack.h:35
TTTrack::thePOCA_
GlobalPoint thePOCA_
Definition: TTTrack.h:34
TTTrack::theTanL_
double theTanL_
Definition: TTTrack.h:37
TTTrack::settrkMVA1
void settrkMVA1(double atrkMVA1)
Definition: TTTrack.h:368
TTTrack::theStubRefs
std::vector< edm::Ref< edmNew::DetSetVector< TTStub< T > >, TTStub< T > > > theStubRefs
Data members.
Definition: TTTrack.h:32
TTStub.h
TTTrack::etaSector
unsigned int etaSector() const
Eta Sector.
Definition: TTTrack.h:136
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TTTrack::setPhiSector
void setPhiSector(unsigned int aSector)
Definition: TTTrack.h:133
TTTrack::theChi2_XY_
double theChi2_XY_
Definition: TTTrack.h:44
TTTrack::theTrkMVA3_
double theTrkMVA3_
Definition: TTTrack.h:50
TTTrack::theStubPtConsistency_
double theStubPtConsistency_
Definition: TTTrack.h:42
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TTTrack::trkMVA2
double trkMVA2() const
Definition: TTTrack.h:374
TTTrack_TrackWord
Definition: TTTrack_TrackWord.h:19
TTTrack::thePhi_
double thePhi_
Definition: TTTrack.h:36
StripSubdetector.h
DetSetVectorNew.h
TTTrack::eta
double eta() const
Track eta.
Definition: TTTrack.h:302
TTTrack::trkMVA3
double trkMVA3() const
Definition: TTTrack.h:385
TTTrack::setBField
void setBField(double aBField)
set new Bfield
Definition: TTTrack.h:416
TTTrack::phiSector
unsigned int phiSector() const
Phi Sector.
Definition: TTTrack.h:132