def test_fks_helas_multi_process_ppz_loonly(self): """tests the LOonly NLO mode. In particular test that no reals are generated and that the get_nexternal_ninitial funciton returns the values as if the reals were generated. """ p = [21, 1, 2, 3, 4, -1, -2, -3, -4] z_leg = MG.MultiLeg({'ids': [23], 'state': True}) p_leg = MG.MultiLeg({ 'ids': p, 'state': False }) # Define the multiprocess my_multi_leglist = MG.MultiLegList([copy.copy(leg) for leg in [p_leg] * 2] \ + MG.MultiLegList([z_leg])) my_process_definition = MG.ProcessDefinition({ \ 'orders': {'QED':1}, 'legs': my_multi_leglist, 'perturbation_couplings': ['QCD'], 'NLO_mode': 'LOonly', 'model': self.mymodel}) my_process_definitions = MG.ProcessDefinitionList(\ [my_process_definition]) my_multi_process = fks_base.FKSMultiProcess(\ {'process_definitions': my_process_definitions}) my_helas_mp = fks_helas.FKSHelasMultiProcess(my_multi_process, gen_color=True) for me in my_helas_mp['matrix_elements']: # self.assertEqual(len(me.real_processes), 0) self.assertEqual(me.get_nexternal_ninitial(), (4, 2))
def test_generate_virtuals_helas_matrix_element(self): """checks that the virtuals are correctly generated for a FKShelasMatrixElement""" myleglist = MG.MultiLegList() # test process is u u~ > u u~ myleglist.append(MG.MultiLeg({'ids':[2], 'state':False})) myleglist.append(MG.MultiLeg({'ids':[-2], 'state':False})) myleglist.append(MG.MultiLeg({'ids':[2], 'state':True})) myleglist.append(MG.MultiLeg({'ids':[-2], 'state':True})) myproc = MG.ProcessDefinition({'legs':myleglist, 'model':self.mymodel, 'orders': {'QED': 0}, 'perturbation_couplings':['QCD'], 'NLO_mode': 'all'}) my_process_definitions = MG.ProcessDefinitionList([myproc]) myfksmulti = fks_base.FKSMultiProcess(\ {'process_definitions': my_process_definitions}) myfksmulti.generate_virtuals() myfksme = fks_helas.FKSHelasMultiProcess(myfksmulti) self.assertNotEqual(myfksme['matrix_elements'][0].virt_matrix_element, None)
def test_fks_helas_multi_process_ppz(self): """tests the correct recycling of color infos for MEs with the same color flow (e.g. uu~>z and dd~>z) """ p = [21, 1, 2, 3, 4, -1, -2, -3, -4] z_leg = MG.MultiLeg({'ids': [23], 'state': True}) p_leg = MG.MultiLeg({ 'ids': p, 'state': False }) # Define the multiprocess my_multi_leglist = MG.MultiLegList([copy.copy(leg) for leg in [p_leg] * 2] \ + MG.MultiLegList([z_leg])) my_process_definition = MG.ProcessDefinition({ \ 'orders': {'QED':1}, 'legs': my_multi_leglist, 'perturbation_couplings': ['QCD'], 'NLO_mode': 'real', 'model': self.mymodel}) my_process_definitions = MG.ProcessDefinitionList(\ [my_process_definition]) my_multi_process = fks_base.FKSMultiProcess(\ {'process_definitions': my_process_definitions}) my_helas_mp = fks_helas.FKSHelasMultiProcess(my_multi_process, gen_color=True) self.assertEqual(my_helas_mp['has_isr'], True) self.assertEqual(my_helas_mp['has_fsr'], False) for me in my_helas_mp['matrix_elements']: self.assertEqual(len(me.born_matrix_element['color_basis']), 1) self.assertEqual(me.get_nexternal_ninitial(), (4, 2))
def generate_matrix_elements(self, group=False): """Helper function to generate the matrix elements before exporting""" # Sort amplitudes according to number of diagrams, # to get most efficient multichannel output self._curr_amps.sort(lambda a1, a2: a2.get_number_of_diagrams() - \ a1.get_number_of_diagrams()) cpu_time1 = time.time() ndiags = 0 if not self._curr_matrix_elements.get_matrix_elements(): if group: raise MadGraph5Error, "Cannot group subprocesses when "+\ "exporting to NLO" else: self._curr_matrix_elements = \ fks_helas.FKSHelasMultiProcess(\ self._fks_multi_proc, loop_optimized= self.options['loop_optimized_output']) ndiags = sum([len(me.get('diagrams')) for \ me in self._curr_matrix_elements.\ get_matrix_elements()]) # assign a unique id number to all process and # generate a list of possible PDF combinations uid = 0 initial_states = [] for me in self._curr_matrix_elements.get_matrix_elements(): uid += 1 # update the identification number me.get('processes')[0].set('uid', uid) try: initial_states.append(sorted(list(set((p.get_initial_pdg(1),p.get_initial_pdg(2)) for \ p in me.born_matrix_element.get('processes'))))) except IndexError: initial_states.append(sorted(list(set((p.get_initial_pdg(1)) for \ p in me.born_matrix_element.get('processes'))))) for fksreal in me.real_processes: # Pick out all initial state particles for the two beams try: initial_states.append(sorted(list(set((p.get_initial_pdg(1),p.get_initial_pdg(2)) for \ p in fksreal.matrix_element.get('processes'))))) except IndexError: initial_states.append(sorted(list(set((p.get_initial_pdg(1)) for \ p in fksreal.matrix_element.get('processes'))))) # remove doubles from the list checked = [] for e in initial_states: if e not in checked: checked.append(e) initial_states = checked self._curr_matrix_elements.set('initial_states', initial_states) cpu_time2 = time.time() return ndiags, cpu_time2 - cpu_time1
def test_fks_ppzz_in_RS(self): """""" p = [21, 1, 2, 3, -1, -2, -3 ] z_leg = MG.MultiLeg({'ids':[23], 'state': True}) p_leg = MG.MultiLeg({'ids': p, 'state': False}); my_multi_leglist = MG.MultiLegList([copy.copy(leg) for leg in [p_leg] * 2] \ + MG.MultiLegList([z_leg, z_leg])) mymodel = import_ufo.import_model('RS') my_process_definition = MG.ProcessDefinition({ \ 'orders': {'WEIGHTED': 4}, 'legs': my_multi_leglist, 'perturbation_couplings': ['QCD'], 'NLO_mode': 'real', 'model': mymodel}) my_process_definitions = MG.ProcessDefinitionList(\ [my_process_definition]) my_multi_process = fks_base.FKSMultiProcess(\ {'process_definitions': my_process_definitions}) for born in my_multi_process['born_processes']: born_pdg_list = [l['id'] for l in born.born_proc['legs']] if born_pdg_list[0] == 21: # gg initiated self.assertEqual(len(born.born_amp['diagrams']), 1) for amp in born.real_amps: if amp.pdgs[0] != 21 or amp.pdgs[1] != 21: self.assertEqual(len(amp.amplitude['diagrams']), 12) else: self.assertEqual(len(amp.amplitude['diagrams']), 4) else: # qq initiated self.assertEqual(len(born.born_amp['diagrams']), 4) for amp in born.real_amps: self.assertEqual(len(amp.amplitude['diagrams']), 12) my_helas_mp = fks_helas.FKSHelasMultiProcess(my_multi_process, gen_color = False) for born in my_helas_mp['matrix_elements']: born_pdg_list = [l['id'] for l in born.born_matrix_element['base_amplitude']['process']['legs']] if born_pdg_list[0] == 21: # gg initiated self.assertEqual(len(born.born_matrix_element['diagrams']), 1) for real in born.real_processes: pdgs = [l['id'] for l in real.matrix_element['base_amplitude']['process']['legs']] if pdgs[0] != 21 or pdgs[1] != 21: self.assertEqual(len(real.matrix_element['diagrams']), 12) else: self.assertEqual(len(real.matrix_element['diagrams']), 4) else: # qq initiated self.assertEqual(len(born.born_matrix_element['diagrams']), 4) for real in born.real_processes: self.assertEqual(len(real.matrix_element['diagrams']), 12)
def test_fks_helas_multi_process_pptt(self): """tests the correct initialization of a FKSHelasMultiProcess, given an FKSMultiProcess. This test also checks that each real process corresponds to the correct number of FKS configurations. The p p > t t~ process is studied """ p = [21, 1, 2, 3, 4, -1, -2, -3, -4] t = MG.MultiLeg({'ids': [6], 'state': True}) tx = MG.MultiLeg({'ids': [-6], 'state': True}) p_leg = MG.MultiLeg({ 'ids': p, 'state': False }) # Define the multiprocess my_multi_leglist = MG.MultiLegList([copy.copy(leg) for leg in [p_leg] * 2] \ + MG.MultiLegList([t, tx])) my_process_definition = MG.ProcessDefinition({ \ 'orders': {'WEIGHTED': 2}, 'legs': my_multi_leglist, 'perturbation_couplings': ['QCD'], 'NLO_mode': 'real', 'model': self.mymodel}) my_process_definitions = MG.ProcessDefinitionList(\ [my_process_definition]) my_multi_process = fks_base.FKSMultiProcess(\ {'process_definitions': my_process_definitions}) my_helas_mp = fks_helas.FKSHelasMultiProcess(my_multi_process, False) #there are 3 (gg uux uxu initiated) borns self.assertEqual(len(my_helas_mp.get('matrix_elements')), 3) # and 25 real matrix elements self.assertEqual(len(my_helas_mp.get('real_matrix_elements')), 25) # the first me is gg tt, with 5 different real emissions self.assertEqual( len(my_helas_mp.get('matrix_elements')[0].real_processes), 5) # the first real emission corresponds to gg ttxg, with 4 different configs self.assertEqual( len( my_helas_mp.get('matrix_elements') [0].real_processes[0].matrix_element['processes']), 1) self.assertEqual( len( my_helas_mp.get('matrix_elements') [0].real_processes[0].fks_infos), 4) # for the 2nd to the 5th real emissions, corresponding to the q g > t tx g and crossings # there is only one config per processes, and the 4 quark flavours should be combined together for real in my_helas_mp.get('matrix_elements')[0].real_processes[1:]: self.assertEqual(len(real.matrix_element['processes']), 4) self.assertEqual(len(real.fks_infos), 1) # the 2nd me is uux tt, with 3 different real emissions self.assertEqual( len(my_helas_mp.get('matrix_elements')[1].real_processes), 3) # the first real emission corresponds to qqx ttxg, with 4 different configs self.assertEqual( len( my_helas_mp.get('matrix_elements') [1].real_processes[0].matrix_element['processes']), 4) self.assertEqual( len( my_helas_mp.get('matrix_elements') [1].real_processes[0].fks_infos), 4) # the 2nd and 3rd real emission corresponds to qg ttxq (and gqx...), with 1 config self.assertEqual( len( my_helas_mp.get('matrix_elements') [1].real_processes[1].matrix_element['processes']), 4) self.assertEqual( len( my_helas_mp.get('matrix_elements') [1].real_processes[1].fks_infos), 1) self.assertEqual( len( my_helas_mp.get('matrix_elements') [1].real_processes[2].matrix_element['processes']), 4) self.assertEqual( len( my_helas_mp.get('matrix_elements') [1].real_processes[2].fks_infos), 1) # the 3rd me is uxu tt, with 3 different real emissions self.assertEqual( len(my_helas_mp.get('matrix_elements')[2].real_processes), 3) # the first real emission corresponds to qxq ttxg, with 4 different configs self.assertEqual( len( my_helas_mp.get('matrix_elements') [2].real_processes[0].matrix_element['processes']), 4) self.assertEqual( len( my_helas_mp.get('matrix_elements') [2].real_processes[0].fks_infos), 4) # the 2nd and 3rd real emission corresponds to qxg ttxqx (and gq...), with 1 config self.assertEqual( len( my_helas_mp.get('matrix_elements') [2].real_processes[1].matrix_element['processes']), 4) self.assertEqual( len( my_helas_mp.get('matrix_elements') [2].real_processes[1].fks_infos), 1) self.assertEqual( len( my_helas_mp.get('matrix_elements') [2].real_processes[2].matrix_element['processes']), 4) self.assertEqual( len( my_helas_mp.get('matrix_elements') [2].real_processes[2].fks_infos), 1)
def test_fks_helas_multi_process_ppwj(self): """tests the correct initialization of a FKSHelasMultiProcess, given an FKSMultiProcess. This also checks that, when combining 2 FKSHelasProcess using the add_process function, the real emissions are combined consistently. The p p > w+ j process is studied """ p = [21, 1, 2, 3, 4, -1, -2, -3, -4] w_leg = MG.MultiLeg({'ids': [24], 'state': True}) j_leg = MG.MultiLeg({'ids': p, 'state': True}) p_leg = MG.MultiLeg({ 'ids': p, 'state': False }) # Define the multiprocess my_multi_leglist = MG.MultiLegList([copy.copy(leg) for leg in [p_leg] * 2] \ + MG.MultiLegList([w_leg, j_leg])) my_process_definition = MG.ProcessDefinition({ \ 'orders': {'WEIGHTED': 3}, 'legs': my_multi_leglist, 'perturbation_couplings': ['QCD'], 'NLO_mode': 'real', 'model': self.mymodel}) my_process_definitions = MG.ProcessDefinitionList(\ [my_process_definition]) my_multi_process = fks_base.FKSMultiProcess(\ {'process_definitions': my_process_definitions}) my_helas_mp = fks_helas.FKSHelasMultiProcess(my_multi_process, gen_color=False) #there are 6 borns self.assertEqual(len(my_helas_mp.get('matrix_elements')), 6) #born processes are initiated by : gu, gdx, ug, udx, dxg, dxu n_real_processes = [8, 8, 8, 6, 8, 6] real_subprocesses = \ [ [ #these are for gu -initiated born [ [21,2,24,1,21], [21,4,24,3,21] ], #subrpocs for real 1 [ [-1,2,24,1,-1], [-3,4,24,3,-3] ], #subrpocs for real 2 [ [1,2,24,1,1], [3,4,24,3,3] ], #subrpocs for real 3 [ [-3,2,24,1,-3], [-4,2,24,1,-4], [-1,4,24,3,-1], [-2,4,24,3,-2] ], #subrpocs for real 4 [ [3,2,24,1,3], [4,2,24,1,4], [1,4,24,3,1], [2,4,24,3,2] ], #subrpocs for real 5 [ [-2,2,24,1,-2], [-4,4,24,3,-4] ], #subrpocs for real 6 [ [2,2,24,1,2], [4,4,24,3,4] ], #subrpocs for real 7 [ [21,21,24,1,-2], [21,21,24,3,-4] ]#subrpocs for real 8 ],[ #these are for gdx-initiated born [ [21,-1,24,-2,21], [21,-3,24,-4,21] ], #subrpocs for real 1 [ [-1,-1,24,-2,-1], [-3,-3,24,-4,-3] ], #subrpocs for real 2 [ [1,-1,24,1,-2], [3,-3,24,3,-4] ], #subrpocs for real 3 [ [-3,-1,24,-2,-3], [-4,-1,24,-2,-4], [-1,-3,24,-4,-1], [-2,-3,24,-4,-2] ], #subrpocs for real 4 [ [3,-1,24,3,-2], [4,-1,24,4,-2], [1,-3,24,1,-4], [2,-3,24,2,-4] ], #subrpocs for real 5 [ [-2,-1,24,-2,-2], [-4,-3,24,-4,-4] ], #subrpocs for real 6 [ [2,-1,24,2,-2], [4,-3,24,4,-4] ], #subrpocs for real 7 [ [21,21,24,1,-2], [21,21,24,3,-4] ]#subrpocs for real 8 ],[ #these are for ug -initiated born [ [2,21,24,1,21], [4,21,24,3,21] ], #subrpocs for real 1 [ [21,21,24,1,-2], [21,21,24,3,-4] ],#subrpocs for real 2 [ [2,-1,24,1,-1], [4,-3,24,3,-3] ], #subrpocs for real 3 [ [2,1,24,1,1], [4,3,24,3,3] ], #subrpocs for real 4 [ [2,-3,24,1,-3], [2,-4,24,1,-4], [4,-1,24,3,-1], [4,-2,24,3,-2] ], #subrpocs for real 5 [ [2,3,24,1,3], [2,4,24,1,4], [4,1,24,3,1], [4,2,24,3,2] ], #subrpocs for real 6 [ [2,-2,24,1,-2], [4,-4,24,3,-4] ], #subrpocs for real 7 [ [2,2,24,1,2], [4,4,24,3,4] ] #subrpocs for real 8 ],[ #these are for udx-initiated born [ [2,-1,24,21,21], [4,-3,24,21,21] ], #subrpocs for real 1 [ [21,-1,24,-2,21], [21,-3,24,-4,21] ],#subrpocs for real 2 [ [2,21,24,1,21], [4,21,24,3,21] ], #subrpocs for real 3 [ [2,-1,24,1,-1], [4,-3,24,3,-3] ], #subrpocs for real 4 [ [2,-1,24,3,-3], [2,-1,24,4,-4], [4,-3,24,1,-1], [4,-3,24,2,-2] ], #subrpocs for real 5 [ [2,-1,24,2,-2], [4,-3,24,4,-4]] #subrpocs for real 6 ],[ #these are for dxg-initiated born [ [-1,21,24,-2,21], [-3,21,24,-4,21] ], #subrpocs for real 1 [ [21,21,24,1,-2], [21,21,24,3,-4] ],#subrpocs for real 2 [ [-1,-1,24,-2,-1], [-3,-3,24,-4,-3] ], #subrpocs for real 3 [ [-1,1,24,1,-2], [-3,3,24,3,-4] ], #subrpocs for real 4 [ [-1,-3,24,-2,-3], [-1,-4,24,-2,-4], [-3,-1,24,-4,-1], [-3,-2,24,-4,-2] ], #subrpocs for real 5 [ [-1,3,24,3,-2], [-1,4,24,4,-2], [-3,1,24,1,-4], [-3,2,24,2,-4] ], #subrpocs for real 6 [ [-1,-2,24,-2,-2], [-3,-4,24,-4,-4] ], #subrpocs for real 7 [ [-1,2,24,2,-2], [-3,4,24,4,-4] ] #subrpocs for real 8 ],[ #these are for dxu-initiated born [ [-1,2,24,21,21], [-3,4,24,21,21] ], #subrpocs for real 1 [ [21,2,24,1,21], [21,4,24,3,21] ],#subrpocs for real 2 [ [-1,21,24,-2,21], [-3,21,24,-4,21] ], #subrpocs for real 3 [ [-1,2,24,1,-1], [-3,4,24,3,-3] ], #subrpocs for real 4 [ [-1,2,24,3,-3], [-1,2,24,4,-4], [-3,4,24,1,-1], [-3,4,24,2,-2] ], #subrpocs for real 5 [ [-1,2,24,2,-2], [-3,4,24,4,-4]] #subrpocs for real 6 ]] #each born correspond to 2 partonic processes for i, me in enumerate(my_helas_mp.get('matrix_elements')): # gu and gc self.assertEqual(len(me.get('processes')), 2) self.assertEqual(len(me.real_processes), n_real_processes[i]) for j, real in enumerate(me.real_processes): pdgs = [[leg['id'] for leg in proc['legs']] for proc in real.matrix_element['processes']] self.assertEqual(real_subprocesses[i][j], pdgs)