コード例 #1
0
ファイル: particleData.py プロジェクト: leinadao/PyShower
	def __init__(self,nameToSet,massToSet = 0.0,widthToSet = 0.0,chargeToSet = 0.0,spinToSet = 0.0):
		"""A function to initiate a PDG entry. Only particles not anti-knownParticles."""
		assert (type(nameToSet) == str)
		assert assertions.all_are_numbers([massToSet,widthToSet,chargeToSet,spinToSet])
		self.__name  = nameToSet
		self.__mass  = assertions.force_float_number(massToSet)
		self.__width = assertions.force_float_number(widthToSet)
		self.__charge = assertions.force_float_number(chargeToSet)
		self.__spin = assertions.force_float_number(spinToSet)
コード例 #2
0
 def __init__(self,
              nameToSet,
              massToSet=0.0,
              widthToSet=0.0,
              chargeToSet=0.0,
              spinToSet=0.0):
     """A function to initiate a PDG entry. Only particles not anti-knownParticles."""
     assert (type(nameToSet) == str)
     assert assertions.all_are_numbers(
         [massToSet, widthToSet, chargeToSet, spinToSet])
     self.__name = nameToSet
     self.__mass = assertions.force_float_number(massToSet)
     self.__width = assertions.force_float_number(widthToSet)
     self.__charge = assertions.force_float_number(chargeToSet)
     self.__spin = assertions.force_float_number(spinToSet)
コード例 #3
0
 def calculate(self, Q):
     """A function for calculating the two-loop strong coupling constant at a given COM energy squared."""
     ##Source: Paper 'Measurements of the strong coupling constant and the QCD colour factors using four-jet..
     ##..observables from hadronic Z decays', p4, equations 2-5.
     ##Unlike the others, these equations are given as a function of Q not Q^2 and so use Mz and alphaS(Mz).
     assert assertions.all_are_numbers([Q])
     __Q = assertions.force_float_number(Q)
     __Nf, __Cf, __twoLoopAlphaSOfMz = Nf(
         __Q * __Q), constants.Cf(), self.__twoLoopAlphaSOfMz
     __Mz = particleData.knownParticles.get_mass_from_code(
         particleData.knownParticles.get_code_from_name('Z-boson'))
     ##Adjust betas to those of this paper:
     __beta0 = beta0(__Nf) / __Cf
     __beta1 = beta1(__Nf) / (2.0 * __Cf * __Cf)
     try:
         assert assertions.safe_division(__Q)
         __ln1 = math.log(__Mz / __Q)
         __wOfQ = 1.0 - (__beta0 * __twoLoopAlphaSOfMz * __Cf * __ln1 /
                         (2.0 * math.pi))
         __denominator4 = __beta0 * 2.0 * math.pi * __wOfQ
         assert assertions.safe_division(__denominator4)
         __term1 = 1.0 - (__beta1 * __twoLoopAlphaSOfMz * __Cf *
                          math.log(__wOfQ) / __denominator4)
         __denominator5 = __wOfQ
         assert assertions.safe_division(__denominator5)
         __result = __twoLoopAlphaSOfMz * __term1 / __denominator5
         return __result
     except:
         ##Breaks down below the cut-off energy as expected.
         print "Error in two-loop at Q =", __Q
         return -1.0
コード例 #4
0
ファイル: runningCouplings.py プロジェクト: leinadao/PyShower
	def calculate(self,QSquared):
		"""A function for calculating the four-loop strong coupling constant at a given COM energy squared."""
		##Using approximate analytic solution.
		##Source: 'Quantum Chromodynamics', Dissertori Group, Lpthe Group, P Salam, p3, equation 9.5.
		assert assertions.all_are_numbers([QSquared])
		__QSquared = assertions.force_float_number(QSquared)
		__Nf, __pi = Nf(__QSquared), math.pi
		__beta0 = beta0(__Nf) / (4.0*__pi)
		__beta1 = beta1(__Nf) / ((4.0*__pi)*(4.0*__pi))
		__beta2 = beta2(__Nf) / ((4.0*__pi)*(4.0*__pi)*(4.0*__pi))
		__beta3 = beta3(__Nf) / ((4.0*__pi)*(4.0*__pi)*(4.0*__pi)*(4.0*__pi))
		try:
			__denominator6 = (self.__fourLoopLambda*self.__fourLoopLambda)
			assert assertions.safe_division(__denominator6)
			__ln = math.log(__QSquared/__denominator6)
			__denominator7 = __beta0*__beta0*__ln
			assert assertions.safe_division(__denominator7)
			__term1 = __beta1*math.log(__ln)/__denominator7
			__denominator8 = __beta0*__beta0*__beta0*__beta0*__ln*__ln
			assert assertions.safe_division(__denominator8)
			__term2 = ((__beta1*__beta1 * ((math.log(__ln)*math.log(__ln)) - math.log(__ln) - 1.0)) + __beta0*__beta2) / __denominator8
			__term3P1 = (math.log(__ln)*math.log(__ln)*math.log(__ln)) - (5.0/2.0)*math.log(__ln)*math.log(__ln) - 2.0*math.log(__ln) + 0.5
			__denominator9 = (__beta0*__beta0*__beta0*__beta0*__beta0*__beta0*__ln*__ln*__ln)
			assert assertions.safe_division(__denominator9)
			__term3 = (__beta1*__beta1*__beta1 * __term3P1) / __denominator9
			__term4 = ((3.0*__beta0*__beta1*__beta2*math.log(__ln)) - (0.5*__beta0*__beta0*__beta3)) / __denominator9
			__denominator10 = __beta0*__ln
			assert assertions.safe_division(__denominator10)
			__result = (1.0 - __term1 + __term2 - (__term3 + __term4)) / __denominator10
			return __result
		except:
			print "Error in four-loop at QSquared =", __QSquared
			return -1.0
コード例 #5
0
ファイル: runningCouplings.py プロジェクト: leinadao/PyShower
	def calculate(self,Q):
		"""A function for calculating the two-loop strong coupling constant at a given COM energy squared."""
		##Source: Paper 'Measurements of the strong coupling constant and the QCD colour factors using four-jet..
		##..observables from hadronic Z decays', p4, equations 2-5.
		##Unlike the others, these equations are given as a function of Q not Q^2 and so use Mz and alphaS(Mz).
		assert assertions.all_are_numbers([Q])
		__Q = assertions.force_float_number(Q)
		__Nf, __Cf, __twoLoopAlphaSOfMz = Nf(__Q*__Q), constants.Cf(), self.__twoLoopAlphaSOfMz
		__Mz = particleData.knownParticles.get_mass_from_code(particleData.knownParticles.get_code_from_name('Z-boson'))
		##Adjust betas to those of this paper:
		__beta0 = beta0(__Nf) / __Cf
		__beta1 = beta1(__Nf) / (2.0*__Cf*__Cf)
		try:
			assert assertions.safe_division(__Q)
			__ln1 = math.log(__Mz/__Q)
			__wOfQ = 1.0 - (__beta0*__twoLoopAlphaSOfMz*__Cf*__ln1 / (2.0* math.pi))
			__denominator4 = __beta0*2.0*math.pi*__wOfQ
			assert assertions.safe_division(__denominator4)
			__term1 = 1.0 - (__beta1*__twoLoopAlphaSOfMz*__Cf*math.log(__wOfQ)/__denominator4)
			__denominator5 = __wOfQ
			assert assertions.safe_division(__denominator5)
			__result = __twoLoopAlphaSOfMz*__term1 / __denominator5
			return __result
		except:
			##Breaks down below the cut-off energy as expected.
			print "Error in two-loop at Q =", __Q
			return -1.0
コード例 #6
0
 def force_float_vector(self):
     """A function to convert all vector integers to floats but leave doubles."""
     for __i2 in range(4):
         assert assertions.all_are_numbers([__i2])
         if (not assertions.check_float(self.__vector[__i2])):
             self.__vector[__i2] = assertions.force_float_number(
                 self.__vector[__i2])
コード例 #7
0
 def __setitem__(self, i6, newValue):
     """A function to assign an entry in a four-vector object."""
     assert assertions.valid_four_vector_index(i6)
     assert assertions.all_are_numbers([newValue])
     __newValue = assertions.force_float_number(newValue)
     self.__vector[i6] = __newValue
     self.__positionsEmpty[i6] = False
     self.update_empty()
コード例 #8
0
ファイル: fourVectors.py プロジェクト: leinadao/PyShower
	def __setitem__(self, i6, newValue):
		"""A function to assign an entry in a four-vector object."""
		assert assertions.valid_four_vector_index(i6)
		assert assertions.all_are_numbers([newValue])
		__newValue = assertions.force_float_number(newValue)
		self.__vector[i6] = __newValue
		self.__positionsEmpty[i6] = False
		self.update_empty()
コード例 #9
0
ファイル: fourVectors.py プロジェクト: leinadao/PyShower
	def __imul__(self,multiplier): ##Used for *=
		"""A function for multiplying a four-vector by a scalar."""
		assert assertions.all_are_numbers([multiplier])
		assert self.__nonzero__()
		__multiplier = assertions.force_float_number(multiplier)
		for __i7 in range(4):
			self[__i7] *= __multiplier
		return self
コード例 #10
0
 def __imul__(self, multiplier):  ##Used for *=
     """A function for multiplying a four-vector by a scalar."""
     assert assertions.all_are_numbers([multiplier])
     assert self.__nonzero__()
     __multiplier = assertions.force_float_number(multiplier)
     for __i7 in range(4):
         self[__i7] *= __multiplier
     return self
コード例 #11
0
 def __idiv__(self, denominator):  ##Used for /=
     """A function for dividing a four-vector by a scalar."""
     assert assertions.all_are_numbers([denominator])
     assert assertions.safe_division(denominator)
     assert self.__nonzero__()
     __denominator = assertions.force_float_number(denominator)
     for __i8 in range(4):
         self[__i8] /= __denominator
     return self
コード例 #12
0
ファイル: fourVectors.py プロジェクト: leinadao/PyShower
	def __idiv__(self,denominator): ##Used for /=
		"""A function for dividing a four-vector by a scalar."""
		assert assertions.all_are_numbers([denominator])
		assert assertions.safe_division(denominator)
		assert self.__nonzero__()
		__denominator = assertions.force_float_number(denominator)
		for __i8 in range(4):
			self[__i8] /= __denominator
		return self
コード例 #13
0
ファイル: fourVectors.py プロジェクト: leinadao/PyShower
	def __div__(self,denominator): ##Used for fVA / denominator.
		"""A function for dividing a four-vector by a scalar."""
		assert assertions.all_are_numbers([denominator])
		assert assertions.safe_division(denominator)
		assert self.__nonzero__()
		__denominator = assertions.force_float_number(denominator)
		__result3 = self.copy()
		__result3 /= __denominator
		return __result3
コード例 #14
0
 def __div__(self, denominator):  ##Used for fVA / denominator.
     """A function for dividing a four-vector by a scalar."""
     assert assertions.all_are_numbers([denominator])
     assert assertions.safe_division(denominator)
     assert self.__nonzero__()
     __denominator = assertions.force_float_number(denominator)
     __result3 = self.copy()
     __result3 /= __denominator
     return __result3
コード例 #15
0
ファイル: runningCouplings.py プロジェクト: leinadao/PyShower
	def calculate(self,QSquared):
		"""A function for calculating the one-loop fine structure constant at a given COM energy squared."""
		##Source: "https://www.ippp.dur.ac.uk/~krauss/Lectures/QuarksLeptons/QCD/AsymptoticFreedom_1.html".
		assert assertions.all_are_numbers([QSquared])
		__QSquared = assertions.force_float_number(QSquared)
		__Mz = particleData.knownParticles.get_mass_from_code(particleData.knownParticles.get_code_from_name('Z-boson'))
		__ln = math.log(__QSquared/(__Mz*__Mz))
		__denominator = 1.0 - (self.__oneLoopAlphaEMOfMzSquared*__ln/(3.0*math.pi))
		return self.__oneLoopAlphaEMOfMzSquared / __denominator
コード例 #16
0
ファイル: runningCouplings.py プロジェクト: leinadao/PyShower
def Nf(QSquared):
	"""A function to return the number of quark flavours that can be produced given a centre of mass energy squared."""
	assert assertions.all_are_numbers([QSquared])
	__QSquared = assertions.force_float_number(QSquared)
	__nf = 0
	for __quarkCode in particleData.knownParticles.get_known_quarks():
		__quarkMass = particleData.knownParticles.get_mass_from_code(__quarkCode)
		if (2.0*__quarkMass < math.sqrt(__QSquared)):
			__nf += 1
	return __nf
コード例 #17
0
 def calculate(self, QSquared):
     """A function for calculating the one-loop fine structure constant at a given COM energy squared."""
     ##Source: "https://www.ippp.dur.ac.uk/~krauss/Lectures/QuarksLeptons/QCD/AsymptoticFreedom_1.html".
     assert assertions.all_are_numbers([QSquared])
     __QSquared = assertions.force_float_number(QSquared)
     __Mz = particleData.knownParticles.get_mass_from_code(
         particleData.knownParticles.get_code_from_name('Z-boson'))
     __ln = math.log(__QSquared / (__Mz * __Mz))
     __denominator = 1.0 - (self.__oneLoopAlphaEMOfMzSquared * __ln /
                            (3.0 * math.pi))
     return self.__oneLoopAlphaEMOfMzSquared / __denominator
コード例 #18
0
def Nf(QSquared):
    """A function to return the number of quark flavours that can be produced given a centre of mass energy squared."""
    assert assertions.all_are_numbers([QSquared])
    __QSquared = assertions.force_float_number(QSquared)
    __nf = 0
    for __quarkCode in particleData.knownParticles.get_known_quarks():
        __quarkMass = particleData.knownParticles.get_mass_from_code(
            __quarkCode)
        if (2.0 * __quarkMass < math.sqrt(__QSquared)):
            __nf += 1
    return __nf
コード例 #19
0
ファイル: runningCouplings.py プロジェクト: leinadao/PyShower
	def calculate(self,QSquared):
		"""A function for calculating the one-loop strong coupling constant at a given COM energy squared."""
		##Source: 'Determination of the QCD coupling alphaS'.
		assert assertions.all_are_numbers([QSquared])
		__QSquared = assertions.force_float_number(QSquared)
		__Nf= Nf(__QSquared)
		__Mz = particleData.knownParticles.get_mass_from_code(particleData.knownParticles.get_code_from_name('Z-boson'))
		##Encorporate in factor of 1/4Pi to make the beta function match:
		__beta0 = beta0(__Nf) / (4.0*math.pi)
		__denominator1 = (__Mz*__Mz)
		__ln = math.log(__QSquared/__denominator1)
		__denominator2 = 1.0 + (self.__oneLoopAlphaSOfMzSquared * __beta0 * __ln)
		return self.__oneLoopAlphaSOfMzSquared / __denominator2
コード例 #20
0
 def calculate(self, QSquared):
     """A function for calculating the one-loop strong coupling constant at a given COM energy squared."""
     ##Source: 'Determination of the QCD coupling alphaS'.
     assert assertions.all_are_numbers([QSquared])
     __QSquared = assertions.force_float_number(QSquared)
     __Nf = Nf(__QSquared)
     __Mz = particleData.knownParticles.get_mass_from_code(
         particleData.knownParticles.get_code_from_name('Z-boson'))
     ##Encorporate in factor of 1/4Pi to make the beta function match:
     __beta0 = beta0(__Nf) / (4.0 * math.pi)
     __denominator1 = (__Mz * __Mz)
     __ln = math.log(__QSquared / __denominator1)
     __denominator2 = 1.0 + (self.__oneLoopAlphaSOfMzSquared * __beta0 *
                             __ln)
     return self.__oneLoopAlphaSOfMzSquared / __denominator2
コード例 #21
0
 def calculate(self, QSquared):
     """A function for calculating the four-loop strong coupling constant at a given COM energy squared."""
     ##Using approximate analytic solution.
     ##Source: 'Quantum Chromodynamics', Dissertori Group, Lpthe Group, P Salam, p3, equation 9.5.
     assert assertions.all_are_numbers([QSquared])
     __QSquared = assertions.force_float_number(QSquared)
     __Nf, __pi = Nf(__QSquared), math.pi
     __beta0 = beta0(__Nf) / (4.0 * __pi)
     __beta1 = beta1(__Nf) / ((4.0 * __pi) * (4.0 * __pi))
     __beta2 = beta2(__Nf) / ((4.0 * __pi) * (4.0 * __pi) * (4.0 * __pi))
     __beta3 = beta3(__Nf) / ((4.0 * __pi) * (4.0 * __pi) * (4.0 * __pi) *
                              (4.0 * __pi))
     try:
         __denominator6 = (self.__fourLoopLambda * self.__fourLoopLambda)
         assert assertions.safe_division(__denominator6)
         __ln = math.log(__QSquared / __denominator6)
         __denominator7 = __beta0 * __beta0 * __ln
         assert assertions.safe_division(__denominator7)
         __term1 = __beta1 * math.log(__ln) / __denominator7
         __denominator8 = __beta0 * __beta0 * __beta0 * __beta0 * __ln * __ln
         assert assertions.safe_division(__denominator8)
         __term2 = ((__beta1 * __beta1 * (
             (math.log(__ln) * math.log(__ln)) - math.log(__ln) - 1.0)) +
                    __beta0 * __beta2) / __denominator8
         __term3P1 = (math.log(__ln) * math.log(__ln) * math.log(__ln)
                      ) - (5.0 / 2.0) * math.log(__ln) * math.log(
                          __ln) - 2.0 * math.log(__ln) + 0.5
         __denominator9 = (__beta0 * __beta0 * __beta0 * __beta0 * __beta0 *
                           __beta0 * __ln * __ln * __ln)
         assert assertions.safe_division(__denominator9)
         __term3 = (__beta1 * __beta1 * __beta1 *
                    __term3P1) / __denominator9
         __term4 = ((3.0 * __beta0 * __beta1 * __beta2 * math.log(__ln)) -
                    (0.5 * __beta0 * __beta0 * __beta3)) / __denominator9
         __denominator10 = __beta0 * __ln
         assert assertions.safe_division(__denominator10)
         __result = (1.0 - __term1 + __term2 -
                     (__term3 + __term4)) / __denominator10
         return __result
     except:
         print "Error in four-loop at QSquared =", __QSquared
         return -1.0
コード例 #22
0
def solve_sudakovs(PperpSquaredMax,
                   S123,
                   difCrossSecIds,
                   code1,
                   code2,
                   logCrosSecs=None):
    """A function to generate a PperpSquared and y for an emission or splitting, using the Sudakov form factor."""
    ##Codes 1,2 still needed to get the charges for EM radiation.
    ##Using veto algorithm in "PYTHIA 6.0 Physics and Manual".
    ##And p198 of "Monte Carlo simulations of hard QCD radiation" for bivariant algorithm.
    ##And p16 of "Initial-state showering based on colour dipoles connected to incoming parton lines" for real y limits.
    ##And p5 of "Fooling around with the Sudakov veto algorithm" for multiple emission form.
    assert assertions.all_are_numbers([PperpSquaredMax, S123])
    assert (type(difCrossSecIds) == list)
    __kQs = particleData.knownParticles.get_known_quarks()
    __gC = particleData.knownParticles.get_code_from_name('gluon')
    __expectedCodes = __kQs + [-x for x in __kQs] + [__gC]
    assert ((code1 in __expectedCodes) and (code2 in __expectedCodes))
    __cutOff = constants.cut_off_energy() * constants.cut_off_energy()
    if (PperpSquaredMax < __cutOff):
        return None, None, None
    __notChosen1, __y, __PperpSquaredi = True, 0, assertions.force_float_number(
        PperpSquaredMax)
    __PperpSquarediMinus1 = __PperpSquaredi
    while __notChosen1:  ##i += 1
        __notChosen2 = True
        while __notChosen2:
            __R1 = random.random()
            __PperpSquaredi = calc_inv_G(
                (math.log(__R1) + calc_G(__PperpSquarediMinus1, S123)), S123)
            if (__PperpSquaredi >
                    S123 / 4.0):  ##The maximum physically possible!
                __notChosen2 = True
                __PperpSquarediMinus1 = __PperpSquaredi
                continue  #Re-run the while loop
            if (
                    __PperpSquaredi <= __PperpSquarediMinus1
            ):  ##Don't update __PperpSquaredi if fails as would start allowing higher values!
                __notChosen2 = False  ##Move on
        if (__PperpSquaredi < __cutOff):
            return None, None, None
        __R2 = random.random()
        __ymin, __ymax = -0.5 * math.log(
            S123 / __PperpSquaredi), 0.5 * math.log(S123 / __PperpSquaredi)
        __yi = calc_inv_G2(__R2 * (calc_G2(__ymax) - calc_G2(__ymin)) +
                           calc_G2(__ymin))
        if not check_rapidity_allowed(
                S123, __PperpSquaredi,
                __yi):  ##Veto incorrect y-range. On the boundary is allowed.
            __PperpSquarediMinus1 = __PperpSquaredi
            continue  ##Don't accept, notChosen1 == True, while will run again.
        __R3 = random.random()
        __numberCSIds = len(difCrossSecIds)
        __ratio = sum_cSs(difCrossSecIds, S123, __PperpSquaredi, __yi, code1,
                          code2) / __numberCSIds * calc_g(
                              __PperpSquaredi, __yi)
        if (__ratio <= __R3):
            __PperpSquarediMinus1 = __PperpSquaredi
            continue  ##Don't accept, notChosen1 == True, while will run again.
        else:
            __notChosen1 = False  ##Accept.
    ##Prepare weights for choosing Id of process occuring:
    __idWeights = {}  ##Empty dictionary initiated.
    for __difCrossSecId in difCrossSecIds:  ##Uses the Ids given so will weight for the chosen set.
        __idWeights[__difCrossSecId] = sum_cSs([__difCrossSecId], S123,
                                               __PperpSquaredi, __yi, code1,
                                               code2)
    __total = sum(__idWeights.itervalues())
    __idWeights.update(
        (x, y / __total) for x, y in __idWeights.items())  ##Normalise them
    assert precision.check_numbers_equal(
        sum(__idWeights.itervalues()),
        1.0)  ##i.e they should now be normalised to 1.
    ##Choose which process:
    __R4 = random.random(
    )  ##Doesn't include 1 -> using < not <= for checks is fair.
    __sumSoFar = 0.0
    __chosenId = None
    __chosen = False
    if (logCrosSecs == 1):
        crossSecsGluSplit.store(qg_to_qQQBar_cS(S123, __PperpSquaredi, __yi))
        crossSecsGluProd.store(qg_to_qgg_cS(S123, __PperpSquaredi, __yi))
    for __difCrossSecId in difCrossSecIds:
        if (not __chosen):
            __sumSoFar += __idWeights[__difCrossSecId]
            if (__R4 < __sumSoFar):
                __chosenId = __difCrossSecId
                __chosen = True
    assert (not (__chosenId == None))  ##Should have chosen by now!
    return __PperpSquaredi, __yi, __chosenId
