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'])
 General Vars. More...
 
 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'])
 
 kMeantime = Var(lambda tables: tables['rec.slc']['meantime'])
 
 kCVNe20 = Var(lambda tables: tables['rec.sel.cvnloosepreselptp']['nueid'])
 
 kCVNm20 = Var(lambda tables: tables['rec.sel.cvnloosepreselptp']['numuid'])
 
 kCVNnc20 = Var(lambda tables: tables['rec.sel.cvnloosepreselptp']['ncid'])
 
 kCVNcos20 = Var(lambda tables: tables['rec.sel.cvnloosepreselptp']['cosmicid'])
 
 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 169 of file analysis_vars.py.

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

169 def kCosNumi(tables):
170  df = tables['rec.trk.kalman.tracks']
171  # Primary kalman track only
172  df = df[df['rec.trk.kalman.tracks_idx']==0]
173  KalDir = df[['dir.x','dir.y', 'dir.z']]
174 
175  # Use separate beam dir for each detector
176  KalDirFD = KalDir[kDetID(tables)==detector.kFD]
177  KalDirND = KalDir[kDetID(tables)==detector.kND]
178 
179  CosFD = KalDirFD.mul(BeamDirFD, axis=1).sum(axis=1)
180  CosND = KalDirND.mul(BeamDirND, axis=1).sum(axis=1)
181 
182  return pd.concat([CosFD, CosND])
Double_t sum
Definition: plot.C:31
def PandAna.var.analysis_vars.kEMEnergy (   tables)

Definition at line 73 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.

73 def kEMEnergy(tables):
74  lng_png = kLongestProng(tables)
75  isRHC = kRHC(tables)
76 
77  shwlid_df = tables['rec.vtx.elastic.fuzzyk.png.shwlid']
78  prim_png = shwlid_df['calE'][(shwlid_df['rec.vtx.elastic.fuzzyk.png_idx']==0)]
79 
80 
81  png_df = tables['rec.vtx.elastic.fuzzyk.png']
82  cvn_png_df = tables['rec.vtx.elastic.fuzzyk.png.cvnpart']
83 
84  cvn_em_pid_df = cvn_png_df[['photonid', \
85  'pizeroid', \
86  'electronid']].sum(axis=1)
87  cvn_had_pid_df = cvn_png_df[['pionid', \
88  'protonid', \
89  'neutronid',\
90  'otherid', \
91  'muonid']].sum(axis=1)
92 
93  cvn_em_calE = shwlid_df['calE'].where( \
94  (cvn_em_pid_df > 0) & \
95  (cvn_em_pid_df >= cvn_had_pid_df), \
96  0).groupby(level=KL).agg(np.sum)
97 
98  if isRHC.agg(np.all):
99  cvn_em_calE[cvn_em_calE == 0] = prim_png[cvn_em_calE == 0]
100  else:
101  cvn_em_calE[lng_png >= 500] = prim_png[lng_png >= 500]
102 
103  hdr_df = tables['rec.hdr']
104  det = hdr_df['det']
105  ismc = tables['rec.hdr']['ismc']
106  runs = hdr_df.assign(run=hdr_df.index.get_level_values('run'))['run']
107  df = pd.concat([runs, det, ismc], axis=1).dropna()
108  scale = df.apply(lambda x: kNueCalibrationCorr(x['det'], x['ismc'], x['run']), axis=1, result_type='reduce')
109 
110  cvn_em_calE *= scale
111  cvn_em_calE.name = 'calE'
112 
113  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 116 of file analysis_vars.py.

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

116 def kHadEnergy(tables):
117  EMEnergy = kEMEnergy(tables)
118 
119  hdr_df = tables['rec.hdr']
120  det = hdr_df['det']
121  ismc = tables['rec.hdr']['ismc']
122  runs = hdr_df.assign(run=hdr_df.index.get_level_values('run'))['run']
123  df = pd.concat([runs, det, ismc], axis=1).dropna()
124  scale = df.apply(lambda x: kNueCalibrationCorr(x['det'], x['ismc'], x['run']), axis=1, result_type='reduce')
125 
126  calE = tables['rec.slc']['calE']*scale
127  calE.name = 'calE'
128 
129  HadEnergy = calE - EMEnergy
130  return HadEnergy.where(HadEnergy > 0, 0)
def kNueCalibrationCorr(det, ismc, run)
def PandAna.var.analysis_vars.kLongestProng (   tables)

