Exemple #1
0
    def process(self, event):
        '''Smear the beam energy.
        
        The two incoming particle energies are smeared under
        a Gaussian pdf of width sigma relative to the beam energy
        
        All outgoing particles are then boosted to the new com
        system 
        '''
        genptcs = getattr(event, self.cfg_ana.gen_particles)
        sigma = self.cfg_ana.sigma
        f1 = random.gauss(1, sigma)
        f2 = random.gauss(1, sigma)
        
        beamptcs = [p for p in genptcs if p.status() == 4]
        pprint.pprint(beamptcs)
        
        assert(len(beamptcs) == 2)
        
        def smear(ptc, factor):
            e = ptc.p4().E() * factor
            pz = math.sqrt(e ** 2 - ptc.m() ** 2)
            if ptc.p4().Pz() < 0:
                pz = -pz                
            ptc._tlv.SetPxPyPzE( ptc.p4().Px(),
                                 ptc.p4().Py(),
                                 pz,
                                 e)        

        newcom = TLorentzVector()
        for ptc, factor in zip(beamptcs, [f1, f2]):
            smear(ptc, factor)
            ptc.p4().Print()
            print ptc.m()
            newcom += ptc.p4()
        
        print 'new com:'
        newcom.Print()
        boost = newcom.BoostVector()
        
        stablep4_before = TLorentzVector()
        stablep4 = TLorentzVector()
        for p in genptcs:
            if p in beamptcs:
                continue
            if p.status() == 1:
                stablep4_before += p._tlv
            # p._tlv.Boost(boost)
            p._tlv.Boost(boost)
            if p.status() == 1:
                stablep4 += p._tlv
                
        pprint.pprint(beamptcs)
        print newcom.E(), newcom.Pz()
        print stablep4.E(), stablep4.Pz()
        print stablep4_before.E(), stablep4_before.Pz()
        boost.Print()
Exemple #2
0
 def process(self, event):
     sqrts = Collider.SQRTS
     mZ = 91.
     pi = TLorentzVector(0, 0, 0, sqrts)
     jets = getattr(event, self.cfg_ana.jets)
     jets_rescaled = []
     setattr(event, self.cfg_ana.output, jets_rescaled)
     if len(jets) == 0:
         return
     sump4 = TLorentzVector()
     for jet in jets:
         sump4 += jet.p4()
         # print jet
     a = sump4.Mag2()
     b = -pi * sump4 * 2.
     c = pi.Mag2() - mZ**2
     sqdelta = math.sqrt(b**2 - 4 * a * c)
     xmin = (-b - sqdelta) / (2 * a)
     xmax = (-b + sqdelta) / (2 * a)
     scaling_factor = xmin
     ## this solution leads to negative missing energy,
     ## going for the physical one
     ##        if abs(xmax-1) < abs(xmin-1):
     ##            scaling_factor = xmax
     # print xmin, xmax
     # print scaling_factor
     if self.cfg_ana.verbose:
         pi.Print()
         sump4.Print()
         print a, b, xmin, xmax, scaling_factor
     for jet in jets:
         jet_rescaled = copy.deepcopy(jet)
         jet_rescaled._tlv *= scaling_factor
         jets_rescaled.append(jet_rescaled)
         if self.cfg_ana.verbose:
             print jet
             print jet_rescaled