Beispiel #1
0
def fillProcessedFeaturesArray(featuresProcessed, channel):
  inputFileName = "rootuples/RootupleBcTo3Mu_"+channel+"Channel.root"
  inputFile = TFile.Open(inputFileName)
  inputTree = inputFile.Get("rootuple/ntuple")
  for event in inputTree:
    if(event.nBc < 1) : continue 
    iBcSelected = bcSelector(event, isBkg = False)
    for iBc in iBcSelected:
      muon1_p4 = TLorentzVector()
      muon2_p4 = TLorentzVector()
      unpairedMuon_p4 = TLorentzVector()
      jpsi_p4 = TLorentzVector()
      bc_p4 = TLorentzVector()

      muon1_p4.SetXYZM(event.Bc_jpsi_mu1_px[iBc],
          event.Bc_jpsi_mu1_py[iBc],
          event.Bc_jpsi_mu1_pz[iBc],
          muonPdgMass)
      muon2_p4.SetXYZM(event.Bc_jpsi_mu2_px[iBc],
          event.Bc_jpsi_mu2_py[iBc],
          event.Bc_jpsi_mu2_pz[iBc],
          muonPdgMass)
      unpairedMuon_p4.SetXYZM(event.Bc_mu_px[iBc],
          event.Bc_mu_py[iBc],
          event.Bc_mu_pz[iBc],
          muonPdgMass)
      bc_p4.SetXYZM(event.Bc_px[iBc],
          event.Bc_py[iBc],
          event.Bc_pz[iBc],
          event.Bc_mass[iBc])
      jpsi_p4.SetXYZM(event.Bc_jpsi_px[iBc],
          event.Bc_jpsi_py[iBc],
          event.Bc_jpsi_pz[iBc],
          event.Bc_jpsi_mass[iBc])

      #print("---")
      #print("event.gen_mu_p4.Px(): ", event.gen_mu_p4.Px())
      #print("event.Bc_mu_px[iBc]: ", event.Bc_mu_px[iBc])
      featuresEntry = computeProcessedFeatures(event.gen_jpsi_mu1_p4, event.gen_jpsi_mu2_p4, event.gen_mu_p4, event.gen_jpsi_p4, event.gen_b_p4)
      #featuresEntry = computeProcessedFeatures(muon1_p4, muon2_p4, unpairedMuon_p4, jpsi_p4, bc_p4)
      featuresEntry = np.append(featuresEntry, np.array([[bc_p4.E()]]), axis=0)
      featuresEntry = np.append(featuresEntry, np.array([[jpsi_p4.E()]]), axis=0)
      featuresEntry = np.append(featuresEntry, np.array([[muon1_p4.E()]]), axis=0)
      featuresEntry = np.append(featuresEntry, np.array([[muon2_p4.E()]]), axis=0)
      featuresEntry = np.append(featuresEntry, np.array([[unpairedMuon_p4.E()]]), axis=0)


      #featuresEntry = computeProcessedFeatures(event.gen_muonPositive_p4, event.gen_muonNegative_p4, event.gen_unpairedMuon_p4, event.gen_jpsi_p4, event.gen_b_p4)
      #featuresEntry = np.append(featuresEntry, np.array([[event.triggerMatchDimuon0[iBc]]]), axis=0)
      #featuresEntry = np.append(featuresEntry, np.array([[event.triggerMatchJpsiTk[iBc]]]), axis=0)
      #featuresEntry = np.append(featuresEntry, np.array([[event.triggerMatchJpsiTkTk[iBc]]]), axis=0)
      #featuresEntry = np.append(featuresEntry, np.array([[event.signalDecayPresent[iBc]]]), axis=0)
      #featuresEntry = np.append(featuresEntry, np.array([[event.normalizationDecayPresent[iBc]]]), axis=0)
      #featuresEntry = np.append(featuresEntry, np.array([[event.background1DecayPresent[iBc]]]), axis=0)
      

      featuresProcessed = np.append(featuresProcessed,featuresEntry, axis=1)

  return featuresProcessed
Beispiel #2
0
class Particle(BaseParticle, POD):
    def __init__(self, fccobj):
        super(Particle, self).__init__(fccobj)
        self._charge = fccobj.core().charge
        self._pid = fccobj.core().pdgId
        self._status = fccobj.core().status
        if hasattr(fccobj, 'startVertex'):
            start = fccobj.startVertex()
            self._start_vertex = Vertex(start) if start.isAvailable() \
                                 else None
            end = fccobj.endVertex()
            self._end_vertex = Vertex(end) if end.isAvailable() \
                               else None
        self._tlv = TLorentzVector()
        p4 = fccobj.core().p4
        self._tlv.SetXYZM(p4.px, p4.py, p4.pz, p4.mass)
        #write(str('Made Pythia {}').format(self))

    def __deepcopy__(self, memodict={}):
        newone = type(self).__new__(type(self))
        for attr, val in self.__dict__.iteritems():
            if attr not in ['fccobj', '_start_vertex', '_end_vertex']:
                setattr(newone, attr, copy.deepcopy(val, memodict))
        return newone

    def short_info(self):
        tmp = '{pdgid:} ({e:.1f})'
        #needed for now to get match with C++
        pid = self.pdgid()
        if self.q() == 0 and pid < 0:
            pid = -pid

        return tmp.format(pdgid=pid, e=self.e())
Beispiel #3
0
class Particle(BaseParticle, POD):
    
    def __init__(self, fccobj):
        super(Particle, self).__init__(fccobj)
        self.uniqueid=Identifier.make_id(Identifier.PFOBJECTTYPE.PARTICLE)
        self._charge = fccobj.core().charge
        self._pid = fccobj.core().pdgId
        self._status = fccobj.core().status
        if hasattr(fccobj, 'startVertex'):
            start = fccobj.startVertex()
            self._start_vertex = Vertex(start) if start.isAvailable() \
                                 else None 
            end = fccobj.endVertex()
            self._end_vertex = Vertex(end) if end.isAvailable() \
                               else None 
        self._tlv = TLorentzVector()
        p4 = fccobj.core().p4
        self._tlv.SetXYZM(p4.px, p4.py, p4.pz, p4.mass)
        #write(str('Made Pythia {}').format(self))
        
    def __deepcopy__(self, memodict={}):
        newone = type(self).__new__(type(self))
        for attr, val in self.__dict__.iteritems():
            if attr not in ['fccobj', '_start_vertex', '_end_vertex']:
                setattr(newone, attr, copy.deepcopy(val, memodict))
        return newone

    def __str__(self):
        mainstr =  super(Particle, self).__str__()
        idstr = '{pretty:6}:{id}'.format(
            pretty = Identifier.pretty(self.uniqueid),
            id = self.uniqueid)
        fields = mainstr.split(':')
        fields.insert(1, idstr)
        return ':'.join(fields)     
Beispiel #4
0
def getpdf(q2):
    xmin = 0.00001
    xmax = 0.999
    x = xmin * (xmax/xmin)**gRandom.Uniform()
    weightx = x*log(xmax/xmin) 
    # this is for the simple case            
    pdf = 3.*pow((1-x),5)/x

    kx, ky = gauss2D(0.7)
    pVec = TLorentzVector()
    pVec.SetXYZM(kx, ky, x*Eb, 0.)
    return pVec, weightx * pdf
