gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
PID_pair.hpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
18 
19 #include <utility>
20 #include <string>
21 
22 #pragma once
23 
24 namespace Gambit
25 {
26 
31  class PID_pair
32  {
33 
34  public:
35 
36  typedef std::pair<int,int> iipair;
37 
39  PID_pair() :
40  _pids(iipair({0, 0}))
41  {}
42 
43  PID_pair(int pid1_in, int pid2_in)
44  {
45  // Use this function to ensure correct sorting
46  set_pids(pid1_in, pid2_in);
47  }
48 
49  PID_pair(const iipair& PIDs_in)
50  {
51  // Use this function to ensure correct sorting
52  set_pids(PIDs_in);
53  }
54 
56  virtual ~PID_pair() { }
57 
58 
60  void set_pids(int pid1_in, int pid2_in)
61  {
62  if (pid1_in <= pid2_in)
63  {
64  _pids = iipair({pid1_in, pid2_in});
65  }
66  else
67  {
68  _pids = iipair({pid2_in, pid1_in});
69  }
70  }
71 
72  void set_pids(const iipair& PIDs_in)
73  {
74  set_pids(PIDs_in.first, PIDs_in.second);
75  }
76 
77 
79  const iipair& PIDs() const
80  {
81  return _pids;
82  }
83 
84  int pid1() const
85  {
86  return _pids.first;
87  }
88 
89  int pid2() const
90  {
91  return _pids.second;
92  }
93 
96  {
97  return PID_pair(-_pids.second, -_pids.first);
98  }
99 
101  bool is_antiparticle_pair() const
102  {
103  return (_pids.first == -_pids.second);
104  }
105 
108  bool operator== (const PID_pair& rhs) const
109  { return this->_pids.first == rhs._pids.first && this->_pids.second == rhs._pids.second; }
110 
111  bool operator!= (const PID_pair& rhs) const
112  { return !(*this == rhs); }
113 
114  bool operator< (const PID_pair& rhs) const
115  { return this->_pids.first < rhs._pids.first || (!(rhs._pids.first < this->_pids.first) && this->_pids.second < rhs._pids.second); }
116 
117  bool operator<= (const PID_pair& rhs) const
118  { return !(rhs < *this); }
119 
120  bool operator> (const PID_pair& rhs) const
121  { return rhs < *this; }
122 
123  bool operator>= (const PID_pair& rhs) const
124  { return !(*this < rhs); }
125 
126 
128  void reset()
129  {
130  _pids = iipair({0,0});
131  }
132 
133 
135  std::string str() const
136  {
137  std::string pids_str = std::to_string(_pids.first) + "_" + std::to_string(_pids.second);
138  return pids_str;
139  }
140 
141 
142  private:
143 
144  iipair _pids;
145  };
146 
147 }
void set_pids(const iipair &PIDs_in)
Definition: PID_pair.hpp:72
PID_pair(int pid1_in, int pid2_in)
Definition: PID_pair.hpp:43
PID_pair()
Constructors.
Definition: PID_pair.hpp:39
Simple class for holding a sorted pair of particle ID (PID) codes.
Definition: PID_pair.hpp:31
bool operator<(const PID_pair &rhs) const
Definition: PID_pair.hpp:114
void reset()
Reset the PIDs.
Definition: PID_pair.hpp:128
bool operator<=(const PID_pair &rhs) const
Definition: PID_pair.hpp:117
bool operator==(const PID_pair &rhs) const
Relational operators, simply using the relational operators for the underlying pair<int,int>
Definition: PID_pair.hpp:108
int pid1() const
Definition: PID_pair.hpp:84
std::pair< int, int > iipair
Definition: PID_pair.hpp:36
bool is_antiparticle_pair() const
Check if |pid1| == |pid2|.
Definition: PID_pair.hpp:101
bool operator!=(const PID_pair &rhs) const
Definition: PID_pair.hpp:111
bool operator>=(const PID_pair &rhs) const
Definition: PID_pair.hpp:123
int pid2() const
Definition: PID_pair.hpp:89
virtual ~PID_pair()
Detstructor.
Definition: PID_pair.hpp:56
PID_pair cc_pid_pair() const
Get the charge-conjugated PID pair.
Definition: PID_pair.hpp:95
void set_pids(int pid1_in, int pid2_in)
Set PIDs, with sorting.
Definition: PID_pair.hpp:60
std::string str() const
Get the PID pair as a string: "<pid1>_<pid2>".
Definition: PID_pair.hpp:135
bool operator>(const PID_pair &rhs) const
Definition: PID_pair.hpp:120
PID_pair(const iipair &PIDs_in)
Definition: PID_pair.hpp:49
const iipair & PIDs() const
Get PIDs.
Definition: PID_pair.hpp:79
TODO: see if we can use this one:
Definition: Analysis.hpp:33