Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fork/alexwenym #38

Merged
merged 28 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
686b459
atlas notebook, added some pybindings
Apr 4, 2023
915f7c3
updates to SNe Ranged injection
Apr 17, 2023
1631a44
incremental changes for atlas injection, columndepth debug ongoing
May 2, 2023
9aab7e9
added some pybindings to help debug classes Path and ColumnDepthPosit…
May 5, 2023
17a7095
Remove old rk build system artifacts
austinschneider May 10, 2023
c50f680
Fix column depth unit conversions. Fix unsigned integer overflow in b…
austinschneider May 10, 2023
a327840
Special case for constructing 180deg rotation Quaternion for a rotati…
austinschneider May 10, 2023
5a3f0df
Include what you use
austinschneider May 10, 2023
386e943
Convert from detector coordinates to earth coordinates before checkin…
austinschneider May 10, 2023
2d1ea7e
Removed extra files, some may need to be added to resources later
pweigel Jun 3, 2023
dfa9be2
TreeWeighter constructor w/o secondary processes
pweigel Jun 3, 2023
e75de67
Delete Doxyfile
austinschneider Jun 19, 2023
8f91d0a
small changes to print error messages if needed, M-H sampling in log …
alexwenym Nov 8, 2023
96f6067
added inverse CDF sampling to replace the M-H sampling in TablulatedF…
alexwenym Jan 6, 2024
791ed48
Resolving merge conflicts between main and fork/alexwenym
nickkamp1 Jan 10, 2024
e206a50
Copy photospline's CFITSIO cmake file into our cmake Packages
nickkamp1 Jan 10, 2024
472b7e3
added units argument to DIS constructors in pybindings
nickkamp1 Jan 10, 2024
d1019f3
removed comments
nickkamp1 Jan 10, 2024
bb5761d
remove unncecessary comments
nickkamp1 Jan 10, 2024
62ad7f2
remove comments
nickkamp1 Jan 10, 2024
ba33c17
removed comments
nickkamp1 Jan 10, 2024
56ec2aa
remove ATLAS directory
nickkamp1 Jan 10, 2024
c872e65
remove old legacy analysis
nickkamp1 Jan 10, 2024
522e99d
remove old ATLAS geometries
nickkamp1 Jan 10, 2024
4accb33
sneaky whitespace
nickkamp1 Jan 10, 2024
4c32788
remove whitespace
nickkamp1 Jan 10, 2024
af3dc55
just kidding, now all the whitespace is gone
nickkamp1 Jan 10, 2024
c375bad
add WeightingUtils include
nickkamp1 Jan 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
nickkamp1 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ include(delabella)
include(photospline)
include(googletest)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${CFITSIO_INCLUDE_DIR}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -I${CFITSIO_INCLUDE_DIR}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -I${CFITSIO_INCLUDE_DIR}")

# load macros for googletest
include(testing)

