-
Notifications
You must be signed in to change notification settings - Fork 0
/
PEs.py
80 lines (48 loc) · 2.44 KB
/
PEs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import numpy as np
import ingredients as ING
import Likelihoods as LH
class PseudoExperiment():
'This class will contain a single pseudo experiment. Containiing functions generate signal and background events according to histograms provided to them'
def __init__(self):
self.events=[]
self.sigs=[]
self.bgs=[]
self.nstrue=0
self.nbgtrue=0
self.ntot=0
def GenBG(self,ingredient,energy,n_bg,test = ING.H1D.Empty(-2.0,3.0,50),test_ene = ING.H1D.Empty(-2.0,3.0,50),tio=False):
'This function generates background events. The first two arguments provide the angular and energy distribution of background events. The third argument should contain the signal energy distribution to avoid errors in TS calculation'
for i in range(int(n_bg)):
ran = ingredient.GetRandom()
ene = energy.GetRandom()
if tio:
while test.GetContent(ran) == 0.0:
ran = ingredient.GetRandom()
while test_ene.GetContent(ene) == 0.0:
ene = energy.GetRandom()
# print ran
self.events.append([ran,ene])
self.bgs.append(self.ntot+i)
self.nbgtrue+=int(n_bg)
self.ntot+=int(n_bg)
def GenSG(self,ingredient,energy,n_sg,test = ING.H1D.Empty(-2.0,3.0,50),test_ene = ING.H1D.Empty(-2.0,3.0,50),tio=False):
'This function generates signal events. The first two arguments provide the angular and energy distribution of signal events. The third argument should contain the background energy distribution to avoid errors in TS calculation'
for i in range(int(n_sg)):
ran = ingredient.GetRandom()
ene = energy.GetRandom()
if tio:
while test.GetContent(ran) == 0.0:
ran = ingredient.GetRandom()
while test_ene.GetContent(ene) == 0.0:
ene = energy.GetRandom()
# print ene
self.events.append([ran,ene])
self.sigs.append(self.ntot+i)
self.nstrue+=n_sg
self.ntot+=n_sg
def GenEvt(self,event):
'This function adds an event from a given event set. Used fro unblinding'
self.events.append(event)
self.bgs.append(len(self.bgs))
self.nbgtrue += 1
self.ntot += 1