Beispiel #1
0
 def test_earth_init(self):
     earth_model_params = [
         "DUNE", "../resources/earthparams/", ["PREM_dune"], ["Standard"],
         "NoIce", 20.0 * LeptonInjector.Constants.degrees,
         1480.0 * LeptonInjector.Constants.m
     ]
     LWpy.earth(earth_model_params)
Beispiel #2
0
 def test_interaction_init(self):
     name = "CC"
     particle = LeptonInjector.Particle.ParticleType.NuE
     final_state = []
     final_state.append(LeptonInjector.Particle.ParticleType.EMinus)
     final_state.append(LeptonInjector.Particle.ParticleType.Hadrons)
     differential_xs = "../resources/crosssections/csms_differential_v1.0/dsdxdy_nu_CC_iso.fits"
     total_xs = "../resources/crosssections/csms_differential_v1.0/sigma_nu_CC_iso.fits"
     LWpy.interaction(name, particle, final_state, differential_xs,
                      total_xs)
Beispiel #3
0
 def test_read_write(self):
     s = LWpy.read_stream('./config_DUNE.lic')
     blocks = s.read()
     sw = LWpy.write_stream('./test_config.lic')
     sw.write(blocks)
     ss = LWpy.read_stream('./test_config.lic')
     new_blocks = ss.read()
     assert (len(new_blocks) == len(blocks))
     for i in range(len(blocks)):
         assert (LWpy.block_equal(blocks[i], new_blocks[i]))
Beispiel #4
0
def make_ranged_generator():
    s = LWpy.read_stream('./config_DUNE.lic')
    blocks = s.read()
    v = blocks[1][2]["height"]
    del blocks[1][2]["height"]
    blocks[1][2]["length"] = v
    earth_model_params = [
        "DUNE",
        "../resources/earthparams/",
        ["PREM_dune"],
        ["Standard"],
        "NoIce",
        20.0*LeptonInjector.Constants.degrees,
        1480.0*LeptonInjector.Constants.m]
    return s, blocks, LWpy.ranged_generator(blocks[1], earth_model_params)
def get_standard_interactions():
    name = "CC"
    particle = LeptonInjector.Particle.ParticleType.NuE
    final_state = []
    final_state.append(LeptonInjector.Particle.ParticleType.EPlus)
    final_state.append(LeptonInjector.Particle.ParticleType.Hadrons)

    cc_nu_differential_xs = path + "../crosssections/csms_differential_v1.0/dsdxdy_nu_CC_iso.fits"
    cc_nu_total_xs = path + "../crosssections/csms_differential_v1.0/sigma_nu_CC_iso.fits"
    nc_nu_differential_xs = path + "../crosssections/csms_differential_v1.0/dsdxdy_nu_NC_iso.fits"
    nc_nu_total_xs = path + "../crosssections/csms_differential_v1.0/sigma_nu_NC_iso.fits"
    cc_nubar_differential_xs = path + "../crosssections/csms_differential_v1.0/dsdxdy_nubar_CC_iso.fits"
    cc_nubar_total_xs = path + "../crosssections/csms_differential_v1.0/sigma_nubar_CC_iso.fits"
    nc_nubar_differential_xs = path + "../crosssections/csms_differential_v1.0/dsdxdy_nubar_NC_iso.fits"
    nc_nubar_total_xs = path + "../crosssections/csms_differential_v1.0/sigma_nubar_NC_iso.fits"

    neutrinos = [
            LeptonInjector.Particle.ParticleType.NuE,
            LeptonInjector.Particle.ParticleType.NuMu,
            LeptonInjector.Particle.ParticleType.NuTau,
            LeptonInjector.Particle.ParticleType.NuEBar,
            LeptonInjector.Particle.ParticleType.NuMuBar,
            LeptonInjector.Particle.ParticleType.NuTauBar,
            ]
    charged_leptons = [
            LeptonInjector.Particle.ParticleType.EMinus,
            LeptonInjector.Particle.ParticleType.MuMinus,
            LeptonInjector.Particle.ParticleType.TauMinus,
            LeptonInjector.Particle.ParticleType.EPlus,
            LeptonInjector.Particle.ParticleType.MuPlus,
            LeptonInjector.Particle.ParticleType.TauPlus,
            ]
    cc_total_xs = [cc_nu_total_xs]*3 +[cc_nubar_total_xs]*3
    nc_total_xs = [nc_nu_total_xs]*3 +[nc_nubar_total_xs]*3
    cc_differential_xs = [cc_nu_differential_xs]*3 +[cc_nubar_differential_xs]*3
    nc_differential_xs = [nc_nu_differential_xs]*3 +[nc_nubar_differential_xs]*3

    interactions_list = []
    for nu, lep, cc_txs, cc_xs, nc_txs, nc_xs in zip(neutrinos, charged_leptons, cc_total_xs, cc_differential_xs, nc_total_xs, nc_differential_xs):
        cc_final_state = [lep, LeptonInjector.Particle.ParticleType.Hadrons]
        cc = LWpy.interaction("CC", nu, cc_final_state, cc_xs, cc_txs)

        nc_final_state = [nu, LeptonInjector.Particle.ParticleType.Hadrons]
        nc = LWpy.interaction("NC", nu, nc_final_state, nc_xs, nc_txs)

        interactions_list.extend([cc, nc])

    return interactions_list
