def do_add(self, line, *args, **opt): args = self.split_arg(line) # Check the validity of the arguments self.check_add(args) if args[0] == 'model': return self.add_model(args[1:]) elif args[0] != 'process': raise self.InvalidCmd( "The add command can only be used with process or model") else: line = ' '.join(args[1:]) proc_type = self.extract_process_type(line) if proc_type[1] not in ['real', 'LOonly']: run_interface.check_compiler(self.options, block=False) self.validate_model(proc_type[1]) #now generate the amplitudes as usual #self.options['group_subprocesses'] = 'False' collect_mirror_procs = False ignore_six_quark_processes = self.options['ignore_six_quark_processes'] if ',' in line: myprocdef, line = mg_interface.MadGraphCmd.extract_decay_chain_process( self, line) if myprocdef.are_decays_perturbed(): raise MadGraph5Error("Decay processes cannot be perturbed") else: myprocdef = mg_interface.MadGraphCmd.extract_process(self, line) self.proc_validity(myprocdef, 'aMCatNLO_%s' % proc_type[1]) # if myprocdef['perturbation_couplings']!=['QCD']: # message = ""FKS for reals only available in QCD for now, you asked %s" \ # % ', '.join(myprocdef['perturbation_couplings'])" # logger.info("%s. Checking for loop induced") # new_line = ln # # # raise self.InvalidCmd("FKS for reals only available in QCD for now, you asked %s" \ # % ', '.join(myprocdef['perturbation_couplings'])) try: self._fks_multi_proc.add( fks_base.FKSMultiProcess(myprocdef, collect_mirror_procs, ignore_six_quark_processes, OLP=self.options['OLP'])) except AttributeError: self._fks_multi_proc = fks_base.FKSMultiProcess( myprocdef, collect_mirror_procs, ignore_six_quark_processes, OLP=self.options['OLP'])
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_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_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 do_generate(self, line, *args, **opts): argss = cmd.Cmd.split_arg(line) # Make sure to switch to the right interface. if len(argss) >= 1: proc_line = ' '.join(argss[1:]) (type, nlo_mode, orders) = self.extract_process_type(proc_line) if type == 'NLO': if not nlo_mode in self._valid_nlo_modes: raise self.InvalidCmd( \ 'The NLO mode %s is not valid. Please chose one among: %s' \ % (nlo_mode, ' '.join(self._valid_nlo_modes))) elif nlo_mode in ['all', 'real', 'LOonly']: self._fks_multi_proc = fks_base.FKSMultiProcess() self.change_principal_cmd('aMC@NLO') elif nlo_mode == 'virt' or nlo_mode == 'virtsqr': self.change_principal_cmd('MadLoop') else: self.change_principal_cmd('MadGraph') return self.cmd.do_generate(self, line, *args, **opts)
def do_add(self, line, *args, **opt): args = self.split_arg(line) # Check the validity of the arguments self.check_add(args) if args[0] == 'model': return self.add_model(args[1:]) elif args[0] != 'process': raise self.InvalidCmd( "The add command can only be used with process or model") else: line = ' '.join(args[1:]) proc_type = self.extract_process_type(line) if proc_type[1] not in ['real', 'LOonly']: run_interface.check_compiler(self.options, block=False) #validate_model will reset self._generate_info; to avoid #this store it geninfo = self._generate_info self.validate_model(proc_type[1], coupling_type=proc_type[2]) self._generate_info = geninfo #now generate the amplitudes as usual #self.options['group_subprocesses'] = 'False' collect_mirror_procs = False ignore_six_quark_processes = self.options['ignore_six_quark_processes'] if ',' in line: myprocdef, line = mg_interface.MadGraphCmd.extract_decay_chain_process( self, line) if myprocdef.are_decays_perturbed(): raise MadGraph5Error("Decay processes cannot be perturbed") else: myprocdef = mg_interface.MadGraphCmd.extract_process(self, line) self.proc_validity(myprocdef, 'aMCatNLO_%s' % proc_type[1]) self._curr_proc_defs.append(myprocdef) # if myprocdef['perturbation_couplings']!=['QCD']: # message = ""FKS for reals only available in QCD for now, you asked %s" \ # % ', '.join(myprocdef['perturbation_couplings'])" # logger.info("%s. Checking for loop induced") # new_line = ln # # # raise self.InvalidCmd("FKS for reals only available in QCD for now, you asked %s" \ # % ', '.join(myprocdef['perturbation_couplings'])) ## # if the new nlo process generation mode is enabled, the number of cores to be # used has to be passed # ncores_for_proc_gen has the following meaning # 0 : do things the old way # > 0 use ncores_for_proc_gen # -1 : use all cores if self.options['low_mem_multicore_nlo_generation']: if self.options['nb_core']: self.ncores_for_proc_gen = int(self.options['nb_core']) else: self.ncores_for_proc_gen = -1 else: self.ncores_for_proc_gen = 0 # this is the options dictionary to pass to the FKSMultiProcess fks_options = { 'OLP': self.options['OLP'], 'ignore_six_quark_processes': self.options['ignore_six_quark_processes'], 'ncores_for_proc_gen': self.ncores_for_proc_gen } try: self._fks_multi_proc.add( fks_base.FKSMultiProcess(myprocdef, fks_options)) except AttributeError: self._fks_multi_proc = fks_base.FKSMultiProcess( myprocdef, fks_options)
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)