Beispiel #1
0
def PropagateMuons(
    tray,
    name,
    RandomService=None,
    CylinderRadius=1200. * I3Units.m,
    CylinderLength=1700. * I3Units.m,
):

    from I3Tray import I3Units

    from icecube import icetray, dataclasses, phys_services, sim_services, simclasses
    from icecube import cmc

    muPropagator = MakePropagator(
        radius=CylinderRadius,
        length=CylinderLength,
        particleType=dataclasses.I3Particle.ParticleType.MuMinus)
    tauPropagator = MakePropagator(
        radius=CylinderRadius,
        length=CylinderLength,
        particleType=dataclasses.I3Particle.ParticleType.TauMinus)
    cascadePropagator = cmc.I3CascadeMCService(
        phys_services.I3GSLRandomService(1))  # dummy RNG

    # set up propagators
    propagators = sim_services.I3ParticleTypePropagatorServiceMap()
    for pt in 'MuMinus', 'MuPlus':
        propagators[getattr(dataclasses.I3Particle.ParticleType,
                            pt)] = muPropagator
    for pt in 'TauMinus', 'TauPlus':
        propagators[getattr(dataclasses.I3Particle.ParticleType,
                            pt)] = tauPropagator
    for pt in 'DeltaE', 'Brems', 'PairProd', 'NuclInt', 'Hadrons', 'EMinus', 'EPlus':
        propagators[getattr(dataclasses.I3Particle.ParticleType,
                            pt)] = cascadePropagator

    tray.AddModule('I3PropagatorModule',
                   name + '_propagator',
                   PropagatorServices=propagators,
                   RandomService=RandomService,
                   RNGStateName="RNGState",
                   InputMCTreeName="I3MCTree_preMuonProp",
                   OutputMCTreeName="I3MCTree")

    # add empty MMCTrackList objects for events that have none
    def addEmptyMMCTrackList(frame):
        if "MMCTrackList" not in frame:
            frame["MMCTrackList"] = simclasses.I3MMCTrackList()

    tray.AddModule(addEmptyMMCTrackList,
                   name + '_addEmptyMMCTrackList',
                   Streams=[icetray.I3Frame.DAQ])
#!/usr/bin/env python

from icecube import cmc, phys_services, dataclasses
import math

rng = phys_services.I3GSLRandomService(0)

mc = cmc.I3CascadeMCService(rng)

p = dataclasses.I3Particle()
p.dir = dataclasses.I3Direction(0, 0)
p.pos = dataclasses.I3Position(0, 0, 0)
p.time = 0
p.energy = 1e9
p.type = p.EMinus
p.shape = p.Cascade

radiation_length = 0.358 / 0.9216

p.type = p.EMinus
daughters = mc.Propagate(p)
for d in daughters:
    try:
        assert d.type == d.EMinus, "all daughters are EMinus"
        assert abs(d.length - 3 *
                   radiation_length) < 1e-7, "segment is 3 radiation lengths"
        assert d.shape == d.CascadeSegment, "shape is cascade segment"
    except AssertionError:
        print(d)
        raise