Ejemplo n.º 1
0
# generate random service
random = phys_services.I3GSLRandomService(42)

# generate earthmodel service
earthmodel = ["PREM_mmc"]
materialmodel = ["Standard"]
earth = earthmodel_service.EarthModelService("EarthModelService", "",
                                             earthmodel, materialmodel,
                                             "IceSheet", 20. * I3Units.degree,
                                             1948 * I3Units.m)

steer = neutrino_generator.Steering(earth)

# generate interaction service
interaction = neutrino_generator.I3NuGInteractionInfo(random, steer, "csms")
interaction.initialize()

inttypes = [
    "CC_Nu_iso", "NC_Nu_iso", "CC_NuBar_iso", "NC_NuBar_iso", "GR_NuBar"
]

elogmin = 6.0
elogmax = 7.5
nx = 50

elogl = []
ccnul = []
ccnubarl = []
ncnul = []
ncnubarl = []
def SelectNeutrino(
    tray,
    name,
    Propagators=None,
    AutoExtendMuonVolume=False,
    EnergyBiasPower=1,
    FlavorBias=[30, 1, 1],
    CylinderRadius=600 * I3Units.m,
    CylinderHeight=1200 * I3Units.m,
    CrossSections='csms',
):
    r"""
    Select a neutrino to interact, and add neutrino propagators to the context.

    :param AutoExtendMuonVolume: allow :math:`\nu_{\mu}` to interact far before they reach the detector
    :param EnergyBiasPower: select a neutrino from the bundle with probability proportional to E^power
    :param FlavorBias: scale selection probability for :math:`\nu_{e}/\nu_{\mu}/\nu_{\tau}`
                       by these factors. The default value is appropriate for equal sampling
                       of conventional atmospheric :math:`\nu_{e}/\nu_{\mu}`.
    :param CylinderRadius: radius of upright-cylinder target volume
    :param CylinderHeight: full height of simulation volume
    :param CrossSections: cross-section tables to use ('cteq5', 'css', or 'csms')
    """
    from operator import add
    from icecube import neutrino_generator, sim_services, MuonGun

    # Set up NeutrinoGenerator internals
    random = tray.context['I3RandomService']
    #surface = MuonGun.Cylinder(CylinderHeight, CylinderRadius)
    surface = phys_services.Cylinder(CylinderHeight, CylinderRadius)
    config = neutrino_generator.Steering()
    config.detection_surface = surface
    config.do_muon_range_extension = AutoExtendMuonVolume
    interactions = neutrino_generator.I3NuGInteractionInfo(
        random, config, CrossSections)
    interactions.initialize()
    # I3NuGSourceSelector needs this in its context
    tray.context['NuGSteer'] = config

    # Remove all but one neutrino
    tray.Add('I3NuGSourceSelector',
             EnergyBiasPowerIndex=EnergyBiasPower,
             ParticleBiases=reduce(add, [[b] * 2 for b in FlavorBias]),
             KeepDarkNeutrinos=False)

    # Store propagators in the context
    if not 'I3ParticleTypePropagatorServiceMap' in tray.context:
        tray.context[
            'I3ParticleTypePropagatorServiceMap'] = sim_services.I3ParticleTypePropagatorServiceMap(
            )
    Propagators = tray.context['I3ParticleTypePropagatorServiceMap']

    # Use NeutrinoPropagator for neutrinos
    prop = neutrino_generator.I3NeutrinoPropagator(random, config,
                                                   interactions)
    # ensure that all nu_e and nu_mu reach the detector
    prop.prop_mode = neutrino_generator.PropagationMode.ncgrweighted
    tau_prop = neutrino_generator.I3NeutrinoPropagator(random, config,
                                                       interactions)
    # un-weighted propagation for nu_tau to allow for tau regeneration
    tau_prop.prop_mode = neutrino_generator.PropagationMode.nopropweight
    for flavor in 'E', 'Mu', 'Tau':
        for ptype in '', 'Bar':
            Propagators[getattr(dataclasses.I3Particle.ParticleType,
                                'Nu' + flavor +
                                ptype)] = tau_prop if flavor == 'Tau' else prop
Ejemplo n.º 3
0
                                             earthmodel, materialmodel,
                                             icecapmodel, icecapangle,
                                             detdepth)

#
# generate steering service
#
steer = neutrino_generator.Steering(earth, neutrino_generator.full,
                                    neutrino_generator.nugen, injectionmode)

steer.cylinder_params = cylinderparams

#
# generate interaction service
#
interaction = neutrino_generator.I3NuGInteractionInfo(random, steer, xsecmodel)
interaction.initialize()
#interaction.view_interaction_info()

#
# generate propagator
#

nugen = neutrino_generator.I3NeutrinoPropagator(random, steer, interaction)
nugen.prop_mode = propmode

# Base propagators for charged leptons
from icecube.sim_services.propagation import get_propagators
propagators = get_propagators()

for flavor in 'E', 'Mu', 'Tau':