def Getkperphitmiss(self,string): # to be used within the string decay class ''' function used to generate a sensible kperp value based on a hit or miss rejection basis ''' ''' Find the suitable range (min - max) of kperp values based on the given string ''' sigma = Constants.kperpsigma() g_sigma = Constants.gsigma() # this value is for g(x) such that g(x) > f(x). If edited, needs to be recalculated (c.f. finding a suitable.... generation) #g_sigma = Constants.kperpsigma() B = 1/(g_sigma*g_sigma) A = Constants.g_kperpA() M = string.Getstringmass() kperpmin = 0 kperpmax = M/2 # where M is the invariant mass of the string decaying # g_kperp = Aexp(-kperp/(gsigma*gsigma) = Aexp(-Bkperp) #numpy.exp(-M*M/(sigma1*sigma1)) - this factor can be omited as it cancels when creating testvalue (its essentially a constant) G_kperp_max = -(A/B)*numpy.exp(-B*kperpmax) G_kperp_min = -(A/B)*numpy.exp(-B*kperpmin) while True: rand_1 = numpy.random.uniform(0,1) #(kperpmin,kperpmax) rand_2 = numpy.random.uniform(0,1) #(kperpmin,kperpmax) kperp_test = -(1/B)*numpy.log(rand_1*(numpy.exp(-kperpmax*B)-1) + 1) # working inverse function #kperp_test = -(1/B)*numpy.log(rand_1*(1-numpy.exp(kperpmax*B)) - 1) # bfroken inverse function #kperp_test = -(1/B)*numpy.log(rand_1 - 1 +numpy.exp(-kperpmax*B)) # dans inverse function f_kperptest = numpy.exp(-kperp_test*kperp_test/(sigma*sigma)) # system designed such that gx is always greater than fx g_kperptest = A*numpy.exp(-B*kperp_test) testvalue = f_kperptest/g_kperptest if rand_2 <= testvalue: return kperp_test break else: continue
def exp(number): pdgid = PDG_ID.PDG_Type(number) mass = PDG_ID.PDG_Type.mass(pdgid) sigma = Constants.kperpsigma() value = numpy.exp(-1*mass*mass/(sigma*sigma)) return value