All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
helpers Namespace Reference

Functions

def broadcast
 
def broadcast_ak
 
def group
 
def NeutrinoPOT
 
def NGenEvt
 
def NEvt
 
def CosmicPOT
 

Variables

int POT_PER_SPILL = 5
 

Function Documentation

def helpers.broadcast (   var,
  nbroadcast 
)

Definition at line 5 of file helpers.py.

5 
6 def broadcast(var, nbroadcast):
7  return np.repeat(var, nbroadcast)
8 
# Broadcast an awkward array (var) over a sequence (nbroadcast)
def broadcast
Definition: helpers.py:5
def helpers.broadcast_ak (   var,
  nbroadcast 
)

Definition at line 9 of file helpers.py.

9 
10 def broadcast_ak(var, nbroadcast):
11  flat_var = var.flatten()
12  flat_nbroadcast = np.repeat(nbroadcast, var.counts)
13 
14  flat_var_repeat = np.repeat(flat_var, flat_nbroadcast)
15 
16  # TODO: VECTORIZE THIS STEP!
17  reindex = np.hstack([np.add.outer(np.arange(0, var.counts[i]) * nbroadcast[i], np.arange(0, nbroadcast[i])).flatten("F") for i in range(len(nbroadcast))])
18 
19  reindex += np.repeat(np.hstack([[0], np.cumsum(nbroadcast * var.counts)[:-1]]), nbroadcast * var.counts)
20  flat_var_repeat_ordered = flat_var_repeat[reindex]
21  return group(flat_var_repeat_ordered, np.repeat(var.counts, nbroadcast))
22 
# Group a numpy array (var) into an awkward array by groups (ngroup)
def broadcast_ak
Definition: helpers.py:9
def group
Definition: helpers.py:23
def helpers.CosmicPOT (   cosmic,
  nu 
)

Definition at line 40 of file helpers.py.

40 
41 def CosmicPOT(cosmic, nu):
42  neutrino_per_spill = (NGenEvt(nu) * POT_PER_SPILL) / NeutrinoPOT(nu)
43  _, ind = np.unique(nu["hdr.subrun"] + nu["hdr.run"]*100, return_index=True)
44  n_cosmic_evt = NGenEvt(cosmic)
45  return n_cosmic_evt * POT_PER_SPILL / (1. - neutrino_per_spill)
def NeutrinoPOT
Definition: helpers.py:27
def NGenEvt
Definition: helpers.py:31
def CosmicPOT
Definition: helpers.py:40
def helpers.group (   var,
  ngroup 
)

Definition at line 23 of file helpers.py.

23 
24 def group(var, ngroup):
25  return ak.JaggedArray.fromcounts(ngroup, var)
26 
# normalize
def group
Definition: helpers.py:23
def helpers.NeutrinoPOT (   data)

Definition at line 27 of file helpers.py.

27 
28 def NeutrinoPOT(data):
29  _, ind = np.unique(data["hdr.subrun"] + data["hdr.run"]*100, return_index=True)
30  return np.sum(data["hdr.pot"][ind])
def NeutrinoPOT
Definition: helpers.py:27
def helpers.NEvt (   data)

Definition at line 35 of file helpers.py.

35 
36 def NEvt(data):
37  return len(data["hdr.evt"])
38 
def NEvt
Definition: helpers.py:35
def helpers.NGenEvt (   data)

Definition at line 31 of file helpers.py.

31 
32 def NGenEvt(data):
33  _, ind = np.unique(data["hdr.subrun"] + data["hdr.run"]*100, return_index=True)
34  return np.sum(data["hdr.ngenevt"][ind])
def NGenEvt
Definition: helpers.py:31

Variable Documentation

int helpers.POT_PER_SPILL = 5

Definition at line 39 of file helpers.py.