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