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

Add GEANT4 detector simulation #170

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

153957
Copy link
Member

@153957 153957 commented Mar 22, 2017

This subclass of HiSPARCSimulation simulates the signals from particles hitting the detector using GEANT4.

@153957
Copy link
Member Author

153957 commented Mar 22, 2017

I merged master to fix the failing unittests.
However, the tests still fail due to the remaining flake8 errors in the new code.

@kaspervd
Copy link

Thanks, in time I'll fix them!

@@ -902,7 +900,7 @@ class GroundParticlesSimulationWithoutErrors(ErrorlessSimulation,
pass


class MultipleGroundParticlesSimulation(GroundParticlesSimulation):
class MultipleGroundParticlesSimulation(GroundParticlesGEANT4Simulation):
Copy link
Member Author

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.

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
Copy link
Member Author

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.")

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:
Copy link
Member Author

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

@tomkooij
Copy link
Member

This PR (branch) will need to be split into a simulations and a corsika branch. After splitting it will need "some" code quality etc work ;)

We'll leave this here while I figure out how git filter-branch works. (But I probably won't have time today)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants