コード例 #1
0
        def DAQ(self, frame):
            daughter = I3Particle()
            daughter.type = self.particleType
            daughter.energy = self.energy
            daughter.pos = I3Position(self.xCoord, self.yCoord, self.zCoord)
            daughter.dir = I3Direction(self.zenith, self.azimuth)
            daughter.time = 0.
            daughter.location_type = I3Particle.LocationType.InIce

            primary = I3Particle()
            primary.type = I3Particle.ParticleType.NuMu
            primary.energy = self.energy
            primary.pos = I3Position(self.xCoord, self.yCoord, self.zCoord)
            primary.dir = I3Direction(0., 0., -1.)
            primary.time = 0.
            primary.location_type = I3Particle.LocationType.Anywhere

            mctree = I3MCTree()
            mctree.add_primary(primary)
            mctree.append_child(primary, daughter)

            frame['I3MCTree'] = mctree

            self.PushFrame(frame)

            self.eventCounter += 1
            if self.eventCounter == self.nEvents:
                self.RequestSuspension()
コード例 #2
0
def GetIceCubeCableShadow(CableAngles=from_led7,
                          DOMRadius=165.1 * I3Units.mm,
                          CableRadius=23 * I3Units.mm,
                          CableLength=1 * I3Units.m):
    """
    Get a cylinder representing the position of the cable at each DOM
    
    :param CableAngles: text file containing string, om, angle (degrees), angle error (degrees)
    :param DOMRadius: radius of the DOM sphere
    :param CableRadius: radius of the cable
    :param CableLength: length of the cable segment at each DOM
    :returns: a map of I3ExtraGeometryItem representing the local position of
        the cable *in DOM-centered coordinates*
    """
    # assume the cable runs along the surface of the DOM
    radius = DOMRadius + CableRadius
    shadows = I3MapModuleKeyI3ExtraGeometryItemCylinder()
    for string, om, angle, _ in np.loadtxt(CableAngles,
                                           dtype=[('string', int), ('om', int),
                                                  ('angle', float),
                                                  ('angle_err', float)]):
        pos = I3Position(radius * np.cos(np.radians(angle)),
                         radius * np.sin(np.radians(angle)), 0)
        shadows[ModuleKey(int(string), int(om))] = I3ExtraGeometryItemCylinder(
            pos + I3Position(0, 0, CableLength / 2.),
            pos + I3Position(0, 0, -CableLength / 2.), CableRadius)

    return shadows
コード例 #3
0
def makeFlasherPulse(x, y, z, zenith, azimuth, width, brightness, scale):

    pulse = I3CLSimFlasherPulse()
    pulse.type = I3CLSimFlasherPulse.FlasherPulseType.LED405nm
    pulse.pos = I3Position(x, y, z)
    pulse.dir = I3Direction(zenith, azimuth)
    pulse.time = 0.
    pulse.pulseWidth = (float(width) / 2.) * I3Units.ns
    lightscale = 1. / (
        32582 * 5.21
    )  # scale down to match 1 GeV equivalent electromagnetic cascade energy
    pulse.numberOfPhotonsNoBias = 1.17e10 * lightscale * scale * (
        0.0006753 +
        0.00005593 * float(brightness)) * (float(width) + 13.9 -
                                           (57.5 /
                                            (1. + float(brightness) / 34.4)))

    if numpy.abs(zenith - 90. * I3Units.degree) > 22.5 * I3Units.degree:
        tiltedFlasher = True  # this is only a rough approximation to describe a tilted flasher
    else:
        tiltedFlasher = False

    pulse.angularEmissionSigmaPolar = FlasherInfoVectToFlasherPulseSeriesConverter.LEDangularEmissionProfile[
        (pulse.type, tiltedFlasher)][0]
    pulse.angularEmissionSigmaAzimuthal = FlasherInfoVectToFlasherPulseSeriesConverter.LEDangularEmissionProfile[
        (pulse.type, tiltedFlasher)][1]

    return pulse
コード例 #4
0
def build_i3_particle(reco_pars, particle_type):
    """build an I3Particle from reco parameters"""
    from icecube.dataclasses import I3Particle, I3Constants, I3Position, I3Direction
    from icecube.icetray import I3Units

    shape_map = dict(
        cascade=I3Particle.ParticleShape.Cascade,
        track=I3Particle.ParticleShape.ContainedTrack,
        neutrino=I3Particle.ParticleShape.Primary,
    )

    particle = I3Particle()

    if reco_pars["success"]:
        particle.fit_status = I3Particle.FitStatus.OK
    else:
        particle.fit_status = I3Particle.GeneralFailure

    particle.dir = I3Direction(reco_pars["zenith"], reco_pars["azimuth"])
    particle.energy = _energy_getters[particle_type](reco_pars) * I3Units.GeV
    particle.pdg_encoding = I3Particle.ParticleType.unknown
    particle.pos = I3Position(*(reco_pars[d] * I3Units.m
                                for d in ("x", "y", "z")))
    particle.shape = shape_map[particle_type]
    particle.time = reco_pars["time"] * I3Units.ns
    particle.speed = I3Constants.c

    if particle_type == "track":
        particle.length = particle.energy * TRACK_M_PER_GEV * I3Units.m
    else:
        particle.length = np.nan

    return particle
