Exemple #1
0
 def test_deltaR2(self):
     """Test that the deltaR2 method properly uses either eta or
     theta depending on the collider configuration
     """
     Collider.BEAMS = 'pp'
     tlv1 = TLorentzVector()
     tlv1.SetPtEtaPhiM(10, 1.1, 0, 0)
     tlv2 = TLorentzVector()
     tlv2.SetPtEtaPhiM(10, 1.2, 0, 0)
     ptc1 = Particle(1, 1, tlv1)        
     ptc2 = Particle(1, 1, tlv2)
     dR = math.sqrt( deltaR2(ptc1, ptc2))
     self.assertAlmostEqual(dR, 0.1)
     
     Collider.BEAMS = 'ee'
     tlv1 = TLorentzVector()
     tlv1.SetPtEtaPhiM(10, 1.1, 0, 0)
     tlv1.SetTheta(1.1)
     tlv2 = TLorentzVector()
     tlv2.SetPtEtaPhiM(10, 1.2, 0, 0)
     tlv2.SetTheta(1.2)
     ptc1 = Particle(1, 1, tlv1)        
     ptc2 = Particle(1, 1, tlv2)
     dR = math.sqrt( deltaR2(ptc1, ptc2))
     self.assertAlmostEqual(dR, 0.1)
 def process(self, event):
     pivot = getattr(event, self.cfg_ana.pivot)[0]
     ptcs = getattr(event, self.cfg_ana.particles)
     dR = self.cfg_ana.dR
     cone_ptcs = inConeCollection(pivot, ptcs, dR, 0.)
     for ptc in cone_ptcs:
         setattr(ptc, 'dR', deltaR(pivot, ptc))
     tlv = TLorentzVector(pivot.p4())
     tlv.SetPhi(pivot.p4().Phi() + math.pi)
     tlv_theta = math.pi - pivot.p4().Theta()
     if tlv_theta >= math.pi:
         tlv_theta -= math.pi
     tlv.SetTheta(tlv_theta)
     control_pivot = Particle(pivot.pdgid(), pivot.charge(), tlv)
     control_cone_ptcs = inConeCollection(control_pivot, ptcs, dR, 0.)
     setattr(event, self.cfg_ana.output, cone_ptcs)
     setattr(event, self.cfg_ana.control_output, control_cone_ptcs)
Exemple #3
0
    def print_vec(self, vec):
        print "theta vec:", TMath.Pi() - vec.Theta()
        print
        return
        print "pxyz:", vec.Px(), vec.Py(), vec.Pz()
        print "en, phi:", vec.E(), vec.Phi()
        print
        v3 = vec.Vect()
        print "vxyz:", v3.x(), v3.y(), v3.z()
        print "theta v3: ", TMath.Pi() - v3.Theta()
        print
        theta_add = 1e-5
        v3.SetTheta(v3.Theta() - theta_add)
        print "vxyz:", v3.x(), v3.y(), v3.z()
        print "theta v3: ", TMath.Pi() - v3.Theta()
        print

        vec2 = TLorentzVector(vec)
        vec3 = TLorentzVector(vec)

        vec.SetVect(v3)

        print "theta vec:", TMath.Pi() - vec.Theta()
        print "pxyz:", vec.Px(), vec.Py(), vec.Pz()
        print "en, phi:", vec.E(), vec.Phi()
        print

        vec2.SetTheta(vec2.Theta() - theta_add)

        print "theta vec:", TMath.Pi() - vec2.Theta()
        print "pxyz:", vec2.Px(), vec2.Py(), vec2.Pz()
        print "en, phi:", vec2.E(), vec2.Phi()
        print

        print "Delta theta, en, phi", vec3.Theta() - vec.Theta(), vec3.E(
        ) - vec.E(), vec3.Phi() - vec.Phi()
        print "Delta theta, en, phi", vec3.Theta() - vec2.Theta(), vec3.E(
        ) - vec2.E(), vec3.Phi() - vec2.Phi()