Functions | Variables
caf_tools Namespace Reference

Functions

def numuFACuts (chain, counters=False)
 FA nu mu analysis cuts (ND only) More...
 
def standardSpillCut (spill)
 spill cuts ported from: https://cdcvs.fnal.gov/redmine/projects/novaart/repository/entry/tags/S15-07-13/CAFAna/Cuts/SpillCuts.h#L120 More...
 
def standardDQCut (spill)
 spill DQ cut ported from: https://cdcvs.fnal.gov/redmine/projects/novaart/repository/entry/tags/S15-07-13/CAFAna/Cuts/SpillCuts.h#L83 More...
 
def tightBeamQualityCut (spill)
 spill beam quality cut ported from: https://cdcvs.fnal.gov/redmine/projects/novaart/repository/entry/tags/S15-07-13/CAFAna/Cuts/SpillCuts.h#L51 More...
 
def dumpSpill (spill)
 print out the spill More...
 
def dumpTruth (chain)
 print the mc truth branches More...
 
def dumpTruthNeutrino (i, nu)
 print an SRNeutrino More...
 
def dumpTruthParticle (i, particle, prefix="", suffix=tcolours["ENDC"])
 print an SRTrueParticle More...
 
def DetermineNeutrinoType (chain, verbose=False)
 return the neutrino type as a string More...
 
def DetermineTruthEventType (chain, verbose=False)
 return the truth event types as string More...
 
def GetBins (axis)
 get the binning of an axis More...
 

Variables

list fa_nu_mu_vars
 FA nu mu analysis cuts variables (ND only) More...
 
dictionary tcolours = {}
 Define colours for terminal printing. More...
 
list interaction_types_enum
 
dictionary interaction_types_dict = {}
 

Function Documentation

def caf_tools.DetermineNeutrinoType (   chain,
  verbose = False 
)

return the neutrino type as a string

Definition at line 311 of file caf_tools.py.

References stan::math.fabs().

311 def DetermineNeutrinoType(chain,verbose=False):
312  assert fabs(chain.rec.mc.nu[0].pdg) in [12,14,16],\
313  "caft : Neutrino type not configured: pdg: %i, pdgorig: %i"%\
314  (chain.rec.mc.nu[0].pdg, chain.rec.mc.nu[0].pdgorig)
315  if chain.rec.mc.nu[0].pdg == 12: prefix = "E_"
316  elif chain.rec.mc.nu[0].pdg == 14: prefix = "Mu_"
317  elif chain.rec.mc.nu[0].pdg == 16: prefix = "Tau_"
318  elif chain.rec.mc.nu[0].pdg == -12: prefix = "AntiE_"
319  elif chain.rec.mc.nu[0].pdg == -14: prefix = "AntiMu_"
320  elif chain.rec.mc.nu[0].pdg == -16: prefix = "AntiTau_"
321 
322  if chain.rec.mc.nu[0].pdg != chain.rec.mc.nu[0].pdgorig: suffix = "oscillated_"
323  else: suffix = ""
324 
325  return prefix+suffix
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
def DetermineNeutrinoType(chain, verbose=False)
return the neutrino type as a string
Definition: caf_tools.py:311
def caf_tools.DetermineTruthEventType (   chain,
  verbose = False 
)

return the truth event types as string

Definition at line 328 of file caf_tools.py.

References dumpTruth().

