rivet is hosted by Hepforge, IPPP Durham
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/Particle.hh"
00006 
00007 namespace Rivet {
00008 
00009 
00010   /// Find whether ParticleName @a p is compatible with the
00011   /// template ParticleName @a allowed. Effectively this is
00012   /// asking whether @a p is a subset of @a allowed.
00013   inline bool compatible(PdgId p, PdgId allowed) {
00014     return (allowed == PID::ANY || p == allowed);
00015   }
00016 
00017   /// Find whether PdgIdPair @a pair is compatible with the template
00018   /// PdgIdPair @a allowedpair. This assesses whether either of the
00019   /// two possible pairings of @a pair's constituents is compatible.
00020   inline bool compatible(const PdgIdPair& pair, const PdgIdPair& allowedpair) {
00021     bool oneToOne = compatible(pair.first, allowedpair.first);
00022     bool twoToTwo = compatible(pair.second, allowedpair.second);
00023     bool oneToTwo = compatible(pair.first, allowedpair.second);
00024     bool twoToOne = compatible(pair.second, allowedpair.first);
00025     return (oneToOne && twoToTwo) || (oneToTwo && twoToOne);
00026   }
00027 
00028 
00029   /// Check particle compatibility of Particle pairs
00030   inline bool compatible(const ParticlePair& ppair,
00031                          const PdgIdPair& allowedpair) {
00032     return compatible(PID::make_pdgid_pair(ppair.first.pid(),
00033                                            ppair.second.pid()), allowedpair);
00034   }
00035   /// Check particle compatibility of Particle pairs (for symmetric completeness)
00036   inline bool compatible(const PdgIdPair& allowedpair,
00037                          const ParticlePair& ppair) {
00038     return compatible(ppair, allowedpair);
00039   }
00040 
00041 
00042   /// Find whether a PdgIdPair @a pair is compatible with at least one template
00043   /// beam pair in a set @a allowedpairs.
00044   inline bool compatible(const PdgIdPair& pair, const set<PdgIdPair>& allowedpairs) {
00045     for (set<PdgIdPair>::const_iterator bp = allowedpairs.begin(); bp != allowedpairs.end(); ++bp) {
00046       if (compatible(pair, *bp)) return true;
00047     }
00048     return false;
00049   }
00050 
00051   /// Return the intersection of two sets of {PdgIdPair}s.
00052   inline set<PdgIdPair> intersection(const set<PdgIdPair>& a, const set<PdgIdPair>& b) {
00053     set<PdgIdPair> ret;
00054     for (set<PdgIdPair>::const_iterator bp = a.begin(); bp != a.end(); ++bp) {
00055       if (compatible(*bp, b)) ret.insert(*bp);
00056     }
00057     return ret;
00058   }
00059 
00060 
00061 }
00062 
00063 #endif