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"
24 
25 template <typename T>
26 class TTTrack : public TTTrack_TrackWord {
27 private:
29  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > > theStubRefs;
32  double theRInv_;
33  double thePhi_;
34  double theTanL_;
35  double theD0_;
36  double theZ0_;
37  unsigned int thePhiSector_;
38  unsigned int theEtaSector_;
40  double theChi2_;
41  double theChi2_XY_;
42  double theChi2_Z_;
43  unsigned int theNumFitPars_;
44  unsigned int theHitPattern_;
45  double theTrkMVA1_;
46  double theTrkMVA2_;
47  double theTrkMVA3_;
49  double theBField_; // needed for unpacking
50  static constexpr unsigned int Npars4 = 4;
51  static constexpr unsigned int Npars5 = 5;
52  static constexpr float MagConstant =
53  CLHEP::c_light / 1.0E3; //constant is 0.299792458; who knew c_light was in mm/ns?
54 
55 public:
57  TTTrack();
58 
59  TTTrack(double aRinv,
60  double aphi,
61  double aTanLambda,
62  double az0,
63  double ad0,
64  double aChi2,
65  double trkMVA1,
66  double trkMVA2,
67  double trkMVA3,
68  unsigned int aHitpattern,
69  unsigned int nPar,
70  double Bfield);
71 
72  TTTrack(double aRinv,
73  double aphi,
74  double aTanLambda,
75  double az0,
76  double ad0,
77  double aChi2xyfit,
78  double aChi2zfit,
79  double trkMVA1,
80  double trkMVA2,
81  double trkMVA3,
82  unsigned int aHitpattern,
83  unsigned int nPar,
84  double Bfield);
85 
87  ~TTTrack();
88 
90  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > > getStubRefs() const { return theStubRefs; }
91  void addStubRef(edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > aStub) { theStubRefs.push_back(aStub); }
93  theStubRefs = aStubs;
94  }
95 
97  GlobalVector momentum() const;
98 
100  double rInv() const;
101 
103  double phi() const;
104 
106  double tanL() const;
107 
109  double d0() const;
110 
112  double z0() const;
113 
115  double eta() const;
116 
118  GlobalPoint POCA() const;
119 
121  double trkMVA1() const;
122  double trkMVA2() const;
123  double trkMVA3() const;
124 
126  unsigned int phiSector() const { return thePhiSector_; }
127  void setPhiSector(unsigned int aSector) { thePhiSector_ = aSector; }
128 
130  unsigned int etaSector() const { return theEtaSector_; }
131  void setEtaSector(unsigned int aSector) { theEtaSector_ = aSector; }
132 
134  unsigned int trackSeedType() const { return theTrackSeedType_; }
135  void setTrackSeedType(int aSeed) { theTrackSeedType_ = aSeed; }
136 
138  double chi2() const;
139  double chi2Red() const;
140  double chi2Z() const;
141  double chi2ZRed() const;
142  double chi2XY() const;
143  double chi2XYRed() const;
144 
146  double stubPtConsistency() const;
147  void setStubPtConsistency(double aPtConsistency);
148 
149  void setFitParNo(unsigned int aFitParNo);
150  int nFitPars() const { return theNumFitPars_; }
151 
153  unsigned int hitPattern() const;
154 
156  void setBField(double aBField);
157 
158  void setTrackWordBits();
159  void testTrackWordBits();
160 
162  std::string print(unsigned int i = 0) const;
163 
164 };
165 
173 template <typename T>
176  theStubRefs.clear();
177  theMomentum_ = GlobalVector(0.0, 0.0, 0.0);
178  theRInv_ = 0.0;
179  thePOCA_ = GlobalPoint(0.0, 0.0, 0.0);
180  theD0_ = 0.;
181  theZ0_ = 0.;
182  theTanL_ = 0;
183  thePhi_ = 0;
184  theTrkMVA1_ = 0;
185  theTrkMVA2_ = 0;
186  theTrkMVA3_ = 0;
187  thePhiSector_ = 0;
188  theEtaSector_ = 0;
189  theTrackSeedType_ = 0;
190  theChi2_ = 0.0;
191  theChi2_XY_ = 0.0;
192  theChi2_Z_ = 0.0;
193  theStubPtConsistency_ = 0.0;
194  theNumFitPars_ = 0;
195 }
196 
198 template <typename T>
199 TTTrack<T>::TTTrack(double aRinv,
200  double aphi0,
201  double aTanlambda,
202  double az0,
203  double ad0,
204  double aChi2,
205  double trkMVA1,
206  double trkMVA2,
207  double trkMVA3,
208  unsigned int aHitPattern,
209  unsigned int nPar,
210  double aBfield) {
211  theStubRefs.clear();
212  double thePT = std::abs(MagConstant / aRinv * aBfield / 100.0); // Rinv is in cm-1
213  theMomentum_ = GlobalVector(GlobalVector::Cylindrical(thePT, aphi0, thePT * aTanlambda));
214  theRInv_ = aRinv;
215  thePOCA_ = GlobalPoint(ad0 * sin(aphi0), -ad0 * cos(aphi0), az0);
216  theD0_ = ad0;
217  theZ0_ = az0;
218  thePhi_ = aphi0;
219  theTanL_ = aTanlambda;
220  thePhiSector_ = 0; // must be set externally
221  theEtaSector_ = 0; // must be set externally
222  theTrackSeedType_ = 0; // must be set externally
223  theChi2_ = aChi2;
224  theTrkMVA1_ = trkMVA1;
225  theTrkMVA2_ = trkMVA2;
226  theTrkMVA3_ = trkMVA3;
227  theStubPtConsistency_ = 0.0; // must be set externally
228  theNumFitPars_ = nPar;
229  theHitPattern_ = aHitPattern;
230  theBField_ = aBfield;
231  theChi2_XY_ = -999.;
232  theChi2_Z_ = -999.;
233 }
234 
236 template <typename T>
237 TTTrack<T>::TTTrack(double aRinv,
238  double aphi0,
239  double aTanlambda,
240  double az0,
241  double ad0,
242  double aChi2XY,
243  double aChi2Z,
244  double trkMVA1,
245  double trkMVA2,
246  double trkMVA3,
247  unsigned int aHitPattern,
248  unsigned int nPar,
249  double aBfield)
250  : TTTrack(aRinv,
251  aphi0,
252  aTanlambda,
253  az0,
254  ad0,
255  aChi2XY + aChi2Z, // add chi2 values
256  trkMVA1,
257  trkMVA2,
258  trkMVA3,
259  aHitPattern,
260  nPar,
261  aBfield) {
262  this->theChi2_XY_ = aChi2XY;
263  this->theChi2_Z_ = aChi2Z;
264 }
265 
267 template <typename T>
269 
270 template <typename T>
271 void TTTrack<T>::setFitParNo(unsigned int nPar) {
272  theNumFitPars_ = nPar;
273 
274  return;
275 }
276 
277 // Note that these calls return the floating point values. If a TTTrack is made with only ditized values,
278 // the unpacked values must come from the TTTrack_Trackword member functions.
279 
280 template <typename T>
282  return theMomentum_;
283 }
284 
285 template <typename T>
286 double TTTrack<T>::rInv() const {
287  return theRInv_;
288 }
289 
290 template <typename T>
291 double TTTrack<T>::tanL() const {
292  return theTanL_;
293 }
294 
295 template <typename T>
296 double TTTrack<T>::eta() const {
297  return theMomentum_.eta();
298 }
299 
300 template <typename T>
301 double TTTrack<T>::phi() const {
302  return thePhi_;
303 }
304 
305 template <typename T>
306 double TTTrack<T>::d0() const {
307  return theD0_;
308 }
309 
310 template <typename T>
311 double TTTrack<T>::z0() const {
312  return theZ0_;
313 }
314 
315 template <typename T>
317  return thePOCA_;
318 }
319 
321 template <typename T>
322 double TTTrack<T>::chi2() const {
323  return theChi2_;
324 }
325 
327 template <typename T>
328 double TTTrack<T>::chi2Z() const {
329  return theChi2_Z_;
330 }
331 
333 template <typename T>
334 double TTTrack<T>::chi2XY() const {
335  return theChi2_XY_;
336 }
337 
339 template <typename T>
340 double TTTrack<T>::chi2Red() const {
341  return theChi2_ / (2 * theStubRefs.size() - theNumFitPars_);
342 }
343 
345 template <typename T>
346 double TTTrack<T>::chi2XYRed() const {
347  return theChi2_XY_ / (theStubRefs.size() - (theNumFitPars_ - 2));
348 }
349 
351 template <typename T>
352 double TTTrack<T>::chi2ZRed() const {
353  return theChi2_Z_ / (theStubRefs.size() - 2.);
354 }
355 
357 template <typename T>
358 double TTTrack<T>::trkMVA1() const {
359  return theTrkMVA1_;
360 }
361 
362 template <typename T>
363 double TTTrack<T>::trkMVA2() const {
364  return theTrkMVA2_;
365 }
366 
367 template <typename T>
368 double TTTrack<T>::trkMVA3() const {
369  return theTrkMVA3_;
370 }
371 
373 template <typename T>
374 void TTTrack<T>::setStubPtConsistency(double aStubPtConsistency) {
375  theStubPtConsistency_ = aStubPtConsistency;
376  return;
377 }
378 
380 template <typename T>
382  return theStubPtConsistency_;
383 }
384 
386 template <typename T>
387 unsigned int TTTrack<T>::hitPattern() const {
388  return theHitPattern_;
389 }
390 
392 template <typename T>
393 void TTTrack<T>::setBField(double aBField) {
394  // if, for some reason, we want to change the value of the B-Field, recompute pT and momentum:
395  double thePT = std::abs(MagConstant / theRInv_ * aBField / 100.0); // Rinv is in cm-1
396  theMomentum_ = GlobalVector(GlobalVector::Cylindrical(thePT, thePhi_, thePT * theTanL_));
397 
398  return;
399 }
400 
402 template <typename T>
404  if (!(theNumFitPars_ == Npars4 || theNumFitPars_ == Npars5)) {
405  edm::LogError("TTTrack") << " setTrackWordBits method is called with theNumFitPars_=" << theNumFitPars_
406  << " only possible values are 4/5" << std::endl;
407  return;
408  }
409 
410  unsigned int sparebits = 0;
411 
412  // missing conversion of global phi to difference from sector center phi
413 
414  if (theChi2_Z_ < 0) {
415  setTrackWord(theMomentum_, thePOCA_, theRInv_, theChi2_, 0, theStubPtConsistency_, theHitPattern_, sparebits);
416 
417  } else {
418  setTrackWord(
419  theMomentum_, thePOCA_, theRInv_, theChi2_XY_, theChi2_Z_, theStubPtConsistency_, theHitPattern_, sparebits);
420  }
421  return;
422 }
423 
425 template <typename T>
427  // float rPhi = theMomentum_.phi(); // this needs to be phi relative to center of sector ****
428  //float rEta = theMomentum_.eta();
429  //float rZ0 = thePOCA_.z();
430  //float rD0 = thePOCA_.perp();
431 
432  //this is meant for debugging only.
433 
434  //std::cout << " phi " << rPhi << " " << get_iphi() << std::endl;
435  //std::cout << " eta " << rEta << " " << get_ieta() << std::endl;
436  //std::cout << " Z0 " << rZ0 << " " << get_iz0() << std::endl;
437  //std::cout << " D0 " << rD0 << " " << get_id0() << std::endl;
438  //std::cout << " Rinv " << theRInv_ << " " << get_iRinv() << std::endl;
439  //std::cout << " chi2 " << theChi2_ << " " << get_ichi2() << std::endl;
440 
441  return;
442 }
443 
445 template <typename T>
446 std::string TTTrack<T>::print(unsigned int i) const {
447  std::string padding("");
448  for (unsigned int j = 0; j != i; ++j) {
449  padding += "\t";
450  }
451 
452  std::stringstream output;
453  output << padding << "TTTrack:\n";
454  padding += '\t';
455  output << '\n';
456  unsigned int iStub = 0;
457 
458  typename std::vector<edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > >::const_iterator stubIter;
459  for (stubIter = theStubRefs.begin(); stubIter != theStubRefs.end(); ++stubIter) {
460  output << padding << "stub: " << iStub++ << ", DetId: " << ((*stubIter)->getDetId()).rawId() << '\n';
461  }
462 
463  return output.str();
464 }
465 
466 template <typename T>
467 std::ostream& operator<<(std::ostream& os, const TTTrack<T>& aTTTrack) {
468  return (os << aTTTrack.print());
469 }
470 
471 #endif
Vector3DBase
Definition: Vector3DBase.h:8
TTTrack::theTrkMVA1_
double theTrkMVA1_
Definition: TTTrack.h:45
TTTrack::chi2XY
double chi2XY() const
Chi2XY.
Definition: TTTrack.h:334
mps_fire.i
i
Definition: mps_fire.py:428
TTTrack::chi2XYRed
double chi2XYRed() const
Chi2XY reduced.
Definition: TTTrack.h:346
TTTrack::chi2Red
double chi2Red() const
Chi2 reduced.
Definition: TTTrack.h:340
MessageLogger.h
TTTrack::chi2
double chi2() const
Chi2.
Definition: TTTrack.h:322
TTTrack::theEtaSector_
unsigned int theEtaSector_
Definition: TTTrack.h:38
TTTrack::momentum
GlobalVector momentum() const
Track momentum.
Definition: TTTrack.h:281
TTTrack::setStubPtConsistency
void setStubPtConsistency(double aPtConsistency)
StubPtConsistency.
Definition: TTTrack.h:374
TTTrack::nFitPars
int nFitPars() const
Definition: TTTrack.h:150
TTTrack::chi2Z
double chi2Z() const
Chi2Z.
Definition: TTTrack.h:328
TTTrack::~TTTrack
~TTTrack()
Destructor.
Definition: TTTrack.h:268
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:91
TTTrack
Class to store the L1 Track Trigger tracks.
Definition: TTTrack.h:26
TTTrack::phi
double phi() const
Track phi.
Definition: TTTrack.h:301
TTTrack::setStubRefs
void setStubRefs(std::vector< edm::Ref< edmNew::DetSetVector< TTStub< T > >, TTStub< T > > > aStubs)
Definition: TTTrack.h:92
TTTrack::theHitPattern_
unsigned int theHitPattern_
Definition: TTTrack.h:44
TTTrack::Npars4
static constexpr unsigned int Npars4
Definition: TTTrack.h:50
TTTrack::setTrackSeedType
void setTrackSeedType(int aSeed)
Definition: TTTrack.h:135
TTTrack_TrackWord.h
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
TTTrack::theTrkMVA2_
double theTrkMVA2_
Definition: TTTrack.h:46
TTTrack::rInv
double rInv() const
Track curvature.
Definition: TTTrack.h:286
TTTrack::TTTrack
TTTrack()
Constructors.
Definition: TTTrack.h:175
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:316
TTTrack::hitPattern
unsigned int hitPattern() const
Hit Pattern.
Definition: TTTrack.h:387
TTTrack::getStubRefs
std::vector< edm::Ref< edmNew::DetSetVector< TTStub< T > >, TTStub< T > > > getStubRefs() const
Track components.
Definition: TTTrack.h:90
TrackerTopology.h
TTTrack::theNumFitPars_
unsigned int theNumFitPars_
Definition: TTTrack.h:43
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TTTrack::chi2ZRed
double chi2ZRed() const
Chi2Z reduced.
Definition: TTTrack.h:352
TTTrack::setTrackWordBits
void setTrackWordBits()
Set bits in 96-bit Track word.
Definition: TTTrack.h:403
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:52
TTTrack::theZ0_
double theZ0_
Definition: TTTrack.h:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TTTrack::setFitParNo
void setFitParNo(unsigned int aFitParNo)
Definition: TTTrack.h:271
TTTrack::theBField_
double theBField_
Definition: TTTrack.h:49
Phase2TrackerDigi.h
TTTrack::d0
double d0() const
Track d0.
Definition: TTTrack.h:306
TTTrack::stubPtConsistency
double stubPtConsistency() const
Stub Pt consistency.
Definition: TTTrack.h:381
operator<<
std::ostream & operator<<(std::ostream &os, const TTTrack< T > &aTTTrack)
Definition: TTTrack.h:467
TTTrack::theChi2_
double theChi2_
Definition: TTTrack.h:40
TTTrack::trackSeedType
unsigned int trackSeedType() const
Track seeding (for debugging)
Definition: TTTrack.h:134
TTTrack::tanL
double tanL() const
Track tanL.
Definition: TTTrack.h:291
TTTrack::thePhiSector_
unsigned int thePhiSector_
Definition: TTTrack.h:37
TTTrack::z0
double z0() const
Track z0.
Definition: TTTrack.h:311
TTTrack::theMomentum_
GlobalVector theMomentum_
Definition: TTTrack.h:30
TTTrack::testTrackWordBits
void testTrackWordBits()
Test bits in 96-bit Track word.
Definition: TTTrack.h:426
TTTrack::trkMVA1
double trkMVA1() const
MVA Track quality variables.
Definition: TTTrack.h:358
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
TTTrack::theTrackSeedType_
int theTrackSeedType_
Definition: TTTrack.h:48
TTTrack::Npars5
static constexpr unsigned int Npars5
Definition: TTTrack.h:51
TTTrack::theD0_
double theD0_
Definition: TTTrack.h:35
TTTrack::setEtaSector
void setEtaSector(unsigned int aSector)
Definition: TTTrack.h:131
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
TTTrack::theChi2_Z_
double theChi2_Z_
Definition: TTTrack.h:42
TTTrack::print
std::string print(unsigned int i=0) const
Information.
Definition: TTTrack.h:446
edmNew::DetSetVector
Definition: DetSetNew.h:13
TTTrack::theRInv_
double theRInv_
Definition: TTTrack.h:32
TTTrack::thePOCA_
GlobalPoint thePOCA_
Definition: TTTrack.h:31
TTTrack::theTanL_
double theTanL_
Definition: TTTrack.h:34
TTTrack::theStubRefs
std::vector< edm::Ref< edmNew::DetSetVector< TTStub< T > >, TTStub< T > > > theStubRefs
Data members.
Definition: TTTrack.h:29
TTStub.h
TTTrack::etaSector
unsigned int etaSector() const
Eta Sector.
Definition: TTTrack.h:130
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TTTrack::setPhiSector
void setPhiSector(unsigned int aSector)
Definition: TTTrack.h:127
TTTrack::theChi2_XY_
double theChi2_XY_
Definition: TTTrack.h:41
TTTrack::theTrkMVA3_
double theTrkMVA3_
Definition: TTTrack.h:47
TTTrack::theStubPtConsistency_
double theStubPtConsistency_
Definition: TTTrack.h:39
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TTTrack::trkMVA2
double trkMVA2() const
Definition: TTTrack.h:363
TTTrack_TrackWord
Definition: TTTrack_TrackWord.h:19
TTTrack::thePhi_
double thePhi_
Definition: TTTrack.h:33
StripSubdetector.h
DetSetVectorNew.h
TTTrack::eta
double eta() const
Track eta.
Definition: TTTrack.h:296
TTTrack::trkMVA3
double trkMVA3() const
Definition: TTTrack.h:368
TTTrack::setBField
void setBField(double aBField)
set new Bfield
Definition: TTTrack.h:393
TTTrack::phiSector
unsigned int phiSector() const
Phi Sector.
Definition: TTTrack.h:126