00001
00002 #ifndef RIVET_BeamConstraint_HH
00003 #define RIVET_BeamConstraint_HH
00004
00005 #include "Rivet/Rivet.hh"
00006 #include "Rivet/ParticleName.hh"
00007 #include "Rivet/Particle.hh"
00008 #include <iostream>
00009
00010
00011 namespace Rivet {
00012
00013
00014
00015
00016 inline bool compatible(PdgId p, PdgId allowed) {
00017
00018 return (allowed == ANY || p == allowed);
00019 }
00020
00021
00022
00023
00024 inline bool compatible(const BeamPair& pair, const BeamPair& allowedpair) {
00025 bool oneToOne = compatible(pair.first, allowedpair.first);
00026 bool twoToTwo = compatible(pair.second, allowedpair.second);
00027 bool oneToTwo = compatible(pair.first, allowedpair.second);
00028 bool twoToOne = compatible(pair.second, allowedpair.first);
00029 return (oneToOne && twoToTwo) || (oneToTwo && twoToOne);
00030 }
00031
00032
00033
00034 inline bool compatible(const ParticlePair& ppair,
00035 const BeamPair& allowedpair) {
00036 return compatible(make_pdgid_pair(ppair.first.pdgId(),
00037 ppair.second.pdgId()), allowedpair);
00038 }
00039
00040 inline bool compatible(const BeamPair& allowedpair,
00041 const ParticlePair& ppair) {
00042 return compatible(ppair, allowedpair);
00043 }
00044
00045
00046
00047
00048 inline bool compatible(const BeamPair& pair, const set<BeamPair>& allowedpairs) {
00049 for (set<BeamPair>::const_iterator bp = allowedpairs.begin(); bp != allowedpairs.end(); ++bp) {
00050 if (compatible(pair, *bp)) return true;
00051 }
00052 return false;
00053 }
00054
00055
00056 inline set<BeamPair> intersection(const set<BeamPair>& a, const set<BeamPair>& b) {
00057 set<BeamPair> ret;
00058 for (set<BeamPair>::const_iterator bp = a.begin(); bp != a.end(); ++bp) {
00059 if (compatible(*bp, b)) ret.insert(*bp);
00060 }
00061 return ret;
00062 }
00063
00064
00065 }
00066
00067 #endif