Beispiel #5
0
def fillQ2Array(inputDF, varCat):
    q2array = np.array([[]], dtype=np.float32)
    for index, row in inputDF.iterrows():
        muon1_p4 = TLorentzVector()
        muon2_p4 = TLorentzVector()
        unpairedMuon_p4 = TLorentzVector()
        jpsi_p4 = TLorentzVector()
        bc_p4 = TLorentzVector()

        if (varCat == 0):
            muon1_p4.SetXYZM(row['gen_jpsi_mu1_px'], row['gen_jpsi_mu1_py'],
                             row['gen_jpsi_mu1_pz'], muonPdgMass)
            muon2_p4.SetXYZM(row['gen_jpsi_mu2_px'], row['gen_jpsi_mu2_py'],
                             row['gen_jpsi_mu2_pz'], muonPdgMass)
            unpairedMuon_p4.SetXYZM(row['gen_mu_px'], row['gen_mu_py'],
                                    row['gen_mu_pz'], muonPdgMass)
            bc_p4.SetXYZM(row['gen_b_px'], row['gen_b_py'], row['gen_b_pz'],
                          bcPdgMass)
            jpsi_p4.SetXYZM(row['gen_jpsi_px'], row['gen_jpsi_py'],
                            row['gen_jpsi_pz'], jpsiPdgMass)

        elif (varCat == 1):
            muon1_p4.SetXYZM(row['Bc_jpsi_mu1_px'], row['Bc_jpsi_mu1_py'],
                             row['Bc_jpsi_mu1_pz'], muonPdgMass)
            muon2_p4.SetXYZM(row['Bc_jpsi_mu2_px'], row['Bc_jpsi_mu2_py'],
                             row['Bc_jpsi_mu2_pz'], muonPdgMass)
            unpairedMuon_p4.SetXYZM(row['Bc_mu_px'], row['Bc_mu_py'],
                                    row['Bc_mu_pz'], muonPdgMass)
            bc_p4.SetXYZM(row['bc_px_predicted'], row['bc_py_predicted'],
                          row['bc_pz_predicted'], bcPdgMass)
            jpsi_p4.SetXYZM(row['Bc_jpsi_px'], row['Bc_jpsi_py'],
                            row['Bc_jpsi_pz'], row['Bc_jpsi_mass'])

        #q2Entry = computeProcessedFeatures(event.gen_jpsi_mu1_p4, event.gen_jpsi_mu2_p4, event.gen_mu_p4, event.gen_jpsi_p4, event.gen_b_p4)
        q2Entry = computeProcessedFeatures(muon1_p4, muon2_p4, unpairedMuon_p4,
                                           jpsi_p4, bc_p4)
        q2array = np.append(q2array, q2Entry, axis=1)

    return q2array
Beispiel #6
0
def get_starting_pdf(q2):
    xmin = 0.0001
    xmax = 0.999
    # get x value according to g(x)\sim 1/x            
    x = xmin * (xmax/xmin)**gRandom.Uniform()
    weightx = x*log(xmax/xmin) 
    # use: xg(x) = 3 (1-x)**5
    pdf = 3.*pow((1-x),5)/x

    # now generate instrinsic kt according to a gauss distribution  
    kx, ky = gauss2D(0.7)
    pVec = TLorentzVector()
    pVec.SetXYZM(kx, ky, x*Eb, 0.)
    return pVec, weightx * pdf
Beispiel #7
0
def Analyze(n, event):
    nele = 0
    npos = 0
    ngam = 0
    ngam05 = 0
    ngam1 = 0
    ### loop on all tracks
    for j in range(event.E.size()):
        wgt = event.wgt[j]
        p = TLorentzVector()
        p.SetXYZM(event.px[j], event.py[j], event.pz[j], meGeV)
        Etru = event.E[j]
        ### only photons
        if (event.pdgId[j] == 22):
            ngam += wgt
            ntot["gam"] += wgt
            avgE["gam"] += wgt * Etru if (not np.isnan(Etru)) else 0
            if (Etru > 0.5):
                ngam05 += wgt
                ntot["gam05"] += wgt
                avgE["gam05"] += wgt * Etru if (not np.isnan(Etru)) else 0
            if (Etru > 1.0):
                ngam1 += wgt
                ntot["gam1"] += wgt
                avgE["gam1"] += wgt * Etru if (not np.isnan(Etru)) else 0
            histos["h_E_photons"].Fill(Etru, wgt)
            histos["h_Efine_photons"].Fill(Etru, wgt)
            histos["h_Evfine_photons"].Fill(Etru, wgt)
        ### only electrons
        if (event.pdgId[j] == 11):
            nele += wgt
            ntot["ele"] += wgt
            avgE["ele"] += wgt * Etru if (not np.isnan(Etru)) else 0
            histos["h_E_electrons"].Fill(Etru, wgt)
            histos["h_Efine_electrons"].Fill(Etru, wgt)
            histos["h_Evfine_electrons"].Fill(Etru, wgt)
        ### only positrons
        if (event.pdgId[j] == -11):
            npos += wgt
            ntot["pos"] += wgt
            avgE["pos"] += wgt * Etru if (not np.isnan(Etru)) else 0
            histos["h_E_positrons"].Fill(Etru, wgt)
            histos["h_Efine_positrons"].Fill(Etru, wgt)
            histos["h_Evfine_positrons"].Fill(Etru, wgt)

    histos["h_ntot"].AddBinContent(1, nele)
    histos["h_ntot"].AddBinContent(2, ngam)
    histos["h_ntot"].AddBinContent(3, ngam05)
    histos["h_ntot"].AddBinContent(4, ngam1)
    histos["h_ntot"].AddBinContent(5, npos)
Beispiel #8
0
 def process(self, event):
     initial = TLorentzVector()
     initial.SetXYZM(0,0,0,self.cfg_ana.sqrts)
     particles = getattr(event, self.cfg_ana.particles)
     visible_p4 = TLorentzVector()
     for ptc in particles: 
         if ptc.status()>1: #PF cand status=0 in CMS
             raise ValueError('are you sure? status='+str(ptc.status()) )
         visible_p4 += ptc.p4()
     recoil_p4 = initial - visible_p4
     recoil = Particle(0, 0, recoil_p4)
     visible = Particle(0, 0, visible_p4)
     setattr(event, '_'.join(['recoil', self.cfg_ana.instance_label]), recoil)
     setattr(event, '_'.join(['recoil_visible', self.cfg_ana.instance_label]), visible)
Beispiel #9
0
class Particle(BaseParticle):
    def __init__(self, fccptc):
        self.fccptc = fccptc
        self._charge = fccptc.Core().Charge
        self._pid = fccptc.Core().Type
        self._status = fccptc.Core().Status
        start = fccptc.StartVertex()
        self._start_vertex = Vertex(start) if start.isAvailable() \
                             else None
        end = fccptc.EndVertex()
        self._end_vertex = Vertex(end) if end.isAvailable() \
                           else None
        self._tlv = TLorentzVector()
        p4 = fccptc.Core().P4
        self._tlv.SetXYZM(p4.Px, p4.Py, p4.Pz, p4.Mass)
Beispiel #10
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
Beispiel #11
0
def FillTheObjectCollections():
    for j in xrange(chain.NMuon):
        muon = MyMuon(chain.Muon_Px[j], chain.Muon_Py[j], chain.Muon_Pz[j],
                      chain.Muon_E[j])
        muon.SetIsolation(chain.Muon_Iso[j])
        muon.SetCharge(chain.Muon_Charge[j])
        AllMuons.append(muon)
    for j in xrange(chain.NElectron):
        electron = MyElectron(chain.Electron_Px[j], chain.Electron_Py[j],
                              chain.Electron_Pz[j], chain.Electron_E[j])
        electron.SetIsolation(chain.Electron_Iso[j])
        electron.SetCharge(chain.Electron_Charge[j])
        AllElectrons.append(electron)
    for j in xrange(chain.NPhoton):
        photon = MyPhoton(chain.Photon_Px[j], chain.Photon_Py[j],
                          chain.Photon_Pz[j], chain.Photon_E[j])
        photon.SetIsolation(chain.Photon_Iso[j])
        AllPhotons.append(photon)
    for j in xrange(chain.NJet):
        jet = MyJet(chain.Jet_Px[j], chain.Jet_Py[j], chain.Jet_Pz[j],
                    chain.Jet_E[j])
        jet.SetBTagDiscriminator(chain.Jet_btag[j])
        AllJets.append(jet)
    hadB = TLorentzVector()
    hadB.SetXYZM(chain.MChadronicBottom_px, chain.MChadronicBottom_py,
                 chain.MChadronicBottom_pz, 4.8)
    lepB = TLorentzVector()
    lepB.SetXYZM(chain.MCleptonicBottom_px, chain.MCleptonicBottom_py,
                 chain.MCleptonicBottom_pz, 4.8)
    hadWq = TLorentzVector()
    hadWq.SetXYZM(chain.MChadronicWDecayQuark_px,
                  chain.MChadronicWDecayQuark_py,
                  chain.MChadronicWDecayQuark_pz, 0.0)
    hadWqb = TLorentzVector()
    hadWqb.SetXYZM(chain.MChadronicWDecayQuarkBar_px,
                   chain.MChadronicWDecayQuarkBar_py,
                   chain.MChadronicWDecayQuarkBar_pz, 0.0)
    lepWl = TLorentzVector()
    lepWl.SetXYZM(chain.MClepton_px, chain.MClepton_py, chain.MClepton_pz, 0.0)
    lepWn = TLorentzVector()
    lepWn.SetXYZM(chain.MCneutrino_px, chain.MCneutrino_py,
                  chain.MCneutrino_pz, 0.0)
    met = TLorentzVector()
    met.SetXYZM(chain.MET_px, chain.MET_py, 0., 0.)
