예제 #1
0
def produce_electron_pair(S123):
    """A function to produce an electron and positron in opposite directions."""
    __cE = constants.cut_off_energy()
    assert ((type(S123) == float) and (S123 > __cE * __cE))
    ##Define beams to be along z: works well for Pythia 8.2.
    __E = math.sqrt(S123) / 2.0
    __pV1 = fourVectors.fourVector(__E, 0.0, 0.0, __E)
    __pV2 = fourVectors.fourVector(__E, 0.0, 0.0, -__E)
    __eCode = particleData.knownParticles.get_code_from_name("electron")
    __p1 = particles.particle(__eCode, __pV1, [0, 0], [3, 4], [0, 0], -1)
    __p2 = particles.particle(-__eCode, __pV2, [0, 0], [3, 4], [0, 0], -1)
    __p1.set_unique_ID(1)
    __p2.set_unique_ID(2)
    return [__p1, __p2]
예제 #2
0
파일: MEs.py 프로젝트: leinadao/PyShower
def produce_electron_pair(S123):
	"""A function to produce an electron and positron in opposite directions."""
	__cE = constants.cut_off_energy()
	assert ((type(S123) == float) and (S123 > __cE*__cE))
	##Define beams to be along z: works well for Pythia 8.2.
	__E = math.sqrt(S123)/2.0
	__pV1 = fourVectors.fourVector(__E,0.0,0.0,__E)
	__pV2 = fourVectors.fourVector(__E,0.0,0.0,-__E)
	__eCode = particleData.knownParticles.get_code_from_name("electron")
	__p1 = particles.particle(__eCode,__pV1,[0,0],[3,4],[0,0],-1)
	__p2 = particles.particle(-__eCode,__pV2,[0,0],[3,4],[0,0],-1)
	__p1.set_unique_ID(1)
	__p2.set_unique_ID(2)
	return [__p1,__p2]
예제 #3
0
def calculate_split_ps(S123, Pperp, y):
    """A function to calculate the new p1,p2,p3 four-vectors following a dipole splitting."""
    ##Letting p2 take +Pperp and p1 take -Pperp by convention.
    assert assertions.all_are_numbers([S123, Pperp, y])
    assert ((S123 > 0.0) and (Pperp > 0.0))
    __E1, __E2 = calculate_E1(S123, Pperp, y), calculate_E2(S123, Pperp, y)
    __E3, __kPerp = calculate_E3(S123, Pperp,
                                 y), calculate_kPerp(S123, Pperp, y)
    ##Store all energies produced for plotting graphs after showering:
    e1s.store(__E1)
    e2s.store(__E2)
    e3s.store(__E3)
    __randomPhi, __newP1 = get_random_phi(), fourVectors.fourVector(
        0.0, 0.0, 0.0, 0.0)
    __newP2, __newP3 = fourVectors.fourVector(0.0, 0.0, 0.0,
                                              0.0), fourVectors.fourVector(
                                                  0.0, 0.0, 0.0, 0.0)
    assert (0.0 < __randomPhi and __randomPhi < 2.0 * math.pi)
    ##Populate the first vector:
    __newP1[0] = __E1
    __newP1[1] = (-1.0) * __kPerp * math.cos(__randomPhi)
    __newP1[2] = (-1.0) * __kPerp * math.sin(__randomPhi)
    __newP1[3] = math.sqrt((__E1 * __E1) - (__kPerp * __kPerp))
    assert ((__newP1[0] > 0.0) and (__newP1[3] > 0.0))
    ##Populate the second vector:
    __newP2[0] = __E2
    __newP2[1] = __kPerp * math.cos(__randomPhi)
    __newP2[2] = __kPerp * math.sin(__randomPhi)
    __newP2[3] = math.sqrt((__E2 * __E2) - (__kPerp * __kPerp))
    assert (__newP2[0] > 0.0)
    ##Populate the third vector. Entries 1 & 2 already 0 as required:
    __newP3[0] = __E3
    __newP3[3] = (-1.0) * __E3
    assert ((__newP3[0] > 0.0) and (__newP3[3] < 0.0))
    ##Log x's for a produced particle for plotting after showering:
    tX1s.store(calculate_x1(S123, Pperp, y))
    tX3s.store(calculate_x3(S123, Pperp, y))
    ##Check the direction of the produced particle is consistent with parallel momentum conservation.
    ##This allows for different recoil configurations.
    if precision.check_numbers_equal(0.0,
                                     __newP1[3] + __newP2[3] + __newP3[3]):
        return __newP1, __newP2, __newP3
    elif precision.check_numbers_equal(0.0,
                                       __newP1[3] - __newP2[3] + __newP3[3]):
        __newP2[3] = -__newP2[3]
        return __newP1, __newP2, __newP3
    elif precision.check_numbers_equal(0.0,
                                       -__newP1[3] + __newP2[3] + __newP3[3]):
        __newP1[3] = -__newP1[3]
        return __newP1, __newP2, __newP3
예제 #4
0
	def __init__(self,lookUpCodeOrName,fourMomentum = fourVectors.fourVector(),mothers = [0,0],children = [0,0],colours = [0,0], statusCode = 1):
		"""A function to initiate a particle."""
		##Allow initiation via name or code but then works from the code.
		##StatusCode: -1 initial, 0 = intermediate, 1 = final state. 1 chosen by default as this is currently a final state shower.
		assert ((type(lookUpCodeOrName) == int) or (type(lookUpCodeOrName) == str))
		assert fourVectors.check_is_fourVector(fourMomentum)
		assert ((type(mothers) == list) and (type(mothers[0]) == int) and (type(mothers[1]) == int))
		assert ((type(children) == list) and (type(children[0]) == int) and (type(children[1]) == int))
		assert ((type(colours) == list) and (type(colours[0]) == int) and (type(colours[1]) == int))
		assert (type(statusCode) == int)
		assert assertions.valid_particle_status_code(statusCode)
		if (type(lookUpCodeOrName) == int):
			assert particleData.knownParticles.has_key(lookUpCodeOrName)
			self.__lookUpCode = lookUpCodeOrName
		elif (type(lookUpCodeOrName) == str):
			assert particleData.knownParticles.has_name(lookUpCodeOrName)
			self.__lookUpCode = particleData.knownParticles.get_code_from_name(lookUpCodeOrName)
		self.__fourMomentum = fourMomentum
		self.__mothers = mothers
		self.__children = children
		self.__colours = colours
		self.__statusCode = statusCode
		self.__historyList = [False,False,False,False] ##Mothers then children (if set)
		self.__colourSetList = [False, False]
		for __i, __a in enumerate(self.__mothers+self.__children): ##Do both at once.
			if __a != 0:
				self.__historyList[__i] = True
		for __i, __a in enumerate(self.__colours):
			if __a != 0:
				self.__colourSetList[__i]= True
		self.__uniqueID = 0
		self.__producedAt = -1 ##Default value for not set, as 0 is actually used.
예제 #5
0
def Sijk(listOfMomentumFourVectors):
    """A function to calculate the invariant quantity Sijk for Pi's in the given list."""
    assert type(listOfMomentumFourVectors) == list
    __sqrtSijk = fourVectors.fourVector(0.0, 0.0, 0.0, 0.0)
    for __Pi in listOfMomentumFourVectors:
        assert fourVectors.check_is_fourVector(__Pi)
        assert __Pi.__nonzero__()
        __sqrtSijk += __Pi
    __Sikj = __sqrtSijk * __sqrtSijk
    return __Sikj
예제 #6
0
	def get_event_particle_four_momentum(self,eventIndex,particleIndex):
		"""A function to get the four-momentum of a particle in an event in an LHEF XML file."""
		assert ((type(eventIndex) == int) and (type(particleIndex) == int))
		__fourVector = fourVectors.fourVector()
		##Energy is the last component in the LHEF
		__fourVector[0] = float(self.get_event_particle_strings(eventIndex,particleIndex)[9])
		__fourVector[1] = float(self.get_event_particle_strings(eventIndex,particleIndex)[6])
		__fourVector[2] = float(self.get_event_particle_strings(eventIndex,particleIndex)[7])
		__fourVector[3] = float(self.get_event_particle_strings(eventIndex,particleIndex)[8])
		return __fourVector
예제 #7
0
def produce_quark_directions(S123, theta):
    """A function to produce a set of opposite directional quark vectors in opposite directions."""
    __cE = constants.cut_off_energy()
    assert ((type(S123) == float) and (S123 > __cE * __cE))
    assert ((type(theta) == float) and (0.0 <= theta) and (theta <= math.pi))
    __phi = kinematics.get_random_phi()
    __x = math.sin(theta) * math.cos(__phi)
    __y = math.sin(theta) * math.sin(__phi)
    __z = math.cos(theta)
    __direction = fourVectors.fourVector(0.0, __x, __y, __z)
    __oppositeDirection = __direction.copy()
    __oppositeDirection *= -1.0
    return __direction, __oppositeDirection
