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
Add GEANT4 detector simulation #170
base: master
Are you sure you want to change the base?
Conversation
I merged master to fix the failing unittests. |
Thanks, in time I'll fix them! |
@@ -902,7 +900,7 @@ class GroundParticlesSimulationWithoutErrors(ErrorlessSimulation, | |||
pass | |||
|
|||
|
|||
class MultipleGroundParticlesSimulation(GroundParticlesSimulation): | |||
class MultipleGroundParticlesSimulation(GroundParticlesGEANT4Simulation): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should create a new version of the Multiple...
class specifically for the GEANT4 version, keeping the existing version as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
@@ -245,7 +241,7 @@ def simulate_detector_mips_for_particles(self, particles, detector, | |||
# and the time it took for the first photon to arrive at the PMT. | |||
file = np.genfromtxt("RUN_1/outpSD.csv", delimiter=",") | |||
try: | |||
numberofphotons = len(file[:,1])-1 # first element is header | |||
numberofphotons = len(file[1:,1]) # first element is header |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of slicing use the skip_header
keyword for genfromtxt
. Just set it to 1 ("The number of lines to skip at the beginning of the file.")
Also fix/improve some other code. Remove some prints.
sapphire/simulations/base.py
Outdated
chosen_core_pos = shower_parameters['core_pos'] | ||
chosen_radius = np.sqrt( chosen_core_pos[0]**2. + chosen_core_pos[1]**2. ) | ||
|
||
if (chosen_energy < (12.5 + 0.1)) and (chosen_energy > (12.5 - 0.1)) and chosen_radius > 50: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaspervd
These if statements can be clarified:
if (chosen_energy < (16.5 + 0.1)) and (chosen_energy > (16.5 - 0.1)) and chosen_radius > 500:
You can drop the brackets around the comparisons:
if chosen_energy < (16.5 + 0.1) and chosen_energy > (16.5 - 0.1) and chosen_radius > 500:
And you can combine comparisons:
if (16.5 - 0.1) < chosen_energy < (16.5 + 0.1) and chosen_radius > 500:
Or simply check the difference:
if abs(chosen_energy - 16.5) < 0.1 and chosen_radius > 500:
And instead of comparing each energy value individually you can compare them all in one go to keep it DRY:
energies = [13, 13.5, 14, ...]
radiuses = [50, 65, 75, ...]
if any(abs(chosen_energy - energy) < 0.1 and chosen_radius > radius for energy, radius in zip(energies, radiuses)):
continue
This PR (branch) will need to be split into a We'll leave this here while I figure out how |
…, possibility to run simulations on grid
This subclass of
HiSPARCSimulation
simulates the signals from particles hitting the detector using GEANT4.