gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-252-gf9a3f78
a Global And Modular Bsm Inference Tool

Base class for defining the required contents of a SubSpectrum object. More...

#include <subspectrum_contents.hpp>

Inheritance diagram for Gambit::SubSpectrumContents:
Collaboration diagram for Gambit::SubSpectrumContents:

Public Member Functions

std::string getName () const
 
std::vector< SpectrumParameterall_parameters () const
 Function to retreive all parameters. More...
 
std::vector< SpectrumParameterall_parameters_with_tag (Par::Tags tag) const
 Function to retreive all parameters matching a certain tag. More...
 
std::vector< SpectrumParameterall_parameters_with_tag_and_shape (Par::Tags tag, std::vector< int > &shape) const
 Function to retrieve all parameters matching a certain tag and shape. More...
 
void verify_contents (const SubSpectrum &spec) const
 Function to verify that a SubSpectrum wrapper contains everything that this class says it should. More...
 

Protected Member Functions

void addParameter (const Par::Tags tag, const std::string &name, const std::vector< int > &shape=initVector(1))
 Add a parameter to the Contents object. More...
 
void setName (const std::string &name)
 Set the name of this Contents object (i.e. the name of the model to which this spectrum data applies) More...
 

Private Attributes

std::vector< SpectrumParameterparameters
 Vector defining what parameters a wrapper must contain. More...
 
std::string my_name
 Name of SubSpectrumContents class (for more helpful error messages) More...
 

Detailed Description

Base class for defining the required contents of a SubSpectrum object.

Definition at line 50 of file subspectrum_contents.hpp.

Member Function Documentation

◆ addParameter()

void Gambit::SubSpectrumContents::addParameter ( const Par::Tags  tag,
const std::string &  name,
const std::vector< int > &  shape = initVector(1) 
)
protected

◆ all_parameters()

std::vector< SpectrumParameter > Gambit::SubSpectrumContents::all_parameters ( ) const

◆ all_parameters_with_tag()

std::vector< SpectrumParameter > Gambit::SubSpectrumContents::all_parameters_with_tag ( Par::Tags  tag) const

Function to retreive all parameters matching a certain tag.

Definition at line 44 of file subspectrum_contents.cpp.

References parameters.

Referenced by Gambit::SpecBit::check_perturb_MDM(), Gambit::SpecBit::find_min_lambda_MDM(), Gambit::SpecBit::find_min_lambda_ScalarSingletDM_Z2(), and Gambit::SpecBit::find_min_lambda_ScalarSingletDM_Z3().

45  {
46  std::vector<SpectrumParameter> search_result;
47  for( std::vector<SpectrumParameter>::const_iterator it=parameters.begin(); it!=parameters.end(); ++it )
48  {
49  if(it->tag() == tag) search_result.push_back(*it);
50  }
51  return search_result;
52  }
std::vector< SpectrumParameter > parameters
Vector defining what parameters a wrapper must contain.
Here is the caller graph for this function:

◆ all_parameters_with_tag_and_shape()

std::vector< SpectrumParameter > Gambit::SubSpectrumContents::all_parameters_with_tag_and_shape ( Par::Tags  tag,
std::vector< int > &  shape 
) const

Function to retrieve all parameters matching a certain tag and shape.

Definition at line 55 of file subspectrum_contents.cpp.

References parameters.

56  {
57  std::vector<SpectrumParameter> search_result;
58  for( std::vector<SpectrumParameter>::const_iterator it=parameters.begin(); it!=parameters.end(); ++it )
59  {
60  if(it->tag() == tag and it->shape() == shape) search_result.push_back(*it);
61  }
62  return search_result;
63  }
std::vector< SpectrumParameter > parameters
Vector defining what parameters a wrapper must contain.

◆ getName()

std::string Gambit::SubSpectrumContents::getName ( ) const
inline

Definition at line 64 of file subspectrum_contents.hpp.

