ATLAS Offline Software
Functions
tools.toys Namespace Reference

Functions

def nan_divide (numer, denom)
 
def toy_trigeff (trig_n1, trig_n2, ntoys=10000)
 
def muon_toy_recoeff (matchos, matchss, nomatchos, nomatchss, ntoys=10000)
 
def electron_toy_recoeff (matchos_peak, matchos_tail, matchss_tail, nomatchos_peak, nomatchos_tail, templateos_peak, templateos_tail, templatess_tail, ntoys=1000)
 

Function Documentation

◆ electron_toy_recoeff()

def tools.toys.electron_toy_recoeff (   matchos_peak,
  matchos_tail,
  matchss_tail,
  nomatchos_peak,
  nomatchos_tail,
  templateos_peak,
  templateos_tail,
  templatess_tail,
  ntoys = 1000 
)

Definition at line 46 of file toys.py.

46 def electron_toy_recoeff(matchos_peak, matchos_tail, matchss_tail, nomatchos_peak, nomatchos_tail, templateos_peak, templateos_tail, templatess_tail, ntoys=1000):
47  matchos_peak = np.random.poisson(matchos_peak, ntoys)
48  matchos_tail = np.random.poisson(matchos_tail, ntoys)
49  matchss_tail = np.random.poisson(matchss_tail, ntoys)
50  nomatchos_peak = np.random.poisson(nomatchos_peak, ntoys)
51  nomatchos_tail = np.random.poisson(nomatchos_tail, ntoys)
52 
53  templateos_peak = np.random.poisson(templateos_peak, ntoys)
54  templateos_tail = np.random.poisson(templateos_tail, ntoys)
55  templatess_tail = np.random.poisson(templatess_tail, ntoys)
56 
57  totalos_peak = matchos_peak + nomatchos_peak
58  totalos_tail = matchos_tail + nomatchos_tail
59 
60  n1 = matchos_peak
61  n2 = np.multiply(templateos_peak, nan_divide(matchss_tail, templatess_tail))
62  d1 = totalos_peak
63  d2 = np.multiply(templateos_peak, nan_divide(nomatchos_tail, templateos_tail))
64  iterative_eff = nan_divide((n1 - n2), (d1 - d2))
65 
66  d2 = np.multiply(templateos_peak, nan_divide((totalos_tail - nan_divide(matchos_tail, iterative_eff)), templateos_tail))
67  eff = nan_divide((n1 - n2), (d1 - d2))
68  nonan_eff = eff[~np.isnan(eff)]
69  if nonan_eff.size > 0:
70  out_eff = np.median(nonan_eff)
71  out_err = nonan_eff.std()
72  else:
73  out_eff = 0.0
74  out_err = 0.0
75 
76  return out_eff, out_err, eff

◆ muon_toy_recoeff()

def tools.toys.muon_toy_recoeff (   matchos,
  matchss,
  nomatchos,
  nomatchss,
  ntoys = 10000 
)

Definition at line 26 of file toys.py.

26 def muon_toy_recoeff(matchos, matchss, nomatchos, nomatchss, ntoys=10000):
27  matchos = np.random.poisson(matchos, ntoys)
28  matchss = np.random.poisson(matchss, ntoys)
29  nomatchos = np.random.poisson(nomatchos, ntoys)
30  nomatchss = np.random.poisson(nomatchss, ntoys)
31 
32  numer = matchos - matchss
33  denom = (matchos - matchss) + (nomatchos - nomatchss)
34 
35  eff = nan_divide(numer, denom)
36  nonan_eff = eff[~np.isnan(eff)]
37  if nonan_eff.size > 0:
38  out_eff = np.median(nonan_eff)
39  out_err = nonan_eff.std()
40  else:
41  out_eff = 0.0
42  out_err = 0.0
43 
44  return out_eff, out_err, eff
45 

◆ nan_divide()

def tools.toys.nan_divide (   numer,
  denom 
)

Definition at line 6 of file toys.py.

6 def nan_divide(numer, denom):
7  return np.divide(numer.astype(np.float), denom.astype(np.float), out=np.full(numer.size, np.nan), where=denom!=0)
8 
9 

◆ toy_trigeff()

def tools.toys.toy_trigeff (   trig_n1,
  trig_n2,
  ntoys = 10000 
)

Definition at line 10 of file toys.py.

10 def toy_trigeff(trig_n1, trig_n2, ntoys=10000):
11  trig_n1 = np.random.poisson(trig_n1, ntoys)
12  trig_n2 = np.random.poisson(trig_n2, ntoys)
13 
14  eff = np.divide(1.0, np.divide(nan_divide(trig_n1, trig_n2), 2.0) + np.full(ntoys, 1.0))
15  nonan_eff = eff[~np.isnan(eff)]
16  if nonan_eff.size > 0:
17  out_eff = np.median(nonan_eff)
18  out_err = nonan_eff.std()
19  else:
20  out_eff = 0.0
21  out_err = 0.0
22 
23  return out_eff, out_err, eff, (trig_n1 + trig_n2)
24 
25 
tools.toys.toy_trigeff
def toy_trigeff(trig_n1, trig_n2, ntoys=10000)
Definition: toys.py:10
tools.toys.muon_toy_recoeff
def muon_toy_recoeff(matchos, matchss, nomatchos, nomatchss, ntoys=10000)
Definition: toys.py:26
tools.toys.nan_divide
def nan_divide(numer, denom)
Definition: toys.py:6
tools.toys.electron_toy_recoeff
def electron_toy_recoeff(matchos_peak, matchos_tail, matchss_tail, nomatchos_peak, nomatchos_tail, templateos_peak, templateos_tail, templatess_tail, ntoys=1000)
Definition: toys.py:46