Skip to content

Commit

Permalink
Touch up DIS examples, preliminary paper plots
Browse files Browse the repository at this point in the history
  • Loading branch information
nickkamp1 committed Feb 2, 2024
1 parent d4fe17b commit df5cccc
Show file tree
Hide file tree
Showing 4 changed files with 255 additions and 4 deletions.
84 changes: 84 additions & 0 deletions resources/Examples/Example1/DIS_ATLAS.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import os

import leptoninjector as LI
from leptoninjector import _util
from leptoninjector.LIController import LIController

resources_dir = _util.resource_package_dir()

# Number of events to inject
events_to_inject = 10000

# Expeirment to run
experiment = "ATLAS"

# Define the controller
controller = LIController(events_to_inject, experiment)

# Particle to inject
primary_type = LI.dataclasses.Particle.ParticleType.NuMu

cross_section_model = "CSMSDISSplines"

xsfiledir = _util.get_cross_section_model_path(cross_section_model)

# Cross Section Model
target_type = LI.dataclasses.Particle.ParticleType.Nucleon

DIS_xs = LI.interactions.DISFromSpline(
os.path.join(xsfiledir, "dsdxdy_nu_CC_iso.fits"),
os.path.join(xsfiledir, "sigma_nu_CC_iso.fits"),
[primary_type],
[target_type],
)

primary_xs = LI.interactions.InteractionCollection(primary_type, [DIS_xs])
controller.SetInteractions(primary_xs)

# Primary distributions
primary_injection_distributions = {}
primary_physical_distributions = {}

# energy distribution
# HE SN flux from ATLAS paper
flux_file = os.path.join(
resources_dir,
"Fluxes",
"HE_SN_Flux_Tables",
"dN_dE_SNe_2n_D1_0_s20_t100d_NuMu_d10kpc.txt",
)
print(flux_file)
edist = LI.distributions.TabulatedFluxDistribution(100, 1e6, flux_file, True) #bool is whether flux is physical
#edist_inj = LI.distributions.PowerLaw(2, 100, int(1e6))
primary_injection_distributions["energy"] = edist
primary_physical_distributions["energy"] = edist

# we need this conversion to make sure the flux is in units of 1/m2
flux_unit_conv = LI.distributions.NormalizationConstant((100 / 1)**2)
primary_physical_distributions["flux_norm"] = flux_unit_conv

# direction distribution
# let's just inject upwards
injection_dir = LI.math.Vector3D(0, 0, 1)
injection_dir.normalize()
direction_distribution = LI.distributions.FixedDirection(injection_dir)
primary_injection_distributions["direction"] = direction_distribution
primary_physical_distributions["direction"] = direction_distribution

# position distribution
muon_range_func = LI.distributions.LeptonDepthFunction()
position_distribution = LI.distributions.ColumnDepthPositionDistribution(
600, 600.0, muon_range_func, set(controller.GetDetectorModelTargets()[0])
)
primary_injection_distributions["position"] = position_distribution

# SetProcesses
controller.SetProcesses(
primary_type, primary_injection_distributions, primary_physical_distributions
)

controller.Initialize()

events = controller.GenerateEvents()

controller.SaveEvents("output/ATLAS_DIS")
68 changes: 68 additions & 0 deletions resources/Examples/Example1/DIS_DUNE.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import os

import leptoninjector as LI
from leptoninjector import _util
from leptoninjector.LIController import LIController

resources_dir = _util.resource_package_dir()

# Number of events to inject
events_to_inject = 10000

# Expeirment to run
experiment = "DUNEFD"

# Define the controller
controller = LIController(events_to_inject, experiment)

# Particle to inject
primary_type = LI.dataclasses.Particle.ParticleType.NuMu

cross_section_model = "CSMSDISSplines"

xsfiledir = _util.get_cross_section_model_path(cross_section_model)

# Cross Section Model
target_type = LI.dataclasses.Particle.ParticleType.Nucleon

DIS_xs = LI.interactions.DISFromSpline(
os.path.join(xsfiledir, "dsdxdy_nu_CC_iso.fits"),
os.path.join(xsfiledir, "sigma_nu_CC_iso.fits"),
[primary_type],
[target_type],
)

primary_xs = LI.interactions.InteractionCollection(primary_type, [DIS_xs])
controller.SetInteractions(primary_xs)

# Primary distributions
primary_injection_distributions = {}
primary_physical_distributions = {}

# energy distribution
edist = LI.distributions.PowerLaw(2, 1e3, 1e6)
primary_injection_distributions["energy"] = edist
primary_physical_distributions["energy"] = edist

# direction distribution
direction_distribution = LI.distributions.IsotropicDirection()
primary_injection_distributions["direction"] = direction_distribution
primary_physical_distributions["direction"] = direction_distribution

# position distribution
muon_range_func = LI.distributions.LeptonDepthFunction()
position_distribution = LI.distributions.ColumnDepthPositionDistribution(
600, 600.0, muon_range_func, set(controller.GetDetectorModelTargets()[0])
)
primary_injection_distributions["position"] = position_distribution

# SetProcesses
controller.SetProcesses(
primary_type, primary_injection_distributions, primary_physical_distributions
)

controller.Initialize()

events = controller.GenerateEvents()

controller.SaveEvents("output/DUNE_DIS")
6 changes: 2 additions & 4 deletions resources/Examples/Example1/DIS_IceCube.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os
import sys
import numpy as np

import leptoninjector as LI
from leptoninjector import _util
Expand All @@ -9,7 +7,7 @@
resources_dir = _util.resource_package_dir()

# Number of events to inject
events_to_inject = 1000
events_to_inject = 10000

# Expeirment to run
experiment = "IceCube"
Expand Down Expand Up @@ -67,4 +65,4 @@

events = controller.GenerateEvents()

controller.SaveEvents("IceCube_DIS.hdf5")
controller.SaveEvents("output/IceCube_DIS")
Loading

0 comments on commit df5cccc

Please sign in to comment.