328 def DetermineTruthEventType(chain, verbose=False):
329  if len(chain.rec.mc.nu) != 1:
330  print "caft : Not one neutrino found: %i"%len(chain.rec.mc.nu)
331  dumpTruth(chain)
332  return [""]
333  nu = chain.rec.mc.nu[0]
334  if verbose: print "caft : DetermineTruthEventType"
335  return_types = [""]
336  # neutrino = DetermineNeutrinoType(chain,verbose=verbose)
337  # if neutrino in ["E_","AntiE_","Tau_","AntiTau_"]: neutrino = "Other_"
338  if nu.mode == 0: interaction = "-QE"
339  elif nu.mode == 1: interaction = "-Res"
340  elif nu.mode == 2: interaction = "-DIS"
341  elif nu.mode == 3: interaction = "-Coh"
342  elif nu.mode == 10: interaction = "-MEC"
343  else:
344  dumpTruth(chain)
345  print "caft : Unknown mode: %i"%nu.mode
346  # assert False
347  # if nu.iscc: current = "CC_"
348  # else: current = "NC_"
349 
350  # in_x = (-191 < nu.vtx.X()) and (nu.vtx.X() < 192)
351  # in_z = ( 0 < nu.vtx.Z()) and (nu.vtx.Z() < 1587)
352  # in_mc = in_z and (1270 < nu.vtx.Z())
353  # if in_mc: in_y = (-187 < nu.vtx.Y()) and (nu.vtx.Y() < 67)
354  # else: in_y = (-187 < nu.vtx.Y()) and (nu.vtx.Y() < 194)
355 
356  # if (in_x and in_y and in_z): return_types.append("Detector_")
357  # else: return_types.append("Rock_")
358 
359  # return_types.append(neutrino)
360  # return_types.append(current)
361  return_types.append(interaction)
362  # return_types.append(neutrino+interaction)
363  # return_types.append(current+interaction)
364  # return_types.append(neutrino+current+interaction)
365  return return_types
def dumpTruth(chain)
print the mc truth branches
Definition: caf_tools.py:268
def DetermineTruthEventType(chain, verbose=False)
return the truth event types as string
Definition: caf_tools.py:328
def caf_tools.dumpSpill (   spill)

print out the spill

Definition at line 174 of file caf_tools.py.

174 def dumpSpill(spill):
175  print "ctool: --- Spill"
176  print "ctool: det: ",spill.det
177  print "ctool: ismc: ",spill.ismc
178  print "ctool: trigger: ",spill.trigger
179  print "ctool: fracdcm3hits: ",spill.fracdcm3hits
180  print "ctool: nmissingdcms: ",spill.nmissingdcms
181  print "ctool: nmissingdcmslg: ",spill.nmissingdcmslg
182  print "ctool: dcmedgematchfrac: ",spill.dcmedgematchfrac
183  print "ctool: deltaspilltimensec: ",spill.deltaspilltimensec
184  print "ctool: spillpot: ",spill.spillpot
185  print "ctool: hornI: ",spill.hornI
186  print "ctool: posx: ",spill.posx[0]
187  print "ctool: posy: ",spill.posy[0]
188  print "ctool: widthx: ",spill.widthx
189  print "ctool: widthy: ",spill.widthy
190 
def dumpSpill(spill)
print out the spill
Definition: caf_tools.py:174
def caf_tools.dumpTruth (   chain)

print the mc truth branches

Definition at line 268 of file caf_tools.py.

References dumpTruthNeutrino().

Referenced by DetermineTruthEventType().

268 def dumpTruth(chain):
269  print "caft : Truth information"
270  print "caft : %i neutrinos"%len(chain.rec.mc.allnus)
271  print "caft : %i matched neutrinos"%len(chain.rec.mc.nu)
272  print "caft : faveidxeff: %i"%chain.rec.mc.faveidxeff
273  for i, neutrino in enumerate(chain.rec.mc.nu):
274  dumpTruthNeutrino(i, neutrino)
def dumpTruth(chain)
print the mc truth branches
Definition: caf_tools.py:268
def dumpTruthNeutrino(i, nu)
print an SRNeutrino
Definition: caf_tools.py:277
def caf_tools.dumpTruthNeutrino (   i,
  nu 
)

print an SRNeutrino

Definition at line 277 of file caf_tools.py.

References dumpTruthParticle().

Referenced by dumpTruth().

