Shift.cxx
Go to the documentation of this file.
2 
4  const std::string &name,
5  std::unordered_map<std::string, double> &vars,
6  std::function<void (double &x)> func
7 )
8 {
9  auto it = vars.find(name);
10  if (it == vars.end()) {
11  return;
12  }
13 
14  func(it->second);
15 }
16 
18  const std::string &name,
19  std::unordered_map<std::string, std::vector<double>> &vars,
20  std::function<void (double &x)> func
21 )
22 {
23  auto it = vars.find(name);
24  if (it == vars.end()) {
25  return;
26  }
27 
28  for (auto &x : it->second) {
29  func(x);
30  }
31 }
32 
34  const std::string &name,
35  std::unordered_map<std::string, double> &vars,
36  double factor
37 )
38 {
39  mapScalarVar(name, vars, [factor] (double &x) { x = factor * x; });
40 }
41 
43  const std::string &name,
44  std::unordered_map<std::string, std::vector<double>> &vars,
45  double factor
46 )
47 {
48  mapVectorVar(name, vars, [factor] (double &x) { x = factor * x; });
49 }
50 
51 double Shift::getScale() const
52 {
53  return scale;
54 }
55 
56 void Shift::setScale(double value)
57 {
58  scale = value;
59 }
60 
62  : scale(scale)
63 { }
64 
const XML_Char * name
Definition: expat.h:151
double scale
Definition: Shift.h:9
static void mapVectorVar(const std::string &name, std::unordered_map< std::string, std::vector< double >> &vars, std::function< void(double &x)> func)
Definition: Shift.cxx:17
set< int >::iterator it
static void mapScalarVar(const std::string &name, std::unordered_map< std::string, double > &vars, std::function< void(double &x)> func)
Definition: Shift.cxx:3
void setScale(double value)
Definition: Shift.cxx:56
const XML_Char int const XML_Char * value
Definition: expat.h:331
double func(double x, double y)
const std::map< std::pair< std::string, std::string >, Variable > vars
double getScale() const
Definition: Shift.cxx:51
Shift(double scale)
Definition: Shift.cxx:61
static void scaleVectorVar(const std::string &name, std::unordered_map< std::string, std::vector< double >> &vars, double factor)
Definition: Shift.cxx:42
static void scaleScalarVar(const std::string &name, std::unordered_map< std::string, double > &vars, double factor)
Definition: Shift.cxx:33
enum BeamMode string