Skip to content

Commit

Permalink
fix log integration
Browse files Browse the repository at this point in the history
  • Loading branch information
nickkamp1 committed Nov 6, 2024
1 parent 80a2e0b commit 3095d66
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Tabulated2DFluxDistribution::Tabulated2DFluxDistribution() {}

void Tabulated2DFluxDistribution::ComputeIntegral() {
std::function<double(double, double)> integrand = [&] (double x, double y) -> double {
return x*unnormed_pdf(pow(10,x),y);
//std::cout << "x " << x << " y " << y << " z " << pow(10,x)*unnormed_pdf(pow(10,x),y) << std::endl;
return pow(10,x)*unnormed_pdf(pow(10,x),y)/log(10);
};
integral = siren::utilities::simpsonIntegrate2D(integrand, log10(energyMin), log10(energyMax), zenithMin, zenithMax);
}
Expand Down Expand Up @@ -92,7 +93,7 @@ void Tabulated2DFluxDistribution::LoadFluxTable(std::vector<double> & energies,
table_data.y = zeniths;
table_data.f = flux;
energy_nodes = energies;
zenith_nodes = energies;
zenith_nodes = zeniths;

// If no physical are manually set, use first/last entry of table
if(not energy_bounds_set) {
Expand Down
2 changes: 1 addition & 1 deletion projects/utilities/public/SIREN/utilities/Integration.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ double simpsonIntegrate2D(const FuncType& func, double a1, double b1, double a2,
if (j==0 || j==N1i) c1 = 1;
else if (j%2==0) c1 = 2;
else if (j%2==1) c1 = 4;
double x = a1 + j*h1i;
for(unsigned int k = 0; k < N2i+1; k++) {
if (k==0 || k==N2i) c2 = 1;
else if (k%2==0) c2 = 2;
else if (k%2==1) c2 = 4;
double x = a1 + j*h1i;
double y = a2 + k*h2i;
estimate += c1*c2*func(x, y);
}
Expand Down

0 comments on commit 3095d66

Please sign in to comment.