Nue Vars.

Definition at line 41 of file analysis_vars.py.

References PandAna.var.analysis_vars.kLongestProng.

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

Definition at line 57 of file analysis_vars.py.

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

57 def kMaxY(tables):
58  df = tables['rec.vtx.elastic.fuzzyk.png.shwlid']
59  df = df[['start.y','stop.y']].max(axis=1)
60  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 67 of file analysis_vars.py.

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

67 def kNueCalibrationCorr(det, ismc, run):
68  if (det != detector.kFD): return 1.
69  if not ismc: return 0.9949
70  if run < 20753: return 0.9949/0.9844
71  return 1.
72 
def kNueCalibrationCorr(det, ismc, run)
def PandAna.var.analysis_vars.kNueEnergy (   tables)

Definition at line 133 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.

133 def kNueEnergy(tables):
134  EMEnergy = kEMEnergy(tables)
135  HadEnergy = kHadEnergy(tables)
136  isRHC = kRHC(tables)
137 
138  p0 = 0.0
139  p1 = 1.00756
140  p2 = 1.07093
141  p3 = 0.0
142  p4 = 1.28608e-02
143  p5 = 2.27129e-01
144  norm = 0.0501206
145  if isRHC.agg(np.all):
146  p0 = 0.0
147  p1 = 0.980479
148  p2 = 1.45170
149  p3 = 0.0
150  p4 = -5.82609e-03
151  p5 = -2.27599e-01
152  norm = 0.001766
153 
154  NueEnergy = 1./(1+norm)*(HadEnergy*HadEnergy*p5 + \
155  EMEnergy*EMEnergy*p4 + \
156  EMEnergy*HadEnergy*p3 + \
157  HadEnergy*p2 + \
158  EMEnergy*p1 + p0)
159  return NueEnergy.where((HadEnergy >= 0) & (EMEnergy >= 0), -5.)
def PandAna.var.analysis_vars.kNumuHadE (   tables)

Definition at line 220 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.

220 def kNumuHadE(tables):
221  det = kDetID(tables)
222  isRHC = kRHC(tables)
223 
224  hdr_df = tables['rec.hdr']
225  runs = hdr_df.assign(run=hdr_df.index.get_level_values('run'))['run']
226 
227  hadvisE = tables['rec.energy.numu']['hadtrkE'] + tables['rec.energy.numu']['hadcalE']
228  hadvisE.name = 'hadvisE'
229  ntracks = (tables['rec.trk.kalman']['ntracks'] != 0)
230 
231  if (det == detector.kFD).agg(np.all) and not det.empty:
232  ismc = tables['rec.hdr']['ismc']
233  if not ismc.agg(np.all) and not ismc.empty:
234  periods = runs.apply(lambda x: GetPeriod(x, det))
235  hadvisE[periods > 2] = 0.9949*hadvisE[periods > 2]
236  hadvisE[periods <= 2] = 0.9844*hadvisE[periods <= 2]
237 
238  df = pd.concat([runs, det, isRHC, hadvisE], axis=1)
239  hadE = df.apply(lambda x: \
240  GetSpline(x['run'], x['det'], x['isRHC'], "had")(x['hadvisE']), axis = 1)
241  return hadE.where(ntracks, -5.)
def GetSpline(run, det, isRHC, comp)
Definition: numuE_utils.py:128
def GetPeriod(run, det)
Definition: misc.py:17
def PandAna.var.analysis_vars.kNumuMuE (   tables)

Definition at line 185 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.

