AttributeError on launch

Asked by Vincent Groff

Hello,

I've written my own model (scalar electrodynamics) in FeynRules and imported it to MG which seems to work fine.
I've generated an interaction and output it successfully, but on launching it I get an AttributeError.

Here is the debug log:

Traceback (most recent call last):
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 1412, in onecmd
    return self.onecmd_orig(line, **opt)
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 1367, in onecmd_orig
    return func(arg, **opt)
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/madevent_interface.py", line 2037, in do_generate_events
    self.ask_run_configuration(mode, args)
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/madevent_interface.py", line 5907, in ask_run_configuration
    self.ask_edit_cards(cards, plot=False, mode='auto')
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/common_run_interface.py", line 874, in ask_edit_cards
    self.ask, first_cmd=first_cmd)
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/common_run_interface.py", line 936, in ask_edit_card_static
    cards=cards, mode=mode, **opt)
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 1115, in ask
    fct=question_instance, fct_timeout=fct_timeout)
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 1622, in timed_input
    result = fct(question)
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 1979, in __call__
    return self.cmdloop()
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 2143, in cmdloop
    super(SmartQuestion,self).cmdloop(intro)
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 167, in cmdloop
    stop = self.postcmd(stop, line)
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/common_run_interface.py", line 5180, in postcmd
    self.do_update('dependent', timer=20)
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/common_run_interface.py", line 5227, in do_update
    self.paths['param'], timer)
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/common_run_interface.py", line 5272, in update_dependent
    modify = param_card.update_dependent(model, restrict_card, log_level)
  File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/models/check_param_card.py", line 456, in update_dependent
    param_value = self.get('mass').get(lhacode).value
AttributeError: 'NoneType' object has no attribute 'get'

It seems to trip up on the param card, so here is param_card.dat:

Block QNUMBERS 9000001 # l
        1 -3 # 3 times electric charge
        2 1 # number of spin states (2S+1)
        3 1 # colour rep (1: singlet, 3: triplet, 8: octet)
        4 1 # Particle/Antiparticle distinction (0=own anti)
Block QNUMBERS 9000002 # l2
        1 -3 # 3 times electric charge
        2 1 # number of spin states (2S+1)
        3 1 # colour rep (1: singlet, 3: triplet, 8: octet)
        4 1 # Particle/Antiparticle distinction (0=own anti)
Block QNUMBERS 9000003 # a
        1 0 # 3 times electric charge
        2 3 # number of spin states (2S+1)
        3 1 # colour rep (1: singlet, 3: triplet, 8: octet)
        4 0 # Particle/Antiparticle distinction (0=own anti)

The particles have a mass defined (it is 0), like so:

l = Particle(pdg_code = 9000001,
             name = 'l',
             antiname = 'l~',
             spin = 1,
             color = 1,
             mass = Param.ZERO,
             width = Param.ZERO,
             texname = 'l',
             antitexname = 'l~',
             charge = -1,
             LeptonNumber = 1)

and Param.ZERO is in parameters.py

ZERO = Parameter(name = 'ZERO',
                 nature = 'internal',
                 type = 'real',
                 value = '0.0',
                 texname = '0')

Obviously this doesn't have an lhacode, could this be the error? That seems like it would make it trip on .value rather than .get

Thank you so much for your help,

Vincent

Question information

Language:
English Edit question
Status:
Solved
For:
MadGraph5_aMC@NLO Edit question
Assignee:
No assignee Edit question
Solved by:
Vincent Groff
Solved:
Last query:
Last reply:
Revision history for this message
Olivier Mattelaer (olivier-mattelaer) said :
#1

Hi,

Do you have all your particle with zero mass?

The problem is that the param_card does not seems to have a “block mass” entry.
(The mass of all particle need to be present in the param_card even if they are forced to be zero).
But my guess is that something funny can occur if all masses (similarly for the width) are hardcoded to zero.
Can you confirm this? if so I will take a look on how force the writting of those value even in that particular case.

Cheers,

Olivier

> On Jan 13, 2017, at 17:17, Vincent Groff <email address hidden> wrote:
>
> New question #439383 on MadGraph5_aMC@NLO:
> https://answers.launchpad.net/mg5amcnlo/+question/439383
>
> Hello,
>
> I've written my own model (scalar electrodynamics) in FeynRules and imported it to MG which seems to work fine.
> I've generated an interaction and output it successfully, but on launching it I get an AttributeError.
>
> Here is the debug log:
>
> Traceback (most recent call last):
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 1412, in onecmd
> return self.onecmd_orig(line, **opt)
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 1367, in onecmd_orig
> return func(arg, **opt)
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/madevent_interface.py", line 2037, in do_generate_events
> self.ask_run_configuration(mode, args)
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/madevent_interface.py", line 5907, in ask_run_configuration
> self.ask_edit_cards(cards, plot=False, mode='auto')
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/common_run_interface.py", line 874, in ask_edit_cards
> self.ask, first_cmd=first_cmd)
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/common_run_interface.py", line 936, in ask_edit_card_static
> cards=cards, mode=mode, **opt)
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 1115, in ask
> fct=question_instance, fct_timeout=fct_timeout)
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 1622, in timed_input
> result = fct(question)
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 1979, in __call__
> return self.cmdloop()
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 2143, in cmdloop
> super(SmartQuestion,self).cmdloop(intro)
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/extended_cmd.py", line 167, in cmdloop
> stop = self.postcmd(stop, line)
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/common_run_interface.py", line 5180, in postcmd
> self.do_update('dependent', timer=20)
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/common_run_interface.py", line 5227, in do_update
> self.paths['param'], timer)
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/madgraph/interface/common_run_interface.py", line 5272, in update_dependent
> modify = param_card.update_dependent(model, restrict_card, log_level)
> File "/mt/home/vgroff/Downloads/MG5_aMC_v2_5_2/models/check_param_card.py", line 456, in update_dependent
> param_value = self.get('mass').get(lhacode).value
> AttributeError: 'NoneType' object has no attribute 'get'
>
>
> It seems to trip up on the param card, so here is param_card.dat:
>
> Block QNUMBERS 9000001 # l
> 1 -3 # 3 times electric charge
> 2 1 # number of spin states (2S+1)
> 3 1 # colour rep (1: singlet, 3: triplet, 8: octet)
> 4 1 # Particle/Antiparticle distinction (0=own anti)
> Block QNUMBERS 9000002 # l2
> 1 -3 # 3 times electric charge
> 2 1 # number of spin states (2S+1)
> 3 1 # colour rep (1: singlet, 3: triplet, 8: octet)
> 4 1 # Particle/Antiparticle distinction (0=own anti)
> Block QNUMBERS 9000003 # a
> 1 0 # 3 times electric charge
> 2 3 # number of spin states (2S+1)
> 3 1 # colour rep (1: singlet, 3: triplet, 8: octet)
> 4 0 # Particle/Antiparticle distinction (0=own anti)
>
> The particles have a mass defined (it is 0), like so:
>
> l = Particle(pdg_code = 9000001,
> name = 'l',
> antiname = 'l~',
> spin = 1,
> color = 1,
> mass = Param.ZERO,
> width = Param.ZERO,
> texname = 'l',
> antitexname = 'l~',
> charge = -1,
> LeptonNumber = 1)
>
> and Param.ZERO is in parameters.py
>
> ZERO = Parameter(name = 'ZERO',
> nature = 'internal',
> type = 'real',
> value = '0.0',
> texname = '0')
>
> Obviously this doesn't have an lhacode, could this be the error? That seems like it would make it trip on .value rather than .get
>
>
> Thank you so much for your help,
>
> Vincent
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Revision history for this message
Vincent Groff (vgroff) said :
#2

Hi,

Yes indeed, all particles have zero mass and width.
This didn't seem to be a problem before, I altered my model to include four-vertices and now it is.

Thanks for your help,
Vincent

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

Hi,

I can reproduce the error if I hack the SM to have all masses to zero.
But indeed this depend on how you handle the writting of the cards (e.g. if you use launch -f the bug did not occur).
So can you try the following patch?

Cheers,

Olivier

=== modified file 'models/check_param_card.py'
--- models/check_param_card.py 2016-11-20 14:05:38 +0000
+++ models/check_param_card.py 2017-01-15 14:06:32 +0000
@@ -480,7 +480,6 @@
                     model_value = model_value.real
                 if not misc.equal(model_value, param_value, 4):
                     modify = True
- misc.sprint(modify)
                     if loglevel == 20:
                         logger.info('For consistency, the width of particle %s (%s) is changed to %s.' % (lhacode, particle.get('name'), model_value), '$MG:color:BLACK')
                     else:
@@ -1175,10 +1174,10 @@
                         is_modified = True
                         if log ==20:
                             logger.log(log,'For model consistency, update %s with id %s to value %s',
- (block, id, 0.0), '$MG:color:BLACK')
+ block, id, 0.0, '$MG:color:BLACK')
                         elif log:
                             logger.log(log,'For model consistency, update %s with id %s to value %s',
- (block, id, 0.0))
+ block, id, 0.0)

         # check one
         for block, id, comment in self.one:

=== modified file 'models/write_param_card.py'
--- models/write_param_card.py 2016-09-06 11:24:51 +0000
+++ models/write_param_card.py 2017-01-15 14:06:15 +0000
@@ -174,6 +174,7 @@

         # order the parameter in a smart way
         self.external.sort(self.order_param)
+ todo_block= ['MASS', 'DECAY'] # ensure that those two block are always written

         cur_lhablock = ''
         for param in self.external:
@@ -182,11 +183,16 @@
                 # check if some dependent param should be written
                 self.write_dep_param_block(cur_lhablock)
                 cur_lhablock = param.lhablock.upper()
+ if cur_lhablock in todo_block:
+ todo_block.remove(cur_lhablock)
                 # write the header of the new block
                 self.write_block(cur_lhablock)
             #write the parameter
             self.write_param(param, cur_lhablock)
         self.write_dep_param_block(cur_lhablock)
+ for cur_lhablock in todo_block:
+ self.write_block(cur_lhablock)
+ self.write_dep_param_block(cur_lhablock)
         self.write_qnumber()

     def write_block(self, name):
> On Jan 15, 2017, at 13:28, Vincent Groff <email address hidden> wrote:
>
> Question #439383 on MadGraph5_aMC@NLO changed:
> https://answers.launchpad.net/mg5amcnlo/+question/439383
>
> Status: Answered => Open
>
> Vincent Groff is still having a problem:
> Hi,
>
> Yes indeed, all particles have zero mass and width.
> This didn't seem to be a problem before, I altered my model to include four-vertices and now it is.
>
> Thanks for your help,
> Vincent
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Revision history for this message
Vincent Groff (vgroff) said :
#4

I seem to get an error when I try to patch it.
When I run the patch command, I get the following response:

"patching file check_param_card.py
Reversed (or previously applied) patch detected! Assume -R? [n]"

If I type y, I get:

"Hunk #1 succeeded at 462 with fuzz 2 (offset -18 lines).
Hunk #2 FAILED at 1175.
1 out of 2 hunks FAILED -- saving rejects to file check_param_card.py.rej
patching file write_param_card.py
Hunk #1 FAILED at 174.
Hunk #2 succeeded at 182 with fuzz 2.
1 out of 2 hunks FAILED -- saving rejects to file write_param_card.py.rej
"

and the rejected files look like:
"
--- check_param_card.py 2017-01-15 14:06:32 +0000
+++ check_param_card.py 2016-11-20 14:05:38 +0000
@@ -1175,10 +1176,10 @@
                         is_modified = True
                         if log ==20:
                             logger.log(log,'For model consistency, update %s with id %s to value %s',
- block, id, 0.0, '$MG:color:BLACK')
+ (block, id, 0.0), '$MG:color:BLACK')
                         elif log:
                             logger.log(log,'For model consistency, update %s with id %s to value %s',
- block, id, 0.0)
+ (block, id, 0.0))

         # check one
         for block, id, comment in self.one:
"

and