277 def dumpTruthNeutrino(i, nu):
278  print "caft : [%3i] - pdg: %i, pdgorig: %i, woscdumb: %f"%\
279  (i, nu.pdg, nu.pdgorig, nu.woscdumb)
280  print "caft : hitnuc: %i, mode: %i, iscc: %i, inttype: %i"%\
281  (nu.hitnuc, nu.mode, nu.iscc, nu.inttype)
282  interaction_type = interaction_types_dict[nu.inttype]
283  print "caft : parsed type: %s"%interaction_type
284  print "caft : q2: %f, x: %f, y: %f, W2: %f"%\
285  (nu.q2, nu.x, nu.y, nu.W2)
286  #print "caft : E: %f, visE: %f, insubevtvisE: %f, time: %f"%\
287  # (nu.E, nu.visE, nu.insubevtvisE, nu.time)
288  print "caft : E: %f, visE: %f, time: %f"%\
289  (nu.E, nu.visE, nu.time)
290  print "caft : px: %f, py: %f, pz: %f, E: %f"%\
291  (nu.p.X(), nu.p.Y(), nu.p.Z(), nu.p.E())
292  print "caft : vtx, x: %f, y: %f, z: %f"%\
293  (nu.vtx.X(), nu.vtx.Y(), nu.vtx.Z())
294  print "caft : %i primary daughters"%(len(nu.prim))
295 
296  for i, truth in enumerate(nu.prim):
297  dumpTruthParticle(i, truth)
def dumpTruthParticle(i, particle, prefix="", suffix=tcolours["ENDC"])
print an SRTrueParticle
Definition: caf_tools.py:300
def dumpTruthNeutrino(i, nu)
print an SRNeutrino
Definition: caf_tools.py:277
def caf_tools.dumpTruthParticle (   i,
  particle,
  prefix = "",
  suffix = tcolours["ENDC"] 
)

print an SRTrueParticle

Definition at line 300 of file caf_tools.py.

Referenced by dumpTruthNeutrino().

300 def dumpTruthParticle(i, particle, prefix="", suffix=tcolours["ENDC"]):
301  if particle.pdg in [-13,13]: prefix = tcolours["OKBLUE"]
302  if particle.pdg in pdg_codes.pdg_codes:
303  pdg = "%s"%(pdg_codes.d_pdg_names[particle.pdg])
304  else:
305  pdg = "%10i"%particle.pdg
306  print "%scaft : [%3i] - %15s, visE: %f, px: %+.1f, py: %+.1f, pz: %+.1f, E: %.1f %s"%\
307  (prefix,i, pdg, particle.visE,
308  particle.p.X(), particle.p.Y(), particle.p.Z(), particle.p.E(),suffix)
def dumpTruthParticle(i, particle, prefix="", suffix=tcolours["ENDC"])
print an SRTrueParticle
Definition: caf_tools.py:300
def caf_tools.GetBins (   axis)

get the binning of an axis

Definition at line 368 of file caf_tools.py.

References PandAna.Demos.demo1.range.

368 def GetBins(axis):
369  from array import array
370  this_bins = []
371  for i in range(1,axis.GetNbins()+1):
372  lower_edge = axis.GetBinLowEdge(i)
373  upper_edge = lower_edge+axis.GetBinWidth(i)
374  if i == 1:
375  this_bins.append(lower_edge)
376  this_bins.append(upper_edge)
377  return_bins = array("f",this_bins)
378  #print return_bins
379  #assert False
380  return return_bins
def GetBins(axis)
get the binning of an axis
Definition: caf_tools.py:368
def caf_tools.numuFACuts (   chain,
  counters = False 
)

FA nu mu analysis cuts (ND only)

Definition at line 45 of file caf_tools.py.

References standardSpillCut().

