CMS 3D CMS Logo

Make3Dtracks.cc
Go to the documentation of this file.
4 
5 #include <iostream>
6 #include <unordered_set>
7 
8 using namespace std;
9 
10 namespace tmtt {
11 
12  class Settings;
13 
14  //=== Initialization
15 
16  Make3Dtracks::Make3Dtracks(const Settings* settings,
17  unsigned int iPhiSec,
18  unsigned int iEtaReg,
19  float etaMinSector,
20  float etaMaxSector,
21  float phiCentreSector)
22  : // Store config params & arguments.
23  settings_(settings),
24  iPhiSec_(iPhiSec), // Sector number
25  iEtaReg_(iEtaReg),
26  etaMinSector_(etaMinSector), // Range of eta sector
27  etaMaxSector_(etaMaxSector), // Range of eta sector
28  phiCentreSector_(phiCentreSector), // Centre of phi sector
29 
30  // Note if any fitters require an r-z track filter to be run.
31  runRZfilter_(not settings->useRZfilter().empty()) {
32  // Initialize any track filters (e.g. r-z) run after the r-phi Hough transform.
33  if (runRZfilter_)
34  rzFilter_ =
35  std::make_unique<TrkRZfilter>(settings_, iPhiSec_, iEtaReg_, etaMinSector_, etaMaxSector_, phiCentreSector_);
36  }
37 
38  //=== Convert 2D tracks found by HT within the current sector to 3D tracks, without running any r-z track filter.
39  //=== by adding a rough estimate of their r-z helix parameters.
40 
41  void Make3Dtracks::makeUnfilteredTrks(const list<L1track2D>& vecTracksRphi) {
43 
44  for (const L1track2D& trkRphi : vecTracksRphi) {
45  const vector<Stub*>& stubsOnTrkRphi = trkRphi.stubs(); // stubs assigned to track
46 
47  float qOverPt = trkRphi.helix2D().first;
48  float phi0 = trkRphi.helix2D().second;
49 
50  if (settings_->enableDigitize()) {
51  // Centre of HT bin lies on boundary of two fitted track digi bins, so nudge slightly +ve (like FW)
52  // to remove ambiguity.
53  const float small = 0.1;
54  const unsigned int nHelixBits = 18; // Bits used internally in KF HLS to represent helix params.
55  qOverPt += (2. / settings_->invPtToInvR()) * small * settings_->kf_oneOver2rRange() / pow(2., nHelixBits);
56  phi0 += small * settings_->kf_phi0Range() / pow(2., nHelixBits);
57  }
58  pair<float, float> helixRphi(qOverPt, phi0);
59 
60  // Estimate r-z track helix parameters from centre of eta sector.
61  float z0 = 0.;
62  float tan_lambda = 0.5 * (1 / tan(2 * atan(exp(-etaMinSector_))) + 1 / tan(2 * atan(exp(-etaMaxSector_))));
63 
64  pair<float, float> helixRz(z0, tan_lambda);
65 
66  // Create 3D track, by adding r-z helix params to 2D track
67  L1track3D trk3D(settings_,
68  stubsOnTrkRphi,
69  trkRphi.cellLocationHT(),
70  helixRphi,
71  helixRz,
72  iPhiSec_,
73  iEtaReg_,
74  trkRphi.optoLinkID(),
75  trkRphi.mergedHTcell());
76 
77  // Optionally use MC truth to eliminate all fake tracks & all incorrect stubs assigned to tracks
78  // before doing fit (for debugging).
79  bool cheat_keep = true;
80  if (settings_->trackFitCheat())
81  cheat_keep = trk3D.cheat();
82 
83  // Add to list of stored 3D tracks.
84  if (cheat_keep)
85  vecTracks3D_unfiltered_.push_back(trk3D);
86  }
87  }
88 
89  //=== Make 3D tracks from the 2D tracks found by the HT within the current sector, by running the r-z track filter.
90  //=== The r-z filter also adds an estimate of the r-z helix parameters to each track.
91 
92  void Make3Dtracks::makeRZfilteredTrks(const list<L1track2D>& vecTracksRphi) {
93  vecTracks3D_rzFiltered_ = rzFilter_->filterTracks(vecTracksRphi);
94 
95  // Optionally use MC truth to eliminate all fake tracks & all incorrect stubs assigned to tracks
96  // before doing fit (for debugging).
97  if (settings_->trackFitCheat()) {
98  list<L1track3D> vecTracks3D_tmp;
99  for (const L1track3D& trk : vecTracks3D_rzFiltered_) {
100  L1track3D trk_tmp = trk;
101  bool cheat_keep = trk_tmp.cheat();
102  if (cheat_keep)
103  vecTracks3D_tmp.push_back(trk_tmp);
104  }
105  vecTracks3D_rzFiltered_ = vecTracks3D_tmp;
106  }
107  }
108 
109  //=== Get all 3D track candidates (either r-z filtered on unfiltered, depending on the boolean),
110  //=== that are associated to the given tracking particle.
111  //=== (If the vector is empty, then the tracking particle was not reconstructed in this sector).
112 
113  vector<const L1track3D*> Make3Dtracks::assocTrackCands3D(const TP& tp, bool rzFiltered) const {
114  const list<L1track3D>& allTracks3D = (rzFiltered) ? vecTracks3D_rzFiltered_ : vecTracks3D_unfiltered_;
115 
116  vector<const L1track3D*> assocRecoTrk;
117 
118  // Loop over track candidates, looking for those associated to given TP.
119  for (const L1track3D& trk : allTracks3D) {
120  if (trk.matchedTP() != nullptr) {
121  if (trk.matchedTP()->index() == tp.index())
122  assocRecoTrk.push_back(&trk);
123  }
124  }
125 
126  return assocRecoTrk;
127  }
128 
129 } // namespace tmtt
tmtt::Make3Dtracks::iPhiSec_
unsigned int iPhiSec_
Definition: Make3Dtracks.h:81
tmtt::Settings::kf_oneOver2rRange
double kf_oneOver2rRange() const
Definition: Settings.h:364
tmtt::Make3Dtracks::etaMaxSector_
float etaMaxSector_
Definition: Make3Dtracks.h:84
tmtt::Settings::enableDigitize
bool enableDigitize() const
Definition: Settings.h:80
Make3Dtracks.h
tmtt::Settings::trackFitCheat
bool trackFitCheat() const
Definition: Settings.h:255
tmtt::TP
Definition: TP.h:23
tmtt::Make3Dtracks::rzFilter_
std::unique_ptr< TrkRZfilter > rzFilter_
Definition: Make3Dtracks.h:90
tmtt::L1track2D
Definition: L1track2D.h:20
tmtt::Make3Dtracks::makeUnfilteredTrks
void makeUnfilteredTrks(const std::list< L1track2D > &vecTracksRphi)
Definition: Make3Dtracks.cc:41
tmtt::Make3Dtracks::runRZfilter_
bool runRZfilter_
Definition: Make3Dtracks.h:87
HLTMuonOfflineAnalyzer_cfi.z0
z0
Definition: HLTMuonOfflineAnalyzer_cfi.py:98
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
tmtt::Make3Dtracks::makeRZfilteredTrks
void makeRZfilteredTrks(const std::list< L1track2D > &vecTracksRphi)
Definition: Make3Dtracks.cc:92
tmtt::Settings
Definition: Settings.h:17
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
tmtt::Make3Dtracks::vecTracks3D_rzFiltered_
std::list< L1track3D > vecTracks3D_rzFiltered_
Definition: Make3Dtracks.h:93
L1track2D.h
tmtt::Make3Dtracks::phiCentreSector_
float phiCentreSector_
Definition: Make3Dtracks.h:85
std
Definition: JetResolutionObject.h:76
Settings.h
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
tmtt::Make3Dtracks::settings_
const Settings * settings_
Definition: Make3Dtracks.h:80
tmtt::Settings::kf_phi0Range
double kf_phi0Range() const
Definition: Settings.h:368
tmtt::Make3Dtracks::iEtaReg_
unsigned int iEtaReg_
Definition: Make3Dtracks.h:82
tmtt::Make3Dtracks::vecTracks3D_unfiltered_
std::list< L1track3D > vecTracks3D_unfiltered_
Definition: Make3Dtracks.h:94
tmtt::L1track3D::cheat
bool cheat()
Definition: L1track3D.h:202
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
tmtt::Make3Dtracks::assocTrackCands3D
std::vector< const L1track3D * > assocTrackCands3D(const TP &tp, bool rzFiltered) const
Definition: Make3Dtracks.cc:113
tmtt::L1track3D
Definition: L1track3D.h:24
tmtt
=== This is the base class for the linearised chi-squared track fit algorithms.
Definition: ChiSquaredFit4.h:6
tmtt::Make3Dtracks::etaMinSector_
float etaMinSector_
Definition: Make3Dtracks.h:83
tmtt::Settings::invPtToInvR
double invPtToInvR() const
Definition: Settings.h:393