Merge lp:~maddevelopers/mg5amcnlo/2.2.0_tutofix into lp:~maddevelopers/mg5amcnlo/2.2.0

Proposed by Olivier Mattelaer
Status: Merged
Merged at revision: 342
Proposed branch: lp:~maddevelopers/mg5amcnlo/2.2.0_tutofix
Merge into: lp:~maddevelopers/mg5amcnlo/2.2.0
Diff against target: 771 lines (+324/-197)
7 files modified
Template/LO/bin/internal/plot_tree.C (+5/-5)
UpdateNotes.txt (+6/-0)
madgraph/interface/amcatnlo_run_interface.py (+16/-5)
madgraph/interface/common_run_interface.py (+203/-4)
madgraph/interface/madevent_interface.py (+3/-177)
madgraph/various/gen_crossxhtml.py (+6/-0)
tests/test_manager.py (+85/-6)
To merge this branch: bzr merge lp:~maddevelopers/mg5amcnlo/2.2.0_tutofix
Reviewer Review Type Date Requested Status
Valentin Hirschi Approve
Review via email: mp+235853@code.launchpad.net

Description of the change

A couple of small change that I would like to have release for tommorow (sorry for that).
the change are
- allow madwidth for NLO model/generation
- have automatic plot for HW6 (with MA4)
- adding the possibility to script the use of showerkt merging
- fixing a bug for DJR plot with root6

To post a comment you must log in.
Revision history for this message
Valentin Hirschi (valentin-hirschi) wrote :

