gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
SLHASimpleSpec.hpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
22 
23 #ifndef __SLHASimpleSpec_hpp__
24 #define __SLHASimpleSpec_hpp__
25 
26 #include "gambit/Elements/spec.hpp"
27 
28 namespace Gambit
29 {
30 
33  {
34  protected:
36  SLHAea::Coll data;
40  std::map<int, int> PDG_translation_map;
41 
42  public:
44  SLHAeaModel();
45  SLHAeaModel(const SLHAea::Coll& input);
47 
49  int slha_version() const;
50 
52  const SLHAea::Coll& get_slhaea() const;
53 
55  const std::map<int, int>& PDG_translator() const;
56 
58  double getdata(const std::string& block, int index) const;
59  double getdata(const std::string& block, int i, int j) const;
60  bool checkdata(const std::string& block, int index) const;
61  };
62 
63  template<class Derived>
64  class SLHASimpleSpec : public Spec<Derived>
65  {
66  public:
67  // Grab typedefs from derived wrapper traits class
68  // (only needed because this is a template class, and would have to
69  // qualify the name all over the place in order to use the equivalent
70  // typedef which is inherited from the base class)
73 
74  protected:
75  // Store SLHAea object internally (via wrapper)
76  Model slhawrap;
77 
78  // Dummy placeholder for potential Inputs object
79  Input dummyinput;
80 
81  public:
83 
84  // Constructors/destructors
86  : slhawrap()
87  {}
88 
89  SLHASimpleSpec(const SLHAea::Coll& input_slha)
90  : slhawrap(input_slha)
91  {}
92 
93  virtual ~SLHASimpleSpec() {};
94 
95  // Functions to interface Model and Input objects with the base 'Spec' class
96  // Need both const and non-const versions of it, so that wrapped objects cannot be modified
97  // if the wrapper is const
98  Model& get_Model() { return slhawrap; }
99  Input& get_Input() { return dummyinput; /*unused, but needs to be defined for the interface*/ }
100  const Model& get_Model() const { return slhawrap; }
101  const Input& get_Input() const { return dummyinput; /*unused, but needs to be defined for the interface*/ }
102 
104  void add_to_SLHAea(int, SLHAea::Coll&) const;
105 
107 
109  virtual double GetScale() const
110  {
113  const SLHAea::Coll& data(slhawrap.get_slhaea());
114  double scale = 0.0;
115  try
116  {
117  scale = SLHAea::to<double>(data.at("GAUGE").find_block_def()->at(3));
118  }
119  catch (const std::out_of_range& e)
120  {
121  std::ostringstream errmsg;
122  errmsg << "Could not find block \"GAUGE\" in SLHAea object. Received out_of_range error with message: " << e.what();
123  utils_error().raise(LOCAL_INFO,errmsg.str());
124  }
125  return scale;
126  }
127 
128  virtual void SetScale(double)
129  {
130  // this is actually a bit of a drag since one should go through all the blocks
131  // that have Q defined and set them accordingly. Leave for now.
132  utils_error().raise(LOCAL_INFO,
133  "Call made to SetScale function of SLHASimpleSpec! This is currently not implemented!");
134  }
135 
136  virtual void RunToScaleOverride(double)
137  {
138  utils_error().raise(LOCAL_INFO,
139  "Call made to RunToScale function of SLHASimpleSpec! This is not allowed; this\n"
140  "version of the SubSpectrum wrapper cannot perform RGE It is just a\n"
141  "simple box containing SLHA information read from a file or SLHAea object.\n");
142  }
144 
145  protected:
147 
148  };
149 
151 
153  // NOTE! This is just a kind of catch-all default! Wrappers for particular models
154  // should more carefully extract the model information and perform SLHA2->SLHA1
155  // conversions if required.
156  template<class Derived>
157  void SLHASimpleSpec<Derived>::add_to_SLHAea(int /*slha_version*/, SLHAea::Coll& slha) const
158  {
159  // Get the internal SLHAea data object
160  const SLHAea::Coll& data = get_Model().get_slhaea();
161 
162  // NO version check. Cannot assume that this is required or makes sense for whatever
163  // model this might be. If it does matter, then the wrapper for that model should
164  // replace this function and do the check itself.
165  //int wrapped_slha_version = get_Model().slha_version();
166  //if (slha_version != wrapped_slha_version)
167  //{
168  // std::stringstream x;
169  // x << "Wrapped SLHA file is in SLHA" << wrapped_slha_version << ", but something requested to add it to an SLHAea object in SLHA" << slha_version << " format.";
170  // model_error().raise(LOCAL_INFO, x.str());
171  //}
172 
173  // Make a copy of the internal SLHAea object, remove any SM info from it and add the rest to the slhaea object.
174  // (we will assume that if SM is wanted then it is provided by the SMSimpleSpec wrapper, or similar)
175  SLHAea::Coll data_copy = data;
176  SLHAea::Coll::key_matches target_blocks[4] = { SLHAea::Coll::key_matches("SMINPUTS"), SLHAea::Coll::key_matches("VCKMIN"), SLHAea::Coll::key_matches("UPMNSIN"), SLHAea::Coll::key_matches("MASS") };
177  for (SLHAea::Coll::iterator sblock = slha.begin(); sblock != slha.end(); ++sblock)
178  {
179  for (SLHAea::Coll::iterator dblock = data_copy.begin(); dblock != data_copy.end();)
180  {
181  bool delete_dblock = false;
182  for (int i = 0; i < 3; i++)
183  {
184  if (target_blocks[i](*sblock) and target_blocks[i](*dblock)) delete_dblock = true;
185  }
186  if (delete_dblock) dblock = data_copy.erase(dblock);
187  else ++dblock;
188  }
189  }
190  for (SLHAea::Coll::iterator sblock = slha.begin(); sblock != slha.end();)
191  {
192  if (target_blocks[3](*sblock))
193  {
194  if(slha["MASS"][24].is_data_line()) data_copy["MASS"][24] = slha["MASS"][24];
195  sblock = slha.erase(sblock);
196  }
197  else
198  {
199  ++sblock;
200  }
201  }
202  slha.insert(slha.end(), data_copy.cbegin(), data_copy.cend());
203  }
204 
206 
207 
208 } // end Gambit namespace
209 
210 #endif
Need to forward declare Spec class.
Definition: spec_head.hpp:39
Fully unspecialised MapTypes declaration.
SLHAea::Coll data
SLHAea object.
SLHASimpleSpec(const SLHAea::Coll &input_slha)
EXPORT_SYMBOLS error & utils_error()
Utility errors.
void add_to_SLHAea(int, SLHAea::Coll &) const
Add spectrum information to an SLHAea object.
virtual void SetScale(double)
Manually set the renormalisation scale of parameters somewhat dangerous to allow this but may be need...
SLHAeaModel()
Constructors.
#define LOCAL_INFO
Definition: local_info.hpp:34
const Input & get_Input() const
Some member function definitions from classes in spec_head.hpp.
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.
virtual double GetScale() const
(using bass class version of getSLHAea)
const SLHAea::Coll & get_slhaea() const
Get the internal SLHAea object.
MapTypes< Derived, MapTag::Get > MTget
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...
Forward declare base traits class which communicates Model and Input typedefs from the wrapper class ...
Definition: spec_head.hpp:59
SpecTraits< Derived >::Model Model
const Model & get_Model() const
virtual void RunToScaleOverride(double)
Run spectrum to new scale.
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
Skeleton "model" class which interacts with an SLHAea object.
SpecTraits< Derived >::Input Input