Functions | Variables
PandAna.var.analysis_vars Namespace Reference

Functions

def kLongestProng (tables)
 Nue Vars. More...
 
def kMaxY (tables)
 
def kNueCalibrationCorr (det, ismc, run)
 
def kEMEnergy (tables)
 
def kHadEnergy (tables)
 
def kNueEnergy (tables)
 
def kCosNumi (tables)
 Numu Vars. More...
 
def kNumuMuE (tables)
 
def kNumuHadE (tables)
 
def NusScale (isRHC, det)
 Nus Vars. More...
 
def kNusEnergy (tables)
 

Variables

 kCVNe = Var(lambda tables: tables['rec.sel.cvn2017']['nueid'])
 
 kCVNm = Var(lambda tables: tables['rec.sel.cvn2017']['numuid'])
 
 kCVNnc = Var(lambda tables: tables['rec.sel.cvn2017']['ncid'])
 
 kNHit = Var(lambda tables: tables['rec.slc']['nhit'])
 
 kRHC = Var(lambda tables: tables['rec.spill']['isRHC'])
 
 kDetID = Var(lambda tables: tables['rec.hdr']['det'])
 
 kLongestProng = Var(kLongestProng)
 
 kDistAllTop = Var(lambda tables: tables['rec.sel.nuecosrej']['distallpngtop'])
 
 kDistAllBottom = Var(lambda tables: tables['rec.sel.nuecosrej']['distallpngbottom'])
 
 kDistAllWest = Var(lambda tables: tables['rec.sel.nuecosrej']['distallpngwest'])
 
 kDistAllEast = Var(lambda tables: tables['rec.sel.nuecosrej']['distallpngeast'])
 
 kDistAllBack = Var(lambda tables: tables['rec.sel.nuecosrej']['distallpngback'])
 
 kDistAllFront = Var(lambda tables: tables['rec.sel.nuecosrej']['distallpngfront'])
 
 kHitsPerPlane = Var(lambda tables: tables['rec.sel.nuecosrej']['hitsperplane'])
 
 kPtP = Var(lambda tables: tables['rec.sel.nuecosrej']['partptp'])
 
 kMaxY = Var(kMaxY)
 
 kSparsenessAsymm = Var(lambda tables: tables['rec.sel.nuecosrej']['sparsenessasymm'])
 
 kCaloE = Var(lambda tables: tables['rec.slc']['calE'])
 
 kEMEnergy = Var(kEMEnergy)
 
 kHadEnergy = Var(kHadEnergy)
 
 kNueEnergy = Var(kNueEnergy)
 
 kCosNumi = Var(kCosNumi)
 
 kNumuMuE = Var(kNumuMuE)
 
 kNumuHadE = Var(kNumuHadE)
 
 kNumuE = kNumuMuE+kNumuHadE
 
 kCCE = kNumuE
 
 kNusEnergy = Var(kNusEnergy)
 
 kClosestSlcTime = Var(lambda tables: tables['rec.slc']['closestslicetime'])
 
 kClosestSlcMinDist = Var(lambda tables: tables['rec.slc']['closestslicemindist'])
 
 kClosestSlcMinTop = Var(lambda tables: tables['rec.slc']['closestsliceminfromtop'])
 

Function Documentation

def PandAna.var.analysis_vars.kCosNumi (   tables)

Numu Vars.

Definition at line 152 of file analysis_vars.py.

References PandAna.var.analysis_vars.kCosNumi, PandAna.var.analysis_vars.kDetID, and sum.

152 def kCosNumi(tables):
153  df = tables['rec.trk.kalman.tracks']
154  # Primary kalman track only
155  df = df[df['rec.trk.kalman.tracks_idx']==0]
156  KalDir = df[['dir.x','dir.y', 'dir.z']]
157 
158  # Use separate beam dir for each detector
159  KalDirFD = KalDir[kDetID(tables)==detector.kFD]
160  KalDirND = KalDir[kDetID(tables)==detector.kND]
161 
162  CosFD = KalDirFD.mul(BeamDirFD, axis=1).sum(axis=1)
163  CosND = KalDirND.mul(BeamDirND, axis=1).sum(axis=1)
164 
165  return pd.concat([CosFD, CosND])
Double_t sum
Definition: plot.C:31
def PandAna.var.analysis_vars.kEMEnergy (   tables)