45 def numuFACuts(chain, counters=False):
46  if chain.rec.hdr.det == 1: fardet = False
47  else: fardet = True
48  # spill cuts
49  spill = standardSpillCut(chain.rec.spill)
50  if (not spill): return False, counters
51  if counters: counters["pass spill"] += 1
52 
53  # preselection cuts
54  preselection = (chain.rec.slc.nhit > 20) and (chain.rec.sel.remid.pid > 0)
55  if (not preselection): return False, counters
56  if counters: counters["pass preselection"] += 1
57 
58  # slice quality cuts
59  quality = (chain.rec.energy.numusimp.trknonqeE > 0) and \
60  (chain.rec.sel.remid.pid > 0 ) and \
61  (chain.rec.slc.nhit > 20 ) and \
62  (chain.rec.slc.ncontplanes > 4) and \
63  (chain.rec.trk.ncosmic > 0)
64  if (not quality): return False, counters
65  if counters: counters["pass quality"] += 1
66 
67  # upper energy cut
68  if (chain.rec.energy.numusimp.trkccE > 5): return False, counters
69  if counters: counters["pass energy"] += 1
70 
71  # containment cut
72  if fardet:
73  containment = (chain.rec.slc.ncellsfromedge > 1 ) and \
74  (chain.rec.sel.contain.nplanestofront > 1) and \
75  (chain.rec.sel.contain.nplanestoback > 1 ) and \
76  (chain.rec.sel.contain.kalfwdcell > 10 ) and \
77  (chain.rec.sel.contain.kalbakcell > 10 ) and \
78  (chain.rec.sel.contain.cosfwdcell > 0 ) and \
79  (chain.rec.sel.contain.cosbakcell > 0 )
80  cosrejloose = (chain.rec.sel.cosrej.numucontpid > 0.5)
81  else:
82  containment = (chain.rec.trk.nkalman > chain.rec.sel.remid.bestidx) and \
83  (chain.rec.slc.ncellsfromedge > 1 ) and \
84  (chain.rec.slc.firstplane > 1 ) and \
85  (chain.rec.slc.lastplane < 212 ) and \
86  (chain.rec.trk.kalman[chain.rec.sel.remid.bestidx].start.Z() < 1150) and \
87  ( \
88  (chain.rec.trk.kalman[chain.rec.sel.remid.bestidx].stop.Z() < 1275) or \
89  (chain.rec.sel.contain.kalyposattrans < 55 ) \
90  ) and \
91  ( (chain.rec.energy.numusimp.ndhadcalcatE + chain.rec.energy.numusimp.ndhadcaltranE) < 0.03 ) and \
92  (chain.rec.sel.contain.kalfwdcellnd > 4) and \
93  (chain.rec.sel.contain.kalbakcellnd > 8)
94  cosrejloose = True
95 
96  if (not containment): return False, counters
97  if counters: counters["pass containment"] += 1
98 
99  if (not cosrejloose): return False, counters
100  if counters: counters["pass loose cosmic rejection"] += 1
101 
102  if fardet:
103  cosrej = (chain.rec.sel.cosrej.anglekal > 0.5) and \
104  (chain.rec.sel.cosrej.numucontpid > 0.535) and \
105  (chain.rec.slc.nhit < 400)
106  else:
107  cosrej = True
108  if (not cosrej): return False, counters
109  if counters: counters["pass cosmic rejection"] += 1
110 
111  # REMID (Muon ID) cut
112  is_remid = (chain.rec.sel.remid.pid > 0.75)
113  if (not is_remid): return False, counters
114  if counters: counters["pass remid"] += 1
115 
116  return True, counters
def standardSpillCut(spill)
spill cuts ported from: https://cdcvs.fnal.gov/redmine/projects/novaart/repository/entry/tags/S15-07-...
Definition: caf_tools.py:121
def numuFACuts(chain, counters=False)
FA nu mu analysis cuts (ND only)
Definition: caf_tools.py:45
def caf_tools.standardDQCut (   spill)

spill DQ cut ported from: https://cdcvs.fnal.gov/redmine/projects/novaart/repository/entry/tags/S15-07-13/CAFAna/Cuts/SpillCuts.h#L83

Definition at line 131 of file caf_tools.py.

Referenced by standardSpillCut().

