-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
414 additions
and
129 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
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,79 +1,64 @@ | ||
import os | ||
import siren | ||
from siren import utilities | ||
from siren._util import GenerateEvents,SaveEvents | ||
|
||
# Number of events to inject | ||
events_to_inject = int(1e5) | ||
|
||
# Experiment to run | ||
experiment = "DUNEFD" | ||
detector_model = utilities.load_detector(experiment) | ||
detector_model = siren.utilities.load_detector(experiment) | ||
|
||
# Particle to inject | ||
primary_type = siren.dataclasses.Particle.ParticleType.NuMu | ||
target_type = siren.dataclasses.Particle.ParticleType.Nucleon | ||
|
||
# Primary interactions and distributions | ||
primary_processes, _ = utilities.load_processes( | ||
"CSMSDISSplines", # model_name | ||
# Cross-section model to use | ||
cross_section_model = "CSMSDISSplines" | ||
|
||
# Load the cross-section model | ||
primary_processes, _ = siren.utilities.load_processes( | ||
cross_section_model, | ||
primary_types=[primary_type], | ||
target_types=[target_type], | ||
isoscalar=True, # for isoscalar splines | ||
process_types=["CC"] # specify the process type, e.g., "CC" for charged current | ||
target_types=[siren.dataclasses.Particle.ParticleType.Nucleon], | ||
isoscalar=True, | ||
process_types=["CC"] | ||
) | ||
|
||
# Energy distribution | ||
edist = siren.distributions.PowerLaw(1, 1e3, 1e6) | ||
|
||
# Direction distribution | ||
direction_distribution = siren.distributions.IsotropicDirection() | ||
|
||
# Position distribution | ||
muon_range_func = siren.distributions.LeptonDepthFunction() | ||
position_distribution = siren.distributions.ColumnDepthPositionDistribution( | ||
60, 60.0, muon_range_func) | ||
|
||
|
||
# Define injection distributions | ||
primary_injection_distributions = { | ||
"energy": edist, | ||
"direction": direction_distribution, | ||
"position": position_distribution | ||
} | ||
# Extract the primary cross-sections for the primary type | ||
primary_cross_sections = primary_processes[primary_type] | ||
|
||
# Set up the Injector | ||
injector = siren.injection.Injector() | ||
injector.number_of_events = events_to_inject | ||
injector.detector_model = detector_model | ||
injector.primary_type = primary_type | ||
injector.primary_interactions = primary_processes[primary_type] | ||
injector.primary_interactions = primary_cross_sections | ||
|
||
# Directly set the distributions | ||
injector.primary_injection_distributions = [ | ||
siren.distributions.PrimaryMass(0), | ||
edist, | ||
direction_distribution, | ||
position_distribution | ||
siren.distributions.PrimaryMass(0), # Mass distribution | ||
siren.distributions.PowerLaw(1, 1e3, 1e6), # Energy distribution | ||
siren.distributions.IsotropicDirection(), # Direction distribution | ||
siren.distributions.ColumnDepthPositionDistribution(60, 60.0, siren.distributions.LeptonDepthFunction()) # Position distribution | ||
] | ||
|
||
# Generate events | ||
event = injector.generate_event() | ||
events,gen_times = GenerateEvents(injector) | ||
|
||
# Set up the Weighter for event weighting | ||
# Set up the Weighter for event weighting (without position distribution) | ||
weighter = siren.injection.Weighter() | ||
weighter.injectors = [injector] | ||
weighter.detector_model = detector_model | ||
weighter.primary_type = primary_type | ||
weighter.primary_interactions = primary_processes[primary_type] | ||
weighter.primary_interactions = primary_cross_sections | ||
weighter.primary_physical_distributions = [ | ||
edist, | ||
direction_distribution, | ||
siren.distributions.PowerLaw(1, 1e3, 1e6), # Energy distribution | ||
siren.distributions.IsotropicDirection() # Direction distribution | ||
] | ||
|
||
# Compute weight | ||
weight = weighter(event) | ||
|
||
# Output events and weights | ||
os.makedirs("output", exist_ok=True) | ||
print(str(event)) | ||
print(f"Event weight: {weight}") | ||
SaveEvents(events,weighter,gen_times,output_filename="output/DUNE") | ||
|
||
# Save events | ||
# TODO | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.