Beispiel #6
0
 def test_standard_interactions(self):
     nu_interactions_list = standard_interactions.get_standard_interactions(
     )
     nu_interactions = LWpy.interactions(nu_interactions_list)
     ints = nu_interactions.get_particle_interactions(
         LeptonInjector.Particle.ParticleType.NuEBar)
     print([i.name for i in ints])
Beispiel #7
0
    def test_ranged_generator(self):
        s = LWpy.read_stream('./config_DUNE.lic')
        blocks = s.read()
        earth_model_params = [
            "DUNE", "../resources/earthparams/", ["PREM_dune"], ["Standard"],
            "NoIce", 20.0 * LeptonInjector.Constants.degrees,
            1480.0 * LeptonInjector.Constants.m
        ]
        v = blocks[1][2]["height"]
        del blocks[1][2]["height"]
        blocks[1][2]["length"] = v
        gen = LWpy.ranged_generator(blocks[1], earth_model_params)

        data_file = h5.File("data_output_DUNE.h5")
        injector_list = [i for i in data_file.keys()]
        for i in injector_list:
            props = data_file[i]["properties"][:]
            props.dtype.names = ('energy', 'zenith', 'azimuth', 'bjorken_x',
                                 'bjorken_y', 'final_type_0', 'final_type_1',
                                 'particle', 'radius', 'z',
                                 'total_column_depth')
            names = props.dtype.names
            formats = [(s, v) for s, v in props.dtype.descr if s in names]
            formats += [('x', '<f8'), ('y', '<f8')]
            a = [props[n] for n in names]
            a += [np.zeros(len(props)), np.zeros(len(props))]
            props = np.array(list(zip(*a)), dtype=formats)
            gen.prob_pos(props)
            gen.prob_area(props)
            gen.get_considered_range(props)
            gen.prob_kinematics(props)

        nu_interactions_list = standard_interactions.get_standard_interactions(
        )
        int_model = LWpy.interaction_model(nu_interactions_list,
                                           earth_model_params)
        int_model.prob_kinematics(props)

        first_pos, last_pos = gen.get_considered_range(props)
        phys_pos = int_model.prob_pos(props, first_pos, last_pos)
        gen_pos = gen.prob_pos(props)
        p_int = int_model.prob_interaction(props, first_pos, last_pos)
Beispiel #8
0
def make_generator():
    s = LWpy.read_stream('./config_DUNE.lic')
    blocks = s.read()
    return s, blocks, LWpy.generator(blocks[1])
Beispiel #9
0
 def test_load(self):
     s = LWpy.read_stream('./config_DUNE.lic')
     blocks = s.read()
     assert (len(blocks) == 2)
Beispiel #10
0
 def test_merge_null(self):
     s = LWpy.read_stream('./config_DUNE.lic')
     blocks = s.read()
     blocks = LWpy.merge_blocks(blocks)
     assert (len(blocks) == 2)