コード例 #5
0
    def DAQ(self, frame):
        random.seed(self.seed)

        pulse_series = I3CLSimFlasherPulseSeries()

        if self.plane_wave:
            for i in xrange(self.num_of_photons):
                random_vector = I3Position(random.random() * 2 - 1,
                                           random.random() * 2 - 1,
                                           random.random() * 2 - 1)
                shift_vector_a = self.photon_direction.cross(random_vector)
                shift_vector_b = self.photon_direction.cross(shift_vector_a)
                len_a = math.sqrt(shift_vector_a * shift_vector_a)
                len_b = math.sqrt(shift_vector_b * shift_vector_b)
                new_photon_position = self.photon_position + \
                    shift_vector_a / len_a * (random.random() * 2 - 1) * self.plane_wave_size / 2 + \
                    shift_vector_b / len_b * (random.random() * 2 - 1) * self.plane_wave_size / 2
                pulse = self.generate_pulse(new_photon_position,
                                            self.photon_direction, 1)
                pulse_series.append(pulse)
        else:
            pulse = self.generate_pulse(self.photon_position,
                                        self.photon_direction,
                                        self.num_of_photons)
            pulse_series.append(pulse)

        frame[self.series_frame_key] = pulse_series
        self.PushFrame(frame, "OutBox")
コード例 #6
0
 def __init__(self, context):
     icetray.I3Module.__init__(self, context)
     self.AddParameter(
         "SeriesFrameKey",
         "Name of the I3Frame Key the photon flash should be written to",
         "PhotonFlasherPulseSeries")
     self.AddParameter("PhotonPosition",
                       "The position of the photon source.",
                       I3Position(0, 0, 0))
     self.AddParameter("PhotonDirection",
                       "The direction of the photon source",
                       I3Direction(0, 0, 0))
     self.AddParameter(
         "NumOfPhotons",
         "The number of photons to inject from the given position.", 1)
     self.AddParameter(
         "FlasherPulseType",
         "The I3CLSimFlasherPulse.FlasherPulseType of the photon flashs. For a list, see: https://github.com/claudiok/clsim/blob/master/public/clsim/I3CLSimFlasherPulse.h#L59",
         I3CLSimFlasherPulse.FlasherPulseType.LED340nm)
     self.AddParameter(
         "PlaneWave",
         "Whether to start the photons from a plane rather than a point",
         False)
     self.AddParameter("PlaneWaveSize",
                       "How big should the plane be in metres, e.g. 1.0.",
                       1.0)
     self.AddParameter("Seed", "Seed for the random number generator", 1234)
     self.AddOutBox("OutBox")
コード例 #7
0
 def random_points(radius, npoints=10000):
     r = numpy.random.uniform(0, radius**3, size=npoints)**(1. / 3)
     azi = numpy.random.uniform(0, 2 * numpy.pi, size=2 * npoints)
     zen = numpy.arccos(numpy.random.uniform(-1, 1, size=2 * npoints))
     return [
         (I3Position(r_, z1_, a1_, I3Position.sph), I3Direction(z2_, a2_))
         for r_, z1_, a1_, z2_, a2_ in zip(r, zen[:npoints], azi[:npoints],
                                           zen[npoints:], azi[npoints:])
     ]
コード例 #8
0
ファイル: tabulator.py プロジェクト: wardVD/IceSimV05
        def reference_source(zenith, azimuth, scale):
            source = I3Particle()
            source.type = ptype
            source.energy = Energy * scale
            source.pos = I3Position(0., 0., ZCoordinate)
            source.dir = I3Direction(zenith, azimuth)
            source.time = 0.
            source.length = 0.
            source.location_type = I3Particle.LocationType.InIce

            return source
コード例 #9
0
    def reference_source(x, y, z, zenith, azimuth, scale):
        source = I3Particle()
        source.pos = I3Position(x, y, z)
        source.dir = I3Direction(zenith, azimuth)
        source.time = 0.0
        # Following are not used (at least not yet)
        source.type = I3Particle.ParticleType.EMinus
        source.energy = 1.0 * scale
        source.length = 0.0
        source.location_type = I3Particle.LocationType.InIce

        return source
コード例 #10
0
ファイル: extruded_polygon.py プロジェクト: wardVD/IceSimV05
 def make_surfaces(npoints=10, padding=0):
     npoints = 10
     x = numpy.random.uniform(0, 1e3, size=npoints)-5e2
     y = numpy.random.uniform(0, 1e3, size=npoints)-5e2
     z = [-500, 500]
     points = numpy.vstack((x,y)).T
 
     py_surface = ExtrudedPolygon(points, z).expand(padding)
     cpoints = []
     for z_ in z:
         cpoints += [I3Position(x_,y_,z_) for x_,y_ in zip(x,y)]
     cpp_surface = CExtrudedPolygon(cpoints, padding)
     
     return py_surface, cpp_surface
