-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from amanmdesai/modify-numpy-dependencies
Modify numpy dependencies
- Loading branch information
Showing
15 changed files
with
304 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,4 +131,6 @@ dmypy.json | |
|
||
notebooks/*png | ||
*root | ||
*.json | ||
*.json | ||
*.png | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,47 @@ | ||
import numpy as np | ||
import random | ||
import math | ||
from pymcabc.particle import Particle | ||
|
||
|
||
class Detector: | ||
"""Applies gaussian smearing on E and momenta""" | ||
def __init__(self, sigma: float =1., factor: float =1.): | ||
self.sigma = sigma | ||
self.factor = factor | ||
|
||
def identify_smear(particle: Particle, type: str = "gauss"): | ||
def identify_smear(self, particle: Particle, type: str = "gauss"): | ||
if type == "gauss": | ||
particle = self.gauss_smear(particle) | ||
else: | ||
print("Type Not found") | ||
return particle | ||
|
||
def gauss_smear(self, particle: Particle, sigma: float = 0.5): | ||
size = particle.E.shape[0] | ||
def gauss_smear(self, particle: Particle): | ||
if particle.px[0] == -9 and particle.py[0] == -9: | ||
return particle | ||
else: | ||
particle.px = np.random.normal(particle.px, sigma, size) | ||
particle.py = np.random.normal(particle.py, sigma, size) | ||
particle.pz = np.random.normal(particle.pz, sigma, size) | ||
particle.E = np.random.normal(particle.E, sigma, size) | ||
return particle | ||
output_px = [0]*len(particle.px) | ||
output_py = [0]*len(particle.px) | ||
output_pz = [0]*len(particle.px) | ||
output_E = [0]*len(particle.px) | ||
for i in range(len(particle.px)): | ||
|
||
momentum = math.sqrt(particle.px[i]**2 + particle.py[i]**2 + particle.pz[i]**2 ) | ||
random_measure_momentum = random.gauss(momentum, self.factor*self.sigma) / momentum | ||
random_measure_energy = random.gauss(particle.E[i], self.sigma) / particle.E[i] | ||
|
||
output_px[i] = random_measure_momentum*particle.px[i] | ||
output_py[i] = random_measure_momentum*particle.py[i] | ||
output_pz[i] = random_measure_momentum*particle.pz[i] | ||
|
||
output_E[i] = random_measure_energy*particle.E[i] | ||
|
||
"""output_px[i] = random.gauss(particle.px[i], self.sigma) | ||
output_py[i] = random.gauss(particle.py[i], self.sigma) | ||
output_pz[i] = random.gauss(particle.pz[i], self.sigma) | ||
output_E[i] = random.gauss(particle.E[i], self.sigma) | ||
""" | ||
mass = (output_E[i]**2 - (output_px[i]**2 + output_py[i]**2 +output_pz[i]**2 )) | ||
print(mass) | ||
particle_output = Particle(output_E, output_px, output_py, output_pz) | ||
return particle_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.