def collect_result(cmd, folder_names=[], jobs=None, main_dir=None): """ """ run = cmd.results.current['run_name'] all = Combine_results(run) for Pdir in cmd.get_Pdir(): P_comb = Combine_results(Pdir) if jobs: for job in [j for j in jobs if j['p_dir'] in Pdir]: P_comb.add_results(os.path.basename(job['dirname']),\ pjoin(job['dirname'],'results.dat')) elif folder_names: try: for line in open(pjoin(Pdir, 'symfact.dat')): name, mfactor = line.split() if float(mfactor) < 0: continue if os.path.exists(pjoin(Pdir, 'ajob.no_ps.log')): continue for folder in folder_names: if 'G' in folder: dir = folder.replace('*', name) else: dir = folder.replace('*', '_G' + name) P_comb.add_results(dir, pjoin(Pdir,dir,'results.dat'), mfactor) if jobs: for job in [j for j in jobs if j['p_dir'] == Pdir]: P_comb.add_results(os.path.basename(job['dirname']),\ pjoin(job['dirname'],'results.dat')) except IOError: continue else: G_dir, mfactors = cmd.get_Gdir(Pdir, symfact=True) for G in G_dir: if not folder_names: if main_dir: path = pjoin(main_dir, os.path.basename(Pdir), os.path.basename(G),'results.dat') else: path = pjoin(G,'results.dat') P_comb.add_results(os.path.basename(G), path, mfactors[G]) P_comb.compute_values() all.append(P_comb) all.compute_values() try: all_channels = sum([list(P) for P in all],[]) timings = sum(x.timing for x in all_channels) logger.info('sum of cpu time of last step: %s', misc.format_time(timings)) except Exception as error: logger.debug(str(error)) pass for x in all_channels: x.timing = 0 return all
def nice_output(self, G, no_warning=False): """Returns a one-line string summarizing the run statistics gathered for the channel G.""" # Do not return anythign for now if there is no madloop calls. This can # change of course if more statistics are gathered, unrelated to MadLoop. if self['n_madloop_calls'] == 0: return '' stability = [ ('tot#', self['n_madloop_calls']), ('unkwn#', self['unknown_stability']), ('UPS%', float(self['unstable_points']) / self['n_madloop_calls']), ('EPS#', self['exceptional_points']) ] stability = [ _ for _ in stability if _[1] > 0 or _[0] in ['UPS%', 'EPS#'] ] stability = [(_[0], '%i' % _[1]) if isinstance(_[1], int) else (_[0], '%.3g' % (100.0 * _[1])) for _ in stability] tools_used = [ ('CT_DP', float(self['CutTools_DP_usage']) / self['n_madloop_calls']), ('CT_QP', float(self['CutTools_QP_usage']) / self['n_madloop_calls']), ('PJFry', float(self['PJFry_usage']) / self['n_madloop_calls']), ('Golem', float(self['Golem_usage']) / self['n_madloop_calls']), ('IREGI', float(self['IREGI_usage']) / self['n_madloop_calls']) ] tools_used = [(_[0], '%.3g' % (100.0 * _[1])) for _ in tools_used if _[1] > 0.0] to_print = [('%s statistics:'%(G if isinstance(G,str) else str(os.path.join(list(G))))\ +(' %s,'%misc.format_time(int(self['cumulative_timing'])) if int(self['cumulative_timing']) > 0 else '') +((' Avg. ML timing = %i ms'%int(1.0e3*self['averaged_timing'])) if self['averaged_timing'] > 0.001 else (' Avg. ML timing = %i mus'%int(1.0e6*self['averaged_timing']))) \ +', Min precision = %.2e'%self['min_precision']) ,' -> Stability %s'%dict(stability) ,' -> Red. tools usage in %% %s'%dict(tools_used) # I like the display above better after all # ,'Stability %s'%(str([_[0] for _ in stability]), # str([_[1] for _ in stability])) # ,'Red. tools usage in %% %s'%(str([_[0] for _ in tools_used]), # str([_[1] for _ in tools_used])) ] if self['skipped_subchannel'] > 0 and not no_warning: to_print.append("WARNING: Some event with large weight have been "+\ "discarded. This happened %s times." % self['skipped_subchannel']) return ('\n'.join(to_print)).replace("'", " ")
def nice_output(self,G, no_warning=False): """Returns a one-line string summarizing the run statistics gathered for the channel G.""" # Do not return anythign for now if there is no madloop calls. This can # change of course if more statistics are gathered, unrelated to MadLoop. if self['n_madloop_calls']==0: return '' stability = [ ('tot#',self['n_madloop_calls']), ('unkwn#',self['unknown_stability']), ('UPS%',float(self['unstable_points'])/self['n_madloop_calls']), ('EPS#',self['exceptional_points'])] stability = [_ for _ in stability if _[1] > 0 or _[0] in ['UPS%','EPS#']] stability = [(_[0],'%i'%_[1]) if isinstance(_[1], int) else (_[0],'%.3g'%(100.0*_[1])) for _ in stability] tools_used = [ ('CT_DP',float(self['CutTools_DP_usage'])/self['n_madloop_calls']), ('CT_QP',float(self['CutTools_QP_usage'])/self['n_madloop_calls']), ('PJFry',float(self['PJFry_usage'])/self['n_madloop_calls']), ('Golem',float(self['Golem_usage'])/self['n_madloop_calls']), ('IREGI',float(self['IREGI_usage'])/self['n_madloop_calls']), ('Samurai',float(self['Samurai_usage'])/self['n_madloop_calls']), ('Ninja_DP',float(self['Ninja_usage'])/self['n_madloop_calls']), ('Ninja_QP',float(self['Ninja_QP_usage'])/self['n_madloop_calls'])] tools_used = [(_[0],'%.3g'%(100.0*_[1])) for _ in tools_used if _[1] > 0.0 ] to_print = [('%s statistics:'%(G if isinstance(G,str) else str(os.path.join(list(G))))\ +(' %s,'%misc.format_time(int(self['cumulative_timing'])) if int(self['cumulative_timing']) > 0 else '') +((' Avg. ML timing = %i ms'%int(1.0e3*self['averaged_timing'])) if self['averaged_timing'] > 0.001 else (' Avg. ML timing = %i mus'%int(1.0e6*self['averaged_timing']))) \ +', Min precision = %.2e'%self['min_precision']) ,' -> Stability %s'%dict(stability) ,' -> Red. tools usage in %% %s'%dict(tools_used) # I like the display above better after all # ,'Stability %s'%(str([_[0] for _ in stability]), # str([_[1] for _ in stability])) # ,'Red. tools usage in %% %s'%(str([_[0] for _ in tools_used]), # str([_[1] for _ in tools_used])) ] if self['skipped_subchannel'] > 0 and not no_warning: to_print.append("WARNING: Some event with large weight have been "+\ "discarded. This happened %s times." % self['skipped_subchannel']) return ('\n'.join(to_print)).replace("'"," ")