rivet is hosted by Hepforge, IPPP Durham
Rivet 4.0.0
BeamConstraint.hh
1// -*- C++ -*-
2#ifndef RIVET_BeamConstraint_HH
3#define RIVET_BeamConstraint_HH
4
5#include "Rivet/Tools/Beams.hh"
6#include "Rivet/Tools/ParticleName.hh"
7
8namespace Rivet {
9
10
13
14
18 inline bool compatibleBeamID(PdgId p, PdgId allowed) {
19 return (allowed == PID::ANY || p == allowed);
20 }
21
26 inline bool compatibleBeamIDs(const PdgIdPair& pair, const PdgIdPair& allowedpair) {
27 const bool oneToOne = compatibleBeamID(pair.first, allowedpair.first);
28 const bool twoToTwo = compatibleBeamID(pair.second, allowedpair.second);
29 const bool oneToTwo = compatibleBeamID(pair.first, allowedpair.second);
30 const bool twoToOne = compatibleBeamID(pair.second, allowedpair.first);
31 return (oneToOne && twoToTwo) || (oneToTwo && twoToOne);
32 }
33
35 inline bool compatibleBeamIDs(const ParticlePair& ppair, const PdgIdPair& allowedpair) {
36 return compatibleBeamIDs(PID::make_pdgid_pair(ppair.first.pid(), ppair.second.pid()), allowedpair);
37 }
38
40 inline bool compatibleBeamIDs(const ParticlePair& a, const ParticlePair& b) {
41 return compatibleBeamIDs(PID::make_pdgid_pair(a.first.pid(), a.second.pid()),
42 PID::make_pdgid_pair(b.first.pid(), b.second.pid()) );
43 }
44
45
47 inline bool compatibleBeamEnergies(const pair<double,double>& energies,
48 const pair<double,double>& allowedenergies, const double reltol=1e-3) {
49 const bool oneToOne = fuzzyEquals(energies.first, allowedenergies.first, reltol);
50 const bool twoToTwo = fuzzyEquals(energies.second, allowedenergies.second, reltol);
51 const bool oneToTwo = fuzzyEquals(energies.first, allowedenergies.second, reltol);
52 const bool twoToOne = fuzzyEquals(energies.second, allowedenergies.first, reltol);
53 const bool absDiffOneToOne = abs(energies.first - allowedenergies.first) < 1*GeV;
54 const bool absDiffTwoToTwo = abs(energies.second - allowedenergies.second) < 1*GeV;
55 const bool absDiffOneToTwo = abs(energies.first - allowedenergies.second) < 1*GeV;
56 const bool absDiffTwoToOne = abs(energies.second - allowedenergies.first) < 1*GeV;
57 return (oneToOne && twoToTwo) || (oneToTwo && twoToOne) ||
58 (absDiffOneToOne && absDiffTwoToTwo) || (absDiffOneToTwo && absDiffTwoToOne);
59 }
60
62 inline bool compatibleBeamEnergies(const ParticlePair& ppair,
63 const pair<double,double>& allowedenergies, double reltol=1e-3) {
64 return compatibleBeamEnergies(make_pair(ppair.first.E(), ppair.second.E()), allowedenergies, reltol);
65 }
66
68 inline bool compatibleBeamEnergies(const ParticlePair& ppair,
69 const ParticlePair& allowedppair, double reltol=1e-3) {
70 return compatibleBeamEnergies(make_pair(ppair.first.E(), ppair.second.E()),
71 make_pair(allowedppair.first.E(), allowedppair.second.E()), reltol);
72 }
73
74
76 inline bool compatibleBeamEnergy(const pair<double,double>& energies, double allowedsqrts, double reltol=1e-3) {
77 return fuzzyEquals(sqrtS(energies.first, energies.second), allowedsqrts, reltol);
78 }
79
81 inline bool compatibleBeamEnergy(const ParticlePair& ppair,
82 const pair<double,double>& allowedenergies, double reltol=1e-3) {
83 return fuzzyEquals(sqrtS(ppair), sqrtS(allowedenergies), reltol);
84 }
85
87 inline bool compatibleBeamEnergy(const ParticlePair& ppair,
88 const double allowedsqrts, double reltol=1e-3) {
89 return fuzzyEquals(sqrtS(ppair), allowedsqrts, reltol);
90 }
91
92
94 inline bool compatibleBeams(const ParticlePair& ppair, const PdgIdPair& allowedpids, double allowedsqrts) {
95 return compatibleBeamIDs(ppair, allowedpids) && compatibleBeamEnergy(ppair, allowedsqrts);
96 }
97
99 inline bool compatibleBeams(const ParticlePair& ppair, const PdgIdPair& allowedpids, const pair<double,double>& allowedenergies) {
100 return compatibleBeamIDs(ppair, allowedpids) && compatibleBeamEnergies(ppair, allowedenergies);
101 }
102
104 inline bool compatibleBeams(const ParticlePair& a, const ParticlePair& b) {
105 return compatibleBeamIDs(a, b) && compatibleBeamEnergies(a, b);
106 }
107
109
110
111
112 // /// Find whether PdgIdPair @a pair is compatible with at least one template beam pair in a set @a allowedpairs
113 // inline bool anyCompatibleBeamIDs(const PdgIdPair& pair, const set<PdgIdPair>& allowedpairs) {
114 // for (const PdgIdPair& bp : allowedpairs)
115 // if (compatibleBeamIDs(pair, bp)) return true;
116 // return false;
117 // }
118
119 // /// Return the intersection of two sets of {PdgIdPair}s.
120 // inline set<PdgIdPair> intersection(const set<PdgIdPair>& a, const set<PdgIdPair>& b) {
121 // set<PdgIdPair> ret;
122 // for (set<PdgIdPair>::const_iterator bp = a.begin(); bp != a.end(); ++bp) {
123 // if (compatibleBeamIDs(*bp, b)) ret.insert(*bp);
124 // }
125 // return ret;
126 // }
127
128
129
130}
131
132#endif
bool compatibleBeamEnergy(const pair< double, double > &energies, double allowedsqrts, double reltol=1e-3)
Check the sqrt(s) compatibility of two massless opposing beams.
Definition BeamConstraint.hh:76
bool compatibleBeams(const ParticlePair &ppair, const PdgIdPair &allowedpids, double allowedsqrts)
Check the particle ID and beam-energy compatibility of two Particle pairs.
Definition BeamConstraint.hh:94
bool compatibleBeamEnergies(const pair< double, double > &energies, const pair< double, double > &allowedenergies, const double reltol=1e-3)
Check the energy compatibility of two pairs of particle energies.
Definition BeamConstraint.hh:47
bool compatibleBeamID(PdgId p, PdgId allowed)
Find whether ParticleName p is compatible with the template ParticleName allowed.
Definition BeamConstraint.hh:18
bool compatibleBeamIDs(const PdgIdPair &pair, const PdgIdPair &allowedpair)
Find whether PdgIdPair pair is compatible with the template PdgIdPair allowedpair.
Definition BeamConstraint.hh:26
double sqrtS(double ea, double eb)
Get beam centre-of-mass energy from a pair of beam energies.
Definition MC_CENT_PPB_Projections.hh:10
std::pair< Particle, Particle > ParticlePair
Typedef for a pair of Particle objects.
Definition Particle.hh:38
std::enable_if< std::is_arithmetic< N1 >::value &&std::is_arithmetic< N2 >::value &&(std::is_floating_point< N1 >::value||std::is_floating_point< N2 >::value), bool >::type fuzzyEquals(N1 a, N2 b, double tolerance=1e-5)
Compare two numbers for equality with a degree of fuzziness.
Definition MathUtils.hh:57