1 #include <evt/GaisserHillas4Parameter.h>
3 #include <utl/MathConstants.h>
4 #include <utl/AugerUnits.h>
5 #include <utl/ErrorLogger.h>
6 #include <utl/LambertW.h>
7 #include <utl/Deprecator.h>
14 using namespace evt::gh;
20 GaisserHillas4Parameter::GaisserHillas4Parameter(
const EFunctionType functionType) :
21 fFunctionType(functionType),
24 for (
int i = 0; i <=
eLast; ++i) {
37 fFunctionType(functionType),
40 for (
int i = 0; i <=
eLast; ++i) {
58 const double Y = (depth -
fXMax)/L;
62 GH = exp(-0.5*
pow(Y, 2));
65 const double p1 = log(1.+R*Y)-R*Y;
66 const double p2 = p1*
pow(R,-2.);
70 double x0 = -(L/R) +
fXMax;
83 const double tmp =
fXMax - x0;
84 return fNMax *
pow((depth - x0) / tmp, tmp/lam) *
85 exp((
fXMax - depth) / lam);
94 os <<
"GH function with 4 parameters" <<
'\n'
98 for (
int i = 0; i <
eLast; ++i)
113 const double exponent = w +
LogGamma(w+1);
115 if (exponent < std::numeric_limits<double>::max_exponent10 *
kLn10)
128 const double wError =
132 const double w1 = w0 + wError;
133 const double w2 = w0 - wError;
135 if (w0 <= 0 || w2 <= 0)
138 const double exponent0 = w0 * (1 - log(w0)) +
LogGamma(w0 + 1);
139 const double exponent1 = w1 * (1 - log(w1)) +
LogGamma(w1 + 1);
140 const double exponent2 = w2 * (1 - log(w2)) +
LogGamma(w2 + 1);
142 const double maxExp = std::numeric_limits<double>::max_exponent10 *
kLn10;
144 if (w0 > maxExp || w1 > maxExp || w2 > maxExp)
147 const double gamma0 = exp(exponent0);
148 const double gamma1 = exp(exponent1);
149 const double gamma2 = exp(exponent2);
151 const double f1 = 0.5 * (gamma1 - gamma2) / gamma0;
177 return left / (left + right);
183 const double X0prime = X0 -
fXMax;
184 return sqrt(
abs(X0prime*lambda));
190 const double X0prime = X0 -
fXMax;
191 return sqrt(lambda/
abs(X0prime));
205 return fXMax - fwhm / R;
212 return fwhm * (log(1 - asym * R) + asym * R) / R / log(0.5);
222 const double X0 =
fXMax - fwhm / R;
223 const double lambda = fwhm * (log(1 - asym * R) + asym * R) / R / log(0.5);
224 const double X0prime = X0 -
fXMax;
225 return sqrt(
abs(X0prime*lambda));
232 const double X0 =
fXMax - fwhm / R;
233 const double lambda = fwhm * (log(1 - asym * R) + asym * R) / R / log(0.5);
234 const double X0prime = X0 -
fXMax;
235 return sqrt(lambda/
abs(X0prime));
253 const double X0prime = -
sqrt(L*L/(R*R));
255 return X0prime +
fXMax;
261 const double X0prime = -
sqrt(L*L/(R*R));
262 const double lambda = R*R *
abs(X0prime);
271 return left / (left + right);
281 ostringstream errMsg;
282 errMsg <<
"no shape parameter available for "
343 ostringstream errMsg;
344 errMsg <<
"no shape parameter available for "
370 if (h <= 0 || h > 1) {
371 ostringstream errMsg;
372 errMsg <<
"Value "<< h <<
" for fraction of NMax not in (0,1]";
378 const double xmax = (
fXMax - x0) / lambda;
379 const double z = -
pow(h, 1/xmax) /
kE;
380 const double xB = -xmax * (branch < 0 ?
LambertW<-1>(z) :
382 return x0 + lambda * xB ;
404 return (exp(-R) * (1+R) - 1) / (R * (exp(-R) - 1));
412 const double asymMin = 0.01;
413 const double asymMax = 0.5;
415 if (asym >= asymMin && asym <= asymMax) {
424 double currAsym = 0.5;
425 rVal.push_back(currR);
426 fVal.push_back(currAsym);
429 const double deltaRfine = 0.05;
430 while (currAsym > 0.4) {
433 rVal.push_back(currR);
434 fVal.push_back(currAsym);
438 const double deltaRCoarse = 1;
439 while (currAsym > asymMin) {
440 currR += deltaRCoarse;
442 rVal.push_back(currR);
443 fVal.push_back(currAsym);
453 ostringstream errMsg;
454 errMsg <<
"Asymmetry value " << asym <<
" out of range [" << asymMin
455 <<
"," << asymMax <<
"]";
501 ostringstream errMsg;
503 <<
" is not a shape parameter of GH type "
552 ostringstream errMsg;
553 errMsg <<
"no external shape parameter for par = " << par
575 const double value,
const double error)
625 ostringstream errMsg;
626 errMsg <<
"no internal shape parameter defined for "
638 Deprecator::GetInstance().Deprecated(
639 "evt::GaisserHillas4Parameter::GetXZero()",
641 "GaisserHillas4Parameter::GetShapeParameter(gh::eX0)");
649 Deprecator::GetInstance().Deprecated(
650 "evt::GaisserHillas4Parameter::GetXZeroError()",
652 "GaisserHillas4Parameter::GetShapeParameterError(gh::eX0)");
660 Deprecator::GetInstance().Deprecated(
661 "evt::GaisserHillas4Parameter::GetLambda()",
663 "GaisserHillas4Parameter::GetShapeParameter(gh::eLambda)");
671 Deprecator::GetInstance().Deprecated(
672 "evt::GaisserHillas4Parameter::GetLambdaError()",
674 "GaisserHillas4Parameter::GetShapeParameterError(gh::eLambda)");
682 Deprecator::GetInstance().Deprecated(
683 "evt::GaisserHillas4Parameter::GetNMaxLambdaCorrelation()",
685 "GaisserHillas4Parameter::GetCorrelationXMaxShapeParameter(gh::eLambda)");
693 Deprecator::GetInstance().Deprecated(
694 "evt::GaisserHillas4Parameter::GetNMaxX0Correlation()",
696 "GaisserHillas4Parameter::GetCorrelationXMaxShapeParameter(gh::eX0)");
704 Deprecator::GetInstance().Deprecated(
705 "evt::GaisserHillas4Parameter::GetXMaxLambdaCorrelation()",
707 "GaisserHillas4Parameter::GetCorrelationXMaxShapeParameter(gh::eLambda)");
715 Deprecator::GetInstance().Deprecated(
716 "evt::GaisserHillas4Parameter::GetXMaxX0Correlation()",
718 "GaisserHillas4Parameter::GetCorrelationXMaxShapeParameter(gh::eX0)");
726 Deprecator::GetInstance().Deprecated(
727 "evt::GaisserHillas4Parameter::GetLambdaX0Correlation()",
729 "GaisserHillas4Parameter::GetCorrelationShapeParameters()");
double GetShapeParameter(const gh::EShapeParameter par) const
access to all variants of shape parameters (see GaisserHillasTypes.h)
unsigned int GetNPoints() const
double GetCorrelationShapeParameters() const
double GetCorrelationXMaxShapeParameter(const gh::EShapeParameter par) const
constexpr T Sqr(const T &x)
EInternalShapeParameter ExternalToInternal(const gh::EShapeParameter par) const
double GetCorrelationNMaxShapeParameter(const gh::EShapeParameter par) const
double GetIntegralError() const
return relative error of integral
double fRhoNMaxShapePar[eLast+1]
double LambertW< 0 >(const double x)
Class to hold collection (x,y) points and provide interpolation between them.
double CalculateR(const double asym) const
std::pair< gh::EShapeParameter, double > ShapeParameter
void SetShapeParameter(const gh::EShapeParameter par, const double value, const double error)
Setters.
double pow(const double x, const unsigned int i)
double InverseLeft(const double h) const
return depth left of XMax for which GH = h*NMax
std::string GetFunctionTypeName(const EFunctionType type)
Exception for reporting variable out of valid range.
double InverseRight(const double h) const
return depth right of XMax for which GH = h*NMax
GaisserHillas4Parameter(const gh::EFunctionType functionType=gh::eClassic)
double GetLambdaX0Correlation() const
double CalcFfromR(const double R)
double LogGamma(const double x)
double abs(const SVector< n, T > &v)
double LambertW(const double x)
double GetXZeroError() const
bool IsInternal(const gh::EShapeParameter par) const
check if parameter "par" is one of the internal shape parameters
Base class for inconsistency/illogicality exceptions.
gh::EShapeParameter InternalToExternal(const EInternalShapeParameter) const
double Eval(const double depth) const
evaluate function a X = depth
double GetXMaxLambdaCorrelation() const
gh::EFunctionType fFunctionType
double Inverse(const double h, const int branch) const
Inverse of GH function. branch = -1 is right of XMax, branch = 0 left of XMax.
Interface class for access to the Gaisser-Hillas parameters.
double fRhoXMaxShapePar[eLast+1]
void SetCorrelationNMaxShapeParameter(const gh::EShapeParameter par, const double rho)
double GetXMaxX0Correlation() const
static utl::TabulatedFunction fRvsAsymTable
std::string GetShapeParameterName(const EShapeParameter par)
double GetShapeParameterError(const gh::EShapeParameter par) const
double GetIntegral() const
calculate integral
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
void SetCorrelationXMaxShapeParameter(const gh::EShapeParameter par, const double rho)
void Dump(std::ostream &os=std::cout) const
dump the parameters
double fShapePar[eLast+1]
double GetNMaxLambdaCorrelation() const
double GetLambdaError() const
double GetNMaxX0Correlation() const
double fShapeParError[eLast+1]