Skip to content

Commit 641d439

Browse files
committed
Add calc_weights_cosmic_Rays
1 parent 56c6f9e commit 641d439

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

fact/analysis/statistics.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import numpy as np
22
import astropy.units as u
3+
from functools import partial
34

45
POINT_SOURCE_FLUX_UNIT = (1 / u.GeV / u.s / u.m**2).unit
56
FLUX_UNIT = POINT_SOURCE_FLUX_UNIT / u.sr
67

78
PDG_COSMIC_RAY_FLUX = 1.8e4 * FLUX_UNIT
89
PDG_COSMIC_RAY_E_REF = 1 * u.GeV
10+
PDG_COSMIC_RAY_INDEX = -2.7
911

1012

1113
@u.quantity_input
@@ -14,7 +16,7 @@ def random_power(
1416
e_min: u.TeV,
1517
e_max: u.TeV,
1618
size,
17-
e_ref: u.TeV=1 * u.TeV,
19+
e_ref: u.TeV = 1 * u.TeV,
1820
) -> u.TeV:
1921
r'''
2022
Draw random numbers from a power law distribution
@@ -458,3 +460,15 @@ def calc_proton_obstime(
458460
)
459461

460462
return (t_ref * phi_sim / flux_normalization).to(u.hour)
463+
464+
465+
calc_weights_cosmic_rays = partial(
466+
calc_weights_powerlaw,
467+
target_index=PDG_COSMIC_RAY_INDEX,
468+
flux_normalization=PDG_COSMIC_RAY_FLUX,
469+
e_ref=PDG_COSMIC_RAY_E_REF,
470+
)
471+
calc_weights_cosmic_rays.__doc__ = '''
472+
Calculate event weights, so that simulated
473+
events are reweighted to the PDG cosmic rays spectrum
474+
'''

0 commit comments

Comments
 (0)