CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
MCTruthHelper Namespace Reference

Functions

int absPdgId (const reco::GenParticle &p)
 
int absPdgId (const HepMC::GenParticle &p)
 
const reco::GenParticledaughter (const reco::GenParticle &p, unsigned int idau)
 
const HepMC::GenParticle * daughter (const HepMC::GenParticle &p, unsigned int idau)
 
template<typename P >
void fillGenStatusFlags (const P &p, reco::GenStatusFlags &statusFlags)
 
template<typename P >
const PfindDecayedMother (const P &p)
 
template<typename P >
const PfindDecayedMother (const P &p, int abspdgid)
 
template<typename P >
const PfirstCopy (const P &p)
 
template<typename P >
bool fromHardProcess (const P &p)
 
template<typename P >
bool fromHardProcessBeforeFSR (const P &p)
 
template<typename P >
bool fromHardProcessDecayed (const P &p)
 
template<typename P >
bool fromHardProcessFinalState (const P &p)
 
template<typename P >
const PhardProcessMotherCopy (const P &p)
 
template<typename P >
bool isDecayedLeptonHadron (const P &p)
 
template<typename P >
bool isDirectHadronDecayProduct (const P &p)
 
template<typename P >
bool isDirectHardProcessTauDecayProduct (const P &p)
 
template<typename P >
bool isDirectPromptTauDecayProduct (const P &p)
 
template<typename P >
bool isDirectTauDecayProduct (const P &p)
 
template<typename P >
bool isFirstCopy (const P &p)
 
template<typename P >
bool isHadron (const P &p)
 
template<typename P >
bool isHardProcess (const P &p)
 
template<typename P >
bool isHardProcessTauDecayProduct (const P &p)
 
template<typename P >
bool isLastCopy (const P &p)
 
template<typename P >
bool isLastCopyBeforeFSR (const P &p)
 
template<typename P >
bool isMuonDecayProduct (const P &p)
 
template<typename P >
bool isPrompt (const P &p)
 
template<typename P >
bool isPromptDecayed (const P &p)
 
template<typename P >
bool isPromptFinalState (const P &p)
 
template<typename P >
bool isPromptMuonDecayProduct (const P &p)
 
template<typename P >
bool isPromptTauDecayProduct (const P &p)
 
template<typename P >
bool isTauDecayProduct (const P &p)
 
template<typename P >
const PlastCopy (const P &p)
 
template<typename P >
const PlastCopyBeforeFSR (const P &p)
 
template<typename P >
const PlastDaughterCopyBeforeFSR (const P &p)
 
const reco::GenParticlemother (const reco::GenParticle &p, unsigned int imoth=0)
 
const HepMC::GenParticle * mother (const HepMC::GenParticle &p, unsigned int imoth=0)
 
template<typename P >
const PnextCopy (const P &p)
 
unsigned int numberOfDaughters (const reco::GenParticle &p)
 
unsigned int numberOfDaughters (const HepMC::GenParticle &p)
 
unsigned int numberOfMothers (const reco::GenParticle &p)
 
unsigned int numberOfMothers (const HepMC::GenParticle &p)
 
int pdgId (const reco::GenParticle &p)
 
int pdgId (const HepMC::GenParticle &p)
 
template<typename P >
const PpreviousCopy (const P &p)
 
template<typename P >
const PuniqueMother (const P &p)
 

Function Documentation

int MCTruthHelper::absPdgId ( const reco::GenParticle p)
int MCTruthHelper::absPdgId ( const HepMC::GenParticle &  p)

Definition at line 579 of file MCTruthHelper.h.

References funct::abs().

