CMS 3D CMS Logo

GenHFHadronMatcher.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: GenHFHadronMatcher
4 // Class: GenHFHadronMatcher
5 //
6 
19 // Original Author: Nazar Bartosik,DESY
20 
21 // system include files
22 #include <memory>
23 #include <utility>
24 #include <vector>
25 #include <algorithm>
26 
27 // user include files
30 
33 
35 
40 
42 
46 
48 
49 //
50 // class declaration
51 //
52 
54 public:
55  explicit GenHFHadronMatcher(const edm::ParameterSet &);
56  ~GenHFHadronMatcher() override;
57 
58  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
59 
60 private:
61  void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
62 
65  std::vector<int> &hadIndex,
66  std::vector<reco::GenParticle> &hadMothersGenPart,
67  std::vector<std::vector<int>> &hadMothersIndices,
68  std::vector<int> &hadLeptonIndex,
69  std::vector<int> &hadLeptonHadIndex,
70  std::vector<int> &hadLeptonViaTau,
71  std::vector<int> &hadFlavour,
72  std::vector<int> &hadFromTopWeakDecay,
73  std::vector<int> &hadBHadronId) const;
74  int analyzeMothers(const reco::Candidate *thisParticle,
75  int &topDaughterQId,
76  int &topBarDaughterQId,
77  std::vector<const reco::Candidate *> &hadMothers,
78  std::vector<std::vector<int>> &hadMothersIndices,
79  std::set<const reco::Candidate *> *analyzedParticles,
80  const int prevPartIndex) const;
81  bool putMotherIndex(std::vector<std::vector<int>> &hadMothersIndices, int partIndex, int mothIndex) const;
82  bool isHadron(const int flavour, const reco::Candidate *thisParticle) const;
83  bool isHadronPdgId(const int flavour, const int pdgId) const;
84  bool isMesonPdgId(const int flavour, const int pdgId) const;
85  bool isBaryonPdgId(const int flavour, const int pdgId) const;
86  int flavourSign(const int pdgId) const;
87  bool hasHadronDaughter(const int flavour, const reco::Candidate *thisParticle) const;
88  int idInList(std::vector<const reco::Candidate *> particleList, const reco::Candidate *particle) const;
89  int idInList(std::vector<int> list, const int value) const;
90  int findInMothers(int idx,
91  std::vector<int> &mothChains,
92  const std::vector<std::vector<int>> &hadMothersIndices,
93  const std::vector<reco::GenParticle> &hadMothers,
94  int status,
95  int pdgId,
96  bool pdgAbs,
97  int stopId,
98  int firstLast,
99  bool verbose) const;
100  bool isNeutralPdg(int pdgId) const;
101 
102  bool checkForLoop(std::vector<const reco::Candidate *> &particleChain, const reco::Candidate *particle) const;
103  std::string getParticleName(int id) const;
104 
105  bool fixExtraSameFlavours(const unsigned int hadId,
106  const std::vector<int> &hadIndices,
107  const std::vector<reco::GenParticle> &hadMothers,
108  const std::vector<std::vector<int>> &hadMothersIndices,
109  const std::vector<int> &isFromTopWeakDecay,
110  const std::vector<std::vector<int>> &LastQuarkIds,
111  const std::vector<std::vector<int>> &LastQuarkMotherIds,
112  std::vector<int> &lastQuarkIndices,
113  std::vector<int> &hadronFlavour,
114  std::set<int> &checkedHadronIds,
115  const int lastQuarkIndex) const;
116 
117  // ----------member data ---------------------------
120  const int flavour_;
121  const bool noBBbarResonances_;
123 
135 };
136 
137 //
138 // constants, enums and typedefs
139 //
140 
141 //
142 // static data member definitions
143 //
144 
145 //
146 // constructors and destructor
147 //
156 namespace {
157  std::string flavourName(int flavour) {
158  if (flavour == 5) {
159  return "B";
160  } else if (flavour == 4) {
161  return "C";
162  }
163  edm::LogError("GenHFHadronMatcher") << "Flavour option must be 4 (c-jet) or 5 (b-jet), but is: " << flavour
164  << ". Correct this!";
165  return std::string();
166  }
167 } // namespace
168 
170  : genParticlesToken_(consumes<reco::GenParticleCollection>(cfg.getParameter<edm::InputTag>("genParticles"))),
171  jetFlavourInfosToken_(
172  consumes<reco::JetFlavourInfoMatchingCollection>(cfg.getParameter<edm::InputTag>("jetFlavourInfos"))),
173  flavour_{std::abs(cfg.getParameter<int>("flavour"))},
174  noBBbarResonances_{cfg.getParameter<bool>("noBBbarResonances")},
175  onlyJetClusteredHadrons_{cfg.getParameter<bool>("onlyJetClusteredHadrons")},
176  flavourStr_{flavourName(flavour_)},
177  plusMothersToken_{produces<std::vector<reco::GenParticle>>(
178  "gen" + flavourStr_ +
179  "HadPlusMothers")}, // All mothers in all decay chains above any hadron of specified flavour
180  plusMothersIndicesToken_{produces<std::vector<std::vector<int>>>(
181  "gen" + flavourStr_ + "HadPlusMothersIndices")}, // Indices of mothers of each hadMother
182  indexToken_{
183  produces<std::vector<int>>("gen" + flavourStr_ + "HadIndex")}, // Index of hadron in the vector of hadMothers
184  flavourToken_{produces<std::vector<int>>(
185  "gen" + flavourStr_ +
186  "HadFlavour")}, // PdgId of the first non-b(c) quark mother with sign corresponding to hadron charge
187  jetIndexToken_{produces<std::vector<int>>(
188  "gen" + flavourStr_ + "HadJetIndex")}, // Index of genJet matched to each hadron by jet clustering algorithm
189  leptonIndexToken_{produces<std::vector<int>>(
190  "gen" + flavourStr_ +
191  "HadLeptonIndex")}, // Index of lepton found among the hadron decay products in the list of mothers
192  leptonHadronIndexToken_{produces<std::vector<int>>(
193  "gen" + flavourStr_ + "HadLeptonHadronIndex")}, // Index of hadron the lepton is associated to
194  leptonViaTauToken_{produces<std::vector<int>>(
195  "gen" + flavourStr_ + "HadLeptonViaTau")}, // Whether lepton comes directly from hadron or via tau decay
196  fromTopWeakDecayToken_{produces<std::vector<int>>(
197  "gen" + flavourStr_ +
198  "HadFromTopWeakDecay")}, // Tells whether the hadron appears in the chain after top decay
199  bHadronIdToken_{produces<std::vector<int>>("gen" + flavourStr_ + "HadBHadronId")}
200 // Index of a b-hadron which the current hadron comes from (for c-hadrons)
201 {
202  // Hadron matching products
203 }
204 
206 
207 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
214  desc.add<edm::InputTag>("genParticles")
215  ->setComment("Collection of GenParticle objects which contains all particles produced in the event");
216  desc.add<edm::InputTag>("jetFlavourInfos")
217  ->setComment(
218  "Output from the JetFlavour tool. Contains information about partons/hadrons/leptons associated to jets");
219  desc.add<bool>("noBBbarResonances", true)->setComment("Whether resonances should not be treated as hadrons");
220  desc.add<bool>("onlyJetClusteredHadrons", false)
221  ->setComment("Whether only hadrons that are matched to jets should be analysed. Runs x1000 faster in Sherpa");
222  desc.add<int>("flavour", 5)->setComment("Flavour of weakly decaying hadron that should be analysed (4-c, 5-b)");
223  descriptions.add("matchGenHFHadron", desc);
224 }
225 
226 //
227 // member functions
228 //
229 
230 // ------------ method called to produce the data ------------
232  using namespace edm;
233 
236 
239 
240  // Defining adron matching variables
241  std::vector<reco::GenParticle> hadMothers;
242  std::vector<std::vector<int>> hadMothersIndices;
243  std::vector<int> hadIndex;
244  std::vector<int> hadFlavour;
245  std::vector<int> hadJetIndex;
246  std::vector<int> hadLeptonIndex;
247  std::vector<int> hadLeptonHadIndex;
248  std::vector<int> hadLeptonViaTau;
249  std::vector<int> hadFromTopWeakDecay;
250  std::vector<int> hadBHadronId;
251 
252  hadJetIndex = findHadronJets(genParticles.product(),
253  jetFlavourInfos.product(),
254  hadIndex,
255  hadMothers,
256  hadMothersIndices,
257  hadLeptonIndex,
258  hadLeptonHadIndex,
259  hadLeptonViaTau,
260  hadFlavour,
261  hadFromTopWeakDecay,
262  hadBHadronId);
263 
264  // Putting products to the event
265  evt.emplace(plusMothersToken_, std::move(hadMothers));
266  evt.emplace(plusMothersIndicesToken_, std::move(hadMothersIndices));
267  evt.emplace(indexToken_, std::move(hadIndex));
268  evt.emplace(flavourToken_, std::move(hadFlavour));
269  evt.emplace(jetIndexToken_, std::move(hadJetIndex));
270  evt.emplace(leptonIndexToken_, std::move(hadLeptonIndex));
271  evt.emplace(leptonHadronIndexToken_, std::move(hadLeptonHadIndex));
272  evt.emplace(leptonViaTauToken_, std::move(hadLeptonViaTau));
273  evt.emplace(fromTopWeakDecayToken_, std::move(hadFromTopWeakDecay));
274  evt.emplace(bHadronIdToken_, std::move(hadBHadronId));
275 }
276 
301  std::vector<int> &hadIndex,
302  std::vector<reco::GenParticle> &hadMothers,
303  std::vector<std::vector<int>> &hadMothersIndices,
304  std::vector<int> &hadLeptonIndex,
305  std::vector<int> &hadLeptonHadIndex,
306  std::vector<int> &hadLeptonViaTau,
307  std::vector<int> &hadFlavour,
308  std::vector<int> &hadFromTopWeakDecay,
309  std::vector<int> &hadBHadronId) const {
310  std::vector<int> hadJetIndex;
311  std::vector<const reco::Candidate *> hadMothersCand;
312 
313  int topDaughterQId = -1;
314  int topBarDaughterQId = -1;
315 
316  // Looping over all jets to get hadrons associated to them
318  i_info != jetFlavourInfos->end();
319  ++i_info) {
320  reco::JetFlavourInfo jetInfo = i_info->second;
321  const int jetIndex = i_info - jetFlavourInfos->begin();
322  // Looping over each hadron associated with the jet and finding its origin
323  const reco::GenParticleRefVector &hadronsInJet =
324  flavour_ == 5 ? jetInfo.getbHadrons() : flavour_ == 4 ? jetInfo.getcHadrons() : reco::GenParticleRefVector();
325  for (reco::GenParticleRefVector::const_iterator hadron = hadronsInJet.begin(); hadron != hadronsInJet.end();
326  ++hadron) {
327  // Check that the hadron satisfies criteria configured in the module
328  if (!isHadron(flavour_, (&**hadron)))
329  continue;
330  if (hasHadronDaughter(flavour_, (reco::Candidate *)(&**hadron)))
331  continue;
332  // Scanning the chain starting from the hadron
333  int hadronIndex = analyzeMothers((reco::Candidate *)(&**hadron),
334  topDaughterQId,
335  topBarDaughterQId,
336  hadMothersCand,
337  hadMothersIndices,
338  nullptr,
339  -1);
340  // Storing the index of the hadron to the list
341  hadIndex.push_back(hadronIndex);
342  hadJetIndex.push_back(jetIndex); // Putting jet index to the result list
343  }
344  } // End of loop over jets
345 
346  // Access all hadrons which are not associated with jets, if requested
348  for (reco::GenParticleCollection::const_iterator i_particle = genParticles->begin();
349  i_particle != genParticles->end();
350  ++i_particle) {
351  const reco::GenParticle *thisParticle = &*i_particle;
352  if (!isHadron(flavour_, thisParticle))
353  continue;
354  // Skipping the hadron if it was already found directly from jets
355  if (std::find(hadMothersCand.begin(), hadMothersCand.end(), thisParticle) != hadMothersCand.end())
356  continue;
357 
358  // Scanning the chain starting from the hadron
359  int hadronIndex = analyzeMothers(
360  thisParticle, topDaughterQId, topBarDaughterQId, hadMothersCand, hadMothersIndices, nullptr, -1);
361  // Storing the index of the hadron to the list
362  hadIndex.push_back(hadronIndex);
363  hadJetIndex.push_back(-1); // Jet index undefined
364  }
365  }
366 
367  // Transfering Candidates to the list of processed particles for further analysis
368  for (int i = 0; i < (int)hadMothersCand.size(); i++) {
369  const reco::GenParticle *particle = dynamic_cast<const reco::GenParticle *>(hadMothersCand.at(i));
370  hadMothers.push_back(*particle);
371  }
372 
373  // Adding leptons from hadron decays
374  for (reco::GenParticleCollection::const_iterator i_particle = genParticles->begin();
375  i_particle != genParticles->end();
376  ++i_particle) {
377  const reco::GenParticle lepton = *i_particle;
378  const int pdg_abs = lepton.pdgId();
379  // Skipping if not a lepton: e/mu
380  if (pdg_abs != 11 && pdg_abs != 13)
381  continue;
382  bool leptonViaTau = false;
383  const reco::Candidate *leptonMother = lepton.mother();
384  if (!leptonMother)
385  continue;
386  // Taking next mother if direct mother is a tau
387  if (std::abs(leptonMother->pdgId()) == 15) {
388  leptonViaTau = true;
389  leptonMother = leptonMother->mother();
390  }
391  // Skipping this lepton if its mother is not a proper hadron
392  if (leptonMother == nullptr or !isHadron(flavour_, leptonMother))
393  continue;
394  // Finding the index of this hadron in the list of analysed particles
395  size_t leptonHadronParticleIndex =
396  std::find(hadMothersCand.begin(), hadMothersCand.end(), leptonMother) - hadMothersCand.begin();
397  if (leptonHadronParticleIndex >= hadMothersCand.size())
398  continue;
399  // Finding the actual hadron index among those that were found
400  size_t leptonHadronIndex =
401  std::find(hadIndex.begin(), hadIndex.end(), leptonHadronParticleIndex) - hadIndex.begin();
402  if (leptonHadronIndex >= hadIndex.size())
403  continue;
404  // Putting the lepton, its index and hadron index to the corresponding lists
405  hadMothers.push_back(lepton);
406  const int leptonIndex = hadMothersCand.size() - 1;
407  hadLeptonIndex.push_back(leptonIndex);
408  hadLeptonViaTau.push_back(leptonViaTau);
409  hadLeptonHadIndex.push_back(leptonHadronIndex);
410  }
411 
412  // Checking mothers of hadrons in order to assign flags (where the hadron comes from)
413  unsigned int nHad = hadIndex.size();
414 
415  std::vector<std::vector<int>> LastQuarkMotherIds;
416  std::vector<std::vector<int>> LastQuarkIds;
417  std::vector<int> lastQuarkIndices(nHad, -1);
418 
419  // Looping over all hadrons
420  for (unsigned int hadNum = 0; hadNum < nHad; hadNum++) {
421  unsigned int hadIdx = hadIndex.at(hadNum); // Index of hadron in the hadMothers
422 
423  std::vector<int> FirstQuarkId;
424  std::vector<int> LastQuarkId;
425  std::vector<int> LastQuarkMotherId;
426 
427  const int hadronFlavourSign = flavourSign(hadMothers.at(hadIdx).pdgId());
428 
429  // Searching only first quark in the chain with the same flavour as hadron
430  if (hadronFlavourSign != 0) {
432  hadIdx, FirstQuarkId, hadMothersIndices, hadMothers, 0, hadronFlavourSign * flavour_, false, -1, 1, false);
433  }
434  // Searching for quarks with both flavours since it is a bb/cc resonance
435  else {
436  findInMothers(hadIdx, FirstQuarkId, hadMothersIndices, hadMothers, 0, flavour_, false, -1, 1, false);
437  findInMothers(hadIdx, FirstQuarkId, hadMothersIndices, hadMothers, 0, -1 * flavour_, false, -1, 1, false);
438  }
439 
440  // Finding last quark for each first quark
441  for (unsigned int qId = 0; qId < FirstQuarkId.size(); qId++) {
442  // Identifying the flavour of the first quark to find the last quark of the same flavour
443  const int quarkFlavourSign = flavourSign(hadMothers.at(FirstQuarkId.at(qId)).pdgId());
444  // Finding last quark of the hadron starting from the first quark
445  findInMothers(FirstQuarkId.at(qId),
446  LastQuarkId,
447  hadMothersIndices,
448  hadMothers,
449  0,
450  quarkFlavourSign * flavour_,
451  false,
452  -1,
453  2,
454  false);
455  } // End of loop over all first quarks of the hadron
456 
457  // Setting initial flavour of the hadron
458  int hadronFlavour = 0;
459 
460  // Initialising pairs of last quark index and its distance from the hadron (to sort by distance)
461  std::vector<std::pair<double, int>> lastQuark_dR_id_pairs;
462 
463  // Finding the closest quark in dR
464  for (unsigned int qId = 0; qId < LastQuarkId.size(); qId++) {
465  int qIdx = LastQuarkId.at(qId);
466  // Calculating the dR between hadron and quark
467  float dR = deltaR(hadMothers.at(hadIdx).eta(),
468  hadMothers.at(hadIdx).phi(),
469  hadMothers.at(qIdx).eta(),
470  hadMothers.at(qIdx).phi());
471 
472  std::pair<double, int> dR_hadId_pair(dR, qIdx);
473  lastQuark_dR_id_pairs.push_back(dR_hadId_pair);
474  } // End of loop over all last quarks of the hadron
475 
476  std::sort(lastQuark_dR_id_pairs.begin(), lastQuark_dR_id_pairs.end());
477 
478  if (lastQuark_dR_id_pairs.size() > 1) {
479  double dRratio =
480  (lastQuark_dR_id_pairs.at(1).first - lastQuark_dR_id_pairs.at(0).first) / lastQuark_dR_id_pairs.at(1).first;
481  int qIdx_closest = lastQuark_dR_id_pairs.at(0).second;
482  LastQuarkId.clear();
483  if (dRratio > 0.5)
484  LastQuarkId.push_back(qIdx_closest);
485  else
486  for (std::pair<double, int> qIdDrPair : lastQuark_dR_id_pairs)
487  LastQuarkId.push_back(qIdDrPair.second);
488  }
489  for (int qIdx : LastQuarkId) {
490  int qmIdx = hadMothersIndices.at(qIdx).at(0);
491  LastQuarkMotherId.push_back(qmIdx);
492  }
493 
494  if ((int)LastQuarkId.size() > 0)
495  lastQuarkIndices.at(hadNum) = 0; // Setting the first quark in array as a candidate if it exists
496 
497  LastQuarkIds.push_back(LastQuarkId);
498 
499  LastQuarkMotherIds.push_back(LastQuarkMotherId);
500 
501  if (LastQuarkMotherId.empty()) {
502  hadronFlavour = 0;
503  } else {
504  int qIdx = LastQuarkId.at(lastQuarkIndices.at(hadNum));
505  int qFlav = flavourSign(hadMothers.at(qIdx).pdgId());
506  hadronFlavour = qFlav * std::abs(hadMothers.at(LastQuarkMotherId.at(lastQuarkIndices.at(hadNum))).pdgId());
507  }
508  hadFlavour.push_back(hadronFlavour); // Adding hadron flavour to the list of flavours
509 
510  // Checking whether hadron comes from the Top weak decay
511  int isFromTopWeakDecay = 1;
512  std::vector<int> checkedParticles;
513  if (hadFlavour.at(hadNum) != 0) {
514  int lastQIndex = LastQuarkId.at(lastQuarkIndices.at(hadNum));
515  bool fromTB = topDaughterQId >= 0 ? findInMothers(lastQIndex,
516  checkedParticles,
517  hadMothersIndices,
518  hadMothers,
519  -1,
520  0,
521  false,
522  topDaughterQId,
523  2,
524  false) >= 0
525  : false;
526  checkedParticles.clear();
527  bool fromTbarB = topBarDaughterQId >= 0 ? findInMothers(lastQIndex,
528  checkedParticles,
529  hadMothersIndices,
530  hadMothers,
531  -1,
532  0,
533  false,
534  topBarDaughterQId,
535  2,
536  false) >= 0
537  : false;
538  checkedParticles.clear();
539  if (!fromTB && !fromTbarB) {
540  isFromTopWeakDecay = 0;
541  }
542  } else
543  isFromTopWeakDecay = 2;
544  hadFromTopWeakDecay.push_back(isFromTopWeakDecay);
545  int bHadronMotherId =
546  findInMothers(hadIdx, checkedParticles, hadMothersIndices, hadMothers, 0, 555555, true, -1, 1, false);
547  hadBHadronId.push_back(bHadronMotherId);
548 
549  if (!LastQuarkMotherId.empty()) {
550  std::set<int> checkedHadronIds;
551  fixExtraSameFlavours(hadNum,
552  hadIndex,
553  hadMothers,
554  hadMothersIndices,
555  hadFromTopWeakDecay,
556  LastQuarkIds,
557  LastQuarkMotherIds,
558  lastQuarkIndices,
559  hadFlavour,
560  checkedHadronIds,
561  0);
562  }
563 
564  } // End of loop over all hadrons
565 
566  return hadJetIndex;
567 }
568 
577 int GenHFHadronMatcher::idInList(std::vector<const reco::Candidate *> particleList,
578  const reco::Candidate *particle) const {
579  const unsigned int position = std::find(particleList.begin(), particleList.end(), particle) - particleList.begin();
580  if (position >= particleList.size())
581  return -1;
582 
583  return position;
584 }
585 
586 int GenHFHadronMatcher::idInList(std::vector<int> list, const int value) const {
587  const unsigned int position = std::find(list.begin(), list.end(), value) - list.begin();
588  if (position >= list.size())
589  return -1;
590 
591  return position;
592 }
593 
602 bool GenHFHadronMatcher::isHadron(const int flavour, const reco::Candidate *thisParticle) const {
603  return isHadronPdgId(flavour, thisParticle->pdgId());
604 }
605 
614 bool GenHFHadronMatcher::isHadronPdgId(const int flavour, const int pdgId) const {
616  return true;
617 
618  return false;
619 }
620 
629 bool GenHFHadronMatcher::isMesonPdgId(const int flavour, const int pdgId) const {
630  const int flavour_abs = std::abs(flavour);
631  if (flavour_abs != 5 && flavour_abs != 4)
632  return false;
633  const int pdgId_abs = std::abs(pdgId);
634 
635  if (pdgId_abs / 100 % 10 != flavour_abs)
636  return false;
637  // Excluding baryons
638  if (pdgId_abs / 1000 == flavour_abs)
639  return false;
640  // Excluding bb/cc resonances if required
641  if (noBBbarResonances_ && pdgId_abs / 10 % 100 == 11 * flavour_abs)
642  return false;
643 
644  return true;
645 }
646 
655 bool GenHFHadronMatcher::isBaryonPdgId(const int flavour, const int pdgId) const {
656  const int flavour_abs = std::abs(flavour);
657  if (flavour_abs != 5 && flavour_abs != 4)
658  return false;
659  const int pdgId_abs = std::abs(pdgId);
660 
661  if (pdgId_abs / 1000 != flavour_abs)
662  return false;
663 
664  return true;
665 }
666 
675  int flavourSign = pdgId / std::abs(pdgId);
676  // B mesons have opposite sign
677  if (isMesonPdgId(5, pdgId))
678  flavourSign *= -1;
679  // Returning 0 for bb/cc resonances
680  if (pdgId % 1000 / 10 / 11 > 0)
681  flavourSign = 0;
682 
683  return flavourSign;
684 }
685 
694 bool GenHFHadronMatcher::hasHadronDaughter(const int flavour, const reco::Candidate *thisParticle) const {
695  // Looping through daughters of the particle
696  bool hasDaughter = false;
697  for (int k = 0; k < (int)thisParticle->numberOfDaughters(); k++) {
698  if (!isHadron(flavour, thisParticle->daughter(k))) {
699  continue;
700  }
701  hasDaughter = true;
702  break;
703  }
704 
705  return hasDaughter;
706 }
707 
726  int &topDaughterQId,
727  int &topBarDaughterQId,
728  std::vector<const reco::Candidate *> &hadMothers,
729  std::vector<std::vector<int>> &hadMothersIndices,
730  std::set<const reco::Candidate *> *analyzedParticles,
731  const int prevPartIndex) const {
732  // Getting the index of the particle which is a hadron in the first call
733  int hadronIndex = -1; // Index of the hadron that is returned by this function
734  int index = idInList(hadMothers, thisParticle);
735  if (index < 0) { // If hadron is not in the list of mothers yet
736  hadMothers.push_back(thisParticle);
737  hadronIndex = hadMothers.size() - 1;
738  } else { // If hadron is in the list of mothers already
739  hadronIndex = index;
740  }
741 
742  int partIndex = -1; // Index of particle being checked in the list of mothers
743  partIndex = idInList(hadMothers, thisParticle);
744 
745  // Checking whether this particle is already in the chain of analyzed particles in order to identify a loop
746  bool isLoop = false;
747  if (!analyzedParticles) {
748  analyzedParticles = new std::set<const reco::Candidate *>;
749  }
750  for (unsigned int i = 0; i < analyzedParticles->size(); i++) {
751  if (analyzedParticles->count(thisParticle) <= 0) {
752  continue;
753  }
754  isLoop = true;
755  break;
756  }
757 
758  // If a loop has been detected
759  if (isLoop) {
760  if (prevPartIndex >= 0) {
761  putMotherIndex(hadMothersIndices, prevPartIndex, -1); // Setting mother index of previous particle to -1
762  }
763  return hadronIndex; // Stopping further processing of the current chain
764  }
765  analyzedParticles->insert(thisParticle);
766 
767  // Putting the mothers to the list of mothers
768  for (size_t iMother = 0; iMother < thisParticle->numberOfMothers(); ++iMother) {
769  const reco::Candidate *mother = thisParticle->mother(iMother);
770  int mothIndex = idInList(hadMothers, mother);
771  if (mothIndex == partIndex && partIndex >= 0) {
772  continue; // Skipping the mother that is its own daughter
773  }
774 
775  // If this mother isn't yet in the list and hadron or lepton is in the list
776  if (mothIndex < 0) {
777  hadMothers.push_back(mother);
778  mothIndex = hadMothers.size() - 1;
779  }
780  // If hadron has already been found in current chain and the mother isn't a duplicate of the particle being checked
781  if (mothIndex != partIndex && partIndex >= 0) {
782  putMotherIndex(hadMothersIndices, partIndex, mothIndex); // Putting the index of mother for current particle
783  }
785  mother, topDaughterQId, topBarDaughterQId, hadMothers, hadMothersIndices, analyzedParticles, partIndex);
786  // Setting the id of the particle which is a quark from the top decay
787  if (std::abs(mother->pdgId()) == 6) {
788  int &bId = mother->pdgId() < 0 ? topBarDaughterQId : topDaughterQId;
789  int thisFlav = std::abs(thisParticle->pdgId());
790  if (bId < 0) {
791  if (thisFlav <= 5)
792  bId = partIndex;
793  } else {
794  int bIdFlav = std::abs(hadMothers.at(bId)->pdgId());
795  if (bIdFlav != 5 && thisFlav == 5)
796  bId = partIndex;
797  else if (thisFlav == 5 && thisParticle->pt() > hadMothers.at(bId)->pt())
798  bId = partIndex;
799  } // If daughter quark of the top not found yet
800  } // If the mother is a top quark and hadron has been found
801  } // End of loop over mothers
802 
803  analyzedParticles->erase(thisParticle); // Removing current particle from the current chain that is being analyzed
804 
805  if (partIndex < 0) {
806  return hadronIndex; // Safety check
807  }
808 
809  // Adding -1 to the list of mother indices for current particle if it has no mothers (for consistency between numbering of indices and mothers)
810  if ((int)thisParticle->numberOfMothers() <= 0) {
811  putMotherIndex(hadMothersIndices, partIndex, -1);
812  }
813 
814  return hadronIndex;
815 }
816 
826 bool GenHFHadronMatcher::putMotherIndex(std::vector<std::vector<int>> &hadMothersIndices,
827  int partIndex,
828  int mothIndex) const {
829  // Putting vector of mothers indices for the given particle
830  bool inList = false;
831  if (partIndex < 0) {
832  return false;
833  }
834 
835  while ((int)hadMothersIndices.size() <= partIndex) { // If there is no list of mothers for current particle yet
836  std::vector<int> mothersIndices;
837  hadMothersIndices.push_back(mothersIndices);
838  }
839 
840  std::vector<int> *hadMotherIndices = &hadMothersIndices.at(partIndex);
841  // Removing other mothers if particle must have no mothers
842  if (mothIndex == -1) {
843  hadMotherIndices->clear();
844  } else {
845  // Checking if current mother is already in the list of theParticle's mothers
846  for (int k = 0; k < (int)hadMotherIndices->size(); k++) {
847  if (hadMotherIndices->at(k) != mothIndex && hadMotherIndices->at(k) != -1) {
848  continue;
849  }
850  inList = true;
851  break;
852  }
853  }
854  // Adding current mother to the list of mothers of this particle
855  if (!inList) {
856  hadMotherIndices->push_back(mothIndex);
857  }
858 
859  return inList;
860 }
861 
880  std::vector<int> &mothChains,
881  const std::vector<std::vector<int>> &hadMothersIndices,
882  const std::vector<reco::GenParticle> &hadMothers,
883  int status,
884  int pdgId,
885  bool pdgAbs = false,
886  int stopId = -1,
887  int firstLast = 0,
888  bool verbose = false) const {
889  int foundStopId = -1;
890  int pdg_1 = hadMothers.at(idx).pdgId();
891 
892  if ((int)hadMothersIndices.size() <= idx) {
893  if (verbose) {
894  printf(" Stopping checking particle %d. No mothers are stored.\n", idx);
895  }
896  return -1; // Skipping if no mothers are stored for this particle
897  }
898 
899  if (std::abs(hadMothers.at(idx).pdgId()) > 10 && std::abs(hadMothers.at(idx).pdgId()) < 19)
900  printf("Lepton: %d\n", hadMothers.at(idx).pdgId());
901 
902  std::vector<int> mothers = hadMothersIndices.at(idx);
903  unsigned int nMothers = mothers.size();
904  bool isCorrect = false; // Whether current particle is what is being searched
905  if (verbose) {
906  if (std::abs(hadMothers.at(idx).pdgId()) == 2212) {
907  printf("Chk: %d\tpdg: %d\tstatus: %d", idx, hadMothers.at(idx).pdgId(), hadMothers.at(idx).status());
908  } else {
909  printf(" Chk: %d(%d mothers)\tpdg: %d\tstatus: %d\tPt: %.3f\tEta: %.3f",
910  idx,
911  nMothers,
912  hadMothers.at(idx).pdgId(),
913  hadMothers.at(idx).status(),
914  hadMothers.at(idx).pt(),
915  hadMothers.at(idx).eta());
916  }
917  }
918  bool hasCorrectMothers = true;
919  if (nMothers < 1)
920  hasCorrectMothers = false;
921  else if (mothers.at(0) < 0)
922  hasCorrectMothers = false;
923  if (!hasCorrectMothers) {
924  if (verbose)
925  printf(" NO CORRECT MOTHER\n");
926  return -1;
927  }
928  // Stopping if the particular particle has been found
929  if (stopId >= 0 && idx == stopId)
930  return idx;
931 
932  // Stopping if the hadron of particular flavour has been found
933  if (pdgId % 111111 == 0 && pdgId != 0) {
934  if (isHadronPdgId(pdgId / 111111, hadMothers.at(idx).pdgId())) {
935  return idx;
936  }
937  }
938 
939  // Checking whether current mother satisfies selection criteria
940  if (((hadMothers.at(idx).pdgId() == pdgId && pdgAbs == false) ||
941  (std::abs(hadMothers.at(idx).pdgId()) == std::abs(pdgId) && pdgAbs == true)) &&
942  (hadMothers.at(idx).status() == status || status == 0) && hasCorrectMothers) {
943  isCorrect = true;
944  // Adding to the list of candidates if not there and if mother of this quark has correct flavour sign
945  const bool inList = std::find(mothChains.begin(), mothChains.end(), idx) != mothChains.end();
946  if (!inList && mothers.at(0) >= 0 && (hadMothers.at(idx).pdgId() * pdgId > 0 || !pdgAbs)) {
947  if (firstLast == 0 || firstLast == 1) {
948  mothChains.push_back(idx);
949  }
950  if (verbose) {
951  printf(" *");
952  }
953  }
954  if (verbose) {
955  printf(" +++");
956  }
957  }
958  if (verbose) {
959  printf("\n");
960  }
961 
962  if (isCorrect && firstLast == 1) {
963  return -1; // Stopping if only the first particle in the chain is looked for
964  }
965 
966  // Checking next level mothers
967  unsigned int nDifferingMothers = 0;
968  for (unsigned int i = 0; i < nMothers; i++) {
969  int idx2 = mothers.at(i);
970  if (idx2 < 0) {
971  if (verbose)
972  printf("^^^ Has no mother\n");
973  continue; // Skipping if mother's id is -1 (no mother), that means current particle is a proton
974  }
975  if (idx2 == idx) {
976  if (verbose)
977  printf("^^^ Stored as its own mother\n");
978  continue; // Skipping if particle is stored as its own mother
979  }
980  int pdg_2 = hadMothers[idx2].pdgId();
981  // Inverting the flavour if bb oscillation detected
982  if (isHadronPdgId(pdgId, pdg_1) && isHadronPdgId(pdgId, pdg_2) && pdg_1 * pdg_2 < 0) {
983  pdgId *= -1;
984  if (verbose)
985  printf("######### Inverting flavour of the hadron\n");
986  }
987  // Counting how many mothers are different from this particle
988  if ((std::abs(pdg_2) != std::abs(pdgId) && pdgAbs == true) || (pdg_2 != pdgId && pdgAbs == false)) {
989  nDifferingMothers++;
990  }
991 
992  // Checking next level mother
993  if (verbose) {
994  printf("Checking mother %d out of %d mothers (%d -> %d), looking for pdgId: %d\n", i, nMothers, idx, idx2, pdgId);
995  }
996  if (firstLast == 2 && pdg_1 != pdg_2)
997  continue; // Requiring the same flavour when finding the last quark
998  foundStopId = findInMothers(
999  idx2, mothChains, hadMothersIndices, hadMothers, status, pdgId, pdgAbs, stopId, firstLast, verbose);
1000  }
1001  // Storing this particle if all its mothers are of another type and the last of its kind should be stored
1002  if (firstLast == 2 && isCorrect && nDifferingMothers >= nMothers) {
1003  if (verbose) {
1004  printf("Checking particle %d once more to store it as the last quark\n", idx);
1005  }
1006  foundStopId = findInMothers(idx, mothChains, hadMothersIndices, hadMothers, 0, pdgId, pdgAbs, stopId, 1, verbose);
1007  }
1008 
1009  return foundStopId;
1010 }
1011 
1021  const int neutralPdgs_array[] = {9, 21, 22, 23, 25};
1022  const std::vector<int> neutralPdgs(neutralPdgs_array, neutralPdgs_array + sizeof(neutralPdgs_array) / sizeof(int));
1023  if (std::find(neutralPdgs.begin(), neutralPdgs.end(), std::abs(pdgId)) == neutralPdgs.end())
1024  return false;
1025 
1026  return true;
1027 }
1028 
1043 bool GenHFHadronMatcher::fixExtraSameFlavours(const unsigned int hadId,
1044  const std::vector<int> &hadIndices,
1045  const std::vector<reco::GenParticle> &hadMothers,
1046  const std::vector<std::vector<int>> &hadMothersIndices,
1047  const std::vector<int> &isFromTopWeakDecay,
1048  const std::vector<std::vector<int>> &LastQuarkIds,
1049  const std::vector<std::vector<int>> &LastQuarkMotherIds,
1050  std::vector<int> &lastQuarkIndices,
1051  std::vector<int> &hadronFlavour,
1052  std::set<int> &checkedHadronIds,
1053  const int lastQuarkIndex) const {
1054  if (checkedHadronIds.count(hadId) != 0)
1055  return false; // Hadron already checked previously and should be skipped
1056  checkedHadronIds.insert(hadId); // Putting hadron to the list of checked ones in this run
1057 
1058  if (lastQuarkIndex < 0)
1059  return false;
1060  if ((int)LastQuarkIds.at(hadId).size() < lastQuarkIndex + 1)
1061  return false;
1062  int LastQuarkId = LastQuarkIds.at(hadId).at(lastQuarkIndex);
1063  int LastQuarkMotherId = LastQuarkMotherIds.at(hadId).at(lastQuarkIndex);
1064  int qmFlav = hadMothers.at(LastQuarkId).pdgId() < 0 ? -1 : 1;
1065  int hadFlavour = qmFlav * std::abs(hadMothers.at(LastQuarkMotherId).pdgId());
1066  bool ambiguityResolved = true;
1067  // If last quark has inconsistent flavour with its mother, setting the hadron flavour to gluon
1068  if ((hadMothers.at(LastQuarkId).pdgId() * hadMothers.at(LastQuarkMotherId).pdgId() < 0 &&
1069  !isNeutralPdg(hadMothers.at(LastQuarkMotherId).pdgId())) ||
1070  // If particle not coming from the Top weak decay has Top flavour
1071  (std::abs(hadronFlavour.at(hadId)) == 6 && isFromTopWeakDecay.at(hadId) == 0)) {
1072  if ((int)LastQuarkIds.at(hadId).size() > lastQuarkIndex + 1)
1073  fixExtraSameFlavours(hadId,
1074  hadIndices,
1075  hadMothers,
1076  hadMothersIndices,
1077  isFromTopWeakDecay,
1078  LastQuarkIds,
1079  LastQuarkMotherIds,
1080  lastQuarkIndices,
1081  hadronFlavour,
1082  checkedHadronIds,
1083  lastQuarkIndex + 1);
1084  else
1085  hadronFlavour.at(hadId) = qmFlav * 21;
1086  return true;
1087  }
1088 
1089  int nSameFlavourHadrons = 0;
1090  // Looping over all previous hadrons
1091  for (unsigned int iHad = 0; iHad < hadronFlavour.size(); iHad++) {
1092  if (iHad == hadId)
1093  continue;
1094  int theLastQuarkIndex = lastQuarkIndices.at(iHad);
1095  if (theLastQuarkIndex < 0)
1096  continue;
1097  if ((int)LastQuarkMotherIds.at(iHad).size() <= theLastQuarkIndex)
1098  continue;
1099  int theLastQuarkMotherId = LastQuarkMotherIds.at(iHad).at(theLastQuarkIndex);
1100  int theHadFlavour = hadronFlavour.at(iHad);
1101  // Skipping hadrons with different flavour
1102  if (theHadFlavour == 0 || std::abs(theHadFlavour) == 21)
1103  continue;
1104  if (theHadFlavour != hadFlavour || theLastQuarkMotherId != LastQuarkMotherId)
1105  continue;
1106  ambiguityResolved = false;
1107  nSameFlavourHadrons++;
1108 
1109  // Checking other b-quark mother candidates of this hadron
1110  if ((int)LastQuarkIds.at(hadId).size() > lastQuarkIndex + 1) {
1111  if (fixExtraSameFlavours(hadId,
1112  hadIndices,
1113  hadMothers,
1114  hadMothersIndices,
1115  isFromTopWeakDecay,
1116  LastQuarkIds,
1117  LastQuarkMotherIds,
1118  lastQuarkIndices,
1119  hadronFlavour,
1120  checkedHadronIds,
1121  lastQuarkIndex + 1)) {
1122  ambiguityResolved = true;
1123  break;
1124  }
1125  } else
1126  // Checking other b-quark mother candidates of the particular previous hadron
1127  if ((int)LastQuarkIds.at(iHad).size() > theLastQuarkIndex + 1) {
1128  if (fixExtraSameFlavours(iHad,
1129  hadIndices,
1130  hadMothers,
1131  hadMothersIndices,
1132  isFromTopWeakDecay,
1133  LastQuarkIds,
1134  LastQuarkMotherIds,
1135  lastQuarkIndices,
1136  hadronFlavour,
1137  checkedHadronIds,
1138  theLastQuarkIndex + 1)) {
1139  ambiguityResolved = true;
1140  break;
1141  };
1142  }
1143 
1144  } // End of loop over all previous hadrons
1145 
1146  checkedHadronIds.erase(hadId); // Removing the hadron from the list of checked hadrons
1147  if (nSameFlavourHadrons > 0 && !ambiguityResolved) {
1148  hadronFlavour.at(hadId) = qmFlav * 21;
1149  return true;
1150  }
1151  lastQuarkIndices.at(hadId) = lastQuarkIndex;
1152  hadronFlavour.at(hadId) = hadFlavour;
1153  return true;
1154 }
1155 
1156 //define this as a plug-in
reco::Candidate::daughter
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode)
edm::StreamID
Definition: StreamID.h:30
GenHFHadronMatcher::putMotherIndex
bool putMotherIndex(std::vector< std::vector< int >> &hadMothersIndices, int partIndex, int mothIndex) const
puts mother index to the list of mothers of particle, if it isn't there already
Definition: GenHFHadronMatcher.cc:826
GenHFHadronMatcher::bHadronIdToken_
const edm::EDPutTokenT< std::vector< int > > bHadronIdToken_
Definition: GenHFHadronMatcher.cc:134
GenHFHadronMatcher_cff.flavour
flavour
Definition: GenHFHadronMatcher_cff.py:8
GenHFHadronMatcher::GenHFHadronMatcher
GenHFHadronMatcher(const edm::ParameterSet &)
Definition: GenHFHadronMatcher.cc:169
mps_fire.i
i
Definition: mps_fire.py:428
GenHFHadronMatcher::jetFlavourInfosToken_
const edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > jetFlavourInfosToken_
Definition: GenHFHadronMatcher.cc:119
MessageLogger.h
genParticles2HepMC_cfi.genParticles
genParticles
Definition: genParticles2HepMC_cfi.py:4
GenHFHadronMatcher::leptonIndexToken_
const edm::EDPutTokenT< std::vector< int > > leptonIndexToken_
Definition: GenHFHadronMatcher.cc:130
ESHandle.h
jets_cff.hadronFlavour
hadronFlavour
Definition: jets_cff.py:587
GenHFHadronMatcher::flavourSign
int flavourSign(const int pdgId) const
Sign of the flavour (matter/antimatter)
Definition: GenHFHadronMatcher.cc:674
reco::GenParticle
Definition: GenParticle.h:21
mps_update.status
status
Definition: mps_update.py:69
GenHFHadronMatcher::idInList
int idInList(std::vector< const reco::Candidate * > particleList, const reco::Candidate *particle) const
Check if the cpecified particle is already in the list of particles.
Definition: GenHFHadronMatcher.cc:577
edm::EDGetTokenT< reco::GenParticleCollection >
JetFlavourInfoMatching.h
reco::CompositeRefCandidateT::mother
const Candidate * mother(size_type=0) const override
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode)
edm
HLT enums.
Definition: AlignableModifier.h:19
GenHFHadronMatcher::flavourToken_
const edm::EDPutTokenT< std::vector< int > > flavourToken_
Definition: GenHFHadronMatcher.cc:128
edm::EDPutTokenT
Definition: EDPutToken.h:33
GenHFHadronMatcher::noBBbarResonances_
const bool noBBbarResonances_
Definition: GenHFHadronMatcher.cc:121
edm::RefVector::begin
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
reco::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
Definition: GenParticleFwd.h:13
GenHFHadronMatcher::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: GenHFHadronMatcher.cc:231
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
Jet.h
GenHFHadronMatcher::fixExtraSameFlavours
bool fixExtraSameFlavours(const unsigned int hadId, const std::vector< int > &hadIndices, const std::vector< reco::GenParticle > &hadMothers, const std::vector< std::vector< int >> &hadMothersIndices, const std::vector< int > &isFromTopWeakDecay, const std::vector< std::vector< int >> &LastQuarkIds, const std::vector< std::vector< int >> &LastQuarkMotherIds, std::vector< int > &lastQuarkIndices, std::vector< int > &hadronFlavour, std::set< int > &checkedHadronIds, const int lastQuarkIndex) const
Definition: GenHFHadronMatcher.cc:1043
GenHFHadronMatcher::isHadronPdgId
bool isHadronPdgId(const int flavour, const int pdgId) const
Check the pdgId if it represents a hadron of particular flavour.
Definition: GenHFHadronMatcher.cc:614
edm::RefVector< GenParticleCollection >
GenHFHadronMatcher::plusMothersToken_
const edm::EDPutTokenT< std::vector< reco::GenParticle > > plusMothersToken_
Definition: GenHFHadronMatcher.cc:125
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
GenHFHadronMatcher::plusMothersIndicesToken_
const edm::EDPutTokenT< std::vector< std::vector< int > > > plusMothersIndicesToken_
Definition: GenHFHadronMatcher.cc:126
GenHFHadronMatcher::genParticlesToken_
const edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken_
Definition: GenHFHadronMatcher.cc:118
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
reco::Candidate::mother
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
edm::Handle< reco::GenParticleCollection >
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
GenParticle.h
GenHFHadronMatcher::jetIndexToken_
const edm::EDPutTokenT< std::vector< int > > jetIndexToken_
Definition: GenHFHadronMatcher.cc:129
MakerMacros.h
edm::RefVector::end
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
reco::Candidate::numberOfMothers
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
GenHFHadronMatcher::flavourStr_
const std::string flavourStr_
Definition: GenHFHadronMatcher.cc:124
GenHFHadronMatcher::isMesonPdgId
bool isMesonPdgId(const int flavour, const int pdgId) const
Check the pdgId if it represents a meson of particular flavour.
Definition: GenHFHadronMatcher.cc:629
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
reco::Candidate::numberOfDaughters
virtual size_type numberOfDaughters() const =0
number of daughters
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
GenHFHadronMatcher::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
description of the run-time parameters
Definition: GenHFHadronMatcher.cc:212
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
dqmdumpme.k
k
Definition: dqmdumpme.py:60
edm::Event::emplace
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&... args)
puts a new product
Definition: Event.h:425
reco::JetFlavourInfo
Class storing the jet flavour information.
Definition: JetFlavourInfo.h:18
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::JetFlavourInfo::getcHadrons
const GenParticleRefVector & getcHadrons() const
Return a vector of GenParticleRef's to c hadrons clustered inside the jet.
Definition: JetFlavourInfo.h:39
reco::JetFlavourInfo::getbHadrons
const GenParticleRefVector & getbHadrons() const
Return a vector of GenParticleRef's to b hadrons clustered inside the jet.
Definition: JetFlavourInfo.h:37
reco::GenParticleRefVector
edm::RefVector< GenParticleCollection > GenParticleRefVector
vector of reference to GenParticle in the same collection
Definition: GenParticleFwd.h:25
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
deltaR.h
EDPutToken.h
reco::LeafCandidate::pdgId
int pdgId() const final
PDG identifier.
Definition: LeafCandidate.h:176
reco::JetFlavourInfoMatchingCollection
Definition: JetFlavourInfoMatching.h:15
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
GenHFHadronMatcher::~GenHFHadronMatcher
~GenHFHadronMatcher() override
Definition: GenHFHadronMatcher.cc:205
GenHFHadronMatcher::hasHadronDaughter
bool hasHadronDaughter(const int flavour, const reco::Candidate *thisParticle) const
Check if the particle has bHadron among daughters.
Definition: GenHFHadronMatcher.cc:694
GenHFHadronMatcher::leptonHadronIndexToken_
const edm::EDPutTokenT< std::vector< int > > leptonHadronIndexToken_
Definition: GenHFHadronMatcher.cc:131
createfilelist.int
int
Definition: createfilelist.py:10
value
Definition: value.py:1
GenHFHadronMatcher::isNeutralPdg
bool isNeutralPdg(int pdgId) const
Check whether a given pdgId represents neutral particle.
Definition: GenHFHadronMatcher.cc:1020
edm::AssociationVector::const_iterator
transient_vector_type::const_iterator const_iterator
Definition: AssociationVector.h:106
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
GenHFHadronMatcher::flavour_
const int flavour_
Definition: GenHFHadronMatcher.cc:120
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
reco::Candidate::pdgId
virtual int pdgId() const =0
PDG identifier.
GenHFHadronMatcher::checkForLoop
bool checkForLoop(std::vector< const reco::Candidate * > &particleChain, const reco::Candidate *particle) const
GenHFHadronMatcher::findHadronJets
std::vector< int > findHadronJets(const reco::GenParticleCollection *genParticles, const reco::JetFlavourInfoMatchingCollection *jetFlavourInfos, std::vector< int > &hadIndex, std::vector< reco::GenParticle > &hadMothersGenPart, std::vector< std::vector< int >> &hadMothersIndices, std::vector< int > &hadLeptonIndex, std::vector< int > &hadLeptonHadIndex, std::vector< int > &hadLeptonViaTau, std::vector< int > &hadFlavour, std::vector< int > &hadFromTopWeakDecay, std::vector< int > &hadBHadronId) const
identify the jets that contain b-hadrons
Definition: GenHFHadronMatcher.cc:299
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
GenHFHadronMatcher::fromTopWeakDecayToken_
const edm::EDPutTokenT< std::vector< int > > fromTopWeakDecayToken_
Definition: GenHFHadronMatcher.cc:133
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
GenHFHadronMatcher::findInMothers
int findInMothers(int idx, std::vector< int > &mothChains, const std::vector< std::vector< int >> &hadMothersIndices, const std::vector< reco::GenParticle > &hadMothers, int status, int pdgId, bool pdgAbs, int stopId, int firstLast, bool verbose) const
helper function to find indices of particles with particular pdgId and status from the list of mother...
Definition: GenHFHadronMatcher.cc:879
eostools.move
def move(src, dest)
Definition: eostools.py:511
GenHFHadronMatcher::leptonViaTauToken_
const edm::EDPutTokenT< std::vector< int > > leptonViaTauToken_
Definition: GenHFHadronMatcher.cc:132
Frameworkfwd.h
relativeConstraints.value
value
Definition: relativeConstraints.py:53
GenHFHadronMatcher::isBaryonPdgId
bool isBaryonPdgId(const int flavour, const int pdgId) const
Check the pdgId if it represents a baryon of particular flavour.
Definition: GenHFHadronMatcher.cc:655
edm::RefVectorIterator
Definition: EDProductfwd.h:33
GenHFHadronMatcher::onlyJetClusteredHadrons_
const bool onlyJetClusteredHadrons_
Definition: GenHFHadronMatcher.cc:122
GenHFHadronMatcher::analyzeMothers
int analyzeMothers(const reco::Candidate *thisParticle, int &topDaughterQId, int &topBarDaughterQId, std::vector< const reco::Candidate * > &hadMothers, std::vector< std::vector< int >> &hadMothersIndices, std::set< const reco::Candidate * > *analyzedParticles, const int prevPartIndex) const
do a recursive search for the mother particles until the b-quark is found or the absolute mother is f...
Definition: GenHFHadronMatcher.cc:725
GenHFHadronMatcher::isHadron
bool isHadron(const int flavour, const reco::Candidate *thisParticle) const
Check the pdgId of a given particle if it is a hadron.
Definition: GenHFHadronMatcher.cc:602
GenHFHadronMatcher::indexToken_
const edm::EDPutTokenT< std::vector< int > > indexToken_
Definition: GenHFHadronMatcher.cc:127
EventSetup.h
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
GenHFHadronMatcher
Finds the origin of each heavy flavour hadron and associated jets to it.
Definition: GenHFHadronMatcher.cc:53
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
GenJet.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GenHFHadronMatcher_cfi.jetFlavourInfos
jetFlavourInfos
Definition: GenHFHadronMatcher_cfi.py:5
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
ParameterSet.h
EDProducer.h
edm::Event
Definition: Event.h:73
GenHFHadronMatcher::getParticleName
std::string getParticleName(int id) const
edm::InputTag
Definition: InputTag.h:15