[Rivet-svn] r4228 - in branches/2012-06-aidarivet: . include/Rivet src/Core

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Fri Mar 22 16:07:59 GMT 2013


Author: buckley
Date: Fri Mar 22 16:07:59 2013
New Revision: 4228

Log:
Adding Particle::fromDecay() method.

Modified:
   branches/2012-06-aidarivet/ChangeLog
   branches/2012-06-aidarivet/include/Rivet/Particle.hh
   branches/2012-06-aidarivet/src/Core/Particle.cc

Modified: branches/2012-06-aidarivet/ChangeLog
==============================================================================
--- branches/2012-06-aidarivet/ChangeLog	Mon Mar 18 14:49:01 2013	(r4227)
+++ branches/2012-06-aidarivet/ChangeLog	Fri Mar 22 16:07:59 2013	(r4228)
@@ -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>
 
 	* Fixing a symbol misnaming in ATLAS_2012_I1119557.

Modified: branches/2012-06-aidarivet/include/Rivet/Particle.hh
==============================================================================
--- branches/2012-06-aidarivet/include/Rivet/Particle.hh	Mon Mar 18 14:49:01 2013	(r4227)
+++ branches/2012-06-aidarivet/include/Rivet/Particle.hh	Fri Mar 22 16:07:59 2013	(r4228)
@@ -79,20 +79,38 @@
       return momentum().mass();
     }
 
+
+    /// @todo Re-enable
     // /// The charge of this Particle.
     // double charge() const {
     //   return PID::charge(*this);
     // }
 
+    /// @todo Re-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: branches/2012-06-aidarivet/src/Core/Particle.cc
==============================================================================
--- branches/2012-06-aidarivet/src/Core/Particle.cc	Mon Mar 18 14:49:01 2013	(r4227)
+++ branches/2012-06-aidarivet/src/Core/Particle.cc	Fri Mar 22 16:07:59 2013	(r4228)
@@ -1,17 +1,31 @@
 #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;
+    if (prodVtx == NULL) return false;
     foreach (const GenParticle* ancestor, particles(prodVtx, HepMC::ancestors)) {
       if (ancestor->pdg_id() == pdg_id) return true;
     }
     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