Rivet  1.8.3
BeamConstraint.hh
1 // -*- C++ -*-
2 #ifndef RIVET_BeamConstraint_HH
3 #define RIVET_BeamConstraint_HH
4 
5 #include "Rivet/Rivet.hh"
6 #include "Rivet/ParticleName.hh"
7 #include "Rivet/Particle.hh"
8 #include <iostream>
9 
10 
11 namespace Rivet {
12 
16  inline bool compatible(PdgId p, PdgId allowed) {
17  //assert(p != ANY);
18  return (allowed == ANY || p == allowed);
19  }
20 
24  inline bool compatible(const PdgIdPair& pair, const PdgIdPair& allowedpair) {
25  bool oneToOne = compatible(pair.first, allowedpair.first);
26  bool twoToTwo = compatible(pair.second, allowedpair.second);
27  bool oneToTwo = compatible(pair.first, allowedpair.second);
28  bool twoToOne = compatible(pair.second, allowedpair.first);
29  return (oneToOne && twoToTwo) || (oneToTwo && twoToOne);
30  }
31 
32 
34  inline bool compatible(const ParticlePair& ppair,
35  const PdgIdPair& allowedpair) {
36  return compatible(make_pdgid_pair(ppair.first.pdgId(),
37  ppair.second.pdgId()), allowedpair);
38  }
40  inline bool compatible(const PdgIdPair& allowedpair,
41  const ParticlePair& ppair) {
42  return compatible(ppair, allowedpair);
43  }
44 
45 
48  inline bool compatible(const PdgIdPair& pair, const set<PdgIdPair>& allowedpairs) {
49  for (set<PdgIdPair>::const_iterator bp = allowedpairs.begin(); bp != allowedpairs.end(); ++bp) {
50  if (compatible(pair, *bp)) return true;
51  }
52  return false;
53  }
54 
56  inline set<PdgIdPair> intersection(const set<PdgIdPair>& a, const set<PdgIdPair>& b) {
57  set<PdgIdPair> ret;
58  for (set<PdgIdPair>::const_iterator bp = a.begin(); bp != a.end(); ++bp) {
59  if (compatible(*bp, b)) ret.insert(*bp);
60  }
61  return ret;
62  }
63 
64 
65 }
66 
67 #endif
Definition: MC_JetAnalysis.hh:9
set< PdgIdPair > intersection(const set< PdgIdPair > &a, const set< PdgIdPair > &b)
Return the intersection of two sets of {PdgIdPair}s.
Definition: BeamConstraint.hh:56
bool compatible(PdgId p, PdgId allowed)
Definition: BeamConstraint.hh:16
std::pair< PdgId, PdgId > make_pdgid_pair(PdgId a, PdgId b)
Convenience maker of particle ID pairs from PdgIds.
Definition: ParticleName.hh:154