Force param_card update after running set?

Asked by andlessa on 2018-06-06

Hi,

I'm running generate_events, where I use "set [param] [value]" to change values in my param_card.
After running set, I run compute_widths all [options] to get all the widths.
However, I've noticed that compute_widths still uses the "old" param_card values.
Is there an easy way to force an update of the param_card before running compute_widths?
Here is a "toy" code snippet to reproduce the issue:

./generate_events
0 #Done with default options
set mass 25 150 #Sets the Higgs mass to 150 (previous value was 125)
compute_widths all #Re-compute widths, but uses mh = 125
0 #Run event generation . Events are generated with mh = 150

Thanks.

-Andre

Question information

Language:
English Edit question
Status:
Solved
For:
MadGraph5_aMC@NLO Edit question
Assignee:
No assignee Edit question
Solved by:
Olivier Mattelaer
Solved:
2018-06-07
Last query:
2018-06-07
Last reply:
2018-06-07

Hi,

Thanks for the information.
I can see three solutions:

1) open the param_card for edition and then close it.
This is obviously not nice with scripting.

2) use the command "set width all Auto"
The problem of that one is that you can not change the result of the computation afterwards if needed.

3) apply the following patch

=== modified file 'madgraph/interface/common_run_interface.py'
--- madgraph/interface/common_run_interface.py 2018-05-25 09:13:24 +0000
+++ madgraph/interface/common_run_interface.py 2018-06-07 07:03:55 +0000
@@ -6143,6 +6143,12 @@

     def do_compute_widths(self, line):
         signal.alarm(0) # avoid timer if any
+
+ # ensure that the card is in sync
+ if 'param' in self.modified_card:
+ self.write_card('param')
+ self.modified_card.discard('param')
+
         path = self.paths['param']
         pattern = re.compile(r'''decay\s+(\+?\-?\d+)\s+auto(@NLO|)''',re.I)
         text = open(path).read()
@@ -6260,7 +6266,7 @@
             logger.info("add in the pythia8_card the parameter \"%s\" with value \"%s\"" % (name, value), '$MG:BOLD')
         elif len(args) > 0:
             if args[0] in self.cards:
- card = args[0]
+ card = args[0]
             elif "%s.dat" % args[0] in self.cards:
                 card = "%s.dat" % args[0]
             elif "%s_card.dat" % args[0] in self.cards:
@@ -6270,7 +6276,11 @@
             else:
                 logger.error("unknow card %s. Please retry." % args[0])
                 return
-
+ # ensure that the card is in sync
+ if card in self.modified_card:
+ self.write_card(card)
+ self.modified_card.discard(card)
+
             if card in self.paths:
                 path = self.paths[card]
             elif os.path.exists(card):
@@ -6434,6 +6444,12 @@
         """Running ASperGe"""
         signal.alarm(0) # avoid timer if any

+ # ensure that the card is in sync
+ if 'param' in self.modified_card:
+ self.write_card('param')
+ self.modified_card.discard('param')
+
+
         path = pjoin(self.me_dir,'bin','internal','ufomodel','ASperGE')
         if not os.path.exists(path):
             logger.error('ASperge has not been detected in the current model, therefore it will not be run.')

This patch will be included in the next version (but if it creates issue detected by our test suite)

Cheers,

Olivier

> On 6 Jun 2018, at 15:32, andlessa <email address hidden> wrote:
>
> New question #670019 on MadGraph5_aMC@NLO:
> https://answers.launchpad.net/mg5amcnlo/+question/670019
>
> Hi,
>
> I'm running generate_events, where I use "set [param] [value]" to change values in my param_card.
> After running set, I run compute_widths all [options] to get all the widths.
> However, I've noticed that compute_widths still uses the "old" param_card values.
> Is there an easy way to force an update of the param_card before running compute_widths?
> Here is a "toy" code snippet to reproduce the issue:
>
> ./generate_events
> 0 #Done with default options
> set mass 25 150 #Sets the Higgs mass to 150 (previous value was 125)
> compute_widths all #Re-compute widths, but uses mh = 125
> 0 #Run event generation . Events are generated with mh = 150
>
> Thanks.
>
> -Andre
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

andlessa (lessa-a-p) said : #2

Thanks Olivier Mattelaer, that solved my question.

andlessa (lessa-a-p) said : #3

Btw, I see that there is an "update" command, but no option to update the full parameter card.
Maybe this could be added in the future?

What do you mean/want by "update the full parameter card."
If you type a path to a file (and if the content of that file is formatted as a param_card)
it will overwrite the param_card is that what you want/need?

> >[timer stopped]
> ./myfile.mg5
> Display all 307 possibilities? (y or n)
> >./myfile.mg5
> INFO: copy ./myfile.mg5 as param_card.dat

The same work for run_card,... obviously (as long as the formatting allow us to determine which type of card it is.)

Cheers,

Olivier

> On 7 Jun 2018, at 10:02, andlessa <email address hidden> wrote:
>
> Question #670019 on MadGraph5_aMC@NLO changed:
> https://answers.launchpad.net/mg5amcnlo/+question/670019
>
> andlessa posted a new comment:
> Btw, I see that there is an "update" command, but no option to update the full parameter card.
> Maybe this could be added in the future?
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

andlessa (lessa-a-p) said : #5

What I meant was that after running multiple 'set [param] [value]', the user could run 'update param_card', so the values
specified by 'set xxx' are written to the param_card file.
This way one makes sure that the param_card stores the user specified parameters and that these will be used by compute_widths (if compute_widths is run after 'update param_card').
But I don't know if it makes sense within the generate_events workflow.

Hi,

The compute_widths should update the card first (as it is done with the patch).
Does not really make sense to have a command for that. The only case where such command will really make sense is some crazy scenario that it is better to not support at all.
(mix edition of the card via set command and via text editor outside of MG5aMC)

Cheers and thanks,

Olivier

> On 7 Jun 2018, at 10:22, andlessa <email address hidden> wrote:
>
> Question #670019 on MadGraph5_aMC@NLO changed:
> https://answers.launchpad.net/mg5amcnlo/+question/670019
>
> andlessa posted a new comment:
> What I meant was that after running multiple 'set [param] [value]', the user could run 'update param_card', so the values
> specified by 'set xxx' are written to the param_card file.
> This way one makes sure that the param_card stores the user specified parameters and that these will be used by compute_widths (if compute_widths is run after 'update param_card').
> But I don't know if it makes sense within the generate_events workflow.
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.