2 #include <fwk/CentralConfig.h>
3 #include <utl/Branch.h>
4 #include <utl/AugerUnits.h>
5 #include <det/Detector.h>
15 #include <utl/PhysicalFunctions.h>
45 const string atmVersion = (realAtmosphere) ?
"un2" :
"bariloche";
50 topBAtm.
GetChild(atmVersion).
GetChild(monthsDict.at(month)).GetChild(
"Xvert").
Get<
double>();
56 const double DX =
AnalyticDX(r, psi, zenith, Xmax, Xvert, hs, hs2, height);
61 vector<double> Signal = { 0., 0., 0., 0., 0. };
70 const vector<double> a_pars =
73 for (
unsigned int p = 0;
p < a_pars.size(); ++
p)
74 gamma +=
pow(r,
p) * a_pars[
p];
87 Sref =
NKG(r, n, rG, s);
104 double DeltaXmax = 0;
108 const vector<double> a_pars =
111 for (
unsigned int p = 0;
p < a_pars.size(); ++
p)
112 DeltaXmax +=
pow(r,
p) * a_pars[
p];
118 const vector<double> a_pars =
121 for (
unsigned int p = 0;
p < a_pars.size(); ++
p)
122 DeltaX0 +=
pow(r,
p) * a_pars[
p];
130 const vector<double> a_pars =
133 DeltaXref = a_pars[0];
141 const vector<double> a_pars =
144 for (
unsigned int p = 0;
p < a_pars.size(); ++
p)
145 lambda0 +=
pow(r,
p) * a_pars[
p];
153 const vector<double> a_pars =
156 for (
unsigned int p = 0;
p < a_pars.size(); ++
p)
157 lambda1 +=
pow(r,
p) * a_pars[
p];
162 ModifiedGH(DX, Sref, lgE, gamma, DeltaX0, DeltaXmax, DeltaXref, lambda0, 0, 0);
164 const map<string, float> psiconsts = {{
"em", 0.01}, {
"mu", 0.05}, {
"emmu", 0.05}, {
"emhd", 0.02}};
165 const double aziCorrection = exp(psiconsts.at(comp) * r/1000 * (DX-DeltaX0)/lambda0 * cos(psi) * sin(zenith));
167 Spred *= aziCorrection;
169 double hadrComponentFactor = 1.;
171 hadrComponentFactor = 1.1;
173 hadrComponentFactor = 1.;
180 }
else if (comp ==
"mu") {
181 Signal[0] += Rmu * Spred;
182 Signal[2] = Rmu * Spred;
183 }
else if (comp ==
"emmu") {
184 Signal[0] += Rmu * Spred;
185 Signal[3] = Rmu * Spred;
186 }
else if (comp ==
"emhd") {
187 if ((1 + hadrComponentFactor*(Rmu - 1)) > 0) {
188 Signal[0] += (1 + hadrComponentFactor*(Rmu -1)) * Spred;
189 Signal[4] = (1 + hadrComponentFactor*(Rmu -1)) * Spred;
201 vector<vector<double>>
219 const string atmVersion = (realAtmosphere) ?
"un2" :
"bariloche";
223 topBAtm.
GetChild(atmVersion).
GetChild(monthsDict.at(month)).GetChild(
"Xvert").
Get<
double>();
229 const double DX =
AnalyticDX(r, psi, zenith, Xmax, Xvert, hs, hs2, height);
231 vector<vector<double>> vals = {};
236 const vector<string> tags = {
"c",
"ddx",
"t0",
"sigma" };
237 vector<double> function_parameters = { 0., 0., 0., 0. };
239 for (
unsigned short int k = 0; k < function_parameters.size(); ++k) {
241 const vector<string> a_pars = {
"a0",
"a1",
"a2",
"a3",
"a4" };
242 vector<double> a_vals = { 0, 0, 0, 0, 0 };
244 for (
short unsigned int i = 0; i < a_pars.size(); ++i) {
246 vector<double> aa_pars;
250 ERROR(boost::format(
"SPECIFIED TIME QUANTILE NOT VALID: %s\nUSING t00 instead!") % quantile);
254 for (
short unsigned int j = 0; j < aa_pars.size(); ++j) {
256 a_vals[i] += aa_pars[j] *
pow(sin(zenith), j);
260 function_parameters[k] += a_vals[i] *
pow(r, i);
266 const double c = function_parameters[0];
267 const double ddx = function_parameters[1];
268 const double t0 = function_parameters[2];
270 const double sigma = function_parameters[3];
273 vals.push_back({ t, sigma });
281 vector<vector<double>>
290 double planeFrontTimeResidual,
296 vector<vector<double>> traceParameters = {};
298 const vector<vector<double>> t40RelToPF =
\
299 GetTimeQuantile(zenith, r, psi, height, Xmax, detector,
"t40", month, realAtmosphere);
301 vector<vector<double>> signalTraces(5);
302 vector<vector<double>> signalCDFs(5);
303 vector<vector<double>> traceMoments(5);
308 const string atmVersion = (realAtmosphere) ?
"un2" :
"bariloche";
317 const double DX =
AnalyticDX(r, psi, zenith, Xmax, Xvert, hs, hs2, height);
319 unsigned int componentNumber = 0;
323 vector<double> componentTrace;
324 vector<double> componentCDF;
325 vector<double> componentMoments;
327 map<string, map<string, double>> readout = { {
"exp", {{
"a", 0}, {
"b", 0}} },
328 {
"std", {{
"a", 0}, {
"b", 0}} } };
330 for (
const auto& moment : {
"exp",
"std"}) {
332 for (
const auto& linPar : {
"a",
"b"}) {
334 vector<double> ai_vals = {0, 0, 0, 0, 0};
335 const vector<string> ai = {
"a0",
"a1",
"a2",
"a3",
"a4"};
337 for (
unsigned int i=0; i < ai.size(); ++i) {
339 vector<double> aii_vals;
342 for (
unsigned int j=0; j < aii_vals.size(); ++j) {
344 ai_vals[i] += aii_vals[j] *
pow(sin(zenith), j);
350 for (
unsigned int j=0; j < ai_vals.size(); ++j) {
352 readout[moment][linPar] += ai_vals[j] *
pow(r, j);
360 const double ExpA = readout[
"exp"][
"a"];
361 const double ExpB = readout[
"exp"][
"b"];
362 const double StdA = readout[
"std"][
"a"];
363 const double StdB = readout[
"std"][
"b"];
366 const double traceExpectationValue = (ExpA * DX + ExpB < 100) ? 100 : ExpA * DX + ExpB;
367 const double traceStandardDeviation = (StdA * DX + StdB < 100) ? 100 : StdA * DX + StdB;
369 traceMoments[componentNumber] = {traceExpectationValue, traceStandardDeviation};
371 componentMoments = {traceExpectationValue, traceStandardDeviation};
373 const double t40 = t40RelToPF[componentNumber][0] + planeFrontTimeResidual;
380 const double muLogNormalPar = (-10 == planeFrontTimeResidual || muLogNormalParFromt40 != muLogNormalParFromt40) ?
382 muLogNormalParFromt40;
384 traceParameters.push_back({muLogNormalPar, sigmaLogNormalPar});
388 return traceParameters;
406 double planeFrontTimeResidual,
413 vector<double> Sig = {};
414 vector<double> SigUncertainty = {};
416 const double totalSignal =
GetSignal(model, lgE, zenith, r, psi, height, Xmax, Rmu, detector, month, realAtmosphere, useThreshold)[component];
417 const double norm = (normalized != 0) ? totalSignal/normalized : 1.;
418 const vector<double> traceParameters =
GetTraceParameters(zenith, r, psi, height, Xmax, detector, month, realAtmosphere, planeFrontTimeResidual, nsBin)[component];
419 const double mu = traceParameters[0];
420 const double sigma = traceParameters[1];
422 for (
unsigned int i = 0; i < t.size(); ++i) {
424 Sig.push_back(
LogNormalCDF(t[i]/nsBin, mu, sigma) * totalSignal / norm);
428 if (returnValue ==
"cdf" || returnValue ==
"integrated" || returnValue ==
"CDF" || returnValue ==
"total")
431 const double timeUncertaintyRaw =
GetTimeQuantile(zenith, r, psi, height, Xmax, detector,
"t40", month, realAtmosphere)[component][1];
432 const double timeUncertainty = (timeUncertaintyRaw > 10) ? 10 : timeUncertaintyRaw;
434 const double baseline = 1;
436 for (
unsigned int i = 0; i < t.size(); ++i) {
439 double stdSigRaw = 0.;
440 if (detector ==
"WCD") {
446 }
else if (detector ==
"SSD") {
454 const double stdSig = (normalized != 0) ? 1. : stdSigRaw;
460 if (returnValue ==
"std" || returnValue ==
"unc" || returnValue ==
"STD" || returnValue ==
"error") {
462 return SigUncertainty;
466 ERROR(
"GetIntegratedTotalSignal reached end of function without defined return value!");
467 ERROR(
"Define returnValue! Was set to:");
489 double planeFrontTimeResidual,
498 vector<double> sumCompSignals;
499 vector<vector<double>> compSignals;
500 for (
unsigned short int i=1; i<5; ++i ) {
503 detector, month, realAtmosphere, useThreshold, planeFrontTimeResidual, nsBin,
"cdf", i ));
507 for (
unsigned int i=0; i<t.size(); ++i) {
511 for (
unsigned int c=0;
c < compSignals.size(); ++
c) {
513 binSum += compSignals[
c][i];
517 sumCompSignals.push_back(binSum);
521 if (normalized != 0) {
523 for (
unsigned int i=0; i<sumCompSignals.size(); ++i) {
525 sumCompSignals[i] = sumCompSignals[i] * normalized / sumCompSignals[sumCompSignals.size()-1];
531 return sumCompSignals;
constexpr T Sqr(const T &x)
void GetTimeQuantile(const float *const trace, const float sum, const int nT, const float timeUnit, const float f, float &tQ, float &tQ_err)
double SignalStartTimePlaneFront(const double r, const double psi, const double theta, const double DX, const double Xvert, const double hs, const double hs2, const double height)
double ActivationFunctionBackground(const double f, const double fThrsh, const double cThrsh, const double bg)
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
double pow(const double x, const unsigned int i)
Exception for errors encountered when parsing XML.
virtual const std::vector< std::string > & GetComponents() const =0
double ModifiedGH(const double deltaX, const double sRef, const double lgE, const double gamma, const double deltaX0, const double deltaXMax, const double deltaXRef, const double lambda0, const double lambda1, const double lambda2)
Class representing a document branch.
double LogNormalMuFromExpAndStd(const double exp_val, const double std, const double ns_bin)
double LogNormalSigmaFromExpAndStd(const double exp_val, const double std, const double ns_bin)
vector< double > GetSignal(string model, double lgE, double zenith, double r, double psi, double height, double Xmax, double Rmu, string detector, int month, bool realAtmosphere, bool useThreshold)
void GetData(bool &b) const
Overloads of the GetData member template function.
virtual const std::vector< std::string > & GetReducedComponents() const =0
vector< vector< double > > GetTraceParameters(double zenith, double r, double psi, double height, double Xmax, string detector, int month, bool realAtmosphere, double planeFrontTimeResidual, double nsBin)
double AnalyticDX(const double r, const double psi, const double theta, const double Xmax, const double Xvert, const double hs, const double hs2, const double height)
double SignalUncertainty(const ESignalVarianceModel model, const double cosTheta, const double signal)
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
double LogNormalMuFromTimeQuantileAndSigma(const double timeQuantile, const double quantile, const double sigma, const double ns_bin)
vector< double > GetIntegratedTotalSignalSum(vector< double > t, string model, double lgE, double zenith, double r, double psi, double height, double Xmax, double Rmu, string detector, int month, bool realAtmosphere, bool useThreshold, double planeFrontTimeResidual, double nsBin, double normalized)
Main configuration utility.
vector< double > GetIntegratedTotalSignal(vector< double > t, string model, double lgE, double zenith, double r, double psi, double height, double Xmax, double Rmu, string detector, int month, bool realAtmosphere, bool useThreshold, double planeFrontTimeResidual, double nsBin, string returnValue, int component, double normalized)
double SignalUncertainty(const ESignalVarianceModel model, const double cosTheta, const double signal)
double LogNormalPDF(const double x, const double mu, const double sigma)
double LogNormalCDF(const double x, const double mu, const double sigma)
#define ERROR(message)
Macro for logging error messages.
double NKG(const double r, const double n, const double rG, const double s)
virtual const std::map< unsigned int, std::string > & GetMonthsMapReverse() const =0
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)