Beispiel #12
0
def evolve_pdf(q20, q2, p0):
    x = p0.Pz()/Eb
    kx = p0.Px()
    ky = p0.Py()
    weightx = 1.
    t1 = q20
    tcut = q2
    while t1 < tcut:
        # here we do now the evolution
        # first we generate t
        t0 = t1
        t1 = sudakov(t0) 
        
        # now we generate z
        z = splitting()
        #   since the sudakov involves only the 1/(1-z) part 
        #   of the splitting fct, we need to weight each branching
        #   by the ratio of the integral of the full and 
        #   approximate splitting fct

        ratio_splitting = 2 # for using Pgg

        if  t1 < tcut:
            x = x*z
            weightx = weightx *ratio_splitting
            # 
            # use here the angular ordering condition: sqrt(t1) = qt/(1-z) 
            # and apply this also to the propagator gluons
            #
            phi = 2*pi*gRandom.Uniform()
            kx +=  sqrt(t1)*cos(phi)*(1.-z)
            ky +=  sqrt(t1)*sin(phi)*(1.-z)                     
            #   kx += sqrt(t1)*cos(phi)
            #   ky += sqrt(t1)*sin(phi)                     
    k = TLorentzVector()
    k.SetXYZM(kx, ky, x*Eb, 0.)
    return k, weightx