Definition at line 56 of file analysis_vars.py.

References PandAna.var.analysis_vars.kEMEnergy, PandAna.var.analysis_vars.kLongestProng, PandAna.var.analysis_vars.kNueCalibrationCorr(), PandAna.var.analysis_vars.kRHC, and sum.

56 def kEMEnergy(tables):
57  lng_png = kLongestProng(tables)
58  isRHC = kRHC(tables)
59 
60  shwlid_df = tables['rec.vtx.elastic.fuzzyk.png.shwlid']
61  prim_png = shwlid_df['calE'][(shwlid_df['rec.vtx.elastic.fuzzyk.png_idx']==0)]
62 
63 
64  png_df = tables['rec.vtx.elastic.fuzzyk.png']
65  cvn_png_df = tables['rec.vtx.elastic.fuzzyk.png.cvnpart']
66 
67  cvn_em_pid_df = cvn_png_df[['photonid', \
68  'pizeroid', \
69  'electronid']].sum(axis=1)
70  cvn_had_pid_df = cvn_png_df[['pionid', \
71  'protonid', \
72  'neutronid',\
73  'otherid', \
74  'muonid']].sum(axis=1)
75 
76  cvn_em_calE = shwlid_df['calE'].where( \
77  (cvn_em_pid_df > 0) & \
78  (cvn_em_pid_df >= cvn_had_pid_df), \
79  0).groupby(level=KL).agg(np.sum)
80 
81  if isRHC.agg(np.all):
82  cvn_em_calE[cvn_em_calE == 0] = prim_png[cvn_em_calE == 0]
83  else:
84  cvn_em_calE[lng_png >= 500] = prim_png[lng_png >= 500]
85 
86  hdr_df = tables['rec.hdr']
87  det = hdr_df['det']
88  ismc = tables['rec.hdr']['ismc']
89  runs = hdr_df.assign(run=hdr_df.index.get_level_values('run'))['run']
90  df = pd.concat([runs, det, ismc], axis=1).dropna()
91  scale = df.apply(lambda x: kNueCalibrationCorr(x['det'], x['ismc'], x['run']), axis=1, result_type='reduce')
92 
93  cvn_em_calE *= scale
94  cvn_em_calE.name = 'calE'
95 
96  return cvn_em_calE
def kNueCalibrationCorr(det, ismc, run)
Double_t sum
Definition: plot.C:31
def PandAna.var.analysis_vars.kHadEnergy (   tables)

Definition at line 99 of file analysis_vars.py.

References PandAna.var.analysis_vars.kEMEnergy, PandAna.var.analysis_vars.kHadEnergy, and PandAna.var.analysis_vars.kNueCalibrationCorr().

99 def kHadEnergy(tables):
100  EMEnergy = kEMEnergy(tables)
101 
102  hdr_df = tables['rec.hdr']
103  det = hdr_df['det']
104  ismc = tables['rec.hdr']['ismc']
105  runs = hdr_df.assign(run=hdr_df.index.get_level_values('run'))['run']
106  df = pd.concat([runs, det, ismc], axis=1).dropna()
107  scale = df.apply(lambda x: kNueCalibrationCorr(x['det'], x['ismc'], x['run']), axis=1, result_type='reduce')
108 
109  calE = tables['rec.slc']['calE']*scale
110  calE.name = 'calE'
111 
112  HadEnergy = calE - EMEnergy
113  return HadEnergy.where(HadEnergy > 0, 0)
def kNueCalibrationCorr(det, ismc, run)
def PandAna.var.analysis_vars.kLongestProng (   tables)

Nue Vars.

Definition at line 24 of file analysis_vars.py.

References PandAna.var.analysis_vars.kLongestProng.

24 def kLongestProng(tables):
25  df = tables['rec.vtx.elastic.fuzzyk.png']['len']
26  return df.groupby(level=KL).agg(np.max)
def PandAna.var.analysis_vars.kMaxY (   tables)

Definition at line 40 of file analysis_vars.py.

References PandAna.var.analysis_vars.kMaxY, and cet::sqlite.max().

