示例#1
0
def make_DC_muon_hadron_hypothesis(frame, pdg=13):
    new_muon = dataclasses.I3Particle()
    new_muon.pos.x = temp_parameters[0]
    new_muon.pos.y = temp_parameters[1]
    new_muon.pos.z = temp_parameters[2]
    new_muon.time = temp_parameters[5]
    new_direction = dataclasses.I3Direction(temp_parameters[4],
                                            temp_parameters[3])
    new_muon.dir = new_direction
    new_muon.length = temp_parameters[7]
    new_muon.energy = temp_parameters[7] / muon_energy_loss
    new_muon.pdg_encoding = pdg
    hypothesis = dataclasses.I3VectorI3Particle()
    hypothesis.append(new_muon)
    new_hadron = dataclasses.I3Particle()
    new_hadron.pos.x = temp_parameters[0]
    new_hadron.pos.y = temp_parameters[1]
    new_hadron.pos.z = temp_parameters[2]
    new_hadron.time = temp_parameters[5]
    #change temp_parameters to 3, to 4 here to say hadron and muon angles are the same
    new_direction = dataclasses.I3Direction(temp_parameters[9],
                                            temp_parameters[8])
    new_hadron.dir = new_direction
    new_hadron.energy = temp_parameters[6]
    new_hadron.pdg_encoding = hadron_pdg
    hypothesis.append(new_hadron)
    frame["DC_cascade_hypothesis_" + str(event_counter)] = hypothesis
示例#2
0
    def DAQ(self, frame):
        daughter = dataclasses.I3Particle()
        daughter.type = self.particleType
        daughter.energy = self.energy
        daughter.pos = dataclasses.I3Position(self.xCoord, self.yCoord,
                                              self.zCoord)
        daughter.dir = dataclasses.I3Direction(0., 0., -1.)
        daughter.time = 0.
        daughter.location_type = dataclasses.I3Particle.LocationType.InIce

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

        mctree = dataclasses.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()
示例#3
0
    def _create_mc_tree(self, inj_pos, inj_time, inj_dir):
        """Inject accompanying muon in provided I3MCTree

        Parameters
        ----------
        inj_pos : I3Position
            The position at which to inject the muon.
        inj_time : double
            The time at which to inject the muon.
        inj_dir : I3Direction
            The direction of the injected muon.

        Returns
        -------
        I3MCTree
            The modified I3MCTree with the injected Muon.
        I3MapStringDouble
            Information on the injected muon.
        """
        mc_tree = dataclasses.I3MCTree()
        muon_primary = dataclasses.I3Particle()
        muon_primary.shape = dataclasses.I3Particle.ParticleShape.Primary
        muon_primary.dir = dataclasses.I3Direction(inj_dir)
        muon_primary.pos = dataclasses.I3Position(inj_pos)
        muon_primary.time = inj_time

        muon = dataclasses.I3Particle()
        muon.dir = dataclasses.I3Direction(inj_dir)
        muon.pos = dataclasses.I3Position(inj_pos)
        muon.time = inj_time
        muon.location_type = dataclasses.I3Particle.LocationType.InIce

        # sample type: MuPlus or MuMinus
        u = self.random_service.uniform(0., 1.)
        if u > 0.5:
            pdg_encoding = 13
        else:
            pdg_encoding = -13
        muon.pdg_encoding = pdg_encoding

        # sample energy
        muon.energy = self._sample_energy()

        # add muon primary to I3MCTree
        mc_tree.add_primary(muon_primary)

        # add muon as new child
        mc_tree.append_child(muon_primary, muon)

        # add info
        injection_info = dataclasses.I3MapStringDouble({
            'muon_energy':
            muon.energy,
            'muon_pdg_encoding':
            muon.pdg_encoding,
        })

        return mc_tree, injection_info
