File indexing completed on 2025-04-19 09:06:50
0001
0002 #ifndef RIVET_BeamConstraint_HH
0003 #define RIVET_BeamConstraint_HH
0004
0005 #include "Rivet/Tools/Beams.hh"
0006 #include "Rivet/Tools/ParticleName.hh"
0007
0008 namespace Rivet {
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 inline bool compatibleBeamID(PdgId p, PdgId allowed) {
0019 return (allowed == PID::ANY || p == allowed);
0020 }
0021
0022
0023
0024
0025
0026 inline bool compatibleBeamIDs(const PdgIdPair& pair, const PdgIdPair& allowedpair) {
0027 const bool oneToOne = compatibleBeamID(pair.first, allowedpair.first);
0028 const bool twoToTwo = compatibleBeamID(pair.second, allowedpair.second);
0029 const bool oneToTwo = compatibleBeamID(pair.first, allowedpair.second);
0030 const bool twoToOne = compatibleBeamID(pair.second, allowedpair.first);
0031 return (oneToOne && twoToTwo) || (oneToTwo && twoToOne);
0032 }
0033
0034
0035 inline bool compatibleBeamIDs(const ParticlePair& ppair, const PdgIdPair& allowedpair) {
0036 return compatibleBeamIDs(PID::make_pdgid_pair(ppair.first.pid(), ppair.second.pid()), allowedpair);
0037 }
0038
0039
0040 inline bool compatibleBeamIDs(const ParticlePair& a, const ParticlePair& b) {
0041 return compatibleBeamIDs(PID::make_pdgid_pair(a.first.pid(), a.second.pid()),
0042 PID::make_pdgid_pair(b.first.pid(), b.second.pid()) );
0043 }
0044
0045
0046
0047 inline bool compatibleBeamEnergies(const pair<double,double>& energies,
0048 const pair<double,double>& allowedenergies, const double reltol=1e-3) {
0049 const bool oneToOne = fuzzyEquals(energies.first, allowedenergies.first, reltol);
0050 const bool twoToTwo = fuzzyEquals(energies.second, allowedenergies.second, reltol);
0051 const bool oneToTwo = fuzzyEquals(energies.first, allowedenergies.second, reltol);
0052 const bool twoToOne = fuzzyEquals(energies.second, allowedenergies.first, reltol);
0053 const bool absDiffOneToOne = abs(energies.first - allowedenergies.first) < 1*GeV;
0054 const bool absDiffTwoToTwo = abs(energies.second - allowedenergies.second) < 1*GeV;
0055 const bool absDiffOneToTwo = abs(energies.first - allowedenergies.second) < 1*GeV;
0056 const bool absDiffTwoToOne = abs(energies.second - allowedenergies.first) < 1*GeV;
0057 return (oneToOne && twoToTwo) || (oneToTwo && twoToOne) ||
0058 (absDiffOneToOne && absDiffTwoToTwo) || (absDiffOneToTwo && absDiffTwoToOne);
0059 }
0060
0061
0062 inline bool compatibleBeamEnergies(const ParticlePair& ppair,
0063 const pair<double,double>& allowedenergies, double reltol=1e-3) {
0064 return compatibleBeamEnergies(make_pair(ppair.first.E(), ppair.second.E()), allowedenergies, reltol);
0065 }
0066
0067
0068 inline bool compatibleBeamEnergies(const ParticlePair& ppair,
0069 const ParticlePair& allowedppair, double reltol=1e-3) {
0070 return compatibleBeamEnergies(make_pair(ppair.first.E(), ppair.second.E()),
0071 make_pair(allowedppair.first.E(), allowedppair.second.E()), reltol);
0072 }
0073
0074
0075
0076 inline bool compatibleBeamEnergy(const pair<double,double>& energies, double allowedsqrts, double reltol=1e-3) {
0077 return fuzzyEquals(sqrtS(energies.first, energies.second), allowedsqrts, reltol);
0078 }
0079
0080
0081 inline bool compatibleBeamEnergy(const ParticlePair& ppair,
0082 const pair<double,double>& allowedenergies, double reltol=1e-3) {
0083 return fuzzyEquals(sqrtS(ppair), sqrtS(allowedenergies), reltol);
0084 }
0085
0086
0087 inline bool compatibleBeamEnergy(const ParticlePair& ppair,
0088 const double allowedsqrts, double reltol=1e-3) {
0089 return fuzzyEquals(sqrtS(ppair), allowedsqrts, reltol);
0090 }
0091
0092
0093
0094 inline bool compatibleBeams(const ParticlePair& ppair, const PdgIdPair& allowedpids, double allowedsqrts) {
0095 return compatibleBeamIDs(ppair, allowedpids) && compatibleBeamEnergy(ppair, allowedsqrts);
0096 }
0097
0098
0099 inline bool compatibleBeams(const ParticlePair& ppair, const PdgIdPair& allowedpids, const pair<double,double>& allowedenergies) {
0100 return compatibleBeamIDs(ppair, allowedpids) && compatibleBeamEnergies(ppair, allowedenergies);
0101 }
0102
0103
0104 inline bool compatibleBeams(const ParticlePair& a, const ParticlePair& b) {
0105 return compatibleBeamIDs(a, b) && compatibleBeamEnergies(a, b);
0106 }
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130 }
0131
0132 #endif