コード例 #11
0
def make_retro_pulse(x, y, z, zenith, azimuth):
    """Retro pulses originate from a DOM with an (x, y, z) coordinate and
    (potentially) a zenith and azimuth orientation (though for now the latter
    are ignored).

    """
    pulse = I3CLSimFlasherPulse()
    pulse.type = I3CLSimFlasherPulse.FlasherPulseType.retro
    pulse.pos = I3Position(x, y, z)
    pulse.dir = I3Direction(zenith, azimuth)
    pulse.time = 0.0
    pulse.numberOfPhotonsNoBias = 10000.

    # Following values don't make a difference
    pulse.pulseWidth = 1.0 * I3Units.ns
    pulse.angularEmissionSigmaPolar = 360.0 * I3Units.deg
    pulse.angularEmissionSigmaAzimuthal = 360.0 * I3Units.deg

    return pulse
コード例 #12
0
ファイル: unthinner_plots2.py プロジェクト: wardVD/IceSimV05
def add_sta(xt, yt):
    pu.add_station(I3Position(xt, yt - 10, -2.5),
                   I3Position(xt, yt + 10, -2.5), 5.0, 5.0)
コード例 #13
0
ファイル: unthinner_plots2.py プロジェクト: wardVD/IceSimV05
# i3logging.set_level_for_unit('ParticleUnthinner', 'DEBUG')

pu = ParticleUnthinner(30, 10, 8)


def add_sta(xt, yt):
    pu.add_station(I3Position(xt, yt - 10, -2.5),
                   I3Position(xt, yt + 10, -2.5), 5.0, 5.0)


add_sta(-10, 0)
add_sta(+10, 0)

for zenith in (0.0, 30.0 * I3Units.degree):
    part = I3Particle()
    part.pos = I3Position(0, 0, 0)
    part.dir = I3Direction(zenith, zenith)
    part.time = 10 * I3Units.ns
    pu.set_primary(part)

    npart = 100000
    ext = pu.grid_rmax / np.cos(zenith)
    xp = ext * (2 * np.random.rand(npart) - 1)
    yp = ext * (2 * np.random.rand(npart) - 1)
    particles = []
    hitmask = []
    stations = pu.stations
    dummy = I3Particle()
    weight = 1.0
    for x, y in zip(xp, yp):
        p = ExtendedI3Particle()
コード例 #14
0
def add_sta(xt, yt):
    pu.add_station(I3Position(xt - 5, yt - 5, 0),
                   I3Position(xt + 5, yt + 5, 0), 1.82, 1.30)
コード例 #15
0
                   I3Position(xt + 5, yt + 5, 0), 1.82, 1.30)


for xt in xrange(-400, 1001, 200):
    add_sta(xt, 0)

for yt in xrange(-400, 1001, 200):
    add_sta(0, yt)

# check coordinate system transform and binning
xl = np.arange(-1000, 1001, 10)
yl = xl

for zenith in (0.0, 60.0 * I3Units.degree):
    part = I3Particle()
    part.pos = I3Position(0, 0, 0)
    part.dir = I3Direction(zenith, zenith)
    pu.set_primary(part)

    zl = np.empty(xl.shape + yl.shape + (2, ))
    for i, x in enumerate(xl):
        for j, y in enumerate(yl):
            zl[i, j] = pu.to_index(I3Position(x, y, 0))

    fig, ax = plt.subplots(1, 2, figsize=(12, 5))
    plt.subplots_adjust(left=0.1, right=0.95, wspace=0.3)
    plt.figtext(0.5,
                0.99, (r'zenith = ${:.0f}^\circ$, '
                       'azimuth = ${:.0f}^\circ$').format(
                           part.dir.zenith / I3Units.degree,
                           part.dir.azimuth / I3Units.degree),
コード例 #16
0
ファイル: unthinner_plots3.py プロジェクト: wardVD/IceSimV05
from icecube.dataclasses import I3Position, I3Direction, I3Particle
from icecube.icetray import I3Units, i3logging
from icecube.phys_services import I3GSLRandomService
from matplotlib import pyplot as plt, cm
from matplotlib.patches import Circle, Polygon
import numpy as np
import sys
import random
from scipy.stats import poisson

np.random.seed(1)
rng = I3GSLRandomService(1)

pu = ParticleUnthinner(20, 10, 16)

pu.add_station(I3Position(100, -1.5, -2.5), I3Position(100, 1.5, 2.5), 1, 1)

part = I3Particle()
part.pos = I3Position(0, 0, 0)
part.dir = I3Direction(0, 0)
part.time = 10 * I3Units.ns
pu.set_primary(part)

show_scenario = False
if show_scenario:
    plt.figure()
    # draw tanks and sampling regions
    x = []
    y = []
    for sta in pu.stations:
        for pos in sta.pos: