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_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 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_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_comparison_for_multiprocess(self): """Test check process for multiprocess""" myleglist = base_objects.MultiLegList() p = [1, 2, -1, -2] myleglist.append(base_objects.MultiLeg({'ids': p, 'state': False})) myleglist.append(base_objects.MultiLeg({'ids': p, 'state': False})) myleglist.append(base_objects.MultiLeg({'ids': p})) myleglist.append(base_objects.MultiLeg({'ids': p})) myproc = base_objects.ProcessDefinition({ 'legs': myleglist, 'model': self.base_model, 'orders': { 'QED': 0 } }) process_checks.clean_added_globals(process_checks.ADDED_GLOBAL) comparisons, used_aloha = process_checks.check_processes(myproc) goal_value_len = [8, 2] for i, comparison in enumerate(comparisons): self.assertEqual(len(comparison['values']), goal_value_len[i]) self.assertTrue(comparison['passed']) comparisons = process_checks.check_lorentz(myproc) nb_fail = process_checks.output_lorentz_inv(comparisons, output='fail') self.assertEqual(0, nb_fail) #check number of helicities/jamp nb_hel = [] nb_jamp = [] for one_comp in comparisons: if one_comp['results'] != 'pass': nb_hel.append(len(one_comp['results'][0]['jamp'])) nb_jamp.append(len(one_comp['results'][0]['jamp'][0])) self.assertEqual(nb_hel, [16, 16]) self.assertEqual(nb_jamp, [2, 2]) for i, comparison in enumerate(comparisons): if i == 2: self.assertEqual(comparison['results'], 'pass') continue else: nb_fail = process_checks.output_lorentz_inv([comparison], output='fail') self.assertEqual(0, nb_fail)
def test_generate_virtuals_single_process(self): """checks that the virtuals are correctly generated for a single process""" 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})) myproc1 = MG.ProcessDefinition({'legs':myleglist, 'model':self.mymodel, 'orders': {'QED': 0}, 'perturbation_couplings':['QCD'], 'NLO_mode': 'real'}) myproc2 = MG.ProcessDefinition({'legs':myleglist, 'model':self.mymodel, 'orders': {'QED': 0}, 'perturbation_couplings':['QCD'], 'NLO_mode': 'all'}) my_process_definitions1 = MG.ProcessDefinitionList([myproc1]) my_process_definitions2 = MG.ProcessDefinitionList([myproc2]) # without virtuals myfksmulti1 = fks_base.FKSMultiProcess(\ {'process_definitions': my_process_definitions1}) # with wirtuals myfksmulti2 = fks_base.FKSMultiProcess(\ {'process_definitions': my_process_definitions2}) self.assertEqual(myfksmulti1['born_processes'][0].virt_amp, None) #there should be 4 virt_amps self.assertNotEqual(myfksmulti2['born_processes'][0].virt_amp, None) self.assertEqual([l['id'] for l in \ myfksmulti2['born_processes'][0].virt_amp.get('process').get('legs')], \ [2,-2,2,-2])
def setUp(self): self.mymodel = import_ufo.import_model( pjoin(MG5DIR,'tests','input_files','LoopSMTest'), prefix=True, complex_mass_scheme = False ) self.mymodel.pass_particles_name_in_mg_default() # Setting up the process p p > h j j and its subtraction self.mylegs = base_objects.MultiLegList([ base_objects.MultiLeg( {'ids': [1,2,-1,-2,21], 'state': base_objects.Leg.INITIAL}), base_objects.MultiLeg( {'ids': [1,2,-1,-2,21], 'state': base_objects.Leg.INITIAL}), base_objects.MultiLeg( {'ids': [22], 'state': base_objects.Leg.FINAL}), base_objects.MultiLeg( {'ids': [21,1,-1,2,-2], 'state': base_objects.Leg.FINAL}) ]) self.myprocdef = base_objects.ProcessDefinition({ 'legs': self.mylegs, 'model': self.mymodel, 'split_orders': ['QCD','QED'] }) # The general accessor with the Born ME registered self.all_born_MEs_accessor = accessors.MEAccessorDict() # Generate only Born LO contributions with misc.TMP_directory(debug=False) as tmp_path: # Generate the output for this. self.madgraph_cmd = cmd.MasterCmd(main='MadGraph') self.madgraph_cmd._curr_model = self.mymodel self.madgraph_cmd.reset_interface_before_new_generation() self.madgraph_cmd._export_dir = pjoin(tmp_path,'ME7ContributionTest_LO') # Generate contributions generation_options = {'ME7_definition': True, 'diagram_filter': False, 'LO': True, 'NNLO': [], 'NNNLO': [], 'optimize': False, 'NLO': [], 'loop_induced': [], 'ignore_contributions' : [], 'beam_types': ['auto', 'auto'], 'loop_filter' : None, 'process_definitions' : {}} self.madgraph_cmd.add_contributions(self.myprocdef, generation_options) LO_contributions = self.madgraph_cmd._curr_contribs LO_contributions.apply_method_to_all_contribs( 'generate_amplitudes', log='Generate diagrams for') self.exporter = export_ME7.ME7Exporter( self.madgraph_cmd, False, group_subprocesses=True ) self.exporter.pass_information_from_cmd(self.madgraph_cmd) self.exporter.copy_template(self.madgraph_cmd._curr_model) self.exporter.export(True, args=[]) # We want to finalize and output the model for the Born, because need to # register its MEs in the accessor. self.exporter.finalize(['nojpeg'], self.madgraph_cmd.history) self.LO_contributions = self.madgraph_cmd._curr_contribs # Add the Born ME accessors to the dictionary self.LO_contributions[0].add_ME_accessors( self.all_born_MEs_accessor, pjoin(tmp_path,'ME7ContributionTest_LO') ) # Generate all NLO contributions with misc.TMP_directory(debug=False) as tmp_path: # Generate the output for this. self.madgraph_cmd = cmd.MasterCmd(main='MadGraph') self.madgraph_cmd._curr_model = self.mymodel self.madgraph_cmd.reset_interface_before_new_generation() self.madgraph_cmd._export_dir = pjoin(tmp_path,'ME7ContributionTest_LO') # Generate contributions generation_options = {'ME7_definition': True, 'diagram_filter': False, 'LO': True, 'NNLO': [], 'NNNLO': [], 'optimize': False, 'NLO': ['QCD'], 'loop_induced': [], 'ignore_contributions' : [], 'beam_types': ['auto', 'auto'], 'loop_filter' : None, 'process_definitions' : {}, } self.madgraph_cmd.add_contributions(self.myprocdef, generation_options) self.madgraph_cmd._curr_contribs.apply_method_to_all_contribs( 'generate_amplitudes', log='Generate diagrams for') self.exporter = export_ME7.ME7Exporter( self.madgraph_cmd, False, group_subprocesses=True ) self.exporter.pass_information_from_cmd(self.madgraph_cmd) self.exporter.copy_template(self.madgraph_cmd._curr_model) self.exporter.export(True, args=[]) # The export above was enough to have fully functional contributions to test # self.exporter.finalize(['nojpeg'], self.madgraph_cmd.history) self.NLO_contributions = self.madgraph_cmd._curr_contribs
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)