def MakePropagator( radius=800 * I3Units.m, length=1600 * I3Units.m, particleType=dataclasses.I3Particle.ParticleType.MuMinus, impl='proposal', mediadef=expandvars('$I3_BUILD/mmc-icetray/resources/mediadef')): """ Create a muon propagator service. :param radius: radius of the target cylinder :param length: full height of the target cylinder :param impl: if "mmc", use MMC, otherwise use PROPOSAL :param mediadef: path to MMC media definition file """ seed = 12345 # fixed seed, RNG will be re-set by the propagator module if impl.lower() == 'mmc': from icecube import sim_services, c2j_icetray, mmc_icetray, icetray jvmOpts = icetray.vector_string( ) # fill this with parameters passed directly to the JavaVM jvmOpts.append(expandvars("-Djava.class.path=$I3_BUILD/lib/mmc.jar")) jvmOpts.append("-Xms256m") jvmOpts.append("-Xmx512m") jvmOpts.append("-XX:-HeapDumpOnOutOfMemoryError") # Now create the MMC propagators, but first *all* of the options must be set here. # There's no special options added behind the scenes. This is much more flexible. # Below are the standard options. To interpret them see the MMC docs. mmcOpts = "-romb=5 -raw -user -sdec -time -lpm -bs=1 -ph=3 -bb=2 -sh=2 -frho -cont " mmcOpts += expandvars("-tdir=$I3_BUILD/mmc-icetray/resources ") mmcOpts += expandvars("-mediadef=%s " % mediadef) mmcOpts += "-radius=%d " % radius mmcOpts += "-length=%d " % length mmcOpts += "-seed=%d " % seed if particleType in [ dataclasses.I3Particle.ParticleType.MuMinus, dataclasses.I3Particle.ParticleType.MuPlus ]: pass # no extra options necessary elif particleType in [ dataclasses.I3Particle.ParticleType.TauMinus, dataclasses.I3Particle.ParticleType.TauPlus ]: mmcOpts += "tau " else: raise RuntimeError("Cannot propagate particle type!") jvm = c2j_icetray.I3JavaVM(jvmOpts) return mmc_icetray.I3PropagatorServiceMMC(jvm, mmcOpts) elif impl.lower() == 'proposal': from icecube import sim_services, PROPOSAL return PROPOSAL.I3PropagatorServicePROPOSAL(mediadef=mediadef, cylinderRadius=radius, cylinderHeight=length, type=particleType) else: raise RuntimeError("unknown propagator: %s" % impl)
#!/usr/bin/env python from __future__ import print_function from icecube import dataclasses, phys_services, PROPOSAL from math import acos, pi p = dataclasses.I3Particle(dataclasses.I3Position(0, 0, -850), dataclasses.I3Direction(0, 0, 1), 0) p.location_type = p.InIce p.type = p.TauMinus p.energy = 1e5 prop = PROPOSAL.I3PropagatorServicePROPOSAL() prop.SetRandomNumberGenerator(phys_services.I3GSLRandomService(0)) products = [] for _ in range(20): p.length = 0 daughters = prop.Propagate(p) products.append(daughters) try: assert any([ p.MuMinus in [pp.type for pp in daughters] for daughters in products ]), "taus decay to muons even outside active volume" except AssertionError: print([[pp.type for pp in daughters] for daughters in products]) raise for daughters in products: try:
#!/usr/bin/env python from I3Tray import I3Units from I3Tray import NaN from icecube import dataclasses as dc from icecube import icetray from icecube import PROPOSAL from icecube import simclasses ptype = dc.I3Particle.MuMinus propagator = PROPOSAL.I3PropagatorServicePROPOSAL( config_file="$I3_BUILD/PROPOSAL/resources/config_icesim.json" ) mu = dc.I3Particle() mu.type = ptype mu.pos = dc.I3Position(0, 0, 0) mu.dir = dc.I3Direction(0, 0) mu.energy = 100 * I3Units.TeV mu.time = 0 * I3Units.ns mu.location_type = dc.I3Particle.InIce mu_length = list() n_daughters = list() for i in range(1000): mu.length = 0 mu.pos = dc.I3Position(0, 0, 0) mu.dir = dc.I3Direction(0, 0) mu.energy = 100 * I3Units.TeV mu.time = 0 * I3Units.ns
#!/usr/bin/env python from I3Tray import I3Units from I3Tray import NaN from icecube import dataclasses as dc from icecube import PROPOSAL from icecube import simclasses propagator = PROPOSAL.I3PropagatorServicePROPOSAL("-tau") tau = dc.I3Particle() tau.type = dc.I3Particle.TauMinus tau.pos = dc.I3Position(0,0,0) tau.dir = dc.I3Direction(0,0) tau.energy = 100 * I3Units.TeV tau.time = 0 * I3Units.ns tau.location_type = dc.I3Particle.InIce tau_length = list() for i in range(100000): tau.length = NaN daughters = dc.I3ParticleVect() # returns None instead of an I3MMCTrack mmctrack = propagator.propagate(tau,daughters) # length of daughters is always 1 tau_length.append(tau.length) try: import pylab pylab.title("Tau Lengths")
#!/usr/bin/env python from I3Tray import I3Units from I3Tray import NaN from icecube import dataclasses as dc from icecube import icetray from icecube import PROPOSAL from icecube import simclasses ptype = dc.I3Particle.TauMinus propagator = PROPOSAL.I3PropagatorServicePROPOSAL(type=ptype) mu = dc.I3Particle() mu.type = ptype mu.pos = dc.I3Position(0, 0, 0) mu.dir = dc.I3Direction(0, 0) mu.energy = 100 * I3Units.TeV mu.time = 0 * I3Units.ns mu.location_type = dc.I3Particle.InIce mu_length = list() n_daughters = list() for i in range(10000): mu.length = NaN # returns None instead of an I3MMCTrack daughters = propagator.Propagate(mu) # length of daughters is always 1 mu_length.append(mu.length) n_daughters.append(len(daughters)) try:
### ADDING PROPAGATOR ### tray.AddModule("I3GENIEResultDictToMCTree", "toMcTree", MCTreeName="I3MCTree_preprop", WeightDictName="I3MCWeightDict_GENIE") # tray.AddModule("Rename", # Keys = ["I3MCTree","I3MCTree_preprop"]) from icecube import PROPOSAL, sim_services propagators = sim_services.I3ParticleTypePropagatorServiceMap() mediadef = expandvars('$I3_BUILD/PROPOSAL/resources/mediadef') muMinusPropagator = PROPOSAL.I3PropagatorServicePROPOSAL( mediadef=mediadef, cylinderRadius=1200, cylinderHeight=1700, type=dataclasses.I3Particle.ParticleType.MuMinus) muPlusPropagator = PROPOSAL.I3PropagatorServicePROPOSAL( mediadef=mediadef, cylinderRadius=1200, cylinderHeight=1700, type=dataclasses.I3Particle.ParticleType.MuPlus) propagators[ dataclasses.I3Particle.ParticleType.MuMinus] = muMinusPropagator propagators[dataclasses.I3Particle.ParticleType.MuPlus] = muPlusPropagator tray.AddModule( 'I3PropagatorModule', 'muon_propagator', PropagatorServices=propagators,