All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
make_etau_df Namespace Reference

Functions

def isTPCE
 
def reduce_df
 
def main
 

Variables

float tcathode_EE = 3198.5279397664003
 
float tcathode_EW = 3207.147982327826
 
float tcathode_WE = 3200.883742841676
 
float tcathode_WW = 3199.9763136348492
 
dictionary run_times = {}
 
tuple dat = line.split(" ")
 
list plane2branches
 
tuple printhelp = len(sys.argv)
 

Function Documentation

def make_etau_df.isTPCE (   df)

Definition at line 28 of file make_etau_df.py.

28 
29 def isTPCE(df):
30  return df.tpc <= 1
def make_etau_df.main (   output,
  inputs 
)

Definition at line 81 of file make_etau_df.py.

81 
82 def main(output, inputs):
83  ntuples = NTupleGlob(inputs, branches.trkbranches + plane2branches)
84  df = ntuples.dataframe(nproc="auto", f=reduce_df)
85  df.to_hdf(output, key="df", mode="w")
def make_etau_df.reduce_df (   df)

Definition at line 31 of file make_etau_df.py.

31 
32 def reduce_df(df):
33  # use the external input to build the t0
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
36 
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
39 
40  # Select anode + cathode crossing tracks
41  select_track = df.selected == 1
42 
43  df["ccross_t0"] = ((ccross_t0_E + ccross_t0_W) / 2.) * tick_period
44 
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())
56 
57  outdf.columns = ["dqdx", "x", "y", "z", "time", "dirx", "diry", "dirz"]
58 
59  # fix the direction normalization
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
64 
65  # TPC/Cryo info
66  outdf["tpcE"] = df.groupby(["entry", "chunk"]).tpcE.all()
67  outdf["tpcW"] = (~outdf.tpcE) & (df.groupby(["entry", "chunk"]).tpcE.nunique() == 1)
68 
69  # Save T0
70  outdf["ccross_t0"] = df.groupby(["entry", "chunk"]).ccross_t0.first()
71  # also save the cryostat number
72  outdf["cryostat"] = df.groupby(["entry", "chunk"]).cryostat.first()
73  # And run number
74  outdf["run"] = df.groupby(["entry", "chunk"])[[('meta', 'run', '', ''),]].first()
75 
76  # Only save chunks that are all in one TPC
77  outdf = outdf[outdf.tpcE | outdf.tpcW].drop(columns=["tpcW"])
78 
79  return outdf
80 
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
T copy(T const &v)

Variable Documentation

tuple make_etau_df.dat = line.split(" ")

Definition at line 20 of file make_etau_df.py.

list make_etau_df.plane2branches
Initial value:
1 = [
2  "h.p.x", "h.p.y", "h.p.z", "h.time", "h.tpc", "dqdx", "dir.x", "dir.y", "dir.z",
3 ]

Definition at line 23 of file make_etau_df.py.

tuple make_etau_df.printhelp = len(sys.argv)

Definition at line 87 of file make_etau_df.py.

dictionary make_etau_df.run_times = {}

Definition at line 17 of file make_etau_df.py.

float make_etau_df.tcathode_EE = 3198.5279397664003

Definition at line 11 of file make_etau_df.py.

float make_etau_df.tcathode_EW = 3207.147982327826

Definition at line 12 of file make_etau_df.py.

float make_etau_df.tcathode_WE = 3200.883742841676

Definition at line 13 of file make_etau_df.py.

float make_etau_df.tcathode_WW = 3199.9763136348492

Definition at line 14 of file make_etau_df.py.