40 def kMaxY(tables):
41  df = tables['rec.vtx.elastic.fuzzyk.png.shwlid']
42  df = df[['start.y','stop.y']].max(axis=1)
43  return df.groupby(level=KL).agg(np.max)
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
def PandAna.var.analysis_vars.kNueCalibrationCorr (   det,
  ismc,
  run 
)

Definition at line 50 of file analysis_vars.py.

Referenced by PandAna.var.analysis_vars.kEMEnergy(), and PandAna.var.analysis_vars.kHadEnergy().

50 def kNueCalibrationCorr(det, ismc, run):
51  if (det != detector.kFD): return 1.
52  if not ismc: return 0.9949
53  if run < 20753: return 0.9949/0.9844
54  return 1.
55 
def kNueCalibrationCorr(det, ismc, run)
def PandAna.var.analysis_vars.kNueEnergy (   tables)

Definition at line 116 of file analysis_vars.py.

References PandAna.var.analysis_vars.kEMEnergy, PandAna.var.analysis_vars.kHadEnergy, PandAna.var.analysis_vars.kNueEnergy, and PandAna.var.analysis_vars.kRHC.

116 def kNueEnergy(tables):
117  EMEnergy = kEMEnergy(tables)
118  HadEnergy = kHadEnergy(tables)
119  isRHC = kRHC(tables)
120 
121  p0 = 0.0
122  p1 = 1.00756
123  p2 = 1.07093
124  p3 = 0.0
125  p4 = 1.28608e-02
126  p5 = 2.27129e-01
127  norm = 0.0501206
128  if isRHC.agg(np.all):
129  p0 = 0.0
130  p1 = 0.980479
131  p2 = 1.45170
132  p3 = 0.0
133  p4 = -5.82609e-03
134  p5 = -2.27599e-01
135  norm = 0.001766
136 
137  NueEnergy = 1./(1+norm)*(HadEnergy*HadEnergy*p5 + \
138  EMEnergy*EMEnergy*p4 + \
139  EMEnergy*HadEnergy*p3 + \
140  HadEnergy*p2 + \
141  EMEnergy*p1 + p0)
142  return NueEnergy.where((HadEnergy >= 0) & (EMEnergy >= 0), -5.)
def PandAna.var.analysis_vars.kNumuHadE (   tables)

Definition at line 203 of file analysis_vars.py.

References PandAna.utils.misc.GetPeriod(), PandAna.var.numuE_utils.GetSpline(), PandAna.var.analysis_vars.kDetID, PandAna.var.analysis_vars.kNumuHadE, and PandAna.var.analysis_vars.kRHC.

203 def kNumuHadE(tables):
204  det = kDetID(tables)
205  isRHC = kRHC(tables)
206 
207  hdr_df = tables['rec.hdr']
208  runs = hdr_df.assign(run=hdr_df.index.get_level_values('run'))['run']
209 
210  hadvisE = tables['rec.energy.numu']['hadtrkE'] + tables['rec.energy.numu']['hadcalE']
211  hadvisE.name = 'hadvisE'
212  ntracks = (tables['rec.trk.kalman']['ntracks'] != 0)
213 
214  if (det == detector.kFD).agg(np.all) and not det.empty:
215  ismc = tables['rec.hdr']['ismc']
216  if not ismc.agg(np.all) and not ismc.empty:
217  periods = runs.apply(lambda x: GetPeriod(x, det))
218  hadvisE[periods > 2] = 0.9949*hadvisE[periods > 2]
219  hadvisE[periods <= 2] = 0.9844*hadvisE[periods <= 2]
220 
221  df = pd.concat([runs, det, isRHC, hadvisE], axis=1)
222  hadE = df.apply(lambda x: \
223  GetSpline(x['run'], x['det'], x['isRHC'], "had")(x['hadvisE']), axis = 1)
224  return hadE.where(ntracks, -5.)
def GetSpline(run, det, isRHC, comp)
Definition: numuE_utils.py:130
def GetPeriod(run, det)
Definition: misc.py:17
def PandAna.var.analysis_vars.kNumuMuE (   tables)

Definition at line 168 of file analysis_vars.py.

References PandAna.var.numuE_utils.GetSpline(), PandAna.var.analysis_vars.kDetID, PandAna.var.analysis_vars.kNumuMuE, and PandAna.var.analysis_vars.kRHC.

