GHShapeParameters.cc
Go to the documentation of this file.
1 #include "GHShapeParameters.h"
2 #include <evt/GaisserHillas4Parameter.h>
3 #include <utl/Branch.h>
4 #include <utl/UnitGrammar.h>
5 #include <sstream>
6 using namespace std;
7 
8 using namespace evt;
9 using namespace evt::gh;
10 using namespace utl;
11 
12 namespace FdEnergyDepositFinderKG {
13 
14  inline
16  nameToGHEnum(const string name, const EFunctionType ghType)
17  {
18  EShapeParameter par = eX0;
19  if (name == "eX0")
20  par = eX0;
21  else if (name == "eLambda")
22  par = eLambda;
23  else if (name == "eFWHM")
24  par = eFWHM;
25  else if (name == "eAsym")
26  par = eAsym;
27  else if (name == "eUspL")
28  par = eUSP_L;
29  else if (name == "eUspR")
30  par = eUSP_R;
31  else {
32  ostringstream errMsg;
33  errMsg << "string to enum conversion not implemented for parameter "
34  << name;
35  throw XMLParseException(errMsg.str());
36  }
37 
38  // consistency check
39  GaisserHillas4Parameter tmp(ghType);
40  if (!tmp.IsInternal(par)) {
41  ostringstream errMsg;
42  errMsg << "incompatible shape parameter "
44  << ", from XML name " << name
45  << ", GH type is "
46  << GetFunctionTypeName(ghType);
47  throw XMLParseException(errMsg.str());
48  }
49 
50  return par;
51  }
52 
53  GHShapeParameters::GHShapeParameters(const Branch& config)
54  {
55  const string ghType = config.GetChild("gaisserHillasType").Get<string>();
56  if (ghType == "eClassic")
57  fGHType = eClassic;
58  else if (ghType == "eWidth")
59  fGHType = eWidth;
60  else if (ghType == "eUSP")
61  fGHType = eUSP;
62  else {
63  throw XMLParseException("Unknown GH type " + ghType);
64  }
65  const Branch ghParB = config.GetChild("gaisserHillasShapeParameters",
66  "type=" + ghType);
67  if (ghParB) {
68  AugerUnitParser up;
69  for (int index = 0; index < 2; ++index) {
70  const EOneTwo i = EOneTwo(index);
71  ostringstream attribute;
72  attribute << "id=" << index + 1;
73  const Branch par = ghParB.GetChild("par", attribute.str());
74  fConstraint[i] = par.GetChild("mean").Get<Function>();
75  fConstraintVariance[i] = par.GetChild("sigma").Get<Function>();
76  fUnit[i] = par.GetChild("unit").Get<Function>();
77  fParType[i] = nameToGHEnum(par.GetChild("name").Get<string>(), fGHType);
78  const vector<double> range = par.GetChild("range").Get<vector<double> >();
79  fRangeMin[i] = range[0]; // range.size() == 2 guaranteed by xsd
80  fRangeMax[i] = range[1];
81  fStep[i] = par.GetChild("step").Get<double>();
82  }
83  }
84  else {
85  ostringstream errMsg;
86  errMsg << "no configuration found for GH type "
87  << GetFunctionTypeName(fGHType);
88  throw XMLParseException(errMsg.str());
89  }
90  }
91 
92  GHShapeParameters::GHShapeParameters() :
93  fGHType(eClassic)
94  {
95  for (unsigned int i = 0; i < eTwo + 1; ++i) {
96  //fConstraint[i] = 0;
97  //fConstraintVariance[i] = 0;
98  fRangeMin[i] = 0;
99  fRangeMax[i] = 0;
100  fStep[i] = 0;
101  }
102  }
103 }
EShapeParameter nameToGHEnum(const string name, const EFunctionType ghType)
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
Exception for errors encountered when parsing XML.
std::string GetFunctionTypeName(const EFunctionType type)
T Get() const
Definition: Branch.h:271
Class representing a document branch.
Definition: Branch.h:107
bool IsInternal(const gh::EShapeParameter par) const
check if parameter &quot;par&quot; is one of the internal shape parameters
Evaluate functions given in a string. The real work is done by the ExpressionParser class...
Definition: Function.h:27
std::string GetShapeParameterName(const EShapeParameter par)
Gaisser Hillas with 4 parameters.

, generated on Tue Sep 26 2023.