Example #1
0
 def test_helix(self):
     cyl1 = SurfaceCylinder('cyl1', 1., 2.)
     cyl2 = SurfaceCylinder('cyl2', 2., 1.)
     field = 3.8
     particle = Particle(LorentzVector(2., 0, 1, 5), Point(0., 0., 0.), -1)
     debug_info = helix.propagate_one(particle, cyl1, field)
     particle = Particle(LorentzVector(0., 2, 1, 5), Point(0., 0., 0.), -1)
     debug_info = helix.propagate_one(particle, cyl1, field)
Example #2
0
    def test_straightline(self):
        origin = Point(0, 0, 0)
        cyl1 = SurfaceCylinder('cyl1', 1, 2)
        cyl2 = SurfaceCylinder('cyl2', 2, 1)

        particle = Particle(LorentzVector(1, 0, 1, 2.), origin, 0)
        straight_line.propagate_one(particle, cyl1)
        straight_line.propagate_one(particle, cyl2)
        self.assertEqual(len(particle.points), 3)
        # test extrapolation to barrel
        self.assertAlmostEqual(particle.points['cyl1'].Perp(), 1.)
        self.assertAlmostEqual(particle.points['cyl1'].Z(), 1.)
        # test extrapolation to endcap
        self.assertAlmostEqual(particle.points['cyl2'].Z(), 1.)

        # testing extrapolation to -z
        particle = Particle(LorentzVector(1, 0, -1, 2.), origin, 0)
        # import pdb; pdb.set_trace()
        straight_line.propagate_one(particle, cyl1)
        straight_line.propagate_one(particle, cyl2)
        self.assertEqual(len(particle.points), 3)
        self.assertAlmostEqual(particle.points['cyl1'].Perp(), 1.)
        # test extrapolation to endcap
        self.assertAlmostEqual(particle.points['cyl1'].Z(), -1.)
        self.assertAlmostEqual(particle.points['cyl2'].Z(), -1.)

        # extrapolating from a vertex close to +endcap
        particle = Particle(LorentzVector(1, 0, 1, 2.), Point(0, 0, 1.5), 0)
        straight_line.propagate_one(particle, cyl1)
        self.assertAlmostEqual(particle.points['cyl1'].Perp(), 0.5)

        # extrapolating from a vertex close to -endcap
        particle = Particle(LorentzVector(1, 0, -1, 2.), Point(0, 0, -1.5), 0)
        straight_line.propagate_one(particle, cyl1)
        self.assertAlmostEqual(particle.points['cyl1'].Perp(), 0.5)

        # extrapolating from a non-zero radius
        particle = Particle(LorentzVector(0, 0.5, 1, 2.), Point(0, 0.5, 0), 0)
        straight_line.propagate_one(particle, cyl1)
        self.assertAlmostEqual(particle.points['cyl1'].Perp(), 1.)
        self.assertAlmostEqual(particle.points['cyl1'].Z(), 1.)

        # extrapolating from a z outside the cylinder
        particle = Particle(LorentzVector(0, 0, -1, 2.), Point(0, 0, 2.5), 0)
        straight_line.propagate_one(particle, cyl1)
        self.assertFalse('cyl1' in particle.points)

        # extrapolating from a z outside the cylinder, negative
        particle = Particle(LorentzVector(0, 0, -1, 2.), Point(0, 0, -2.5), 0)
        straight_line.propagate_one(particle, cyl1)
        self.assertFalse('cyl1' in particle.points)

        # extrapolating from a rho outside the cylinder
        particle = Particle(LorentzVector(0, 0, -1, 2.), Point(0, 1.1, 0), 0)
        straight_line.propagate_one(particle, cyl1)
        self.assertFalse('cyl1' in particle.points)
Example #3
0
def monojet(pdgids, theta, phi, pstar, jetenergy, vertex=None):
    particles = []
    if vertex is None:
        vertex = TVector3(0., 0., 0.)
    jetp4star = TLorentzVector()
    for pdgid in pdgids[:-1]:
        mass, charge = particle_data[pdgid]
        phistar = random.uniform(-math.pi, math.pi)
        thetastar = random.uniform(-math.pi, math.pi)
        sint = math.sin(thetastar)
        cost = math.cos(thetastar)
        sinp = math.sin(phistar)
        cosp = math.cos(phistar)
        pz = pstar * cost
        px = pstar * sint * cosp
        py = pstar * sint * sinp
        p4 = TLorentzVector()
        p4.SetXYZM(px, py, pz, mass)
        jetp4star += p4
        particles.append(Particle(p4, vertex, charge, pdgid))
    pdgid = pdgids[-1]
    mass, charge = particle_data[pdgid]
    p4 = TLorentzVector()
    p4.SetVectM(-jetp4star.Vect(), mass)
    particles.append(Particle(p4, vertex, charge, pdgid))
    jetp4star += p4

    #boosting to lab
    gamma = jetenergy / jetp4star.M()
    beta = math.sqrt(1 - 1 / gamma**2)
    boostvec = TVector3(
        math.sin(theta) * math.cos(phi),
        math.sin(theta) * math.sin(phi), math.cos(theta))
    boostvec *= beta
    boosted_particles = []
    jetp4 = LorentzVector()
    for ptc in particles:
        bp4 = LorentzVector(ptc.p4())
        bp4.Boost(boostvec)
        jetp4 += bp4
        boosted_particles.append(
            Particle(bp4, ptc.vertex, ptc.q(), ptc.pdgid()))
    # print jetp4.M(), jetp4.E()
    return boosted_particles
Example #4
0
def particle(pdgid, theta, phi, energy, vertex=None):
    if vertex is None:
        vertex = Point(0, 0, 0)
    mass, charge = particle_data[pdgid]
    momentum = math.sqrt(energy**2 - mass**2)
    costheta = math.cos(theta)
    sintheta = math.sin(theta)
    cosphi = math.cos(phi)
    sinphi = math.sin(phi)
    p4 = LorentzVector(momentum * sintheta * cosphi,
                       momentum * sintheta * sinphi, momentum * costheta,
                       energy)
    return Particle(p4, vertex, charge, pdgid)
Example #5
0
def particles(nptcs, pdgid, thetamin, thetamax, emin, emax, vertex=None):
    ngenerated = 0
    mass, charge = particle_data[pdgid]
    while ngenerated < nptcs:
        theta = random.uniform(thetamin, thetamax)
        phi = random.uniform(-math.pi, math.pi)
        energy = random.uniform(emin, emax)
        if vertex is None:
            vertex = Point(0, 0, 0)
        momentum = math.sqrt(energy**2 - mass**2)
        costheta = math.cos(theta)
        sintheta = math.sin(theta)
        cosphi = math.cos(phi)
        sinphi = math.sin(phi)
        p4 = LorentzVector(momentum * sintheta * cosphi,
                           momentum * sintheta * sinphi, momentum * costheta,
                           energy)
        ngenerated += 1
        yield Particle(p4, vertex, charge, pdgid)