Writing events at NLO

Asked by Matthew Low

Dear MadGraph team,

When running at NLO the cross-section is computed but there seems to be an issue with storing the events. I get the error message:

INFO: Combining Events
Command "generate_events --multicore -f" interrupted with error:
AttributeError : class GzipFile has no attribute '__new__'
Please report this bug on https://bugs.launchpad.net/madgraph5
More information is found in '/project/liantaow/Multihiggs/MG5_aMC_v2_3_0_beta/my_test/run_02_tag_1_debug.log'.
Please attach this file to your report.
quit

There are no problems when running a process at LO.

Thanks!
- Matthew

Question information

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

Dear Matthew,

Thanks for the very useful report.

However, I did not succeed to reproduce your bug (for which process did this happen?)
 I have try p p > t t~ [QCD] and it works fine.
However, some LO computation (like g g > h [QCD]) indeed have that problem.
This problem might be also present for NLO computation if you run MadSpin (but I did not check actually)

Actually this happens ONLY with python2.6 and not with python2.7
Looks like that they have update the class “GzipFile” between the two version (from a old class type of python to a new class type)
but this information is missing in their documentation and therefore I miss the compatibility issue with 2.6.

Here is a patch, that fixes the problem that i face for gluon production:

=== modified file 'madgraph/various/lhe_parser.py'
--- madgraph/various/lhe_parser.py 2015-05-22 16:18:38 +0000
+++ madgraph/various/lhe_parser.py 2015-05-28 01:08:55 +0000
@@ -150,7 +150,18 @@
     def __new__(self, path, mode='r', *args, **opt):

         if path.endswith(".gz"):
- return gzip.GzipFile.__new__(EventFileGzip, path, mode, *args, **opt)
+ try:
+ return gzip.GzipFile.__new__(EventFileGzip, path, mode, *args, **opt)
+ except IOError, error:
+ raise
+ except Exception, error:
+ if mode == 'r':
+ misc.gunzip(path)
+ return file.__new__(EventFileNoGzip, path[:-3], mode, *args, **opt)
         else:
             return file.__new__(EventFileNoGzip, path, mode, *args, **opt)

=== modified file 'madgraph/various/misc.py'
--- madgraph/various/misc.py 2015-05-14 00:17:43 +0000
+++ madgraph/various/misc.py 2015-05-28 01:21:35 +0000
@@ -742,8 +742,20 @@
         return 0

     if not stdout:
- stdout = path[:-3]
- open(stdout,'w').write(ziplib.open(path, "r").read())
+ stdout = path[:-3]
+ try:
+ gfile = ziplib.open(path, "r")
+ except IOError:
+ raise
+ else:
+ try:
+ open(stdout,'w').write(gfile.read())
+ except IOError:
+ if stdout == path:
+ return
+ else:
+ files.cp(path, stdout)
+
     if not keep:
         os.remove(path)
     return 0

Cheers,

Olivier

On 28 May 2015, at 01:07, Matthew Low <email address hidden> wrote:

> New question #267481 on MadGraph5_aMC@NLO:
> https://answers.launchpad.net/mg5amcnlo/+question/267481
>
> Dear MadGraph team,
>
> When running at NLO the cross-section is computed but there seems to be an issue with storing the events. I get the error message:
>
>
> INFO: Combining Events
> Command "generate_events --multicore -f" interrupted with error:
> AttributeError : class GzipFile has no attribute '__new__'
> Please report this bug on https://bugs.launchpad.net/madgraph5
> More information is found in '/project/liantaow/Multihiggs/MG5_aMC_v2_3_0_beta/my_test/run_02_tag_1_debug.log'.
> Please attach this file to your report.
> quit
>
>
> There are no problems when running a process at LO.
>
> Thanks!
> - Matthew
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Revision history for this message
Matthew Low (mattlow) said :
#2

Ah, sorry, I meant for loop-induced processes (specifically p p > h [QCD]). I switched to python 2.7 and then it worked (and p p > t t~ [QCD] worked fine even with python 2.6).

Thanks!
- Matthew