34 ccross_t0_E = df.hit_max_time_p2_tpcE - tcathode_EE
35 ccross_t0_E[df.cryostat==1] = df.hit_max_time_p2_tpcE - tcathode_WE
37 ccross_t0_W = df.hit_max_time_p2_tpcW - tcathode_EW
38 ccross_t0_W[df.cryostat==1] = df.hit_max_time_p2_tpcW - tcathode_WW
41 select_track = df.selected == 1
43 df[
"ccross_t0"] = ((ccross_t0_E + ccross_t0_W) / 2.) * tick_period
45 df = df[(df.hits2.dqdx > 0) & select_track].
copy()
46 df[
"chunk"] = df.index.get_level_values(1) // 5
47 df[
"tpcE"] =
isTPCE(df.hits2.h)
48 outdf = df.groupby([
"entry",
"chunk"])[(
'hits2',
'dqdx',
'',
''),].median()
49 outdf = outdf.join(df.groupby([
"entry",
"chunk"])[[(
'hits2',
'h',
'p',
'x'),
50 (
'hits2',
'h',
'p',
'y'),
51 (
'hits2',
'h',
'p',
'z'),
52 (
'hits2',
'h',
'time',
''),
53 (
'hits2',
'dir',
'x',
''),
54 (
'hits2',
'dir',
'y',
''),
55 (
'hits2',
'dir',
'z',
''),]].
mean())
57 outdf.columns = [
"dqdx",
"x",
"y",
"z",
"time",
"dirx",
"diry",
"dirz"]
60 norm = np.sqrt(outdf.dirx**2 + outdf.diry**2 + outdf.dirz**2)
61 outdf.dirx = outdf.dirx / norm
62 outdf.diry = outdf.diry / norm
63 outdf.dirz = outdf.dirz / norm
66 outdf[
"tpcE"] = df.groupby([
"entry",
"chunk"]).tpcE.all()
67 outdf[
"tpcW"] = (~outdf.tpcE) & (df.groupby([
"entry",
"chunk"]).tpcE.nunique() == 1)
70 outdf[
"ccross_t0"] = df.groupby([
"entry",
"chunk"]).ccross_t0.first()
72 outdf[
"cryostat"] = df.groupby([
"entry",
"chunk"]).cryostat.first()
74 outdf[
"run"] = df.groupby([
"entry",
"chunk"])[[(
'meta',
'run',
'',
''),]].
first()
77 outdf = outdf[outdf.tpcE | outdf.tpcW].drop(columns=[
"tpcW"])