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