gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
SLHASimpleSpec.cpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
5 //
24 
26 
27 #include <boost/preprocessor/tuple/to_seq.hpp>
28 #include <boost/preprocessor/seq/elem.hpp>
29 #include <boost/preprocessor/seq/for_each_product.hpp>
30 
32 // Relies on "tmp_map" being used as the variable name for the temporary maps
33 // inside the fill_map functions.
34 #define addtomap_EL(r, PRODUCT) \
35 { \
36  str key = BOOST_PP_SEQ_ELEM(0,PRODUCT); /* string map key */ \
37  tmp_map[key] = BOOST_PP_SEQ_ELEM(1,PRODUCT); /* function pointer */ \
38 }
39 
40 #define addtomap(__KEYS,FPTR) BOOST_PP_SEQ_FOR_EACH_PRODUCT(addtomap_EL, (BOOST_PP_TUPLE_TO_SEQ(__KEYS))((FPTR)) )
41 
42 using namespace SLHAea;
43 
44 namespace Gambit
45 {
46 
48 
50  SLHAeaModel::SLHAeaModel()
51  : data()
52  {}
53 
55  SLHAeaModel::SLHAeaModel(const SLHAea::Coll& input)
56  : data(input)
57  {
58  // No idea what kind of model this is, so cannot set valid slha_version. Use "0" for "unknown" or "n/a"
59  // If you write a model-specific derived class from this, be sure to add a sensible check for this and
60  // overwrite what we set here in the base class.
62  }
63 
66 
68  const SLHAea::Coll& SLHAeaModel::get_slhaea() const { return data; }
69 
71  const std::map<int, int>& SLHAeaModel::PDG_translator() const
72  {
73  return PDG_translation_map;
74  }
75 
77 
79  double SLHAeaModel::getdata(const std::string& block, int index) const
80  {
81  double output = 0.0;
82  try
83  {
84  output = to<double>(data.at(block).at(index).at(1));
85  }
86  catch (const std::out_of_range& e)
87  {
88  std::ostringstream errmsg;
89  errmsg << "Error accessing data at index "<<index<<" of block "<<block<<". Please check that the SLHAea object was properly filled." << std::endl;
90  errmsg << "(Received out_of_range error from SLHAea class with message: " << e.what() << ")";
91  utils_error().raise(LOCAL_INFO,errmsg.str());
92  }
93  return output;
94  }
95 
97  double SLHAeaModel::getdata(const std::string& block, int i, int j) const
98  {
99  double output = 0.0;
100  try
101  {
102  output = to<double>(data.at(block).at(i,j).at(2));
103  }
104  catch (const std::out_of_range& e)
105  {
106  std::ostringstream errmsg;
107  errmsg << "Error accessing data at index "<<i<<","<<j<<" of block "<<block<<". Please check that the SLHAea object was properly filled." << std::endl;
108  errmsg << "(Received out_of_range error from SLHAea class with message: " << e.what() << ")";
109  utils_error().raise(LOCAL_INFO,errmsg.str());
110  }
111  return output;
112  }
113 
114  // Check if block and entry exist, 1 index
115  bool SLHAeaModel::checkdata(const std::string& block, int i) const
116  {
117  if (data.find(block) == data.end()) return false;
118 
119  SLHAea::Block::key_type key(1);
120  key[0] = std::to_string(i);
121  if (data.at(block).find(key) != data.at(block).end())
122  return true;
123 
124  return false;
125  }
126 
128 
130 
131 
132 } // end Gambit namespace
133 
134 
greatScanData data
Definition: great.cpp:38
SLHAea::Coll data
SLHAea object.
EXPORT_SYMBOLS error & utils_error()
Utility errors.
SLHAeaModel()
Constructors.
#define LOCAL_INFO
Definition: local_info.hpp:34
Helper base class for simple subspectrum wrappers that want to use SLHAea features.
double getdata(const std::string &block, int index) const
Helper functions to do error checking for SLHAea object contents.
bool checkdata(const std::string &block, int index) const
int slha_version() const
Get the SLHA version of the internal SLHAea object.
const SLHAea::Coll & get_slhaea() const
Get the internal SLHAea object.
const std::map< int, int > & PDG_translator() const
PDG code translation map, for special cases where an SLHA file has been read in and the PDG codes cha...
int wrapped_slha_version
SLHA version of SLHAea object.
std::map< int, int > PDG_translation_map
PDG translation map (e.g. from SLHA1 to SLHA2 for MSSMskeleton)
TODO: see if we can use this one:
Definition: Analysis.hpp:33