1 #include "UnivTimeKGConfig.h"
3 #include <tls/UnivTimeKGGamma.h>
5 #include <utl/GeometryUtilities.h>
6 #include <utl/AugerUnits.h>
7 #include <utl/Reader.h>
9 #include <Math/PdfFuncMathCore.h>
10 #include <Math/ProbFuncMathCore.h>
11 #include <Math/QuantFuncMathCore.h>
26 namespace UnivTimeKG {
32 GammaTimeModel::GammaTimeModel()
33 :
m(0),
s(0), l(0), moff(0), soff(0) { }
46 for (
unsigned int ipar = 0; ipar <
nParams; ++ipar) {
48 ostringstream stringStream;
49 string baseDir = DATA_DIR;
50 stringStream << baseDir <<
"/Gamma/parameters/"
51 <<
icomp <<
"_" << ipar <<
".xml";
53 Reader XMLReader(stringStream.str(), Reader::eNONE);
64 vector<Polynomial> ipolys;
66 const string ptypes[8] = {
"DX0",
"DX1",
"DX2",
"DX3",
"Zenith0",
"Zenith1",
"Energy0",
"Energy1"};
68 for (
unsigned int j = 0; j <
sizeof(ptypes) /
sizeof(ptypes[0]); ++j) {
91 const double theta,
const double lgE, vector<double>& output)
96 const double r0 = 1e3;
97 const double rn = r / r0;
98 const double DXn = DX / 750;
99 const double lgEn = lgE - 19;
101 for (
unsigned int ipar = 0; ipar <
nParams; ++ipar) {
103 vector<Polynomial> ipoly =
fPolys[ipar];
110 for (
unsigned int i = 0; i < ipoly.size(); ++i) {
124 rpolyval = ipoly[i](rn);
129 pars.push_back(rpolyval);
133 const double pari = pars[0] + DXn * (pars[1] + DXn * (pars[2] + DXn * pars[3]))
134 + sin(theta) * (pars[4] * cos(psi) + pars[5] * DXn)
135 + lgEn * (pars[6] + DXn * pars[7]);
137 output.push_back(pari < 0 ? 0 : pari);
145 const double theta,
const double lgE)
147 vector<double> params;
149 m = params[0] +
moff;
150 s = params[1] +
soff;
182 return ROOT::Math::lognormal_pdf(t,
m,
s, 0);
184 const double lnres = (-TMath::Exp(
l * (log(t) -
m) /
s) /
l /
l
185 -
m /
l /
s + log(t) * (1 /
s /
l - 1)
186 + log(
l) * (1 - 2 /
l /
l) - log(
s)
187 - TMath::LnGamma(1 /
l /
l));
189 return TMath::Exp(lnres);
198 const double t = x[0];
204 return ROOT::Math::lognormal_cdf(t,
m,
s, 0);
206 const double z = (log(t) -
m) /
s;
207 return TMath::Gamma(1 /
l /
l, 1 /
l /
l * TMath::Exp(
l * z));
214 const double xs[] = { t };
223 return ROOT::Math::lognormal_quantile(quantile,
m,
s);
226 return cdfgamma.GetX(quantile);
double invcdf(const double)
Branch GetTopBranch() const
double NormalizeAngleMinusPiPi(const double x)
Normalize angle to lie between -pi and pi (-180 and 180 deg)
Simple polynomial container.
void setShapeParameters(const double DX, const double r, const double psi, const double theta, const double lgE)
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Utility for parsing XML files.
Class representing a document branch.
std::vector< std::vector< utl::Polynomial > > fPolys
void setShapeParametersDirectly(const double mm, const double ss, const double ll)
void GetData(bool &b) const
Overloads of the GetData member template function.
double getShapeParameter(const unsigned int ipar, const std::vector< double > &pars, const double DX)
double cdf_analytical(const double *const x, const double *const p)
std::vector< std::vector< double > > fRpoints
void setParameterOffsets(const double m, const double s)
void CalculateModel(const double DX, const double r, const double psi, const double theta, const double lgE, std::vector< double > &output)