CMS 3D CMS Logo

TP.cc
Go to the documentation of this file.
7 
8 #include <array>
9 
10 using namespace std;
11 
12 namespace tmtt {
13 
14  //=== Store useful info about this tracking particle
15 
16  TP::TP(const TrackingParticlePtr& tpPtr, unsigned int index_in_vTPs, const Settings* settings)
17  : trackingParticlePtr_(tpPtr),
18  index_in_vTPs_(index_in_vTPs),
19  settings_(settings),
20  pdgId_(tpPtr->pdgId()),
21  charge_(tpPtr->charge()),
22  mass_(tpPtr->mass()),
23  pt_(tpPtr->pt()),
24  eta_(tpPtr->eta()),
25  theta_(tpPtr->theta()),
26  tanLambda_(1. / tan(theta_)),
27  phi0_(tpPtr->phi()),
28  vx_(tpPtr->vertex().x()),
29  vy_(tpPtr->vertex().y()),
30  vz_(tpPtr->vertex().z()),
31  d0_(vx_ * sin(phi0_) - vy_ * cos(phi0_)), // Copied from CMSSW class TrackBase::d0().
32  z0_(vz_ - (vx_ * cos(phi0_) + vy_ * sin(phi0_)) * tanLambda_) // Copied from CMSSW class TrackBase::dz().
33  {
34  const vector<SimTrack>& vst = tpPtr->g4Tracks();
35  EncodedEventId eid = vst.at(0).eventId();
36  inTimeBx_ = (eid.bunchCrossing() == 0); // TP from in-time or out-of-time Bx.
37  physicsCollision_ = (eid.event() == 0); // TP from physics collision or from pileup.
38 
39  this->fillUse(); // Fill use_ flag, indicating if TP is worth keeping.
40  this->fillUseForEff(); // Fill useForEff_ flag, indicating if TP is good for tracking efficiency measurement.
41  }
42 
43  //=== Fill truth info with association from tracking particle to stubs.
44 
45  void TP::fillTruth(const list<Stub>& vStubs) {
46  for (const Stub& s : vStubs) {
47  for (const TP* tp_i : s.assocTPs()) {
48  if (tp_i->index() == this->index())
49  assocStubs_.push_back(&s);
50  }
51  }
52 
53  this->fillUseForAlgEff(); // Fill useForAlgEff_ flag.
54 
55  this->calcNumLayers(); // Calculate number of tracker layers this TP has stubs in.
56  }
57 
58  //=== Check if this tracking particle is worth keeping.
59  //=== (i.e. If there is the slightest chance of reconstructing it, so as to measure fake rate).
60 
61  void TP::fillUse() {
62  constexpr bool useOnlyInTimeParticles = false;
63  constexpr bool useOnlyTPfromPhysicsCollisionFalse = false;
64  // Use looser cuts here those those used for tracking efficiency measurement.
65  // Keep only those TP that have a chance (allowing for finite track resolution) of being reconstructed as L1 tracks. L1 tracks not matching these TP will be defined as fake.
66 
67  // Include all possible particle types here, as if some are left out, L1 tracks matching one of missing types will be declared fake.
68  constexpr std::array<int, 5> genPdgIdsAllUnsigned = {{11, 13, 211, 321, 2212}};
69  vector<int> genPdgIdsAll;
70  for (const int& iPdg : genPdgIdsAllUnsigned) {
71  genPdgIdsAll.push_back(iPdg);
72  genPdgIdsAll.push_back(-iPdg);
73  }
74 
75  // Range big enough to include all TP needed to measure tracking efficiency
76  // and big enough to include any TP that might be reconstructed for fake rate measurement.
77  constexpr float ptMinScale = 0.7;
78  const float ptMin = min(settings_->genMinPt(), ptMinScale * settings_->houghMinPt());
79  constexpr double ptMax = 9.9e9;
80  const float etaExtra = 0.2;
82  constexpr double fixedVertRcut = 10.;
83  constexpr double fixedVertZcut = 35.;
84 
86  ptMax,
87  -etaMax,
88  etaMax,
89  max(fixedVertRcut, settings_->genMaxVertR()),
90  max(fixedVertZcut, settings_->genMaxVertZ()),
91  0,
92  useOnlyTPfromPhysicsCollisionFalse,
93  useOnlyInTimeParticles,
94  true,
95  false,
96  genPdgIdsAll);
97 
99  }
100 
101  //=== Check if this tracking particle can be used to measure the L1 tracking efficiency.
102 
104  useForEff_ = false;
105  if (use_) {
106  constexpr bool useOnlyInTimeParticles = true;
107  constexpr bool useOnlyTPfromPhysicsCollision = true;
108  constexpr double ptMax = 9.9e9;
110  ptMax,
115  0,
116  useOnlyTPfromPhysicsCollision,
117  useOnlyInTimeParticles,
118  true,
119  false,
120  settings_->genPdgIds());
121 
123 
124  // Add additional cut on particle transverse impact parameter.
125  if (std::abs(d0_) > settings_->genMaxD0())
126  useForEff_ = false;
127  if (std::abs(z0_) > settings_->genMaxZ0())
128  useForEff_ = false;
129  }
130  }
131 
132  //=== Check if this tracking particle can be used to measure the L1 tracking algorithmic efficiency (makes stubs in enough layers).
133 
135  useForAlgEff_ = false;
136  if (useForEff_) {
138  }
139  }
140 
141  //== Estimated phi angle at which TP trajectory crosses the module containing the stub.
142 
143  float TP::trkPhiAtStub(const Stub* stub) const {
144  float trkPhi = phi0_ - this->dphi(this->trkRAtStub(stub));
145  return trkPhi;
146  }
147 
148  //== Estimated r coord. at which TP trajectory crosses the module containing the given stub.
149  //== Only works for modules orientated parallel or perpendicular to beam-axis,
150  //== and makes the approximation that tracks are straight-lines in r-z plane.
151 
152  float TP::trkRAtStub(const Stub* stub) const {
153  float rTrk = (stub->barrel()) ? stub->r() : (stub->z() - z0_) / tanLambda_;
154  return rTrk;
155  }
156 
157  //== Estimated z coord. at which TP trajectory crosses the module containing the given stub.
158  //== Only works for modules orientated parallel or perpendicular to beam-axis,
159  //== and makes the approximation that tracks are straight-lines in r-z plane.
160 
161  float TP::trkZAtStub(const Stub* stub) const {
162  float zTrk = (stub->barrel()) ? z0_ + tanLambda_ * stub->r() : stub->z();
163  return zTrk;
164  }
165 
167  double minDR = 999.;
168  double ptOfNearestJet = -1;
169 
170  reco::GenJetCollection::const_iterator iterGenJet;
171  for (iterGenJet = genJets->begin(); iterGenJet != genJets->end(); ++iterGenJet) {
172  reco::GenJet myJet = reco::GenJet(*iterGenJet);
173 
174  // Don't consider GenJets failing these cuts.
175  constexpr float minPt = 30.0;
176  constexpr float maxEta = 2.5;
177 
178  if (myJet.pt() > minPt && std::abs(myJet.eta()) > maxEta) {
179  double deltaR = reco::deltaR(this->eta(), this->phi0(), myJet.eta(), myJet.phi());
180 
181  if (deltaR < minDR) {
182  minDR = deltaR;
183  ptOfNearestJet = myJet.pt();
184  }
185  }
186  }
187 
188  // Only consider GenJets within this distance of TP.
189  constexpr float cutDR = 0.4;
190  tpInJet_ = (minDR < cutDR);
191  nearestJetPt_ = tpInJet_ ? ptOfNearestJet : -1.;
192  }
193 
194 } // namespace tmtt
float phi0_
Definition: TP.h:121
float r() const
Definition: Stub.h:108
double genMaxZ0() const
Definition: Settings.h:53
void fillNearestJetInfo(const reco::GenJetCollection *genJets)
Definition: TP.cc:166
double pt() const final
transverse momentum
double genMaxAbsEta() const
Definition: Settings.h:49
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< GenJet > GenJetCollection
collection of GenJet objects
float dphi(float rad) const
Definition: TP.h:66
constexpr float ptMin
float phi0() const
Definition: TP.h:57
bool useForEff_
Definition: TP.h:132
void fillUseForEff()
Definition: TP.cc:103
minPt
Definition: PV_cfg.py:222
float z() const
Definition: Stub.h:109
float trkRAtStub(const Stub *stub) const
Definition: TP.cc:152
double genMinPt() const
Definition: Settings.h:48
const std::vector< SimTrack > & g4Tracks() const
void calcNumLayers()
Definition: TP.h:103
void fillUse()
Definition: TP.cc:61
double genMaxVertR() const
Definition: Settings.h:50
const std::vector< int > & genPdgIds() const
Definition: Settings.h:54
float eta() const
Definition: TP.h:54
float nearestJetPt_
Definition: TP.h:136
Definition: TP.h:23
TrackingParticlePtr trackingParticlePtr_
Definition: TP.h:106
unsigned int index() const
Definition: TP.h:39
double genMaxVertZ() const
Definition: Settings.h:51
float trkPhiAtStub(const Stub *stub) const
Definition: TP.cc:143
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Jets made from MC generator particles.
Definition: GenJet.h:23
bool useForAlgEff_
Definition: TP.h:133
bool tpInJet_
Definition: TP.h:135
bool barrel() const
Definition: Stub.h:201
const Settings * settings_
Definition: TP.h:110
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
bool use_
Definition: TP.h:131
unsigned int genMinStubLayers() const
Definition: Settings.h:56
double genMaxD0() const
Definition: Settings.h:52
float d0_
Definition: TP.h:125
=== This is the base class for the linearised chi-squared track fit algorithms.
Definition: Array2D.h:16
bool physicsCollision_
Definition: TP.h:114
double houghMinPt() const
Definition: Settings.h:135
float z0_
Definition: TP.h:126
void fillUseForAlgEff()
Definition: TP.cc:134
float x
void fillTruth(const std::list< Stub > &vStubs)
Definition: TP.cc:45
bool inTimeBx_
Definition: TP.h:113
unsigned int countLayers(const Settings *settings, const std::vector< const Stub *> &stubs, bool disableReducedLayerID=false, bool onlyPS=false)
Definition: Utility.cc:25
double phi() const final
momentum azimuthal angle
Geom::Theta< T > theta() const
float tanLambda_
Definition: TP.h:120
const std::vector< double > & etaRegions() const
Definition: Settings.h:124
std::vector< const Stub * > assocStubs_
Definition: TP.h:128
float trkZAtStub(const Stub *stub) const
Definition: TP.cc:161
double eta() const final
momentum pseudorapidity