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
tmtt::TP::trkPhiAtStub
float trkPhiAtStub(const Stub *stub) const
Definition: TP.cc:143
tmtt::Settings::genPdgIds
const std::vector< int > & genPdgIds() const
Definition: Settings.h:54
tmtt::Settings::houghMinPt
double houghMinPt() const
Definition: Settings.h:135
reco::GenJet
Jets made from MC generator particles.
Definition: GenJet.h:23
tmtt::TP::useForAlgEff_
bool useForAlgEff_
Definition: TP.h:133
tmtt::Utility::countLayers
unsigned int countLayers(const Settings *settings, const std::vector< const Stub * > &stubs, bool disableReducedLayerID=false, bool onlyPS=false)
Definition: Utility.cc:25
tmtt::Settings::genMaxVertZ
double genMaxVertZ() const
Definition: Settings.h:51
tmtt::TP::d0_
float d0_
Definition: TP.h:125
reco::GenJetCollection
std::vector< GenJet > GenJetCollection
collection of GenJet objects
Definition: GenJetCollection.h:14
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
min
T min(T a, T b)
Definition: MathUtil.h:58
Stub.h
tmtt::TP::physicsCollision_
bool physicsCollision_
Definition: TP.h:114
TrackingParticleSelector.h
tmtt::TP::use_
bool use_
Definition: TP.h:131
tmtt::TP::settings_
const Settings * settings_
Definition: TP.h:110
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:153
DigiToRawDM_cff.TP
TP
Definition: DigiToRawDM_cff.py:51
tmtt::Stub::r
float r() const
Definition: Stub.h:108
tmtt::TP::z0_
float z0_
Definition: TP.h:126
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
tmtt::TP
Definition: TP.h:23
tmtt::Settings::genMinStubLayers
unsigned int genMinStubLayers() const
Definition: Settings.h:56
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
deltaR.h
EncodedEventId
Definition: EncodedEventId.h:11
TrackingParticleSelector
tmtt::TP::fillTruth
void fillTruth(const std::list< Stub > &vStubs)
Definition: TP.cc:45
Utility.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
tmtt::TP::inTimeBx_
bool inTimeBx_
Definition: TP.h:113
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
tmtt::TP::fillUseForAlgEff
void fillUseForAlgEff()
Definition: TP.cc:134
AlignmentTrackSelector_cfi.ptMax
ptMax
Definition: AlignmentTrackSelector_cfi.py:12
tmtt::Settings::genMaxAbsEta
double genMaxAbsEta() const
Definition: Settings.h:49
PVValHelper::eta
Definition: PVValidationHelpers.h:69
tmtt::Settings::genMaxZ0
double genMaxZ0() const
Definition: Settings.h:53
maxEta
double maxEta
Definition: PFJetBenchmarkAnalyzer.cc:76
l1pfProducerBarrel_cfi.etaExtra
etaExtra
Definition: l1pfProducerBarrel_cfi.py:62
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
tmtt::TP::tanLambda_
float tanLambda_
Definition: TP.h:120
PDWG_EXOHSCP_cff.minDR
minDR
Definition: PDWG_EXOHSCP_cff.py:109
tmtt::TP::assocStubs_
std::vector< const Stub * > assocStubs_
Definition: TP.h:128
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
tmtt::Stub::z
float z() const
Definition: Stub.h:109
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
TP.h
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
tmtt::TP::trkZAtStub
float trkZAtStub(const Stub *stub) const
Definition: TP.cc:161
tmtt::TP::fillNearestJetInfo
void fillNearestJetInfo(const reco::GenJetCollection *genJets)
Definition: TP.cc:166
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
tmtt::Settings
Definition: Settings.h:17
tmtt::TP::phi0_
float phi0_
Definition: TP.h:121
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
runTauDisplay.eid
eid
Definition: runTauDisplay.py:298
tmtt::Settings::genMaxVertR
double genMaxVertR() const
Definition: Settings.h:50
tmtt::TP::dphi
float dphi(float rad) const
Definition: TP.h:66
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
ttbarCategorization_cff.genJets
genJets
Definition: ttbarCategorization_cff.py:29
beam_dqm_sourceclient-live_cfg.minPt
minPt
Definition: beam_dqm_sourceclient-live_cfg.py:318
tmtt::TP::phi0
float phi0() const
Definition: TP.h:57
tmtt::TP::useForEff_
bool useForEff_
Definition: TP.h:132
edm::Ptr< TrackingParticle >
tmtt::Stub::barrel
bool barrel() const
Definition: Stub.h:201
std
Definition: JetResolutionObject.h:76
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
tmtt::TP::trkRAtStub
float trkRAtStub(const Stub *stub) const
Definition: TP.cc:152
tmtt::Settings::genMaxD0
double genMaxD0() const
Definition: Settings.h:52
Settings.h
tmtt::TP::calcNumLayers
void calcNumLayers()
Definition: TP.h:103
tmtt::TP::fillUseForEff
void fillUseForEff()
Definition: TP.cc:103
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
tmtt::TP::nearestJetPt_
float nearestJetPt_
Definition: TP.h:136
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
nanoDQM_cfi.GenJet
GenJet
Definition: nanoDQM_cfi.py:226
trackingParticleSelector_cfi.trackingParticleSelector
trackingParticleSelector
Definition: trackingParticleSelector_cfi.py:4
tmtt::TP::index
unsigned int index() const
Definition: TP.h:39
tmtt::TP::trackingParticlePtr_
TrackingParticlePtr trackingParticlePtr_
Definition: TP.h:106
tmtt::Stub
Definition: Stub.h:43
tmtt::TP::fillUse
void fillUse()
Definition: TP.cc:61
tmtt
=== This is the base class for the linearised chi-squared track fit algorithms.
Definition: ChiSquaredFit4.h:6
tmtt::TP::eta
float eta() const
Definition: TP.h:54
tmtt::Settings::etaRegions
const std::vector< double > & etaRegions() const
Definition: Settings.h:124
tmtt::Settings::genMinPt
double genMinPt() const
Definition: Settings.h:48
tmtt::TP::tpInJet_
bool tpInJet_
Definition: TP.h:135
TrackingParticle::g4Tracks
const std::vector< SimTrack > & g4Tracks() const
Definition: TrackingParticle.h:89