168 def kNumuMuE(tables):
169  det = kDetID(tables)
170  isRHC = kRHC(tables)
171 
172  hdr_df = tables['rec.hdr']
173  runs = hdr_df.assign(run=hdr_df.index.get_level_values('run'))['run']
174  ntracks = (tables['rec.trk.kalman']['ntracks'] != 0)
175 
176  if (det == detector.kFD).agg(np.all) and not det.empty:
177  ismc = tables['rec.hdr']['ismc']
178 
179  trks = tables['rec.trk.kalman.tracks']
180  trklen = trks['len'][(trks['rec.trk.kalman.tracks_idx'] == 0)]/100
181  if not ismc.agg(np.all) and not ismc.empty:
182  trklen = trklen*0.9957
183 
184  df = pd.concat([runs, det, isRHC, trklen], axis=1).dropna()
185  muE = df.apply(lambda x: \
186  GetSpline(x[0], x[1], x[2], "muon")(x[3]), axis = 1)
187  return muE.where(ntracks, -5.)
188 
189  else:
190  trklenact = tables['rec.energy.numu']['ndtrklenact']/100.
191  trklencat = tables['rec.energy.numu']['ndtrklencat']/100.
192  trkcalactE = tables['rec.energy.numu']['ndtrkcalactE']
193  trkcaltranE = tables['rec.energy.numu']['ndtrkcaltranE']
194 
195  df = pd.concat([runs, det, isRHC, trklenact, trklencat], axis=1)
196  muE = df.apply(lambda x: \
197  GetSpline(x['run'], x['det'], x['isRHC'], "act")(x['ndtrklenact']) + \
198  GetSpline(x['run'], x['det'], x['isRHC'], "cat")(x['ndtrklencat']), axis = 1)
199  muE[(trkcalactE == 0.) & (trkcaltranE == 0.)] = -5.
200  return muE.where(ntracks, -5.)
def GetSpline(run, det, isRHC, comp)
Definition: numuE_utils.py:130
def PandAna.var.analysis_vars.kNusEnergy (   tables)

Definition at line 243 of file analysis_vars.py.

References PandAna.var.analysis_vars.kCaloE, PandAna.var.analysis_vars.kDetID, PandAna.var.analysis_vars.kNusEnergy, PandAna.var.analysis_vars.kRHC, and PandAna.var.analysis_vars.NusScale().

243 def kNusEnergy(tables):
244  det = kDetID(tables)
245  isRHC = kRHC(tables)
246  cale = kCaloE(tables)
247  df = pd.concat([det, isRHC, cale], axis=1)
248  return df.apply(lambda x: \
249  NusScale(x['isRHC'], x['det'])*x['calE'], axis = 1)
def NusScale(isRHC, det)
Nus Vars.
def PandAna.var.analysis_vars.NusScale (   isRHC,
  det 
)

Nus Vars.

Definition at line 236 of file analysis_vars.py.

Referenced by PandAna.var.analysis_vars.kNusEnergy().

236 def NusScale(isRHC, det):
237  if (isRHC and det == detector.kFD): return 1.18
238  if (isRHC and det == detector.kND): return 1.15
239  if (not isRHC and det == detector.kFD): return 1.2
240  if (not isRHC and det == detector.kND): return 1.11
241  else: return -5.
242 
def NusScale(isRHC, det)
Nus Vars.

Variable Documentation

PandAna.var.analysis_vars.kCaloE = Var(lambda tables: tables['rec.slc']['calE'])

Definition at line 48 of file analysis_vars.py.

Referenced by PandAna.var.analysis_vars.kNusEnergy().

PandAna.var.analysis_vars.kCCE = kNumuE

Definition at line 228 of file analysis_vars.py.

PandAna.var.analysis_vars.kClosestSlcMinDist = Var(lambda tables: tables['rec.slc']['closestslicemindist'])

Definition at line 253 of file analysis_vars.py.

PandAna.var.analysis_vars.kClosestSlcMinTop = Var(lambda tables: tables['rec.slc']['closestsliceminfromtop'])

Definition at line 254 of file analysis_vars.py.

PandAna.var.analysis_vars.kClosestSlcTime = Var(lambda tables: tables['rec.slc']['closestslicetime'])

