27 #define UNUSED(V) ((void) V)
32 #define LEN(x) ((sizeof(x)/sizeof(0[x]))/((size_t)(!(sizeof(x) % sizeof(0[x])))))
36 int isclose(
double a,
double b,
double rel_tol,
double abs_tol)
42 return fabs(a-b) <= fmax(rel_tol*fmax(fabs(a),fabs(b)),abs_tol);
45 using namespace genie;
46 using namespace genie::flux;
52 double emin, emax, value, expected;
55 sprintf(filename,
"%s/src/contrib/test/fmax20_i0403z.sno_nue", getenv(
"GENIE"));
58 atmo_flux_driver =
dynamic_cast<GAtmoFlux *
>(bartol_flux);
72 expected = atmo_flux_driver->
GetFlux(12);
76 if (value != expected) {
77 sprintf(err,
"GetTotalFlux() = %f which is not equal to GetFlux(12) = %f", value, expected);
81 delete atmo_flux_driver;
86 delete atmo_flux_driver;
95 double emin, emax, value, expected;
98 sprintf(filename,
"%s/src/contrib/test/fmax20_i0403z.sno_nue", getenv(
"GENIE"));
101 atmo_flux_driver =
dynamic_cast<GAtmoFlux *
>(bartol_flux);
118 if (value != expected) {
119 sprintf(err,
"GetTotalFlux(%.2f,%.2f) = %f which is not equal to the expected total flux = %f", emin, emax, value, expected);
133 if (value != expected) {
134 sprintf(err,
"GetTotalFlux(%.1e,%.1e) = %f, but expected %f!", emin, emax, value, expected);
148 if (value != expected) {
149 sprintf(err,
"GetTotalFlux(%.1e,%.1e) = %f, but expected %f!", emin, emax, value, expected);
161 expected = atmo_flux_driver->
GetFlux(12,emin)*(emax-emin);
163 if (!
isclose(value,expected,1
e-5,0)) {
164 sprintf(err,
"GetTotalFlux(%.3f,%.3f) = %f, but expected %f!", emin, emax, value, expected);
178 if (!
isclose(value,expected,1
e-5,0)) {
179 sprintf(err,
"GetTotalFlux(%.3f,%.3f) = %f, but expected %f!", emin, emax, value, expected);
183 delete atmo_flux_driver;
188 delete atmo_flux_driver;
201 int main(
int argc,
char **argv)
218 if (!test.
test(err)) {
219 printf(
"[\033[92mok\033[0m] %s\n", test.
name);
221 printf(
"[\033[91mfail\033[0m] %s: %s\n", test.
name, err);
#define UNUSED(V)
Program used for testing the GAtmoFlux class.
double GetTotalFluxInEnergyRange(void)
double GetFlux(int flavour)
int main(int argc, char **argv)
static constexpr double b
void ForceMaxEnergy(double emax)
static constexpr double GeV
static Messenger * Instance(void)
int testGetTotalFluxInEnergyRange(char *err)
int testGetTotalFlux(char *err)
int isclose(double a, double b, double rel_tol, double abs_tol)
int testFunction(char *err)
double GetTotalFlux(void)
A more convenient interface to the log4cpp Message Service.
void SetPriorityLevel(const char *stream, log4cpp::Priority::Value p)
void AddFluxFile(int neutrino_pdg, string filename)
A base class for the FLUKA, BGLRS and ATMNC atmo. nu. flux drivers. The driver depends on data files ...
void ForceMinEnergy(double emin)
A flux driver for the Bartol Atmospheric Neutrino Flux.