Esempio n. 1
0
def generate_mesh(geometry_function, estimator_type):
    result = ""

    # create empty estimator object
    estimator = SHEstimator()
    estimator.estimator = estimator_type

    # possible particle types and associated names
    part_types = OrderedDict({
        "al": SHParticleType.all,
        "p": SHParticleType.proton,
        "n": SHParticleType.neutron
    })

    # possible detector types and associated names
    det_types = OrderedDict({
        "en": SHDetType.energy,
        "fl": SHDetType.fluence,
        "aen": SHDetType.avg_energy,
        "bet": SHDetType.avg_beta
    })

    # possible geometries and associated names
    geometries_dict = geometry_function()
    for geometry_name, part_name, det_name in product(geometries_dict,
                                                      part_types, det_types):
        estimator.geometry = geometries_dict[geometry_name]
        estimator.detector_type = det_types[det_name]
        estimator.particle_type = part_types[part_name]
        estimator.filename = det_name + "_" + geometry_name + "_" + part_name
        text = EstimatorWriter.get_text(estimator, add_comment=True)
        result += text

    return result
Esempio n. 2
0
def generate_plane():
    result = ""

    # create empty estimator object
    estimator = SHEstimator()
    estimator.estimator = SHGeoType.plane

    # possible particle types and associated names
    part_types = OrderedDict({
        "al": SHParticleType.all,
        "p": SHParticleType.proton,
        "n": SHParticleType.neutron
    })

    # possible detector types and associated names
    det_types = OrderedDict({"cnt": SHDetType.counter})

    # possible geometries and associated names
    geometries_dict = plane_geometries()
    for geometry_name, part_name, det_name in product(geometries_dict,
                                                      part_types, det_types):
        estimator.geometry = geometries_dict[geometry_name]
        estimator.detector_type = det_types[det_name]
        estimator.particle_type = part_types[part_name]
        estimator.filename = det_name + "_" + geometry_name + "_" + part_name
        text = EstimatorWriter.get_text(estimator, add_comment=True)
        result += text

    return result
Esempio n. 3
0
def generate_geomap():
    result = ""

    # create empty estimator object
    estimator = SHEstimator()
    estimator.estimator = SHGeoType.geomap
    estimator.particle_type = SHParticleType.unknown

    # possible detector types and associated names
    det_types = OrderedDict({
        "zon": SHDetType.zone,
        "rho": SHDetType.rho,
        "med": SHDetType.medium
    })

    # possible geometries and associated names
    geometries_dict = msh_geometries()
    for geometry_name, det_name in product(geometries_dict, det_types):
        estimator.geometry = geometries_dict[geometry_name]
        estimator.detector_type = det_types[det_name]
        estimator.filename = det_name + "_" + geometry_name
        text = EstimatorWriter.get_text(estimator, add_comment=True)
        result += text

    return result
Esempio n. 4
0
def main(args=sys.argv[1:]):
    """
    Compose programatically detect.dat SHIELDHIT-12A input file
    with fixed mesh and many combinations of detector and particle type.
    :param args: part of sys.argv, used here to simplify automated testing
    :return: None
    """

    # create empty estimator object
    estimator = SHEstimator()

    # create carthesian mesh
    # it is done once and in single place
    # editing in manually in detect.dat file would require changes in many lines,
    # for every combination of particle and detector type, making it error prone
    estimator.estimator = SHGeoType.msh
    estimator.geometry = CarthesianMesh()
    estimator.geometry.set_axis(axis_no=0, start=-5.0, stop=5.0, nbins=1)
    estimator.geometry.set_axis(axis_no=1, start=-5.0, stop=5.0, nbins=1)
    estimator.geometry.set_axis(axis_no=2, start=0.0, stop=30.0, nbins=300)

    # possible detector types and associated names
    det_types = {SHDetType.energy: "en", SHDetType.fluence: "fl"}

    # possible particle types and associated names
    particle_types = {
        SHParticleType.all: "all",
        SHParticleType.proton: "p",
        SHParticleType.neutron: "n"
    }

    # open detector.dat file for writing
    with open("detect.dat", "w") as f:
        f.write(CardLine.credits + "\n")

        # loop over all combinations of detector and particle types
        # output filename will be composed from associated detector and particle names
        for dt, pt in product(det_types.keys(), particle_types.keys()):
            estimator.detector_type = dt
            estimator.particle_type = pt
            estimator.filename = det_types[dt] + "_" + particle_types[pt]
            text = EstimatorWriter.get_text(estimator, add_comment=True)
            f.write(text)
        f.write(CardLine.comment + "\n")
def main(args=sys.argv[1:]):
    """
    Compose programatically detect.dat SHIELDHIT-12A input file
    with fixed mesh and many combinations of detector and particle type.
    :param args: part of sys.argv, used here to simplify automated testing
    :return: None
    """

    # create empty estimator object
    estimator = SHEstimator()

    # create carthesian mesh
    # it is done once and in single place
    # editing in manually in detect.dat file would require changes in many lines,
    # for every combination of particle and detector type, making it error prone
    estimator.estimator = SHGeoType.msh
    estimator.geometry = CarthesianMesh()
    estimator.geometry.set_axis(axis_no=0, start=-5.0, stop=5.0, nbins=1)
    estimator.geometry.set_axis(axis_no=1, start=-5.0, stop=5.0, nbins=1)
    estimator.geometry.set_axis(axis_no=2, start=0.0, stop=30.0, nbins=300)

    # possible detector types and associated names
    det_types = {SHDetType.energy: "en", SHDetType.fluence: "fl"}

    # possible particle types and associated names
    particle_types = {SHParticleType.all: "all", SHParticleType.proton: "p", SHParticleType.neutron: "n"}

    # open detector.dat file for writing
    with open("detect.dat", "w") as f:
        f.write(CardLine.credits + "\n")

        # loop over all combinations of detector and particle types
        # output filename will be composed from associated detector and particle names
        for dt, pt in product(det_types.keys(), particle_types.keys()):
            estimator.detector_type = dt
            estimator.particle_type = pt
            estimator.filename = det_types[dt] + "_" + particle_types[pt]
            text = EstimatorWriter.get_text(estimator, add_comment=True)
            f.write(text)
        f.write(CardLine.comment + "\n")