Beispiel #1
0
    def find_fks_j_from_i(self, born_pdg_list): #test written
        """Returns a dictionary with the entries i : [j_from_i], if the born pdgs are in 
        born_pdg_list"""
        fks_j_from_i = {}
        dict = {}
        for i in self.process.get('legs'):
            fks_j_from_i[i.get('number')] = []
            if i.get('state'):
                for j in [l for l in self.process.get('legs') if \
                        l.get('number') != i.get('number')]:
                    ijlist = fks_common.combine_ij(i, j, self.process.get('model'), dict,\
                                                   pert=self.perturbation)
                    for ij in ijlist:
                        born_leglist = fks_common.to_fks_legs(
                                      copy.deepcopy(self.process.get('legs')), 
                                      self.process.get('model'))
                        born_leglist.remove(i)
                        born_leglist.remove(j)
                        born_leglist.insert(ij.get('number') - 1, ij)
                        born_leglist.sort(pert = self.perturbation)
                        if [l['id'] for l in born_leglist] in born_pdg_list:
                            fks_j_from_i[i.get('number')].append(\
                                                    j.get('number'))                                

        self.fks_j_from_i = fks_j_from_i
        return fks_j_from_i
Beispiel #2
0
    def find_fks_j_from_i(self, born_pdg_list): #test written
        """Returns a dictionary with the entries i : [j_from_i], if the born pdgs are in 
        born_pdg_list"""
        fks_j_from_i = {}
        dict = {}
        for i in self.process.get('legs'):
            fks_j_from_i[i.get('number')] = []
            if i.get('state'):
                for j in [l for l in self.process.get('legs') if \
                        l.get('number') != i.get('number')]:
                    ijlist = fks_common.combine_ij(i, j, self.process.get('model'), dict,\
                                                   pert=self.perturbation)
                    for ij in ijlist:
                        born_leglist = fks_common.to_fks_legs(
                                      copy.deepcopy(self.process.get('legs')), 
                                      self.process.get('model'))
                        born_leglist.remove(i)
                        born_leglist.remove(j)
                        born_leglist.insert(ij.get('number') - 1, ij)
                        born_leglist.sort(pert = self.perturbation)
                        if [l['id'] for l in born_leglist] in born_pdg_list:
                            fks_j_from_i[i.get('number')].append(\
                                                    j.get('number'))                                

        self.fks_j_from_i = fks_j_from_i
        return fks_j_from_i
Beispiel #3
0
    def __init__(self, start_proc = None, remove_reals = True):
        """initialization: starts either from an amplitude or a process,
        then init the needed variables.
        remove_borns tells if the borns not needed for integration will be removed
        from the born list (mainly used for testing)"""
                
        self.splittings = {}
        self.reals = []
        self.fks_dirs = []
        self.leglist = []
        self.myorders = {}
        self.pdg_codes = []
        self.colors = []
        self.nlegs = 0
        self.fks_ipos = []
        self.fks_j_from_i = {}
        self.real_amps = []
        self.remove_reals = remove_reals
        self.nincoming = 0
        self.virt_amp = None

        if not remove_reals in [True, False]:
            raise fks_common.FKSProcessError(\
                    'Not valid type for remove_reals in FKSProcess')
        
        if start_proc:
            if isinstance(start_proc, MG.Process):
                self.born_proc = fks_common.sort_proc(start_proc) 
                self.born_amp = diagram_generation.Amplitude(self.born_proc)
            elif isinstance(start_proc, diagram_generation.Amplitude):
                self.born_proc = fks_common.sort_proc(start_proc.get('process'))
                self.born_amp = diagram_generation.Amplitude(self.born_proc)
            else:
                raise fks_common.FKSProcessError(\
                    'Not valid start_proc in FKSProcess')

            self.born_proc.set('legs_with_decays', MG.LegList())

            self.leglist = fks_common.to_fks_legs(
                                    self.born_proc['legs'], self.born_proc['model'])
            self.nlegs = len(self.leglist)
            self.pdg_codes = [leg.get('id') for leg in self.leglist]
            self.colors = [leg.get('color') for leg in self.leglist]
            self.isr = set([leg.get('color') for leg in self.leglist if not leg.get('state')]) != set([1])
            self.fsr = set([leg.get('color') for leg in self.leglist if leg.get('state')]) != set([1])
            for leg in self.leglist:
                if not leg['state']:
                    self.nincoming += 1
            self.orders = self.born_amp['process']['orders']
            # this is for cases in which the user specifies e.g. QED=0
            if sum(self.orders.values()) == 0:
                self.orders = fks_common.find_orders(self.born_amp)
                
            self.ndirs = 0
            for order in self.born_proc.get('perturbation_couplings'):
                self.find_reals(order)
 def set_color_links(self):
     """this function computes and returns the color links, it should be called
     after the initialization and the setting of the color basis"""
     if not self.color_links:
         legs = self.born_matrix_element.get('base_amplitude').get('process').get('legs')
         model = self.born_matrix_element.get('base_amplitude').get('process').get('model')
         color_links_info = fks_common.find_color_links(fks_common.to_fks_legs(legs, model),
                     symm = True,pert = self.perturbation)
         col_basis = self.born_matrix_element.get('color_basis')
         self.color_links = fks_common.insert_color_links(col_basis,
                             col_basis.create_color_dict_list(
                                 self.born_matrix_element.get('base_amplitude')),
                             color_links_info)    
Beispiel #5
0
 def set_color_links(self):
     """this function computes and returns the color links, it should be called
     after the initialization and the setting of the color basis"""
     if not self.color_links:
         legs = self.born_matrix_element.get('base_amplitude').get('process').get('legs')
         model = self.born_matrix_element.get('base_amplitude').get('process').get('model')
         color_links_info = fks_common.find_color_links(fks_common.to_fks_legs(legs, model),
                     symm = True,pert = self.perturbation)
         col_basis = self.born_matrix_element.get('color_basis')
         self.color_links = fks_common.insert_color_links(col_basis,
                             col_basis.create_color_dict_list(
                                 self.born_matrix_element.get('base_amplitude')),
                             color_links_info)    
Beispiel #6
0
    def test_fks_helas_real_process_init(self):
        """tests the correct initialization of an FKSHelasRealProcess, from a 
        FKSRealProc. The process uu~>dd~ is used as born.
        For the real we use uu~>dd~(j) g(i).
        We test The correct initialization of:
        --i/j fks
        --permutation
        --matrix element
        """
        #uu~> dd~
        fks3 = fks_base.FKSProcess(self.myproc3)

        fksleglist = copy.copy(
            fks_common.to_fks_legs(self.myleglist3, self.mymodel))
        amplist = []
        amp_id_list = []
        me_list = []
        me_id_list = []

        fksleglist.append(
            fks_common.to_fks_leg(
                MG.Leg({
                    'id': 21,
                    'state': True,
                    'number': 5,
                    'from_group': True
                }), self.mymodel))
        fksleglist[0]['fks'] = 'n'
        fksleglist[1]['fks'] = 'n'
        fksleglist[2]['fks'] = 'n'
        fksleglist[3]['fks'] = 'j'
        fksleglist[4]['fks'] = 'i'

        real_proc = fks_base.FKSRealProcess(fks3.born_proc, fksleglist, 4, 0)
        real_proc.generate_real_amplitude()
        helas_real_proc = fks_helas.FKSHelasRealProcess(
            real_proc, me_list, me_id_list)
        self.assertEqual(helas_real_proc.fks_infos, [{
            'i': 5,
            'j': 4,
            'ij': 4,
            'ij_glu': 0,
            'need_color_links': True
        }])
        target_me = helas_objects.HelasMatrixElement(real_proc.amplitude)
        self.assertEqual(helas_real_proc.matrix_element, target_me)
        self.assertEqual(helas_real_proc.matrix_element.get('color_matrix'),
                         target_me.get('color_matrix'))