185 def kNumuMuE(tables):
186  det = kDetID(tables)
187  isRHC = kRHC(tables)
188 
189  hdr_df = tables['rec.hdr']
190  runs = hdr_df.assign(run=hdr_df.index.get_level_values('run'))['run']
191  ntracks = (tables['rec.trk.kalman']['ntracks'] != 0)
192 
193  if (det == detector.kFD).agg(np.all) and not det.empty:
194  ismc = tables['rec.hdr']['ismc']
195 
196  trks = tables['rec.trk.kalman.tracks']
197  trklen = trks['len'][(trks['rec.trk.kalman.tracks_idx'] == 0)]/100
198  if not ismc.agg(np.all) and not ismc.empty:
199  trklen = trklen*0.9957
200 
201  df = pd.concat([runs, det, isRHC, trklen], axis=1).dropna()
202  muE = df.apply(lambda x: \
203  GetSpline(x[0], x[1], x[2], "muon")(x[3]), axis = 1)
204  return muE.where(ntracks, -5.)
205 
206  else:
207  trklenact = tables['rec.energy.numu']['ndtrklenact']/100.
208  trklencat = tables['rec.energy.numu']['ndtrklencat']/100.
209  trkcalactE = tables['rec.energy.numu']['ndtrkcalactE']
210  trkcaltranE = tables['rec.energy.numu']['ndtrkcaltranE']
211 
212  df = pd.concat([runs, det, isRHC, trklenact, trklencat], axis=1)
213  muE = df.apply(lambda x: \
214  GetSpline(x['run'], x['det'], x['isRHC'], "act")(x['ndtrklenact']) + \
215  GetSpline(x['run'], x['det'], x['isRHC'], "cat")(x['ndtrklencat']), axis = 1)
216  muE[(trkcalactE == 0.) & (trkcaltranE == 0.)] = -5.
217  return muE.where(ntracks, -5.)
def GetSpline(run, det, isRHC, comp)
Definition: numuE_utils.py:128
def PandAna.var.analysis_vars.kNusEnergy (   tables)

Definition at line 260 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().

260 def kNusEnergy(tables):
261  det = kDetID(tables)
262  isRHC = kRHC(tables)
263  cale = kCaloE(tables)
264  df = pd.concat([det, isRHC, cale], axis=1)
265  return df.apply(lambda x: \
266  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 253 of file analysis_vars.py.

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

253 def NusScale(isRHC, det):
254  if (isRHC and det == detector.kFD): return 1.18
255  if (isRHC and det == detector.kND): return 1.15
256  if (not isRHC and det == detector.kFD): return 1.2
257  if (not isRHC and det == detector.kND): return 1.11
258  else: return -5.
259 
def NusScale(isRHC, det)
Nus Vars.

Variable Documentation

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

Definition at line 65 of file analysis_vars.py.

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

PandAna.var.analysis_vars.kCCE = kNumuE

Definition at line 245 of file analysis_vars.py.

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

Definition at line 270 of file analysis_vars.py.

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

Definition at line 271 of file analysis_vars.py.

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

Definition at line 269 of file analysis_vars.py.

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

Definition at line 183 of file analysis_vars.py.

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

PandAna.var.analysis_vars.kCVNcos20 = Var(lambda tables: tables['rec.sel.cvnloosepreselptp']['cosmicid'])

Definition at line 31 of file analysis_vars.py.

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

General Vars.

Definition at line 16 of file analysis_vars.py.

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

Definition at line 28 of file analysis_vars.py.

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

Definition at line 17 of file analysis_vars.py.

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

Definition at line 29 of file analysis_vars.py.

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

Definition at line 18 of file analysis_vars.py.

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

Definition at line 30 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 50 of file analysis_vars.py.

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

Definition at line 47 of file analysis_vars.py.

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

Definition at line 49 of file analysis_vars.py.

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

Definition at line 51 of file analysis_vars.py.

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

Definition at line 46 of file analysis_vars.py.

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

Definition at line 48 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 53 of file analysis_vars.py.

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

Definition at line 61 of file analysis_vars.py.

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

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

Definition at line 25 of file analysis_vars.py.

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

Definition at line 20 of file analysis_vars.py.

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

Definition at line 244 of file analysis_vars.py.

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

Definition at line 242 of file analysis_vars.py.

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

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

Definition at line 218 of file analysis_vars.py.

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

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

Definition at line 267 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 55 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 63 of file analysis_vars.py.