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     //assert(p != ANY);
00018     return (allowed == ANY || p == allowed);
00019   }
00020 
00021   /// Find whether BeamPair @a pair is compatible with the template
00022   /// BeamPair @a allowedpair. This assesses whether either of the
00023   /// two possible pairings of @a pair's constituents is compatible.
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   /// Check particle compatibility of Particle pairs
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   /// Check particle compatibility of Particle pairs (for symmetric completeness)
00040   inline bool compatible(const BeamPair& allowedpair,
00041                          const ParticlePair& ppair) {
00042     return compatible(ppair, allowedpair);
00043   }
00044 
00045 
00046   /// Find whether a BeamPair @a pair is compatible with at least one template
00047   /// beam pair in a set @a allowedpairs.
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   /// Return the intersection of two sets of {@link BeamPair}s.
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