Definition at line 252 of file analysis_vars.py.

PandAna.var.analysis_vars.kCosNumi = Var(kCosNumi)

Definition at line 166 of file analysis_vars.py.

Referenced by PandAna.var.analysis_vars.kCosNumi().

PandAna.var.analysis_vars.kCVNe = Var(lambda tables: tables['rec.sel.cvn2017']['nueid'])

Definition at line 9 of file analysis_vars.py.

PandAna.var.analysis_vars.kCVNm = Var(lambda tables: tables['rec.sel.cvn2017']['numuid'])

Definition at line 10 of file analysis_vars.py.

PandAna.var.analysis_vars.kCVNnc = Var(lambda tables: tables['rec.sel.cvn2017']['ncid'])

Definition at line 11 of file analysis_vars.py.

PandAna.var.analysis_vars.kDetID = Var(lambda tables: tables['rec.hdr']['det'])
PandAna.var.analysis_vars.kDistAllBack = Var(lambda tables: tables['rec.sel.nuecosrej']['distallpngback'])

Definition at line 33 of file analysis_vars.py.

PandAna.var.analysis_vars.kDistAllBottom = Var(lambda tables: tables['rec.sel.nuecosrej']['distallpngbottom'])

Definition at line 30 of file analysis_vars.py.

PandAna.var.analysis_vars.kDistAllEast = Var(lambda tables: tables['rec.sel.nuecosrej']['distallpngeast'])

Definition at line 32 of file analysis_vars.py.

PandAna.var.analysis_vars.kDistAllFront = Var(lambda tables: tables['rec.sel.nuecosrej']['distallpngfront'])

Definition at line 34 of file analysis_vars.py.

PandAna.var.analysis_vars.kDistAllTop = Var(lambda tables: tables['rec.sel.nuecosrej']['distallpngtop'])

Definition at line 29 of file analysis_vars.py.

PandAna.var.analysis_vars.kDistAllWest = Var(lambda tables: tables['rec.sel.nuecosrej']['distallpngwest'])

Definition at line 31 of file analysis_vars.py.

PandAna.var.analysis_vars.kEMEnergy = Var(kEMEnergy)
PandAna.var.analysis_vars.kHadEnergy = Var(kHadEnergy)
PandAna.var.analysis_vars.kHitsPerPlane = Var(lambda tables: tables['rec.sel.nuecosrej']['hitsperplane'])

Definition at line 36 of file analysis_vars.py.

PandAna.var.analysis_vars.kLongestProng = Var(kLongestProng)
PandAna.var.analysis_vars.kMaxY = Var(kMaxY)

Definition at line 44 of file analysis_vars.py.

Referenced by PandAna.var.analysis_vars.kMaxY().

PandAna.var.analysis_vars.kNHit = Var(lambda tables: tables['rec.slc']['nhit'])

Definition at line 13 of file analysis_vars.py.

PandAna.var.analysis_vars.kNueEnergy = Var(kNueEnergy)
PandAna.var.analysis_vars.kNumuE = kNumuMuE+kNumuHadE

Definition at line 227 of file analysis_vars.py.

PandAna.var.analysis_vars.kNumuHadE = Var(kNumuHadE)

Definition at line 225 of file analysis_vars.py.

Referenced by PandAna.var.analysis_vars.kNumuHadE().

PandAna.var.analysis_vars.kNumuMuE = Var(kNumuMuE)

Definition at line 201 of file analysis_vars.py.

Referenced by PandAna.var.analysis_vars.kNumuMuE().

PandAna.var.analysis_vars.kNusEnergy = Var(kNusEnergy)

Definition at line 250 of file analysis_vars.py.

Referenced by PandAna.var.analysis_vars.kNusEnergy().

PandAna.var.analysis_vars.kPtP = Var(lambda tables: tables['rec.sel.nuecosrej']['partptp'])

Definition at line 38 of file analysis_vars.py.

PandAna.var.analysis_vars.kRHC = Var(lambda tables: tables['rec.spill']['isRHC'])
PandAna.var.analysis_vars.kSparsenessAsymm = Var(lambda tables: tables['rec.sel.nuecosrej']['sparsenessasymm'])

Definition at line 46 of file analysis_vars.py.