4 from lib
import branches
11 tcathode_EE = 3198.5279397664003
12 tcathode_EW = 3207.147982327826
13 tcathode_WE = 3200.883742841676
14 tcathode_WW = 3199.9763136348492
18 with
open(
"/icarus/app/users/gputnam/calib/rundata")
as f:
21 run_times[int(dat[0])] = dt.datetime.strptime(dat[1].rstrip(
"\n"),
"%Y-%m-%dT%H:%M:%S").date()
25 with
open(
"/icarus/app/users/gputnam/calib/plots2/etau_run_data.txt")
as f:
29 run_etaus[int(dat[0])] = [float(d)
for d
in dat[1:]]
32 "h.time",
"h.width",
"h.tpc",
"dqdx",
"pitch",
"rr",
"dir.x",
34 plane2branches = [
"hits2.%s" % s
for s
in plane2branches]
39 "daughter_sp_toend_dist"
45 return A*np.exp(-(t - t0)/tau)
52 ccross_t0_E = df.hit_max_time_p2_tpcE - tcathode_EE
53 ccross_t0_E[df.cryostat==1] = df.hit_max_time_p2_tpcE - tcathode_WE
55 ccross_t0_W = df.hit_max_time_p2_tpcW - tcathode_EW
56 ccross_t0_W[df.cryostat==1] = df.hit_max_time_p2_tpcW - tcathode_WW
59 select_track = df.selected == 0
61 df[
"ccross_t0"] = ((ccross_t0_E + ccross_t0_W) / 2.) * tick_period
62 df[
"tpcE"] =
isTPCE(df.hits2.h)
65 outdf = df.loc[(df.hits2.dqdx > 0) & (df.hits2.rr < 200.) & select_track,
66 [ (
"hits2",
"h",
"time"),
68 (
"hits2",
"dqdx",
""),
69 (
"hits2",
"pitch",
""),
71 (
"hits2",
"dir",
"x"),
72 (
"hits2",
"h",
"width"),
73 (
"ccross_t0",
"",
""),
77 (
"hit_min_time_p2_tpcE",
"",
""),
78 (
"hit_max_time_p2_tpcE",
"",
""),
79 (
"hit_min_time_p2_tpcW",
"",
""),
80 (
"hit_max_time_p2_tpcW",
"",
""),
85 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"]
88 outdf[
"thit"] = (outdf.time * tick_period - outdf.ccross_t0 - tanode*tick_period) / 1000.
90 thisrun = outdf.run.iloc[0]
92 outdf[
"dqdx_corr"] = outdf.dqdx_nocorr *
exp(outdf.thit, 1., -run_etaus[thisrun][0]*1e3)
93 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)]
94 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)]
95 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)]
99 closest_tdaughter = raydf.groupby(level=0).daughter_sp_toend_dist.min()
100 outdf = outdf.join(closest_tdaughter.rename(
"closest_tdaughter"), on=
"entry", how=
"left")
105 ntuples =
NTupleGlob(inputs, branches.trkbranches + plane2branches + ray_branches)
106 df = ntuples.dataframe(nproc=
"auto", f=reduce_df)
107 df.to_hdf(output, key=
"df", mode=
"w")
109 if __name__ ==
"__main__":
110 printhelp = len(sys.argv) < 3
or sys.argv[1] ==
"-h"
112 print(
"Usage: python make_calib_df.py [output.df] [inputs.root,]")
114 main(sys.argv[1], sys.argv[2:])
do one_file $F done echo for F in find $TOP name CMakeLists txt print
open(RACETRACK) or die("Could not open file $RACETRACK for writing")