13 addRadiation_(
cfg.getParameter<
bool>(
"addRadiation")),
21 else if (
mode ==
"kStable")
29 else if (
mode ==
"Run2")
37 produces<reco::GenParticleCollection>();
58 std::vector<const reco::GenParticle*> tops;
100 std::vector<const reco::GenParticle*> tops;
101 for (reco::GenParticleCollection::const_iterator
t =
parts.begin();
t !=
parts.end(); ++
t) {
103 tops.push_back(&(*
t));
111 std::vector<const reco::GenParticle*> tops;
112 for (reco::GenParticleCollection::const_iterator
t =
parts.begin();
t !=
parts.end(); ++
t) {
116 bool hasTopMother =
false;
117 for (
unsigned idx = 0;
idx <
t->numberOfMothers(); ++
idx) {
124 tops.push_back(&(*
t));
133 std::vector<const reco::GenParticle*> tops;
134 for (reco::GenParticleCollection::const_iterator
t =
parts.begin();
t !=
parts.end(); ++
t) {
138 bool hasTopDaughter =
false;
139 for (
unsigned idx = 0;
idx <
t->numberOfDaughters(); ++
idx) {
141 hasTopDaughter =
true;
146 tops.push_back(&(*
t));
155 unsigned int w_index = 0;
162 return static_cast<const reco::GenParticle*>(top->
daughter(w_index));
179 bool containsItself =
false;
180 unsigned int d_idx = 0;
181 for (
unsigned idx = 0;
idx <
p->numberOfDaughters(); ++
idx) {
183 containsItself =
true;
194 if (
p->status() == 3)
203 for (std::vector<const reco::GenParticle*>::const_iterator it = tops.begin(); it != tops.end(); ++it) {
210 top->
begin()->numberOfDaughters() > 1)
217 bool containsWBoson =
false, containsQuarkDaughter =
false;
220 containsQuarkDaughter =
true;
222 containsWBoson =
true;
224 if (containsQuarkDaughter && containsWBoson)
230 edm::LogInfo(
"decayChain") <<
" Failed to find top quarks in decay chain. Will assume that this a \n"
231 <<
" non-top sample and produce an empty decaySubset.\n";
234 " Can not find back any of the supported hadronization models. Models \n"
235 " which are supported are: \n"
236 " Pythia LO(+PS): Top(status 3) --> WBoson(status 3), Quark(status 3)\n"
237 " Herwig NLO(+PS): Top(status 2) --> Top(status 3) --> Top(status 2) \n");
247 if (genEvtInfoProduct.
isValid()) {
253 if (
moduleName.find(
"Pythia6") != std::string::npos)
255 else if (
moduleName.find(
"Pythia8") != std::string::npos)
257 else if (
moduleName.find(
"Herwig6") != std::string::npos)
259 else if (
moduleName.find(
"ThePEG") != std::string::npos)
262 else if (
moduleName.find(
"Sherpa") != std::string::npos)
270 unsigned nTops = tops.size();
271 for (std::vector<const reco::GenParticle*>::iterator it = tops.begin(); it != tops.end();) {
273 bool isContained =
false;
274 bool expectedStatus =
false;
283 expectedStatus =
true;
288 if (!expectedStatus) {
291 edm::LogInfo(
"decayChain") <<
" W boson does not have the expected status. This happens, e.g., \n"
292 <<
" with MC@NLO in the case of additional ttbar pairs from radiated \n"
293 <<
" gluons. We hope everything is fine, remove the correspdonding top \n"
294 <<
" quark from our list since it is not part of the primary ttbar pair \n"
295 <<
" and try to continue. \n";
299 if (tops.empty() && nTops != 0)
301 " Did not find a W boson with appropriate status for any of the top \n"
302 " quarks in this event. This means that the hadronization of the W \n"
303 " boson might be screwed up or there is another problem with the \n"
304 " particle listing in this MC sample. Please contact an expert. \n");
310 unsigned int statusFlag;
315 for (std::vector<const reco::GenParticle*>::const_iterator it = tops.begin(); it != tops.end(); ++it) {
318 std::unique_ptr<reco::GenParticle> topPtr(
320 target.push_back(*topPtr);
324 std::vector<int> topDaughters;
328 std::vector<int> wDaughters;
338 std::unique_ptr<reco::GenParticle> bPtr(
339 new reco::GenParticle(td->threeCharge(),
p4(td, statusFlag), td->vertex(), td->pdgId(), statusFlag,
false));
373 wd->threeCharge(),
p4(wd, statusFlag), wd->vertex(), wd->pdgId(), statusFlag,
false));
394 target.push_back(*radPtr);
405 if (
std::abs(ts->pdgId()) !=
t->pdgId() && ts->pdgId() !=
t->mother()->pdgId()) {
409 new reco::GenParticle(ts->threeCharge(), ts->p4(), ts->vertex(), ts->pdgId(), ts->status(),
false);
410 std::unique_ptr<reco::GenParticle> sPtr(
cand);
412 if (ts->begin() != ts->end()) {
422 refs_[iTop] = topDaughters;
423 refs_[iW] = wDaughters;
428 const std::vector<const reco::GenParticle*>& decayingTops,
430 std::vector<const reco::GenParticle*>::const_iterator top_start;
431 std::vector<const reco::GenParticle*>::const_iterator top_end;
433 top_start = primalTops.begin();
434 top_end = primalTops.end();
436 top_start = decayingTops.begin();
437 top_end = decayingTops.end();
439 for (std::vector<const reco::GenParticle*>::const_iterator it = top_start; it != top_end; ++it) {
442 std::unique_ptr<reco::GenParticle> topPtr(
444 target.push_back(*topPtr);
449 std::vector<int> topDaughters;
453 std::vector<int> wDaughters;
460 std::unique_ptr<reco::GenParticle> qPtr(
461 new reco::GenParticle(td->threeCharge(), td->p4(), td->vertex(), td->pdgId(), td->status(),
false));
473 std::unique_ptr<reco::GenParticle> WPtr(
474 new reco::GenParticle(td->threeCharge(), td->p4(), td->vertex(), td->pdgId(), td->status(),
false));
486 std::unique_ptr<reco::GenParticle> qPtr(
487 new reco::GenParticle(wd->threeCharge(), wd->p4(), wd->vertex(), wd->pdgId(), wd->status(),
false));
505 std::unique_ptr<reco::GenParticle> radPtr(
506 new reco::GenParticle(td->threeCharge(), td->p4(), td->vertex(), td->pdgId(), td->status(),
false));
507 target.push_back(*radPtr);
518 refs_[iTop] = topDaughters;
519 refs_[iW] = wDaughters;
538 vec +=
p4(
p, statusFlag);
549 if (vec.mass() - (*top)->mass() > 0) {
582 vec +=
p4(
p, statusFlag);
602 daughter->threeCharge(), daughter->p4(), daughter->vertex(), daughter->pdgId(), daughter->status(),
false));
618 if (daughter->pdgId() !=
part->pdgId()) {
620 daughter->threeCharge(), daughter->p4(), daughter->vertex(), daughter->pdgId(), daughter->status(),
false));
639 daughter->threeCharge(), daughter->p4(), daughter->vertex(), daughter->pdgId(), daughter->status(),
false));
665 for (reco::GenParticleCollection::iterator
p =
sel.begin();
p !=
sel.end(); ++
p, ++
idx) {
669 for (std::vector<int>::const_iterator daughter =
daughters->second.begin(); daughter !=
daughters->second.end();
672 if (
part ==
nullptr) {