def run(self): """A function to run a shower for the given LHEF file.""" ##For e+e- -> qqBar (massless). __reader = LHEFHandlers.LHEFReader(self.__toLoad) self.__numEvents = __reader.get_number_events() __writer = LHEFHandlers.LHEFShowerWriter(__reader,self.__numEvents) __alertEvery = self.__numEvents/10 if __alertEvery > 1000: ##Slow enough to want to see something is happening! __alertEvery = 1000 elif (__alertEvery == 0): ##i.e < 10 events. __alertEvery = 1 for __eventIndex in range(self.__numEvents): if (__eventIndex%__alertEvery == 0): if (__eventIndex == 0): print "Begin showering...\n" else: print "Showering event", __eventIndex __MEParticle1 = __reader.get_event_particle(__eventIndex,0) __MEParticle2 = __reader.get_event_particle(__eventIndex,1) __EIn = __MEParticle1[0] + __MEParticle2[0] __S123In = kinematics.Sijk([__MEParticle1.get_four_momentum(), __MEParticle2.get_four_momentum()]) __particlesIn = [__MEParticle1,__MEParticle2] __showerParticle1 = __reader.get_event_particle(__eventIndex,2) __showerParticle2 = __reader.get_event_particle(__eventIndex,3) __showeri = showers.qqBarShower(__showerParticle1,__showerParticle2,self.__activeQCodes) __showeri.run_shower() __particlesOut = __showeri.export_results() __EOut = 0.0 __fourVectorsOut = [] for __p in __particlesOut: __ePV = __p.get_four_momentum() __EOut += __ePV[0] __fourVectorsOut.append(__ePV) assert precision.check_numbers_equal(kinematics.Sijk(__fourVectorsOut),__S123In) assert precision.check_numbers_equal(__EIn,__EOut) __trials, __muf2, __mur2 = __reader.get_event_trials(__eventIndex), __reader.get_event_muf2(__eventIndex), __reader.get_event_mur2(__eventIndex) __processID, __weight = __reader.get_event_process_ID(__eventIndex), __reader.get_event_weight(__eventIndex) __scale, __alphaEM = __reader.get_event_scale(__eventIndex), __reader.get_event_alphaEM(__eventIndex) __alphaS = __reader.get_event_alphaS(__eventIndex) __writer.add_event(__trials,__muf2,__mur2,__processID,__weight,__scale,__alphaEM,__alphaS,__particlesIn,__particlesOut) __writer.save() __numGluonsSplit = counters.gluonSplitCounter.counted() print "\nThere were", counters.gluonProdCounter.counted(), "gluons produced!" print "\nThere were", __numGluonsSplit, "gluons split!" print "\nThere were", counters.photonProdCounter.counted(), "photons produced!" print "\nThere were", counters.kPerpProdWarningCounter.counted(), "warnings for E1 or E3 < E2!\n" print "\n---------------------" print "Quark content report:" print "---------------------" __sumPercent = 0.0 for __aQCode in [1,2,3,4,5,6]: __qName = particleData.knownParticles.get_name_from_code(__aQCode) if precision.check_numbers_equal(__numGluonsSplit,0.0): __qPercent = 0.0 else: __qPercent = chains.producedQuarkCodes.output().count(__aQCode)*100.0/__numGluonsSplit __sumPercent += __qPercent print str(__qPercent) + "% are " + __qName + "s." print "This adds up to " + str(__sumPercent) + "%." assertions.pause(__name__)
def run(self): """A function to run the qqBar ME generator approximation.""" ##Initialise writer __writer = LHEFHandlers.LHEFMEWriter('qqBar', self.__numEvents, self.__S123, self.__quarkCodes) __trials, __muf2, __mur2 = 1, self.__S123, self.__S123 __processID, __weight = 0, 1 __scale, __alphaEM = 0.0, 0.0 __alphaS = 0.0 ##Generate and output events. __i, __printEvery = 0, self.__numEvents / 10 if __printEvery > 1000: ##Slow enough to want to see something is happening! __printEvery = 1000 elif (__printEvery == 0): ##i.e < 10 events. __printEvery = 1 while (__i < self.__numEvents): __initial = produce_electron_pair(self.__S123) __final = produce_quark_pair(self.__S123, self.__quarkCodes) __writer.add_event(__trials, __muf2, __mur2, __processID, __weight, __scale, __alphaEM, __alphaS, __initial, __final) if (__i % __printEvery == 0): if (__i == 0): print "\nStart generating..." else: print "Reached event", __i __i += 1 ##Iterate ##End output. print "\nSaving..." __writer.save() assertions.pause(__name__) print "\n---------------------" print "Quark content report:" print "---------------------" __sumPercent = 0.0 for __qIndex, __counter in enumerate(quarkCounters): __qName = particleData.knownParticles.get_name_from_code(__qIndex + 1) __qPercent = __counter.counted() * 100.0 / self.__numEvents __sumPercent += __qPercent print str(__qPercent) + "% are " + __qName + "s." print "This adds up to " + str(__sumPercent) + "%."
def run(self): """A function to run the qqBar ME generator approximation.""" ##Initialise writer __writer = LHEFHandlers.LHEFMEWriter('qqBar',self.__numEvents,self.__S123,self.__quarkCodes) __trials, __muf2, __mur2 = 1, self.__S123, self.__S123 __processID, __weight = 0, 1 __scale, __alphaEM = 0.0,0.0 __alphaS = 0.0 ##Generate and output events. __i, __printEvery = 0, self.__numEvents/10 if __printEvery > 1000: ##Slow enough to want to see something is happening! __printEvery = 1000 elif (__printEvery == 0): ##i.e < 10 events. __printEvery = 1 while (__i < self.__numEvents): __initial = produce_electron_pair(self.__S123) __final = produce_quark_pair(self.__S123,self.__quarkCodes) __writer.add_event(__trials,__muf2,__mur2,__processID,__weight,__scale,__alphaEM,__alphaS,__initial,__final) if (__i%__printEvery == 0): if (__i == 0): print "\nStart generating..." else: print "Reached event", __i __i += 1 ##Iterate ##End output. print "\nSaving..." __writer.save() assertions.pause(__name__) print "\n---------------------" print "Quark content report:" print "---------------------" __sumPercent = 0.0 for __qIndex, __counter in enumerate(quarkCounters): __qName = particleData.knownParticles.get_name_from_code(__qIndex + 1) __qPercent = __counter.counted()*100.0/self.__numEvents __sumPercent += __qPercent print str(__qPercent) + "% are " + __qName + "s." print "This adds up to " + str(__sumPercent) + "%."
##Module test code:## if __name__ == "__main__": ##Import modules required for testing:## import math import random 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
def __ne__(self,other): """A function to check whether two four-vectors are not equal up to the code precision.""" return not self.__eq__(other) ##Module test code:## if __name__ == "__main__": ##Import modules required for testing:## import random ##Begin testing:## print "\n----------------------------------------------------------------------" print "----------------------------------------------------------------------\n" print "///////////////////////////" print "Testing fourVectors 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] = fourVector(tX0,tX1,tX2,tX3) ##~~~~~~~## tFloat = 2.30000 tString = "string" ##~~~~~~~##
def run(self): """A function to run a shower for the given LHEF file.""" ##For e+e- -> qqBar (massless). __reader = LHEFHandlers.LHEFReader(self.__toLoad) self.__numEvents = __reader.get_number_events() __writer = LHEFHandlers.LHEFShowerWriter(__reader, self.__numEvents) __alertEvery = self.__numEvents / 10 if __alertEvery > 1000: ##Slow enough to want to see something is happening! __alertEvery = 1000 elif (__alertEvery == 0): ##i.e < 10 events. __alertEvery = 1 for __eventIndex in range(self.__numEvents): if (__eventIndex % __alertEvery == 0): if (__eventIndex == 0): print "Begin showering...\n" else: print "Showering event", __eventIndex __MEParticle1 = __reader.get_event_particle(__eventIndex, 0) __MEParticle2 = __reader.get_event_particle(__eventIndex, 1) __EIn = __MEParticle1[0] + __MEParticle2[0] __S123In = kinematics.Sijk([ __MEParticle1.get_four_momentum(), __MEParticle2.get_four_momentum() ]) __particlesIn = [__MEParticle1, __MEParticle2] __showerParticle1 = __reader.get_event_particle(__eventIndex, 2) __showerParticle2 = __reader.get_event_particle(__eventIndex, 3) __showeri = showers.qqBarShower(__showerParticle1, __showerParticle2, self.__activeQCodes) __showeri.run_shower() __particlesOut = __showeri.export_results() __EOut = 0.0 __fourVectorsOut = [] for __p in __particlesOut: __ePV = __p.get_four_momentum() __EOut += __ePV[0] __fourVectorsOut.append(__ePV) assert precision.check_numbers_equal( kinematics.Sijk(__fourVectorsOut), __S123In) assert precision.check_numbers_equal(__EIn, __EOut) __trials, __muf2, __mur2 = __reader.get_event_trials( __eventIndex), __reader.get_event_muf2( __eventIndex), __reader.get_event_mur2(__eventIndex) __processID, __weight = __reader.get_event_process_ID( __eventIndex), __reader.get_event_weight(__eventIndex) __scale, __alphaEM = __reader.get_event_scale( __eventIndex), __reader.get_event_alphaEM(__eventIndex) __alphaS = __reader.get_event_alphaS(__eventIndex) __writer.add_event(__trials, __muf2, __mur2, __processID, __weight, __scale, __alphaEM, __alphaS, __particlesIn, __particlesOut) __writer.save() __numGluonsSplit = counters.gluonSplitCounter.counted() print "\nThere were", counters.gluonProdCounter.counted( ), "gluons produced!" print "\nThere were", __numGluonsSplit, "gluons split!" print "\nThere were", counters.photonProdCounter.counted( ), "photons produced!" print "\nThere were", counters.kPerpProdWarningCounter.counted( ), "warnings for E1 or E3 < E2!\n" print "\n---------------------" print "Quark content report:" print "---------------------" __sumPercent = 0.0 for __aQCode in [1, 2, 3, 4, 5, 6]: __qName = particleData.knownParticles.get_name_from_code(__aQCode) if precision.check_numbers_equal(__numGluonsSplit, 0.0): __qPercent = 0.0 else: __qPercent = chains.producedQuarkCodes.output().count( __aQCode) * 100.0 / __numGluonsSplit __sumPercent += __qPercent print str(__qPercent) + "% are " + __qName + "s." print "This adds up to " + str(__sumPercent) + "%." assertions.pause(__name__)