BeamConstraint.hh

Go to the documentation of this file.
00001 // -*- C++ -*-
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   /// Find whether ParticleName @a p is compatible with the
00013   /// template ParticleName @a allowed. Effectively this is
00014   /// asking whether @a p is a subset of @a allowed.
00015   inline bool compatible(ParticleName p, ParticleName allowed) {
00016     //assert(p != ANY);
00017     return (allowed == ANY || p == allowed);
00018   }
00019 
00020   /// Find whether BeamPair @a pair is compatible with the template
00021   /// BeamPair @a allowedpair. This assesses whether either of the 
00022   /// two possible pairings of @a pair's constituents is compatible.
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   /// Find whether a BeamPair @a pair is compatible with at least one template
00032   /// beam pair in a set @a allowedpairs.
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   /// Return the intersection of two sets of {@link BeamPair}s.
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