Пример #1
0
def read_particles():
    path = '/home/dylan/Research/Ampt_Particle_Counts/62GeV/'
    particles = {}
    pdg = PythiaData()
    files = [x for x in os.listdir(path) if '.out' in x]
    for file in files:
        with open(path + file, 'r') as f:
            lines = f.readlines()
            flag = False
            for line in lines:
                if 'making .root file from .dat file...' in line:
                    flag = True
                elif not flag:
                    continue
                if 'Tree written succesfully' in line:
                    break
                line = line.strip().split(' ')
                if len(line) == 2:
                    name = pdg.name(int(line[0]))
                    if name in particles.keys():
                        particles[name] += int(line[1])
                    else:
                        particles.update({name: int(line[1])})

    return particles
Пример #2
0
class ParticleProperties(object):
    modtab = SibyllParticleTable()
    pd = PYTHIAParticleData()

    mass_dict = {}
    lifetime_dict = {}
    pdg_id = {}
    sibling = {}

    for k in modtab.part_table:
        pdg_id[k] = modtab.modname2pdg[k]
        mass_dict[k] = pd.mass(pdg_id[k]) * Units.GeV
        lifetime_dict[k] = pd.ctau(pdg_id[k]) * Units.cm

    @staticmethod
    def rr(mother, daughter):
        """ returns ratio of masses
        """
        other_masses = []
        mother_pdg = ParticleProperties.pdg_id[mother]
        daughter_pdg = ParticleProperties.pdg_id[daughter]
        for br, prod in ParticleProperties.pd.decay_channels(mother_pdg):
            if daughter_pdg in prod:
                mass_tot = sum([
                    ParticleProperties.pd.mass(abs(prod)) for prod in prod
                ]) - ParticleProperties.pd.mass(daughter_pdg)
                other_masses.append(mass_tot)

        return (min(other_masses) / ParticleProperties.mass_dict[mother])**2

    @staticmethod
    def br_2body(mother, daughter):
        """ returns the two-body branching ratio if it exists
        """
        mother_pdg = ParticleProperties.pdg_id[mother]
        daughter_pdg = ParticleProperties.pdg_id[daughter]
        brs = 0
        for br, prod in ParticleProperties.pd.decay_channels(mother_pdg):
            if daughter_pdg in prod and len(prod) == 2:
                brs += br
        return brs
from __future__ import print_function
from particletools.tables import (PYTHIAParticleData, c_speed_of_light,
                                  print_stable, make_stable_list)
import math

pdata = PYTHIAParticleData()

print_stable(pdata.ctau('D0') / c_speed_of_light,
             title=('Particles with known finite lifetimes longer '
                    'than that of D0 ({0}cm)').format(pdata.ctau('D0')))
print()
print('Known particles with tau > 1e-8s:', make_stable_list(1e-8))
Пример #4
0
from __future__ import division
import math

from phenomena.particles.particle import Particle
from skhep.constants import c_light
from skhep import units as u
from skhep.math  import lifetime_to_width
from .particle_unicode import unicodedict

#https://github.com/afedynitch/ParticleDataTool

from particletools.tables import PYTHIAParticleData
pythia = PYTHIAParticleData()

class ParticleDataToolFetcher(object):

    @staticmethod
    def getName(pdgid):
        return pythia.name(pdgid)

    @staticmethod
    def getSymbolName(pdgid):
        name = ParticleDataToolFetcher.getName(pdgid)
        symbolname = unicodedict[name]
        if symbolname == '':
            symbolname = name
        return symbolname

    @staticmethod
    def getMass(pdgid):
        return pythia.mass(pdgid) * u.GeV
Пример #5
0
import six
from math import copysign
import numpy as np
import mceq_config as config
from MCEq.misc import info, print_in_rows, getAZN

from particletools.tables import PYTHIAParticleData

info(5, 'Initialization of PYTHIAParticleData object')
_pdata = PYTHIAParticleData()

backward_compatible_namestr = {
    'nu_mu': 'numu',
    'nu_mubar': 'antinumu',
    'nu_e': 'nue',
    'nu_ebar': 'antinue',
    'nu_tau': 'nutau',
    'nu_taubar': 'antinutau'
}


# Replace particle names for neutrinos with those used
# in previous MCEq versions
def _pname(pdg_id_or_name):
    """Replace some particle names from pythia database with those from previous
    MCEq versions for backward compatibility."""

    pythia_name = _pdata.name(pdg_id_or_name)
    if pythia_name in backward_compatible_namestr:
        return backward_compatible_namestr[pythia_name]
    return pythia_name
Пример #6
0
from particletools.tables import PYTHIAParticleData, print_decay_channels
import argparse
import six

pyth_data = PYTHIAParticleData()

parser = argparse.ArgumentParser()
parser.add_argument("pid_or_name", default="Ds+")
args = parser.parse_args()

try:
    pid = int(args.pid_or_name)
except ValueError:
    pid = pyth_data.pdg_id(args.pid_or_name)

pd = pyth_data[pid]

print('List decay channels and branching ratios of {} (ID={})'.format(
    pd.name, pid))
print_decay_channels(pid, pyth_data)
from particletools.tables import PYTHIAParticleData, SibyllParticleTable

# Translate SIBYLL particle codes to PYTHIA/PDG conventions
sibtab = SibyllParticleTable()
pyth_data = PYTHIAParticleData()

print("Example of index translation between model indices.")
for sib_id in sibtab.mod_ids:
    line = "SIBYLL ID: {0}\t SIBYLL name: {1:12s}\tPDG ID: {2}\t PYTHIA name {3}"
    pdg_id = sibtab.modid2pdg[sib_id]
    print(
        line.format(sib_id, sibtab.modid2modname[sib_id], pdg_id,
                    pyth_data.name(pdg_id)))