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
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)))