示例#4
0
def make_mctree(frame, linearized=True):
    tree = dataclasses.I3MCTree()
    p1 = dataclasses.I3Particle()
    tree.insert(p1)
    p2 = dataclasses.I3Particle()
    tree.append_child(p1, p2)
    if linearized:
        tree = dataclasses.I3LinearizedMCTree(tree)
    frame['I3MCTree'] = tree
    def test_get_most_energetic_primary(self):
        primary1 = dc.I3Particle()
        primary1.energy = 10 * I3Units.TeV
    
        primary2 = dc.I3Particle()
        primary2.energy = 1 * I3Units.TeV

        tree = dc.I3MCTree()
        tree.insert(primary1)
        tree.insert(primary2)

        mep = get_most_energetic_primary(tree)
        self.assertTrue(mep, "got no particles, but there are primaries.")
        self.assertEqual(mep.id, primary1.id, "got the wrong particle.")
    def Process(self):
        frame = icetray.I3Frame(icetray.I3Frame.DAQ)
        mctree = dataclasses.I3MCTree()

        cascade = dataclasses.I3Particle(dataclasses.I3Particle.Primary,
                                         dataclasses.I3Particle.EPlus)
        muon = dataclasses.I3Particle(dataclasses.I3Particle.Primary,
                                      dataclasses.I3Particle.MuPlus)

        mctree.add_primary(cascade)
        mctree.add_primary(muon)

        frame["I3MCTree"] = mctree
        self.PushFrame(frame)
示例#7
0
def Hybridforge(frame, seed, seedTime, factor, output): #seedC, seedT, output):
    if frame.Has(seed):
        source = frame[seed]
	sourceTime = frame[seedTime]
#	sourceT = frame[seedT]
#	sourceC = frame[seedC]
	if frame.Has("String1Pulses"):
		cogPos = common_variables.hit_statistics.calculate_cog(geometry_,frame["String1Pulses"].apply(frame))
	else:
		cogPos = frame["FirstHLCvertex"].pos
	qtot = common_variables.hit_statistics.calculate_q_tot_pulses(geometry_,frame['OfflinePulses_sRT'].apply(frame)) #"SRTTWOfflinePulsesDC"
        forged_particle = dataclasses.I3Particle()
#        forged_particle.energy = sourceT.energy + sourceC.energy
	forged_particle.energy = qtot.value
#	forged_particle.length = sourceT.length
	forged_particle.length = factor*qtot.value
        forged_particle.dir = source.dir
        forged_particle.pos.x = cogPos.x+2
        forged_particle.pos.y = cogPos.y+2
        forged_particle.pos.z = cogPos.z-2
        forged_particle.time = sourceTime.time
        forged_particle.speed = 0.29979245799999998
        forged_particle.shape = dataclasses.I3Particle.ParticleShape.ContainedTrack
        forged_particle.fit_status = dataclasses.I3Particle.FitStatus.OK
        frame.Put(output, forged_particle)
示例#8
0
def make_seed(frame):
    truth = frame['trueCascade']
    trueX = truth.pos.x
    trueY = truth.pos.y
    trueZ = truth.pos.z
    #print trueX, trueZ
    xsteps = options.xsteps
    #ysteps = options.zsteps
    zsteps = options.zsteps
    #print xsteps, zsteps
    xstepsize = options.xstepsize
    #ystepsize = options.zstepsize
    zstepsize = options.zstepsize
    #print xstepsize, zstepsize
    startX = trueX - (xsteps / 2.) * xstepsize
    #startY = trueY - (ysteps/2.)*ystepsize
    startZ = trueZ - (zsteps / 2.) * zstepsize
    #print startX, startZ
    testX = startX + options.x * xstepsize
    #testY = startY + options.z*ystepsize
    testZ = startZ + options.z * zstepsize
    #print testX, testZ
    newparticle = dataclasses.I3Particle(truth)
    newparticle.pos.x = testX
    #newparticle.pos.y = testY
    newparticle.pos.z = testZ
    #print newparticle
    frame['trueCascade_seed'] = newparticle
