コード例 #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 oscNext_L7_compute_reconstruction_comparisons(frame):
    '''
    Compare RetroReco and SANTA
    '''

    from icecube.dataclasses import I3Direction
    from icecube.oscNext.frame_objects.geom import angular_comparison

    #
    # Compute the angle between Retro Santa recostructed directions
    #

    # Get best SANTA fit
    santa_bestfit = frame[SANTA_BEST_KEY] if frame.Has(
        SANTA_BEST_KEY) else None

    # Get directions to compare
    santa_bestfit_dir = santa_bestfit.dir if santa_bestfit is not None else I3Direction(
    )  # Null if nothing is there
    retro_bestfit_dir = I3Direction(frame[L7_FINAL_RECO_ZENITH_KEY].value,
                                    frame[L7_FINAL_RECO_AZIMUTH_KEY].value)

    # Compare
    frame[L7_SANTA_RETRO_ANGLE_DIFF_KEY] = angular_comparison(
        santa_bestfit_dir, retro_bestfit_dir)
コード例 #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 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:])
     ]
コード例 #6
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
コード例 #7
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
コード例 #8
0
ファイル: tabulator.py プロジェクト: recepkandemir/clsim
 def reference_source(zenith, azimuth, scale):
     source = I3Particle()
     source.type = ptype
     source.energy = Energy*scale
     source.dir = I3Direction(zenith, azimuth)
     source.pos = surface.sample_impact_position(source.dir, randomService)
     crossings = surface.intersection(source.pos, source.dir)
     source.length = crossings.second-crossings.first
     source.time = 0.
     source.location_type = I3Particle.LocationType.InIce
     
     return source
コード例 #9
0
ファイル: tools.py プロジェクト: jrbourbeau/cr-composition
def get_direction(geometry, pulses, barycenter, barytime, front_time):
    import numpy
    from icecube.dataclasses import I3Constants
    from icecube.dataclasses import I3Direction

    sumw = 0
    sumx = 0
    sumy = 0
    sumx2 = 0
    sumy2 = 0
    sumxy = 0
    sumt = 0
    sumxt = 0
    sumyt = 0
    for k in pulses.keys():
        for launch, p in enumerate(pulses[k]):
            dx = tank_geometry(geometry, k).position.x - barycenter.x
            dy = tank_geometry(geometry, k).position.y - barycenter.y
            dt = p.time - barytime

            sumx += dx
            sumy += dy
            sumx2 += dx * dx
            sumy2 += dy * dy
            sumxy += dx * dy
            sumt += dt
            sumxt += dt * dx
            sumyt += dt * dy

    rxx = sumw * sumy2 - sumy * sumy
    ryy = sumw * sumx2 - sumx * sumx
    rxy = sumx * sumy - sumw * sumxy
    rx = sumxy * sumy - sumx * sumy2
    ry = sumxy * sumx - sumy * sumx2
    rr = sumx2 * sumy2 - sumxy * sumxy
    deter = sumx2 * rxx + sumxy * rxy + sumx * rx

    if deter == 0 or deter is numpy.nan:
        return None

    u = (rxx * sumxt + rxy * sumyt + rx * sumt) / deter
    u *= -I3Constants.c
    v = (rxy * sumxt + ryy * sumyt + ry * sumt) / deter
    v *= -I3Constants.c
    t0 = (rx * sumxt + ry * sumyt + rr * sumt) / deter

    return I3Direction(u, v, numpy.sqrt(u * u + v * v))
コード例 #10
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
コード例 #11
0
    track_energy
    cascade_energy

    Returns
    -------
    total_energy

    """
    return const_en_to_gms_en(track_energy) + em2hadr(cascade_energy)


DEFAULT_I3PARTICLE_ATTRS = {
    "dir":
    dict(
        fields=["zenith", "azimuth"],
        func=lambda zenith, azimuth: I3Direction(float(zenith), float(azimuth)
                                                 ),
    ),
    "energy":
    dict(fields="energy", func=None, units=I3Units.GeV),
    "fit_status":
    dict(fields="fit_status", func=I3Particle.FitStatus),
    "length":
    dict(value=np.nan, units=I3Units.m),
    # "location_type" deprecated according to `dataclasses/resources/docs/particle.rst`
    "pdg_encoding":
    dict(value=I3Particle.ParticleType.unknown),
    "pos.x":
    dict(fields="x", units=I3Units.m),
    "pos.y":
    dict(fields="y", units=I3Units.m),
    "pos.z":
コード例 #12
0
ファイル: unthinner_plots2.py プロジェクト: wardVD/IceSimV05
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()
        p.type = I3Particle.MuMinus
コード例 #13
0
                                          cpp_surface.area(dir))

    # test acceptance calculation
    ct = numpy.random.uniform(-1, 1, size=2 * 1000).reshape(2, 1000)
    ct.sort(axis=0)
    for ct_lo, ct_hi in ct.T:
        py_acceptance = py_surface.entendue(ct_lo, ct_hi)
        cpp_acceptance = cpp_surface.acceptance(ct_lo, ct_hi)
        numpy.testing.assert_almost_equal(py_acceptance, cpp_acceptance)

    rng = I3GSLRandomService(1)
    # test area sampling
    pos, dir = cpp_surface.sample_impact_ray(rng)

    sampler = AxialCylinder(1000, 1000)
    volume = py_surface.length * py_surface.area(I3Direction(0, 0))
    # compare volume and projected area to sampled versions
    for i, (pos, dir) in enumerate(random_points(0, 10)):
        nsamples = 50000
        hits = 0
        depth = 0.
        for _ in range(nsamples):
            pos = sampler.sample_impact_position(dir, rng)
            intersections = cpp_surface.intersection(pos, dir)
            if numpy.isfinite(intersections.first):
                hits += 1
                depth += (intersections.second - intersections.first)
        numpy.testing.assert_allclose(
            float(hits) / nsamples,
            py_surface.area(dir) / sampler.area(dir),
            rtol=2e-2,
コード例 #14
0
ファイル: unthinner_plots3.py プロジェクト: wardVD/IceSimV05
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:
            c = Circle((pos.x, pos.y), sta.radius)
            plt.gca().add_artist(c)
        r1, r2 = sta.ring_radius
        phi1, phi2 = sta.ring_phi