gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
spectrum_helpers.hpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
22 
23 #ifndef __spectrum_helpers_hpp__
24 #define __spectrum_helpers_hpp__
25 
26 #include <string>
27 #include <set>
28 #include <vector>
29 #include <map>
30 
31 namespace Gambit
32 {
33  typedef std::string str;
34 
36  inline bool within_bounds(const int i, const std::set<int> allowed)
37  {
38  return ( allowed.find(i) != allowed.end() );
39  }
40 
42  namespace Par
43  {
44  enum Tags
45  {
47  Pole_Mass = 0,
58  };
59 
60  // Stick enum values in a vector to help auto-generate maps that use them as keys
61  inline std::vector<Tags> get_all()
62  {
63  std::vector<Tags> vec;
64  vec.push_back(Pole_Mass);
65  vec.push_back(Pole_Mass_1srd_high);
66  vec.push_back(Pole_Mass_1srd_low);
67  vec.push_back(Pole_Mixing);
68  vec.push_back(mass4);
69  vec.push_back(mass3);
70  vec.push_back(mass2);
71  vec.push_back(mass1);
72  vec.push_back(dimensionless);
73  vec.push_back(mass_eigenstate);
74  return vec;
75  }
76 
78  static std::map<Tags,std::string> fill_map()
79  {
80  std::map<Tags,std::string> name;
81  name[Pole_Mass] = "Pole_Mass";
82  name[Pole_Mass_1srd_high] = "Pole_Mass_1srd_high";
83  name[Pole_Mass_1srd_low] = "Pole_Mass_1srd_low";
84  name[Pole_Mixing] = "Pole_Mixing";
85  name[mass4] = "mass4";
86  name[mass3] = "mass3";
87  name[mass2] = "mass2";
88  name[mass1] = "mass1";
89  name[dimensionless] = "dimensionless";
90  name[mass_eigenstate] = "mass4";
91  return name;
92  }
93  static const std::map<Tags,std::string> toString = fill_map();
94  }
95 
98  {
99  private:
100  int my_value;
101  public:
102  int value() const { return my_value; }
103  SpecOverrideOptions(int i) : my_value(i) {}
104  };
105  inline static bool operator==(const SpecOverrideOptions& lhs, const SpecOverrideOptions& rhs)
106  { return lhs.value() == rhs.value(); }
107  static const SpecOverrideOptions use_overrides(0);
108  static const SpecOverrideOptions overrides_only(1);
109  static const SpecOverrideOptions ignore_overrides(2);
110 
113 
114  template <class Fptr>
115  struct FcnInfo1
116  {
117  Fptr fptr;
118  std::set<int> iset1;
119  FcnInfo1() {}
120  FcnInfo1(Fptr p, std::set<int> s)
121  : fptr(p)
122  , iset1(s)
123  {}
124  };
125 
126  template <class Fptr>
127  struct FcnInfo2
128  {
129  Fptr fptr;
130  std::set<int> iset1;
131  std::set<int> iset2;
132  FcnInfo2() {}
133  FcnInfo2(Fptr p, std::set<int> s1, std::set<int> s2)
134  : fptr(p)
135  , iset1(s1)
136  , iset2(s2)
137  {}
138  };
139 
141 
145 
147  struct MapTag {
148  struct Get {};
149  struct Set {};
150  };
151 
153  template <class DerivedSpec, class GetOrSet>
154  struct MapTypes;
155 
158  template <class>
159  struct SpecTraits;
160 
163  template <class DerivedSpec>
164  struct MapTypes<DerivedSpec, MapTag::Get>
165  {
166  // Typedef collection
169  typedef double(Model::*FSptr)(void) const; /* Function pointer signature for Model object member functions with no arguments */
170  typedef double(Model::*FSptr1)(int) const; /* Function pointer signature for Model object member functions with one argument */
171  typedef double(Model::*FSptr2)(int,int) const; /* Function pointer signature for Model object member functions with two arguments */
172  typedef double(DerivedSpec::*FSptrW)(void) const; /* Function pointer signature for DerivedSpec member functions with no arguments */
173  typedef double(DerivedSpec::*FSptr1W)(int) const; /* Function pointer signature for DerivedSpec member functions with one argument */
174  typedef double(DerivedSpec::*FSptr2W)(int,int) const; /* Function pointer signature for DerivedSpec member functions with two arguments */
175  typedef double(*plainfptrM)(const Model&); /* Function pointer for plain functions; used for custom functions */
176  typedef double(*plainfptrM1)(const Model&,int); /* ... with one index */
177  typedef double(*plainfptrM2)(const Model&,int,int); /* ... with two indices */
178  typedef double(*plainfptrI)(const Input&); /* Function pointer for plain functions; used for custom functions */
179  typedef double(*plainfptrI1)(const Input&,int); /* ... with one index */
180  typedef double(*plainfptrI2)(const Input&,int,int); /* with two indices */
181  typedef FcnInfo1<FSptr1> FInfo1; // Structs to help specify valid indices for functions
182  typedef FcnInfo2<FSptr2> FInfo2; // " "
183  typedef FcnInfo1<FSptr1W> FInfo1W; // " "
184  typedef FcnInfo2<FSptr2W> FInfo2W; // " "
189  typedef std::map<str, FSptr> fmap0; /* Typedef for map of strings to Model function pointers */
190  typedef std::map<str, FInfo1> fmap1;/*with an index*/
191  typedef std::map<str, FInfo2> fmap2; /*with 2 indices */
192  typedef std::map<str, FSptrW> fmap0W; /* Typedef for map of strings to DerivedSpec function pointers */
193  typedef std::map<str, FInfo1W> fmap1W;/* with an index*/
194  typedef std::map<str, FInfo2W> fmap2W; /*with 2 indices */
195  typedef std::map<str, plainfptrM> fmap0_extraM; /* map of plain function pointers */
196  typedef std::map<str, FInfo1M> fmap1_extraM; /* map of plain function pointers */
197  typedef std::map<str, FInfo2M> fmap2_extraM; /* map of plain function pointers */
198  typedef std::map<str, plainfptrI> fmap0_extraI; /* map of plain function pointers */
199  typedef std::map<str, FInfo1I> fmap1_extraI; /* map of plain function pointers */
200  typedef std::map<str, FInfo2I> fmap2_extraI; /* map of plain function pointers */
201  };
202 
205  template <class DerivedSpec>
206  struct MapTypes<DerivedSpec, MapTag::Set>
207  {
208  // Typedef collection
211  typedef void(Model::*FSptr)(double); /* Function pointer signature for Model object member functions with no arguments */
212  typedef void(Model::*FSptr1)(int,const double&); /* Function pointer signature for Model object member functions with one argument */
213  typedef void(Model::*FSptr2)(int,int,const double&); /* Function pointer signature for Model object member functions with two arguments */
214  typedef void(DerivedSpec::*FSptrW)(double); /* Function pointer signature for DerivedSpec member functions with no arguments */
215  typedef void(DerivedSpec::*FSptr1W)(double,int); /* Function pointer signature for DerivedSpec member functions with one argument */
216  typedef void(DerivedSpec::*FSptr2W)(double,int,int); /* Function pointer signature for DerivedSpec object member functions with two arguments */
217  typedef void(*plainfptrM)(Model&, double); /* Function pointer for plain functions; used for custom functions */
218  typedef void(*plainfptrM1)(Model&, double, int); /* Function pointer for plain functions; used for custom functions */
219  typedef void(*plainfptrM2)(Model&, double, int, int); /* Function pointer for plain functions; used for custom functions */
220  typedef void(*plainfptrI)(Input&, double); /* Function pointer for plain functions; used for custom functions */
221  typedef void(*plainfptrI1)(Input&, double, int); /* Function pointer for plain functions; used for custom functions */
222  typedef void(*plainfptrI2)(Input&, double, int, int); /* Function pointer for plain functions; used for custom functions */
223  typedef FcnInfo1<FSptr1> FInfo1; // Structs to help specify valid indices for functions
224  typedef FcnInfo2<FSptr2> FInfo2; // " "
225  typedef FcnInfo1<FSptr1W> FInfo1W; // " "
226  typedef FcnInfo2<FSptr2W> FInfo2W; // " "
231  typedef std::map<str, FSptr> fmap0; /* Typedef for map of strings to function pointers */
232  typedef std::map<str, FInfo1> fmap1;/*with an index*/
233  typedef std::map<str, FInfo2> fmap2; /*with 2 indices */
234  typedef std::map<str, FSptrW> fmap0W; /* Typedef for map of strings to DerivedSpec function pointers */
235  typedef std::map<str, FInfo1W> fmap1W;/* with an index*/
236  typedef std::map<str, FInfo2W> fmap2W; /*with 2 indices */
237  typedef std::map<str, plainfptrM> fmap0_extraM; /* map of plain function pointers */
238  typedef std::map<str, FInfo1M> fmap1_extraM; /* map of plain function pointers */
239  typedef std::map<str, FInfo2M> fmap2_extraM; /* map of plain function pointers */
240  typedef std::map<str, plainfptrI> fmap0_extraI; /* map of plain function pointers */
241  typedef std::map<str, FInfo1I> fmap1_extraI; /* map of plain function pointers */
242  typedef std::map<str, FInfo2I> fmap2_extraI; /* map of plain function pointers */
243  };
244 
246 
247 }
248 
249 #endif // #defined __spectrum_helpers_hpp__
Mini helper class to specify behaviour of getters w.r.t. overrides in a type-safe way...
Fully unspecialised MapTypes declaration.
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
SpecTraits< DerivedSpec >::Input Input
FcnInfo2(Fptr p, std::set< int > s1, std::set< int > s2)
SpecTraits< DerivedSpec >::Model Model
std::set< int > iset1
SpecTraits< DerivedSpec >::Input Input
std::vector< Tags > get_all()
Structs to hold function pointers and valid index sets.
FcnInfo1(Fptr p, std::set< int > s)
std::set< int > iset1
Ex-"Running" tags.
bool within_bounds(const int i, const std::set< int > allowed)
Helper function for checking if indices are valid.
hb_ModelParameters void
std::string str
Shorthand for a standard string.
Definition: Analysis.hpp:35
DS5_MSPCTM DS_INTDOF int
Forward declare base traits class which communicates Model and Input typedefs from the wrapper class ...
Definition: spec_head.hpp:59
std::set< int > iset2
std::vector< T > vec(std::vector< T > vector)
Definition: daFunk.hpp:142
SpecTraits< DerivedSpec >::Model Model
TODO: see if we can use this one:
Definition: Analysis.hpp:33