Reviewed via skype.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Template/LO/bin/internal/plot_tree.C'
2--- Template/LO/bin/internal/plot_tree.C 2011-06-29 14:15:21 +0000
3+++ Template/LO/bin/internal/plot_tree.C 2014-09-24 19:46:10 +0000
4@@ -32,11 +32,11 @@
5 Float_t Xsecfact;
6 leaf_Xsec->SetAddress(&Xsecfact);
7 xsecs->GetEntry(0);
8-
9- for(int i=0;i<maxjets && events->GetEntries()>0;i++){
10+ if (events->GetEntries()>0) {
11+ for(int i=0;i<maxjets;i++){
12 events->SetLineWidth(2);
13- events->SetLineColor(color[i]);
14- events->SetLineStyle(style[i]);
15+ events->SetLineColor(i+2);
16+ events->SetLineStyle(i+2);
17
18 if(log)
19 sprintf(tmp1,"log10(%s)>>%s%i%s",quantity,quantity,i,plotdim);
20@@ -54,7 +54,7 @@
21 return false;
22 }
23 }
24-
25+ }
26
27 TH1F *hsum = (TH1F*)hists[0]->Clone();
28 sprintf(tmp3,"%ssum",quantity);
29
30=== modified file 'UpdateNotes.txt'
31--- UpdateNotes.txt 2014-09-17 11:50:05 +0000
32+++ UpdateNotes.txt 2014-09-24 19:46:10 +0000
33@@ -36,10 +36,16 @@
34 set lhc 14 # configure for LHC 14TeV
35 set ilc 1000 # configure for ilc 1TeV
36 set fixed_scale 100 # set all scale to fixed and at 100GeV
37+ set showerkt T # set showerkt on T in the shower card
38+ set qcut 20 # set the qctu to 20 in the shower card
39 OM: Fix a bug in the card edition mode which was sometimes returning to default value
40 which were edited by hand and not via the set command.
41 Seoyoung Kim (by OM): Implementation of the htcaas (super-)cluster support.
42 Juan Rojo (by RF): extended the 3 internal NNPDF sets for scales relevant for a 100TeV collider.
43+ OM: Fix a problem with the creation of DJR plot with root 6
44+ OM: allow the set the width to Auto in NLO computation (width computated at LO accuracy)
45+ OM: Adding the possibility to have automatic plot after the parton shower for Herwig6/Pythia6.
46+ This require MadAnalysis and the pythia-pgs package.
47
48 2.1.2(03/07/14) OM: Fix a bug in ALOHA in presence of customized propagator (Thanks Saurabh)
49 OM: Fixing some compilation issue with MadWeight (Thanks A. Pin)
50
51=== modified file 'madgraph/interface/amcatnlo_run_interface.py'
52--- madgraph/interface/amcatnlo_run_interface.py 2014-09-17 07:02:56 +0000
53+++ madgraph/interface/amcatnlo_run_interface.py 2014-09-24 19:46:10 +0000
54@@ -404,8 +404,6 @@
55 """Check the argument for the plot command
56 plot run_name modes"""
57
58- if options['force']:
59- self.force = True
60
61 madir = self.options['madanalysis_path']
62 td = self.options['td_path']
63@@ -966,7 +964,8 @@
64 self.check_plot(args)
65 logger.info('plot for run %s' % self.run_name)
66
67- self.ask_edit_cards([], args, plot=True)
68+ if not self.force:
69+ self.ask_edit_cards([], args, plot=True)
70
71 if any([arg in ['parton'] for arg in args]):
72 filename = pjoin(self.me_dir, 'Events', self.run_name, 'events.lhe')
73@@ -1024,14 +1023,17 @@
74 misc.gunzip(filename, keep=True, stdout=pjoin(self.me_dir, 'Events','pythia_events.hep'))
75
76 if not os.path.exists(pjoin(self.me_dir, 'Cards', 'pythia_card.dat')):
77- files.cp(pjoin(self.me_dir, 'Cards', 'pythia_card_default.dat'),
78+ if aMCatNLO and not self.options['mg5_path']:
79+ raise "plotting NLO HEP file needs MG5 utilities"
80+
81+ files.cp(pjoin(self.options['mg5_path'], 'Template','LO', 'Cards', 'pythia_card_default.dat'),
82 pjoin(self.me_dir, 'Cards', 'pythia_card.dat'))
83 self.run_hep2lhe()
84 else:
85 filename = filenames[0]
86 misc.gunzip(filename, keep=True, stdout=pjoin(self.me_dir, 'Events','pythia_events.hep'))
87
88- self.create_plot('Pythia')
89+ self.create_plot('shower')
90 lhe_file_name = filename.replace('.hep.gz', '.lhe')
91 shutil.move(pjoin(self.me_dir, 'Events','pythia_events.lhe'),
92 lhe_file_name)
93@@ -1125,6 +1127,8 @@
94 ############################################################################
95 def do_treatcards(self, line, amcatnlo=True):
96 """Advanced commands: this is for creating the correct run_card.inc from the nlo format"""
97+ #check if no 'Auto' are present in the file
98+ self.check_param_card(pjoin(self.me_dir, 'Cards','param_card.dat'))
99 return super(aMCatNLOCmd,self).do_treatcards(line, amcatnlo)
100
101 ############################################################################
102@@ -2545,6 +2549,13 @@
103 raise aMCatNLOError('No file has been generated, an error occurred.'+\
104 ' More information in %s' % pjoin(os.getcwd(), 'amcatnlo_run.log'))
105
106+ # run the plot creation in a secure way
107+ try:
108+ self.do_plot('%s -f' % self.run_name)
109+ except Exception, error:
110+ logger.info("Fail to make the plot. Continue...")
111+ pass
112+
113 elif out_id == 'TOP':
114 #copy the topdrawer file(s) back in events
115 topfiles = []
116
117=== modified file 'madgraph/interface/common_run_interface.py'
118--- madgraph/interface/common_run_interface.py 2014-09-17 07:02:56 +0000
119+++ madgraph/interface/common_run_interface.py 2014-09-24 19:46:10 +0000
120@@ -111,6 +111,14 @@
121 logger.info(" will be performed automaticaly during the event generation.")
122 logger.info(" -f options: answer all question by default.")
123
124+ def help_compute_widths(self):
125+ logger.info("syntax: compute_widths Particle [Particles] [--precision=] [--path=Param_card] [--output=PATH]")
126+ logger.info("-- Compute the widths for the particles specified.")
127+ logger.info(" By default, this takes the current param_card and overwrites it.")
128+ logger.info(" Precision allows to define when to include three/four/... body decays (LO).")
129+ logger.info(" If this number is an integer then all N-body decay will be included.")
130+
131+
132 def help_pythia(self):
133 logger.info("syntax: pythia [RUN] [--run_options]")
134 logger.info("-- run pythia on RUN (current one by default)")
135@@ -168,6 +176,111 @@
136 if not args[1].isdigit():
137 raise self.InvalidCmd('timeout values should be a integer')
138
139+ def check_compute_widths(self, args):
140+ """check that the model is loadable and check that the format is of the
141+ type: PART PATH --output=PATH -f --precision=N
142+ return the model.
143+ """
144+
145+ # Check that MG5 directory is present .
146+ if MADEVENT and not self.options['mg5_path']:
147+ raise self.InvalidCmd, '''The automatic computations of widths requires that MG5 is installed on the system.
148+ You can install it and set his path in ./Cards/me5_configuration.txt'''
149+ elif MADEVENT:
150+ sys.path.append(self.options['mg5_path'])
151+ try:
152+ import models.model_reader as model_reader
153+ import models.import_ufo as import_ufo
154+ except ImportError:
155+ raise self.ConfigurationError, '''Can\'t load MG5.
156+ The variable mg5_path should not be correctly configure.'''
157+
158+ ufo_path = pjoin(self.me_dir,'bin','internal', 'ufomodel')
159+ # Import model
160+ if not MADEVENT:
161+ modelname = self.find_model_name()
162+ #restrict_file = None
163+ #if os.path.exists(pjoin(ufo_path, 'restrict_default.dat')):
164+ # restrict_file = pjoin(ufo_path, 'restrict_default.dat')
165+ model = import_ufo.import_model(modelname, decay=True,
166+ restrict=True)
167+ if self.mother and self.mother.options['complex_mass_scheme']:
168+ model.change_mass_to_complex_scheme()
169+ else:
170+ model = import_ufo.import_model(pjoin(self.me_dir,'bin','internal', 'ufomodel'),
171+ decay=True)
172+ #pattern for checking complex mass scheme.
173+ has_cms = re.compile(r'''set\s+complex_mass_scheme\s*(True|T|1|true|$|;)''')
174+ if has_cms.search(open(pjoin(self.me_dir,'Cards','proc_card_mg5.dat')\
175+ ).read()):
176+ model.change_mass_to_complex_scheme()
177+
178+
179+# if not hasattr(model.get('particles')[0], 'partial_widths'):
180+# raise self.InvalidCmd, 'The UFO model does not include partial widths information. Impossible to compute widths automatically'
181+
182+ # check if the name are passed to default MG5
183+ if '-modelname' in open(pjoin(self.me_dir,'Cards','proc_card_mg5.dat')).read():
184+ model.pass_particles_name_in_mg_default()
185+ model = model_reader.ModelReader(model)
186+ particles_name = dict([(p.get('name'), p.get('pdg_code'))
187+ for p in model.get('particles')])
188+ particles_name.update(dict([(p.get('antiname'), p.get('pdg_code'))
189+ for p in model.get('particles')]))
190+
191+ output = {'model': model, 'force': False, 'output': None,
192+ 'path':None, 'particles': set(), 'body_decay':4.0025,
193+ 'min_br':None, 'precision_channel':0.01}
194+ for arg in args:
195+ if arg.startswith('--output='):
196+ output_path = arg.split('=',1)[1]
197+ if not os.path.exists(output_path):
198+ raise self.InvalidCmd, 'Invalid Path for the output. Please retry.'
199+ if not os.path.isfile(output_path):
200+ output_path = pjoin(output_path, 'param_card.dat')
201+ output['output'] = output_path
202+ elif arg == '-f':
203+ output['force'] = True
204+ elif os.path.isfile(arg):
205+ ftype = self.detect_card_type(arg)
206+ if ftype != 'param_card.dat':
207+ raise self.InvalidCmd , '%s is not a valid param_card.' % arg
208+ output['path'] = arg
209+ elif arg.startswith('--path='):
210+ arg = arg.split('=',1)[1]
211+ ftype = self.detect_card_type(arg)
212+ if ftype != 'param_card.dat':
213+ raise self.InvalidCmd , '%s is not a valid param_card.' % arg
214+ output['path'] = arg
215+ elif arg.startswith('--'):
216+ name, value = arg.split('=',1)
217+ try:
218+ value = float(value)
219+ except Exception:
220+ raise self.InvalidCmd, '--%s requires integer or a float' % name
221+ output[name[2:]] = float(value)
222+ elif arg in particles_name:
223+ # should be a particles
224+ output['particles'].add(particles_name[arg])
225+ elif arg.isdigit() and int(arg) in particles_name.values():
226+ output['particles'].add(eval(arg))
227+ elif arg == 'all':
228+ output['particles'] = set(['all'])
229+ else:
230+ self.help_compute_widths()
231+ raise self.InvalidCmd, '%s is not a valid argument for compute_widths' % arg
232+ if self.force:
233+ output['force'] = True
234+
235+ if not output['particles']:
236+ raise self.InvalidCmd, '''This routines requires at least one particle in order to compute
237+ the related width'''
238+
239+ if output['output'] is None:
240+ output['output'] = output['path']
241+
242+ return output
243+
244 def check_open(self, args):
245 """ check the validity of the line """
246
247@@ -739,6 +852,12 @@
248 event_path = pjoin(self.me_dir, 'Events', self.run_name,'%s_delphes_events.lhco' % tag)
249 output = pjoin(self.me_dir, 'HTML',self.run_name,
250 'plots_delphes_%s.html' % tag)
251+ elif mode == "shower":
252+ event_path = pjoin(self.me_dir, 'Events','pythia_events.lhe')
253+ output = pjoin(self.me_dir, 'HTML',self.run_name,
254+ 'plots_shower_%s.html' % tag)
255+ if not self.options['pythia-pgs_path']:
256+ return
257 else:
258 raise self.InvalidCmd, 'Invalid mode %s' % mode
259 elif mode == 'reweight' and not output:
260@@ -815,7 +934,7 @@
261
262 # Creating LHE file
263 if misc.is_executable(pjoin(pydir, 'hep2lhe')):
264- self.update_status('Creating Pythia LHE File', level='pythia')
265+ self.update_status('Creating shower LHE File (for plot)', level='pythia')
266 # Write the banner to the LHE file
267 out = open(pjoin(self.me_dir,'Events','pythia_events.lhe'), 'w')
268 #out.writelines('<LesHouchesEvents version=\"1.0\">\n')
269@@ -829,9 +948,10 @@
270
271 self.cluster.launch_and_wait(self.dirbin+'/run_hep2lhe',
272 argument= [pydir],
273- cwd=pjoin(self.me_dir,'Events'))
274+ cwd=pjoin(self.me_dir,'Events'),
275+ stdout=open(os.devnull,'w'))
276
277- logger.info('Warning! Never use this pythia lhe file for detector studies!')
278+ logger.info('Warning! Never use this lhe file for detector studies!')
279 # Creating ROOT file
280 if eradir and misc.is_executable(pjoin(eradir, 'ExRootLHEFConverter')):
281 self.update_status('Creating Pythia LHE Root File', level='pythia')
282@@ -960,6 +1080,33 @@
283
284 self.update_status('finish', level='pgs', makehtml=False)
285
286+ ############################################################################
287+ def do_compute_widths(self, line):
288+ """Require MG5 directory: Compute automatically the widths of a set
289+ of particles"""
290+
291+ args = self.split_arg(line)
292+ opts = self.check_compute_widths(args)
293+
294+
295+ from madgraph.interface.master_interface import MasterCmd
296+ cmd = MasterCmd()
297+ self.define_child_cmd_interface(cmd, interface=False)
298+ cmd.exec_cmd('set automatic_html_opening False --no_save')
299+ if not opts['path']:
300+ opts['path'] = pjoin(self.me_dir, 'Cards', 'param_card.dat')
301+ if not opts['force'] :
302+ self.ask_edit_cards(['param_card'],[], plot=False)
303+
304+
305+ line = 'compute_widths %s %s' % \
306+ (' '.join([str(i) for i in opts['particles']]),
307+ ' '.join('--%s=%s' % (key,value) for (key,value) in opts.items()
308+ if key not in ['model', 'force', 'particles'] and value))
309+
310+ cmd.exec_cmd(line, model=opts['model'])
311+ self.child = None
312+ del cmd
313
314 ############################################################################
315 def do_print_results(self, line):
316@@ -1313,6 +1460,24 @@
317 cluster_name = opt['cluster_type']
318 self.cluster = cluster.from_name[cluster_name](**opt)
319
320+ def check_param_card(self, path, run=True):
321+ """Check that all the width are define in the param_card.
322+ If some width are set on 'Auto', call the computation tools."""
323+
324+ pattern = re.compile(r'''decay\s+(\+?\-?\d+)\s+auto''',re.I)
325+ text = open(path).read()
326+ pdg = pattern.findall(text)
327+ if pdg:
328+ if run:
329+ logger.info('Computing the width set on auto in the param_card.dat')
330+ self.do_compute_widths('%s %s' % (' '.join(pdg), path))
331+ else:
332+ logger.info('''Some width are on Auto in the card.
333+ Those will be computed as soon as you have finish the edition of the cards.
334+ If you want to force the computation right now and being able to re-edit
335+ the cards afterwards, you can type \"compute_wdiths\".''')
336+
337+
338 def add_error_log_in_html(self, errortype=None):
339 """If a ME run is currently running add a link in the html output"""
340
341@@ -1696,6 +1861,27 @@
342 os.path.join('.',*[a for a in args \
343 if a.endswith(os.path.sep)]))
344
345+ def complete_compute_widths(self, text, line, begidx, endidx):
346+ "Complete the compute_widths command"
347+
348+ args = self.split_arg(line[0:begidx])
349+
350+ if args[-1] in ['--path=', '--output=']:
351+ completion = {'path': self.path_completion(text)}
352+ elif line[begidx-1] == os.path.sep:
353+ current_dir = pjoin(*[a for a in args if a.endswith(os.path.sep)])
354+ if current_dir.startswith('--path='):
355+ current_dir = current_dir[7:]
356+ if current_dir.startswith('--output='):
357+ current_dir = current_dir[9:]
358+ completion = {'path': self.path_completion(text, current_dir)}
359+ else:
360+ completion = {}
361+ completion['options'] = self.list_completion(text,
362+ ['--path=', '--output=', '--min_br=0.\$'
363+ '--precision_channel=0.\$', '--body_decay='])
364+
365+ return self.deal_multiple_categories(completion)
366
367
368 # lhapdf-related functions
369@@ -2080,7 +2266,7 @@
370 self.list_completion(text, categories)
371
372 if 'shortcut' in allowed.keys():
373- possibilities['special values'] = self.list_completion(text, self.special_shortcut.keys()+['qcut'])
374+ possibilities['special values'] = self.list_completion(text, self.special_shortcut.keys()+['qcut', 'showerkt'])
375
376 if 'run_card' in allowed.keys():
377 opts = self.run_set
378@@ -2219,6 +2405,19 @@
379 p_card = '%s \n QCUT= %s' % (p_card, args[1])
380 open(pythia_path, 'w').write(p_card)
381 return
382+ # Special case for the showerkt value
383+ if args[0].lower() == 'showerkt':
384+ pythia_path = pjoin(self.me_dir, 'Cards','pythia_card.dat')
385+ if os.path.exists(pythia_path):
386+ logger.info('add line SHOWERKT = %s in pythia_card.dat' % args[1].upper())
387+ p_card = open(pythia_path,'r').read()
388+ p_card, n = re.subn('''^\s*SHOWERKT\s*=\s*[default\de\+\-\.]*\s*$''',
389+ ''' SHOWERKT = %s ''' % args[1].upper(), \
390+ p_card, flags=(re.M+re.I))
391+ if n==0:
392+ p_card = '%s \n SHOWERKT= %s' % (p_card, args[1].upper())
393+ open(pythia_path, 'w').write(p_card)
394+ return
395
396
397 card = '' #store which card need to be modify (for name conflict)
398
399=== modified file 'madgraph/interface/madevent_interface.py'
400--- madgraph/interface/madevent_interface.py 2014-09-20 07:40:10 +0000
401+++ madgraph/interface/madevent_interface.py 2014-09-24 19:46:10 +0000
402@@ -418,13 +418,6 @@
403 logger.info(" asked in the run_card.")
404 self.run_options_help([])
405
406- def help_compute_widths(self):
407- logger.info("syntax: compute_widths Particle [Particles] [--precision=] [--path=Param_card] [--output=PATH]")
408- logger.info("-- Compute the widths for the particles specified.")
409- logger.info(" By default, this takes the current param_card and overwrites it.")
410- logger.info(" Precision allows to define when to include three/four/... body decays.")
411- logger.info(" If this number is an integer then all N-body decay will be included.")
412-
413 def help_store_events(self):
414 """ """
415 logger.info("syntax: store_events [--run_options]")
416@@ -867,112 +860,7 @@
417 raise self.InvalidCmd('refine arguments are suppose to be number')
418
419 return True
420-
421- def check_compute_widths(self, args):
422- """check that the model is loadable and check that the format is of the
423- type: PART PATH --output=PATH -f --precision=N
424- return the model.
425- """
426-
427- # Check that MG5 directory is present .
428- if MADEVENT and not self.options['mg5_path']:
429- raise self.InvalidCmd, '''The automatic computations of widths requires that MG5 is installed on the system.
430- You can install it and set his path in ./Cards/me5_configuration.txt'''
431- elif MADEVENT:
432- sys.path.append(self.options['mg5_path'])
433- try:
434- import models.model_reader as model_reader
435- import models.import_ufo as import_ufo
436- except ImportError:
437- raise self.ConfigurationError, '''Can\'t load MG5.
438- The variable mg5_path should not be correctly configure.'''
439-
440- ufo_path = pjoin(self.me_dir,'bin','internal', 'ufomodel')
441- # Import model
442- if not MADEVENT:
443- modelname = self.find_model_name()
444- #restrict_file = None
445- #if os.path.exists(pjoin(ufo_path, 'restrict_default.dat')):
446- # restrict_file = pjoin(ufo_path, 'restrict_default.dat')
447- model = import_ufo.import_model(modelname, decay=True,
448- restrict=True)
449- if self.mother and self.mother.options['complex_mass_scheme']:
450- model.change_mass_to_complex_scheme()
451- else:
452- model = import_ufo.import_model(pjoin(self.me_dir,'bin','internal', 'ufomodel'),
453- decay=True)
454- #pattern for checking complex mass scheme.
455- has_cms = re.compile(r'''set\s+complex_mass_scheme\s*(True|T|1|true|$|;)''')
456- if has_cms.search(open(pjoin(self.me_dir,'Cards','proc_card_mg5.dat')\
457- ).read()):
458- model.change_mass_to_complex_scheme()
459-
460-
461-# if not hasattr(model.get('particles')[0], 'partial_widths'):
462-# raise self.InvalidCmd, 'The UFO model does not include partial widths information. Impossible to compute widths automatically'
463-
464- # check if the name are passed to default MG5
465- if '-modelname' in open(pjoin(self.me_dir,'Cards','proc_card_mg5.dat')).read():
466- model.pass_particles_name_in_mg_default()
467- model = model_reader.ModelReader(model)
468- particles_name = dict([(p.get('name'), p.get('pdg_code'))
469- for p in model.get('particles')])
470- particles_name.update(dict([(p.get('antiname'), p.get('pdg_code'))
471- for p in model.get('particles')]))
472-
473- output = {'model': model, 'force': False, 'output': None,
474- 'path':None, 'particles': set(), 'body_decay':4.0025,
475- 'min_br':None, 'precision_channel':0.01}
476- for arg in args:
477- if arg.startswith('--output='):
478- output_path = arg.split('=',1)[1]
479- if not os.path.exists(output_path):
480- raise self.InvalidCmd, 'Invalid Path for the output. Please retry.'
481- if not os.path.isfile(output_path):
482- output_path = pjoin(output_path, 'param_card.dat')
483- output['output'] = output_path
484- elif arg == '-f':
485- output['force'] = True
486- elif os.path.isfile(arg):
487- type = self.detect_card_type(arg)
488- if type != 'param_card.dat':
489- raise self.InvalidCmd , '%s is not a valid param_card.' % arg
490- output['path'] = arg
491- elif arg.startswith('--path='):
492- arg = arg.split('=',1)[1]
493- type = self.detect_card_type(arg)
494- if type != 'param_card.dat':
495- raise self.InvalidCmd , '%s is not a valid param_card.' % arg
496- output['path'] = arg
497- elif arg.startswith('--'):
498- name, value = arg.split('=',1)
499- try:
500- value = float(value)
501- except Exception:
502- raise self.InvalidCmd, '--%s requires integer or a float' % name
503- output[name[2:]] = float(value)
504- elif arg in particles_name:
505- # should be a particles
506- output['particles'].add(particles_name[arg])
507- elif arg.isdigit() and int(arg) in particles_name.values():
508- output['particles'].add(eval(arg))
509- elif arg == 'all':
510- output['particles'] = set(['all'])
511- else:
512- self.help_compute_widths()
513- raise self.InvalidCmd, '%s is not a valid argument for compute_widths' % arg
514- if self.force:
515- output['force'] = True
516-
517- if not output['particles']:
518- raise self.InvalidCmd, '''This routines requires at least one particle in order to compute
519- the related width'''
520-
521- if output['output'] is None:
522- output['output'] = output['path']
523-
524- return output
525-
526+
527 def check_combine_events(self, arg):
528 """ Check the argument for the combine events command """
529
530@@ -1506,28 +1394,6 @@
531 else:
532 return self.complete_generate_events(*args, **opts)
533
534- def complete_compute_widths(self, text, line, begidx, endidx):
535- "Complete the compute_widths command"
536-
537- args = self.split_arg(line[0:begidx])
538-
539- if args[-1] in ['--path=', '--output=']:
540- completion = {'path': self.path_completion(text)}
541- elif line[begidx-1] == os.path.sep:
542- current_dir = pjoin(*[a for a in args if a.endswith(os.path.sep)])
543- if current_dir.startswith('--path='):
544- current_dir = current_dir[7:]
545- if current_dir.startswith('--output='):
546- current_dir = current_dir[9:]
547- completion = {'path': self.path_completion(text, current_dir)}
548- else:
549- completion = {}
550- completion['options'] = self.list_completion(text,
551- ['--path=', '--output=', '--min_br=0.\$'
552- '--precision_channel=0.\$', '--body_decay='])
553-
554- return self.deal_multiple_categories(completion)
555-
556 def complete_calculate_decay_widths(self, text, line, begidx, endidx):
557 """ Complete the calculate_decay_widths command"""
558
559@@ -2694,33 +2560,7 @@
560 self.create_root_file(output='%s/unweighted_events.root' % \
561 self.run_name)
562
563- ############################################################################
564- def do_compute_widths(self, line):
565- """Require MG5 directory: Compute automatically the widths of a set
566- of particles"""
567
568- args = self.split_arg(line)
569- opts = self.check_compute_widths(args)
570-
571-
572- from madgraph.interface.master_interface import MasterCmd
573- cmd = MasterCmd()
574- self.define_child_cmd_interface(cmd, interface=False)
575- cmd.exec_cmd('set automatic_html_opening False --no_save')
576- if not opts['path']:
577- opts['path'] = pjoin(self.me_dir, 'Cards', 'param_card.dat')
578- if not opts['force'] :
579- self.ask_edit_cards(['param_card'],[], plot=False)
580-
581-
582- line = 'compute_widths %s %s' % \
583- (' '.join([str(i) for i in opts['particles']]),
584- ' '.join('--%s=%s' % (key,value) for (key,value) in opts.items()
585- if key not in ['model', 'force', 'particles'] and value))
586-
587- cmd.exec_cmd(line, model=opts['model'])
588- self.child = None
589- del cmd
590
591
592
593@@ -4048,22 +3888,8 @@
594
595
596
597- def check_param_card(self, path, run=True):
598- """Check that all the width are define in the param_card.
599- If some width are set on 'Auto', call the computation tools."""
600-
601- pattern = re.compile(r'''decay\s+(\+?\-?\d+)\s+auto''',re.I)
602- text = open(path).read()
603- pdg = pattern.findall(text)
604- if pdg:
605- if run:
606- logger.info('Computing the width set on auto in the param_card.dat')
607- self.do_compute_widths('%s %s' % (' '.join(pdg), path))
608- else:
609- logger.info('''Some width are on Auto in the card.
610- Those will be computed as soon as you have finish the edition of the cards.
611- If you want to force the computation right now and being able to re-edit
612- the cards afterwards, you can type \"compute_wdiths\".''')
613+
614+
615 #===============================================================================
616 # MadEventCmd
617 #===============================================================================
618
619=== modified file 'madgraph/various/gen_crossxhtml.py'
620--- madgraph/various/gen_crossxhtml.py 2014-09-22 07:17:43 +0000
621+++ madgraph/various/gen_crossxhtml.py 2014-09-24 19:46:10 +0000
622@@ -791,6 +791,10 @@
623 glob.glob(pjoin(path,"*.hep.gz")):
624 self.shower.append('hep')
625
626+ if 'plot' not in self.shower and \
627+ exists(pjoin(html_path,"plots_shower_%s.html" % tag)):
628+ self.shower.append('plot')
629+
630 if glob.glob(pjoin(path,"*.hepmc")) + \
631 glob.glob(pjoin(path,"*.hepmc.gz")):
632 self.shower.append('hepmc')
633@@ -988,6 +992,8 @@
634 glob.glob(pjoin(self.me_dir, 'Events', self['run_name'], '*.' + kind)) + \
635 glob.glob(pjoin(self.me_dir, 'Events', self['run_name'], '*.' + kind + '.gz')):
636 out += " <a href=\"%s\">%s</a> " % (f, kind.upper())
637+ if 'plot' in self.shower:
638+ out += """ <a href="./HTML/%(run_name)s/plots_shower_%(tag)s.html">plots</a>"""
639
640 return out % self
641
642
643=== modified file 'tests/test_manager.py'
644--- tests/test_manager.py 2014-05-15 00:02:06 +0000
645+++ tests/test_manager.py 2014-09-24 19:46:10 +0000
646@@ -115,6 +115,38 @@
647 self.stream.writeln(" ".join(self.bypassed))
648 return result
649
650+ def run_border(self, test):
651+ "Run the given test case or test suite."
652+ MyTextTestRunner.stream = self.stream
653+ result = self._makeResult()
654+ startTime = time.time()
655+ test(result)
656+ stopTime = time.time()
657+ timeTaken = float(stopTime - startTime)
658+ result.printErrors()
659+ self.stream.writeln(result.separator2)
660+ run = result.testsRun
661+ #self.stream.writeln("Ran %d test%s in %.3fs" %
662+ # (run, run != 1 and "s" or "", timeTaken))
663+ #self.stream.writeln()
664+ if not result.wasSuccessful():
665+ self.stream.write("FAILED (")
666+ failed, errored = map(len, (result.failures, result.errors))
667+ if failed:
668+ self.stream.write("failures=%d" % failed)
669+ if errored:
670+ if failed: self.stream.write(", ")
671+ self.stream.write("errors=%d" % errored)
672+ self.stream.writeln(")")
673+ sys.exit(0)
674+ #else:
675+ # self.stream.writeln("OK")
676+ #if self.bypassed:
677+ # self.stream.writeln("Bypassed %s:" % len(self.bypassed))
678+ # self.stream.writeln(" ".join(self.bypassed))
679+ return result
680+
681+
682
683 #===============================================================================
684 # run
685@@ -153,6 +185,46 @@
686 #return out
687
688 #===============================================================================
689+# run
690+#===============================================================================
691+def run_border_search(to_crash='',expression='', re_opt=0, package='./tests/unit_tests', verbosity=1,
692+ timelimit=0):
693+ """ running the test associated to expression one by one. and follow them by the to_crash one
694+ up to the time that to_crash is actually crashing. Then the run stops and print the list of the
695+ routine tested. Then the code re-run itself(via a fork) to restrict the list.
696+ The code stops when the list is of order 1. The order of the test is randomize at each level!
697+ """
698+ #init a test suite
699+ collect = unittest.TestLoader()
700+ TestSuiteModified.time_limit = float(timelimit)
701+ all_test = TestFinder(package=package, expression=expression, re_opt=re_opt)
702+ import random
703+ random.shuffle(all_test)
704+ print "to_crash"
705+ to_crash = TestFinder(package=package, expression=to_crash, re_opt=re_opt)
706+ to_crash.collect_dir(package, checking=True)
707+ print dir(to_crash)
708+
709+ for test_fct in all_test:
710+ testsuite = unittest.TestSuite()
711+ data = collect.loadTestsFromName(test_fct)
712+ assert(isinstance(data,unittest.TestSuite))
713+ data.__class__ = TestSuiteModified
714+ testsuite.addTest(data)
715+ data = collect.loadTestsFromName(to_crash[0])
716+ assert(isinstance(data,unittest.TestSuite))
717+ data.__class__ = TestSuiteModified
718+ testsuite.addTest(data)
719+ # Running it
720+ print "run it for %s" % test_fct
721+ output = MyTextTestRunner(verbosity=verbosity).run_border(testsuite)
722+
723+ return output
724+ #import tests
725+ #print 'runned %s checks' % tests.NBTEST
726+ #return out
727+
728+#===============================================================================
729 # listIOTests
730 #===============================================================================
731
732@@ -262,8 +334,8 @@
733 IOTestManager.testFolders_filter = arg.split('/')[0].split('&')
734 IOTestManager.testNames_filter = arg.split('/')[1].split('&')
735 IOTestManager.filesChecked_filter = '/'.join(arg.split('/')[2:]).split('&')
736- #print "INFO:: Using folders %s"%str(IOTestManager.testFolders_filter)
737- #print "INFO:: Using test names %s"%str(IOTestManager.testNames_filter)
738+ #print "INFO:: Using folders %s"%str(IOTestManager.testFolders_filter)
739+ #print "INFO:: Using test names %s"%str(IOTestManager.testNames_filter)
740 #print "INFO:: Using file paths %s"%str(IOTestManager.filesChecked_filter)
741
742 # Initiate all the IOTests from all the setUp()
743@@ -820,7 +892,10 @@
744 "content of the folder IOTestsComparison")
745 parser.add_option("-t", "--timed", default="Auto",
746 help="limit the duration of each test. Negative number re-writes the information file.")
747-
748+
749+ parser.add_option("", "--border_effect", default=None,
750+ help="Define the test which are sensitive to a border effect, the test will find which test creates this border effect")
751+
752 (options, args) = parser.parse_args()
753
754 if options.IOTestsUpdate:
755@@ -897,9 +972,13 @@
756 " MadGraph5_aMCatNLO is configured not to compress the references files."
757
758 if options.IOTests=='No' and not options.synchronize:
759- #logging.basicConfig(level=vars(logging)[options.logging])
760- run(args, re_opt=options.reopt, verbosity=options.verbose, \
761- package=options.path, timelimit=options.timed)
762+ if not options.border_effect:
763+ #logging.basicConfig(level=vars(logging)[options.logging])
764+ run(args, re_opt=options.reopt, verbosity=options.verbose, \
765+ package=options.path, timelimit=options.timed)
766+ else:
767+ run_border_search(options.border_effect, args, re_opt=options.reopt, verbosity=options.verbose, \
768+ package=options.path, timelimit=options.timed)
769 else:
770 if options.IOTests=='L':
771 print "Listing all tests defined in the reference files ..."

Subscribers

People subscribed via source and target branches

to all changes: