Merge lp:~maddevelopers/mg5amcnlo/FixMA5 into lp:~mg5core2/mg5amcnlo/2.6.1

Proposed by Valentin Hirschi
Status: Merged
Merged at revision: 307
Proposed branch: lp:~maddevelopers/mg5amcnlo/FixMA5
Merge into: lp:~mg5core2/mg5amcnlo/2.6.1
Diff against target: 230 lines (+81/-15)
5 files modified
VERSION (+1/-1)
madgraph/interface/common_run_interface.py (+12/-7)
madgraph/interface/madgraph_interface.py (+15/-2)
madgraph/madevent/gen_crossxhtml.py (+5/-5)
madgraph/various/misc.py (+48/-0)
To merge this branch: bzr merge lp:~maddevelopers/mg5amcnlo/FixMA5
Reviewer Review Type Date Requested Status
Olivier Mattelaer Approve
Benjamin Fuks Pending
Review via email: mp+333963@code.launchpad.net

Description of the change

1. Fixed the handling of MA5 output paths so as to comply with the new standards introduced in MA5 v1.6.32.

2. The installation and handling of MA5 has been adjusted so as to make sure that MG5 and MA5 version are compatible.
     Namely:
        MG5 v2.6+ requires MA5 v1.6.32+
        MG5 v2.6- requires MA5 v1.6.21-
This will require Benjamin to set up the online links I asked him to setup and for us to update the online version on the servers of the HEPToolsInstaller.
The links you should setup Benj are:

http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/ma5_latest.tgz

with v1.6.32 and

http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/ma5_v_1_6_21.tgz

with v1.6.21

And as soon as we are done with this merge, you can remove the following old link:

http://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/ma5.tgz

For now Olivier, you can test the new MA5 version 1.6.32 by installing it with:
   install madanalysis5 --madanalysis5_tarball=https://madanalysis.irmp.ucl.ac.be/raw-attachment/wiki/MA5SandBox/ma5_new.tgz

And Benj, please check that the handling of the recasting output (path-wise) is correctly handled with this new version (that is, you can find the CLs link in the MG5 HTML summary).

Let us please have this in for the next release, also because Kentarou needs it for a school.

To post a comment you must log in.
lp:~maddevelopers/mg5amcnlo/FixMA5 updated
300. By Valentin Hirschi

1. Small Fix, I should require MG5aMC version 2.6.1+ not 2.6.0+

Revision history for this message
Valentin Hirschi (valentin-hirschi) wrote :

Sorry, the above should read:

     Namely:
        MG5 v2.6.1+ requires MA5 v1.6.32+
        MG5 v2.6.1- requires MA5 v1.6.21-

I just modified and pushed the code so as to match the above.

lp:~maddevelopers/mg5amcnlo/FixMA5 updated
301. By Valentin Hirschi

1. Reworked the version check for MA5 so as to apply it both at set_configuration and do_set stage.

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

Hi Valentin,

Perfect, nicely done. just one minor comment to fix before merging.

1)
@@ -2755,6 +2760,7 @@
                 shutil.copy(target, pjoin(self.me_dir,'Events',self.run_name,carboncopy_name))
             else:
                 logger.error('MadAnalysis5 failed to create PDF output')
+ stop

stop is not a valid python syntax. Is that a debug statement that you forget to remove?

review: Approve
lp:~maddevelopers/mg5amcnlo/FixMA5 updated
302. By Valentin Hirschi

1. Removal of a left-over 'stop' debug statement.

Revision history for this message
Valentin Hirschi (valentin-hirschi) wrote :

On Thu, Nov 23, 2017 at 12:53 PM, Olivier Mattelaer <
<email address hidden>> wrote:

> Review: Approve
>
> Hi Valentin,
>
> Perfect, nicely done. just one minor comment to fix before merging.
>
> 1)
> @@ -2755,6 +2760,7 @@
> shutil.copy(target,
> pjoin(self.me_dir,'Events',self.run_name,carboncopy_name))
> else:
> logger.error('MadAnalysis5 failed to create PDF output')
> + stop
>
> stop is not a valid python syntax. Is that a debug statement that you
> forget to remove?
>

Yes, thank you for having spotted this. I pushed the removal of this line.

>
>
>
>
>
> Diff comments:
>
> >
> > === modified file 'madgraph/interface/common_run_interface.py'
> > --- madgraph/interface/common_run_interface.py 2017-11-17
> 12:35:40 +0000
> > +++ madgraph/interface/common_run_interface.py 2017-11-21
> 13:27:59 +0000
> > @@ -2755,6 +2760,7 @@
> > shutil.copy(target,
> pjoin(self.me_dir,'Events',self.run_name,carboncopy_name))
> > else:
> > logger.error('MadAnalysis5 failed to create PDF output')
> > + stop
>
> Well stop is not a valid python syntax -> should be raise Exception
> "MadAnalysis5 failed to create PDF output" if you really want to make the
> code to crash (but do we want that?)
>
> > if MA5_runtag!='default':
> > logger.info("MadAnalysis5 successfully completed the "+
> > "%s. Reported results are placed in:"%("analysis
> '%s'"%MA5_runtag
>
>
> --
> https://code.launchpad.net/~maddevelopers/mg5amcnlo/FixMA5/+merge/333963
> Your team MadDevelopers is subscribed to branch
> lp:~maddevelopers/mg5amcnlo/FixMA5.
>

--
Valentin
--
Valentin

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'VERSION'
2--- VERSION 2017-08-16 21:28:30 +0000
3+++ VERSION 2017-11-23 12:02:36 +0000
4@@ -1,4 +1,4 @@
5-version = 2.6.0
6+version = 2.6.1
7 date = 2017-08-16
8
9
10
11=== modified file 'madgraph/interface/common_run_interface.py'
12--- madgraph/interface/common_run_interface.py 2017-11-17 12:35:40 +0000
13+++ madgraph/interface/common_run_interface.py 2017-11-23 12:02:36 +0000
14@@ -2661,8 +2661,11 @@
15 # Make sure to only run over one analysis over each fifo.
16 used_up_fifos = []
17 # Now loop over the different MA5_runs
18- for MA5_runtag, MA5_cmds in MA5_cmds_list:
19+ for MA5_run_number, (MA5_runtag, MA5_cmds) in enumerate(MA5_cmds_list):
20
21+ # Since we place every MA5 run in a fresh new folder, the MA5_run_number
22+ # is always zero.
23+ MA5_run_number = 0
24 # Bypass the banner.
25 MA5_interpreter.setLogLevel(100)
26 # Make sure to properly initialize MA5 interpreter
27@@ -2689,7 +2692,7 @@
28 pjoin(self.me_dir,'Events',self.run_name,'%s_MA5_%s.log'%(self.run_tag,MA5_runtag))):
29 # Unsuccessful MA5 run, we therefore stop here.
30 return
31-
32+
33 if MA5_runtag.startswith('_reco_'):
34 # When doing a reconstruction we must first link the event file
35 # created with MA5 reconstruction and then directly proceed to the
36@@ -2712,8 +2715,8 @@
37 reco_output = pjoin(self.me_dir,
38 'MA5_%s_ANALYSIS%s_%d'%(mode.upper(),MA5_runtag,i+1))
39 # Look for either a root or .lhe.gz output
40- reco_event_file = misc.glob('*.lhe.gz',pjoin(reco_output,'Output','_reco_events'))+\
41- misc.glob('*.root',pjoin(reco_output,'Output','_reco_events'))
42+ reco_event_file = misc.glob('*.lhe.gz',pjoin(reco_output,'Output','_reco_events','lheEvents0_%d'%MA5_run_number))+\
43+ misc.glob('*.root',pjoin(reco_output,'Output','_reco_events', 'RecoEvents0_%d'%MA5_run_number))
44 if len(reco_event_file)==0:
45 raise MadGraph5Error, "MadAnalysis5 failed to produce the "+\
46 "reconstructed event file for reconstruction '%s'."%MA5_runtag[6:]
47@@ -2722,13 +2725,15 @@
48 shutil.move(reco_output,pjoin(self.me_dir,'HTML',
49 self.run_name,'%s_MA5_%s_ANALYSIS%s_%d'%
50 (self.run_tag,mode.upper(),MA5_runtag,i+1)))
51+
52 # link the reconstructed event file to the run directory
53 links_created.append(os.path.basename(reco_event_file))
54+ parent_dir_name = os.path.basename(os.path.dirname(reco_event_file))
55 files.ln(pjoin(self.me_dir,'HTML',self.run_name,
56 '%s_MA5_%s_ANALYSIS%s_%d'%(self.run_tag,mode.upper(),
57- MA5_runtag,i+1),'Output','_reco_events',links_created[-1]),
58+ MA5_runtag,i+1),'Output','_reco_events',parent_dir_name,links_created[-1]),
59 pjoin(self.me_dir,'Events',self.run_name))
60-
61+
62 logger.info("MadAnalysis5 successfully completed the reconstruction "+
63 "'%s'. Links to the reconstructed event files are:"%MA5_runtag[6:])
64 for link in links_created:
65@@ -2740,7 +2745,7 @@
66 %(mode.upper(),MA5_runtag),'Output','CLs_output_summary.dat')
67 else:
68 target = pjoin(self.me_dir,'MA5_%s_ANALYSIS_%s'\
69- %(mode.upper(),MA5_runtag),'PDF','main.pdf')
70+ %(mode.upper(),MA5_runtag),'Output','PDF','MadAnalysis5job_%d'%MA5_run_number,'main.pdf')
71 has_pdf = True
72 if not os.path.isfile(target):
73 has_pdf = False
74
75=== modified file 'madgraph/interface/madgraph_interface.py'
76--- madgraph/interface/madgraph_interface.py 2017-11-02 10:22:25 +0000
77+++ madgraph/interface/madgraph_interface.py 2017-11-23 12:02:36 +0000
78@@ -39,7 +39,6 @@
79 import urllib
80 import random
81
82-
83 #useful shortcut
84 pjoin = os.path.join
85
86@@ -6527,7 +6526,13 @@
87 if not os.path.isfile(pjoin(path,'bin','ma5')):
88 self.options['madanalysis5_path'] = None
89 else:
90- continue
91+ ma5path = pjoin(MG5DIR, path) if os.path.isfile(pjoin(MG5DIR, path)) else path
92+ message = misc.is_MA5_compatible_with_this_MG5(ma5path)
93+ if not message is None:
94+ self.options['madanalysis5_path'] = None
95+ logger.warning(message)
96+ continue
97+
98 #this is for hw++
99 if key == 'hwpp_path' and not os.path.isfile(pjoin(MG5DIR, path, 'include', 'Herwig++', 'Analysis', 'BasicConsistency.hh')):
100 if not os.path.isfile(pjoin(path, 'include', 'Herwig++', 'Analysis', 'BasicConsistency.hh')):
101@@ -7209,6 +7214,14 @@
102
103 self.options[args[0]] = (int(first), int(second))
104
105+ elif args[0] == 'madanalysis5_path':
106+ ma5path = pjoin(MG5DIR, args[1]) if os.path.isfile(pjoin(MG5DIR, args[1])) else args[1]
107+ message = misc.is_MA5_compatible_with_this_MG5(ma5path)
108+ if message is None:
109+ self.options['madanalysis5_path'] = args[1]
110+ else:
111+ logger.warning(message)
112+
113 elif args[0] == 'OLP':
114 # Reset the amplitudes, MatrixElements and exporter as they might
115 # depend on this option
116
117=== modified file 'madgraph/madevent/gen_crossxhtml.py'
118--- madgraph/madevent/gen_crossxhtml.py 2017-08-10 13:09:28 +0000
119+++ madgraph/madevent/gen_crossxhtml.py 2017-11-23 12:02:36 +0000
120@@ -850,7 +850,7 @@
121 self.parton.append('ma5_plot')
122
123 if 'ma5_html' not in self.parton and \
124- misc.glob(pjoin('%s_MA5_PARTON_ANALYSIS_*'%self['tag'],'HTML','index.html'),html_path):
125+ misc.glob(pjoin('%s_MA5_PARTON_ANALYSIS_*'%self['tag'],'Output','HTML','MadAnalysis5job_0','index.html'),html_path):
126 self.parton.append('ma5_html')
127
128 if 'ma5_card' not in self.parton and \
129@@ -868,7 +868,7 @@
130 self.madanalysis5_hadron.append('ma5_plot')
131
132 if 'ma5_html' not in self.madanalysis5_hadron and \
133- misc.glob(pjoin('%s_MA5_HADRON_ANALYSIS_*'%self['tag'],'HTML','index.html'),html_path):
134+ misc.glob(pjoin('%s_MA5_HADRON_ANALYSIS_*'%self['tag'],'Output','HTML','MadAnalysis5job_0','index.html'),html_path):
135 self.madanalysis5_hadron.append('ma5_html')
136
137 if 'ma5_cls' not in self.madanalysis5_hadron and \
138@@ -1055,7 +1055,7 @@
139 if 'ma5_html' in self.parton:
140 for result in misc.glob(pjoin('%s_MA5_PARTON_ANALYSIS_*'%self['tag']),
141 pjoin(self.me_dir,'HTML',self['run_name'])):
142- target = pjoin(os.curdir,os.path.relpath(result,self.me_dir),'HTML','index.html')
143+ target = pjoin(os.curdir,os.path.relpath(result,self.me_dir),'Output','HTML','MadAnalysis5job_0','index.html')
144 link_name = os.path.basename(result).split('PARTON_ANALYSIS')[-1]
145 out += """ <a href="%s">MA5_report%s</a> """%(target, link_name)
146
147@@ -1164,7 +1164,7 @@
148 linked_analysis = False
149 for result in misc.glob(pjoin('%s_MA5_HADRON_ANALYSIS_*'%self['tag']),
150 pjoin(self.me_dir,'HTML',self['run_name'])):
151- target = pjoin(os.curdir,os.path.relpath(result,self.me_dir),'HTML','index.html')
152+ target = pjoin(os.curdir,os.path.relpath(result,self.me_dir),'Output','HTML','MadAnalysis5job_0','index.html')
153 link_name = os.path.basename(result).split('HADRON_ANALYSIS')[-1]
154 if link_name.startswith('_reco_'):
155 continue
156@@ -1180,7 +1180,7 @@
157 for result in misc.glob(pjoin('%s_MA5_HADRON_ANALYSIS_*'%self['tag']),
158 pjoin(self.me_dir,'HTML',self['run_name'])):
159 target = pjoin(os.curdir,os.path.relpath(
160- result,self.me_dir),'HTML','index.html')
161+ result,self.me_dir),'Output','HTML','MadAnalysis5job_0','index.html')
162 link_name = os.path.basename(result).split('HADRON_ANALYSIS')[-1]
163 if not link_name.startswith('_reco_'):
164 continue
165
166=== modified file 'madgraph/various/misc.py'
167--- madgraph/various/misc.py 2017-10-05 15:19:01 +0000
168+++ madgraph/various/misc.py 2017-11-23 12:02:36 +0000
169@@ -29,6 +29,7 @@
170 import shutil
171 import traceback
172 import gzip as ziplib
173+from distutils.version import LooseVersion, StrictVersion
174
175 try:
176 # Use in MadGraph
177@@ -149,6 +150,53 @@
178
179 return time_info
180
181+
182+#===============================================================================
183+# Test the compatibility of a given version of MA5 with this version of MG5
184+#===============================================================================
185+def is_MA5_compatible_with_this_MG5(ma5path):
186+ """ Returns None if compatible or, it not compatible, a string explaining
187+ why it is so."""
188+
189+ ma5_version = None
190+ try:
191+ for line in open(pjoin(ma5path,'version.txt'),'r').read().split('\n'):
192+ if line.startswith('MA5 version :'):
193+ ma5_version=LooseVersion(line[13:].strip())
194+ break
195+ except:
196+ ma5_version = None
197+
198+ if ma5_version is None:
199+ reason = "No MadAnalysis5 version number could be read from the path supplied '%s'."%ma5path
200+ reason += "\nThe specified version of MadAnalysis5 will not be active in your session."
201+ return reason
202+
203+ mg5_version = None
204+ try:
205+ info = get_pkg_info()
206+ mg5_version = LooseVersion(info['version'])
207+ except:
208+ mg5_version = None
209+
210+ # If version not reckognized, then carry on as it's probably a development version
211+ if not mg5_version:
212+ return None
213+
214+ if mg5_version < LooseVersion("2.6.1") and ma5_version >= LooseVersion("1.6.32"):
215+ reason = "This active MG5aMC version is too old (v%s) for your selected version of MadAnalysis5 (v%s)"%(mg5_version,ma5_version)
216+ reason += "\nUpgrade MG5aMC or re-install MA5 from within MG5aMC to fix this compatibility issue."
217+ reason += "\nThe specified version of MadAnalysis5 will not be active in your session."
218+ return reason
219+
220+ if mg5_version >= LooseVersion("2.6.1") and ma5_version < LooseVersion("1.6.32"):
221+ reason = "Your selected version of MadAnalysis5 (v%s) is too old for this active version of MG5aMC (v%s)."%(ma5_version,mg5_version)
222+ reason += "\nRe-install MA5 from within MG5aMC to fix this compatibility issue."
223+ reason += "\nThe specified version of MadAnalysis5 will not be active in your session."
224+ return reason
225+
226+ return None
227+
228 #===============================================================================
229 # Find the subdirectory which includes the files ending with a given extension
230 #===============================================================================

Subscribers

People subscribed via source and target branches

to all changes: