|
[Rivet-svn] r4230 - in trunk: . include/Rivet src/Coreblackhole at projects.hepforge.org blackhole at projects.hepforge.orgFri Mar 22 16:12:41 GMT 2013
Author: buckley Date: Fri Mar 22 16:12:41 2013 New Revision: 4230 Log: Adding Particle::fromDecay() method. Modified: trunk/ChangeLog trunk/include/Rivet/Particle.hh trunk/src/Core/Particle.cc Modified: trunk/ChangeLog ============================================================================== --- trunk/ChangeLog Fri Mar 22 16:11:47 2013 (r4229) +++ trunk/ChangeLog Fri Mar 22 16:12:41 2013 (r4230) @@ -1,3 +1,7 @@ +2013-03-22 Andy Buckley <andy.buckley at cern.ch> + + * Adding Particle::fromDecay() method. + 2013-03-09 Andy Buckley <andy.buckley at cern.ch> * Version bump to 2.0.0b1 in anticipation of first beta release. Modified: trunk/include/Rivet/Particle.hh ============================================================================== --- trunk/include/Rivet/Particle.hh Fri Mar 22 16:11:47 2013 (r4229) +++ trunk/include/Rivet/Particle.hh Fri Mar 22 16:12:41 2013 (r4230) @@ -79,21 +79,38 @@ return momentum().mass(); } + /// @todo Enable? // /// The charge of this Particle. // double charge() const { // return PID::charge(*this); // } - /// @todo Enable? // /// Three times the charge of this Particle (i.e. integer multiple of smallest quark charge). + /// @todo Enable? + // /// Three times the charge of this Particle (i.e. integer multiple of smallest quark charge). // int threeCharge() const { // return PID::threeCharge(*this); // } - /// Check whether a given PID is found in the GenParticle's ancestor list + /// + /// @note This question is valid in MC, but may not be answerable + /// experimentally -- use this function with care when replicating + /// experimental analyses! bool hasAncestor(PdgId pdg_id) const; + /// @brief Determine whether the particle is from a hadron or tau decay + /// + /// Specifically, walk up the ancestor chain until a status 2 hadron or + /// tau is found, if at all. + /// + /// @note This question is valid in MC, but may not be answerable + /// experimentally -- use this function with care when replicating + /// experimental analyses! + bool fromDecay() const; + + /// @todo Add methods like fromS/C/BHadron(), fromTau()? + private: Modified: trunk/src/Core/Particle.cc ============================================================================== --- trunk/src/Core/Particle.cc Fri Mar 22 16:11:47 2013 (r4229) +++ trunk/src/Core/Particle.cc Fri Mar 22 16:12:41 2013 (r4230) @@ -1,10 +1,12 @@ #include "Rivet/Particle.hh" #include "Rivet/RivetBoost.hh" +#include "Rivet/Tools/ParticleIdUtils.hh" namespace Rivet { bool Particle::hasAncestor(PdgId pdg_id) const { + /// @todo Shouldn't a const vertex be being returned? Ah, HepMC... GenVertex* prodVtx = genParticle()->production_vertex(); if (prodVtx == 0) return false; foreach (const GenParticle* ancestor, particles(prodVtx, HepMC::ancestors)) { @@ -12,6 +14,18 @@ } return false; } + + + bool Particle::fromDecay() const { + /// @todo Shouldn't a const vertex be being returned? Ah, HepMC... + GenVertex* prodVtx = genParticle()->production_vertex(); + if (prodVtx == NULL) return false; + foreach (const GenParticle* ancestor, particles(prodVtx, HepMC::ancestors)) { + const PdgId pid = ancestor->pdg_id(); + if (ancestor->status() == 2 && (PID::isHadron(pid) || abs(pid) == TAU)) return true; + } + return false; + } }
More information about the Rivet-svn mailing list |