コード例 #23
0
ファイル: runningCouplings.py プロジェクト: leinadao/PyShower
	def calculate_weighted(self,QSquared):
		"""A function to return the one-loop fine structure constant weighted on it's maximum value (at Mz^2)."""
		##Currently only set for showering on resonance with the Z-boson channel.
		assert assertions.all_are_numbers([QSquared])
		__QSquared = assertions.force_float_number(QSquared)
		return self.calculate(__QSquared) / self.__alphaEMMax
コード例 #24
0
ファイル: runningCouplings.py プロジェクト: leinadao/PyShower
	def calculate_weighted(self,QSquared):
		"""A function to return the four-loop strong coupling constant weighted on it's maximum value (at parton shower cutoff)."""
		assert assertions.all_are_numbers([QSquared])
		__QSquared = assertions.force_float_number(QSquared)
		return self.calculate(__QSquared) / self.__alphaSMax
コード例 #25
0
ファイル: sudakovs.py プロジェクト: leinadao/PyShower
def solve_sudakovs(PperpSquaredMax,S123,difCrossSecIds,code1,code2,logCrosSecs = None):
	"""A function to generate a PperpSquared and y for an emission or splitting, using the Sudakov form factor."""
	##Codes 1,2 still needed to get the charges for EM radiation.
	##Using veto algorithm in "PYTHIA 6.0 Physics and Manual".
	##And p198 of "Monte Carlo simulations of hard QCD radiation" for bivariant algorithm.
	##And p16 of "Initial-state showering based on colour dipoles connected to incoming parton lines" for real y limits.
	##And p5 of "Fooling around with the Sudakov veto algorithm" for multiple emission form.
	assert assertions.all_are_numbers([PperpSquaredMax,S123])
	assert (type(difCrossSecIds) == list)
	__kQs = particleData.knownParticles.get_known_quarks()
	__gC = particleData.knownParticles.get_code_from_name('gluon')
	__expectedCodes = __kQs + [-x for x in __kQs] + [__gC]
	assert ((code1 in __expectedCodes) and (code2 in __expectedCodes))
	__cutOff = constants.cut_off_energy()*constants.cut_off_energy()
	if (PperpSquaredMax < __cutOff):
		return None, None, None
	__notChosen1, __y, __PperpSquaredi = True, 0, assertions.force_float_number(PperpSquaredMax)
	__PperpSquarediMinus1 = __PperpSquaredi
	while __notChosen1: ##i += 1
		__notChosen2 = True
		while __notChosen2:
			__R1 = random.random()
			__PperpSquaredi = calc_inv_G((math.log(__R1) + calc_G(__PperpSquarediMinus1,S123)),S123)
			if (__PperpSquaredi > S123/4.0): ##The maximum physically possible!
				__notChosen2 = True
				__PperpSquarediMinus1 = __PperpSquaredi
				continue #Re-run the while loop
			if (__PperpSquaredi <= __PperpSquarediMinus1): ##Don't update __PperpSquaredi if fails as would start allowing higher values!
				__notChosen2 = False ##Move on
		if (__PperpSquaredi < __cutOff):
			return None, None, None
		__R2 = random.random()
		__ymin, __ymax = -0.5*math.log(S123/__PperpSquaredi), 0.5*math.log(S123/__PperpSquaredi)
		__yi = calc_inv_G2(__R2*(calc_G2(__ymax) - calc_G2(__ymin)) + calc_G2(__ymin))
		if not check_rapidity_allowed(S123,__PperpSquaredi,__yi): ##Veto incorrect y-range. On the boundary is allowed.
			__PperpSquarediMinus1 = __PperpSquaredi
			continue ##Don't accept, notChosen1 == True, while will run again.
		__R3 = random.random()
		__numberCSIds = len(difCrossSecIds)
		__ratio = sum_cSs(difCrossSecIds,S123,__PperpSquaredi,__yi,code1,code2) / __numberCSIds*calc_g(__PperpSquaredi,__yi)
		if (__ratio <= __R3):
			__PperpSquarediMinus1 = __PperpSquaredi
			continue ##Don't accept, notChosen1 == True, while will run again.
		else:
			__notChosen1 = False ##Accept.
	##Prepare weights for choosing Id of process occuring:
	__idWeights = {} ##Empty dictionary initiated.
	for __difCrossSecId in difCrossSecIds: ##Uses the Ids given so will weight for the chosen set.
		__idWeights[__difCrossSecId] = sum_cSs([__difCrossSecId],S123,__PperpSquaredi,__yi,code1,code2)
	__total = sum(__idWeights.itervalues())
	__idWeights.update((x, y/__total) for x, y in __idWeights.items()) ##Normalise them
	assert precision.check_numbers_equal(sum(__idWeights.itervalues()),1.0) ##i.e they should now be normalised to 1.
	##Choose which process:
	__R4 = random.random() ##Doesn't include 1 -> using < not <= for checks is fair.
	__sumSoFar = 0.0
	__chosenId = None
	__chosen = False
	if (logCrosSecs == 1):
		crossSecsGluSplit.store(qg_to_qQQBar_cS(S123,__PperpSquaredi,__yi))
		crossSecsGluProd.store(qg_to_qgg_cS(S123,__PperpSquaredi,__yi))
	for __difCrossSecId in difCrossSecIds:
		if (not __chosen):
			__sumSoFar += __idWeights[__difCrossSecId]
			if (__R4 < __sumSoFar):
				__chosenId = __difCrossSecId
				__chosen = True
	assert (not (__chosenId == None)) ##Should have chosen by now!
	return __PperpSquaredi, __yi, __chosenId