Beispiel #13
0
def jpsimuDirections(chiccand, jpsicand, frame='hx'):
    """return two directions: 
       1. direction vector of jpsi in the chic rest frame, wrt to the direction of chic
       2. direction vector of muon in the jpsi rest frame, wrt to the direction of the psi as seen in the chic rest frame"""

    pbeam = 3500
    Mpsi = 3.097
    Mprot = 0.938

    Ebeam = sqrt(pbeam**2 + Mprot**2)

    targ = TLorentzVector(0., 0., -pbeam, Ebeam)
    beam = TLorentzVector(0., 0., pbeam, Ebeam)

    # chic 4vector in lab frame
    chi = TLorentzVector()
    #chi.SetXYZM(chiccand.px(), chiccand.py(), chiccand.pz(), mass)
    chi.SetXYZM(chiccand.px(), chiccand.py(), chiccand.pz(), chiccand.mass())

    chi_direction = chi.Vect().Unit()

    # psi 4vector in lab fram
    psi = TLorentzVector()
    psi.SetXYZM(jpsicand.px(), jpsicand.py(), jpsicand.pz(), jpsicand.mass())

    cm_to_chi = -chi.BoostVector()
    chi_to_cm = chi.BoostVector()

    cm_to_psi = -psi.BoostVector()

    beam_chi = beam
    beam_chi.Boost(cm_to_chi)  # beam in the chi rest frame

    targ_chi = targ
    targ_chi.Boost(cm_to_chi)  # target in the chi rest frame

    beam_direction_chi = beam_chi.Vect().Unit()
    targ_direction_chi = targ_chi.Vect().Unit()
    beam_targ_bisec_chi = (beam_direction_chi - targ_direction_chi).Unit()

    psi_chi = psi
    psi_chi.Boost(cm_to_chi)  # psi in the chi rest frame

    psi_direction_chi = psi_chi.Vect().Unit()

    # all polarization frames have the same Y axis = the normal to the plane
    # formed by the directions of the colliding hadrons

    Yaxis = (beam_direction_chi.Cross(targ_direction_chi)).Unit()

    # transform(rotation) psi momentum components from polarization axis system
    # to the system with x,y,z axes as in the laboratory

    ChiPolAxis = chi_direction
    # helicity frame
    if frame is 'cs':
        ChiPolAxis = beam_targ_bisec_chi

    newZaxis = ChiPolAxis
    newYaxis = Yaxis
    newXaxis = newYaxis.Cross(newZaxis)

    # rotation needed to go to the chi rest frame
    rotation = TRotation()
    rotation.SetToIdentity()
    rotation.RotateAxes(newXaxis, newYaxis, newZaxis)
    rotation.Invert()

    psi_chi_rotated = psi_chi.Vect()

    psi_chi_rotated.Transform(rotation)
    # direction of the psi in the chi rest frame
    # relative to direction of chi in the lab

    # now calculate muon direction in the jpsi rest frame wrt chi direction
    mumass = 0.105

    Yaxis = (ChiPolAxis.Cross(psi_direction_chi)).Unit()

    newZaxis = psi_direction_chi
    newYaxis = Yaxis
    newXaxis = newYaxis.Cross(newZaxis)

    rotation.SetToIdentity()
    rotation.RotateAxes(newXaxis, newYaxis, newZaxis)
    rotation.Invert()

    #muon in the lab
    lepton = TLorentzVector()
    lepton.SetXYZM(
        jpsicand.daughter(0).px(),
        jpsicand.daughter(0).py(),
        jpsicand.daughter(0).pz(), mumass)

    #muon in the psi rest frame
    lepton_psi = lepton
    lepton_psi.Boost(cm_to_psi)

    lepton_psi_rotated = lepton_psi.Vect()
    lepton_psi_rotated.Transform(rotation)

    return psi_chi_rotated, lepton_psi_rotated
