problem with continuation lines in input files (probably in MadSpin code)

Bug #1548882 reported by Kilian Rosbach
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
MadGraph5_aMC@NLO
Fix Released
Undecided
Unassigned

Bug Description

I've come across an unusual error message while running a simple MadGraph+MadSpin event generation (I believe the details are unimportant, but I can provide them if requested): MadSpin fails, complaining about an unknown particle "dl~dr~" (notice the missing space between what should actually be two SUSY particles).

The exact message is: "InvalidCmd : No particle dl~dr~ in model"

Studying the input files, I found the following continued (with \ at the end) line:
"define susystrong = go ul ur dl dr cl cr sl sr t1 t2 b1 b2 ul~ ur~ dl~\
 dr~ cl~ cr~ sl~ sr~ t1~ t2~ b1~ b2~"
in the file PROC_mssm_0/Cards/proc_card_mg5.dat

It appears that the space following the backslash-newline combination is lost while reading this file. The problem disappears if I manually replace the file by one that doesn't use continued lines instead, but this is very difficult to do when running on the grid (the file is automatically generated by a script outside of my control).

Is this easy to fix on your end?

Thanks and best regards!

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote : Re: [Bug 1548882] [NEW] problem with continuation lines in input files (probably in MadSpin code)
Download full text (3.2 KiB)

Dear Kilian,

Here is a simple fix:

=== modified file 'madgraph/interface/extended_cmd.py'
--- madgraph/interface/extended_cmd.py 2016-01-23 00:40:59 +0000
+++ madgraph/interface/extended_cmd.py 2016-02-23 16:48:44 +0000
@@ -579,7 +579,7 @@

         # Check if the line is complete
         if line.endswith('\\'):
- self.save_line = line[:-1]
+ self.save_line = line[:-1] + ' '
             return '' # do nothing

         # Remove comment

Thanks a lot for your help,

Olivier

> On Feb 23, 2016, at 15:49, Kilian Rosbach <email address hidden> wrote:
>
> Public bug reported:
>
> I've come across an unusual error message while running a simple
> MadGraph+MadSpin event generation (I believe the details are
> unimportant, but I can provide them if requested): MadSpin fails,
> complaining about an unknown particle "dl~dr~" (notice the missing space
> between what should actually be two SUSY particles).
>
> The exact message is: "InvalidCmd : No particle dl~dr~ in model"
>
> Studying the input files, I found the following continued (with \ at the end) line:
> "define susystrong = go ul ur dl dr cl cr sl sr t1 t2 b1 b2 ul~ ur~ dl~\
> dr~ cl~ cr~ sl~ sr~ t1~ t2~ b1~ b2~"
> in the file PROC_mssm_0/Cards/proc_card_mg5.dat
>
> It appears that the space following the backslash-newline combination is
> lost while reading this file. The problem disappears if I manually
> replace the file by one that doesn't use continued lines instead, but
> this is very difficult to do when running on the grid (the file is
> automatically generated by a script outside of my control).
>
> Is this easy to fix on your end?
>
> Thanks and best regards!
>
> ** Affects: mg5amcnlo
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are subscribed to
> MadGraph5_aMC@NLO.
> https://bugs.launchpad.net/bugs/1548882
>
> Title:
> problem with continuation lines in input files (probably in MadSpin
> code)
>
> Status in MadGraph5_aMC@NLO:
> New
>
> Bug description:
> I've come across an unusual error message while running a simple
> MadGraph+MadSpin event generation (I believe the details are
> unimportant, but I can provide them if requested): MadSpin fails,
> complaining about an unknown particle "dl~dr~" (notice the missing
> space between what should actually be two SUSY particles).
>
> The exact message is: "InvalidCmd : No particle dl~dr~ in model"
>
> Studying the input files, I found the following continued (with \ at the end) line:
> "define susystrong = go ul ur dl dr cl cr sl sr t1 t2 b1 b2 ul~ ur~ dl~\
> dr~ cl~ cr~ sl~ sr~ t1~ t2~ b1~ b2~"
> in the file PROC_mssm_0/Cards/proc_card_mg5.dat
>
> It appears that the space following the backslash-newline combination
> is lost while reading this file. The problem disappears if I manually
> replace the file by one that doesn't use continued lines instead, but
> this is very difficult to do when running on the grid (the file is
> automatically generated by a script outside of my control).
>
> Is this easy to fix on your end?
>
> Thanks and best regards!
>
> To manage n...

Read more...

Changed in mg5amcnlo:
status: New → Fix Committed
Revision history for this message
Kilian Rosbach (kilian-rosbach) wrote :

Hi Olivier,

thanks a lot for the super-fast reply!

I've looked at extended_cmd.py, and while I agree your fix will work for the particular case I mentioned, I think there might be an easy way to have a more general solution that will also work if the second line does not start with a space:

In lines 523-525, the first part of the continued line is added to the current line:
        if self.save_line:
            line = self.save_line + line
            self.save_line = ''
But just before that, in line 520, any spaces at the beginning of the line are removed:
        line = line.lstrip()

I would suggest to simply reverse the order of these two blocks of code, then it should work in all cases I believe.

Thanks again and cheers,
Kilian

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote : Re: [Bug 1548882] problem with continuation lines in input files (probably in MadSpin code)

Hi,

You are right this is a nicer fix.

Thanks a lot,

Olivier

> On Feb 23, 2016, at 17:54, Kilian Rosbach <email address hidden> wrote:
>
> Hi Olivier,
>
> thanks a lot for the super-fast reply!
>
> I've looked at extended_cmd.py, and while I agree your fix will work for
> the particular case I mentioned, I think there might be an easy way to
> have a more general solution that will also work if the second line does
> not start with a space:
>
> In lines 523-525, the first part of the continued line is added to the current line:
> if self.save_line:
> line = self.save_line + line
> self.save_line = ''
> But just before that, in line 520, any spaces at the beginning of the line are removed:
> line = line.lstrip()
>
> I would suggest to simply reverse the order of these two blocks of code,
> then it should work in all cases I believe.
>
> Thanks again and cheers,
> Kilian
>
> --
> You received this bug notification because you are subscribed to
> MadGraph5_aMC@NLO.
> https://bugs.launchpad.net/bugs/1548882
>
> Title:
> problem with continuation lines in input files (probably in MadSpin
> code)
>
> Status in MadGraph5_aMC@NLO:
> Fix Committed
>
> Bug description:
> I've come across an unusual error message while running a simple
> MadGraph+MadSpin event generation (I believe the details are
> unimportant, but I can provide them if requested): MadSpin fails,
> complaining about an unknown particle "dl~dr~" (notice the missing
> space between what should actually be two SUSY particles).
>
> The exact message is: "InvalidCmd : No particle dl~dr~ in model"
>
> Studying the input files, I found the following continued (with \ at the end) line:
> "define susystrong = go ul ur dl dr cl cr sl sr t1 t2 b1 b2 ul~ ur~ dl~\
> dr~ cl~ cr~ sl~ sr~ t1~ t2~ b1~ b2~"
> in the file PROC_mssm_0/Cards/proc_card_mg5.dat
>
> It appears that the space following the backslash-newline combination
> is lost while reading this file. The problem disappears if I manually
> replace the file by one that doesn't use continued lines instead, but
> this is very difficult to do when running on the grid (the file is
> automatically generated by a script outside of my control).
>
> Is this easy to fix on your end?
>
> Thanks and best regards!
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/mg5amcnlo/+bug/1548882/+subscriptions

Revision history for this message
Kilian Rosbach (kilian-rosbach) wrote :

Hello again,

it turns out that one additional change is needed to fully get things to work in the case of continued lines in proc_card_mg5.dat read by MadSpin. It took me a while to track this down, and maybe there is a more elegant:
In madgraph/various/banner.py, in the function read(self, init), the line = line.strip() statement needs to be removed, then it works for me.
In order to keep the change minimal, one could modify "self.append(store_line + line)" to "self.append((store_line + line).strip())" a few lines further down.

Cheers,
Kilian

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote :

Hi,

Thanks so much for the time that you spent to track down this. It is really appreciated.

Cheers,

Olivier

I will do the following:
=== modified file 'madgraph/various/banner.py'
--- madgraph/various/banner.py 2016-01-30 16:53:08 +0000
+++ madgraph/various/banner.py 2016-03-02 12:05:34 +0000
@@ -732,14 +732,17 @@

         store_line = ''
         for line in init:
- line = line.strip()
+ line = line.rstrip()
             if line.endswith('\\'):
                 store_line += line[:-1]
             else:
- self.append(store_line + line)
+ tmp = store_line + line
+ self.append(tmp.store_line)
                 store_line = ""
         if store_line:
             raise Exception, "WRONG CARD FORMAT"
+
+
     def move_to_last(self, cmd):
         """move an element to the last history."""
         for line in self[:]:

> On Mar 1, 2016, at 21:43, Kilian Rosbach <email address hidden> wrote:
>
> Hello again,
>
> it turns out that one additional change is needed to fully get things to work in the case of continued lines in proc_card_mg5.dat read by MadSpin. It took me a while to track this down, and maybe there is a more elegant:
> In madgraph/various/banner.py, in the function read(self, init), the line = line.strip() statement needs to be removed, then it works for me.
> In order to keep the change minimal, one could modify "self.append(store_line + line)" to "self.append((store_line + line).strip())" a few lines further down.
>
> Cheers,
> Kilian
>
> --
> You received this bug notification because you are subscribed to
> MadGraph5_aMC@NLO.
> https://bugs.launchpad.net/bugs/1548882
>
> Title:
> problem with continuation lines in input files (probably in MadSpin
> code)
>
> Status in MadGraph5_aMC@NLO:
> Fix Committed
>
> Bug description:
> I've come across an unusual error message while running a simple
> MadGraph+MadSpin event generation (I believe the details are
> unimportant, but I can provide them if requested): MadSpin fails,
> complaining about an unknown particle "dl~dr~" (notice the missing
> space between what should actually be two SUSY particles).
>
> The exact message is: "InvalidCmd : No particle dl~dr~ in model"
>
> Studying the input files, I found the following continued (with \ at the end) line:
> "define susystrong = go ul ur dl dr cl cr sl sr t1 t2 b1 b2 ul~ ur~ dl~\
> dr~ cl~ cr~ sl~ sr~ t1~ t2~ b1~ b2~"
> in the file PROC_mssm_0/Cards/proc_card_mg5.dat
>
> It appears that the space following the backslash-newline combination
> is lost while reading this file. The problem disappears if I manually
> replace the file by one that doesn't use continued lines instead, but
> this is very difficult to do when running on the grid (the file is
> automatically generated by a script outside of my control).
>
> Is this easy to fix on your end?
>
> Thanks and best regards!
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/mg5amcnlo/+bug/1548882/+subscriptions

Revision history for this message
Kilian Rosbach (kilian-rosbach) wrote :
Download full text (3.5 KiB)

Hi Olivier,

I'm happy to help!

I agree it's a good to add the rstrip() command in case there are any
newline characters present.

If I'm not mistaken you probably wanted to write
self.append(tmp.strip())
instead of
self.append(tmp.store_line)

Do you perhaps know already when this will appear in an official
MadGraph release?

Thanks and cheers,
Kilian

On 02.03.2016 13:08, Olivier Mattelaer wrote:
> Hi,
>
> Thanks so much for the time that you spent to track down this. It is
> really appreciated.
>
> Cheers,
>
> Olivier
>
> I will do the following:
> === modified file 'madgraph/various/banner.py'
> --- madgraph/various/banner.py 2016-01-30 16:53:08 +0000
> +++ madgraph/various/banner.py 2016-03-02 12:05:34 +0000
> @@ -732,14 +732,17 @@
>
> store_line = ''
> for line in init:
> - line = line.strip()
> + line = line.rstrip()
> if line.endswith('\\'):
> store_line += line[:-1]
> else:
> - self.append(store_line + line)
> + tmp = store_line + line
> + self.append(tmp.store_line)
> store_line = ""
> if store_line:
> raise Exception, "WRONG CARD FORMAT"
> +
> +
> def move_to_last(self, cmd):
> """move an element to the last history."""
> for line in self[:]:
>
>
>> On Mar 1, 2016, at 21:43, Kilian Rosbach <email address hidden> wrote:
>>
>> Hello again,
>>
>> it turns out that one additional change is needed to fully get things to work in the case of continued lines in proc_card_mg5.dat read by MadSpin. It took me a while to track this down, and maybe there is a more elegant:
>> In madgraph/various/banner.py, in the function read(self, init), the line = line.strip() statement needs to be removed, then it works for me.
>> In order to keep the change minimal, one could modify "self.append(store_line + line)" to "self.append((store_line + line).strip())" a few lines further down.
>>
>> Cheers,
>> Kilian
>>
>> --
>> You received this bug notification because you are subscribed to
>> MadGraph5_aMC@NLO.
>> https://bugs.launchpad.net/bugs/1548882
>>
>> Title:
>> problem with continuation lines in input files (probably in MadSpin
>> code)
>>
>> Status in MadGraph5_aMC@NLO:
>> Fix Committed
>>
>> Bug description:
>> I've come across an unusual error message while running a simple
>> MadGraph+MadSpin event generation (I believe the details are
>> unimportant, but I can provide them if requested): MadSpin fails,
>> complaining about an unknown particle "dl~dr~" (notice the missing
>> space between what should actually be two SUSY particles).
>>
>> The exact message is: "InvalidCmd : No particle dl~dr~ in model"
>>
>> Studying the input files, I found the following continued (with \ at the end) line:
>> "define susystrong = go ul ur dl dr cl cr sl sr t1 t2 b1 b2 ul~ ur~ dl~\
>> dr~ cl~ cr~ sl~ sr~ t1~ t2~ b1~ b2~"
>> in the file PROC_mssm_0/Cards/proc_card_mg5.dat
>>
>> It appears that the space following the backslash-newline combination
>> is lost while reading this file. The problem disappears if I manually
>> replace the fil...

Read more...

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote :
Download full text (5.7 KiB)

Hi Kilian,

> If I'm not mistaken you probably wanted to write
> self.append(tmp.strip())
> instead of
> self.append(tmp.store_line)

Oops, I realized my mistake and change it in the code, but the diff was already created and I forget to edit it.
Sorry.

> Do you perhaps know already when this will appear in an official
> MadGraph release?

We are preparing the 2.4.0 version for the moment. All the feature that we want to put it are in the internal review process.
So I hope it will out in before the end of the month at latest.

Cheers,

Olivier

> On Mar 2, 2016, at 15:46, Kilian Rosbach <email address hidden> wrote:
>
> Hi Olivier,
>
> I'm happy to help!
>
> I agree it's a good to add the rstrip() command in case there are any
> newline characters present.
>
> If I'm not mistaken you probably wanted to write
> self.append(tmp.strip())
> instead of
> self.append(tmp.store_line)
>
> Do you perhaps know already when this will appear in an official
> MadGraph release?
>
> Thanks and cheers,
> Kilian
>
> On 02.03.2016 13:08, Olivier Mattelaer wrote:
>> Hi,
>>
>> Thanks so much for the time that you spent to track down this. It is
>> really appreciated.
>>
>> Cheers,
>>
>> Olivier
>>
>> I will do the following:
>> === modified file 'madgraph/various/banner.py'
>> --- madgraph/various/banner.py 2016-01-30 16:53:08 +0000
>> +++ madgraph/various/banner.py 2016-03-02 12:05:34 +0000
>> @@ -732,14 +732,17 @@
>>
>> store_line = ''
>> for line in init:
>> - line = line.strip()
>> + line = line.rstrip()
>> if line.endswith('\\'):
>> store_line += line[:-1]
>> else:
>> - self.append(store_line + line)
>> + tmp = store_line + line
>> + self.append(tmp.store_line)
>> store_line = ""
>> if store_line:
>> raise Exception, "WRONG CARD FORMAT"
>> +
>> +
>> def move_to_last(self, cmd):
>> """move an element to the last history."""
>> for line in self[:]:
>>
>>
>>> On Mar 1, 2016, at 21:43, Kilian Rosbach <email address hidden> wrote:
>>>
>>> Hello again,
>>>
>>> it turns out that one additional change is needed to fully get things to work in the case of continued lines in proc_card_mg5.dat read by MadSpin. It took me a while to track this down, and maybe there is a more elegant:
>>> In madgraph/various/banner.py, in the function read(self, init), the line = line.strip() statement needs to be removed, then it works for me.
>>> In order to keep the change minimal, one could modify "self.append(store_line + line)" to "self.append((store_line + line).strip())" a few lines further down.
>>>
>>> Cheers,
>>> Kilian
>>>
>>> --
>>> You received this bug notification because you are subscribed to
>>> MadGraph5_aMC@NLO.
>>> https://bugs.launchpad.net/bugs/1548882
>>>
>>> Title:
>>> problem with continuation lines in input files (probably in MadSpin
>>> code)
>>>
>>> Status in MadGraph5_aMC@NLO:
>>> Fix Committed
>>>
>>> Bug description:
>>> I've come across an unusual error message while running a simple
>>> MadGraph+MadSpin event generation...

Read more...

Changed in mg5amcnlo:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.