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
=== modified file 'Template/LO/bin/internal/plot_tree.C'
--- Template/LO/bin/internal/plot_tree.C 2011-06-29 14:15:21 +0000
+++ Template/LO/bin/internal/plot_tree.C 2014-09-24 19:46:10 +0000
@@ -32,11 +32,11 @@
32 Float_t Xsecfact;32 Float_t Xsecfact;
33 leaf_Xsec->SetAddress(&Xsecfact);33 leaf_Xsec->SetAddress(&Xsecfact);
34 xsecs->GetEntry(0);34 xsecs->GetEntry(0);
3535 if (events->GetEntries()>0) {
36 for(int i=0;i<maxjets && events->GetEntries()>0;i++){36 for(int i=0;i<maxjets;i++){
37 events->SetLineWidth(2);37 events->SetLineWidth(2);
38 events->SetLineColor(color[i]);38 events->SetLineColor(i+2);
39 events->SetLineStyle(style[i]);39 events->SetLineStyle(i+2);
40 40
41 if(log) 41 if(log)
42 sprintf(tmp1,"log10(%s)>>%s%i%s",quantity,quantity,i,plotdim);42 sprintf(tmp1,"log10(%s)>>%s%i%s",quantity,quantity,i,plotdim);
@@ -54,7 +54,7 @@
54 return false;54 return false;
55 }55 }
56 }56 }
5757 }
5858
59 TH1F *hsum = (TH1F*)hists[0]->Clone();59 TH1F *hsum = (TH1F*)hists[0]->Clone();
60 sprintf(tmp3,"%ssum",quantity);60 sprintf(tmp3,"%ssum",quantity);
6161
=== modified file 'UpdateNotes.txt'
--- UpdateNotes.txt 2014-09-17 11:50:05 +0000
+++ UpdateNotes.txt 2014-09-24 19:46:10 +0000
@@ -36,10 +36,16 @@
36 set lhc 14 # configure for LHC 14TeV36 set lhc 14 # configure for LHC 14TeV
37 set ilc 1000 # configure for ilc 1TeV37 set ilc 1000 # configure for ilc 1TeV
38 set fixed_scale 100 # set all scale to fixed and at 100GeV38 set fixed_scale 100 # set all scale to fixed and at 100GeV
39 set showerkt T # set showerkt on T in the shower card
40 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 value41 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.42 which were edited by hand and not via the set command.
41 Seoyoung Kim (by OM): Implementation of the htcaas (super-)cluster support.43 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.44 Juan Rojo (by RF): extended the 3 internal NNPDF sets for scales relevant for a 100TeV collider.
45 OM: Fix a problem with the creation of DJR plot with root 6
46 OM: allow the set the width to Auto in NLO computation (width computated at LO accuracy)
47 OM: Adding the possibility to have automatic plot after the parton shower for Herwig6/Pythia6.
48 This require MadAnalysis and the pythia-pgs package.
4349
442.1.2(03/07/14) OM: Fix a bug in ALOHA in presence of customized propagator (Thanks Saurabh)502.1.2(03/07/14) OM: Fix a bug in ALOHA in presence of customized propagator (Thanks Saurabh)
45 OM: Fixing some compilation issue with MadWeight (Thanks A. Pin)51 OM: Fixing some compilation issue with MadWeight (Thanks A. Pin)
4652
=== modified file 'madgraph/interface/amcatnlo_run_interface.py'
--- madgraph/interface/amcatnlo_run_interface.py 2014-09-17 07:02:56 +0000
+++ madgraph/interface/amcatnlo_run_interface.py 2014-09-24 19:46:10 +0000
@@ -404,8 +404,6 @@
404 """Check the argument for the plot command404 """Check the argument for the plot command
405 plot run_name modes"""405 plot run_name modes"""
406406
407 if options['force']:
408 self.force = True
409407
410 madir = self.options['madanalysis_path']408 madir = self.options['madanalysis_path']
411 td = self.options['td_path']409 td = self.options['td_path']
@@ -966,7 +964,8 @@
966 self.check_plot(args)964 self.check_plot(args)
967 logger.info('plot for run %s' % self.run_name)965 logger.info('plot for run %s' % self.run_name)
968 966
969 self.ask_edit_cards([], args, plot=True)967 if not self.force:
968 self.ask_edit_cards([], args, plot=True)
970 969
971 if any([arg in ['parton'] for arg in args]):970 if any([arg in ['parton'] for arg in args]):
972 filename = pjoin(self.me_dir, 'Events', self.run_name, 'events.lhe')971 filename = pjoin(self.me_dir, 'Events', self.run_name, 'events.lhe')
@@ -1024,14 +1023,17 @@
1024 misc.gunzip(filename, keep=True, stdout=pjoin(self.me_dir, 'Events','pythia_events.hep'))1023 misc.gunzip(filename, keep=True, stdout=pjoin(self.me_dir, 'Events','pythia_events.hep'))
1025 1024
1026 if not os.path.exists(pjoin(self.me_dir, 'Cards', 'pythia_card.dat')):1025 if not os.path.exists(pjoin(self.me_dir, 'Cards', 'pythia_card.dat')):
1027 files.cp(pjoin(self.me_dir, 'Cards', 'pythia_card_default.dat'),1026 if aMCatNLO and not self.options['mg5_path']:
1027 raise "plotting NLO HEP file needs MG5 utilities"
1028
1029 files.cp(pjoin(self.options['mg5_path'], 'Template','LO', 'Cards', 'pythia_card_default.dat'),
1028 pjoin(self.me_dir, 'Cards', 'pythia_card.dat'))1030 pjoin(self.me_dir, 'Cards', 'pythia_card.dat'))
1029 self.run_hep2lhe()1031 self.run_hep2lhe()
1030 else:1032 else:
1031 filename = filenames[0]1033 filename = filenames[0]
1032 misc.gunzip(filename, keep=True, stdout=pjoin(self.me_dir, 'Events','pythia_events.hep'))1034 misc.gunzip(filename, keep=True, stdout=pjoin(self.me_dir, 'Events','pythia_events.hep'))
10331035
1034 self.create_plot('Pythia')1036 self.create_plot('shower')
1035 lhe_file_name = filename.replace('.hep.gz', '.lhe')1037 lhe_file_name = filename.replace('.hep.gz', '.lhe')
1036 shutil.move(pjoin(self.me_dir, 'Events','pythia_events.lhe'), 1038 shutil.move(pjoin(self.me_dir, 'Events','pythia_events.lhe'),
1037 lhe_file_name)1039 lhe_file_name)
@@ -1125,6 +1127,8 @@
1125 ############################################################################1127 ############################################################################
1126 def do_treatcards(self, line, amcatnlo=True):1128 def do_treatcards(self, line, amcatnlo=True):
1127 """Advanced commands: this is for creating the correct run_card.inc from the nlo format"""1129 """Advanced commands: this is for creating the correct run_card.inc from the nlo format"""
1130 #check if no 'Auto' are present in the file
1131 self.check_param_card(pjoin(self.me_dir, 'Cards','param_card.dat'))
1128 return super(aMCatNLOCmd,self).do_treatcards(line, amcatnlo)1132 return super(aMCatNLOCmd,self).do_treatcards(line, amcatnlo)
1129 1133
1130 ############################################################################1134 ############################################################################
@@ -2545,6 +2549,13 @@
2545 raise aMCatNLOError('No file has been generated, an error occurred.'+\2549 raise aMCatNLOError('No file has been generated, an error occurred.'+\
2546 ' More information in %s' % pjoin(os.getcwd(), 'amcatnlo_run.log'))2550 ' More information in %s' % pjoin(os.getcwd(), 'amcatnlo_run.log'))
25472551
2552 # run the plot creation in a secure way
2553 try:
2554 self.do_plot('%s -f' % self.run_name)
2555 except Exception, error:
2556 logger.info("Fail to make the plot. Continue...")
2557 pass
2558
2548 elif out_id == 'TOP':2559 elif out_id == 'TOP':
2549 #copy the topdrawer file(s) back in events2560 #copy the topdrawer file(s) back in events
2550 topfiles = []2561 topfiles = []
25512562
=== modified file 'madgraph/interface/common_run_interface.py'
--- madgraph/interface/common_run_interface.py 2014-09-17 07:02:56 +0000
+++ madgraph/interface/common_run_interface.py 2014-09-24 19:46:10 +0000
@@ -111,6 +111,14 @@
111 logger.info(" will be performed automaticaly during the event generation.")111 logger.info(" will be performed automaticaly during the event generation.")
112 logger.info(" -f options: answer all question by default.")112 logger.info(" -f options: answer all question by default.")
113113
114 def help_compute_widths(self):
115 logger.info("syntax: compute_widths Particle [Particles] [--precision=] [--path=Param_card] [--output=PATH]")
116 logger.info("-- Compute the widths for the particles specified.")
117 logger.info(" By default, this takes the current param_card and overwrites it.")
118 logger.info(" Precision allows to define when to include three/four/... body decays (LO).")
119 logger.info(" If this number is an integer then all N-body decay will be included.")
120
121
114 def help_pythia(self):122 def help_pythia(self):
115 logger.info("syntax: pythia [RUN] [--run_options]")123 logger.info("syntax: pythia [RUN] [--run_options]")
116 logger.info("-- run pythia on RUN (current one by default)")124 logger.info("-- run pythia on RUN (current one by default)")
@@ -168,6 +176,111 @@
168 if not args[1].isdigit():176 if not args[1].isdigit():
169 raise self.InvalidCmd('timeout values should be a integer')177 raise self.InvalidCmd('timeout values should be a integer')
170178
179 def check_compute_widths(self, args):
180 """check that the model is loadable and check that the format is of the
181 type: PART PATH --output=PATH -f --precision=N
182 return the model.
183 """
184
185 # Check that MG5 directory is present .
186 if MADEVENT and not self.options['mg5_path']:
187 raise self.InvalidCmd, '''The automatic computations of widths requires that MG5 is installed on the system.
188 You can install it and set his path in ./Cards/me5_configuration.txt'''
189 elif MADEVENT:
190 sys.path.append(self.options['mg5_path'])
191 try:
192 import models.model_reader as model_reader
193 import models.import_ufo as import_ufo
194 except ImportError:
195 raise self.ConfigurationError, '''Can\'t load MG5.
196 The variable mg5_path should not be correctly configure.'''
197
198 ufo_path = pjoin(self.me_dir,'bin','internal', 'ufomodel')
199 # Import model
200 if not MADEVENT:
201 modelname = self.find_model_name()
202 #restrict_file = None
203 #if os.path.exists(pjoin(ufo_path, 'restrict_default.dat')):
204 # restrict_file = pjoin(ufo_path, 'restrict_default.dat')
205 model = import_ufo.import_model(modelname, decay=True,
206 restrict=True)
207 if self.mother and self.mother.options['complex_mass_scheme']:
208 model.change_mass_to_complex_scheme()
209 else:
210 model = import_ufo.import_model(pjoin(self.me_dir,'bin','internal', 'ufomodel'),
211 decay=True)
212 #pattern for checking complex mass scheme.
213 has_cms = re.compile(r'''set\s+complex_mass_scheme\s*(True|T|1|true|$|;)''')
214 if has_cms.search(open(pjoin(self.me_dir,'Cards','proc_card_mg5.dat')\
215 ).read()):
216 model.change_mass_to_complex_scheme()
217
218
219# if not hasattr(model.get('particles')[0], 'partial_widths'):
220# raise self.InvalidCmd, 'The UFO model does not include partial widths information. Impossible to compute widths automatically'
221
222 # check if the name are passed to default MG5
223 if '-modelname' in open(pjoin(self.me_dir,'Cards','proc_card_mg5.dat')).read():
224 model.pass_particles_name_in_mg_default()
225 model = model_reader.ModelReader(model)
226 particles_name = dict([(p.get('name'), p.get('pdg_code'))
227 for p in model.get('particles')])
228 particles_name.update(dict([(p.get('antiname'), p.get('pdg_code'))
229 for p in model.get('particles')]))
230
231 output = {'model': model, 'force': False, 'output': None,
232 'path':None, 'particles': set(), 'body_decay':4.0025,
233 'min_br':None, 'precision_channel':0.01}
234 for arg in args:
235 if arg.startswith('--output='):
236 output_path = arg.split('=',1)[1]
237 if not os.path.exists(output_path):
238 raise self.InvalidCmd, 'Invalid Path for the output. Please retry.'
239 if not os.path.isfile(output_path):
240 output_path = pjoin(output_path, 'param_card.dat')
241 output['output'] = output_path
242 elif arg == '-f':
243 output['force'] = True
244 elif os.path.isfile(arg):
245 ftype = self.detect_card_type(arg)
246 if ftype != 'param_card.dat':
247 raise self.InvalidCmd , '%s is not a valid param_card.' % arg
248 output['path'] = arg
249 elif arg.startswith('--path='):
250 arg = arg.split('=',1)[1]
251 ftype = self.detect_card_type(arg)
252 if ftype != 'param_card.dat':
253 raise self.InvalidCmd , '%s is not a valid param_card.' % arg
254 output['path'] = arg
255 elif arg.startswith('--'):
256 name, value = arg.split('=',1)
257 try:
258 value = float(value)
259 except Exception:
260 raise self.InvalidCmd, '--%s requires integer or a float' % name
261 output[name[2:]] = float(value)
262 elif arg in particles_name:
263 # should be a particles
264 output['particles'].add(particles_name[arg])
265 elif arg.isdigit() and int(arg) in particles_name.values():
266 output['particles'].add(eval(arg))
267 elif arg == 'all':
268 output['particles'] = set(['all'])
269 else:
270 self.help_compute_widths()
271 raise self.InvalidCmd, '%s is not a valid argument for compute_widths' % arg
272 if self.force:
273 output['force'] = True
274
275 if not output['particles']:
276 raise self.InvalidCmd, '''This routines requires at least one particle in order to compute
277 the related width'''
278
279 if output['output'] is None:
280 output['output'] = output['path']
281
282 return output
283
171 def check_open(self, args):284 def check_open(self, args):
172 """ check the validity of the line """285 """ check the validity of the line """
173286
@@ -739,6 +852,12 @@
739 event_path = pjoin(self.me_dir, 'Events', self.run_name,'%s_delphes_events.lhco' % tag)852 event_path = pjoin(self.me_dir, 'Events', self.run_name,'%s_delphes_events.lhco' % tag)
740 output = pjoin(self.me_dir, 'HTML',self.run_name,853 output = pjoin(self.me_dir, 'HTML',self.run_name,
741 'plots_delphes_%s.html' % tag)854 'plots_delphes_%s.html' % tag)
855 elif mode == "shower":
856 event_path = pjoin(self.me_dir, 'Events','pythia_events.lhe')
857 output = pjoin(self.me_dir, 'HTML',self.run_name,
858 'plots_shower_%s.html' % tag)
859 if not self.options['pythia-pgs_path']:
860 return
742 else:861 else:
743 raise self.InvalidCmd, 'Invalid mode %s' % mode862 raise self.InvalidCmd, 'Invalid mode %s' % mode
744 elif mode == 'reweight' and not output:863 elif mode == 'reweight' and not output:
@@ -815,7 +934,7 @@
815934
816 # Creating LHE file935 # Creating LHE file
817 if misc.is_executable(pjoin(pydir, 'hep2lhe')):936 if misc.is_executable(pjoin(pydir, 'hep2lhe')):
818 self.update_status('Creating Pythia LHE File', level='pythia')937 self.update_status('Creating shower LHE File (for plot)', level='pythia')
819 # Write the banner to the LHE file938 # Write the banner to the LHE file
820 out = open(pjoin(self.me_dir,'Events','pythia_events.lhe'), 'w')939 out = open(pjoin(self.me_dir,'Events','pythia_events.lhe'), 'w')
821 #out.writelines('<LesHouchesEvents version=\"1.0\">\n')940 #out.writelines('<LesHouchesEvents version=\"1.0\">\n')
@@ -829,9 +948,10 @@
829948
830 self.cluster.launch_and_wait(self.dirbin+'/run_hep2lhe',949 self.cluster.launch_and_wait(self.dirbin+'/run_hep2lhe',
831 argument= [pydir],950 argument= [pydir],
832 cwd=pjoin(self.me_dir,'Events'))951 cwd=pjoin(self.me_dir,'Events'),
952 stdout=open(os.devnull,'w'))
833953
834 logger.info('Warning! Never use this pythia lhe file for detector studies!')954 logger.info('Warning! Never use this lhe file for detector studies!')
835 # Creating ROOT file955 # Creating ROOT file
836 if eradir and misc.is_executable(pjoin(eradir, 'ExRootLHEFConverter')):956 if eradir and misc.is_executable(pjoin(eradir, 'ExRootLHEFConverter')):
837 self.update_status('Creating Pythia LHE Root File', level='pythia')957 self.update_status('Creating Pythia LHE Root File', level='pythia')
@@ -960,6 +1080,33 @@
9601080
961 self.update_status('finish', level='pgs', makehtml=False)1081 self.update_status('finish', level='pgs', makehtml=False)
9621082
1083 ############################################################################
1084 def do_compute_widths(self, line):
1085 """Require MG5 directory: Compute automatically the widths of a set
1086 of particles"""
1087
1088 args = self.split_arg(line)
1089 opts = self.check_compute_widths(args)
1090
1091
1092 from madgraph.interface.master_interface import MasterCmd
1093 cmd = MasterCmd()
1094 self.define_child_cmd_interface(cmd, interface=False)
1095 cmd.exec_cmd('set automatic_html_opening False --no_save')
1096 if not opts['path']:
1097 opts['path'] = pjoin(self.me_dir, 'Cards', 'param_card.dat')
1098 if not opts['force'] :
1099 self.ask_edit_cards(['param_card'],[], plot=False)
1100
1101
1102 line = 'compute_widths %s %s' % \
1103 (' '.join([str(i) for i in opts['particles']]),
1104 ' '.join('--%s=%s' % (key,value) for (key,value) in opts.items()
1105 if key not in ['model', 'force', 'particles'] and value))
1106
1107 cmd.exec_cmd(line, model=opts['model'])
1108 self.child = None
1109 del cmd
9631110
964 ############################################################################ 1111 ############################################################################
965 def do_print_results(self, line):1112 def do_print_results(self, line):
@@ -1313,6 +1460,24 @@
1313 cluster_name = opt['cluster_type']1460 cluster_name = opt['cluster_type']
1314 self.cluster = cluster.from_name[cluster_name](**opt)1461 self.cluster = cluster.from_name[cluster_name](**opt)
13151462
1463 def check_param_card(self, path, run=True):
1464 """Check that all the width are define in the param_card.
1465 If some width are set on 'Auto', call the computation tools."""
1466
1467 pattern = re.compile(r'''decay\s+(\+?\-?\d+)\s+auto''',re.I)
1468 text = open(path).read()
1469 pdg = pattern.findall(text)
1470 if pdg:
1471 if run:
1472 logger.info('Computing the width set on auto in the param_card.dat')
1473 self.do_compute_widths('%s %s' % (' '.join(pdg), path))
1474 else:
1475 logger.info('''Some width are on Auto in the card.
1476 Those will be computed as soon as you have finish the edition of the cards.
1477 If you want to force the computation right now and being able to re-edit
1478 the cards afterwards, you can type \"compute_wdiths\".''')
1479
1480
1316 def add_error_log_in_html(self, errortype=None):1481 def add_error_log_in_html(self, errortype=None):
1317 """If a ME run is currently running add a link in the html output"""1482 """If a ME run is currently running add a link in the html output"""
13181483
@@ -1696,6 +1861,27 @@
1696 os.path.join('.',*[a for a in args \1861 os.path.join('.',*[a for a in args \
1697 if a.endswith(os.path.sep)]))1862 if a.endswith(os.path.sep)]))
16981863
1864 def complete_compute_widths(self, text, line, begidx, endidx):
1865 "Complete the compute_widths command"
1866
1867 args = self.split_arg(line[0:begidx])
1868
1869 if args[-1] in ['--path=', '--output=']:
1870 completion = {'path': self.path_completion(text)}
1871 elif line[begidx-1] == os.path.sep:
1872 current_dir = pjoin(*[a for a in args if a.endswith(os.path.sep)])
1873 if current_dir.startswith('--path='):
1874 current_dir = current_dir[7:]
1875 if current_dir.startswith('--output='):
1876 current_dir = current_dir[9:]
1877 completion = {'path': self.path_completion(text, current_dir)}
1878 else:
1879 completion = {}
1880 completion['options'] = self.list_completion(text,
1881 ['--path=', '--output=', '--min_br=0.\$'
1882 '--precision_channel=0.\$', '--body_decay='])
1883
1884 return self.deal_multiple_categories(completion)
1699 1885
17001886
1701# lhapdf-related functions1887# lhapdf-related functions
@@ -2080,7 +2266,7 @@
2080 self.list_completion(text, categories)2266 self.list_completion(text, categories)
2081 2267
2082 if 'shortcut' in allowed.keys():2268 if 'shortcut' in allowed.keys():
2083 possibilities['special values'] = self.list_completion(text, self.special_shortcut.keys()+['qcut'])2269 possibilities['special values'] = self.list_completion(text, self.special_shortcut.keys()+['qcut', 'showerkt'])
20842270
2085 if 'run_card' in allowed.keys():2271 if 'run_card' in allowed.keys():
2086 opts = self.run_set2272 opts = self.run_set
@@ -2219,6 +2405,19 @@
2219 p_card = '%s \n QCUT= %s' % (p_card, args[1])2405 p_card = '%s \n QCUT= %s' % (p_card, args[1])
2220 open(pythia_path, 'w').write(p_card)2406 open(pythia_path, 'w').write(p_card)
2221 return2407 return
2408 # Special case for the showerkt value
2409 if args[0].lower() == 'showerkt':
2410 pythia_path = pjoin(self.me_dir, 'Cards','pythia_card.dat')
2411 if os.path.exists(pythia_path):
2412 logger.info('add line SHOWERKT = %s in pythia_card.dat' % args[1].upper())
2413 p_card = open(pythia_path,'r').read()
2414 p_card, n = re.subn('''^\s*SHOWERKT\s*=\s*[default\de\+\-\.]*\s*$''',
2415 ''' SHOWERKT = %s ''' % args[1].upper(), \
2416 p_card, flags=(re.M+re.I))
2417 if n==0:
2418 p_card = '%s \n SHOWERKT= %s' % (p_card, args[1].upper())
2419 open(pythia_path, 'w').write(p_card)
2420 return
2222 2421
22232422
2224 card = '' #store which card need to be modify (for name conflict)2423 card = '' #store which card need to be modify (for name conflict)
22252424
=== modified file 'madgraph/interface/madevent_interface.py'
--- madgraph/interface/madevent_interface.py 2014-09-20 07:40:10 +0000
+++ madgraph/interface/madevent_interface.py 2014-09-24 19:46:10 +0000
@@ -418,13 +418,6 @@
418 logger.info(" asked in the run_card.")418 logger.info(" asked in the run_card.")
419 self.run_options_help([])419 self.run_options_help([])
420 420
421 def help_compute_widths(self):
422 logger.info("syntax: compute_widths Particle [Particles] [--precision=] [--path=Param_card] [--output=PATH]")
423 logger.info("-- Compute the widths for the particles specified.")
424 logger.info(" By default, this takes the current param_card and overwrites it.")
425 logger.info(" Precision allows to define when to include three/four/... body decays.")
426 logger.info(" If this number is an integer then all N-body decay will be included.")
427
428 def help_store_events(self):421 def help_store_events(self):
429 """ """422 """ """
430 logger.info("syntax: store_events [--run_options]")423 logger.info("syntax: store_events [--run_options]")
@@ -867,112 +860,7 @@
867 raise self.InvalidCmd('refine arguments are suppose to be number')860 raise self.InvalidCmd('refine arguments are suppose to be number')
868 861
869 return True862 return True
870 863
871 def check_compute_widths(self, args):
872 """check that the model is loadable and check that the format is of the
873 type: PART PATH --output=PATH -f --precision=N
874 return the model.
875 """
876
877 # Check that MG5 directory is present .
878 if MADEVENT and not self.options['mg5_path']:
879 raise self.InvalidCmd, '''The automatic computations of widths requires that MG5 is installed on the system.
880 You can install it and set his path in ./Cards/me5_configuration.txt'''
881 elif MADEVENT:
882 sys.path.append(self.options['mg5_path'])
883 try:
884 import models.model_reader as model_reader
885 import models.import_ufo as import_ufo
886 except ImportError:
887 raise self.ConfigurationError, '''Can\'t load MG5.
888 The variable mg5_path should not be correctly configure.'''
889
890 ufo_path = pjoin(self.me_dir,'bin','internal', 'ufomodel')
891 # Import model
892 if not MADEVENT:
893 modelname = self.find_model_name()
894 #restrict_file = None
895 #if os.path.exists(pjoin(ufo_path, 'restrict_default.dat')):
896 # restrict_file = pjoin(ufo_path, 'restrict_default.dat')
897 model = import_ufo.import_model(modelname, decay=True,
898 restrict=True)
899 if self.mother and self.mother.options['complex_mass_scheme']:
900 model.change_mass_to_complex_scheme()
901 else:
902 model = import_ufo.import_model(pjoin(self.me_dir,'bin','internal', 'ufomodel'),
903 decay=True)
904 #pattern for checking complex mass scheme.
905 has_cms = re.compile(r'''set\s+complex_mass_scheme\s*(True|T|1|true|$|;)''')
906 if has_cms.search(open(pjoin(self.me_dir,'Cards','proc_card_mg5.dat')\
907 ).read()):
908 model.change_mass_to_complex_scheme()
909
910
911# if not hasattr(model.get('particles')[0], 'partial_widths'):
912# raise self.InvalidCmd, 'The UFO model does not include partial widths information. Impossible to compute widths automatically'
913
914 # check if the name are passed to default MG5
915 if '-modelname' in open(pjoin(self.me_dir,'Cards','proc_card_mg5.dat')).read():
916 model.pass_particles_name_in_mg_default()
917 model = model_reader.ModelReader(model)
918 particles_name = dict([(p.get('name'), p.get('pdg_code'))
919 for p in model.get('particles')])
920 particles_name.update(dict([(p.get('antiname'), p.get('pdg_code'))
921 for p in model.get('particles')]))
922
923 output = {'model': model, 'force': False, 'output': None,
924 'path':None, 'particles': set(), 'body_decay':4.0025,
925 'min_br':None, 'precision_channel':0.01}
926 for arg in args:
927 if arg.startswith('--output='):
928 output_path = arg.split('=',1)[1]
929 if not os.path.exists(output_path):
930 raise self.InvalidCmd, 'Invalid Path for the output. Please retry.'
931 if not os.path.isfile(output_path):
932 output_path = pjoin(output_path, 'param_card.dat')
933 output['output'] = output_path
934 elif arg == '-f':
935 output['force'] = True
936 elif os.path.isfile(arg):
937 type = self.detect_card_type(arg)
938 if type != 'param_card.dat':
939 raise self.InvalidCmd , '%s is not a valid param_card.' % arg
940 output['path'] = arg
941 elif arg.startswith('--path='):
942 arg = arg.split('=',1)[1]
943 type = self.detect_card_type(arg)
944 if type != 'param_card.dat':
945 raise self.InvalidCmd , '%s is not a valid param_card.' % arg
946 output['path'] = arg
947 elif arg.startswith('--'):
948 name, value = arg.split('=',1)
949 try:
950 value = float(value)
951 except Exception:
952 raise self.InvalidCmd, '--%s requires integer or a float' % name
953 output[name[2:]] = float(value)
954 elif arg in particles_name:
955 # should be a particles
956 output['particles'].add(particles_name[arg])
957 elif arg.isdigit() and int(arg) in particles_name.values():
958 output['particles'].add(eval(arg))
959 elif arg == 'all':
960 output['particles'] = set(['all'])
961 else:
962 self.help_compute_widths()
963 raise self.InvalidCmd, '%s is not a valid argument for compute_widths' % arg
964 if self.force:
965 output['force'] = True
966
967 if not output['particles']:
968 raise self.InvalidCmd, '''This routines requires at least one particle in order to compute
969 the related width'''
970
971 if output['output'] is None:
972 output['output'] = output['path']
973
974 return output
975
976 def check_combine_events(self, arg):864 def check_combine_events(self, arg):
977 """ Check the argument for the combine events command """865 """ Check the argument for the combine events command """
978 866
@@ -1506,28 +1394,6 @@
1506 else:1394 else:
1507 return self.complete_generate_events(*args, **opts)1395 return self.complete_generate_events(*args, **opts)
15081396
1509 def complete_compute_widths(self, text, line, begidx, endidx):
1510 "Complete the compute_widths command"
1511
1512 args = self.split_arg(line[0:begidx])
1513
1514 if args[-1] in ['--path=', '--output=']:
1515 completion = {'path': self.path_completion(text)}
1516 elif line[begidx-1] == os.path.sep:
1517 current_dir = pjoin(*[a for a in args if a.endswith(os.path.sep)])
1518 if current_dir.startswith('--path='):
1519 current_dir = current_dir[7:]
1520 if current_dir.startswith('--output='):
1521 current_dir = current_dir[9:]
1522 completion = {'path': self.path_completion(text, current_dir)}
1523 else:
1524 completion = {}
1525 completion['options'] = self.list_completion(text,
1526 ['--path=', '--output=', '--min_br=0.\$'
1527 '--precision_channel=0.\$', '--body_decay='])
1528
1529 return self.deal_multiple_categories(completion)
1530
1531 def complete_calculate_decay_widths(self, text, line, begidx, endidx):1397 def complete_calculate_decay_widths(self, text, line, begidx, endidx):
1532 """ Complete the calculate_decay_widths command"""1398 """ Complete the calculate_decay_widths command"""
1533 1399
@@ -2694,33 +2560,7 @@
2694 self.create_root_file(output='%s/unweighted_events.root' % \2560 self.create_root_file(output='%s/unweighted_events.root' % \
2695 self.run_name)2561 self.run_name)
2696 2562
2697 ############################################################################
2698 def do_compute_widths(self, line):
2699 """Require MG5 directory: Compute automatically the widths of a set
2700 of particles"""
27012563
2702 args = self.split_arg(line)
2703 opts = self.check_compute_widths(args)
2704
2705
2706 from madgraph.interface.master_interface import MasterCmd
2707 cmd = MasterCmd()
2708 self.define_child_cmd_interface(cmd, interface=False)
2709 cmd.exec_cmd('set automatic_html_opening False --no_save')
2710 if not opts['path']:
2711 opts['path'] = pjoin(self.me_dir, 'Cards', 'param_card.dat')
2712 if not opts['force'] :
2713 self.ask_edit_cards(['param_card'],[], plot=False)
2714
2715
2716 line = 'compute_widths %s %s' % \
2717 (' '.join([str(i) for i in opts['particles']]),
2718 ' '.join('--%s=%s' % (key,value) for (key,value) in opts.items()
2719 if key not in ['model', 'force', 'particles'] and value))
2720
2721 cmd.exec_cmd(line, model=opts['model'])
2722 self.child = None
2723 del cmd
27242564
27252565
2726 2566
@@ -4048,22 +3888,8 @@
4048 3888
4049 3889
4050 3890
4051 def check_param_card(self, path, run=True):3891
4052 """Check that all the width are define in the param_card.3892
4053 If some width are set on 'Auto', call the computation tools."""
4054
4055 pattern = re.compile(r'''decay\s+(\+?\-?\d+)\s+auto''',re.I)
4056 text = open(path).read()
4057 pdg = pattern.findall(text)
4058 if pdg:
4059 if run:
4060 logger.info('Computing the width set on auto in the param_card.dat')
4061 self.do_compute_widths('%s %s' % (' '.join(pdg), path))
4062 else:
4063 logger.info('''Some width are on Auto in the card.
4064 Those will be computed as soon as you have finish the edition of the cards.
4065 If you want to force the computation right now and being able to re-edit
4066 the cards afterwards, you can type \"compute_wdiths\".''')
4067#===============================================================================3893#===============================================================================
4068# MadEventCmd3894# MadEventCmd
4069#===============================================================================3895#===============================================================================
40703896
=== modified file 'madgraph/various/gen_crossxhtml.py'
--- madgraph/various/gen_crossxhtml.py 2014-09-22 07:17:43 +0000
+++ madgraph/various/gen_crossxhtml.py 2014-09-24 19:46:10 +0000
@@ -791,6 +791,10 @@
791 glob.glob(pjoin(path,"*.hep.gz")):791 glob.glob(pjoin(path,"*.hep.gz")):
792 self.shower.append('hep')792 self.shower.append('hep')
793793
794 if 'plot' not in self.shower and \
795 exists(pjoin(html_path,"plots_shower_%s.html" % tag)):
796 self.shower.append('plot')
797
794 if glob.glob(pjoin(path,"*.hepmc")) + \798 if glob.glob(pjoin(path,"*.hepmc")) + \
795 glob.glob(pjoin(path,"*.hepmc.gz")):799 glob.glob(pjoin(path,"*.hepmc.gz")):
796 self.shower.append('hepmc')800 self.shower.append('hepmc')
@@ -988,6 +992,8 @@
988 glob.glob(pjoin(self.me_dir, 'Events', self['run_name'], '*.' + kind)) + \992 glob.glob(pjoin(self.me_dir, 'Events', self['run_name'], '*.' + kind)) + \
989 glob.glob(pjoin(self.me_dir, 'Events', self['run_name'], '*.' + kind + '.gz')):993 glob.glob(pjoin(self.me_dir, 'Events', self['run_name'], '*.' + kind + '.gz')):
990 out += " <a href=\"%s\">%s</a> " % (f, kind.upper())994 out += " <a href=\"%s\">%s</a> " % (f, kind.upper())
995 if 'plot' in self.shower:
996 out += """ <a href="./HTML/%(run_name)s/plots_shower_%(tag)s.html">plots</a>"""
991 997
992 return out % self998 return out % self
993 999
9941000
=== modified file 'tests/test_manager.py'
--- tests/test_manager.py 2014-05-15 00:02:06 +0000
+++ tests/test_manager.py 2014-09-24 19:46:10 +0000
@@ -115,6 +115,38 @@
115 self.stream.writeln(" ".join(self.bypassed))115 self.stream.writeln(" ".join(self.bypassed))
116 return result 116 return result
117117
118 def run_border(self, test):
119 "Run the given test case or test suite."
120 MyTextTestRunner.stream = self.stream
121 result = self._makeResult()
122 startTime = time.time()
123 test(result)
124 stopTime = time.time()
125 timeTaken = float(stopTime - startTime)
126 result.printErrors()
127 self.stream.writeln(result.separator2)
128 run = result.testsRun
129 #self.stream.writeln("Ran %d test%s in %.3fs" %
130 # (run, run != 1 and "s" or "", timeTaken))
131 #self.stream.writeln()
132 if not result.wasSuccessful():
133 self.stream.write("FAILED (")
134 failed, errored = map(len, (result.failures, result.errors))
135 if failed:
136 self.stream.write("failures=%d" % failed)
137 if errored:
138 if failed: self.stream.write(", ")
139 self.stream.write("errors=%d" % errored)
140 self.stream.writeln(")")
141 sys.exit(0)
142 #else:
143 # self.stream.writeln("OK")
144 #if self.bypassed:
145 # self.stream.writeln("Bypassed %s:" % len(self.bypassed))
146 # self.stream.writeln(" ".join(self.bypassed))
147 return result
148
149
118 150
119#===============================================================================151#===============================================================================
120# run152# run
@@ -153,6 +185,46 @@
153 #return out185 #return out
154186
155#===============================================================================187#===============================================================================
188# run
189#===============================================================================
190def run_border_search(to_crash='',expression='', re_opt=0, package='./tests/unit_tests', verbosity=1,
191 timelimit=0):
192 """ running the test associated to expression one by one. and follow them by the to_crash one
193 up to the time that to_crash is actually crashing. Then the run stops and print the list of the
194 routine tested. Then the code re-run itself(via a fork) to restrict the list.
195 The code stops when the list is of order 1. The order of the test is randomize at each level!
196 """
197 #init a test suite
198 collect = unittest.TestLoader()
199 TestSuiteModified.time_limit = float(timelimit)
200 all_test = TestFinder(package=package, expression=expression, re_opt=re_opt)
201 import random
202 random.shuffle(all_test)
203 print "to_crash"
204 to_crash = TestFinder(package=package, expression=to_crash, re_opt=re_opt)
205 to_crash.collect_dir(package, checking=True)
206 print dir(to_crash)
207
208 for test_fct in all_test:
209 testsuite = unittest.TestSuite()
210 data = collect.loadTestsFromName(test_fct)
211 assert(isinstance(data,unittest.TestSuite))
212 data.__class__ = TestSuiteModified
213 testsuite.addTest(data)
214 data = collect.loadTestsFromName(to_crash[0])
215 assert(isinstance(data,unittest.TestSuite))
216 data.__class__ = TestSuiteModified
217 testsuite.addTest(data)
218 # Running it
219 print "run it for %s" % test_fct
220 output = MyTextTestRunner(verbosity=verbosity).run_border(testsuite)
221
222 return output
223 #import tests
224 #print 'runned %s checks' % tests.NBTEST
225 #return out
226
227#===============================================================================
156# listIOTests228# listIOTests
157#===============================================================================229#===============================================================================
158230
@@ -262,8 +334,8 @@
262 IOTestManager.testFolders_filter = arg.split('/')[0].split('&')334 IOTestManager.testFolders_filter = arg.split('/')[0].split('&')
263 IOTestManager.testNames_filter = arg.split('/')[1].split('&')335 IOTestManager.testNames_filter = arg.split('/')[1].split('&')
264 IOTestManager.filesChecked_filter = '/'.join(arg.split('/')[2:]).split('&')336 IOTestManager.filesChecked_filter = '/'.join(arg.split('/')[2:]).split('&')
265 #print "INFO:: Using folders %s"%str(IOTestManager.testFolders_filter)337 #print "INFO:: Using folders %s"%str(IOTestManager.testFolders_filter)
266 #print "INFO:: Using test names %s"%str(IOTestManager.testNames_filter)338 #print "INFO:: Using test names %s"%str(IOTestManager.testNames_filter)
267 #print "INFO:: Using file paths %s"%str(IOTestManager.filesChecked_filter)339 #print "INFO:: Using file paths %s"%str(IOTestManager.filesChecked_filter)
268 340
269 # Initiate all the IOTests from all the setUp()341 # Initiate all the IOTests from all the setUp()
@@ -820,7 +892,10 @@
820 "content of the folder IOTestsComparison")892 "content of the folder IOTestsComparison")
821 parser.add_option("-t", "--timed", default="Auto",893 parser.add_option("-t", "--timed", default="Auto",
822 help="limit the duration of each test. Negative number re-writes the information file.") 894 help="limit the duration of each test. Negative number re-writes the information file.")
823 895
896 parser.add_option("", "--border_effect", default=None,
897 help="Define the test which are sensitive to a border effect, the test will find which test creates this border effect")
898
824 (options, args) = parser.parse_args()899 (options, args) = parser.parse_args()
825900
826 if options.IOTestsUpdate:901 if options.IOTestsUpdate:
@@ -897,9 +972,13 @@
897 " MadGraph5_aMCatNLO is configured not to compress the references files."972 " MadGraph5_aMCatNLO is configured not to compress the references files."
898 973
899 if options.IOTests=='No' and not options.synchronize:974 if options.IOTests=='No' and not options.synchronize:
900 #logging.basicConfig(level=vars(logging)[options.logging])975 if not options.border_effect:
901 run(args, re_opt=options.reopt, verbosity=options.verbose, \976 #logging.basicConfig(level=vars(logging)[options.logging])
902 package=options.path, timelimit=options.timed)977 run(args, re_opt=options.reopt, verbosity=options.verbose, \
978 package=options.path, timelimit=options.timed)
979 else:
980 run_border_search(options.border_effect, args, re_opt=options.reopt, verbosity=options.verbose, \
981 package=options.path, timelimit=options.timed)
903 else:982 else:
904 if options.IOTests=='L':983 if options.IOTests=='L':
905 print "Listing all tests defined in the reference files ..."984 print "Listing all tests defined in the reference files ..."

Subscribers

People subscribed via source and target branches

to all changes: