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()
24 "h.p.x",
"h.p.y",
"h.p.z",
"h.time",
"h.tpc",
"dqdx",
"dir.x",
"dir.y",
"dir.z",
26 plane2branches = [
"hits2.%s" % s
for s
in plane2branches]
33 ccross_t0_E = df.hit_max_time_p2_tpcE - tcathode_EE
34 ccross_t0_E[df.cryostat==1] = df.hit_max_time_p2_tpcE - tcathode_WE
36 ccross_t0_W = df.hit_max_time_p2_tpcW - tcathode_EW
37 ccross_t0_W[df.cryostat==1] = df.hit_max_time_p2_tpcW - tcathode_WW
40 select_track = df.selected == 1
42 df[
"ccross_t0"] = ((ccross_t0_E + ccross_t0_W) / 2.) * tick_period
44 df = df[(df.hits2.dqdx > 0) & select_track].
copy()
45 df[
"chunk"] = df.index.get_level_values(1) // 5
46 df[
"tpcE"] =
isTPCE(df.hits2.h)
47 outdf = df.groupby([
"entry",
"chunk"])[(
'hits2',
'dqdx',
'',
''),].median()
48 outdf = outdf.join(df.groupby([
"entry",
"chunk"])[[(
'hits2',
'h',
'p',
'x'),
49 (
'hits2',
'h',
'p',
'y'),
50 (
'hits2',
'h',
'p',
'z'),
51 (
'hits2',
'h',
'time',
''),
52 (
'hits2',
'dir',
'x',
''),
53 (
'hits2',
'dir',
'y',
''),
54 (
'hits2',
'dir',
'z',
''),]].
mean())
56 outdf.columns = [
"dqdx",
"x",
"y",
"z",
"time",
"dirx",
"diry",
"dirz"]
59 norm = np.sqrt(outdf.dirx**2 + outdf.diry**2 + outdf.dirz**2)
60 outdf.dirx = outdf.dirx / norm
61 outdf.diry = outdf.diry / norm
62 outdf.dirz = outdf.dirz / norm
65 outdf[
"tpcE"] = df.groupby([
"entry",
"chunk"]).tpcE.all()
66 outdf[
"tpcW"] = (~outdf.tpcE) & (df.groupby([
"entry",
"chunk"]).tpcE.nunique() == 1)
69 outdf[
"ccross_t0"] = df.groupby([
"entry",
"chunk"]).ccross_t0.first()
71 outdf[
"cryostat"] = df.groupby([
"entry",
"chunk"]).cryostat.first()
73 outdf[
"run"] = df.groupby([
"entry",
"chunk"])[[(
'meta',
'run',
'',
''),]].
first()
76 outdf = outdf[outdf.tpcE | outdf.tpcW].drop(columns=[
"tpcW"])
82 ntuples =
NTupleGlob(inputs, branches.trkbranches + plane2branches)
83 df = ntuples.dataframe(nproc=
"auto", f=reduce_df)
84 df.to_hdf(output, key=
"df", mode=
"w")
86 if __name__ ==
"__main__":
87 printhelp = len(sys.argv) < 3
or sys.argv[1] ==
"-h"
89 print(
"Usage: python make_etau_df.py [output.df] [inputs.root,]")
91 main(sys.argv[1], sys.argv[2:])
do one_file $F done echo for F in find $TOP name CMakeLists txt print
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
open(RACETRACK) or die("Could not open file $RACETRACK for writing")