Esempio n. 1
0
 def apdgid(partid):
     partid = str(partid)
     if pypdt.get(partid) != None:
         return pypdt.get(partid)
     else:
         if partid[0] == '-':
             return pypdt.get(partid[1:])
         else:
             return ValueError("Id not found")
Esempio n. 2
0
    def __init__(self,
                 init_conds=None,
                 bounds=None,
                 particle_id=11,
                 B_func=lambda p_vec: np.array([0., 0., 1.]),
                 E_func=lambda p_vec: np.array([0., 0., 0.]),
                 zevents=None):
        '''
        Default particle_id is for electron

        B_func should take in 3D numpy array of position, but defaults to a 1 Tesla field in the z direction.
        '''
        self.init_conds = init_conds
        self.bounds = bounds
        # dummy termination (no termination) if no bounds
        if bounds is None:
            self.terminate = lambda t, x: 1
        else:
            self.terminate = get_terminate(bounds)
        if particle_id < 0:
            sign = -1
        else:
            sign = +1
        particle_id = abs(particle_id)
        self.particle = pypdt.get(particle_id)
        self.particle.mass_kg = self.particle.mass * one_gev_c2_to_kg
        self.particle.charge_true = self.particle.charge * sign
        self.B_func = B_func
        self.E_func = E_func
        self.zevents = zevents
Esempio n. 3
0
def massPDG(pdgid):
    """Gaussian mass distribution with mass and width of a chosen particle.
    Accept the Particle Data Group ID as the only argument."""
    return gauss(
        pypdt.get(pdgid).mass,
        pypdt.get(pdgid).width / (2 * _sqrt(2 * _log(2))))
Esempio n. 4
0
import math
import numbers
import numpy as np
import pandas as pd
import lmfit as lm
from scipy.spatial.transform import Rotation
import scipy.optimize as optimize

import pypdt
from .conversions import one_gev_c2_to_kg, one_kgm_s_to_mev_c, q_factor
from scipy.constants import c

cbar = c / 1.e9
cmmns = c / 1.e6
m_e = pypdt.get(11).mass*1000.
q_e = -1

# fitting routine
def fit_helix(track_data, B_data, m=m_e, q=q_e, rot=True):
    '''
    track_data is 4 by N np.array, B_data is 3 by N where each row is
    track_data: [t, x, y, z] with units [s, m, m, m]
    B_data: [Bx, By, Bz] with units [T, T, T]
    (to work out of the box with emtracks.particle)
    '''
    track_data = track_data.copy() # to not change track_data information
    track_data[0] = track_data[0]*1e9 # convert to ns
    track_data[1:] = track_data[1:]*1e3 # convert to mm
    # x0, y0 = track_data[1:3,0] # for phi0 estimate
    # translations:
    translate_vec = track_data[:,0].reshape(1, 4)
#!/usr/bin/env python
import ROOT
from math import sqrt
ROOT.gStyle.SetOptStat(00000)
infile=ROOT.TFile("run_0.root")
outfile=ROOT.TFile("cocktail.root","RECREATE")
outfile.cd()
hBreakup=ROOT.TH1F("hBreakup","neutron (breakup) escapes",300,0,300)
hNeutron=ROOT.TH1F("hNeutron","neutron (other) escapes",300,0,300)
hGamma=ROOT.TH1F("hGamma","#gamma escapes",300,0,300)
hOther=ROOT.TH1F("hOther","other",300,0,300)
hAbsorbed=ROOT.TH1F("hAbsorbed","no particle escape",300,0,300)
hDeuteronExit=ROOT.TH1F("deuteronExit","deuteron escapes",300,0,300)
import pypdt
neutron_mass=pypdt.get(2112).mass
proton_mass=pypdt.get(2212).mass
deuteron4=ROOT.TLorentzVector(0,0,sqrt(.270*(.270+2*1.875)),1.875+.270)
mothermass=ROOT.TH1F("mother","mother mass",1000,0,5)
missingmass=ROOT.TH1F("missing","missing mass",1000,0,5)
iev=0
edepMap={}
particleMap={}
for event in infile.sim:
    if iev % (0.05*infile.sim.GetEntries())==0:
        print str(int(float(100.*iev/infile.sim.GetEntries())))+"% done"
    deuteronExit=False
    breakup=False
    other=False
    gamma=False
    neutron=False
    tracks=[]