예제 #8
0
파일: MEs.py 프로젝트: leinadao/PyShower
def produce_quark_directions(S123,theta):
	"""A function to produce a set of opposite directional quark vectors in opposite directions."""
	__cE = constants.cut_off_energy()
	assert ((type(S123) == float) and (S123 > __cE*__cE))
	assert((type(theta) == float) and (0.0 <= theta) and (theta <= math.pi))
	__phi = kinematics.get_random_phi()
	__x = math.sin(theta)*math.cos(__phi)
	__y = math.sin(theta)*math.sin(__phi)
	__z = math.cos(theta)
	__direction = fourVectors.fourVector(0.0,__x,__y,__z)
	__oppositeDirection = __direction.copy()
	__oppositeDirection *= -1.0
	return __direction, __oppositeDirection
예제 #9
0
 def get_event_particle_four_momentum(self, eventIndex, particleIndex):
     """A function to get the four-momentum of a particle in an event in an LHEF XML file."""
     assert ((type(eventIndex) == int) and (type(particleIndex) == int))
     __fourVector = fourVectors.fourVector()
     ##Energy is the last component in the LHEF
     __fourVector[0] = float(
         self.get_event_particle_strings(eventIndex, particleIndex)[9])
     __fourVector[1] = float(
         self.get_event_particle_strings(eventIndex, particleIndex)[6])
     __fourVector[2] = float(
         self.get_event_particle_strings(eventIndex, particleIndex)[7])
     __fourVector[3] = float(
         self.get_event_particle_strings(eventIndex, particleIndex)[8])
     return __fourVector
예제 #10
0
	def inverse_boost(self,pVIn):
		"""A function to perform the inverse lorentz boost on a given (E,p) four-vector."""
		assert fourVectors.check_is_fourVector(pVIn)
		assert pVIn.__nonzero__()
		##Make sure it's not space-like:
		assert (check_timelike(pVIn) or check_lightlike(pVIn))
		__pVOut = fourVectors.fourVector()
		__energyOut = (self.__reverseMomentumOfCMF * pVIn)/self.__massOfCMF
		__alpha = (pVIn[0]+__energyOut)/(self.__massOfCMF + self.__momentumOfCMF[0])
		__pVOut[0] = __energyOut
		for __i3 in range(3):
			__pVOut[__i3+1] = pVIn[__i3+1] - __alpha * self.__reverseMomentumOfCMF[__i3+1]
		##Make sure its still not space-like after the boost:
		assert (check_timelike(__pVOut) or check_lightlike(__pVOut))
		return __pVOut
예제 #11
0
 def inverse_boost(self, pVIn):
     """A function to perform the inverse lorentz boost on a given (E,p) four-vector."""
     assert fourVectors.check_is_fourVector(pVIn)
     assert pVIn.__nonzero__()
     ##Make sure it's not space-like:
     assert (check_timelike(pVIn) or check_lightlike(pVIn))
     __pVOut = fourVectors.fourVector()
     __energyOut = (self.__reverseMomentumOfCMF * pVIn) / self.__massOfCMF
     __alpha = (pVIn[0] + __energyOut) / (self.__massOfCMF +
                                          self.__momentumOfCMF[0])
     __pVOut[0] = __energyOut
     for __i3 in range(3):
         __pVOut[__i3 + 1] = pVIn[
             __i3 + 1] - __alpha * self.__reverseMomentumOfCMF[__i3 + 1]
     ##Make sure its still not space-like after the boost:
     assert (check_timelike(__pVOut) or check_lightlike(__pVOut))
     return __pVOut
예제 #12
0
	def boost(self,pVIn):
		"""A function to perform the lorentz boost on a given (E,p) four-vector."""
		assert fourVectors.check_is_fourVector(pVIn)
		assert pVIn.__nonzero__()
		##Make sure it's not space-like:
		__pVIn = pVIn.copy()
		assert (check_timelike(__pVIn) or check_lightlike(__pVIn))
		##Make sure not trying to boost into its own CMF:
		if check_lightlike(__pVIn):
			assert (__pVIn != self.__momentumOfCMF)
		__pVOut = fourVectors.fourVector()
		__energyPrime = (self.__momentumOfCMF * __pVIn)/self.__massOfCMF
		__alpha = (__pVIn[0]+__energyPrime)/(self.__massOfCMF + self.__momentumOfCMF[0])
		__pVOut[0] = __energyPrime
		for __i2 in range(3):
			__pVOut[__i2+1] = __pVIn[__i2+1] - __alpha * self.__momentumOfCMF[__i2+1]
		##Make sure its still not space-like after the boost:
		assert (check_timelike(__pVOut) or check_lightlike(__pVOut))
		return __pVOut
