[Rivet-svn] r1641 - in trunk: . include/Rivet

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed Jun 24 17:26:38 BST 2009


Author: buckley
Date: Wed Jun 24 17:17:23 2009
New Revision: 1641

Log:
Adding RivetHepMC.hh, which defines container-type accessors to HepMC particles and vertices, making it possible to use Boost foreach and hence avoiding the usual huge boilerplate for-loops.

Added:
   trunk/include/Rivet/RivetHepMC.hh
Modified:
   trunk/ChangeLog
   trunk/include/Rivet/Makefile.am

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Tue Jun 23 15:57:15 2009	(r1640)
+++ trunk/ChangeLog	Wed Jun 24 17:17:23 2009	(r1641)
@@ -1,3 +1,9 @@
+2009-06-24  Andy Buckley  <andy at insectnation.org>
+
+	* Adding RivetHepMC.hh, which defines container-type accessors to
+	HepMC particles and vertices, making it possible to use Boost
+	foreach and hence avoiding the usual huge boilerplate for-loops.
+
 2009-06-11  Andy Buckley  <andy at insectnation.org>
 
 	* Adding --disable-pdfmanual option, to make the bootstrap a bit

Modified: trunk/include/Rivet/Makefile.am
==============================================================================
--- trunk/include/Rivet/Makefile.am	Tue Jun 23 15:57:15 2009	(r1640)
+++ trunk/include/Rivet/Makefile.am	Wed Jun 24 17:17:23 2009	(r1641)
@@ -6,16 +6,16 @@
 
 ## Rivet interface
 nobase_pkginclude_HEADERS += \
-  Rivet.hh \
-  RivetBoost.hh       Exceptions.hh       \
+  Rivet.hh            Exceptions.hh       \
+  RivetBoost.hh       RivetHepMC.hh       \
   Constraints.hh      BeamConstraint.hh   \
   Event.hh            Event.fhh           \
-  ParticleBase.hh \
+  ParticleBase.hh                         \
   Particle.hh         Particle.fhh        \
   RivetAIDA.hh        RivetAIDA.fhh       \
   Analysis.hh         Analysis.fhh        \
   AnalysisHandler.hh  AnalysisHandler.fhh \
-  ProjectionHandler.hh \
+  ProjectionHandler.hh                    \
   ProjectionApplier.hh ProjectionApplier.fhh \
   Projection.hh       Projection.fhh      \
   Cmp.hh              Cmp.fhh             \

Added: trunk/include/Rivet/RivetHepMC.hh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/include/Rivet/RivetHepMC.hh	Wed Jun 24 17:17:23 2009	(r1641)
@@ -0,0 +1,74 @@
+// -*- C++ -*-
+#ifndef RIVET_RivetHepMC_HH
+#define RIVET_RivetHepMC_HH
+
+#include "HepMC/GenEvent.h"
+#include "HepMC/GenParticle.h"
+#include "HepMC/GenVertex.h"
+
+#include <vector>
+
+namespace Rivet {
+
+
+  using HepMC::GenEvent;
+  using HepMC::GenParticle;
+  using HepMC::GenVertex;
+
+
+  inline vector<GenParticle*> particles(const GenEvent& ge) {
+    vector<GenParticle*> rtn;
+    for (GenEvent::particle_const_iterator pi = ge.particles_begin(); pi != ge.particles_end(); ++pi) {
+      rtn.push_back(*pi);
+    }
+    return rtn;
+  }
+  inline vector<GenParticle*> particles(const GenEvent* ge) {
+    assert(ge);
+    return particles(*ge);
+  }
+
+
+  inline vector<GenVertex*> vertices(const GenEvent& ge) {
+    vector<GenVertex*> rtn;
+    for (GenEvent::vertex_const_iterator vi = ge.vertices_begin(); vi != ge.vertices_end(); ++vi) {
+      rtn.push_back(*vi);
+    }
+    return rtn;
+  }
+  inline vector<GenVertex*> vertices(const GenEvent* ge) {
+    assert(ge);
+    return vertices(*ge);
+  }
+
+
+  inline const vector<GenParticle*> particles_in(const GenVertex* gv) {
+    vector<GenParticle*> rtn;
+    for (GenVertex::particles_in_const_iterator pi = gv->particles_in_const_begin(); pi != gv->particles_in_const_end(); ++pi) {
+      rtn.push_back(*pi);
+    }
+    return rtn;
+  }
+
+
+  inline const vector<GenParticle*> particles_out(const GenVertex* gv) {
+    vector<GenParticle*> rtn;
+    for (GenVertex::particles_out_const_iterator pi = gv->particles_out_const_begin(); pi != gv->particles_out_const_end(); ++pi) {
+      rtn.push_back(*pi);
+    }
+    return rtn;
+  }
+
+
+  inline vector<GenParticle*> particles(GenVertex* gv, HepMC::IteratorRange range=HepMC::relatives) {
+    vector<GenParticle*> rtn;
+    for (GenVertex::particle_iterator pi = gv->particles_begin(range); pi != gv->particles_end(range); ++pi) {
+      rtn.push_back(*pi);
+    }
+    return rtn;
+  }
+
+
+}
+
+#endif


More information about the Rivet-svn mailing list