Beispiel #14
0
def Analyze(n, event):
    npositrons = 0
    nelectrons = 0
    npositrons_acc = 0
    nelectrons_acc = 0
    npositrons_rec_emul = 0
    nelectrons_rec_emul = 0
    ### loop on all tracks
    for j in range(event.E.size()):
        wgt = event.wgt[j]
        p = TLorentzVector()
        p.SetXYZM(event.px[j], event.py[j], event.pz[j], meGeV)
        xVtx = event.vx[j]
        yVtx = event.vy[j]
        zVtx = event.vz[j]
        Etru = event.E[j]
        Erec = Etru * (1 + resolution.GetRandom())
        prob = accxeff.Eval(Etru)

        ### only electrons
        if (event.pdgId[j] == 11):
            nelectrons += wgt
            if (Etru > 1.5): nelectrons_acc += wgt
            nelectrons_rec_emul += prob * wgt
            histos["h_E_electrons"].Fill(Etru, wgt)
            histos["h_E_electrons_fine"].Fill(Etru, wgt)
            histos["h_E_electrons_full"].Fill(Etru, wgt)
            histos["h_px_electrons"].Fill(event.px[j], wgt)
            histos["h_px_electrons_fine"].Fill(event.px[j], wgt)
            histos["h_py_electrons"].Fill(event.py[j], wgt)
            histos["h_py_electrons_fine"].Fill(event.py[j], wgt)
            histos["h_pz_electrons"].Fill(event.pz[j], wgt)
            histos["h_pz_electrons_fine"].Fill(event.pz[j], wgt)
            histos["h_pz_electrons_full"].Fill(event.pz[j], wgt)
            histos["h_E_electrons_rec_emul"].Fill(Erec, wgt * prob)
            histos["h_E_electrons_rec_emul_fine"].Fill(Erec, wgt * prob)
            histos["h_E_electrons_rec_emul_full"].Fill(Erec, wgt * prob)

        ### only positrons
        if (event.pdgId[j] == -11):
            npositrons += wgt
            if (Etru > 1.5): npositrons_acc += wgt
            npositrons_rec_emul += prob * wgt
            histos["h_E_positrons"].Fill(Etru, wgt)
            histos["h_E_positrons_fine"].Fill(Etru, wgt)
            histos["h_E_positrons_full"].Fill(Etru, wgt)
            histos["h_px_positrons"].Fill(event.px[j], wgt)
            histos["h_px_positrons_fine"].Fill(event.px[j], wgt)
            histos["h_py_positrons"].Fill(event.py[j], wgt)
            histos["h_py_positrons_fine"].Fill(event.py[j], wgt)
            histos["h_pz_positrons"].Fill(event.pz[j], wgt)
            histos["h_pz_positrons_fine"].Fill(event.pz[j], wgt)
            histos["h_pz_positrons_full"].Fill(event.pz[j], wgt)
            histos["h_xyVtx_positrons"].Fill(xVtx, yVtx)
            histos["h_zxVtx_positrons"].Fill(zVtx, xVtx)
            histos["h_zyVtx_positrons"].Fill(zVtx, yVtx)
            histos["h_E_positrons_rec_emul"].Fill(Erec, wgt * prob)
            histos["h_E_positrons_rec_emul_fine"].Fill(Erec, wgt * prob)
            histos["h_E_positrons_rec_emul_full"].Fill(Erec, wgt * prob)

    histos["h_ntrks_positrons"].Fill(npositrons)
    histos["h_ntrks_positrons_small"].Fill(npositrons)
    histos["h_ntrks_positrons_tiny"].Fill(npositrons)

    histos["h_ntrks_positrons_rec_emul"].Fill(npositrons_rec_emul)
    histos["h_ntrks_positrons_rec_emul_small"].Fill(npositrons_rec_emul)
    histos["h_ntrks_positrons_rec_emul_tiny"].Fill(npositrons_rec_emul)

    histos["h_ntrks_electrons"].Fill(nelectrons)
    histos["h_ntrks_electrons_small"].Fill(nelectrons)
    histos["h_ntrks_electrons_tiny"].Fill(nelectrons)

    histos["h_ntrks_electrons_rec_emul"].Fill(nelectrons_rec_emul)
    histos["h_ntrks_electrons_rec_emul_small"].Fill(nelectrons_rec_emul)
    histos["h_ntrks_electrons_rec_emul_tiny"].Fill(nelectrons_rec_emul)

    histos["h_ntot"].AddBinContent(2, npositrons)
    histos["h_ntot"].AddBinContent(3, npositrons_acc)
    histos["h_ntot"].AddBinContent(4, npositrons_rec_emul)
    if (process == "bppp"):
        histos["h_ntot"].AddBinContent(5, nelectrons)
        histos["h_ntot"].AddBinContent(6, nelectrons_acc)
        histos["h_ntot"].AddBinContent(7, nelectrons_rec_emul)
Beispiel #15
0
class Jet(BaseJet, POD):
    def __init__(self, fccobj):
        super(Jet, self).__init__(fccobj)
        self._tlv = TLorentzVector()
        p4 = fccobj.Core().P4
        self._tlv.SetXYZM(p4.Px, p4.Py, p4.Pz, p4.Mass)
Beispiel #16
0
class Jet(BaseJet, POD):
    def __init__(self, fccobj):
        super(Jet, self).__init__(fccobj)
        self._tlv = TLorentzVector()
        p4 = fccobj.core().p4
        self._tlv.SetXYZM(p4.px, p4.py, p4.pz, p4.mass)