Expand Down
34 changes: 26 additions & 8 deletions projects/crosssections/private/DISFromSpline.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,54 @@ bool kinematicallyAllowed(double x, double y, double E, double M, double m) {

DISFromSpline::DISFromSpline() {}

DISFromSpline::DISFromSpline(std::vector<char> differential_data, std::vector<char> total_data, int interaction, double target_mass, double minimum_Q2, std::set<LI::dataclasses::Particle::ParticleType> primary_types, std::set<LI::dataclasses::Particle::ParticleType> target_types) : primary_types_(primary_types), target_types_(target_types), interaction_type_(interaction), target_mass_(target_mass), minimum_Q2_(minimum_Q2) {
DISFromSpline::DISFromSpline(std::vector<char> differential_data, std::vector<char> total_data, int interaction, double target_mass, double minimum_Q2, std::set<LI::dataclasses::Particle::ParticleType> primary_types, std::set<LI::dataclasses::Particle::ParticleType> target_types, std::string units) : primary_types_(primary_types), target_types_(target_types), interaction_type_(interaction), target_mass_(target_mass), minimum_Q2_(minimum_Q2) {
LoadFromMemory(differential_data, total_data);
InitializeSignatures();
SetUnits(units);
}

DISFromSpline::DISFromSpline(std::vector<char> differential_data, std::vector<char> total_data, int interaction, double target_mass, double minimum_Q2, std::vector<LI::dataclasses::Particle::ParticleType> primary_types, std::vector<LI::dataclasses::Particle::ParticleType> target_types) : primary_types_(primary_types.begin(), primary_types.end()), target_types_(target_types.begin(), target_types.end()), interaction_type_(interaction), target_mass_(target_mass), minimum_Q2_(minimum_Q2) {
DISFromSpline::DISFromSpline(std::vector<char> differential_data, std::vector<char> total_data, int interaction, double target_mass, double minimum_Q2, std::vector<LI::dataclasses::Particle::ParticleType> primary_types, std::vector<LI::dataclasses::Particle::ParticleType> target_types, std::string units) : primary_types_(primary_types.begin(), primary_types.end()), target_types_(target_types.begin(), target_types.end()), interaction_type_(interaction), target_mass_(target_mass), minimum_Q2_(minimum_Q2) {
LoadFromMemory(differential_data, total_data);
InitializeSignatures();
SetUnits(units);
}

DISFromSpline::DISFromSpline(std::string differential_filename, std::string total_filename, int interaction, double target_mass, double minimum_Q2, std::set<LI::dataclasses::Particle::ParticleType> primary_types, std::set<LI::dataclasses::Particle::ParticleType> target_types) : primary_types_(primary_types), target_types_(target_types), interaction_type_(interaction), target_mass_(target_mass), minimum_Q2_(minimum_Q2) {
DISFromSpline::DISFromSpline(std::string differential_filename, std::string total_filename, int interaction, double target_mass, double minimum_Q2, std::set<LI::dataclasses::Particle::ParticleType> primary_types, std::set<LI::dataclasses::Particle::ParticleType> target_types, std::string units) : primary_types_(primary_types), target_types_(target_types), interaction_type_(interaction), target_mass_(target_mass), minimum_Q2_(minimum_Q2) {
LoadFromFile(differential_filename, total_filename);
InitializeSignatures();
SetUnits(units);
}

DISFromSpline::DISFromSpline(std::string differential_filename, std::string total_filename, std::set<LI::dataclasses::Particle::ParticleType> primary_types, std::set<LI::dataclasses::Particle::ParticleType> target_types) : primary_types_(primary_types), target_types_(target_types) {
DISFromSpline::DISFromSpline(std::string differential_filename, std::string total_filename, std::set<LI::dataclasses::Particle::ParticleType> primary_types, std::set<LI::dataclasses::Particle::ParticleType> target_types, std::string units) : primary_types_(primary_types), target_types_(target_types) {
LoadFromFile(differential_filename, total_filename);
ReadParamsFromSplineTable();
InitializeSignatures();
SetUnits(units);
}

DISFromSpline::DISFromSpline(std::string differential_filename, std::string total_filename, int interaction, double target_mass, double minimum_Q2, std::vector<LI::dataclasses::Particle::ParticleType> primary_types, std::vector<LI::dataclasses::Particle::ParticleType> target_types) : primary_types_(primary_types.begin(), primary_types.end()), target_types_(target_types.begin(), target_types.end()), interaction_type_(interaction), target_mass_(target_mass), minimum_Q2_(minimum_Q2) {
DISFromSpline::DISFromSpline(std::string differential_filename, std::string total_filename, int interaction, double target_mass, double minimum_Q2, std::vector<LI::dataclasses::Particle::ParticleType> primary_types, std::vector<LI::dataclasses::Particle::ParticleType> target_types, std::string units) : primary_types_(primary_types.begin(), primary_types.end()), target_types_(target_types.begin(), target_types.end()), interaction_type_(interaction), target_mass_(target_mass), minimum_Q2_(minimum_Q2) {
LoadFromFile(differential_filename, total_filename);
InitializeSignatures();
SetUnits(units);
}

DISFromSpline::DISFromSpline(std::string differential_filename, std::string total_filename, std::vector<LI::dataclasses::Particle::ParticleType> primary_types, std::vector<LI::dataclasses::Particle::ParticleType> target_types) : primary_types_(primary_types.begin(), primary_types.end()), target_types_(target_types.begin(), target_types.end()) {
DISFromSpline::DISFromSpline(std::string differential_filename, std::string total_filename, std::vector<LI::dataclasses::Particle::ParticleType> primary_types, std::vector<LI::dataclasses::Particle::ParticleType> target_types, std::string units) : primary_types_(primary_types.begin(), primary_types.end()), target_types_(target_types.begin(), target_types.end()) {
LoadFromFile(differential_filename, total_filename);
ReadParamsFromSplineTable();
InitializeSignatures();
SetUnits(units);
}

void DISFromSpline::SetUnits(std::string units) {
std::transform(units.begin(), units.end(), units.begin(),
[](unsigned char c){ return std::tolower(c); });
if(units == "cm") {
unit = 1.0;
} else if(units == "m") {
unit = 10000.0;
} else {
throw std::runtime_error("Cross section units not supported!");
}
}

bool DISFromSpline::equal(CrossSection const & other) const {
Expand Down Expand Up @@ -263,7 +281,7 @@ double DISFromSpline::TotalCrossSection(LI::dataclasses::Particle::ParticleType
total_cross_section_.searchcenters(&log_energy, &center);
double log_xs = total_cross_section_.ndsplineeval(&log_energy, &center, 0);

return std::pow(10.0, log_xs);
return unit * std::pow(10.0, log_xs);
}

// No implementation for DIS yet, just use non-target function
Expand Down Expand Up @@ -336,7 +354,7 @@ double DISFromSpline::DifferentialCrossSection(double energy, double x, double y
return 0;
double result = pow(10., differential_cross_section_.ndsplineeval(coordinates.data(), centers.data(), 0));
assert(result >= 0);
return result;
return unit * result;
}

double DISFromSpline::InteractionThreshold(dataclasses::InteractionRecord const & interaction) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "../../public/LeptonInjector/crosssections/CrossSectionCollection.h"
#include "../../public/LeptonInjector/crosssections/DISFromSpline.h"
#include "../../public/LeptonInjector/crosssections/HNLFromSpline.h"
#include "../../public/LeptonInjector/crosssections/CrossSectionCollection.h"
#include "../../public/LeptonInjector/crosssections/DipoleFromTable.h"
#include "../../public/LeptonInjector/crosssections/DarkNewsCrossSection.h"
#include "../../public/LeptonInjector/crosssections/DarkNewsDecay.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,19 @@ friend cereal::access;
int interaction_type_;
double target_mass_;
double minimum_Q2_;

double unit;

public:
DISFromSpline();
DISFromSpline(std::vector<char> differential_data, std::vector<char> total_data, int interaction, double target_mass, double minumum_Q2, std::set<LI::dataclasses::Particle::ParticleType> primary_types, std::set<LI::dataclasses::Particle::ParticleType> target_types);
DISFromSpline(std::vector<char> differential_data, std::vector<char> total_data, int interaction, double target_mass, double minumum_Q2, std::vector<LI::dataclasses::Particle::ParticleType> primary_types, std::vector<LI::dataclasses::Particle::ParticleType> target_types);
DISFromSpline(std::string differential_filename, std::string total_filename, int interaction, double target_mass, double minumum_Q2, std::set<LI::dataclasses::Particle::ParticleType> primary_types, std::set<LI::dataclasses::Particle::ParticleType> target_types);
DISFromSpline(std::string differential_filename, std::string total_filename, std::set<LI::dataclasses::Particle::ParticleType> primary_types, std::set<LI::dataclasses::Particle::ParticleType> target_types);
DISFromSpline(std::string differential_filename, std::string total_filename, int interaction, double target_mass, double minumum_Q2, std::vector<LI::dataclasses::Particle::ParticleType> primary_types, std::vector<LI::dataclasses::Particle::ParticleType> target_types);
DISFromSpline(std::string differential_filename, std::string total_filename, std::vector<LI::dataclasses::Particle::ParticleType> primary_types, std::vector<LI::dataclasses::Particle::ParticleType> target_types);
DISFromSpline(std::vector<char> differential_data, std::vector<char> total_data, int interaction, double target_mass, double minumum_Q2, std::set<LI::dataclasses::Particle::ParticleType> primary_types, std::set<LI::dataclasses::Particle::ParticleType> target_types, std::string units = "cm");
DISFromSpline(std::vector<char> differential_data, std::vector<char> total_data, int interaction, double target_mass, double minumum_Q2, std::vector<LI::dataclasses::Particle::ParticleType> primary_types, std::vector<LI::dataclasses::Particle::ParticleType> target_types, std::string units = "cm");
DISFromSpline(std::string differential_filename, std::string total_filename, int interaction, double target_mass, double minumum_Q2, std::set<LI::dataclasses::Particle::ParticleType> primary_types, std::set<LI::dataclasses::Particle::ParticleType> target_types, std::string units = "cm");
DISFromSpline(std::string differential_filename, std::string total_filename, std::set<LI::dataclasses::Particle::ParticleType> primary_types, std::set<LI::dataclasses::Particle::ParticleType> target_types, std::string units = "cm");
DISFromSpline(std::string differential_filename, std::string total_filename, int interaction, double target_mass, double minumum_Q2, std::vector<LI::dataclasses::Particle::ParticleType> primary_types, std::vector<LI::dataclasses::Particle::ParticleType> target_types, std::string units = "cm");
DISFromSpline(std::string differential_filename, std::string total_filename, std::vector<LI::dataclasses::Particle::ParticleType> primary_types, std::vector<LI::dataclasses::Particle::ParticleType> target_types, std::string units = "cm");

void SetUnits(std::string units);

virtual bool equal(CrossSection const & other) const override;

Expand Down
12 changes: 12 additions & 0 deletions projects/detector/private/EarthModel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,9 @@ double EarthModel::GetInteractionDensity(Geometry::IntersectionList const & inte
interaction_density = 0.0;
for(unsigned int i=0; i<targets.size(); ++i) {
interaction_density += density * particle_fractions[i] * total_cross_sections[i];
//std::cout << " EarthModel::GetInteractionDensity: density " << density << std::endl;
//std::cout << " EarthModel::GetInteractionDensity: particle_fractions[i] " << particle_fractions[i] << std::endl;
//std::cout << " EarthModel::GetInteractionDensity: total_cross_sections[i] " << total_cross_sections[i] << std::endl;
nickkamp1 marked this conversation as resolved.
Show resolved Hide resolved
}
interaction_density *= 100; // cm^-1 --> m^-1
return true;
Expand Down Expand Up @@ -697,6 +700,10 @@ double EarthModel::DistanceForColumnDepthFromPoint(Geometry::IntersectionList co
EarthSector sector = GetSector(current_intersection->hierarchy);
double target = column_depth - total_column_depth;
double distance = sector.density->InverseIntegral(p0+start_point*direction, direction, target, segment_length);
//std::cout << " EarthModel::DistanceForColumnDepthFromPoint: p0+start_point*direction (" << (p0+start_point*direction).GetX() << ", " << (p0+start_point*direction).GetY() << ", " << (p0+start_point*direction).GetZ() << ")" << std::endl;
//std::cout << " EarthModel::DistanceForColumnDepthFromPoint: direction (" << direction.GetX() << ", " << direction.GetY() << ", " << direction.GetZ() << ")" << std::endl;
//std::cout << " EarthModel::DistanceForColumnDepthFromPoint: (target, segment_length) (" << target << ", " << segment_length << ")" <<std::endl;

nickkamp1 marked this conversation as resolved.
Show resolved Hide resolved
done = distance >= 0;
double integral = sector.density->Integral(p0+start_point*direction, direction, segment_length);
total_column_depth += integral;
Expand Down Expand Up @@ -873,9 +880,14 @@ double EarthModel::GetInteractionDepthInCGS(Geometry::IntersectionList const & i
double segment_length = end_point - start_point;
EarthSector sector = GetSector(current_intersection->hierarchy);
double integral = sector.density->Integral(p0+start_point*direction, direction, segment_length);

//std::cout << " EarthModel::GetInteractionDepthInCGS: segment_length: " << segment_length << std::endl;
//std::cout << " EarthModel::GetInteractionDepthInCGS: integral: " << integral << std::endl;
nickkamp1 marked this conversation as resolved.
Show resolved Hide resolved
std::vector<double> particle_fractions = materials_.GetTargetParticleFraction(sector.material_id, targets.begin(), targets.end());
for(unsigned int i=0; i<targets.size(); ++i) {
interaction_depths[i] += (integral * 100) * particle_fractions[i]; // cm^-3 * m --> cm^-2
//std::cout << " EarthModel::GetInteractionDepthInCGS: particle_fractions[i]: " << particle_fractions[i] << std::endl;
//std::cout << " EarthModel::GetInteractionDepthInCGS: interaction_depths[i]: " << interaction_depths[i] << std::endl;
nickkamp1 marked this conversation as resolved.
Show resolved Hide resolved
}
}
// last_point = end_point;
Expand Down
Loading
Loading