Beispiel #7
0
    def test_FKSRealProcess_init(self):
        """tests the correct initialization of the FKSRealProcess class. 
        In particular checks that
        --fks_info
        --amplitude (also the generate_real_amplitude function is tested)
        --leg_permutation <<REMOVED
        are set to the correct values"""
        # u g > u g
        fksproc = fks_base.FKSProcess(self.myproc)
        # take the first real for this process 2j 21 >2 21 21i
        leglist = fksproc.reals[0][0]
        realproc = fks_base.FKSRealProcess(fksproc.born_proc, leglist, 1, 0)

        self.assertEqual(realproc.fks_infos, [{"i": 5, "j": 1, "ij": 1, "ij_glu": 0, "need_color_links": True}])

        sorted_legs = fks_common.to_fks_legs(
            [
                fks_common.FKSLeg({"id": 2, "number": 1, "state": False, "fks": "j"}),
                fks_common.FKSLeg({"id": 21, "number": 2, "state": False, "fks": "n"}),
                fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                fks_common.FKSLeg({"id": 21, "number": 4, "state": True, "fks": "n"}),
                fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "i"}),
            ],
            self.mymodel,
        )

        sorted_real_proc = MG.Process(
            {"legs": sorted_legs, "model": self.mymodel, "orders": {"QCD": 3, "QED": 0, "WEIGHTED": 3}, "id": 1}
        )
        ## an emplty amplitude is generted so far...
        self.assertEqual(diagram_generation.Amplitude(), realproc.amplitude)

        ## now generate the amplitude
        realproc.generate_real_amplitude()

        self.assertEqual(sorted_real_proc, realproc.amplitude.get("process"))
        self.assertEqual(realproc.amplitude["process"]["legs_with_decays"], MG.LegList())
        amp = diagram_generation.Amplitude(sorted_real_proc)
        self.assertEqual(amp, realproc.amplitude)
        self.assertEqual(array.array("i", [2, 21, 2, 21, 21]), realproc.pdgs)
        self.assertEqual([3, 8, 3, 8, 8], realproc.colors)
    def test_fks_helas_real_process_init(self):
        """tests the correct initialization of an FKSHelasRealProcess, from a 
        FKSRealProc. The process uu~>dd~ is used as born.
        For the real we use uu~>dd~(j) g(i).
        We test The correct initialization of:
        --i/j fks
        --permutation
        --matrix element
        """         
        #uu~> dd~
        fks3 = fks_base.FKSProcess(self.myproc3)
 
        fksleglist = copy.copy(fks_common.to_fks_legs(self.myleglist3,
                                                      self.mymodel))
        amplist = []
        amp_id_list = []
        me_list=[]
        me_id_list=[]
        
        fksleglist.append(fks_common.to_fks_leg(MG.Leg({'id' : 21,
                                                 'state' : True,
                                                 'number' : 5,
                                                 'from_group' : True}),
                                                 self.mymodel))
        fksleglist[0]['fks']='n'
        fksleglist[1]['fks']='n'
        fksleglist[2]['fks']='n'
        fksleglist[3]['fks']='j'
        fksleglist[4]['fks']='i'
        
        real_proc = fks_base.FKSRealProcess(fks3.born_proc, fksleglist, 4, 0)
        real_proc.generate_real_amplitude()
        helas_real_proc = fks_helas.FKSHelasRealProcess(real_proc, me_list, me_id_list)
        self.assertEqual(helas_real_proc.fks_infos,
                [{'i':5, 'j':4, 'ij':4, 'ij_glu':0, 'need_color_links': True}])
        target_me = helas_objects.HelasMatrixElement(real_proc.amplitude)
        self.assertEqual(helas_real_proc.matrix_element, target_me)
        self.assertEqual(helas_real_proc.matrix_element.get('color_matrix'), 
                         target_me.get('color_matrix'))
Beispiel #9
0
    def __init__(self, start_proc = None, remove_reals = True, ncores_for_proc_gen=0):
        """initialization: starts either from an amplitude or a process,
        then init the needed variables.
        remove_borns tells if the borns not needed for integration will be removed
        from the born list (mainly used for testing)
        ncores_for_proc_gen has the following meaning
           0 : do things the old way
           > 0 use ncores_for_proc_gen
           -1 : use all cores
        """
                
        self.splittings = {}
        self.reals = []
        self.fks_dirs = []
        self.leglist = []
        self.myorders = {}
        self.pdg_codes = []
        self.colors = [] # color
        self.charges = [] # charge
        self.nlegs = 0
        self.fks_ipos = []
        self.fks_j_from_i = {}
        self.real_amps = []
        self.remove_reals = remove_reals
        self.nincoming = 0
        self.virt_amp = None
        self.perturbation = 'QCD'
        self.ncores_for_proc_gen = ncores_for_proc_gen

        if not remove_reals in [True, False]:
            raise fks_common.FKSProcessError(\
                    'Not valid type for remove_reals in FKSProcess')

        if start_proc:
            if isinstance(start_proc, MG.Process):
                pertur = start_proc['perturbation_couplings']
                if pertur:
                    self.perturbation = sorted(pertur)[0]
                self.born_proc = fks_common.sort_proc(start_proc,pert = self.perturbation)
                # filter in Amplitude will legs sorted in bornproc
                bornproc = copy.copy(self.born_proc) # deepcopy might let T -> array
                assert bornproc==self.born_proc
                self.born_amp = diagram_generation.Amplitude(bornproc)
            elif isinstance(start_proc, diagram_generation.Amplitude):
                pertur = start_proc.get('process')['perturbation_couplings']
                if pertur:
                    self.perturbation = sorted(pertur)[0]
                self.born_proc = fks_common.sort_proc(start_proc.get('process'),\
                                                      pert = self.perturbation)
                # filter in Amplitude will legs sorted in bornproc
                bornproc = copy.copy(self.born_proc)
                assert bornproc == self.born_proc
                self.born_amp = diagram_generation.Amplitude(bornproc)
            else:
                raise fks_common.FKSProcessError(\
                    'Not valid start_proc in FKSProcess')
            self.born_proc.set('legs_with_decays', MG.LegList())

            self.leglist = fks_common.to_fks_legs(
                                    self.born_proc['legs'], self.born_proc['model'])
            self.nlegs = len(self.leglist)
            self.pdg_codes = [leg.get('id') for leg in self.leglist]
            if self.perturbation == 'QCD':
                self.colors = [leg.get('color') for leg in self.leglist]
                # in QCD, charge is irrelevant but impact the combine process !
                self.charges = [0. for leg in self.leglist]
                color = 'color'
                zero = 1
            elif self.perturbation == 'QED':
                self.colors = [leg.get('color') for leg in self.leglist]
                self.charges = [leg.get('charge') for leg in self.leglist]
                color = 'charge'
                zero = 0.
            # special treatment of photon is needed !
            self.isr = set([leg.get(color) for leg in self.leglist if not leg.get('state')]) != set([zero])
            self.fsr = set([leg.get(color) for leg in self.leglist if leg.get('state')]) != set([zero])
            for leg in self.leglist:
                if not leg['state']:
                    self.nincoming += 1
            self.orders = self.born_amp['process']['orders']
            # this is for cases in which the user specifies e.g. QED=0
            if sum(self.orders.values()) == 0:
                self.orders = fks_common.find_orders(self.born_amp)
                
            self.ndirs = 0
            # generate reals, when the mode is not LOonly
            # when is LOonly it is supposed to be a 'fake' NLO process
            # e.g. to be used in merged sampels at high multiplicities
            if self.born_proc['NLO_mode'] != 'LOonly':
                for order in self.born_proc.get('perturbation_couplings'):
                    self.find_reals(order)
Beispiel #10
0
    def __init__(self, start_proc = None, remove_reals = True, ncores_for_proc_gen=0):
        """initialization: starts either from an amplitude or a process,
        then init the needed variables.
        remove_borns tells if the borns not needed for integration will be removed
        from the born list (mainly used for testing)
        ncores_for_proc_gen has the following meaning
           0 : do things the old way
           > 0 use ncores_for_proc_gen
           -1 : use all cores
        """
                
        self.splittings = {}
        self.reals = []
        self.fks_dirs = []
        self.leglist = []
        self.myorders = {}
        self.pdg_codes = []
        self.colors = [] # color
        self.charges = [] # charge
        self.nlegs = 0
        self.fks_ipos = []
        self.fks_j_from_i = {}
        self.real_amps = []
        self.remove_reals = remove_reals
        self.nincoming = 0
        self.virt_amp = None
        self.perturbation = 'QCD'
        self.ncores_for_proc_gen = ncores_for_proc_gen

        if not remove_reals in [True, False]:
            raise fks_common.FKSProcessError(\
                    'Not valid type for remove_reals in FKSProcess')

        if start_proc:
            if isinstance(start_proc, MG.Process):
                pertur = start_proc['perturbation_couplings']
                if pertur:
                    self.perturbation = sorted(pertur)[0]
                self.born_proc = fks_common.sort_proc(start_proc,pert = self.perturbation)
                # filter in Amplitude will legs sorted in bornproc
                bornproc = copy.copy(self.born_proc) # deepcopy might let T -> array
                assert bornproc==self.born_proc
                self.born_amp = diagram_generation.Amplitude(bornproc)
            elif isinstance(start_proc, diagram_generation.Amplitude):
                pertur = start_proc.get('process')['perturbation_couplings']
                if pertur:
                    self.perturbation = sorted(pertur)[0]
                self.born_proc = fks_common.sort_proc(start_proc.get('process'),\
                                                      pert = self.perturbation)
                # filter in Amplitude will legs sorted in bornproc
                bornproc = copy.copy(self.born_proc)
                assert bornproc == self.born_proc
                self.born_amp = diagram_generation.Amplitude(bornproc)
            else:
                raise fks_common.FKSProcessError(\
                    'Not valid start_proc in FKSProcess')
            self.born_proc.set('legs_with_decays', MG.LegList())

            self.leglist = fks_common.to_fks_legs(
                                    self.born_proc['legs'], self.born_proc['model'])
            self.nlegs = len(self.leglist)
            self.pdg_codes = [leg.get('id') for leg in self.leglist]
            if self.perturbation == 'QCD':
                self.colors = [leg.get('color') for leg in self.leglist]
                # in QCD, charge is irrelevant but impact the combine process !
                self.charges = [0. for leg in self.leglist]
                color = 'color'
                zero = 1
            elif self.perturbation == 'QED':
                self.colors = [leg.get('color') for leg in self.leglist]
                self.charges = [leg.get('charge') for leg in self.leglist]
                color = 'charge'
                zero = 0.
            # special treatment of photon is needed !
            self.isr = set([leg.get(color) for leg in self.leglist if not leg.get('state')]) != set([zero])
            self.fsr = set([leg.get(color) for leg in self.leglist if leg.get('state')]) != set([zero])
            for leg in self.leglist:
                if not leg['state']:
                    self.nincoming += 1
            self.orders = self.born_amp['process']['orders']
            # this is for cases in which the user specifies e.g. QED=0
            if sum(self.orders.values()) == 0:
                self.orders = fks_common.find_orders(self.born_amp)
                
            self.ndirs = 0
            # generate reals, when the mode is not LOonly
            # when is LOonly it is supposed to be a 'fake' NLO process
            # e.g. to be used in merged sampels at high multiplicities
            if self.born_proc['NLO_mode'] != 'LOonly':
                for order in self.born_proc.get('perturbation_couplings'):
                    self.find_reals(order)
Beispiel #11
0
    def test_find_reals(self):
        """tests if all the real processes are found for a given born"""
        # process is u g > u g
        fksproc = fks_base.FKSProcess(self.myproc)
        target = []

        # leg 1 can split as u g > u g g or  g g > u u~ g
        target.append(
            [
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 2, "number": 1, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": 21, "number": 2, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 4, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                ),
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 21, "number": 1, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": 21, "number": 2, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": -2, "number": 4, "state": True, "fks": "i"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "n"}),
                    ],
                    self.mymodel,
                ),
            ]
        )

        # leg 2 can split as u d > d u g OR u d~ > d~ u g OR
        #                   u u > u u g OR u u~ > u u~ g OR
        #                   u g > u g g

        target.append(
            [
                fks_common.to_fks_legs(
                    [  # ug>ugg
                        fks_common.FKSLeg({"id": 2, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 2, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 4, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                ),
                fks_common.to_fks_legs(
                    [  # ud>dug
                        fks_common.FKSLeg({"id": 2, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 1, "number": 2, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 1, "number": 4, "state": True, "fks": "i"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "n"}),
                    ],
                    self.mymodel,
                ),
                fks_common.to_fks_legs(
                    [  # ud~>d~ug
                        fks_common.FKSLeg({"id": 2, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": -1, "number": 2, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": -1, "number": 4, "state": True, "fks": "i"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "n"}),
                    ],
                    self.mymodel,
                ),
                fks_common.to_fks_legs(
                    [  # uu>uug
                        fks_common.FKSLeg({"id": 2, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 2, "number": 2, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 2, "number": 4, "state": True, "fks": "i"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "n"}),
                    ],
                    self.mymodel,
                ),
                fks_common.to_fks_legs(
                    [  # uu~>uu~g
                        fks_common.FKSLeg({"id": 2, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": -2, "number": 2, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": -2, "number": 4, "state": True, "fks": "i"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "n"}),
                    ],
                    self.mymodel,
                ),
            ]
        )

        # leg 3 can split as u g > u g g
        target.append(
            [
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 2, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 2, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "j"}),
                        fks_common.FKSLeg({"id": 21, "number": 4, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                )
            ]
        )
        # leg 4 can split as u g > u g g or u g > u u u~ or u g > u d d~
        target.append(
            [
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 2, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 2, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 4, "state": True, "fks": "j"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                ),
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 2, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 2, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 1, "number": 4, "state": True, "fks": "j"}),
                        fks_common.FKSLeg({"id": -1, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                ),
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 2, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 2, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 2, "number": 4, "state": True, "fks": "j"}),
                        fks_common.FKSLeg({"id": -2, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                ),
            ]
        )

        for i in range(len(fksproc.reals)):
            for j in range(len(fksproc.reals[i])):
                self.assertEqual(fksproc.reals[i][j], target[i][j])

        # process is d d~ > u u~
        fksproc2 = fks_base.FKSProcess(self.myproc2)
        target2 = []
        # leg 1 can split as d d~ > u u~ g or  g d~ > d~ u u~
        target2.append(
            [
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 1, "number": 1, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": -1, "number": 2, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": -2, "number": 4, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                ),
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 21, "number": 1, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": -1, "number": 2, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": -2, "number": 4, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": -1, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                ),
            ]
        )

        # leg 2 can split as d d~ > u u~ g or  d g > d u u~
        target2.append(
            [
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 1, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": -1, "number": 2, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": -2, "number": 4, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                ),
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 1, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 2, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 1, "number": 4, "state": True, "fks": "i"}),
                        fks_common.FKSLeg({"id": -2, "number": 5, "state": True, "fks": "n"}),
                    ],
                    self.mymodel,
                ),
            ]
        )

        # leg 3 can split as d d~ > u u~ g
        target2.append(
            [
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 1, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": -1, "number": 2, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "j"}),
                        fks_common.FKSLeg({"id": -2, "number": 4, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                )
            ]
        )

        # leg 4 can split as d d~ > u u~ g
        target2.append(
            [
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 1, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": -1, "number": 2, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 2, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": -2, "number": 4, "state": True, "fks": "j"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                )
            ]
        )

        for i in range(len(fksproc2.reals)):
            self.assertEqual(fksproc2.reals[i], target2[i])

        # d d~ > a a
        fksproc3 = fks_base.FKSProcess(self.myprocaa)
        target3 = []
        # leg 1 can split as d d~ > g a a or  g d~ > d~ a a
        target3.append(
            [
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 1, "number": 1, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": -1, "number": 2, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 22, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 22, "number": 4, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                ),
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 21, "number": 1, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": -1, "number": 2, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 22, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 22, "number": 4, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": -1, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                ),
            ]
        )
        # leg 2 can split as d d~ > g a a  or  d g > d a a
        target3.append(
            [
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 1, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": -1, "number": 2, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": 22, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 22, "number": 4, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                ),
                fks_common.to_fks_legs(
                    [
                        fks_common.FKSLeg({"id": 1, "number": 1, "state": False, "fks": "n"}),
                        fks_common.FKSLeg({"id": 21, "number": 2, "state": False, "fks": "j"}),
                        fks_common.FKSLeg({"id": 22, "number": 3, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 22, "number": 4, "state": True, "fks": "n"}),
                        fks_common.FKSLeg({"id": 1, "number": 5, "state": True, "fks": "i"}),
                    ],
                    self.mymodel,
                ),
            ]
        )

        for real, res in zip(fksproc3.reals, target3):
            self.assertEqual(real, res)