def GenerateAtmosphericNeutrinos(tray,
                                 name,
                                 Files,
                                 GCDFile="",
                                 AutoExtendMuonVolume=False,
                                 EnergyBiasPower=1,
                                 FlavorBias=[30, 1, 1],
                                 CylinderRadius=600 * I3Units.m,
                                 CylinderHeight=1200 * I3Units.m,
                                 CrossSections='csms',
                                 NEvents=-1,
                                 MakeNeutrino=True):
    r"""
    Read CORSIKA showers containing neutrinos, and force exactly one neutrino to interact.

    NB: this segment is deprecated. Use GenerateAirShowers, SelectNeutrino, and PropagateMuons instead.
    
    :param Files: a list of CORSIKA files to read
    :param GCDFile: I3 file with GCD information to read in before the CORSIKA files
    :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')
    """
    import warnings
    warnings.warn(
        'GenerateAtmosphericNeutrinos is deprecated. Use GenerateAirShowers, SelectNeutrino, and PropagateMuons instead'
    )
    from operator import add
    from icecube import neutrino_generator, sim_services, MuonGun
    from icecube.sim_services.propagation import get_propagators
    icetray.load('corsika-reader', False)

    random = tray.context['I3RandomService']
    surface = MuonGun.Cylinder(CylinderHeight, CylinderRadius)
    tray.Add('I3CORSIKAReader',
             'reader',
             filenamelist=Files,
             NEvents=NEvents,
             CylinderHeight=surface.length,
             CylinderRadius=surface.radius,
             Prefix=GCDFile)

    # Drop showers where no particles reach the observation level
    tray.Add(lambda frame: len(frame['I3MCTree']) > 1,
             Streams=[icetray.I3Frame.DAQ])

    # Remove low-energy muons that can't reach the detector
    tray.Add('I3InIceCORSIKATrimmer')

    tray.Add(SelectNeutrino,
             AutoExtendMuonVolume=AutoExtendMuonVolume,
             EnergyBiasPower=EnergyBiasPower,
             FlavorBias=FlavorBias,
             CylinderRadius=CylinderRadius,
             CylinderHeight=CylinderHeight,
             CrossSections=CrossSections)

    base_propagators = get_propagators()
    propagators = tray.context['I3ParticleTypePropagatorServiceMap']
    for k in base_propagators.keys():
        propagators[k] = base_propagators[k]

    tray.Add('Rename', Keys=['I3MCTree', 'I3MCTree_preMuonProp'])
    tray.Add('I3PropagatorModule',
             PropagatorServices=propagators,
             InputMCTreeName="I3MCTree_preMuonProp",
             OutputMCTreeName="I3MCTree",
             RandomService='I3RandomService')
Ejemplo n.º 2
0
randomService = phys_services.I3SPRNGRandomService(seed=options.SEED * 2,
                                                   nstreams=10000,
                                                   streamnum=options.RUNNUMBER)

tray.context['I3RandomService'] = randomService

#Generate bundles of muons
tray.AddSegment(GenerateBundles,
                'BundleGen',
                Generator=generator,
                NEvents=options.NUMEVENTS,
                GCDFile=options.GCDFILE)
print 'GCD', options.GCDFILE
#Propogate the muons in the detector
tray.AddModule('I3PropagatorModule',
               PropagatorServices=get_propagators(),
               RandomService=randomService)

tray.AddModule(GPU_Client, 'client')

#Make MCPESeries
#tray.AddSegment(clsim.I3CLSimMakeHits, 'goCLSIM',
#                UseCPUs=False,
#                UseGPUs=True,
#                MMCTrackListName = "MMCTrackList",
#                MCPESeriesName="I3MCPESeriesMap",
#                PhotonSeriesName='thePhotons',
#                ParallelEvents=500,
#                OverrideApproximateNumberOfWorkItems = 1024000,
#                RandomService=randomService,
#                IceModelLocation=expandvars("$I3_SRC/clsim/resources/ice/spice_mie"),
Ejemplo n.º 3
0
# Set up random number generator
from globals import max_num_files_per_dataset
randomService = phys_services.I3SPRNGRandomService(
        seed = seed*2, #TODO Store to I frame
        nstreams = max_num_files_per_dataset,
        streamnum = args.filenr)
tray.context['I3RandomService'] = randomService

# Generate bundles of muons
tray.AddSegment(GenerateBundles, 'BundleGen', Generator=generator, NEvents=args.numevents, GCDFile=expandvars(args.gcdfile))

#TODO simprod-scripts/python/segments/GenerateCosmicRayMuons.py add generator module in a differnt way (see line below). Are these equivalent?
# tray.AddModule('I3MuonGun::GeneratorModule',name,Generator=num_events*generator)

# Propogate the muons in the detector
tray.AddModule('I3PropagatorModule', PropagatorServices=get_propagators(), RandomService=randomService)

# Calculate event weights
raw_weight_name = 'MuonWeight'
tray.AddModule('I3MuonGun::WeightCalculatorModule', raw_weight_name, Model=model, Generator=generator)



#########################
# APPLY KDE
#########################

weight_dict_name = "I3MCWeightDict"

if args.kde:
Ejemplo n.º 4
0
# 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':
    for ptype in '', 'Bar':
        propagators[getattr(dataclasses.I3Particle.ParticleType,
                            'Nu' + flavor + ptype)] = nugen

#
# create I3Tray
#
tray = I3Tray()
tray.context['I3RandomService'] = random
tray.context['EarthModel'] = earth
tray.context['NuGSteer'] = steer

from os.path import expandvars