Rivet: /Users/chrisg/software/rivet/include/Rivet/Tools/RivetHepMC.hh Source File

| Rivet 3.1.9

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
17#include "HepMC3/Version.h"
18#if HEPMC3_VERSION_CODE >= 3002007
19#include "HepMC3/ReaderFactory.h"
20#else
21namespace HepMC3 {
22 std::shared_ptr<HepMC3::Reader> deduce_reader(const std::string &filename);
23 std::shared_ptr<HepMC3::Reader> deduce_reader(std::istream &stream);
24}
25#endif
26
27#ifndef HEPMC_HAS_CROSS_SECTION
28#define HEPMC_HAS_CROSS_SECTION
29#endif
30
31namespace Rivet {
32 namespace RivetHepMC = HepMC3;
33
34 using RivetHepMC::ConstGenParticlePtr;
35 using RivetHepMC::ConstGenVertexPtr;
36 using RivetHepMC::Relatives;
37 using RivetHepMC::ConstGenHeavyIonPtr;
38
39 using HepMC_IO_type = RivetHepMC::Reader;
40 using PdfInfo = RivetHepMC::GenPdfInfo;
41}
42
43#else // HEPMC_2
44
45#include "HepMC/GenEvent.h"
46#include "HepMC/GenParticle.h"
47#include "HepMC/HeavyIon.h"
48#include "HepMC/GenVertex.h"
49#include "HepMC/Version.h"
50#include "HepMC/GenRanges.h"
51#include "HepMC/IO_GenEvent.h"
52namespace Rivet {
53 namespace RivetHepMC = HepMC;
54
55 // HepMC 2.07 provides its own #defines
56 typedef const HepMC::GenParticle* ConstGenParticlePtr;
57 typedef const HepMC::GenVertex* ConstGenVertexPtr;
58 typedef const HepMC::HeavyIon* ConstGenHeavyIonPtr;
59
62 class Relatives {
63 public:
64
65 constexpr Relatives(HepMC::IteratorRange relo): _internal(relo){}
66
67 constexpr HepMC::IteratorRange operator()() const {return _internal;}
68 operator HepMC::IteratorRange() const {return _internal;}
69
70 const static Relatives PARENTS;
71 const static Relatives CHILDREN;
72 const static Relatives ANCESTORS;
73 const static Relatives DESCENDANTS;
74
75 private:
76 const HepMC::IteratorRange _internal;
77
78 };
79
80 using HepMC_IO_type = HepMC::IO_GenEvent;
81 using PdfInfo = RivetHepMC::PdfInfo;
82}
83
84#endif
85
86
87namespace Rivet {
88
89
90 using RivetHepMC::GenEvent;
91 using ConstGenEventPtr = std::shared_ptr<const GenEvent>;
92
94 namespace HepMCUtils {
95 ConstGenParticlePtr getParticlePtr(const RivetHepMC::GenParticle & gp);
96 std::vector<ConstGenParticlePtr> particles(ConstGenEventPtr ge);
97 std::vector<ConstGenParticlePtr> particles(const GenEvent *ge);
98 std::vector<ConstGenVertexPtr> vertices(ConstGenEventPtr ge);
99 std::vector<ConstGenVertexPtr> vertices(const GenEvent *ge);
100 std::vector<ConstGenParticlePtr> particles(ConstGenVertexPtr gv, const Relatives &relo);
101 std::vector<ConstGenParticlePtr> particles(ConstGenParticlePtr gp, const Relatives &relo);
102 int uniqueId(ConstGenParticlePtr gp);
103 int particles_size(ConstGenEventPtr ge);
104 int particles_size(const GenEvent* ge);
105 std::pair<ConstGenParticlePtr,ConstGenParticlePtr> beams(const GenEvent* ge);
106 std::shared_ptr<HepMC_IO_type> makeReader(std::string filename, std::shared_ptr<std::istream>& istrp, std::string* errm = 0);
107 bool readEvent(std::shared_ptr<HepMC_IO_type> io, std::shared_ptr<GenEvent> evt);
108 void strip(GenEvent & ge, const set<long>& stripid = {1, -1, 2, -2, 3,-3, 21});
109 vector<string> weightNames(const GenEvent& ge);
110 std::valarray<double> weights(const GenEvent& ge);
111 pair<double,double> crossSection(const GenEvent& ge, size_t index = 0);
112 }
113
114
115}
116
117#endif
Rivet
Definition MC_Cent_pPb.hh:10
Rivet::beams
ParticlePair beams(const Event &e)
Get beam particles from an event.