References Gambit::SpectrumParameter::my_name, and Gambit::SpectrumParameter::shape().

64 {return my_name;}
std::string my_name
Name of SubSpectrumContents class (for more helpful error messages)
Here is the call graph for this function:

◆ setName()

void Gambit::SubSpectrumContents::setName ( const std::string &  name)
protected

◆ verify_contents()

void Gambit::SubSpectrumContents::verify_contents ( const SubSpectrum spec) const

Function to verify that a SubSpectrum wrapper contains everything that this class says it should.

Verify that the supplied SubSpectrum object conforms to the requirements specified by the Contents class.

Definition at line 67 of file subspectrum_contents.cpp.

References all_parameters(), Gambit::SubSpectrum::has(), LOCAL_INFO, my_name, and Gambit::utils_error().

68  {
69  const std::vector<SpectrumParameter> required_parameters = all_parameters();
70 
71  for(std::vector<SpectrumParameter>::const_iterator it = required_parameters.begin();
72  it != required_parameters.end(); ++it)
73  {
74  const Par::Tags tag = it->tag();
75  const std::string name = it->name();
76  const std::vector<int> shape = it->shape();
77 
78  // Deal with empty shape case
79  if(shape.size()==0)
80  {
81  // ERROR, please use length 1 vector for scalar case
82  std::ostringstream errmsg;
83  errmsg << "Error while verifying contents of SubSpectrum object against SubSpectrumContents object with name \""<<my_name<<"\" !" << std::endl;
84  errmsg << "Encountered a required parameter ("<<Par::toString.at(tag)<<", "<<name<<") with shape.size()==0. This is not allowed; if you want this parameter to be considered a scalar, please set the shape to '1', i.e. std::vector<int> shape = initVector(1). Please fix this parameter in the SubSpectrumContents class." << std::endl;
85  utils_error().forced_throw(LOCAL_INFO,errmsg.str());
86  }
87  // Check scalar case
88  else if(shape.size()==1 and shape[0]==1)
89  {
90  if(not spec.has(tag,name))
91  {
92  // ERROR, Required parameter not found
93  std::ostringstream errmsg;
94  errmsg << "Error while verifying contents of SubSpectrum object against SubSpectrumContents object with name \""<<my_name<<"\" !" << std::endl;
95  errmsg << "Required scalar-valued parameter ("<<Par::toString.at(tag)<<", "<<name<<") is not accessible via subspectrum->get(Par::"<<Par::toString.at(tag)<<", \""<<name<<"\"). Please fix the relevant SubSpectrum wrapper class so that this parameter can be accessed." << std::endl;
96  utils_error().forced_throw(LOCAL_INFO,errmsg.str());
97  }
98  }
99  // Check vector case
100  else if(shape.size()==1 and shape[0]>1)
101  {
102  if(shape[0]<0)
103  {
104  // ERROR, asked for negative length vector
105  std::ostringstream errmsg;
106  errmsg << "Error while verifying contents of SubSpectrum object against SubSpectrumContents object with name \""<<my_name<<"\" !" << std::endl;
107  errmsg << "Encountered a vector-valued required parameter ("<<Par::toString.at(tag)<<", "<<name<<") with negative required length ("<<shape[0]<<")! This is invalid; Please fix this parameter in the SubSpectrumContents class so that the required length is a positive number." << std::endl;
108  utils_error().forced_throw(LOCAL_INFO,errmsg.str());
109  }
110  else
111  {
112  for(int i = 1; i<=shape[0]; ++i) {
113  if(not spec.has(tag,name,i))
114  {
115  // ERROR, Required parameter not found
116  std::ostringstream errmsg;
117  errmsg << "Error while verifying contents of SubSpectrum object against SubSpectrumContents object with name \""<<my_name<<"\" !" << std::endl;
118  errmsg << "An entry of the required vector-valued parameter ("<<Par::toString.at(tag)<<", "<<name<<") with required length "<<shape[0]<<" is not accessible via subspectrum->get(Par::"<<Par::toString.at(tag)<<", \""<<name<<"\", "<<i<<"). Please fix the relevant SubSpectrum wrapper class so that this parameter can be accessed. Keep in mind that you may need to override index_offset() to align the expected indices." << std::endl;
119  utils_error().forced_throw(LOCAL_INFO,errmsg.str());
120  }
121  }
122  }
123  }
124  // Check matrix case
125  else if(shape.size()==2)
126  {
127  if(shape[0]<0 or shape[1]<0)
128  {
129  // ERROR, asked for negative matrix dimensions
130  std::ostringstream errmsg;
131  errmsg << "Error while verifying contents of SubSpectrum object against SubSpectrumContents object with name \""<<my_name<<"\" !" << std::endl;
132  errmsg << "Encountered a matrix-valued required parameter ("<<Par::toString.at(tag)<<", "<<name<<") with at least one negative required dimension (dims = ["<<shape[0]<<", "<<shape[1]<<"])! This is invalid; Please fix the shape settings for this parameter in the SubSpectrumContents so that they are positive numbers." << std::endl;
133  utils_error().forced_throw(LOCAL_INFO,errmsg.str());
134  }
135  else
136  {
137  for(int i = 1; i<=shape[0]; ++i) {
138  for(int j = 1; j<=shape[0]; ++j) {
139  if(not spec.has(tag,name,i,j))
140  {
141  // ERROR, Required parameter not found
142  std::ostringstream errmsg;
143  errmsg << "Error while verifying contents of SubSpectrum object against SubSpectrumContents object with name \""<<my_name<<"\" !" << std::endl;
144  errmsg << "An entry of the required matrix-valued parameter ("<<Par::toString.at(tag)<<", "<<name<<") with required dimensions ("<<shape[0]<<", "<<shape[1]<<") is not accessible via subspectrum->get(Par::"<<Par::toString.at(tag)<<", \""<<name<<"\", "<<i<<", "<<j<<"). Please fix the relevant SubSpectrum wrapper class so that this parameter can be accessed. Keep in mind that you may need to override index_offset() to align the expected indices." << std::endl;
145  utils_error().forced_throw(LOCAL_INFO,errmsg.str());
146  }
147  }
148  }
149  }
150  }
151  // Deal with all other cases
152  else
153  {
154  // ERROR invalid shape
155  std::ostringstream errmsg;
156  errmsg << "Error while verifying contents of SubSpectrum object against SubSpectrumContents object with name \""<<my_name<<"\" !" << std::endl;
157  errmsg << "The specified shape for the required parameter ("<<Par::toString.at(tag)<<", "<<name<<") is invalid. The length of the shape vector is only permitted to be 1 or 2 (received shape vector was "<<shape<<"). Please fix this parameter entry in the SubSpectrumContents class."<<std::endl;
158  utils_error().forced_throw(LOCAL_INFO,errmsg.str());
159  }
160  }
161  // End constructor
162  }
EXPORT_SYMBOLS error & utils_error()
Utility errors.
#define LOCAL_INFO
Definition: local_info.hpp:34
std::string my_name
Name of SubSpectrumContents class (for more helpful error messages)
std::vector< SpectrumParameter > all_parameters() const
Function to retreive all parameters.
Here is the call graph for this function:

Member Data Documentation

◆ my_name

std::string Gambit::SubSpectrumContents::my_name
private

Name of SubSpectrumContents class (for more helpful error messages)

Definition at line 57 of file subspectrum_contents.hpp.

Referenced by setName(), and verify_contents().

◆ parameters

std::vector<SpectrumParameter> Gambit::SubSpectrumContents::parameters
private

Vector defining what parameters a wrapper must contain.

Definition at line 54 of file subspectrum_contents.hpp.

Referenced by addParameter(), all_parameters(), all_parameters_with_tag(), and all_parameters_with_tag_and_shape().


The documentation for this class was generated from the following files: