From aff88b09bb1795ba3510c0ff07c010a615d9d805 Mon Sep 17 00:00:00 2001 From: Nicholas Kamp Date: Mon, 3 Jun 2024 14:33:46 -0400 Subject: [PATCH] remove serialization test --- .../Examples/Example2/SerializationTest.py | 109 ------------------ 1 file changed, 109 deletions(-) delete mode 100644 resources/Examples/Example2/SerializationTest.py diff --git a/resources/Examples/Example2/SerializationTest.py b/resources/Examples/Example2/SerializationTest.py deleted file mode 100644 index d88cc939..00000000 --- a/resources/Examples/Example2/SerializationTest.py +++ /dev/null @@ -1,109 +0,0 @@ -import os - -import siren -from siren.SIREN_Controller import SIREN_Controller - -# Define a DarkNews model -model_kwargs = { - "m4": 0.47, # 0.140, - "mu_tr_mu4": 2.50e-6, # 1e-6, # GeV^-1 - "UD4": 0, - "Umu4": 0, - "epsilon": 0.0, - "gD": 0.0, - "decay_product": "photon", - "noHC": True, - "HNLtype": "dirac", -} - -# Number of events to inject -events_to_inject = 10 - -# Expeirment to run -experiment = "MiniBooNE" - -# Define the controller -controller = SIREN_Controller(events_to_inject, experiment) - -# Particle to inject -primary_type = siren.dataclasses.Particle.ParticleType.NuMu - -xs_path = siren.utilities.get_cross_section_model_path(f"DarkNewsTables-v{siren.utilities.darknews_version()}", must_exist=False) -# Define DarkNews Model -table_dir = os.path.join( - xs_path, - "Dipole_M%2.2e_mu%2.2e" % (model_kwargs["m4"], model_kwargs["mu_tr_mu4"]), -) -controller.InputDarkNewsModel(primary_type, table_dir, **model_kwargs) - -# Primary distributions -primary_injection_distributions = {} -primary_physical_distributions = {} - -# energy distribution -flux_file = siren.utilities.get_tabulated_flux_file("BNB","FHC_numu") -edist = siren.distributions.TabulatedFluxDistribution(flux_file, True) -edist_gen = siren.distributions.TabulatedFluxDistribution( - model_kwargs["m4"], 10, flux_file, False -) -primary_injection_distributions["energy"] = edist_gen -primary_physical_distributions["energy"] = edist - -# direction distribution -direction_distribution = siren.distributions.FixedDirection(siren.math.Vector3D(0, 0, 1.0)) -primary_injection_distributions["direction"] = direction_distribution -primary_physical_distributions["direction"] = direction_distribution - -# position distribution -decay_range_func = siren.distributions.DecayRangeFunction( - model_kwargs["m4"], controller.DN_min_decay_width, 3, 541 -) -position_distribution = siren.distributions.RangePositionDistribution( - 6.2, 6.2, decay_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() - -def stop(datum, i): - secondary_type = datum.record.signature.secondary_types[i] - return secondary_type != siren.dataclasses.Particle.ParticleType.N4 - -controller.SetInjectorStoppingCondition(stop) -os.makedirs("output", exist_ok=True) - -print("Running initial event generation and serializing injector") -events = controller.GenerateEvents(fill_tables_at_exit=False) -controller.SaveEvents( - "output/serialization_example", - fill_tables_at_exit=False -) - -# Define the second controller -controller_reloaded = SIREN_Controller(events_to_inject, experiment) - -controller_reloaded.InputDarkNewsModel(primary_type, table_dir, **model_kwargs) - -# SetProcesses -controller_reloaded.SetPhysicalProcesses( - primary_type, primary_physical_distributions -) - -print("Deserializing injector") -controller_reloaded.Initialize("output/serialization_example") - -controller_reloaded.SetInjectorStoppingCondition(stop) - -print("Generating events with deserialized injector") -events = controller_reloaded.GenerateEvents(fill_tables_at_exit=False) -controller_reloaded.SaveEvents( - "output/serialization_example_reloaded", - fill_tables_at_exit=False -) - -print("Succesfully serialized and deserialized injector with DarkNews interactions")