コード例 #26
0
 def calculate_weighted(self, QSquared):
     """A function to return the one-loop fine structure constant weighted on it's maximum value (at Mz^2)."""
     ##Currently only set for showering on resonance with the Z-boson channel.
     assert assertions.all_are_numbers([QSquared])
     __QSquared = assertions.force_float_number(QSquared)
     return self.calculate(__QSquared) / self.__alphaEMMax
コード例 #27
0
 def calculate_weighted(self, QSquared):
     """A function to return the four-loop strong coupling constant weighted on it's maximum value (at parton shower cutoff)."""
     assert assertions.all_are_numbers([QSquared])
     __QSquared = assertions.force_float_number(QSquared)
     return self.calculate(__QSquared) / self.__alphaSMax
コード例 #28
0
def check_v_not_faster_than_c(scalarVelocity):
    """A function to check that a scalar velocity isn't faster than the speed of light."""
    ##Allows equal to the speed of light to accommodate massless particles.
    assert assertions.all_are_numbers([scalarVelocity])
    __scalarVelocity = assertions.force_float_number(scalarVelocity)
    return (__scalarVelocity <= 1.0)
コード例 #29
0
ファイル: fourVectors.py プロジェクト: leinadao/PyShower
	def force_float_vector(self):
		"""A function to convert all vector integers to floats but leave doubles."""
		for __i2 in range(4):
			assert assertions.all_are_numbers([__i2])
			if (not assertions.check_float(self.__vector[__i2])):
				self.__vector[__i2] = assertions.force_float_number(self.__vector[__i2])
コード例 #30
0
ファイル: lorentz.py プロジェクト: leinadao/PyShower
def check_v_not_faster_than_c(scalarVelocity):
	"""A function to check that a scalar velocity isn't faster than the speed of light."""
	##Allows equal to the speed of light to accommodate massless particles.
	assert assertions.all_are_numbers([scalarVelocity])
	__scalarVelocity = assertions.force_float_number(scalarVelocity)
	return (__scalarVelocity <= 1.0)