All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
make_equalibriate_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
 
int t0 = 0
 
tuple printhelp = len(sys.argv)
 

Function Documentation

def make_equalibriate_df.exp (   t,
  p 
)

Definition at line 39 of file make_equalibriate_df.py.

39 
40 def exp(t, *p):
41  A,tau = p
42  return A*np.exp(-(t - t0)/tau)
def make_equalibriate_df.isTPCE (   df)

Definition at line 43 of file make_equalibriate_df.py.

43 
44 def isTPCE(df):
45  return df.tpc <= 1
def make_equalibriate_df.main (   output,
  inputs 
)

Definition at line 88 of file make_equalibriate_df.py.

88 
89 def main(output, inputs):
90  ntuples = NTupleGlob(inputs, branches.trkbranches + plane2branches)
91  df = ntuples.dataframe(nproc="auto", f=reduce_df)
92  df.to_hdf(output, key="df", mode="w")
def make_equalibriate_df.reduce_df (   df)

Definition at line 46 of file make_equalibriate_df.py.

46 
47 def reduce_df(df):
48  # use the external input to build the t0
49  ccross_t0_E = df.hit_max_time_p2_tpcE - tcathode_EE
50  ccross_t0_E[df.cryostat==1] = df.hit_max_time_p2_tpcE - tcathode_WE
51 
52  ccross_t0_W = df.hit_max_time_p2_tpcW - tcathode_EW
53  ccross_t0_W[df.cryostat==1] = df.hit_max_time_p2_tpcW - tcathode_WW
54 
55  # Select anode + cathode crossing tracks
56  select_track = df.selected == 1
57 
58  df["ccross_t0"] = ((ccross_t0_E + ccross_t0_W) / 2.) * tick_period
59  df["tpcE"] = isTPCE(df.hits2.h)
60 
61  # What to save
62  outdf = df.loc[(df.hits2.dqdx > 0) & select_track,
63  [ ("hits2", "h", "time"),
64  ("hits2", "h", "wire"),
65  ("tpcE", "", ""),
66  ("hits2", "dqdx", ""),
67  ("hits2", "pitch", ""),
68  ("ccross_t0", "", ""),
69  ("meta", "run", ""),
70  ("cryostat", "", ""),
71  ]
72  ].copy()
73 
74  # Simplify column names
75  outdf.columns = ["time", "wire", "tpcE", "dqdx_nocorr", "width", "ccross_t0", "run", "cryostat"]
76 
77  # Correct for electron lifetime
78  outdf["thit"] = (outdf.time * tick_period - outdf.ccross_t0 - tanode*tick_period) / 1000.
79  if len(outdf):
80  thisrun = outdf.run.iloc[0]
81  # Correct in each TPC
82  outdf["dqdx_corr"] = outdf.dqdx_nocorr * exp(outdf.thit, 1., -run_etaus[thisrun][0]*1e3)
83  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)]
84  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)]
85  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)]
86 
87  return outdf
T copy(T const &v)

Variable Documentation

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

Definition at line 20 of file make_equalibriate_df.py.

list make_equalibriate_df.plane2branches
Initial value:
1 = [
2  "h.time", "h.width", "h.tpc", "h.wire", "dqdx", "pitch",
3 ]

Definition at line 31 of file make_equalibriate_df.py.

tuple make_equalibriate_df.printhelp = len(sys.argv)

Definition at line 94 of file make_equalibriate_df.py.

dictionary make_equalibriate_df.run_etaus = {}

Definition at line 24 of file make_equalibriate_df.py.

dictionary make_equalibriate_df.run_times = {}

Definition at line 17 of file make_equalibriate_df.py.

int make_equalibriate_df.t0 = 0

Definition at line 38 of file make_equalibriate_df.py.

float make_equalibriate_df.tcathode_EE = 3198.5279397664003

Definition at line 11 of file make_equalibriate_df.py.

float make_equalibriate_df.tcathode_EW = 3207.147982327826

Definition at line 12 of file make_equalibriate_df.py.

float make_equalibriate_df.tcathode_WE = 3200.883742841676

Definition at line 13 of file make_equalibriate_df.py.

float make_equalibriate_df.tcathode_WW = 3199.9763136348492

Definition at line 14 of file make_equalibriate_df.py.