File indexing completed on 2024-06-04 04:34:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef L1_TRACK_TRIGGER_TRACK_FORMAT_H
0014 #define L1_TRACK_TRIGGER_TRACK_FORMAT_H
0015
0016 #include "CLHEP/Units/GlobalPhysicalConstants.h"
0017 #include "DataFormats/L1TrackTrigger/interface/TTStub.h"
0018 #include "DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h"
0019 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0020 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0021 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0022 #include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h"
0023
0024 namespace tttrack {
0025 void errorSetTrackWordBits(unsigned int);
0026 }
0027
0028 template <typename T>
0029 class TTTrack : public TTTrack_TrackWord {
0030 private:
0031
0032 std::vector<edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > > theStubRefs;
0033 GlobalVector theMomentum_;
0034 GlobalPoint thePOCA_;
0035 double theRInv_;
0036 double thePhi_;
0037 double theTanL_;
0038 double theD0_;
0039 double theZ0_;
0040 unsigned int thePhiSector_;
0041 unsigned int theEtaSector_;
0042 double theStubPtConsistency_;
0043 double theChi2_;
0044 double theChi2_XY_;
0045 double theChi2_Z_;
0046 unsigned int theNumFitPars_;
0047 unsigned int theHitPattern_;
0048 double theTrkMVA1_;
0049 double theTrkMVA2_;
0050 double theTrkMVA3_;
0051 int theTrackSeedType_;
0052 double theBField_;
0053 static constexpr unsigned int Npars4 = 4;
0054 static constexpr unsigned int Npars5 = 5;
0055 static constexpr float MagConstant =
0056 CLHEP::c_light / 1.0E3;
0057
0058 public:
0059
0060 TTTrack();
0061
0062 TTTrack(double aRinv,
0063 double aphi,
0064 double aTanLambda,
0065 double az0,
0066 double ad0,
0067 double aChi2,
0068 double trkMVA1,
0069 double trkMVA2,
0070 double trkMVA3,
0071 unsigned int aHitpattern,
0072 unsigned int nPar,
0073 double Bfield);
0074
0075 TTTrack(double aRinv,
0076 double aphi,
0077 double aTanLambda,
0078 double az0,
0079 double ad0,
0080 double aChi2xyfit,
0081 double aChi2zfit,
0082 double trkMVA1,
0083 double trkMVA2,
0084 double trkMVA3,
0085 unsigned int aHitpattern,
0086 unsigned int nPar,
0087 double Bfield);
0088
0089
0090 ~TTTrack();
0091
0092
0093 std::vector<edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > > getStubRefs() const { return theStubRefs; }
0094 void addStubRef(edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > aStub) { theStubRefs.push_back(aStub); }
0095 void setStubRefs(std::vector<edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > > aStubs) {
0096 theStubRefs = aStubs;
0097 }
0098
0099
0100 GlobalVector momentum() const;
0101
0102
0103 double rInv() const;
0104
0105
0106 double phi() const;
0107
0108
0109 double localPhi() const;
0110
0111
0112 double tanL() const;
0113
0114
0115 double d0() const;
0116
0117
0118 double z0() const;
0119
0120
0121 double eta() const;
0122
0123
0124 GlobalPoint POCA() const;
0125
0126
0127 double trkMVA1() const;
0128 void settrkMVA1(double atrkMVA1);
0129 double trkMVA2() const;
0130 void settrkMVA2(double atrkMVA2);
0131 double trkMVA3() const;
0132 void settrkMVA3(double atrkMVA3);
0133
0134
0135 unsigned int phiSector() const { return thePhiSector_; }
0136 void setPhiSector(unsigned int aSector) { thePhiSector_ = aSector; }
0137
0138
0139 unsigned int etaSector() const { return theEtaSector_; }
0140 void setEtaSector(unsigned int aSector) { theEtaSector_ = aSector; }
0141
0142
0143 unsigned int trackSeedType() const { return theTrackSeedType_; }
0144 void setTrackSeedType(int aSeed) { theTrackSeedType_ = aSeed; }
0145
0146
0147 double chi2() const;
0148 double chi2Red() const;
0149 double chi2Z() const;
0150 double chi2ZRed() const;
0151 double chi2XY() const;
0152 double chi2XYRed() const;
0153
0154
0155
0156
0157 double stubPtConsistency() const;
0158 void setStubPtConsistency(double aPtConsistency);
0159 double chi2BendRed() { return stubPtConsistency(); }
0160 void setChi2BendRed(double aChi2BendRed) { setStubPtConsistency(aChi2BendRed); }
0161 double chi2Bend() { return chi2BendRed() * theStubRefs.size(); }
0162
0163 void setFitParNo(unsigned int aFitParNo);
0164 int nFitPars() const { return theNumFitPars_; }
0165
0166
0167 unsigned int hitPattern() const;
0168
0169
0170 void setBField(double aBField);
0171
0172 void setTrackWordBits();
0173 void testTrackWordBits();
0174
0175
0176 std::string print(unsigned int i = 0) const;
0177
0178 };
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188 template <typename T>
0189 TTTrack<T>::TTTrack() {
0190 theStubRefs.clear();
0191 theMomentum_ = GlobalVector(0.0, 0.0, 0.0);
0192 theRInv_ = 0.0;
0193 thePOCA_ = GlobalPoint(0.0, 0.0, 0.0);
0194 theD0_ = 0.;
0195 theZ0_ = 0.;
0196 theTanL_ = 0;
0197 thePhi_ = 0;
0198 theTrkMVA1_ = 0;
0199 theTrkMVA2_ = 0;
0200 theTrkMVA3_ = 0;
0201 thePhiSector_ = 0;
0202 theEtaSector_ = 0;
0203 theTrackSeedType_ = 0;
0204 theChi2_ = 0.0;
0205 theChi2_XY_ = 0.0;
0206 theChi2_Z_ = 0.0;
0207 theStubPtConsistency_ = 0.0;
0208 theNumFitPars_ = 0;
0209 }
0210
0211
0212 template <typename T>
0213 TTTrack<T>::TTTrack(double aRinv,
0214 double aphi0,
0215 double aTanlambda,
0216 double az0,
0217 double ad0,
0218 double aChi2,
0219 double trkMVA1,
0220 double trkMVA2,
0221 double trkMVA3,
0222 unsigned int aHitPattern,
0223 unsigned int nPar,
0224 double aBfield) {
0225 theStubRefs.clear();
0226 double thePT = std::abs(MagConstant / aRinv * aBfield / 100.0);
0227 theMomentum_ = GlobalVector(GlobalVector::Cylindrical(thePT, aphi0, thePT * aTanlambda));
0228 theRInv_ = aRinv;
0229 thePOCA_ = GlobalPoint(ad0 * sin(aphi0), -ad0 * cos(aphi0), az0);
0230 theD0_ = ad0;
0231 theZ0_ = az0;
0232 thePhi_ = aphi0;
0233 theTanL_ = aTanlambda;
0234 thePhiSector_ = 0;
0235 theEtaSector_ = 0;
0236 theTrackSeedType_ = 0;
0237 theChi2_ = aChi2;
0238 theTrkMVA1_ = trkMVA1;
0239 theTrkMVA2_ = trkMVA2;
0240 theTrkMVA3_ = trkMVA3;
0241 theStubPtConsistency_ = 0.0;
0242 theNumFitPars_ = nPar;
0243 theHitPattern_ = aHitPattern;
0244 theBField_ = aBfield;
0245 theChi2_XY_ = -999.;
0246 theChi2_Z_ = -999.;
0247 }
0248
0249
0250 template <typename T>
0251 TTTrack<T>::TTTrack(double aRinv,
0252 double aphi0,
0253 double aTanlambda,
0254 double az0,
0255 double ad0,
0256 double aChi2XY,
0257 double aChi2Z,
0258 double trkMVA1,
0259 double trkMVA2,
0260 double trkMVA3,
0261 unsigned int aHitPattern,
0262 unsigned int nPar,
0263 double aBfield)
0264 : TTTrack(aRinv,
0265 aphi0,
0266 aTanlambda,
0267 az0,
0268 ad0,
0269 aChi2XY + aChi2Z,
0270 trkMVA1,
0271 trkMVA2,
0272 trkMVA3,
0273 aHitPattern,
0274 nPar,
0275 aBfield) {
0276 this->theChi2_XY_ = aChi2XY;
0277 this->theChi2_Z_ = aChi2Z;
0278 }
0279
0280
0281 template <typename T>
0282 TTTrack<T>::~TTTrack() {}
0283
0284 template <typename T>
0285 void TTTrack<T>::setFitParNo(unsigned int nPar) {
0286 theNumFitPars_ = nPar;
0287
0288 return;
0289 }
0290
0291
0292
0293
0294 template <typename T>
0295 GlobalVector TTTrack<T>::momentum() const {
0296 return theMomentum_;
0297 }
0298
0299 template <typename T>
0300 double TTTrack<T>::rInv() const {
0301 return theRInv_;
0302 }
0303
0304 template <typename T>
0305 double TTTrack<T>::tanL() const {
0306 return theTanL_;
0307 }
0308
0309 template <typename T>
0310 double TTTrack<T>::eta() const {
0311 return theMomentum_.eta();
0312 }
0313
0314 template <typename T>
0315 double TTTrack<T>::phi() const {
0316 return thePhi_;
0317 }
0318
0319 template <typename T>
0320 double TTTrack<T>::localPhi() const {
0321 return TTTrack_TrackWord::localPhi(thePhi_, thePhiSector_);
0322 }
0323
0324 template <typename T>
0325 double TTTrack<T>::d0() const {
0326 return theD0_;
0327 }
0328
0329 template <typename T>
0330 double TTTrack<T>::z0() const {
0331 return theZ0_;
0332 }
0333
0334 template <typename T>
0335 GlobalPoint TTTrack<T>::POCA() const {
0336 return thePOCA_;
0337 }
0338
0339
0340 template <typename T>
0341 double TTTrack<T>::chi2() const {
0342 return theChi2_;
0343 }
0344
0345
0346 template <typename T>
0347 double TTTrack<T>::chi2Z() const {
0348 return theChi2_Z_;
0349 }
0350
0351
0352 template <typename T>
0353 double TTTrack<T>::chi2XY() const {
0354 return theChi2_XY_;
0355 }
0356
0357
0358 template <typename T>
0359 double TTTrack<T>::chi2Red() const {
0360 return theChi2_ / (2 * theStubRefs.size() - theNumFitPars_);
0361 }
0362
0363
0364 template <typename T>
0365 double TTTrack<T>::chi2XYRed() const {
0366 return theChi2_XY_ / (theStubRefs.size() - (theNumFitPars_ - 2));
0367 }
0368
0369
0370 template <typename T>
0371 double TTTrack<T>::chi2ZRed() const {
0372 return theChi2_Z_ / (theStubRefs.size() - 2.);
0373 }
0374
0375
0376 template <typename T>
0377 double TTTrack<T>::trkMVA1() const {
0378 return theTrkMVA1_;
0379 }
0380
0381 template <typename T>
0382 void TTTrack<T>::settrkMVA1(double atrkMVA1) {
0383 theTrkMVA1_ = atrkMVA1;
0384 return;
0385 }
0386
0387 template <typename T>
0388 double TTTrack<T>::trkMVA2() const {
0389 return theTrkMVA2_;
0390 }
0391
0392 template <typename T>
0393 void TTTrack<T>::settrkMVA2(double atrkMVA2) {
0394 theTrkMVA2_ = atrkMVA2;
0395 return;
0396 }
0397
0398 template <typename T>
0399 double TTTrack<T>::trkMVA3() const {
0400 return theTrkMVA3_;
0401 }
0402
0403 template <typename T>
0404 void TTTrack<T>::settrkMVA3(double atrkMVA3) {
0405 theTrkMVA3_ = atrkMVA3;
0406 return;
0407 }
0408
0409
0410 template <typename T>
0411 void TTTrack<T>::setStubPtConsistency(double aStubPtConsistency) {
0412 theStubPtConsistency_ = aStubPtConsistency;
0413 return;
0414 }
0415
0416
0417 template <typename T>
0418 double TTTrack<T>::stubPtConsistency() const {
0419 return theStubPtConsistency_;
0420 }
0421
0422
0423 template <typename T>
0424 unsigned int TTTrack<T>::hitPattern() const {
0425 return theHitPattern_;
0426 }
0427
0428
0429 template <typename T>
0430 void TTTrack<T>::setBField(double aBField) {
0431
0432 double thePT = std::abs(MagConstant / theRInv_ * aBField / 100.0);
0433 theMomentum_ = GlobalVector(GlobalVector::Cylindrical(thePT, thePhi_, thePT * theTanL_));
0434
0435 return;
0436 }
0437
0438
0439 template <typename T>
0440 void TTTrack<T>::setTrackWordBits() {
0441 if (!(theNumFitPars_ == Npars4 || theNumFitPars_ == Npars5)) {
0442 tttrack::errorSetTrackWordBits(theNumFitPars_);
0443 return;
0444 }
0445
0446 unsigned int valid = true;
0447 unsigned int mvaOther = 0;
0448
0449
0450
0451 if (theChi2_Z_ < 0) {
0452 setTrackWord(valid,
0453 theMomentum_,
0454 thePOCA_,
0455 theRInv_,
0456 theChi2_,
0457 0,
0458 theStubPtConsistency_,
0459 theHitPattern_,
0460 theTrkMVA1_,
0461 mvaOther,
0462 thePhiSector_);
0463 } else {
0464 setTrackWord(valid,
0465 theMomentum_,
0466 thePOCA_,
0467 theRInv_,
0468 chi2XYRed(),
0469 chi2ZRed(),
0470 chi2BendRed(),
0471 theHitPattern_,
0472 theTrkMVA1_,
0473 mvaOther,
0474 thePhiSector_);
0475 }
0476 return;
0477 }
0478
0479
0480 template <typename T>
0481 void TTTrack<T>::testTrackWordBits() {
0482
0483
0484
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495
0496 return;
0497 }
0498
0499
0500 template <typename T>
0501 std::string TTTrack<T>::print(unsigned int i) const {
0502 std::string padding("");
0503 for (unsigned int j = 0; j != i; ++j) {
0504 padding += "\t";
0505 }
0506
0507 std::stringstream output;
0508 output << padding << "TTTrack:\n";
0509 padding += '\t';
0510 output << '\n';
0511 unsigned int iStub = 0;
0512
0513 typename std::vector<edm::Ref<edmNew::DetSetVector<TTStub<T> >, TTStub<T> > >::const_iterator stubIter;
0514 for (stubIter = theStubRefs.begin(); stubIter != theStubRefs.end(); ++stubIter) {
0515 output << padding << "stub: " << iStub++ << ", DetId: " << ((*stubIter)->getDetId()).rawId() << '\n';
0516 }
0517
0518 return output.str();
0519 }
0520
0521 template <typename T>
0522 std::ostream& operator<<(std::ostream& os, const TTTrack<T>& aTTTrack) {
0523 return (os << aTTTrack.print());
0524 }
0525
0526 #endif