131 def standardDQCut(spill):
132  # dumpSpill(spill)
133  # need detector ID variable, defined here:
134  # http://nusoft.fnal.gov/nova/novasoft/doxygen/html/SRHeader_8h_source.html
135  kNEARDET = 1
136  kFARDET = 2
137 
138  if (spill.det == kNEARDET) and \
139  ( (spill.fracdcm3hits > 0.45) or (spill.nmissingdcms > 0) ):
140  return False
141 
142  if (spill.det == kFARDET) and \
143  (spill.nmissingdcmslg > 0 ):
144  return False
145 
146  if (spill.det == kFARDET) and \
147  (not spill.ismc) and \
148  (spill.dcmedgematchfrac <= 0.2):
149  return False
150 
151  return True
def standardDQCut(spill)
spill DQ cut ported from: https://cdcvs.fnal.gov/redmine/projects/novaart/repository/entry/tags/S15-0...
Definition: caf_tools.py:131
def caf_tools.standardSpillCut (   spill)

spill cuts ported from: https://cdcvs.fnal.gov/redmine/projects/novaart/repository/entry/tags/S15-07-13/CAFAna/Cuts/SpillCuts.h#L120

Definition at line 121 of file caf_tools.py.

References standardDQCut(), and tightBeamQualityCut().

Referenced by numuFACuts().

121 def standardSpillCut(spill):
122  dq = standardDQCut(spill)
123  if (not dq): return False
124 
125  beam = tightBeamQualityCut(spill)
126  return beam
def standardDQCut(spill)
spill DQ cut ported from: https://cdcvs.fnal.gov/redmine/projects/novaart/repository/entry/tags/S15-0...
Definition: caf_tools.py:131
def standardSpillCut(spill)
spill cuts ported from: https://cdcvs.fnal.gov/redmine/projects/novaart/repository/entry/tags/S15-07-...
Definition: caf_tools.py:121
def tightBeamQualityCut(spill)
spill beam quality cut ported from: https://cdcvs.fnal.gov/redmine/projects/novaart/repository/entry/...
Definition: caf_tools.py:156
def caf_tools.tightBeamQualityCut (   spill)

spill beam quality cut ported from: https://cdcvs.fnal.gov/redmine/projects/novaart/repository/entry/tags/S15-07-13/CAFAna/Cuts/SpillCuts.h#L51

Definition at line 156 of file caf_tools.py.

References abs().

Referenced by standardSpillCut().

157  if (spill.ismc): return True
158  if (spill.trigger == 2): return True
159 
160  if (abs(spill.deltaspilltimensec) > 0.5e9): return False
161  if (spill.spillpot < 2e12): return False
162  if (spill.hornI < -202) or (spill.hornI > -198): return False
163  if (type(spill.posx) == float):
164  if (spill.posx < 0.02) or (spill.posx > 2.00): return False
165  if (spill.posy < 0.02) or (spill.posy > 2.00): return False
166  else:
167  if (spill.posx[0] < 0.02) or (spill.posx[0] > 2.00): return False
168  if (spill.posy[0] < 0.02) or (spill.posy[0] > 2.00): return False
169  if (spill.widthx < 0.57) or (spill.widthx > 1.58): return False
170  if (spill.widthy < 0.57) or (spill.widthy > 1.58): return False
171  return True
void abs(TH1 *hist)
::xsd::cxx::tree::type type
Definition: Database.h:110
def tightBeamQualityCut(spill)
spill beam quality cut ported from: https://cdcvs.fnal.gov/redmine/projects/novaart/repository/entry/...
Definition: caf_tools.py:156

Variable Documentation

list caf_tools.fa_nu_mu_vars

FA nu mu analysis cuts variables (ND only)

Definition at line 3 of file caf_tools.py.

dictionary caf_tools.interaction_types_dict = {}

Definition at line 263 of file caf_tools.py.

list caf_tools.interaction_types_enum

Definition at line 208 of file caf_tools.py.

dictionary caf_tools.tcolours = {}

Define colours for terminal printing.

Definition at line 196 of file caf_tools.py.