Rivet  3.1.0
RivetHepMC.hh
1 // -*- C++ -*-
2 #ifndef RIVET_RivetHepMC_HH
3 #define RIVET_RivetHepMC_HH
4 
5 #include "Rivet/Config/RivetConfig.hh"
6 #include "Rivet/Tools/RivetSTL.hh"
7 #include "Rivet/Tools/Exceptions.hh"
8 #include <valarray>
9 
10 
11 #ifdef RIVET_ENABLE_HEPMC_3
12 
13 #include "HepMC3/HepMC3.h"
14 #include "HepMC3/Relatives.h"
15 #include "HepMC3/Reader.h"
16 #ifndef HEPMC_HAS_CROSS_SECTION
17 #define HEPMC_HAS_CROSS_SECTION
18 #endif
19 namespace Rivet {
20  namespace RivetHepMC = HepMC3;
21 
22  using RivetHepMC::ConstGenParticlePtr;
23  using RivetHepMC::ConstGenVertexPtr;
24  using RivetHepMC::Relatives;
25  using RivetHepMC::ConstGenHeavyIonPtr;
26 
27  using HepMC_IO_type = RivetHepMC::Reader;
28  using PdfInfo = RivetHepMC::GenPdfInfo;
29 }
30 
31 #else // HEPMC_2
32 
33 #include "HepMC/GenEvent.h"
34 #include "HepMC/GenParticle.h"
35 #include "HepMC/HeavyIon.h"
36 #include "HepMC/GenVertex.h"
37 #include "HepMC/Version.h"
38 #include "HepMC/GenRanges.h"
39 #include "HepMC/IO_GenEvent.h"
40 namespace Rivet {
41  namespace RivetHepMC = HepMC;
42 
43  // HepMC 2.07 provides its own #defines
44  typedef const HepMC::GenParticle* ConstGenParticlePtr;
45  typedef const HepMC::GenVertex* ConstGenVertexPtr;
46  typedef const HepMC::HeavyIon* ConstGenHeavyIonPtr;
47 
50  class Relatives {
51  public:
52 
53  constexpr Relatives(HepMC::IteratorRange relo): _internal(relo){}
54 
55  constexpr HepMC::IteratorRange operator()() const {return _internal;}
56  operator HepMC::IteratorRange() const {return _internal;}
57 
58  const static Relatives PARENTS;
59  const static Relatives CHILDREN;
60  const static Relatives ANCESTORS;
61  const static Relatives DESCENDANTS;
62 
63  private:
64  const HepMC::IteratorRange _internal;
65 
66  };
67 
68  using HepMC_IO_type = HepMC::IO_GenEvent;
69  using PdfInfo = RivetHepMC::PdfInfo;
70 }
71 
72 #endif
73 
74 
75 namespace Rivet {
76 
77 
78  using RivetHepMC::GenEvent;
79  using ConstGenEventPtr = std::shared_ptr<const GenEvent>;
80 
82  namespace HepMCUtils {
83  ConstGenParticlePtr getParticlePtr(const RivetHepMC::GenParticle & gp);
84  std::vector<ConstGenParticlePtr> particles(ConstGenEventPtr ge);
85  std::vector<ConstGenParticlePtr> particles(const GenEvent *ge);
86  std::vector<ConstGenVertexPtr> vertices(ConstGenEventPtr ge);
87  std::vector<ConstGenVertexPtr> vertices(const GenEvent *ge);
88  std::vector<ConstGenParticlePtr> particles(ConstGenVertexPtr gv, const Relatives &relo);
89  std::vector<ConstGenParticlePtr> particles(ConstGenParticlePtr gp, const Relatives &relo);
90  int uniqueId(ConstGenParticlePtr gp);
91  int particles_size(ConstGenEventPtr ge);
92  int particles_size(const GenEvent* ge);
93  std::pair<ConstGenParticlePtr,ConstGenParticlePtr> beams(const GenEvent* ge);
94  std::shared_ptr<HepMC_IO_type> makeReader(std::string filename, std::shared_ptr<std::istream>& istrp, std::string* errm = 0);
95  bool readEvent(std::shared_ptr<HepMC_IO_type> io, std::shared_ptr<GenEvent> evt);
96  void strip(GenEvent & ge, const set<long>& stripid = {1, -1, 2, -2, 3,-3, 21});
97  vector<string> weightNames(const GenEvent& ge);
98  std::valarray<double> weights(const GenEvent& ge);
99  pair<double,double> crossSection(const GenEvent& ge);
100  }
101 
102 
103 }
104 
105 #endif
Definition: MC_Cent_pPb.hh:10
ParticlePair beams(const Event &e)
Get beam particles from an event.