NuWro / nuwro

The main distribution of NuWro
GNU General Public License v3.0
13 stars 15 forks source link

Changes to allow NuWro to be used a library for event simulation #16

Open marzece opened 4 years ago

marzece commented 4 years ago

These changes allow NuWro to be compiled as a static library (libnuwro.a) and used by other programs that include NuWro. To do this I added a few functions to the NuWro class that allow parameters and data paths to be set at run time by whatever program instantiates a new NuWro instance. I also wrapped a few of the more important API classes (event, particle, params & NuWro) in a NUWRO namespace to ensure there's no namespace clashes.

In principle none of my changes should effect the physics output of the simulation at all. I tested this by running a few simulations with a fixed seed on a version of NuWro with and without these changes. The output energy, momentum and particle multiplicity distributions were completely identical. If anyone has suggestions for further tests that could be done to ensure the simulation results haven't been changed I'd be happy to do them.

If anyone has an objections or questions or requests about any of these changes let me know and I'd be happy to try and address it. Also I'd be happy to squash all of these changes down to a single commit if people would prefer that.

Finally here's a quick example script for how one could use NuWro via the static library. https://gist.github.com/marzece/2324121477b85f8acb1a8845ba29dd46