예제 #13
0
 def boost(self, pVIn):
     """A function to perform the lorentz boost on a given (E,p) four-vector."""
     assert fourVectors.check_is_fourVector(pVIn)
     assert pVIn.__nonzero__()
     ##Make sure it's not space-like:
     __pVIn = pVIn.copy()
     assert (check_timelike(__pVIn) or check_lightlike(__pVIn))
     ##Make sure not trying to boost into its own CMF:
     if check_lightlike(__pVIn):
         assert (__pVIn != self.__momentumOfCMF)
     __pVOut = fourVectors.fourVector()
     __energyPrime = (self.__momentumOfCMF * __pVIn) / self.__massOfCMF
     __alpha = (__pVIn[0] + __energyPrime) / (self.__massOfCMF +
                                              self.__momentumOfCMF[0])
     __pVOut[0] = __energyPrime
     for __i2 in range(3):
         __pVOut[__i2 +
                 1] = __pVIn[__i2 +
                             1] - __alpha * self.__momentumOfCMF[__i2 + 1]
     ##Make sure its still not space-like after the boost:
     assert (check_timelike(__pVOut) or check_lightlike(__pVOut))
     return __pVOut
예제 #14
0
##Module test code:##
if __name__ == "__main__":
	##Import modules required for testing:##
	import random

	##Begin testing:##
	print "\n----------------------------------------------------------------------"
	print "----------------------------------------------------------------------\n"
	print "///////////////////////"
	print "Testing lorentz module:"
	print "///////////////////////"
	assertions.pause(__name__)
	
	##Setup here:##
	print "\nGenerating test values..."
	tLightlike = fourVectors.fourVector(math.sqrt(3*3 + 4*4 + 5*5),3,4,5)
	tMomentum4V1 = fourVectors.fourVector(200,30,50,40)
	tMomentum4V2 = fourVectors.fourVector(215,66,12,52)
	tNotTooFast1 = 0.87
	tNotTooFast2 = 1.0
	tTooFast1 = 1.01
	tTooFast2 = 109
	tBoost1 = lorentzBoost(tMomentum4V1)
	tFourVectors = {'a':None,'b':None,'c':None,'d':None}
	tMomentumSquares = {'a':None,'b':None,'c':None,'d':None}
	tBoostedMomentumSquares = {'a':None,'b':None,'c':None,'d':None}
	tSumMomentums = fourVectors.fourVector(0,0,0,0)
	tBoostedSumMomentums = fourVectors.fourVector(0,0,0,0)
	##Generate random test four-vectors:##
	for tFourVector in tFourVectors:
		tX0 = random.randrange(1000,2000)/10.0
예제 #15
0
	##Test all get_event_particle_'' functions:##
	print "\n--------------------------------------------------\n"
	print "Testing all get_event_particle_'' functions:\n"
	print "Using the first event in '" + testPathIn + "':"
	print "\nThe PDGID is:", testReader.get_event_particle_ID(0,0)
	print "The 'when' code is:", testReader.get_event_particle_when(0,0)
	print "The mothers are:", testReader.get_event_particle_mothers(0,0)
	print "The coloursL are:", testReader.get_event_particle_colours(0,0)
	print "The four-momentum is:", testReader.get_event_particle_four_momentum(0,0)
	print "The mass is:", testReader.get_event_particle_mass(0,0)
	print "The proper lifetime is:", testReader.get_event_particle_lifetime(0,0)
	print "The spin is:", testReader.get_event_particle_spin(0,0)
	results = [testReader.get_event_particle_ID(0,0),testReader.get_event_particle_when(0,0),testReader.get_event_particle_mothers(0,0)]
	results += [testReader.get_event_particle_colours(0,0),testReader.get_event_particle_four_momentum(0,0),testReader.get_event_particle_mass(0,0)]
	results += [testReader.get_event_particle_lifetime(0,0),testReader.gget_event_particle_spin(0,0)]
	expected = [11,-1,0,0,0,0,fourVectors.fourVector(5.2899734145e+00,0.0000000000e+00,0.0000000000e+00,5.2899734145e+00),0,0,9]
	if (results == expected):
		print "Test successful!"
	else:
		print "Test failed!"
	print "\nFinished testing all get_event_particle_'' functions."
	assertions.pause(__name__)

	##Test LHEFShowerWriter class:##
	print "\n----------------------------------------------------------------------"
	print "----------------------------------------------------------------------\n"
	print "///////////////////////////////"
	print "Testing LHEFShowerWriter class:"
	print "///////////////////////////////"
	assertions.pause(__name__)
예제 #16
0
	print "Testing counters module:"
	print "////////////////////////"
	assertions.pause(__name__)
	
	##Setup here:##
	tCounter1 = counter(0)
	tCounter2 = counter(501)
	tCounter3 = counter(0)
	tCounter4 = counter(501)
	tNumIts = 1000000

	##Test check_is_counter:##
	print "\n--------------------------------------------------\n"
	print "Testing check_is_counter:"
	print "Calling check_is_counter on instance: " , check_is_counter(tCounter1)
	print "Calling check_is_counter on wrong instance: " , check_is_counter(fourVectors.fourVector())
	print "Calling check_is_counter on 1.055: " , check_is_counter(1.055)
	print "Calling check_is_counter on 'word': " , check_is_counter('word')
	tResults = [check_is_counter(tCounter1),check_is_counter(fourVectors.fourVector())]
	tResults += [check_is_counter(1.055),check_is_counter('word')]
	if (sum(tResults) == 1):
		print "\nTest successful!"
	else:
		print "\nTest failed!"
	print "\nFinished testing check_is_counter."
	assertions.pause(__name__)

	##Test counter class:##
	print "\n----------------------------------------------------------------------"
	print "----------------------------------------------------------------------\n"
	print "//////////////////////"
예제 #17
0
 def get_momentum_in_CMF(self):
     """A function to return the four-vector in its COM frame."""
     return fourVectors.fourVector(self.__massOfCMF, 0.0, 0.0, 0.0)
예제 #18
0
        testReader.get_event_particle_ID(0, 0),
        testReader.get_event_particle_when(0, 0),
        testReader.get_event_particle_mothers(0, 0)
    ]
    results += [
        testReader.get_event_particle_colours(0, 0),
        testReader.get_event_particle_four_momentum(0, 0),
        testReader.get_event_particle_mass(0, 0)
    ]
    results += [
        testReader.get_event_particle_lifetime(0, 0),
        testReader.gget_event_particle_spin(0, 0)
    ]
    expected = [
        11, -1, 0, 0, 0, 0,
        fourVectors.fourVector(5.2899734145e+00, 0.0000000000e+00,
                               0.0000000000e+00, 5.2899734145e+00), 0, 0, 9
    ]
    if (results == expected):
        print "Test successful!"
    else:
        print "Test failed!"
    print "\nFinished testing all get_event_particle_'' functions."
    assertions.pause(__name__)

    ##Test LHEFShowerWriter class:##
    print "\n----------------------------------------------------------------------"
    print "----------------------------------------------------------------------\n"
    print "///////////////////////////////"
    print "Testing LHEFShowerWriter class:"
    print "///////////////////////////////"
    assertions.pause(__name__)
예제 #19
0
##Module test code:##
if __name__ == "__main__":
    ##Import modules required for testing:##
    import random

    ##Begin testing:##
    print "\n----------------------------------------------------------------------"
    print "----------------------------------------------------------------------\n"
    print "///////////////////////"
    print "Testing lorentz module:"
    print "///////////////////////"
    assertions.pause(__name__)

    ##Setup here:##
    print "\nGenerating test values..."
    tLightlike = fourVectors.fourVector(math.sqrt(3 * 3 + 4 * 4 + 5 * 5), 3, 4,
                                        5)
    tMomentum4V1 = fourVectors.fourVector(200, 30, 50, 40)
    tMomentum4V2 = fourVectors.fourVector(215, 66, 12, 52)
    tNotTooFast1 = 0.87
    tNotTooFast2 = 1.0
    tTooFast1 = 1.01
    tTooFast2 = 109
    tBoost1 = lorentzBoost(tMomentum4V1)
    tFourVectors = {'a': None, 'b': None, 'c': None, 'd': None}
    tMomentumSquares = {'a': None, 'b': None, 'c': None, 'd': None}
    tBoostedMomentumSquares = {'a': None, 'b': None, 'c': None, 'd': None}
    tSumMomentums = fourVectors.fourVector(0, 0, 0, 0)
    tBoostedSumMomentums = fourVectors.fourVector(0, 0, 0, 0)
    ##Generate random test four-vectors:##
    for tFourVector in tFourVectors:
        tX0 = random.randrange(1000, 2000) / 10.0
예제 #20
0
	import math

	##Begin testing:##
	print "\n----------------------------------------------------------------------"
	print "----------------------------------------------------------------------\n"
	print "//////////////////////"
	print "Testing chains module:"
	print "//////////////////////"
	assertions.pause(__name__)
	
	##Setup here:##
	print "\nGenerating test values..."
	##Generate random test four-vectors:##
	testFourVectors = {'a':None,'b':None,'c':None,'d':None,'e':None}
	##Prevent the random vectors being the same as can't boost into frame of massless particle.
	testVector1, testVector2 = fourVectors.fourVector(0,0,0,0), fourVectors.fourVector(0,0,0,0) ##Required to start while loop.
	selectionFinished = False
	while (not selectionFinished):
		for testFourVector in testFourVectors:
			x1 = random.randrange(1,100)
			x2 = random.randrange(0,100)
			x3 = random.randrange(0,100)
			##Make them massless.
			x0 = math.sqrt((x1*x1) + (x2*x2) +(x3*x3))
			testFourVectors[testFourVector] = fourVectors.fourVector(x0,x1,x2,x3)
		testVector1 = testFourVectors['a'].copy()
		testVector2 = testFourVectors['b'].copy()
		testVector3 = testFourVectors['c'].copy()
		testVector4 = testFourVectors['d'].copy()
		testVector5 = testFourVectors['e'].copy()
		##Want five independent energy-momentum four-vectors.
예제 #21
0
	def get_momentum_in_CMF(self):
		"""A function to return the four-vector in its COM frame."""
		return fourVectors.fourVector(self.__massOfCMF, 0.0, 0.0, 0.0)
예제 #22
0
    print "////////////////////////"
    assertions.pause(__name__)

    ##Setup here:##
    tCounter1 = counter(0)
    tCounter2 = counter(501)
    tCounter3 = counter(0)
    tCounter4 = counter(501)
    tNumIts = 1000000

    ##Test check_is_counter:##
    print "\n--------------------------------------------------\n"
    print "Testing check_is_counter:"
    print "Calling check_is_counter on instance: ", check_is_counter(tCounter1)
    print "Calling check_is_counter on wrong instance: ", check_is_counter(
        fourVectors.fourVector())
    print "Calling check_is_counter on 1.055: ", check_is_counter(1.055)
    print "Calling check_is_counter on 'word': ", check_is_counter('word')
    tResults = [
        check_is_counter(tCounter1),
        check_is_counter(fourVectors.fourVector())
    ]
    tResults += [check_is_counter(1.055), check_is_counter('word')]
    if (sum(tResults) == 1):
        print "\nTest successful!"
    else:
        print "\nTest failed!"
    print "\nFinished testing check_is_counter."
    assertions.pause(__name__)

    ##Test counter class:##
예제 #23
0
    ##Begin testing:##
    print "\n----------------------------------------------------------------------"
    print "----------------------------------------------------------------------\n"
    print "//////////////////////////"
    print "Testing kinematics module:"
    print "//////////////////////////"
    assertions.pause(__name__)

    ##Setup here:##
    print "\nGenerating test values..."
    tS123 = 0.0  ##Needed to start while loop.
    while tS123 < 10.0:
        ##Generate random test four-vectors:
        tFourVectors = {'a': None, 'b': None, 'c': None, 'd': None}
        ##Prevent the random vectors being the same as can't boost into frame of massless particle.
        tVector1, tVector2 = fourVectors.fourVector(0, 0, 0,
                                                    0), fourVectors.fourVector(
                                                        0, 0, 0, 0)
        while (
            (tVector1 == tVector2) or
            (not fourVectors.check_different_direction(tVector1, tVector2))):
            for tFourVector in tFourVectors:
                ##Random range set so as to produce a vector slower than the speed of light.
                tX1 = random.randrange(2, 100)
                tX2 = random.randrange(2, 100)
                tX3 = random.randrange(2, 100)
                ##Make them massless.
                tX0 = math.sqrt((tX1 * tX1) + (tX2 * tX2) + (tX3 * tX3))
                tFourVectors[tFourVector] = fourVectors.fourVector(
                    tX0, tX1, tX2, tX3)
            tExpectedSab = tFourVectors['a'] * tFourVectors[
                'a'] + tFourVectors['b'] * tFourVectors['b']
예제 #24
0
	import fourVectors

	##Begin testing:##
	print "\n----------------------------------------------------------------------"
	print "----------------------------------------------------------------------\n"
	print "///////////////////////"
	print "Testing dipoles module:"
	print "///////////////////////"
	assertions.pause(__name__)
	
	##Setup here:##
	print "\nGenerating test values..."
	##Generate random test four-vectors:##
	testFourVectors1 = {'a':None,'b':None}
	##Prevent the random vectors being the same as can't boost into frame of massless particle.
	testVector1, testVector2 = fourVectors.fourVector(0,0,0,0), fourVectors.fourVector(0,0,0,0) ##Required to start while loop.
	while ((testVector1 == testVector2) or (not fourVectors.check_different_direction(testVector1,testVector2))):
		for testFourVector in testFourVectors1:
			x1 = random.randrange(1,10)/10.0
			x2 = random.randrange(0,int(math.sqrt(1-(x1**2))*10))/10.0
			x3 = random.randrange(0,int(math.sqrt(1-(x2**2))*10))/10.0
			##Make them massless.
			x0 = math.sqrt((x1*x1) + (x2*x2) +(x3*x3))
			testFourVectors1[testFourVector] = fourVectors.fourVector(x0,x1,x2,x3)
		testVector1 = testFourVectors1['a'].copy()
		testVector2 = testFourVectors1['b'].copy()
	##Generate set 2:
	testFourVectors2 = {'a':None,'b':None}
	##Prevent the random vectors being the same as can't boost into frame of massless particle.
	testVector3, testVector4 = fourVectors.fourVector(0,0,0,0), fourVectors.fourVector(0,0,0,0) ##Required to start while loop.
	while ((testVector3 == testVector4) or (not fourVectors.check_different_direction(testVector3,testVector4))):
예제 #25
0
	print "\n----------------------------------------------------------------------"
	print "----------------------------------------------------------------------\n"
	print "///////////////////////////"
	print "Testing dataLoggers module:"
	print "///////////////////////////"
	assertions.pause(__name__)
	
	##Setup here:##
	tLogger1 = dataLogger()
	tNumIts = 1000000

	##Test check_is_dataLogger:##
	print "\n--------------------------------------------------\n"
	print "Testing check_is_dataLogger:"
	print "Calling check_is_dataLogger on instance: " , check_is_dataLogger(tLogger1)
	print "Calling check_is_dataLogger on wrong instance: " , check_is_dataLogger(fourVectors.fourVector())
	print "Calling check_is_dataLogger on 1.055: " , check_is_dataLogger(1.055)
	print "Calling check_is_dataLogger on 'word': " , check_is_dataLogger('word')
	tResults = [check_is_dataLogger(tLogger1),check_is_dataLogger(fourVectors.fourVector())]
	tResults += [check_is_dataLogger(1.055),check_is_dataLogger('word')]
	if (sum(tResults) == 1):
		print "\nTest successful!"
	else:
		print "\nTest failed!"
	print "\nFinished testing check_is_dataLogger."
	assertions.pause(__name__)

	##Test dataLogger class:##
	print "\n----------------------------------------------------------------------"
	print "----------------------------------------------------------------------\n"
	print "/////////////////////////"
예제 #26
0
	print "----------------------------------------------------------------------\n"
	print "////////////////////////"
	print "Testing particles module:"
	print "////////////////////////"
	assertions.pause(__name__)

	##Setup here:##
	print "\nGenerating test values..."
	##Generate random test four-vectors:##
	tFourVectors = {'a':None,'b':None,'c':None,'d':None}
	for tFourVector in tFourVectors:
		tX0 = random.randrange(20)
		tX1 = random.randrange(20)
		tX2 = random.randrange(20)
		tX3 = random.randrange(20)
		tFourVectors[tFourVector] = fourVectors.fourVector(tX0,tX1,tX2,tX3)
	tZeroParticle = particle(3)
	tParticle1 = particle(2,tFourVectors['a'].copy(),[5,6],[7,8],[51,52],-1)
	tParticle2 = particle(1,tFourVectors['b'].copy(),[0,0],[0,0],[0,0],-1)
	tParticle3 = particle('photon',tFourVectors['c'].copy())
	tParticle4 = tZeroParticle.copy()
	tParticle4.set_four_momentum(tParticle1.get_four_momentum())
	tP1C = tParticle1.copy()
	tParticle5 = particle(2,tFourVectors['a'].copy(),[5,6],[7,8],[51,52],-1)
	tQuark1 = particle(1,tFourVectors['a'].copy())
	tQuark2FourVector = tFourVectors['a'].copy()
	tQuark2FourVector *= 2
	tGluon2FourVector = tQuark2FourVector.copy()
	tQuark2 = particle(2,tQuark2FourVector)
	tGluon1 = particle(21,tFourVectors['a'].copy())
	tGluon2 = particle(21,tGluon2FourVector)
예제 #27
0
	import particles

	##Begin testing:##
	print "\n----------------------------------------------------------------------"
	print "----------------------------------------------------------------------\n"
	print "/////////////////////////////////"
	print "Testing resultsContainers module:"
	print "/////////////////////////////////"
	assertions.pause(__name__)
	
	##Setup here:##
	print "\nGenerating test values..."
	##Generate random test four-vectors:##
	testFourVectors = {'a':None,'b':None,'c':None,'d':None,'e':None}
	##Prevent the random vectors being the same as can't boost into frame of massless particle.
	testVector1, testVector2 = fourVectors.fourVector(0,0,0,0), fourVectors.fourVector(0,0,0,0)
	selectionFinished = False
	while (not selectionFinished):
		for testFourVector in testFourVectors:
			x1 = random.randrange(1,100)
			x2 = random.randrange(0,100)
			x3 = random.randrange(0,100)
			##Make them massless.
			x0 = math.sqrt((x1*x1) + (x2*x2) +(x3*x3))
			testFourVectors[testFourVector] = fourVectors.fourVector(x0,x1,x2,x3)
		testVector1 = testFourVectors['a'].copy()
		testVector2 = testFourVectors['b'].copy()
		testVector3 = testFourVectors['c'].copy()
		testVector4 = testFourVectors['d'].copy()
		testVector5 = testFourVectors['e'].copy()
		##Want five independent energy-momentum four-vectors.
