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

Functions

def exp
 
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(" ")
 
dictionary run_etaus = {}
 
list plane2branches
 
list ray_branches
 
int t0 = 0
 
tuple printhelp = len(sys.argv)
 

Function Documentation

def make_calib_df.exp (   t,
  p 
)

Definition at line 43 of file make_calib_df.py.

43 
44 def exp(t, *p):
45  A,tau = p
46  return A*np.exp(-(t - t0)/tau)
def make_calib_df.isTPCE (   df)

Definition at line 47 of file make_calib_df.py.

47 
48 def isTPCE(df):
49  return df.tpc <= 1
def make_calib_df.main (   output,
  inputs 
)

Definition at line 104 of file make_calib_df.py.

105 def main(output, inputs):
106  ntuples = NTupleGlob(inputs, branches.trkbranches + plane2branches + ray_branches)
107  df = ntuples.dataframe(nproc="auto", f=reduce_df)
108  df.to_hdf(output, key="df", mode="w")
def make_calib_df.reduce_df (   df,
  raydf = None 
)

Definition at line 50 of file make_calib_df.py.

50 
51 def reduce_df(df, raydf=None):
52  # use the external input to build the t0
53  ccross_t0_E = df.hit_max_time_p2_tpcE - tcathode_EE
54  ccross_t0_E[df.cryostat==1] = df.hit_max_time_p2_tpcE - tcathode_WE
55 
56  ccross_t0_W = df.hit_max_time_p2_tpcW - tcathode_EW
57  ccross_t0_W[df.cryostat==1] = df.hit_max_time_p2_tpcW - tcathode_WW
58 
59  # Select stopping tracks
60  select_track = df.selected == 0
61 
62  df["ccross_t0"] = ((ccross_t0_E + ccross_t0_W) / 2.) * tick_period
63  df["tpcE"] = isTPCE(df.hits2.h)
64 
65  # What to save
66  outdf = df.loc[(df.hits2.dqdx > 0) & (df.hits2.rr < 200.) & select_track,
67  [ ("hits2", "h", "time"),
68  ("tpcE", "", ""),
69  ("hits2", "dqdx", ""),
70  ("hits2", "pitch", ""),
71  ("hits2", "rr", ""),
72  ("hits2", "dir", "x"),
73  ("hits2", "h", "width"),
74  ("ccross_t0", "", ""),
75  ("meta", "run", ""),
76  ("cryostat", "", ""),
77  ("dir", "y", ""),
78  ("hit_min_time_p2_tpcE", "", ""),
79  ("hit_max_time_p2_tpcE", "", ""),
80  ("hit_min_time_p2_tpcW", "", ""),
81  ("hit_max_time_p2_tpcW", "", ""),
82  ]
83  ].copy()
84 
85  # Simplify column names
86  outdf.columns = ["time", "tpcE", "dqdx_nocorr", "pitch", "rr", "dir_x", "width", "ccross_t0", "run", "cryostat", "tdir_y", "mint_tpcE", "maxt_tpcE", "mint_tpcW", "maxt_tpcW"]
87 
88  # Correct for electron lifetime
89  outdf["thit"] = (outdf.time * tick_period - outdf.ccross_t0 - tanode*tick_period) / 1000.
90  if len(outdf):
91  thisrun = outdf.run.iloc[0]
92  # Correct in each TPC
93  outdf["dqdx_corr"] = outdf.dqdx_nocorr * exp(outdf.thit, 1., -run_etaus[thisrun][0]*1e3)
94  outdf.loc[~outdf.tpcE & (outdf.cryostat==0), "dqdx_corr"] = (outdf.dqdx_nocorr * exp(outdf.thit, 1., -run_etaus[thisrun][1]*1e3))[~outdf.tpcE & (outdf.cryostat==0)]
95  outdf.loc[outdf.tpcE & (outdf.cryostat==1), "dqdx_corr"] = (outdf.dqdx_nocorr * exp(outdf.thit, 1., -run_etaus[thisrun][2]*1e3))[outdf.tpcE & (outdf.cryostat==1)]
96  outdf.loc[~outdf.tpcE & (outdf.cryostat==1), "dqdx_corr"] = (outdf.dqdx_nocorr * exp(outdf.thit, 1., -run_etaus[thisrun][3]*1e3))[~outdf.tpcE & (outdf.cryostat==1)]
97 
98  # Save information on PFP daughters
99  if raydf is not None:
100  closest_tdaughter = raydf.groupby(level=0).daughter_sp_toend_dist.min()
101  outdf = outdf.join(closest_tdaughter.rename("closest_tdaughter"), on="entry", how="left")
102 
103  return outdf
T copy(T const &v)

Variable Documentation

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

Definition at line 20 of file make_calib_df.py.

list make_calib_df.plane2branches
Initial value:
1 = [
2  "h.time", "h.width", "h.tpc", "dqdx", "pitch", "rr", "dir.x",
3 ]

Definition at line 31 of file make_calib_df.py.

tuple make_calib_df.printhelp = len(sys.argv)

Definition at line 110 of file make_calib_df.py.

list make_calib_df.ray_branches
Initial value:
1 = [
2  "daughter_nsp",
3  "daughter_pdg",
4  "daughter_sp_toend_dist"
5 ]

Definition at line 36 of file make_calib_df.py.

dictionary make_calib_df.run_etaus = {}

Definition at line 24 of file make_calib_df.py.

dictionary make_calib_df.run_times = {}

Definition at line 17 of file make_calib_df.py.

int make_calib_df.t0 = 0

Definition at line 42 of file make_calib_df.py.

float make_calib_df.tcathode_EE = 3198.5279397664003

Definition at line 11 of file make_calib_df.py.

float make_calib_df.tcathode_EW = 3207.147982327826

Definition at line 12 of file make_calib_df.py.

float make_calib_df.tcathode_WE = 3200.883742841676

Definition at line 13 of file make_calib_df.py.

float make_calib_df.tcathode_WW = 3199.9763136348492

Definition at line 14 of file make_calib_df.py.