Functions | Variables
make_pion_angle Namespace Reference

Functions

def shift_bins (n_bins, shift)
 
def flip_pions (h_in)
 
def flat (h_in)
 
def shift_pions (h_in, i)
 
def gaus_pions (h_in)
 
def check_bins (h_in)
 
def get_variation (h_in, t, j=0)
 

Variables

 parser = ap()
 
 type
 
 str
 
 help
 
 default
 
 int
 
 float
 
 args = parser.parse_args()
 
 f = RT.TFile(args.i, "OPEN")
 
 t = f.Get("pduneana/beamana")
 
list end_p = [0., .4, .6, .8, 1.]
 
list nbins = [ 5, 25, 25, 25, 10]
 
list shifts = [ 2, 12, 12, 12, 5]
 
 fout = RT.TFile(args.o, "RECREATE")
 
list rs = []
 
 h = RT.TH1D("h" + str(i), "", nbins[i-1], -1., 1.)
 
 h2 = get_variation(h, args.t, i-1)
 
 r = h2.Clone()
 

Function Documentation

def make_pion_angle.check_bins (   h_in)

Definition at line 63 of file make_pion_angle.py.

63 def check_bins(h_in):
64  for i in range(1, h_in.GetNbinsX()+1):
65  if h_in.GetBinContent(i) == 0.:
66  print(h_in.GetName(), "empty:", i)
67 
def check_bins(h_in)
def make_pion_angle.flat (   h_in)

Definition at line 38 of file make_pion_angle.py.

38 def flat(h_in):
39  h2 = h_in.Clone()
40  for j in range(1, h2.GetNbinsX()+1):
41  h2.SetBinContent(j, 1.)
42  h2.Scale(1. / h2.Integral())
43  return h2
44 
def make_pion_angle.flip_pions (   h_in)

Definition at line 32 of file make_pion_angle.py.

32 def flip_pions(h_in):
33  h2 = h_in.Clone()
34  for j in range(1, h2.GetNbinsX()+1):
35  h2.SetBinContent(j, h.GetBinContent(h2.GetNbinsX() + 1 - j))
36  return h2
37 
def flip_pions(h_in)
def make_pion_angle.gaus_pions (   h_in)

Definition at line 53 of file make_pion_angle.py.

53 def gaus_pions(h_in):
54  n_bins = h_in.GetNbinsX()
55  width = n_bins/4.
56  mean = n_bins*args.p
57  h2 = h_in.Clone()
58  for i in range(1, n_bins+1):
59  h2.SetBinContent(i, exp(-.5*(((i - mean)/width)**2)))
60  h2.Scale(1. / h2.Integral())
61  return h2
62 
def gaus_pions(h_in)
def make_pion_angle.get_variation (   h_in,
  t,
  j = 0 
)

Definition at line 68 of file make_pion_angle.py.

68 def get_variation(h_in, t, j = 0):
69  if t == 0:
70  return flip_pions(h_in)
71  elif t == 1:
72  return flat(h_in)
73  elif t == 2:
74  return shift_pions(h_in, j)
75  elif t == 3:
76  return gaus_pions(h_in)
77  else:
78  print("error, unkown type", t)
79 
def shift_pions(h_in, i)
def get_variation(h_in, t, j=0)
def gaus_pions(h_in)
def flip_pions(h_in)
def make_pion_angle.shift_bins (   n_bins,
  shift 
)

Definition at line 24 of file make_pion_angle.py.

24 def shift_bins(n_bins, shift):
25  bins = range(1, n_bins+1)
26  new_bins = [i + shift for i in range(1, len(bins)-shift+1)] + [i - len(bins) + shift for i in range(len(bins)-shift+1, len(bins)+1)]
27  print(new_bins)
28  return new_bins
def shift_bins(n_bins, shift)
def make_pion_angle.shift_pions (   h_in,
  i 
)

Definition at line 45 of file make_pion_angle.py.

45 def shift_pions(h_in, i):
46  new_bins = shift_bins(h_in.GetNbinsX(), shifts[i])
47  h2 = h_in.Clone()
48  for j in range(1, h2.GetNbinsX()+1):
49  h2.SetBinContent(j, h.GetBinContent(new_bins[j-1]))
50  h2.Scale(1. / h2.Integral())
51  return h2
52 
def shift_pions(h_in, i)
def shift_bins(n_bins, shift)

Variable Documentation

make_pion_angle.args = parser.parse_args()

Definition at line 10 of file make_pion_angle.py.

make_pion_angle.default

Definition at line 6 of file make_pion_angle.py.

list make_pion_angle.end_p = [0., .4, .6, .8, 1.]

Definition at line 15 of file make_pion_angle.py.

make_pion_angle.f = RT.TFile(args.i, "OPEN")

Definition at line 12 of file make_pion_angle.py.

make_pion_angle.float

Definition at line 9 of file make_pion_angle.py.

make_pion_angle.fout = RT.TFile(args.o, "RECREATE")

Definition at line 20 of file make_pion_angle.py.

make_pion_angle.h = RT.TH1D("h" + str(i), "", nbins[i-1], -1., 1.)

Definition at line 82 of file make_pion_angle.py.

make_pion_angle.h2 = get_variation(h, args.t, i-1)

Definition at line 96 of file make_pion_angle.py.

make_pion_angle.help

Definition at line 6 of file make_pion_angle.py.

make_pion_angle.int

Definition at line 8 of file make_pion_angle.py.

list make_pion_angle.nbins = [ 5, 25, 25, 25, 10]

Definition at line 16 of file make_pion_angle.py.

make_pion_angle.parser = ap()

Definition at line 4 of file make_pion_angle.py.

make_pion_angle.r = h2.Clone()

Definition at line 98 of file make_pion_angle.py.

list make_pion_angle.rs = []

Definition at line 22 of file make_pion_angle.py.

list make_pion_angle.shifts = [ 2, 12, 12, 12, 5]

Definition at line 17 of file make_pion_angle.py.

make_pion_angle.str

Definition at line 6 of file make_pion_angle.py.

make_pion_angle.t = f.Get("pduneana/beamana")

Definition at line 13 of file make_pion_angle.py.

make_pion_angle.type

Definition at line 6 of file make_pion_angle.py.