gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
subspectrum.hpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
25 
26 #ifndef __subspectrum_hpp__
27 #define __subspectrum_hpp__
28 
29 #include <map>
30 #include <set>
31 #include <cfloat>
32 #include <sstream>
33 
34 #include "gambit/Utils/cats.hpp"
41 
42 
43 // Particle database access
44 #define PDB Models::ParticleDB()
45 
46 namespace Gambit
47 {
48 
50  #define vfcn_error(local_info) \
51  utils_error().forced_throw(local_info,"This virtual function (of SubSpectrum object) has not been overridden in the derived class! (name = "+getName()+")")
52 
53  class SubSpectrum;
54 
56  template <class MapTypes>
58  {
59  typename MapTypes::fmap0 map0;
60  typename MapTypes::fmap1 map1;
61  typename MapTypes::fmap2 map2;
62  typename MapTypes::fmap0W map0W;
63  typename MapTypes::fmap1W map1W;
64  typename MapTypes::fmap2W map2W;
65  typename MapTypes::fmap0_extraM map0_extraM;
66  typename MapTypes::fmap1_extraM map1_extraM;
67  typename MapTypes::fmap2_extraM map2_extraM;
68  typename MapTypes::fmap0_extraI map0_extraI;
69  typename MapTypes::fmap1_extraI map1_extraI;
70  typename MapTypes::fmap2_extraI map2_extraI;
71  };
72 
74  struct OverrideMaps
75  {
76  std::map<str,double> m0; // No indices
77  std::map<str,std::map<int,double>> m1; // One index
78  std::map<str,std::map<int,std::map<int,double>>> m2; // Two indices
79  /* e.g. retrieve like this: contents = m2[name][i][j]; */
80  };
81 
82 
83 
85  // Includes facilities for running RGEs
86  // This is the interface class that most module-writers see
88  {
89 
90  public:
92  SubSpectrum() : override_maps(create_override_maps()) {}
93  virtual ~SubSpectrum() {}
95 
97 
99  virtual std::string getName() const = 0;
100 
102  virtual std::unique_ptr<SubSpectrum> clone() const = 0;
103 
105  virtual void writeSLHAfile(int, const str&) const;
106 
108  virtual SLHAstruct getSLHAea(int) const;
109 
111  virtual void add_to_SLHAea(int, SLHAstruct&) const {}
112 
117  virtual int get_numbers_stable_particles() const { vfcn_error(LOCAL_INFO); return -1; }
118 
122  virtual double hard_upper() const {return DBL_MAX;}
123  virtual double soft_upper() const {return DBL_MAX;}
124  virtual double soft_lower() const {return 0.;}
125  virtual double hard_lower() const {return 0.;}
126 
129 
131  virtual void RunToScaleOverride(double) { vfcn_error(LOCAL_INFO); }
133  virtual double GetScale() const { vfcn_error(LOCAL_INFO); return -1;}
136  virtual void SetScale(double) { vfcn_error(LOCAL_INFO); }
137 
139 
143  // Behaviour modified by "behave" integer:
144  // behave = 0 -- If running beyond soft limit requested, halt at soft limit
145  // (assumes hard limits outside of soft limits; but this is not enforced)
146  // behave = 1 -- If running beyond soft limit requested, throw warning
147  // " " hard limit " , throw error
148  // behave = anything else -- Ignore limits and attempt running to requested scale
149  void RunToScale(double scale, const int behave = 0);
150 
152 
153  /* Getters and checker declarations for parameter retrieval with zero, one, and two indices
154  Note optional arguments:
155  first bool; "check_overrides". Set to SafeBool(false) to disable matching on override entries
156  second bool; "check_antiparticle". Set to SafeBool(false) to disable matching on antiparticle entries */
157  virtual bool has(const Par::Tags, const str&, const SpecOverrideOptions=use_overrides, const SafeBool check_antiparticle = SafeBool(true)) const = 0;
158  virtual double get(const Par::Tags, const str&, const SpecOverrideOptions=use_overrides, const SafeBool check_antiparticle = SafeBool(true)) const = 0;
159  virtual bool has(const Par::Tags, const str&, const int, const SpecOverrideOptions=use_overrides, const SafeBool check_antiparticle = SafeBool(true)) const = 0;
160  virtual double get(const Par::Tags, const str&, const int, const SpecOverrideOptions=use_overrides, const SafeBool check_antiparticle = SafeBool(true)) const = 0;
161  virtual bool has(const Par::Tags, const str&, const int, const int, const SpecOverrideOptions=use_overrides) const = 0;
162  virtual double get(const Par::Tags, const str&, const int, const int, const SpecOverrideOptions=use_overrides) const = 0;
163 
164  /* Setter declarations, for setting parameters in a derived model object,
165  and for overriding model object values with values stored outside
166  the model object (for when values cannot be inserted back into the
167  model object)
168  Note; these are NON-CONST */
169  virtual void set(const Par::Tags, const double, const str&, const SafeBool check_antiparticle = SafeBool(true)) = 0;
170  virtual void set(const Par::Tags, const double, const str&, const int, const SafeBool check_antiparticle = SafeBool(true)) = 0;
171  virtual void set(const Par::Tags, const double, const str&, const int, const int) = 0;
172 
173  /* The parameter overrides are handled entirely by this base class, so
174  they are not virtual.
175  optional arguments:
176  allow_new: Allow "overriding" non-existent parameters if 'true'..
177  decouple: If allow_new=true AND decouple=true, allows adding separate particle and antiparticle values. */
178  void set_override(const Par::Tags, const double, const str&, const bool allow_new = false, const bool decouple = false);
179  void set_override(const Par::Tags, const double, const str&, const int, const bool allow_new = false, const bool decouple = false);
180  void set_override(const Par::Tags, const double, const str&, const int, const int, const bool allow_new = false);
181 
182  /* Helpers for override functions which take parameter names and indices as vectors, and
183  loop over them, to make it easy to set many parameters to the same value.
184  No two-index versions at the moment, but could be added if needed. */
185  void set_override_vector(const Par::Tags, const double, const std::vector<str>&, const bool allow_new = false, const bool decouple = false);
186  void set_override_vector(const Par::Tags, const double, const std::vector<str>&, const std::vector<int>, const bool allow_new = false, const bool decouple = false);
187  void set_override_vector(const Par::Tags, const double, const std::vector<str>&, const int, const bool allow_new = false, const bool decouple = false);
188  void set_override_vector(const Par::Tags, const double, const str&, const std::vector<int>, const bool allow_new = false, const bool decouple = false);
189 
190  /* Overloads of getter/checker functions to allow access using PDG codes */
191  /* as defined in Models/src/particle_database.cpp */
192  /* These don't have to be virtual; they just call the virtual functions in the end. */
193  bool has(const Par::Tags, const int, const int,
194  const SpecOverrideOptions=use_overrides,
195  const SafeBool check_antiparticle = SafeBool(true)) const; /* Input PDG code plus context integer */
196 
197  double get(const Par::Tags, const int, const int,
198  const SpecOverrideOptions=use_overrides,
199  const SafeBool check_antiparticle = SafeBool(true)) const; /* Input PDG code plus context integer */
200 
201  bool has(const Par::Tags, const std::pair<int,int>,
202  const SpecOverrideOptions=use_overrides,
203  const SafeBool check_antiparticle = SafeBool(true)) const; /* Input PDG code plus context integer */
204 
205  double get(const Par::Tags, const std::pair<int,int>,
206  const SpecOverrideOptions=use_overrides,
207  const SafeBool check_antiparticle = SafeBool(true)) const; /* Input PDG code plus context integer */
208 
209  bool has(const Par::Tags, const std::pair<str,int>,
210  const SpecOverrideOptions=use_overrides,
211  const SafeBool check_antiparticle = SafeBool(true)) const; /* Input short name plus index */
212 
213  double get(const Par::Tags, const std::pair<str,int>,
214  const SpecOverrideOptions=use_overrides,
215  const SafeBool check_antiparticle = SafeBool(true)) const; /* Input short name plus index */
216 
217  /* Getters which first check the sanity of the thing they are returning */
218  /* These don't have to be virtual; they just call the virtual functions in the end. */
219  double safeget(const Par::Tags, const str&,
220  const SpecOverrideOptions=use_overrides,
221  const SafeBool check_antiparticle = SafeBool(true)) const;
222 
223  double safeget(const Par::Tags, const str&, const int,
224  const SpecOverrideOptions=use_overrides,
225  const SafeBool check_antiparticle = SafeBool(true)) const;
226 
227  double safeget(const Par::Tags, const str&, const int, const int,
228  const SpecOverrideOptions=use_overrides) const;
229 
230  double safeget(const Par::Tags, const int, const int,
231  const SpecOverrideOptions=use_overrides,
232  const SafeBool check_antiparticle = SafeBool(true)) const; /* Input PDG code plus context integer */
233 
234  double safeget(const Par::Tags, const std::pair<int,int>,
235  const SpecOverrideOptions=use_overrides,
236  const SafeBool check_antiparticle = SafeBool(true)) const; /* Input PDG code plus context integer */
237 
238  double safeget(const Par::Tags, const std::pair<str,int>,
239  const SpecOverrideOptions=use_overrides,
240  const SafeBool check_antiparticle = SafeBool(true)) const; /* Input short name plus index */
241 
243 
244  /* Input PDG code plus context integer */
245  void set_override(const Par::Tags, const double, const int, const int, const bool allow_new = false, const bool decouple = false);
246  void set_override(const Par::Tags, const double, const std::pair<int,int>, const bool allow_new = false, const bool decouple = false);
247 
248  /* Input short name plus index */
249  void set_override(const Par::Tags, const double, const std::pair<str,int>, const bool allow_new = false, const bool decouple = false);
250 
252 
254 
255 
257  virtual const std::map<int, int>& PDG_translator() const { return empty_map; }
258 
259  private:
260 
261  const std::map<int, int> empty_map;
262 
264  static std::map<Par::Tags,OverrideMaps> create_override_maps();
265 
266  protected:
268  std::map<Par::Tags,OverrideMaps> override_maps;
269 
270  };
271 
272 } // end namespace Gambit
273 
274 // Undef the various helper macros to avoid contaminating other files
275 #undef PDB
276 
277 #endif
Mini helper class to specify behaviour of getters w.r.t. overrides in a type-safe way...
DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry double
virtual double soft_upper() const
MapTypes::fmap1W map1W
Definition: subspectrum.hpp:63
MapTypes::fmap0_extraM map0_extraM
Definition: subspectrum.hpp:65
virtual int get_numbers_stable_particles() const
There may be more than one new stable particle this method will tell you how many.
virtual void add_to_SLHAea(int, SLHAstruct &) const
Add spectrum information to an SLHAea object (if possible)
Struct to hold collections of function pointer maps to be filled by derived classes.
Definition: subspectrum.hpp:57
MapTypes::fmap1_extraI map1_extraI
Definition: subspectrum.hpp:69
A replacement type for &#39;bool&#39; which does not allow automatic conversion to/from &#39;int&#39; etc...
#define LOCAL_INFO
Definition: local_info.hpp:34
MapTypes::fmap2W map2W
Definition: subspectrum.hpp:64
virtual double GetScale() const
Returns the renormalisation scale of parameters.
virtual void RunToScaleOverride(double)
Run spectrum to new scale.
std::map< str, std::map< int, std::map< int, double > > > m2
Definition: subspectrum.hpp:78
virtual const std::map< int, int > & PDG_translator() const
TODO: extra PDB overloads to handle all the one and two index cases (well all the ones that are feasi...
SubSpectrum()
Constructors/destructors.
Definition: subspectrum.hpp:92
General small utility functions.
#define vfcn_error(local_info)
Helper macro for throwing errors in base class versions of virtual functions.
Definition: subspectrum.hpp:50
SLHAea::Coll SLHAstruct
Less confusing name for SLHAea container class.
MapTypes::fmap0_extraI map0_extraI
Definition: subspectrum.hpp:68
const std::map< int, int > empty_map
virtual double hard_lower() const
MapTypes::fmap2_extraM map2_extraM
Definition: subspectrum.hpp:67
MapTypes::fmap0 map0
Definition: subspectrum.hpp:59
virtual double soft_lower() const
std::string str
Shorthand for a standard string.
Definition: Analysis.hpp:35
DS5_MSPCTM DS_INTDOF int
MapTypes::fmap1_extraM map1_extraM
Definition: subspectrum.hpp:66
MapTypes::fmap1 map1
Definition: subspectrum.hpp:60
std::map< str, std::map< int, double > > m1
Definition: subspectrum.hpp:77
Virtual base class for interacting with spectrum generator output.
Definition: subspectrum.hpp:87
virtual void SetScale(double)
Manually set the renormalisation scale of parameters somewhat dangerous to allow this but may be need...
SLHAea helper functions using spectrum objects.
Class definitions for GAMBIT particle database.
Exception objects required for standalone compilation.
std::string getName(hid_t dset_id)
Get name of dataset.
Definition: hdf5tools.cpp:723
MapTypes::fmap0W map0W
Definition: subspectrum.hpp:62
virtual ~SubSpectrum()
Definition: subspectrum.hpp:93
Definition of struct to hold various override values for a given ParamTag.
Definition: subspectrum.hpp:74
Helpers for using the spectrum and subspectrum classes.
std::map< Par::Tags, OverrideMaps > override_maps
Map of override maps.
MapTypes::fmap2 map2
Definition: subspectrum.hpp:61
virtual double hard_upper() const
Limits to RGE running; warning/error raised if running beyond these is attempted. ...
MapTypes::fmap2_extraI map2_extraI
Definition: subspectrum.hpp:70
TODO: see if we can use this one:
Definition: Analysis.hpp:33
Concatenation macros.
std::map< str, double > m0
Definition: subspectrum.hpp:76