def test9k(): os.system('rm -rf tof_save.txt') field = mytof.Field(1., 1., 2.) pat = mytof.Particle(13, -1., 0.1056583745, -.1, 0., .02, 0., 0.33, -1.5) tof = mytof.Tof(.5, 2., 3., 25.e-9, .999) print tof.get_time_v2(pat, field) os.system('cp -f tof_save.txt tof_test_9k.txt')
def test9c(): os.system('rm -rf tof_save.txt') field = mytof.Field(1., 1., 2.) pat = mytof.Particle(13, -1., 0.1056583745, .10 / 2**.5, .10 / 2**.5, .1, 0.0, 0.00, -1.5) tof = mytof.Tof(1.5, 2., 3., 25.e-9, .999) print tof.get_time_v2(pat, field) os.system('cp -f tof_save.txt tof_test_9c.txt')
def test8b(): os.system('rm -rf tof_save.txt') field = mytof.Field(1., 1., 2.) pat = mytof.Particle(130, 0., pdg2m(130), .5 / 2**.5, .5 / 2**.5, 1., 0.5, 0.25, 1.5) tof = mytof.Tof(1.5, 2., 3., 25.e-9, .999) print tof.get_time_v2(pat, field) os.system('cp -f tof_save.txt tof_test_8.txt')
def test6b(): os.system('rm -rf tof_save.txt') field = mytof.Field(1., 1., 2.) pat = mytof.Particle(-13, 1., 0.1056583745, .3 / 2**.5, .3 / 2**.5, -1., -.90 / 2**.5, .90 / 2**.5, 1.5) tof = mytof.Tof(1.5, 2., 3., 25.e-9, .999) print tof.get_time_v2(pat, field) os.system('cp -f tof_save.txt tof_test_6b.txt')
def test4(): os.system('rm -rf tof_save.txt') field = mytof.Field(1., 1., 2.) pat = mytof.Particle(13, -1., 0.1056583745, .5 / 2**.5, .5 / 2**.5, 1., 0.5, 0.25, 1.75) tof = mytof.Tof(.5, 2., 3., 25.e-9, .999) print tof.get_time_v2(pat, field) os.system('cp -f tof_save.txt tof_test_4.txt')
def test6c(): os.system('rm -rf tof_save.txt') field = mytof.Field(1., 1., 2.) phi = math.pi / 180 * 88. pat = mytof.Particle(-13, 1., 0.1056583745, .3 * math.cos(phi), .3 * math.sin(phi), -.1, -.99, 0.001, 1.5) tof = mytof.Tof(1.5, 2., 3., 25.e-9, .999) print tof.get_time_v2(pat, field) os.system('cp -f tof_save.txt tof_test_6c.txt')
def test1(): os.system('rm -rf tof_save.txt') field = mytof.Field(1., 1., 2.) # def __init__(self, pdgid, charge, m, px, py, pz, vx=0., vy=0., vz=0.): pat = mytof.Particle(13, -1., 0.1056583745, .5 / 2**.5, .5 / 2**.5, 0., 0., 0., 0.) # def __init__(self, r_in, r_out, z, sigma, eff): tof = mytof.Tof(.5, 2., 3., 25.e-9, .999) print tof.get_time_v2(pat, field) os.system('cp -f tof_save.txt tof_test_1.txt')
def main(): # # PID systems # create ToF and mu as a ToF. field = mytof.Field(1., 1.575, 3.780/2) tofdet = mytof.Tof(.250, 1.090, 2.550/2, .1, .99) mu0det = mytof.Tof(.950, 1.930, 3.900/2, .1, .99) # Fin = r.TFile('/home/vvorob/public/tuples/fccedm/dkspipi.root') tin = Fin.Get('events') # finname = 'output/tmp_out.txt' Fout = r.TFile('output/txt2root.root', 'recreate') t = r.TTree('t', 'ctau papas tree :)') # n = array.array('i', [0]) recgen = array.array('i', [0]*100) pdg = array.array('i', [0]*100) q = array.array('f', [0.]*100) en = array.array('f', [0.]*100) pt = array.array('f', [0.]*100) px = array.array('f', [0.]*100) py = array.array('f', [0.]*100) pz = array.array('f', [0.]*100) th = array.array('f', [0.]*100) phi = array.array('f', [0.]*100) tof = array.array('f', [0.]*100) tofmu = array.array('f', [0.]*100) # t.Branch('n', n, 'n/I') t.Branch('recgen', recgen, 'recgen[n]/I') t.Branch('pdg', pdg, 'pdg[n]/I') t.Branch('q', q, 'q[n]/F') t.Branch('en', en, 'en[n]/F') t.Branch('pt', pt, 'pt[n]/F') t.Branch('px', px, 'px[n]/F') t.Branch('py', py, 'py[n]/F') t.Branch('pz', pz, 'pz[n]/F') t.Branch('th', th, 'th[n]/F') t.Branch('phi', phi, 'phi[n]/F') t.Branch('tof', tof, 'tof[n]/F') t.Branch('tofmu', tofmu, 'tofmu[n]/F') # n0 = array.array('i', [0]) pdg0 = array.array('i', [0]*100) genver = array.array('i', [0]*100) q0 = array.array('f', [0.]*100) en0 = array.array('f', [0.]*100) pt0 = array.array('f', [0.]*100) px0 = array.array('f', [0.]*100) py0 = array.array('f', [0.]*100) pz0 = array.array('f', [0.]*100) th0 = array.array('f', [0.]*100) phi0 = array.array('f', [0.]*100) tof0 = array.array('f', [0.]*100) tofmu0 = array.array('f', [0.]*100) # t.Branch('n0', n0, 'n0/I') t.Branch('genver', genver, 'genver[n0]/I') t.Branch('pdg0', pdg0, 'pdg0[n0]/I') t.Branch('q0', q0, 'q0[n0]/F') t.Branch('en0', en0, 'en0[n0]/F') # t.Branch('pt0', pt0, 'pt0[n0]/F') t.Branch('px0', px0, 'px0[n0]/F') t.Branch('py0', py0, 'py0[n0]/F') t.Branch('pz0', pz0, 'pz0[n0]/F') # t.Branch('th0', th0, 'th0[n0]/F') # t.Branch('phi0', phi0, 'phi0[n0]/F') t.Branch('tof0', tof0, 'tof0[n]/F') t.Branch('tofmu0', tofmu0, 'tofmu0[n]/F') # nv0 = array.array('i', [0]) vx0 = array.array('f', [0.]*100) vy0 = array.array('f', [0.]*100) vz0 = array.array('f', [0.]*100) # t.Branch('nv0', nv0, 'nv0/I') t.Branch('vx0', vx0, 'vx0[nv0]/F') t.Branch('vy0', vy0, 'vy0[nv0]/F') t.Branch('vz0', vz0, 'vz0[nv0]/F') # # type evn prt pdgid en pt px py pz th eta phi m q # 0 1 2 3 4 5 6 7 8 9 10 11 12 fin = open(finname) evn = 1 n[0] = 0 n0[0] = 0 for line in fin: if line[0] == '#': continue # print line.rstrip('\n') lin = line.split() li = [float(x) for x in lin[4:]] li = [int(x) for x in lin[1:4]] + li if lin[0] == 'gen': isGen = True isRec = False elif lin[0] == 'rec': isRec = True isGen = False if isRec: pdg[n[0]] = li[2] en[n[0]] = li[3] pt[n[0]] = li[4] px[n[0]] = li[5] py[n[0]] = li[6] pz[n[0]] = li[7] th[n[0]] = li[8] phi[n[0]] = li[10] q[n[0]] = li[12] n[0] += 1 ######## if isGen: if evn != li[0] and evn != -1: ######## bbeforeFill(evn, tin, n0, pdg0, q0, en0, px0, py0, pz0) beforeFill(evn, tin, genver, nv0, vx0, vy0, vz0, n, recgen, px, py, pz, n0, px0, py0, pz0) beforeFill_pid(n0, pdg0, q0, en0, px0, py0, pz0, tof0, tofmu0, tof, tofmu, tofdet, mu0det, field) ######## t.Fill() evn = li[0] n[0] = 0 n0[0] = 0 ######## bbeforeFill(evn, tin, n0, pdg0, q0, en0, px0, py0, pz0) beforeFill(evn, tin, genver, nv0, vx0, vy0, vz0, n, recgen, px, py, pz, n0, px0, py0, pz0) beforeFill_pid(n0, pdg0, q0, en0, px0, py0, pz0, tof0, tofmu0, tof, tofmu, tofdet, mu0det, field) t.Fill() t.Write() Fin.Close() Fout.Close()