Define new propogator

Asked by Yinfa Shen

Hi MadTeam,

I am trying to define a new propagator for fermions. For this purpose, I started with a simple test. I directly copied the definition of PSlash in aloha_object.py (line 245) and then pasted it in the same file at line 1651. Then, in the UFO directory, I add a new kind of propagator to propagators.py:

HN = Propagator(name = "HN",
                numerator = "complex(0,1) * FullFermionPropagator(1, 2, id)",
                denominator = "1"
               ).
I also changed the heavy neutrino's propagator in particles.py as

N1 = Particle(pdg_code = 9900012,
              name = 'N1',
              antiname = 'N1',
              spin = 2,
              color = 1,
              mass = Param.mN1,
              width = Param.WN1,
              texname = 'N1',
              antitexname = 'N1',
              charge = 0,
              GhostNumber = 0,
              LeptonNumber = 0,
              Y = 0,
              propagator = Prop.HN)

When I ran Madgraph, it didn't work, and the output was:

Command "output HN_no_s_test" interrupted with error:
UnboundLocalError : local variable 'text' referenced before assignment

However, if I changed the propagator definition as:

HN = Propagator(name = "HN",
                numerator = "complex(0,1) * PSlash(1, 2, id)",
                denominator = "1"
               )
It worked. That's strange since their definitions in the aloha_object.py are almost the same, I just changed the name.

Can you provide some suggestions?

Yin-Fa

Question information

Language:
English Edit question
Status:
Solved
For:
MadGraph5_aMC@NLO Edit question
Assignee:
No assignee Edit question
Solved by:
Olivier Mattelaer
Solved:
Last query:
Last reply:
Revision history for this message
Yinfa Shen (syf123) said :
#1

My definition in aloha_object.py:

#===============================================================================
# FullFermionPropagator
#===============================================================================
class L_FullFermionPropagator(aloha_lib.LorentzObject):
    """ Full Fermion Propagator: i / (slash(p) - m - Sigma(p)) """

    def __init__(self, name, spin1, spin2, particle):

        self.particle = particle
        aloha_lib.LorentzObject.__init__(self,name,[], [spin1, spin2])

    def create_representation(self):
        """create representation"""
        p0 = aloha_lib.DVariable('P%s_0' % self.particle)
        p1 = aloha_lib.DVariable('P%s_1' % self.particle)
        p2 = aloha_lib.DVariable('P%s_2' % self.particle)
        p3 = aloha_lib.DVariable('P%s_3' % self.particle)

        propagator_dict = {
             (0, 0): 0, (0, 1): 0, (0, 2): p0-p3, (0, 3): -1*p1+1j*p2,
             (1, 0): 0, (1, 1): 0, (1, 2): -1*p1-1j*p2, (1, 3): p0+p3,
             (2, 0): p0+p3, (2, 1): p1-1j*p2, (2, 2): 0, (2, 3): 0,
             (3, 0): p1+1j*p2, (3, 1): p0-p3, (3, 2): 0, (3, 3): 0}

        self.representation = aloha_lib.LorentzObjectRepresentation(propagator_dict,
                                self.lorentz_ind,self.spin_ind)

class FullFermionPropagator(aloha_lib.FactoryLorentz):

    object_class = L_FullFermionPropagator

    @classmethod
    def get_unique_name(self, spin1, spin2, particle):
        return '_FFProp%s/_%s_%s' % (particle, spin1,spin2)

The output of Madgraph debug:

import model SM_HeavyN_NLO_Test-no_FNV
generate p p > mu- vl~ j j NP==2 $$ a z h w- w+
output HN_no_s_test
Traceback (most recent call last):
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/aloha/aloha_writers.py", line 280, in write_obj
    vartype = obj.vartype
AttributeError: 'str' object has no attribute 'vartype'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/aloha/aloha_writers.py", line 788, in define_expression
    text = format % ','.join([self.write_obj(obj) for obj in objs])
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/aloha/aloha_writers.py", line 788, in <listcomp>
    text = format % ','.join([self.write_obj(obj) for obj in objs])
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/aloha/aloha_writers.py", line 282, in write_obj
    return self.change_number_format(obj)
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/aloha/aloha_writers.py", line 730, in change_number_format
    if isinteger(number):
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/aloha/aloha_writers.py", line 726, in isinteger
    return int(x) == x
ValueError: invalid literal for int() with base 10: 'I2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/madgraph/interface/extended_cmd.py", line 1546, in onecmd
    return self.onecmd_orig(line, **opt)
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/madgraph/interface/extended_cmd.py", line 1495, in onecmd_orig
    return func(arg, **opt)
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/madgraph/interface/master_interface.py", line 299, in do_output
    self.cmd.do_output(self, line, *args, **opts)
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/madgraph/interface/madgraph_interface.py", line 8320, in do_output
    self.finalize(nojpeg, flaglist=flaglist)
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/madgraph/interface/madgraph_interface.py", line 8618, in finalize
    self._curr_exporter.convert_model(self._curr_model,
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/madgraph/iolibs/export_v4.py", line 4158, in convert_model
    super(ProcessExporterFortranME,self).convert_model(model,
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/madgraph/iolibs/export_v4.py", line 975, in convert_model
    aloha_model.write(write_dir, 'Fortran')
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/aloha/create_aloha.py", line 1114, in write
    abstract_routine.write(output_dir, language)
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/aloha/create_aloha.py", line 97, in write
    text = writer.write(mode=mode, **opt)
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/aloha/aloha_writers.py", line 244, in write
    core_text = self.define_expression()
  File "/panfs/accrepfs.vampire/home/sheny19/CMSSW_14_1_0_pre4/src/MG5_aMC_v3_5_6/aloha/aloha_writers.py", line 792, in define_expression
    out.write(text)
UnboundLocalError: local variable 'text' referenced before assignment

Revision history for this message
Best Olivier Mattelaer (olivier-mattelaer) said :
#2

Hi,

In principle, one should not define new object in aloha_object in order to define new propagator.
Those type of definitions are supposed to be restricted to internal object that are not passed to the UFO reader.

Since in top you are passing trough the UFO interface, you need to indicate to the UFO parser how to convert the string that is passed within the UFO to the object that you have define in propagators.py since UFO and aloha does not agree on the sigh of the fermion momenta.

At minimum, you need to indicate to the parser that your new object does exists, by adding it to the aloha_object of the ALOHAExpressionParser class (in file aloha_parser.py).

Getting back to the sign issue of the momenta, since you define a new object, this will not be consider for the automatic change of sign (if/when needed) for the momenta.

So this is in create_aloha.py:
        if need_P_sign:
            expr = re.sub(r'\b(P|PSlash)\(', r'-\1(', expr)

Regular expression that will likely need to be changed in your case as well.

Now this is the two points that I remember but they might have more, I would suggest to grep the full aloha code to check each appearance of PSlash and be sure to add your new object accordingly. (or if possible just stick to the UFO interface to add your new propagator if this is possible without adding new object within aloha)

Cheers,

Olivier

Revision history for this message
Yinfa Shen (syf123) said :
#3

Thanks Olivier Mattelaer, that solved my question.