Beispiel #17
0
class Jet(BaseJet):
    def __init__(self, fccjet):
        self.fccjet = fccjet
        self._tlv = TLorentzVector()
        p4 = fccjet.Core().P4
        self._tlv.SetXYZM(p4.Px, p4.Py, p4.Pz, p4.Mass)
Beispiel #18
0
    # loop over the simulated hypertritons
    for sim in ev.SHypertriton:
        hyp = TLorentzVector()
        deu = TLorentzVector()
        p = TLorentzVector()
        pi = TLorentzVector()

        e_deu = hypot4(sim.fPxDeu, sim.fPyDeu, sim.fPzDeu,
                       AliPID.ParticleMass(AliPID.kDeuteron))
        e_p = hypot4(sim.fPxP, sim.fPyP, sim.fPzP,
                     AliPID.ParticleMass(AliPID.kProton))
        e_pi = hypot4(sim.fPxPi, sim.fPyPi, sim.fPzPi,
                      AliPID.ParticleMass(AliPID.kPion))

        deu.SetXYZM(sim.fPxDeu, sim.fPyDeu, sim.fPzDeu,
                    AliPID.ParticleMass(AliPID.kDeuteron))
        p.SetXYZM(sim.fPxP, sim.fPyP, sim.fPzP,
                  AliPID.ParticleMass(AliPID.kProton))
        pi.SetXYZM(sim.fPxPi, sim.fPyPi, sim.fPzPi,
                   AliPID.ParticleMass(AliPID.kPion))

        hyp = deu + p + pi

        decay_lenght = TVector3(sim.fDecayVtxX, sim.fDecayVtxY, sim.fDecayVtxZ)
        dl = decay_lenght.Mag()

        if hyp.Gamma() == 0 or hyp.Beta() == 0:
            continue

        ct = dl / (hyp.Gamma() * hyp.Beta())
Beispiel #19
0
def get_lorentz_vector(particle):
    # Get the Lorentz Vector of a given particle (Legacy TLorentzVector class)
    vector = TLorentzVector()
    vector.SetXYZM(particle.core.p4.px, particle.core.p4.py,
                   particle.core.p4.pz, particle.core.p4.mass)
    return vector
Beispiel #20
0
def fourvecs_xyzm(px, py, pz, m):
    from ROOT import TLorentzVector
    p4 = TLorentzVector()
    p4.SetXYZM(px, py, pz, m)
    return p4
def p4(r1, r2, E):
    p = p3(r1, r2, E)
    tlv = TLorentzVector()
    tlv.SetXYZM(p.Px(), p.Py(), p.Pz(), me)
    return tlv  ## TLorentzVector
    
    r4 = zLayer1*rp.Unit()
    # print("x4=%g, y4=%g" % (r4.X(),r4.Y()))
    # if(abs(r4.X())<=cfgmap["Rbeampipe"]):                       continue ## |x| must be >Rbeampipe
    # if(abs(r4.X())>cfgmap["RoffsetBfield"]+2*cfgmap["Lstave"]): continue ## |x| must be <=Rbeampipe+2*Lstave
    # if(abs(r4.Y())>1.5*cfgmap["Hstave"]/2.):                    continue ## |y| must be within Hstave/2+50%
    
    nbkgtrks+=1
    
    Px = rp.Unit().X()*P0
    Py = rp.Unit().Y()*P0
    Pz = rp.Unit().Z()*P0
    
    E0 = ROOT.TMath.Sqrt(P0*P0+me2)
    p4 = TLorentzVector()
    p4.SetXYZM(Px,Py,Pz,me)
    wgt0 = 1
    pdgId0 = 11 if(rnd.Uniform()>0.5) else -11
    
    ### fill output vectors
    wgt.push_back(wgt0)  
    pdgId.push_back(pdgId0)  
    vx.push_back(vx0)
    vy.push_back(vy0)
    vz.push_back(vz0)
    px.push_back(p4.Px())
    py.push_back(p4.Py())
    pz.push_back(p4.Pz())
    E.push_back(p4.E())
    
 if(n%100==0): print("done %g out of %g" % (n,Nevt))