"
--- write_param_card.py 2016-09-06 11:24:51 +0000
+++ write_param_card.py 2017-01-15 14:06:15 +0000
@@ -174,6 +174,7 @@

         # order the parameter in a smart way
         self.external.sort(self.order_param)
+ todo_block= ['MASS', 'DECAY'] # ensure that those two block are always written

         cur_lhablock = ''
         for param in self.external:
"

and with "n":

"
Hunk #1 FAILED at 480.
Hunk #2 FAILED at 1175.
2 out of 2 hunks FAILED -- saving rejects to file check_param_card.py.rej
patching file write_param_card.py
Hunk #1 FAILED at 174.
Hunk #2 FAILED at 182.
2 out of 2 hunks FAILED -- saving rejects to file write_param_card.py.rej
"

And as you'd expect if I run MG after applying the patch like so then it crashes.
Any idea why the patch doesn't seem to be working? Should I try and apply it manually?
Is it possible our starting files are different, I have the latest version from the website though?

Thanks,
Vincent

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

No idea why the patch fails.
you can try to apply it manually.

or you can do
bzr branch lp:~maddevelopers/mg5amcnlo/2.5.3
to get the latest development version with those changes.

Cheers,

Olivier
> On Jan 15, 2017, at 16:13, Vincent Groff <email address hidden> wrote:
>
> Question #439383 on MadGraph5_aMC@NLO changed:
> https://answers.launchpad.net/mg5amcnlo/+question/439383
>
> Status: Answered => Open
>
> Vincent Groff is still having a problem:
> I seem to get an error when I try to patch it.
> When I run the patch command, I get the following response:
>
> "patching file check_param_card.py
> Reversed (or previously applied) patch detected! Assume -R? [n]"
>
> If I type y, I get:
>
> "Hunk #1 succeeded at 462 with fuzz 2 (offset -18 lines).
> Hunk #2 FAILED at 1175.
> 1 out of 2 hunks FAILED -- saving rejects to file check_param_card.py.rej
> patching file write_param_card.py
> Hunk #1 FAILED at 174.
> Hunk #2 succeeded at 182 with fuzz 2.
> 1 out of 2 hunks FAILED -- saving rejects to file write_param_card.py.rej
> "
>
> and the rejected files look like:
> "
> --- check_param_card.py 2017-01-15 14:06:32 +0000
> +++ check_param_card.py 2016-11-20 14:05:38 +0000
> @@ -1175,10 +1176,10 @@
> is_modified = True
> if log ==20:
> logger.log(log,'For model consistency, update %s with id %s to value %s',
> - block, id, 0.0, '$MG:color:BLACK')
> + (block, id, 0.0), '$MG:color:BLACK')
> elif log:
> logger.log(log,'For model consistency, update %s with id %s to value %s',
> - block, id, 0.0)
> + (block, id, 0.0))
>
> # check one
> for block, id, comment in self.one:
> "
>
> and
>
> "
> --- write_param_card.py 2016-09-06 11:24:51 +0000
> +++ write_param_card.py 2017-01-15 14:06:15 +0000
> @@ -174,6 +174,7 @@
>
> # order the parameter in a smart way
> self.external.sort(self.order_param)
> + todo_block= ['MASS', 'DECAY'] # ensure that those two block are always written
>
> cur_lhablock = ''
> for param in self.external:
> "
>
> and with "n":
>
> "
> Hunk #1 FAILED at 480.
> Hunk #2 FAILED at 1175.
> 2 out of 2 hunks FAILED -- saving rejects to file check_param_card.py.rej
> patching file write_param_card.py
> Hunk #1 FAILED at 174.
> Hunk #2 FAILED at 182.
> 2 out of 2 hunks FAILED -- saving rejects to file write_param_card.py.rej
> "
>
> And as you'd expect if I run MG after applying the patch like so then it crashes.
> Any idea why the patch doesn't seem to be working? Should I try and apply it manually?
> Is it possible our starting files are different, I have the latest version from the website though?
>
> Thanks,
> Vincent
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Revision history for this message
Vincent Groff (vgroff) said :
#6

Updated to developed branch, it's working fine now.

Thanks!
Vincent