示例#9
0
        def Generator(frame,
                      FromEnergy=1 * I3Units.TeV,
                      ToEnergy=1 * I3Units.TeV):
            p = dataclasses.I3Particle()
            p.energy = random.uniform(FromEnergy, ToEnergy)
            p.pos = dataclasses.I3Position(0, 0, 0)

            # sample on a cylinder
            theta = random.uniform(0., 2 * pi)
            r = sqrt(random.uniform(0, 300 * I3Units.m * 300 * I3Units.m))

            x = r * sin(theta)
            y = r * cos(theta)
            z = random.uniform(-300 * I3Units.m, 300 * I3Units.m)

            zenith = random.uniform(0., pi)
            azimuth = random.uniform(0., 2 * pi)
            p.dir = dataclasses.I3Direction(zenith, azimuth)
            p.length = 500 * I3Units.m
            p.type = dataclasses.I3Particle.ParticleType.EMinus
            p.location_type = dataclasses.I3Particle.LocationType.InIce
            p.time = 0. * I3Units.ns

            tree = dataclasses.I3MCTree()
            tree.add_primary(p)

            frame["I3MCTree"] = tree
def muon_injector(frame):
    zenith = randomService.uniform(ZenithMin, ZenithMax)
    azimuth = randomService.uniform(0, 360 * I3Units.degree)
    x = CylinderRadius * math.cos(azimuth)
    y = CylinderRadius * math.sin(azimuth)
    z = CylinderRadius * math.cos(zenith)

    global mu_type
    if mu_type == dataclasses.I3Particle.MuMinus:
        mu_type = dataclasses.I3Particle.MuPlus
    else:
        mu_type = dataclasses.I3Particle.MuMinus

    mu = dataclasses.I3Particle()
    mu.type = mu_type
    mu.pos = dataclasses.I3Position(x, y, z)
    mu.dir = dataclasses.I3Direction(zenith, azimuth)
    mu.energy = MuonEnergy
    mu.time = 0 * I3Units.ns
    mu.length = NaN
    mu.location_type = dataclasses.I3Particle.InIce

    mctree = dataclasses.I3MCTree()
    mctree.add_primary(mu)
    frame["I3MCTree_preMuonProp"] = mctree
示例#11
0
def BestFit(frame):
    global pt_tup, delete_keys
    content_map = []
    igel_seed = frame[vert_seed]
    #  for i in xrange(len(pt_tup)):
    #    for j in xrange(num_mins):
    seed_id = 'Seed'
    millipede_id = 'Milli_'

    millipede = frame[millipede_id]
    millipede_fitparams = frame[millipede_id + 'FitParams']
    rlogl = millipede_fitparams.rlogl
    content_map.append([rlogl, millipede_id])
    fit = min(content_map, key=lambda content_map: content_map[0])
    fit_rlogl = fit[0]
    fit_id = fit[1]
    print 'Looking for the best fit', fit_id
    track_fit = frame[fit_id]
    track_fit_fitparams = frame[fit_id + 'FitParams']

    zenith, azimuth = track_fit[0].dir.zenith, track_fit[0].dir.azimuth
    forged_particle = dataclasses.I3Particle()
    forged_particle.energy = 0
    forged_particle.dir = dataclasses.I3Direction(zenith, azimuth)
    forged_particle.pos.x = igel_seed.pos.x
    forged_particle.pos.y = igel_seed.pos.y
    forged_particle.pos.z = igel_seed.pos.z
    forged_particle.time = igel_seed.time
    forged_particle.speed = 0.299792
    forged_particle.shape = igel_seed.shape.InfiniteTrack

    frame["BlumeFit"] = forged_particle
示例#12
0
    def Process(self):
        try:
            c = next(self.lines)
        except StopIteration:
            self.RequestSuspension()
            return

        eq = astro.I3Equatorial(c[0] * I3Units.degree, c[1] * I3Units.degree)
        time = dataclasses.I3Time(2015, 0)
        direction = astro.I3GetDirectionFromEquatorial(eq, time)

        eqq = astro.I3GetEquatorialFromDirection(direction, time)

        particle = dataclasses.I3Particle()
        particle.dir = direction

        header = dataclasses.I3EventHeader()
        header.start_time = time

        frame = icetray.I3Frame("P")
        if self.evthdr:
            frame["I3EventHeader"] = header
        frame["Particle"] = particle

        self.PushFrame(frame)
示例#13
0
def GetMostEnergeticCascade(frame):
	if frame.Has('I3MCTree'):
		name = "MostEnergeticCascade"
		tree = frame['I3MCTree']
		maincascade = dataclasses.I3Particle(dataclasses.get_most_energetic_cascade(tree))
		maincascade.fit_status = dataclasses.I3Particle.OK
		frame.Put("MostEnergeticCascade", maincascade)
示例#14
0
 def add_fake_scan(frame):
     fp = millipede.MillipedeFitParams()
     fp.logl = random.uniform(4000.,6000.)
     frame["MillipedeStarting2ndPass_millipedellh"] = fp
     p = dataclasses.I3Particle()
     frame["MillipedeStarting2ndPass"] = p
     time.sleep(0.1)
示例#15
0
    def Process(self):

        if self.counter % 20 == 0:
            sframe = icetray.I3Frame('S')
            info = simclasses.I3CorsikaInfo()
            sframe['I3CorsikaInfo'] = info
            self.PushFrame(sframe)

        qframe = icetray.I3Frame('Q')
        eh = dataclasses.I3EventHeader()
        eh.run_id = 1
        eh.event_id = self.counter
        qframe['I3EventHeader'] = eh

        tree = dataclasses.I3MCTree()
        p1 = dataclasses.I3Particle()
        tree.insert(p1)

        if self.counter % 2 == 0:
            qframe['I3MCTree'] = tree
            qframe['I3MCPrimary'] = p1

        self.PushFrame(qframe)
        self.counter += 1

        if self.counter >= 100:
            self.RequestSuspension()
示例#16
0
 def weight(x, y, z, zenith, azimuth, multiplicity, e, r):
     axis = dataclasses.I3Particle()
     axis.pos = dataclasses.I3Position(x, y, z)
     axis.dir = dataclasses.I3Direction(zenith, azimuth)
     assert multiplicity == 1
     bundle = MuonGun.BundleConfiguration()
     bundle.append(MuonGun.BundleEntry(float(r), float(e)))
     return weighter(axis, bundle)
