Skip to content

Commit

Permalink
allowed setting of earth model through pybindings, fixed example
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSmithers committed Jun 15, 2021
1 parent 3d722fb commit 929271b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions private/LeptonInjector/Controller.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ namespace LeptonInjector {
this->earthModel = earthModel_;
}

void Controller::setEarthModel(const std::string & earthModelName_, const std::string & earthModelTablePath_){
this->earthModel = std::make_shared<earthmodel::EarthModelService>(earthModelName_, earthModelTablePath_);
}

void Controller::NameOutfile( std::string out_file_){
out_file = out_file_;
}
Expand Down
1 change: 1 addition & 0 deletions private/pybindings/LeptonInjector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ BOOST_PYTHON_MODULE(LeptonInjector){
(args("injectors"),args("minimum energy"),args("maximum energy"),args("spectral index"),args("minimum azimuth"),args("maximum azimuth"),args("minimum zenith"),args("maximum zenith"),args("injection radius")=1200., args("endcap length")=1200., args("cylinder radius")=1200., args("cylinder height")=1200.))
)
.def("Execute",&Controller::Execute)
.def("SetEarthModel",&Controller::setEarthModel)
.def("AddInjector",&Controller::AddInjector)
.def("NameOutfile",&Controller::NameOutfile)
.def("NameLicFile",&Controller::NameLicFile)
Expand Down
2 changes: 2 additions & 0 deletions public/LeptonInjector/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class Controller{

// changes the Earth model to be used with the injectors
void SetEarthModel(std::shared_ptr<earthmodel::EarthModelService> earthModel);
void setEarthModel(const std::string & earthmodel, const std::string &earthmodelpath);

// adds a new injector to be used in the process
void AddInjector(Injector configs_received);
// changes the name of the data file
Expand Down
8 changes: 5 additions & 3 deletions resources/examples/inject_muons.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
diff_xs = xs_folder + "/test_xs.fits"
total_xs = xs_folder + "/test_xs_total.fits"
is_ranged = True
final_1 = LI.Particle.MuMinus
final_2 = LI.Particle.Hadrons
final_1 = LI.Particle.ParticleType.MuMinus
final_2 = LI.Particle.ParticleType.Hadrons
the_injector = LI.Injector( n_events , final_1, final_2, diff_xs, total_xs, is_ranged)


Expand All @@ -42,7 +42,9 @@
# construct the controller
controller = LI.Controller( the_injector, minE, maxE, gamma, minAzimuth, maxAzimuth, minZenith, maxZenith)

# specify the output
# specify the output, earth model
path_to = os.path.join(os.path.dirname(__file__), "..","earthparams/")
controller.SetEarthModel("Planet", path_to)
controller.NameOutfile("./data_output.h5")
controller.NameLicFile("./config.lic")

Expand Down

0 comments on commit 929271b

Please sign in to comment.