gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
decay_table.hpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
16 
17 #ifndef __decay_table_hpp__
18 #define __decay_table_hpp__
19 
20 #include <map>
21 #include <set>
22 #include <string>
23 #include <sstream>
24 
30 
31 namespace Gambit
32 {
33 
35  class DecayTable
36  {
37  public:
38 
39  // Forward declaration of DecayTable entry class, for readability. Holds the info on all decays of a given particle.
40  class Entry;
41 
47  DecayTable(str slha, int context = 0, bool force_SM_fermion_gauge_eigenstates = false);
49  DecayTable(str slha, const std::map<int, int>& PDG_map, int context = 0, bool force_SM_fermion_gauge_eigenstates = false);
51  DecayTable(const SLHAstruct&, int context = 0, bool force_SM_fermion_gauge_eigenstates = false);
53  DecayTable(const SLHAstruct&, const std::map<int, int>&, int context = 0, bool force_SM_fermion_gauge_eigenstates = false);
55 
57  SLHAstruct getSLHAea(int SLHA_version, bool include_zero_bfs=false, const mass_es_pseudonyms& psn=mass_es_pseudonyms()) const;
58 
60  void writeSLHAfile(int SLHA_version, const str& filename, bool include_zero_bfs=false, const mass_es_pseudonyms& psn=mass_es_pseudonyms()) const;
61 
64  SLHAea::Block getSLHAea_block(int, std::pair<int,int>, bool include_zero_bfs=false, const mass_es_pseudonyms& psn=mass_es_pseudonyms()) const;
65  SLHAea::Block getSLHAea_block(int, str, bool include_zero_bfs=false, const mass_es_pseudonyms& psn=mass_es_pseudonyms()) const;
66  SLHAea::Block getSLHAea_block(int, str, int, bool include_zero_bfs=false, const mass_es_pseudonyms& psn=mass_es_pseudonyms()) const;
68 
72  Entry& operator()(std::pair<int,int>);
74  Entry& operator()(str, int);
75  const Entry& operator()(std::pair<int,int>) const;
76  const Entry& operator()(str) const;
77  const Entry& operator()(str, int) const;
79 
83  Entry& at(std::pair<int,int>);
84  Entry& at(str);
85  Entry& at(str, int);
86  const Entry& at(std::pair<int,int>) const;
87  const Entry& at(str) const;
88  const Entry& at(str, int) const;
90 
92  std::map< std::pair<int,int>, Entry > particles;
93 
94 
96  class Entry
97  {
98  private:
99 
101  void init(const SLHAea::Block&, int, bool force_SM_fermion_gauge_eigenstates = false);
102 
104  void check_particles_exist(std::multiset< std::pair<int,int> >&) const;
105 
107  void check_BF_validity(double, double, std::multiset< std::pair<int,int> >&) const;
108 
112  static void construct_key(std::multiset< std::pair<int,int> >&) {}
114  template <typename... Args>
115  static void construct_key(std::multiset< std::pair<int,int> >& key, str p1, Args... args)
116  {
117  construct_key(key, args...);
118  key.insert(Models::ParticleDB().pdg_pair(p1));
119  }
121  template <typename... Args>
122  static void construct_key(std::multiset< std::pair<int,int> >& key, str p1, int i1, Args... args)
123  {
124  construct_key(key, args...);
125  key.insert(Models::ParticleDB().pdg_pair(p1, i1));
126  }
128 
129  public:
130 
134  Entry(double width) : width_in_GeV(width), calculator(""), calculator_version(""), warnings(""), errors("") {}
136  Entry(const SLHAea::Block&, int context = 0, bool force_SM_fermion_gauge_eigenstates = false, str calculator = "", str calculator_version = "");
138  Entry(const SLHAea::Block&, SLHAea::Block::const_iterator, int context = 0, bool force_SM_fermion_gauge_eigenstates = false,
139  str calculator = "", str calculator_version = "");
140 
150  void set_BF(double, double, const std::vector<std::pair<int,int> >&);
151  void set_BF(double, double, const std::vector<str>&);
152 
153  template <typename... Args>
154  void set_BF(double BF, double error, std::pair<int,int> p1, Args... args)
155  {
156  std::pair<int,int> particles[] = {p1, args...};
157  std::multiset< std::pair<int,int> > key(particles, particles+sizeof...(Args)+1);
159  check_BF_validity(BF, error, key);
160  channels[key] = std::pair<double, double>(BF, error);
161  }
162 
163  template <typename... Args>
164  void set_BF(double BF, double error, str p1, Args... args)
165  {
166  std::multiset< std::pair<int,int> > key;
167  construct_key(key, p1, args...);
168  check_BF_validity(BF, error, key);
169  channels[key] = std::pair<double, double>(BF, error);
170  }
172 
182  bool has_channel(const std::vector<std::pair<int,int> >&) const;
183  bool has_channel(const std::vector<str>&) const;
184 
185  template <typename... Args>
186  bool has_channel(std::pair<int,int> p1, Args... args) const
187  {
188  std::pair<int,int> particles[] = {p1, args...};
189  std::multiset< std::pair<int,int> > key(particles, particles+sizeof...(Args)+1);
191  return channels.find(key) != channels.end();
192  }
193 
194  template <typename... Args>
195  bool has_channel(str p1, Args... args) const
196  {
197  std::multiset< std::pair<int,int> > key;
198  construct_key(key, p1, args...);
199  return channels.find(key) != channels.end();
200  }
202 
212  double BF(const std::vector<std::pair<int, int> >&) const;
213  double BF(const std::vector<str>&) const;
214 
215  template <typename... Args>
216  double BF(std::pair<int,int> p1, Args... args) const
217  {
218  std::pair<int,int> particles[] = {p1, args...};
219  std::multiset< std::pair<int,int> > key(particles, particles+sizeof...(Args)+1);
220  if (channels.find(key) == channels.end())
221  {
222  std::ostringstream err;
223  err << "No branching fraction exists for the requested final states:";
224  for (auto particle = key.begin(); particle != key.end(); ++particle)
225  {
226  err << " {" << particle->first << ", " << particle->second << "}";
227  }
228  model_error().raise(LOCAL_INFO,err.str());
229  }
230  return channels.at(key).first;
231  }
232 
233  template <typename... Args>
234  double BF(str p1, Args... args) const
235  {
236  std::multiset< std::pair<int,int> > key;
237  construct_key(key, p1, args...);
238  if (channels.find(key) == channels.end())
239  {
240  std::ostringstream err;
241  err << "No branching fraction exists for the requested final states:";
242  for (auto particle = key.begin(); particle != key.end(); ++particle)
243  {
244  err << " {" << particle->first << ", " << particle->second << "}";
245  }
246  model_error().raise(LOCAL_INFO,err.str());
247  }
248  return channels.at(key).first;
249  }
251 
256  template <typename... Args>
257  double BF_error(std::pair<int,int> p1, Args... args) const
258  {
259  std::pair<int,int> particles[] = {p1, args...};
260  std::multiset< std::pair<int,int> > key(particles, particles+sizeof...(Args)+1);
261  if (channels.find(key) == channels.end())
262  {
263  std::ostringstream err;
264  err << "No branching fraction exists for the requested final states:";
265  for (auto particle = key.begin(); particle != key.end(); ++particle)
266  {
267  err << " {" << particle->first << ", " << particle->second << "}";
268  }
269  model_error().raise(LOCAL_INFO,err.str());
270  }
271  return channels.at(key).second;
272  }
273 
274  template <typename... Args>
275  double BF_error(str p1, Args... args) const
276  {
277  std::multiset< std::pair<int,int> > key;
278  construct_key(key, p1, args...);
279  if (channels.find(key) == channels.end())
280  {
281  std::ostringstream err;
282  err << "No branching fraction exists for the requested final states:";
283  for (auto particle = key.begin(); particle != key.end(); ++particle)
284  {
285  err << " {" << particle->first << ", " << particle->second << "}";
286  }
287  model_error().raise(LOCAL_INFO,err.str());
288  }
289  return channels.at(key).second;
290  }
292 
297  template <typename... Args>
298  std::pair<double, double> BF_with_error(std::pair<int,int> p1, Args... args) const
299  {
300  std::pair<int,int> particles[] = {p1, args...};
301  std::multiset< std::pair<int,int> > key(particles, particles+sizeof...(Args)+1);
302  if (channels.find(key) == channels.end())
303  {
304  std::ostringstream err;
305  err << "No branching fraction exists for the requested final states:";
306  for (auto particle = key.begin(); particle != key.end(); ++particle)
307  {
308  err << " {" << particle->first << ", " << particle->second << "}";
309  }
310  model_error().raise(LOCAL_INFO,err.str());
311  }
312  return channels.at(key);
313  }
314 
315  template <typename... Args>
316  std::pair<double, double> BF_with_error(str p1, Args... args) const
317  {
318  std::multiset< std::pair<int,int> > key;
319  construct_key(key, p1, args...);
320  if (channels.find(key) == channels.end())
321  {
322  std::ostringstream err;
323  err << "No branching fraction exists for the requested final states:";
324  for (auto particle = key.begin(); particle != key.end(); ++particle)
325  {
326  err << " {" << particle->first << ", " << particle->second << "}";
327  }
328  model_error().raise(LOCAL_INFO,err.str());
329  }
330  return channels.at(key);
331  }
333 
336  SLHAea::Block getSLHAea_block(int, str, bool include_zero_bfs=false, const mass_es_pseudonyms& psn=mass_es_pseudonyms()) const;
337  SLHAea::Block getSLHAea_block(int, str, int, bool include_zero_bfs=false, const mass_es_pseudonyms& psn=mass_es_pseudonyms()) const;
338  SLHAea::Block getSLHAea_block(int, std::pair<int,int>, bool include_zero_bfs=false, const mass_es_pseudonyms& psn=mass_es_pseudonyms()) const;
340 
342  double sum_BF() const;
343 
345  double width_in_GeV;
346 
349 
352 
361 
364  std::map< std::multiset< std::pair<int,int> >, std::pair<double, double> > channels;
365 
366  };
367 
368  };
369 
370 
371 }
372 
373 
374 #endif //#defined __decay_table_hpp__
void set_BF(double BF, double error, std::pair< int, int > p1, Args... args)
double BF(str p1, Args... args) const
DecayTable entry class. Holds the info on all decays of a given particle.
Definition: decay_table.hpp:96
double BF(const std::vector< std::pair< int, int > > &) const
Retrieve branching fraction for decay to a given final state.
SLHAea::Block getSLHAea_block(int, std::pair< int, int >, bool include_zero_bfs=false, const mass_es_pseudonyms &psn=mass_es_pseudonyms()) const
Output a decay table entry as an SLHAea DECAY block, using input parameter to identify the entry...
bool has_channel(std::pair< int, int > p1, Args... args) const
std::pair< double, double > BF_with_error(std::pair< int, int > p1, Args... args) const
Retrieve branching fraction and error for decay to a given final state.
double positive_error
Positive error on width.
Entry & at(std::pair< int, int >)
Get entry in decay table for a give particle, throwing an error if particle is absent.
DecayTable()
ConstructorsDefault constructor.
Definition: decay_table.hpp:45
double sum_BF() const
Sum up the partial widths and return the result.
void writeSLHAfile(int SLHA_version, const str &filename, bool include_zero_bfs=false, const mass_es_pseudonyms &psn=mass_es_pseudonyms()) const
Output entire decay table as an SLHA file full of DECAY blocks.
#define LOCAL_INFO
Definition: local_info.hpp:34
Entry & operator()(std::pair< int, int >)
Get entry in decay table for a given particle, adding the particle to the table if it is absent...
General small utility classes, typedefs, etc.
void set_BF(double BF, double error, str p1, Args... args)
double BF_error(std::pair< int, int > p1, Args... args) const
Retrieve branching fraction error for decay to a given final state.
Entry(double width)
Constructor taking total width.
void init(const SLHAea::Block &, int, bool force_SM_fermion_gauge_eigenstates=false)
Initialise a DecayTable Entry using an SLHAea DECAY block.
std::map< std::pair< int, int >, Entry > particles
The actual underlying map. Just iterate over this directly if you need to iterate over all particles ...
Definition: decay_table.hpp:92
SLHAea::Block getSLHAea_block(int, str, bool include_zero_bfs=false, const mass_es_pseudonyms &psn=mass_es_pseudonyms()) const
Output this entry as an SLHAea DECAY block, using input parameter to identify the mother particle...
double BF(std::pair< int, int > p1, Args... args) const
Routines to help translate between SLHA2 sfermions and SLHA1 (or similar) sfermions.
double BF_error(str p1, Args... args) const
SLHAea::Coll SLHAstruct
Less confusing name for SLHAea container class.
GAMBIT error class.
Definition: exceptions.hpp:136
std::pair< double, double > BF_with_error(str p1, Args... args) const
void check_particles_exist(std::multiset< std::pair< int, int > > &) const
Make sure all particles listed in a set are actually known to the GAMBIT particle database...
static void construct_key(std::multiset< std::pair< int, int > > &key, str p1, Args... args)
Templated version for long names.
double width_in_GeV
Total particle width (in GeV)
str calculator_version
Version of the code used for calculating this entry.
bool has_channel(const std::vector< std::pair< int, int > > &) const
Check if a given final state exists in this DecayTable::Entry.
partmap & ParticleDB()
Database accessor function.
Definition: partmap.cpp:36
str calculator
Name of the code (backend or otherwise) used for calculating this entry.
std::string str
Shorthand for a standard string.
Definition: Analysis.hpp:35
str errors
Errors from the calculator.
double negative_error
Negative error on width.
str warnings
Warnings from the calculator.
bool has_channel(str p1, Args... args) const
GAMBIT native decay table class.
Definition: decay_table.hpp:35
static void construct_key(std::multiset< std::pair< int, int > > &key, str p1, int i1, Args... args)
Templated version for short names and indices.
SLHAea helper functions using spectrum objects.
Class definitions for GAMBIT particle database.
Exception objects required for standalone compilation.
static void construct_key(std::multiset< std::pair< int, int > > &)
Construct a set of particles from a variadic list of full names or short names and indicesBase functi...
std::map< std::multiset< std::pair< int, int > >, std::pair< double, double > > channels
The actual underlying map of channels to their BFs.
void check_BF_validity(double, double, std::multiset< std::pair< int, int > > &) const
Make sure no NaNs have been passed to the DecayTable by nefarious backends.
SLHAstruct getSLHAea(int SLHA_version, bool include_zero_bfs=false, const mass_es_pseudonyms &psn=mass_es_pseudonyms()) const
Output entire decay table as an SLHAea file full of DECAY blocks.
error & model_error()
Model errors.
TODO: see if we can use this one:
Definition: Analysis.hpp:33
void set_BF(double, double, const std::vector< std::pair< int, int > > &)
Set branching fraction for decay to a given final state.
Entry()
Default constructor.