579  {
580  return std::abs(p.pdg_id());
581  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const reco::GenParticle * MCTruthHelper::daughter ( const reco::GenParticle p,
unsigned int  idau 
)

Definition at line 614 of file MCTruthHelper.h.

References reco::CompositeRefCandidateT< D >::daughter().

Referenced by TopDecaySubset::addDaughters(), FBaseSimEvent::addParticles(), TopDecaySubset::addRadiation(), AcceptanceHistoProducer::analyze(), EmbeddingKineReweightNtupleProducer::analyze(), JetTester_HeavyIons::analyze(), JetAnalyzer_HeavyIons::analyze(), MCEmbeddingValidationAnalyzer::analyze(), gen::Pythia6Gun::attachPy6DecaysToGenEvent(), EPOS::IO_EPOS::build_end_vertex(), QGTagger::calcVariables(), DatabasePDG::CheckImpossibleDecays(), compGenParticleP4afterRad(), tauImpactParameter::TrackHelixVertexFitter::computeMotherLorentzVectorPar(), TtDecayChannelSelector::countProngs(), DatabasePDG::DumpData(), reco::modules::JetFlavourIdentifier::fillLeptons(), TopDecaySubset::fillReferences(), JetMCTagUtils::genTauDecayMode(), getSelMuons(), PrimaryVertexAnalyzer::getSimPVs(), PrimaryVertexAnalyzer4PU::getSimPVs(), TtSemiLeptonicEvent::hadronicDecayTop(), reco::tau::xclean::CrossCleanPiZeros< PtrIter >::initialize(), reco::tau::xclean::CrossCleanPtrs< PtrIter >::initialize(), CandMatcherBase< C1, C2 >::initMaps(), lastCopyBeforeFSR(), lastDaughterCopyBeforeFSR(), TtSemiLeptonicEvent::leptonicDecayTop(), nextCopy(), reco::tau::RecoTauBuilderCombinatoricPlugin::operator()(), GenParticlesFromZsSelectorForMCEmbedding::produce(), reco::CentralityProducer::produce(), PFTau3ProngReco::produce(), gen::Cascade2Hadronizer::residualDecay(), gen::Pythia6Hadronizer::residualDecay(), CandCommonVertexFitterBase::set(), PFCandCommonVertexFitterBase::set(), CandKinematicVertexFitter::set(), TtDecayChannelSelector::tauDecay(), ParticleReplacerZtautau::testEvent(), TtFullLeptonicEvent::top(), TtFullHadronicEvent::top(), TtFullLeptonicEvent::topBar(), TtFullHadronicEvent::topBar(), gen::EvtGenInterface::update_particles(), gen::TauolappInterface::update_particles(), and TrajectoryManager::updateWithDaughters().

614  {
615  return static_cast<const reco::GenParticle*>(p.daughter(idau));
616  }
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
const HepMC::GenParticle * MCTruthHelper::daughter ( const HepMC::GenParticle &  p,
unsigned int  idau 
)

Definition at line 619 of file MCTruthHelper.h.

619  {
620  return *(p.end_vertex()->particles_out_const_begin() + idau);
621  }
template<typename P >
void MCTruthHelper::fillGenStatusFlags ( const P p,
reco::GenStatusFlags statusFlags 
)

Definition at line 625 of file MCTruthHelper.h.

References fromHardProcess(), fromHardProcessBeforeFSR(), isDecayedLeptonHadron(), isDirectHadronDecayProduct(), isDirectHardProcessTauDecayProduct(), isDirectPromptTauDecayProduct(), isDirectTauDecayProduct(), isFirstCopy(), isHardProcess(), isHardProcessTauDecayProduct(), isLastCopy(), isLastCopyBeforeFSR(), isPrompt(), isPromptTauDecayProduct(), isTauDecayProduct(), reco::GenStatusFlags::setFromHardProcess(), reco::GenStatusFlags::setFromHardProcessBeforeFSR(), reco::GenStatusFlags::setIsDecayedLeptonHadron(), reco::GenStatusFlags::setIsDirectHadronDecayProduct(), reco::GenStatusFlags::setIsDirectHardProcessTauDecayProduct(), reco::GenStatusFlags::setIsDirectPromptTauDecayProduct(), reco::GenStatusFlags::setIsDirectTauDecayProduct(), reco::GenStatusFlags::setIsFirstCopy(), reco::GenStatusFlags::setIsHardProcess(), reco::GenStatusFlags::setIsHardProcessTauDecayProduct(), reco::GenStatusFlags::setIsLastCopy(), reco::GenStatusFlags::setIsLastCopyBeforeFSR(), reco::GenStatusFlags::setIsPrompt(), reco::GenStatusFlags::setIsPromptTauDecayProduct(), and reco::GenStatusFlags::setIsTauDecayProduct().

Referenced by GenParticleProducer::convertParticle().

625  {
626  statusFlags.setIsPrompt(isPrompt(p));
633  statusFlags.setIsHardProcess(isHardProcess(p));
634  statusFlags.setFromHardProcess(fromHardProcess(p));
638  statusFlags.setIsFirstCopy(isFirstCopy(p));
639  statusFlags.setIsLastCopy(isLastCopy(p));
641  }
bool isDirectTauDecayProduct(const P &p)
bool isTauDecayProduct(const P &p)
bool isPrompt(const P &p)
void setIsLastCopyBeforeFSR(bool b)
void setIsPrompt(bool b)
bool isDirectHadronDecayProduct(const P &p)
void setIsTauDecayProduct(bool b)
void setIsDirectPromptTauDecayProduct(bool b)
void setIsDirectHadronDecayProduct(bool b)
bool isPromptTauDecayProduct(const P &p)
bool fromHardProcess(const P &p)
void setIsDirectHardProcessTauDecayProduct(bool b)
void setIsHardProcess(bool b)
bool isHardProcessTauDecayProduct(const P &p)
bool isLastCopyBeforeFSR(const P &p)
void setIsHardProcessTauDecayProduct(bool b)
void setFromHardProcess(bool b)
bool isDirectHardProcessTauDecayProduct(const P &p)
void setIsPromptTauDecayProduct(bool b)
void setIsDecayedLeptonHadron(bool b)
bool isFirstCopy(const P &p)
void setIsFirstCopy(bool b)
bool isDirectPromptTauDecayProduct(const P &p)
bool fromHardProcessBeforeFSR(const P &p)
bool isLastCopy(const P &p)
void setIsDirectTauDecayProduct(bool b)
void setFromHardProcessBeforeFSR(bool b)
bool isDecayedLeptonHadron(const P &p)
void setIsLastCopy(bool b)
bool isHardProcess(const P &p)
template<typename P >
const P * MCTruthHelper::findDecayedMother ( const P p)

Definition at line 545 of file MCTruthHelper.h.

References isDecayedLeptonHadron(), mother(), and P.

Referenced by isDirectHardProcessTauDecayProduct(), isDirectPromptTauDecayProduct(), isDirectTauDecayProduct(), isHardProcessTauDecayProduct(), isMuonDecayProduct(), isPrompt(), isPromptMuonDecayProduct(), isPromptTauDecayProduct(), and isTauDecayProduct().

545  {
546  const P *mo = mother(p);
547  while (mo && !isDecayedLeptonHadron(*mo)) {
548  mo = mother(*mo);
549  }
550  return mo;
551  }
const reco::GenParticle * mother(const reco::GenParticle &p, unsigned int imoth=0)
#define P
bool isDecayedLeptonHadron(const P &p)
template<typename P >
const P * MCTruthHelper::findDecayedMother ( const P p,
int  abspdgid 
)

Definition at line 555 of file MCTruthHelper.h.

References absPdgId(), isDecayedLeptonHadron(), mother(), and P.

555  {
556  const P *mo = mother(p);
557  while (mo && (absPdgId(*mo)!=abspdgid || !isDecayedLeptonHadron(*mo)) ) {
558  mo = mother(*mo);
559  }
560  return mo;
561  }
int absPdgId(const reco::GenParticle &p)
const reco::GenParticle * mother(const reco::GenParticle &p, unsigned int imoth=0)
#define P
bool isDecayedLeptonHadron(const P &p)
template<typename P >
const P * MCTruthHelper::firstCopy ( const P p)

Definition at line 420 of file MCTruthHelper.h.

References P, AlCaHLTBitMon_ParallelJobs::p, and previousCopy().

Referenced by isFirstCopy(), isHardProcess(), and lastCopyBeforeFSR().

420  {
421  const P *pcopy = &p;
422  while (previousCopy(*pcopy)) {
423  pcopy = previousCopy(*pcopy);
424  }
425  return pcopy;
426  }
#define P
const P * previousCopy(const P &p)
template<typename P >
bool MCTruthHelper::fromHardProcess ( const P p)
template<typename P >
bool MCTruthHelper::fromHardProcessBeforeFSR ( const P p)

Definition at line 364 of file MCTruthHelper.h.

References hardProcessMotherCopy(), isLastCopy(), lastDaughterCopyBeforeFSR(), P, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by fillGenStatusFlags().

364  {
365  //pythia 6 documentation line roughly corresponds to this condition
366  if (p.status()==3) return true;
367 
368  //check hard process mother properties
369  const P *hpc = hardProcessMotherCopy(p);
370  if (!hpc) return false;
371 
372  //for incoming partons in pythia8, more useful information is not
373  //easily available, so take only the incoming parton itself
374  if (hpc->status()==21 && (&p)==hpc) return true;
375 
376  //for intermediate particles in pythia 8, just take the last copy
377  if (hpc->status()==22 && isLastCopy(p)) return true;
378 
379  //for outgoing particles in pythia 8, explicitly find the last copy
380  //before FSR starting from the hardProcess particle, and take only
381  //this one
382  if ( (hpc->status()==23 || hpc->status()==1) && (&p)==lastDaughterCopyBeforeFSR(*hpc) ) return true;
383 
384 
385  //didn't satisfy any of the conditions
386  return false;
387 
388  }
#define P
const P * hardProcessMotherCopy(const P &p)
bool isLastCopy(const P &p)
const P * lastDaughterCopyBeforeFSR(const P &p)
template<typename P >
bool MCTruthHelper::fromHardProcessDecayed ( const P p)

Definition at line 344 of file MCTruthHelper.h.

References fromHardProcess(), and isDecayedLeptonHadron().

Referenced by isHardProcessTauDecayProduct().

344  {
346  }
bool fromHardProcess(const P &p)
bool isDecayedLeptonHadron(const P &p)
template<typename P >
bool MCTruthHelper::fromHardProcessFinalState ( const P p)

Definition at line 338 of file MCTruthHelper.h.

References fromHardProcess().

338  {
339  return p.status()==1 && fromHardProcess(p);
340  }
bool fromHardProcess(const P &p)
template<typename P >
const P * MCTruthHelper::hardProcessMotherCopy ( const P p)

Definition at line 500 of file MCTruthHelper.h.

References isHardProcess(), P, AlCaHLTBitMon_ParallelJobs::p, and previousCopy().

Referenced by fromHardProcess(), and fromHardProcessBeforeFSR().

500  {
501  //is particle itself is hard process particle
502  if (isHardProcess(p)) return &p;
503 
504  //check if any other copies are hard process particles
505  const P *pcopy = &p;
506  while (previousCopy(*pcopy)) {
507  pcopy = previousCopy(*pcopy);
508  if (isHardProcess(*pcopy)) return pcopy;
509  }
510  return 0;
511  }
#define P
const P * previousCopy(const P &p)
bool isHardProcess(const P &p)
template<typename P >
bool MCTruthHelper::isDecayedLeptonHadron ( const P p)

Definition at line 235 of file MCTruthHelper.h.

References absPdgId(), isHadron(), and isLastCopy().

Referenced by fillGenStatusFlags(), findDecayedMother(), fromHardProcessDecayed(), isDirectHadronDecayProduct(), and isPromptDecayed().

235  {
236  return p.status()==2 && (isHadron(p) || absPdgId(p)==13 || absPdgId(p)==15) && isLastCopy(p);
237  }
int absPdgId(const reco::GenParticle &p)
bool isHadron(const P &p)
bool isLastCopy(const P &p)
template<typename P >
bool MCTruthHelper::isDirectHadronDecayProduct ( const P p)

Definition at line 288 of file MCTruthHelper.h.

References isDecayedLeptonHadron(), isHadron(), P, and uniqueMother().

Referenced by fillGenStatusFlags().

288  {
289  const P *um = uniqueMother(p);
290  return um && isHadron(*um) && isDecayedLeptonHadron(*um);
291  }
#define P
bool isHadron(const P &p)
const P * uniqueMother(const P &p)
bool isDecayedLeptonHadron(const P &p)
template<typename P >
bool MCTruthHelper::isDirectHardProcessTauDecayProduct ( const P p)

Definition at line 357 of file MCTruthHelper.h.

References findDecayedMother(), fromHardProcess(), P, and metsig::tau.

Referenced by fillGenStatusFlags().

357  {
358  const P *tau = findDecayedMother(p,15);
359  const P *dm = findDecayedMother(p);
360  return tau && tau==dm && fromHardProcess(*tau);
361  }
#define P
bool fromHardProcess(const P &p)
const P * findDecayedMother(const P &p)
template<typename P >
bool MCTruthHelper::isDirectPromptTauDecayProduct ( const P p)

Definition at line 267 of file MCTruthHelper.h.

References findDecayedMother(), isPrompt(), P, and metsig::tau.

Referenced by fillGenStatusFlags().

267  {
268  const P *tau = findDecayedMother(p,15);
269  const P *dm = findDecayedMother(p);
270  return tau && tau==dm && isPrompt(*tau);
271  }
#define P
bool isPrompt(const P &p)
const P * findDecayedMother(const P &p)
template<typename P >
bool MCTruthHelper::isDirectTauDecayProduct ( const P p)

Definition at line 259 of file MCTruthHelper.h.

References findDecayedMother(), P, and metsig::tau.

Referenced by fillGenStatusFlags().

259  {
260  const P *tau = findDecayedMother(p,15);
261  const P *dm = findDecayedMother(p);
262  return tau && tau==dm;
263  }
#define P
const P * findDecayedMother(const P &p)
template<typename P >
bool MCTruthHelper::isFirstCopy ( const P p)

Definition at line 392 of file MCTruthHelper.h.

References firstCopy().

Referenced by fillGenStatusFlags().

392  {
393  return &p == firstCopy(p);
394  }
const P * firstCopy(const P &p)
template<typename P >
bool MCTruthHelper::isHadron ( const P p)
template<typename P >
bool MCTruthHelper::isHardProcess ( const P p)

Definition at line 302 of file MCTruthHelper.h.

References firstCopy(), mother(), nextCopy(), and P.

Referenced by fillGenStatusFlags(), and hardProcessMotherCopy().

302  {
303 
304  //status 3 in pythia6 means hard process;
305  if (p.status()==3) return true;
306 
307  //hard process codes for pythia8 are 21-29 inclusive (currently 21,22,23,24 are used)
308  if (p.status()>20 && p.status()<30) return true;
309 
310  //if this is a final state or decayed particle,
311  //check if direct mother is a resonance decay in pythia8 but exclude FSR branchings
312  //(In pythia8 if a resonance decay product did not undergo any further branchings
313  //it will be directly stored as status 1 or 2 without any status 23 copy)
314  if (p.status()==1 || p.status()==2) {
315  const P *um = mother(p);
316  if (um) {
317  bool fromResonance = firstCopy(*um)->status()==22;
318 
319  const P *umNext = nextCopy(*um);
320  bool fsrBranching = umNext && umNext->status()>50 && umNext->status()<60;
321 
322  if (fromResonance && !fsrBranching) return true;
323  }
324  }
325 
326  return false;
327 
328  }
const reco::GenParticle * mother(const reco::GenParticle &p, unsigned int imoth=0)
#define P
const P * firstCopy(const P &p)
const P * nextCopy(const P &p)
template<typename P >
bool MCTruthHelper::isHardProcessTauDecayProduct ( const P p)

Definition at line 350 of file MCTruthHelper.h.

References findDecayedMother(), fromHardProcessDecayed(), P, and metsig::tau.

Referenced by fillGenStatusFlags().

350  {
351  const P *tau = findDecayedMother(p,15);
352  return tau && fromHardProcessDecayed(*tau);
353  }
bool fromHardProcessDecayed(const P &p)
#define P
const P * findDecayedMother(const P &p)
template<typename P >
bool MCTruthHelper::isLastCopy ( const P p)

Definition at line 398 of file MCTruthHelper.h.

References lastCopy().

Referenced by fillGenStatusFlags(), fromHardProcessBeforeFSR(), and isDecayedLeptonHadron().

398  {
399  return &p == lastCopy(p);
400  }
const P * lastCopy(const P &p)
template<typename P >
bool MCTruthHelper::isLastCopyBeforeFSR ( const P p)

Definition at line 404 of file MCTruthHelper.h.

References lastCopyBeforeFSR().

Referenced by fillGenStatusFlags().

404  {
405  return &p == lastCopyBeforeFSR(p);
406  }
const P * lastCopyBeforeFSR(const P &p)
template<typename P >
bool MCTruthHelper::isMuonDecayProduct ( const P p)

Definition at line 275 of file MCTruthHelper.h.

References findDecayedMother().

275  {
276  return findDecayedMother(p,13) != 0;
277  }
const P * findDecayedMother(const P &p)
template<typename P >
bool MCTruthHelper::isPrompt ( const P p)

Definition at line 221 of file MCTruthHelper.h.

References findDecayedMother().

Referenced by fillGenStatusFlags(), PythiaFilterGammaGamma::filter(), isDirectPromptTauDecayProduct(), isPromptDecayed(), isPromptFinalState(), isPromptMuonDecayProduct(), and isPromptTauDecayProduct().

221  {
222  //particle from hadron/muon/tau decay -> not prompt
223  //checking all the way up the chain treats properly the radiated photon
224  //case as well
225  return findDecayedMother(p) == 0;
226  }
const P * findDecayedMother(const P &p)
template<typename P >
bool MCTruthHelper::isPromptDecayed ( const P p)

Definition at line 240 of file MCTruthHelper.h.

References isDecayedLeptonHadron(), and isPrompt().

240  {
241  return isDecayedLeptonHadron(p) && isPrompt(p);
242  }
bool isPrompt(const P &p)
bool isDecayedLeptonHadron(const P &p)
template<typename P >
bool MCTruthHelper::isPromptFinalState ( const P p)

Definition at line 230 of file MCTruthHelper.h.

References isPrompt().

230  {
231  return p.status()==1 && isPrompt(p);
232  }
bool isPrompt(const P &p)
template<typename P >
bool MCTruthHelper::isPromptMuonDecayProduct ( const P p)

Definition at line 281 of file MCTruthHelper.h.

References findDecayedMother(), isPrompt(), RPCpg::mu, and P.

281  {
282  const P *mu = findDecayedMother(p,13);
283  return mu && isPrompt(*mu);
284  }
#define P
bool isPrompt(const P &p)
const P * findDecayedMother(const P &p)
const int mu
Definition: Constants.h:22
template<typename P >
bool MCTruthHelper::isPromptTauDecayProduct ( const P p)

Definition at line 252 of file MCTruthHelper.h.

References findDecayedMother(), isPrompt(), P, and metsig::tau.

Referenced by fillGenStatusFlags().

252  {
253  const P *tau = findDecayedMother(p,15);
254  return tau && isPrompt(*tau);
255  }
#define P
bool isPrompt(const P &p)
const P * findDecayedMother(const P &p)
template<typename P >
bool MCTruthHelper::isTauDecayProduct ( const P p)

Definition at line 246 of file MCTruthHelper.h.

References findDecayedMother().

Referenced by fillGenStatusFlags().

246  {
247  return findDecayedMother(p,15) != 0;
248  }
const P * findDecayedMother(const P &p)
template<typename P >
const P * MCTruthHelper::lastCopy ( const P p)

Definition at line 430 of file MCTruthHelper.h.

References nextCopy(), P, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by isLastCopy().

430  {
431  const P *pcopy = &p;
432  while (nextCopy(*pcopy)) {
433  pcopy = nextCopy(*pcopy);
434  }
435  return pcopy;
436  }
#define P
const P * nextCopy(const P &p)
template<typename P >
const P * MCTruthHelper::lastCopyBeforeFSR ( const P p)

Definition at line 440 of file MCTruthHelper.h.

References daughter(), firstCopy(), numberOfDaughters(), P, and pdgId().

Referenced by isLastCopyBeforeFSR().

440  {
441  //start with first copy and then walk down until there is FSR
442  const P *pcopy = firstCopy(p);
443  bool hasDaughterCopy = true;
444  while (hasDaughterCopy) {
445  hasDaughterCopy = false;
446  const unsigned int ndau = numberOfDaughters(*pcopy);
447  //look for FSR
448  for (unsigned int idau = 0; idau<ndau; ++idau) {
449  const P *dau = daughter(*pcopy,idau);
450  if (pdgId(*dau)==21 || pdgId(*dau)==22) {
451  //has fsr (or else decayed and is the last copy by construction)
452  return pcopy;
453  }
454  }
455  //look for daughter copy
456  for (unsigned int idau = 0; idau<ndau; ++idau) {
457  const P *dau = daughter(*pcopy,idau);
458  if (pdgId(*dau)==pdgId(p)) {
459  pcopy = dau;
460  hasDaughterCopy = true;
461  break;
462  }
463  }
464  }
465  return pcopy;
466  }
unsigned int numberOfDaughters(const reco::GenParticle &p)
#define P
const reco::GenParticle * daughter(const reco::GenParticle &p, unsigned int idau)
const P * firstCopy(const P &p)
template<typename P >
const P * MCTruthHelper::lastDaughterCopyBeforeFSR ( const P p)

Definition at line 470 of file MCTruthHelper.h.

References daughter(), numberOfDaughters(), P, AlCaHLTBitMon_ParallelJobs::p, and pdgId().

Referenced by fromHardProcessBeforeFSR().

470  {
471  //start with this particle and then walk down until there is FSR
472  const P *pcopy = &p;
473  bool hasDaughterCopy = true;
474  while (hasDaughterCopy) {
475  hasDaughterCopy = false;
476  const unsigned int ndau = numberOfDaughters(*pcopy);
477  //look for FSR
478  for (unsigned int idau = 0; idau<ndau; ++idau) {
479  const P *dau = daughter(*pcopy,idau);
480  if (pdgId(*dau)==21 || pdgId(*dau)==22) {
481  //has fsr (or else decayed and is the last copy by construction)
482  return pcopy;
483  }
484  }
485  //look for daughter copy
486  for (unsigned int idau = 0; idau<ndau; ++idau) {
487  const P *dau = daughter(*pcopy,idau);
488  if (pdgId(*dau)==pdgId(p)) {
489  pcopy = dau;
490  hasDaughterCopy = true;
491  break;
492  }
493  }
494  }
495  return pcopy;
496  }
unsigned int numberOfDaughters(const reco::GenParticle &p)
#define P
const reco::GenParticle * daughter(const reco::GenParticle &p, unsigned int idau)
const reco::GenParticle * MCTruthHelper::mother ( const reco::GenParticle p,
unsigned int  imoth = 0 
)

Definition at line 594 of file MCTruthHelper.h.

References reco::CompositeRefCandidateT< D >::mother().

Referenced by FBaseSimEvent::addParticles(), AlignmentParameterStore::alignableFromAlignableDet(), ZLONLOHistogrammer::analyze(), EWKSystUnc::analyze(), zPdfUnc::analyze(), HLTTauRelvalQTester::analyze(), ZMuPtScaleAnalyzer::analyze(), ElectronMcSignalValidator::analyze(), TkAlCaRecoMonitor::analyze(), ElectronSeedAnalyzer::analyze(), SimplePhotonAnalyzer::analyze(), GsfElectronMCAnalyzer::analyze(), TauValidation::analyze(), PhotonValidator::analyze(), GenHFHadronMatcher::analyzeMothers(), HepMC::Pythia8ToHepMCA::append_event(), EPOS::IO_EPOS::build_production_vertex(), PedeSteerer::buildNoHierarchyCollection(), TopGenEvent::candidate(), AlignmentTwoBodyDecayTrackSelector::checkMass(), AlignmentTwoBodyDecayTrackSelector::checkMETMass(), CheckOverlap::checkPV(), KillSecondariesStackingAction::ClassifyNewTrack(), StackingAction::ClassifyNewTrack(), tauImpactParameter::TrackHelixVertexFitter::computeMotherLorentzVectorPar(), DDHCalBarrelAlgo::constructInsideLayers(), DDHCalBarrelAlgo::constructMidLayer(), DDHCalBarrelAlgo::constructSideLayer(), TopGenEvent::daughterQuarkOfWPlus(), gen::TauolappInterface::decay(), DecayChannel::DecayChannel(), PrintGeomInfoAction::dumpPV(), PrintGeomMatInfo::dumpPV(), PrintSensitive::dumpTouch(), PrintGeomInfoAction::dumpTouch(), PrintGeomMatInfo::dumpTouch(), DDLinear::execute(), DDAngular::execute(), DDPixFwdDiskAlgo::execute(), DDTrackerLinearXY::execute(), DDTrackerLinear::execute(), DDTrackerZPosAlgo::execute(), DDTrackerXYZPosAlgo::execute(), DDPixBarLayerUpgradeAlgoCoverage::execute(), DDPixBarStackLinear::execute(), DDPixBarLayerUpgradeAlgo::execute(), DDPixBarStackLayerAlgo::execute(), DDPixBarStackLinearGap::execute(), DDPixBarStackTrigLayerAlgo::execute(), DDPixBarTPGStackLayerAlgo::execute(), DDPixBarLayerAlgo::execute(), DDHCalTBZposAlgo::execute(), DDTECCoolAlgo::execute(), DDTECOptoHybAlgo::execute(), DDTrackerAngularV1::execute(), DDTrackerPhiAlgo::execute(), DDTrackerPhiAltAlgo::execute(), DDHCalLinearXY::execute(), DDHCalFibreBundle::execute(), DDTECAxialCableAlgo::execute(), DDTECPhiAlgo::execute(), DDTECPhiAltAlgo::execute(), DDTIDAxialCableAlgo::execute(), DDTIDRingAlgo::execute(), DDTrackerAngular::execute(), DDPixFwdBlades::execute(), GenParticleProducer::fillDaughters(), MuScleFitPlotter::fillGen(), PythiaFilterGammaGamma::filter(), PythiaFilter::filter(), findDecayedMother(), MuScleFitUtils::findGenMuFromRes(), MuScleFitMuonSelector::findGenMuFromRes(), HiggsValidation::findHiggsDecayChannel(), MuScleFitUtils::findSimMuFromRes(), MuScleFitMuonSelector::findSimMuFromRes(), TauValidation::findTauList(), gen::TauolappInterface::FirstTauInChain(), gen::HijingHadronizer::get_particles(), gen::AMPTHadronizer::get_particles(), gen::HydjetHadronizer::get_particles(), gen::Hydjet2Hadronizer::get_particles(), MEChannel::getAncestor(), MEChannel::getListOfAncestors(), gen::TauolappInterface::GetMother(), TauValidation::GetMother(), HeavyFlavorValidation::getMotherId(), TauValidation::GetMothers(), PrimaryVertexAnalyzer::getSimPVs(), PrimaryVertexAnalyzer4PU::getSimPVs(), PseudoTopProducer::isFromHadron(), isHardProcess(), TtGenEvent::lepton(), TtGenEvent::leptonBar(), FSimEvent::load(), gen::TauolappInterface::MatchedLHESpinUp(), TtGenEvent::neutrino(), TtGenEvent::neutrinoBar(), TopGenEvent::numberOfBQuarks(), TopGenEvent::numberOfLeptons(), ParametersToParametersDerivatives::ParametersToParametersDerivatives(), previousCopy(), FBaseSimEvent::printMCTruth(), ISRGammaWeightProducer::produce(), GenParticles2HepMCConverter::produce(), pat::PATGenCandsFromSimTracksProducer::produce(), MuonTrajectoryUpdator::propagateState(), pf2pat::TopProjectorAlgo< Top, Bottom >::ptrToAncestor(), BtoCharmDecayVertexMerger::resolveBtoDchain(), tnp::TagProbePairMaker::run(), PedeSteerer::selectCoordinateAlis(), StGenEvent::singleLepton(), TtGenEvent::singleLepton(), StGenEvent::singleNeutrino(), TtGenEvent::singleNeutrino(), and uniqueMother().

594  {
595  return static_cast<const reco::GenParticle*>(p.mother(imoth));
596  }
virtual const Candidate * mother(size_type=0) const
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
const HepMC::GenParticle * MCTruthHelper::mother ( const HepMC::GenParticle &  p,
unsigned int  imoth = 0 
)

Definition at line 599 of file MCTruthHelper.h.

599  {
600  return p.production_vertex() && p.production_vertex()->particles_in_size() ? *(p.production_vertex()->particles_in_const_begin() + imoth) : 0;
601  }
template<typename P >
const P * MCTruthHelper::nextCopy ( const P p)

Definition at line 530 of file MCTruthHelper.h.

References daughter(), numberOfDaughters(), P, and pdgId().

Referenced by isHardProcess(), and lastCopy().

530  {
531 
532  const unsigned int ndau = numberOfDaughters(p);
533  for (unsigned int idau = 0; idau<ndau; ++idau) {
534  const P *dau = daughter(p,idau);
535  if (pdgId(*dau)==pdgId(p)) {
536  return dau;
537  }
538  }
539 
540  return 0;
541  }
unsigned int numberOfDaughters(const reco::GenParticle &p)
#define P
const reco::GenParticle * daughter(const reco::GenParticle &p, unsigned int idau)
unsigned int MCTruthHelper::numberOfDaughters ( const reco::GenParticle p)
unsigned int MCTruthHelper::numberOfDaughters ( const HepMC::GenParticle &  p)

Definition at line 609 of file MCTruthHelper.h.

609  {
610  return p.end_vertex() ? p.end_vertex()->particles_out_size() : 0;
611  }
unsigned int MCTruthHelper::numberOfMothers ( const reco::GenParticle p)

Definition at line 584 of file MCTruthHelper.h.

References reco::CompositeRefCandidateT< D >::numberOfMothers().

Referenced by GenParticleProducer::fillDaughters(), EcalGenEvtSelectorFrag::filter(), and previousCopy().

584  {
585  return p.numberOfMothers();
586  }
virtual size_t numberOfMothers() const
number of mothers
unsigned int MCTruthHelper::numberOfMothers ( const HepMC::GenParticle &  p)

Definition at line 589 of file MCTruthHelper.h.

589  {
590  return p.production_vertex() ? p.production_vertex()->particles_in_size() : 0;
591  }
int MCTruthHelper::pdgId ( const reco::GenParticle p)

Definition at line 564 of file MCTruthHelper.h.

References reco::LeafCandidate::pdgId().

Referenced by isHadron(), lastCopyBeforeFSR(), lastDaughterCopyBeforeFSR(), nextCopy(), previousCopy(), and uniqueMother().

564  {
565  return p.pdgId();
566  }
virtual int pdgId() const
PDG identifier.
int MCTruthHelper::pdgId ( const HepMC::GenParticle &  p)

Definition at line 569 of file MCTruthHelper.h.

569  {
570  return p.pdg_id();
571  }
template<typename P >
const P * MCTruthHelper::previousCopy ( const P p)

Definition at line 515 of file MCTruthHelper.h.

References mother(), numberOfMothers(), P, and pdgId().

Referenced by firstCopy(), and hardProcessMotherCopy().

515  {
516 
517  const unsigned int nmoth = numberOfMothers(p);
518  for (unsigned int imoth = 0; imoth<nmoth; ++imoth) {
519  const P *moth = mother(p,imoth);
520  if (pdgId(*moth)==pdgId(p)) {
521  return moth;
522  }
523  }
524 
525  return 0;
526  }
unsigned int numberOfMothers(const reco::GenParticle &p)
const reco::GenParticle * mother(const reco::GenParticle &p, unsigned int imoth=0)
#define P
template<typename P >
const P * MCTruthHelper::uniqueMother ( const P p)

Definition at line 410 of file MCTruthHelper.h.

References mother(), P, AlCaHLTBitMon_ParallelJobs::p, and pdgId().

Referenced by isDirectHadronDecayProduct().

410  {
411  const P *mo = &p;
412  while (mo && pdgId(*mo)==pdgId(p)) {
413  mo = mother(*mo);
414  }
415  return mo;
416  }
const reco::GenParticle * mother(const reco::GenParticle &p, unsigned int imoth=0)
#define P