def charge_localization(
    frame,
    pulses=''
):  # the algorithm that computes the reconstructed muon track. Can be used in this form as a module in icetray script.
    pulse_series = dataclasses.I3RecoPulseSeriesMap.from_frame(frame, pulses)
    DOMcharge = []  ## getting the charge deposited in each DOM
    for omkey, pulses in pulse_series:
        DOMcharge.append(
            np.array([omkey.string, omkey.om,
                      sum([p.charge for p in pulses])]))
    DOMcharge = np.asarray(DOMcharge)
    localized_charge, total_event_charge = localize(
        DOMcharge
    )  ## returns [string, om, % total event charge], total charge of the event
    brightest_dom_coord = DOMcoord[
        int(localized_charge[0][0]),
        int(localized_charge[0][1])]  ## coordintates of the brightest DOM
    brightest_dom_charge = localized_charge[0][2]
    second_brightest_dom_charge = 0
    for dom in localized_charge:
        if int(localized_charge[0][0]) != int(
                dom[0]
        ):  # if the second brightest DOM is on the same string as the brightest, add its charge to the brightest, move on to next brightest DOM
            second_brightest_dom_coord = DOMcoord[int(dom[0]), int(dom[1])]
            second_brightest_dom_charge = dom[2]
            break
        else:
            second_brightest_dom_coord = DOMcoord[int(dom[0]), int(dom[1])]
            brightest_dom_charge = +dom[2]
    brightest_dom_distance = np.linalg.norm(
        brightest_dom_coord - second_brightest_dom_coord
    )  ## distance betweeen the two brightest DOMs, called the lever arm
    if brightest_dom_coord[2] > second_brightest_dom_coord[2]:
        charge_localization_vector = (
            brightest_dom_coord -
            second_brightest_dom_coord) / brightest_dom_distance
    else:
        charge_localization_vector = (
            second_brightest_dom_coord -
            brightest_dom_coord) / brightest_dom_distance
    localization_zenith, localization_azimuth = angles(
        charge_localization_vector)
    particle = dataclasses.I3Particle(
    )  # creating an I3Particle object containing direction and length information
    particle.dir = dataclasses.I3Direction(-charge_localization_vector[0],
                                           -charge_localization_vector[1],
                                           -charge_localization_vector[2])
    particle.pos = dataclasses.I3Position(brightest_dom_coord[0],
                                          brightest_dom_coord[1],
                                          brightest_dom_coord[2])
    frame[
        'localization_line'] = particle  # writing I3Particle object to the I3File
    particle.length = brightest_dom_distance
    frame['brightest_dom_charge'] = dataclasses.I3Double(
        brightest_dom_charge
    )  # writing brightest and second brightest DOM charge to I3File
    frame['second_brightest_dom_charge'] = dataclasses.I3Double(
        second_brightest_dom_charge)
示例#18
0
def make_seed(frame):
    fPart = frame["CascadeLast_DC"]
    myPart = dataclasses.I3Particle(fPart)
    myPartP3X = dataclasses.I3Particle(fPart)
    myPartP3Y = dataclasses.I3Particle(fPart)
    myPartP3Z = dataclasses.I3Particle(fPart)
    myPartN3X = dataclasses.I3Particle(fPart)
    myPartN3Y = dataclasses.I3Particle(fPart)
    myPartN3Z = dataclasses.I3Particle(fPart)
    xPos = frame["ThreePosX"].value
    yPos = frame["ThreePosY"].value
    zPos = frame["ThreePosZ"].value
    myPart.pos = dataclasses.I3Position(xPos, yPos, zPos)
    myPartP3X.pos = dataclasses.I3Position(xPos + 3, yPos, zPos)
    myPartP3Y.pos = dataclasses.I3Position(xPos, yPos + 3, zPos)
    myPartP3Z.pos = dataclasses.I3Position(xPos, yPos, zPos + 3)
    myPartN3X.pos = dataclasses.I3Position(xPos - 3, yPos, zPos)
    myPartN3Y.pos = dataclasses.I3Position(xPos, yPos - 3, zPos)
    myPartN3Z.pos = dataclasses.I3Position(xPos, yPos, zPos - 3)
    frame["MySeed"] = myPart
    frame["MySeedP3X"] = myPartP3X
    frame["MySeedP3Y"] = myPartP3Y
    frame["MySeedP3Z"] = myPartP3Z
    frame["MySeedN3X"] = myPartN3X
    frame["MySeedN3Y"] = myPartN3Y
    frame["MySeedN3Z"] = myPartN3Z
 def make_particle():
     p = dataclasses.I3Particle()
     p.pos = dataclasses.I3Position(0, 0, 2e3)
     p.dir = dataclasses.I3Direction(0, 0)
     p.time = 0
     p.energy = 10**randomService.Uniform(3, 6)
     p.type = p.DeltaE
     p.location_type = p.InIce
     return p
示例#20
0
 def forgeseed(fr):
     seed = dataclasses.I3Particle()
     seed.pos=fr['CascadeLlhVertexFit_DP'].pos
     seed.time=fr['CascadeLlhVertexFit_DP'].time
     seed.dir=fr['SPEFit32_DP'].dir
     seed.shape=dataclasses.I3Particle.Cascade
     seed.type=dataclasses.I3Particle.EMinus
     seed.fit_status=dataclasses.I3Particle.OK
     fr['CascadeSeed']=seed
