All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
selection.py
Go to the documentation of this file.
1 import numpy as np
2 from helpers import *
3 
4 def InBeam(t): # us
5  return (t > 0.) & (t < 1.800) # allow some wiggle
6 
7 def InBeamVeto(t): # us
8  return (t > 0.) & (t < 2.200) # allow some wiggle
9 
10 def InBeamTrue(t): # us
11  return (t > 0.) & (t < 1.596) # No wiggle!
12 
13 def InFV(x, y, z): # cm
14  xmin = -199.15 + 10
15  ymin = -200. + 10
16  zmin = 0.0 + 10
17  xmax = 199.15 - 10
18  ymax = 200. - 10
19  zmax = 500. - 50
20 
21  return (x > xmin) & (x < xmax) & (y > ymin) & (y < ymax) & (z > zmin) & (z < zmax)
22 
23 # Primary track calculation
25  # these are the tracks that we consider as coming from the neutrino vertex
26  from_slice = data["slc.reco.trk.atslc"] & data["slc.reco.trk.parent_is_primary"]
27 
28  maybe_muon_exiting = np.invert(data["slc.reco.trk.contained"]) & (data["slc.reco.trk.len"] > 100)
29  maybe_muon_contained = data["slc.reco.trk.contained"] & (data["slc.reco.trk.bestplane.chi2_proton"] > 60) & (data["slc.reco.trk.bestplane.chi2_muon"] < 30) & (data["slc.reco.trk.len"] > 50)
30  # In cases where all the tracks are contained, first apply cuts on the particle ID
31  maybe_muon = from_slice & (maybe_muon_contained | maybe_muon_exiting)
32  has_maybe_muon = maybe_muon.any()
33 
34  # Cases where all the tracks are contained
35  ret = (data["slc.reco.trk.len"]*maybe_muon).argmax().max()
36  # map very small to -1
37  ret[ret < 0] = -1
38  ret[np.invert(has_maybe_muon)] = -1
39  return ret
40 
41 # Using truth to get the primary track
43  ret = ((np.abs(data["slc.reco.trk.truth.p.pdg"]) == 13) & \
44  (data["slc.reco.trk.truth.bestmatch.energy"] / data["slc.reco.trk.truth.p.planeVisE"] > 0.5)).argmax().max()
45  is_numu_cc = (data["slc.truth.index"] >= 0) & data["slc.truth.iscc"] & (np.abs(data["slc.truth.pdg"]) == 14)
46  # ignore non cc numu cases
47  ret[np.invert(is_numu_cc)] = -1
48  ret[ret<0] = -1
49  # setup for index
50  #ret = group(ret, np.ones(ret.shape, dtype="int"))
51  return ret
52 
53 # Define the Cuts!!!!!
54 def crtveto(data):
55  return broadcast(np.invert(InBeamVeto(data["crt_hits.time"]).any()), data["nslc"])
57  return np.invert(InBeamVeto(data["crt_tracks.time"]).any())
58 def crttrackveto(data):
59  return broadcast(crttrackveto_perevt(data), data["nslc"])
60 
62  return np.invert((InBeamVeto(data["crt_tracks.time"]) & (data["crt_tracks.hita.position.y"] > -357.) & (data["crt_tracks.hitb.position.y"] > -357.)).any())
64  return broadcast(crttrackveto_nobottom_perevt(data), data["nslc"])
65 
66 def fid(data):
67  return InFV(data["slc.vertex.x"], data["slc.vertex.y"], data["slc.vertex.z"])
68 def nu_score(data):
69  return (data["slc.nu_score"] > 0.4) & np.invert(data["slc.is_clear_cosmic"])
70 def f_time(data):
71  return InBeam(data["slc.fmatch.time"])
72 def f_score(data):
73  return data["slc.fmatch.score"] < 7
74 def ptrk(data):
75  return data["slc.has_ptrk"] & np.invert(np.isnan(data["slc.ptrk.recop"])) & (data["slc.ptrk.recop"] < 7.5) & (data["slc.ptrk.recop"] > 0.)
76 def crttrack(data):
77  return np.isnan(data["slc.ptrk.crttrack.angle"]) | (data["slc.ptrk.crttrack.angle"] > 0.05)
78 def crthit(data):
79  return np.isnan(data["slc.ptrk.crthit.distance"]) | (data["slc.ptrk.crthit.distance"] > 5) | InBeam(data["slc.ptrk.crthit.hit.time"])
def ptrk
Definition: selection.py:74
def get_true_primary_track
Definition: selection.py:42
def get_primary_tracks
Definition: selection.py:24
def fid
Definition: selection.py:66
def f_score
Definition: selection.py:72
def InFV
Definition: selection.py:13
def crttrackveto_perevt
Definition: selection.py:56
def crttrack
Definition: selection.py:76
def crttrackveto_nobottom
Definition: selection.py:63
def crttrackveto_nobottom_perevt
Definition: selection.py:61
def InBeamTrue
Definition: selection.py:10
def broadcast
Definition: helpers.py:5
def crttrackveto
Definition: selection.py:58
def InBeamVeto
Definition: selection.py:7
def f_time
Definition: selection.py:70
def crtveto
Definition: selection.py:54
def nu_score
Definition: selection.py:68
def crthit
Definition: selection.py:78
def InBeam
Definition: selection.py:4