CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TtGenEvent.cc
Go to the documentation of this file.
1 //
2 //
3 
8 
13  if (top() && topBar())
14  topPair_ = math::XYZTLorentzVector(top()->p4() + topBar()->p4());
15 }
16 
18  const reco::GenParticleCollection& initPartsColl = *initPartons_;
19  if (initPartsColl.size() == 2)
20  if (initPartsColl[0].pdgId() == 21 && initPartsColl[1].pdgId() == 21)
21  return true;
22  return false;
23 }
24 
26  const reco::GenParticleCollection& initPartsColl = *initPartons_;
27  if (initPartsColl.size() == 2)
28  if (std::abs(initPartsColl[0].pdgId()) < TopDecayID::tID && initPartsColl[0].pdgId() == -initPartsColl[1].pdgId())
29  return true;
30  return false;
31 }
32 
35  if (isSemiLeptonic() && singleLepton()) {
36  if (std::abs(singleLepton()->pdgId()) == TopDecayID::elecID)
37  type = WDecay::kElec;
38  if (std::abs(singleLepton()->pdgId()) == TopDecayID::muonID)
39  type = WDecay::kMuon;
40  if (std::abs(singleLepton()->pdgId()) == TopDecayID::tauID)
41  type = WDecay::kTau;
42  }
43  return type;
44 }
45 
46 std::pair<WDecay::LeptonType, WDecay::LeptonType> TtGenEvent::fullLeptonicChannel() const {
48  if (isFullLeptonic()) {
49  if (lepton()) {
50  if (std::abs(lepton()->pdgId()) == TopDecayID::elecID)
51  typeA = WDecay::kElec;
52  if (std::abs(lepton()->pdgId()) == TopDecayID::muonID)
53  typeA = WDecay::kMuon;
54  if (std::abs(lepton()->pdgId()) == TopDecayID::tauID)
55  typeA = WDecay::kTau;
56  }
57  if (leptonBar()) {
58  if (std::abs(leptonBar()->pdgId()) == TopDecayID::elecID)
59  typeB = WDecay::kElec;
60  if (std::abs(leptonBar()->pdgId()) == TopDecayID::muonID)
61  typeB = WDecay::kMuon;
62  if (std::abs(leptonBar()->pdgId()) == TopDecayID::tauID)
63  typeB = WDecay::kTau;
64  }
65  }
66  return (std::pair<WDecay::LeptonType, WDecay::LeptonType>(typeA, typeB));
67 }
68 
69 const reco::GenParticle* TtGenEvent::lepton(bool excludeTauLeptons) const {
70  const reco::GenParticle* cand = nullptr;
71  const reco::GenParticleCollection& partsColl = *parts_;
72  for (unsigned int i = 0; i < partsColl.size(); ++i) {
73  if (reco::isLepton(partsColl[i]) && partsColl[i].mother() &&
74  std::abs(partsColl[i].mother()->pdgId()) == TopDecayID::WID) {
75  if (reco::flavour(partsColl[i]) > 0) {
76  cand = &partsColl[i];
77  }
78  }
79  }
80  return cand;
81 }
82 
83 const reco::GenParticle* TtGenEvent::leptonBar(bool excludeTauLeptons) const {
84  const reco::GenParticle* cand = nullptr;
85  const reco::GenParticleCollection& partsColl = *parts_;
86  for (unsigned int i = 0; i < partsColl.size(); ++i) {
87  if (reco::isLepton(partsColl[i]) && partsColl[i].mother() &&
88  std::abs(partsColl[i].mother()->pdgId()) == TopDecayID::WID) {
89  if (reco::flavour(partsColl[i]) < 0) {
90  cand = &partsColl[i];
91  }
92  }
93  }
94  return cand;
95 }
96 
97 const reco::GenParticle* TtGenEvent::singleLepton(bool excludeTauLeptons) const {
98  const reco::GenParticle* cand = nullptr;
99  if (isSemiLeptonic(excludeTauLeptons)) {
100  const reco::GenParticleCollection& partsColl = *parts_;
101  for (unsigned int i = 0; i < partsColl.size(); ++i) {
102  if (reco::isLepton(partsColl[i]) && partsColl[i].mother() &&
103  std::abs(partsColl[i].mother()->pdgId()) == TopDecayID::WID) {
104  cand = &partsColl[i];
105  }
106  }
107  }
108  return cand;
109 }
110 
111 const reco::GenParticle* TtGenEvent::neutrino(bool excludeTauLeptons) const {
112  const reco::GenParticle* cand = nullptr;
113  const reco::GenParticleCollection& partsColl = *parts_;
114  for (unsigned int i = 0; i < partsColl.size(); ++i) {
115  if (reco::isNeutrino(partsColl[i]) && partsColl[i].mother() &&
116  std::abs(partsColl[i].mother()->pdgId()) == TopDecayID::WID) {
117  if (reco::flavour(partsColl[i]) > 0) {
118  cand = &partsColl[i];
119  }
120  }
121  }
122  return cand;
123 }
124 
125 const reco::GenParticle* TtGenEvent::neutrinoBar(bool excludeTauLeptons) const {
126  const reco::GenParticle* cand = nullptr;
127  const reco::GenParticleCollection& partsColl = *parts_;
128  for (unsigned int i = 0; i < partsColl.size(); ++i) {
129  if (reco::isNeutrino(partsColl[i]) && partsColl[i].mother() &&
130  std::abs(partsColl[i].mother()->pdgId()) == TopDecayID::WID) {
131  if (reco::flavour(partsColl[i]) < 0) {
132  cand = &partsColl[i];
133  }
134  }
135  }
136  return cand;
137 }
138 
139 const reco::GenParticle* TtGenEvent::singleNeutrino(bool excludeTauLeptons) const {
140  const reco::GenParticle* cand = nullptr;
141  if (isSemiLeptonic(excludeTauLeptons)) {
142  const reco::GenParticleCollection& partsColl = *parts_;
143  for (unsigned int i = 0; i < partsColl.size(); ++i) {
144  if (reco::isNeutrino(partsColl[i]) && partsColl[i].mother() &&
145  std::abs(partsColl[i].mother()->pdgId()) == TopDecayID::WID) {
146  cand = &partsColl[i];
147  }
148  }
149  }
150  return cand;
151 }
152 
153 const reco::GenParticle* TtGenEvent::hadronicDecayQuark(bool invertFlavor) const {
154  const reco::GenParticle* cand = nullptr;
155  // catch W boson and check its daughters for a quark;
156  // make sure the decay is semi-leptonic first; this
157  // only makes sense if taus are not excluded from the
158  // decision
159  if (singleLepton(false)) {
160  for (reco::GenParticleCollection::const_iterator w = parts_->begin(); w != parts_->end(); ++w) {
161  if (std::abs(w->pdgId()) == TopDecayID::WID) {
162  // make sure that the particle is a W daughter
163  for (reco::GenParticle::const_iterator wd = w->begin(); wd != w->end(); ++wd) {
164  // make sure that the parton is a quark
165  if (std::abs(wd->pdgId()) < TopDecayID::tID) {
166  if (invertFlavor ? reco::flavour(*wd) < 0 : reco::flavour(*wd) > 0) {
167  cand = dynamic_cast<const reco::GenParticle*>(&(*wd));
168  if (cand == nullptr) {
169  throw edm::Exception(edm::errors::InvalidReference, "Not a GenParticle");
170  }
171  break;
172  }
173  }
174  }
175  }
176  }
177  }
178  return cand;
179 }
180 
181 const reco::GenParticle* TtGenEvent::hadronicDecayB(bool excludeTauLeptons) const {
182  const reco::GenParticle* cand = nullptr;
183  if (singleLepton(excludeTauLeptons)) {
184  const reco::GenParticleCollection& partsColl = *parts_;
185  const reco::GenParticle& singleLep = *singleLepton(excludeTauLeptons);
186  for (unsigned int i = 0; i < partsColl.size(); ++i) {
187  if (std::abs(partsColl[i].pdgId()) == TopDecayID::bID &&
188  reco::flavour(singleLep) == reco::flavour(partsColl[i])) {
189  cand = &partsColl[i];
190  }
191  }
192  }
193  return cand;
194 }
195 
196 const reco::GenParticle* TtGenEvent::hadronicDecayW(bool excludeTauLeptons) const {
197  const reco::GenParticle* cand = nullptr;
198  if (singleLepton(excludeTauLeptons)) {
199  const reco::GenParticleCollection& partsColl = *parts_;
200  const reco::GenParticle& singleLep = *singleLepton(excludeTauLeptons);
201  for (unsigned int i = 0; i < partsColl.size(); ++i) {
202  if (std::abs(partsColl[i].pdgId()) == TopDecayID::WID &&
203  reco::flavour(singleLep) != -reco::flavour(partsColl[i])) {
204  // PDG Id:13=mu- 24=W+ (+24)->(-13) (-24)->(+13) opposite sign
205  cand = &partsColl[i];
206  }
207  }
208  }
209  return cand;
210 }
211 
212 const reco::GenParticle* TtGenEvent::hadronicDecayTop(bool excludeTauLeptons) const {
213  const reco::GenParticle* cand = nullptr;
214  if (singleLepton(excludeTauLeptons)) {
215  const reco::GenParticleCollection& partsColl = *parts_;
216  const reco::GenParticle& singleLep = *singleLepton(excludeTauLeptons);
217  for (unsigned int i = 0; i < partsColl.size(); ++i) {
218  if (std::abs(partsColl[i].pdgId()) == TopDecayID::tID &&
219  reco::flavour(singleLep) == reco::flavour(partsColl[i])) {
220  cand = &partsColl[i];
221  }
222  }
223  }
224  return cand;
225 }
226 
227 const reco::GenParticle* TtGenEvent::leptonicDecayB(bool excludeTauLeptons) const {
228  const reco::GenParticle* cand = nullptr;
229  if (singleLepton(excludeTauLeptons)) {
230  const reco::GenParticleCollection& partsColl = *parts_;
231  const reco::GenParticle& singleLep = *singleLepton(excludeTauLeptons);
232  for (unsigned int i = 0; i < partsColl.size(); ++i) {
233  if (std::abs(partsColl[i].pdgId()) == TopDecayID::bID &&
234  reco::flavour(singleLep) != reco::flavour(partsColl[i])) {
235  cand = &partsColl[i];
236  }
237  }
238  }
239  return cand;
240 }
241 
242 const reco::GenParticle* TtGenEvent::leptonicDecayW(bool excludeTauLeptons) const {
243  const reco::GenParticle* cand = nullptr;
244  if (singleLepton(excludeTauLeptons)) {
245  const reco::GenParticleCollection& partsColl = *parts_;
246  const reco::GenParticle& singleLep = *singleLepton(excludeTauLeptons);
247  for (unsigned int i = 0; i < partsColl.size(); ++i) {
248  if (std::abs(partsColl[i].pdgId()) == TopDecayID::WID &&
249  reco::flavour(singleLep) == -reco::flavour(partsColl[i])) {
250  // PDG Id:13=mu- 24=W+ (+24)->(-13) (-24)->(+13) opposite sign
251  cand = &partsColl[i];
252  }
253  }
254  }
255  return cand;
256 }
257 
258 const reco::GenParticle* TtGenEvent::leptonicDecayTop(bool excludeTauLeptons) const {
259  const reco::GenParticle* cand = nullptr;
260  if (singleLepton(excludeTauLeptons)) {
261  const reco::GenParticleCollection& partsColl = *parts_;
262  const reco::GenParticle& singleLep = *singleLepton(excludeTauLeptons);
263  for (unsigned int i = 0; i < partsColl.size(); ++i) {
264  if (std::abs(partsColl[i].pdgId()) == TopDecayID::tID &&
265  reco::flavour(singleLep) != reco::flavour(partsColl[i])) {
266  cand = &partsColl[i];
267  }
268  }
269  }
270  return cand;
271 }
272 
273 std::vector<const reco::GenParticle*> TtGenEvent::leptonicDecayTopRadiation(bool excludeTauLeptons) const {
274  if (leptonicDecayTop(excludeTauLeptons)) {
275  return (leptonicDecayTop(excludeTauLeptons)->pdgId() > 0 ? radiatedGluons(TopDecayID::tID)
277  }
278  std::vector<const reco::GenParticle*> rad;
279  return (rad);
280 }
281 
282 std::vector<const reco::GenParticle*> TtGenEvent::hadronicDecayTopRadiation(bool excludeTauLeptons) const {
283  if (hadronicDecayTop(excludeTauLeptons)) {
284  return (hadronicDecayTop(excludeTauLeptons)->pdgId() > 0 ? radiatedGluons(TopDecayID::tID)
286  }
287  std::vector<const reco::GenParticle*> rad;
288  return (rad);
289 }
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
const reco::GenParticle * leptonicDecayTop(bool excludeTauLeptons=false) const
get top of leptonic decay branch
Definition: TtGenEvent.cc:258
const reco::GenParticle * hadronicDecayB(bool excludeTauLeptons=false) const
get b of hadronic decay branch
Definition: TtGenEvent.cc:181
reco::GenParticleRefProd parts_
reference to the top decay chain (has to be kept in the event!)
Definition: TopGenEvent.h:111
bool isSemiLeptonic(bool excludeTauLeptons=false) const
check if the event can be classified as semi-laptonic
Definition: TtGenEvent.h:38
static const int bID
Definition: TopGenEvent.h:13
bool fromQuarkAnnihilation() const
check if the tops were produced from qqbar
Definition: TtGenEvent.cc:25
const reco::GenParticle * lepton(bool excludeTauLeptons=false) const
get lepton for semi-leptonic or full leptonic decays
Definition: TtGenEvent.cc:69
bool isLepton(const Candidate &part)
Definition: pdgIdUtils.h:13
math::XYZTLorentzVector topPair_
combined 4-vector of top and topBar
Definition: TtGenEvent.h:93
std::vector< const reco::GenParticle * > leptonicDecayTopRadiation(bool excludeTauLeptons=false) const
gluons as radiated from the leptonicly decaying top quark
Definition: TtGenEvent.cc:273
const reco::GenParticle * hadronicDecayW(bool excludeTauLeptons=false) const
get W of hadronic decay branch
Definition: TtGenEvent.cc:196
const reco::GenParticle * top() const
return top if available; 0 else
Definition: TopGenEvent.h:101
reco::GenParticleRefProd initPartons_
reference to the list of initial partons (has to be kept in the event!)
Definition: TopGenEvent.h:113
static const int tID
Definition: TopGenEvent.h:12
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
static const int tauID
Definition: TopGenEvent.h:20
bool isFullLeptonic(bool excludeTauLeptons=false) const
check if the event can be classified as full leptonic
Definition: TtGenEvent.h:42
bool isNeutrino(const Candidate &part)
Definition: pdgIdUtils.h:17
WDecay::LeptonType semiLeptonicChannel() const
return decay channel; all leptons including taus are allowed
Definition: TtGenEvent.cc:33
bool fromGluonFusion() const
check if the tops were produced from a pair of gluons
Definition: TtGenEvent.cc:17
std::vector< const reco::GenParticle * > hadronicDecayTopRadiation(bool excludeTauLeptons=false) const
gluons as radiated from the hadronicly decaying top quark
Definition: TtGenEvent.cc:282
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TtGenEvent()
empty constructor
Definition: TtGenEvent.h:21
const reco::GenParticle * hadronicDecayTop(bool excludeTauLeptons=false) const
get top of hadronic decay branch
Definition: TtGenEvent.cc:212
const reco::GenParticle * hadronicDecayQuark(bool invertFlavor=false) const
get light quark of hadronic decay branch
Definition: TtGenEvent.cc:153
std::pair< WDecay::LeptonType, WDecay::LeptonType > fullLeptonicChannel() const
Definition: TtGenEvent.cc:46
const reco::GenParticle * singleNeutrino(bool excludeTauLeptons=false) const
return single neutrino if available; 0 else
Definition: TtGenEvent.cc:139
static const int muonID
Definition: TopGenEvent.h:19
const reco::GenParticle * leptonicDecayB(bool excludeTauLeptons=false) const
get b of leptonic decay branch
Definition: TtGenEvent.cc:227
std::vector< const reco::GenParticle * > radiatedGluons(int pdgId) const
return radiated gluons from particle with pdgId
Definition: TopGenEvent.cc:177
static const int WID
Definition: TopGenEvent.h:17
const reco::GenParticle * neutrino(bool excludeTauLeptons=false) const
get neutrino for semi-leptonic or full leptonic decays
Definition: TtGenEvent.cc:111
static const int elecID
Definition: TopGenEvent.h:18
T w() const
const reco::GenParticle * neutrinoBar(bool excludeTauLeptons=false) const
get anti-neutrino for semi-leptonic or full leptonic decays
Definition: TtGenEvent.cc:125
const reco::GenParticle * leptonicDecayW(bool excludeTauLeptons=false) const
get W of leptonic decay branch
Definition: TtGenEvent.cc:242
int flavour(const Candidate &part)
Definition: pdgIdUtils.h:21
const reco::GenParticle * topBar() const
return anti-top if available; 0 else
Definition: TopGenEvent.h:103
const reco::GenParticle * leptonBar(bool excludeTauLeptons=false) const
get anti-lepton for semi-leptonic or full leptonic decays
Definition: TtGenEvent.cc:83
const reco::GenParticle * singleLepton(bool excludeTauLeptons=false) const
return single lepton if available; 0 else
Definition: TtGenEvent.cc:97