示例#21
0
def particle(f):
    p = dataclasses.I3Particle(dataclasses.I3Position(0, 0, 0),
                               dataclasses.I3Direction(0, 0, 1), 0,
                               dataclasses.I3Particle.Cascade, 0)
    p.type = dataclasses.I3Particle.ParticleType.EMinus
    p.location_type = dataclasses.I3Particle.LocationType.InIce
    p.energy = 1.e5 * I3Units.GeV
    t = dataclasses.I3MCTree()
    t.add_primary(p)
    f["particle"] = t
示例#22
0
    def DAQ(self, frame):

        azi = self.rs.uniform(self.azimuthMin, self.azimuthMax)

        cos_zen_low = math.cos(self.zenithMin / I3Units.radian)
        cos_zen_high = math.cos(self.zenithMax / I3Units.radian)
        zen = math.acos(self.rs.uniform(cos_zen_low, cos_zen_high))

        r = self.ConstructPerpVector(zen, azi) * math.sqrt(
            self.rs.uniform(0, self.diskRadius**2))

        diskCenter = self.sphereRadius * numpy.array([math.sin(zen) * math.cos(azi),\
                                                      math.sin(zen) * math.sin(azi),
                                                      math.cos(zen)])

        pos = diskCenter + r

        # set the particle's energy
        energy = self.rs.uniform(self.energyMin, self.energyMax) * I3Units.GeV

        daughter = dataclasses.I3Particle()
        daughter.type = self.particleType
        daughter.energy = energy
        daughter.pos = dataclasses.I3Position(pos[0], pos[1], pos[2])
        daughter.dir = dataclasses.I3Direction(zen, azi)
        daughter.time = 0.
        daughter.location_type = dataclasses.I3Particle.LocationType.InIce

        primary = dataclasses.I3Particle()
        primary.type = dataclasses.I3Particle.ParticleType.NuMu
        primary.energy = energy
        primary.pos = dataclasses.I3Position(pos[0], pos[1], pos[2])
        primary.dir = dataclasses.I3Direction(zen, azi)
        primary.time = 0.
        primary.location_type = dataclasses.I3Particle.LocationType.Anywhere

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

        frame["I3MCTree_preMuonProp"] = mctree

        self.PushFrame(frame)
示例#23
0
def makeSeed(vertSeed, zen, azi):
    partPos = vertSeed.pos
    partDir = dataclasses.I3Direction(zen, azi)
    partTime = vertSeed.time
    partLength = vertSeed.length
    partShape = dataclasses.I3Particle.ParticleShape.InfiniteTrack

    seedPart = dataclasses.I3Particle(partPos, partDir, partTime, partShape,
                                      partLength)

    return seedPart
示例#24
0
def make_i3_particle( particle_data ):
    """
    This takes one of the lists/tuples from the hdf5 datatable for a particle.
    It converts it into an I3Particle 
    """
    pt = dataclasses.I3Particle()
    pt.pdg_encoding = int(particle_data[1])
    pt.pos = dataclasses.I3Position( particle_data[2][0], particle_data[2][1], particle_data[2][2])
    pt.dir = dataclasses.I3Direction(particle_data[3][0], particle_data[3][1])
    pt.energy = particle_data[4]*I3Units.GeV
    return(pt)
示例#25
0
    def DAQ(self, frame):

        azi = self.rs.uniform(self.azimuthMin, self.azimuthMax)

        cos_zen_low = math.cos(self.zenithMin / I3Units.radian)
        cos_zen_high = math.cos(self.zenithMax / I3Units.radian)
        zen = math.acos(self.rs.uniform(cos_zen_low, cos_zen_high))

        while True:
            posX = self.rs.uniform(-self.cylinderRadius, self.cylinderRadius)
            posY = self.rs.uniform(-self.cylinderRadius, self.cylinderRadius)
            if posX**2 + posY**2 < self.cylinderRadius**2: break
        posZ = self.rs.uniform(-self.cylinderHeight / 2.,
                               self.cylinderHeight / 2.)

        # set the particle's energy
        energy = self.rs.uniform(self.energyMin, self.energyMax) * I3Units.GeV

        daughter = dataclasses.I3Particle()
        daughter.type = self.particleType
        daughter.energy = energy
        daughter.pos = dataclasses.I3Position(posX, posY, posZ)
        daughter.dir = dataclasses.I3Direction(zen, azi)
        daughter.time = 0.
        daughter.location_type = dataclasses.I3Particle.LocationType.InIce

        primary = dataclasses.I3Particle()
        primary.type = dataclasses.I3Particle.ParticleType.NuMu
        primary.energy = energy
        primary.pos = dataclasses.I3Position(posX, posY, posZ)
        primary.dir = dataclasses.I3Direction(zen, azi)
        primary.time = 0.
        primary.location_type = dataclasses.I3Particle.LocationType.Anywhere

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

        frame["I3MCTree_preMuonProp"] = mctree

        self.PushFrame(frame)
示例#26
0
    def CreatePFrame(self, nside, pixel):
        dec, ra = healpy.pix2ang(nside, pixel)
        dec = dec - numpy.pi / 2.
        zenith, azimuth = astro.equa_to_dir(ra, dec, self.event_mjd)
        zenith = float(zenith)
        azimuth = float(azimuth)
        direction = dataclasses.I3Direction(zenith, azimuth)

        position = self.seed_position
        time = self.seed_time
        energy = self.seed_energy

        variationDistance = 20. * I3Units.m
        posVariations = [
            dataclasses.I3Position(0., 0., 0.),
            dataclasses.I3Position(-variationDistance, 0., 0.),
            dataclasses.I3Position(variationDistance, 0., 0.),
            dataclasses.I3Position(0., -variationDistance, 0.),
            dataclasses.I3Position(0., variationDistance, 0.),
            dataclasses.I3Position(0., 0., -variationDistance),
            dataclasses.I3Position(0., 0., variationDistance)
        ]

        for i in range(0, len(posVariations)):
            posVariation = posVariations[i]
            p_frame = icetray.I3Frame(icetray.I3Frame.Physics)
            thisPosition = dataclasses.I3Position(position.x + posVariation.x,
                                                  position.y + posVariation.y,
                                                  position.z + posVariation.z)

            # generate the particle from scratch
            particle = dataclasses.I3Particle()
            particle.shape = dataclasses.I3Particle.ParticleShape.InfiniteTrack
            particle.fit_status = dataclasses.I3Particle.FitStatus.OK
            particle.pos = thisPosition
            particle.dir = direction
            particle.time = time
            particle.energy = energy
            p_frame[self.output_particle_name] = particle

            # generate a new event header
            eventHeader = dataclasses.I3EventHeader(self.event_header)
            eventHeader.sub_event_stream = "SCAN_nside%04u_pixel%04u_posvar%04u" % (
                nside, pixel, i)
            eventHeader.sub_event_id = pixel
            p_frame["I3EventHeader"] = eventHeader
            p_frame["SCAN_HealpixPixel"] = icetray.I3Int(int(pixel))
            p_frame["SCAN_HealpixNSide"] = icetray.I3Int(int(nside))
            p_frame["SCAN_PositionVariationIndex"] = icetray.I3Int(int(i))

            for frame in self.GCDQpFrames[0:-1]:
                self.PushFrame(frame)
            self.PushFrame(p_frame)
示例#27
0
def extractMCTreeParticles(frame):
    mctree = frame["I3MCTree"]

    # get tracks in ice/water
    mctracksinice = mctree.get_filter(lambda p: p.location_type == p.InIce)
    mcmuontrack = None
    highestEnergy = -1.
    for track in mctracksinice:
        if track.energy > highestEnergy:
            highestEnergy = track.energy
            mcmuontrack = track

    if mcmuontrack is None:
        mcmuontrack = dataclasses.I3Particle()
    primary = dataclasses.get_most_energetic_primary(mctree)

    if primary is None:
        primary = dataclasses.I3Particle()

    frame["MCMostEnergeticInIce"] = mcmuontrack
    frame["MCMostEnergeticPrimary"] = primary
示例#28
0
			def RFrame(self, frame):
				position = frame[self.input_pos_name]
				time = frame[self.input_time_name].value
				energy = float('NaN')

				self.PushFrame(frame)

				for pixel in self.pixels:
					p_frame = icetray.I3Frame(icetray.I3Frame.Physics)
				
					zenith, azimuth = healpy.pix2ang(self.nside, pixel)
					direction = dataclasses.I3Direction(zenith,azimuth)

					#print "reconstructing with fixed direction", direction, "(npixels=", self.npix, ", pixel=", pixel, ")"
				
				
					variationDistance = 20.*I3Units.m
					posVariations = [dataclasses.I3Position(0.,0.,0.),
									dataclasses.I3Position(-variationDistance,0.,0.),
									dataclasses.I3Position( variationDistance,0.,0.),
									dataclasses.I3Position(0.,-variationDistance,0.),
									dataclasses.I3Position(0., variationDistance,0.),
									dataclasses.I3Position(0.,0.,-variationDistance),
									dataclasses.I3Position(0.,0., variationDistance)]
				
					for i in range(len(posVariations)):
						thisPosition = dataclasses.I3Position(position.x + posVariations[i].x,position.y + posVariations[i].y,position.z + posVariations[i].z)
					
						# generate the particle from scratch
						particle = dataclasses.I3Particle()
						particle.shape = dataclasses.I3Particle.ParticleShape.Cascade
						particle.fit_status = dataclasses.I3Particle.FitStatus.OK
						particle.pos = thisPosition
						particle.dir = direction
						particle.time = time
						particle.energy = energy
					
						thisParticleName = self.output_particle_name
						if i>0: thisParticleName = thisParticleName+"_%i"%i
					
						p_frame[thisParticleName] = particle
					
					p_frame["HealpixPixel"] = icetray.I3Int(int(pixel))
					p_frame["HealpixNSide"] = icetray.I3Int(int(self.nside))
				
					# generate a new event header
					eventHeader = dataclasses.I3EventHeader(frame["I3EventHeader"])
					eventHeader.sub_event_stream = "millipede_scan_nside%04u" % self.nside
					eventHeader.sub_event_id = pixel
					p_frame["I3EventHeader"] = eventHeader
				
					self.PushFrame(p_frame)
示例#29
0
    def calc_factor(particle):
        factor = 0.

        for pos, charge in zip(positions, charges):
            diff = pos - particle.pos
            diff_p = dataclasses.I3Particle()
            diff_p.dir = dataclasses.I3Direction(diff.x, diff.y, diff.z)
            angle = I3Calculator.angle(diff_p, particle)

            distance = max(10, diff.magnitude)
            if distance < 500:
                factor += charge * get_angle_factor(angle) / (distance**3)
        return factor * particle.energy
示例#30
0
def make_DC_cascade_hypothesis(frame, pdg=11):
    new_particle = dataclasses.I3Particle()
    new_particle.pos.x = temp_parameters[0]
    new_particle.pos.y = temp_parameters[1]
    new_particle.pos.z = temp_parameters[2]
    new_particle.time = temp_parameters[5]
    new_direction = dataclasses.I3Direction(temp_parameters[4],
                                            temp_parameters[3])
    new_particle.dir = new_direction
    new_particle.energy = temp_parameters[6]
    new_particle.pdg_encoding = pdg
    hypothesis = dataclasses.I3VectorI3Particle()
    hypothesis.append(new_particle)
    frame["DC_cascade_hypothesis_" + str(event_counter)] = hypothesis