예제 #28
0
    print "///////////////////////////"
    print "Testing dataLoggers module:"
    print "///////////////////////////"
    assertions.pause(__name__)

    ##Setup here:##
    tLogger1 = dataLogger()
    tNumIts = 1000000

    ##Test check_is_dataLogger:##
    print "\n--------------------------------------------------\n"
    print "Testing check_is_dataLogger:"
    print "Calling check_is_dataLogger on instance: ", check_is_dataLogger(
        tLogger1)
    print "Calling check_is_dataLogger on wrong instance: ", check_is_dataLogger(
        fourVectors.fourVector())
    print "Calling check_is_dataLogger on 1.055: ", check_is_dataLogger(1.055)
    print "Calling check_is_dataLogger on 'word': ", check_is_dataLogger(
        'word')
    tResults = [
        check_is_dataLogger(tLogger1),
        check_is_dataLogger(fourVectors.fourVector())
    ]
    tResults += [check_is_dataLogger(1.055), check_is_dataLogger('word')]
    if (sum(tResults) == 1):
        print "\nTest successful!"
    else:
        print "\nTest failed!"
    print "\nFinished testing check_is_dataLogger."
    assertions.pause(__name__)
예제 #29
0
    import fourVectors

    ##Begin testing:##
    print "\n----------------------------------------------------------------------"
    print "----------------------------------------------------------------------\n"
    print "///////////////////////"
    print "Testing dipoles module:"
    print "///////////////////////"
    assertions.pause(__name__)

    ##Setup here:##
    print "\nGenerating test values..."
    ##Generate random test four-vectors:##
    testFourVectors1 = {'a': None, 'b': None}
    ##Prevent the random vectors being the same as can't boost into frame of massless particle.
    testVector1, testVector2 = fourVectors.fourVector(
        0, 0, 0, 0), fourVectors.fourVector(0, 0, 0,
                                            0)  ##Required to start while loop.
    while (
        (testVector1 == testVector2) or
        (not fourVectors.check_different_direction(testVector1, testVector2))):
        for testFourVector in testFourVectors1:
            x1 = random.randrange(1, 10) / 10.0
            x2 = random.randrange(0, int(math.sqrt(1 - (x1**2)) * 10)) / 10.0
            x3 = random.randrange(0, int(math.sqrt(1 - (x2**2)) * 10)) / 10.0
            ##Make them massless.
            x0 = math.sqrt((x1 * x1) + (x2 * x2) + (x3 * x3))
            testFourVectors1[testFourVector] = fourVectors.fourVector(
                x0, x1, x2, x3)
        testVector1 = testFourVectors1['a'].copy()
        testVector2 = testFourVectors1['b'].copy()
    ##Generate set 2:
예제 #30
0
    import particles

    ##Begin testing:##
    print "\n----------------------------------------------------------------------"
    print "----------------------------------------------------------------------\n"
    print "/////////////////////////////////"
    print "Testing resultsContainers module:"
    print "/////////////////////////////////"
    assertions.pause(__name__)

    ##Setup here:##
    print "\nGenerating test values..."
    ##Generate random test four-vectors:##
    testFourVectors = {'a': None, 'b': None, 'c': None, 'd': None, 'e': None}
    ##Prevent the random vectors being the same as can't boost into frame of massless particle.
    testVector1, testVector2 = fourVectors.fourVector(
        0, 0, 0, 0), fourVectors.fourVector(0, 0, 0, 0)
    selectionFinished = False
    while (not selectionFinished):
        for testFourVector in testFourVectors:
            x1 = random.randrange(1, 100)
            x2 = random.randrange(0, 100)
            x3 = random.randrange(0, 100)
            ##Make them massless.
            x0 = math.sqrt((x1 * x1) + (x2 * x2) + (x3 * x3))
            testFourVectors[testFourVector] = fourVectors.fourVector(
                x0, x1, x2, x3)
        testVector1 = testFourVectors['a'].copy()
        testVector2 = testFourVectors['b'].copy()
        testVector3 = testFourVectors['c'].copy()
        testVector4 = testFourVectors['d'].copy()
        testVector5 = testFourVectors['e'].copy()