Ejemplo n.º 1
0
    def create_loop_pickle(self, my_proc_list, model, pickle_file, energy, \
                                                                 chosen_runner):
        """ Create the pickle file for reference for the arguments here."""
        #       print "Creating loop pickle for chosen_runner=",chosen_runner
        allowed_chosen_runners = ['ML4', 'ML5_opt', 'ML5_default']
        if chosen_runner not in allowed_chosen_runners:
            raise MadGraph5Error, 'The reference runner can only be in %s.'%\
                                                          allowed_chosen_runners

        runner = None
        if chosen_runner == 'ML5_opt':
            runner = loop_me_comparator.LoopMG5Runner()
            runner.setup(_mg5_path, optimized_output=True)
        if chosen_runner == 'ML5_default':
            runner = loop_me_comparator.LoopMG5Runner()
            runner.setup(_mg5_path, optimized_output=False)
        if chosen_runner == 'ML4':
            runner = loop_me_comparator.LoopMG4Runner()
            # Replace here the path of your ML4 installation
            runner.setup(
                '/Users/valentin/Documents/Work/aMC@NLO_v4/ML4ParrallelTest/NLOComp'
            )

        self.create_pickle(my_proc_list,pickle_file, runner, ref_runner=None, \
                                                      model=model,energy=energy)
        # Clean up the runner only if it is not ML4
        if chosen_runner != 'ML4':
            runner.cleanup()
Ejemplo n.º 2
0
    def compare_processes(self, my_proc_list = [], model = 'loop_sm-parallel_test',
            pickle_file = "", energy = 2000, tolerance = 1e-06, filename = "",
            chosen_runner = "ML5_opt"):
        """ A helper function to compare processes. 
        Note that the chosen_runner is what runner should to create the reference
        pickle if missing"""
        
        # Print out progress if it is a run for an individual process
        if len(my_proc_list)==1:
            print "\n== %s =="%my_proc_list[0][0]
        else:
            print "\n== %s =="%filename
        
        # Check if pickle exists, if not create it        
        if pickle_file!="" and not os.path.isfile(os.path.join(_pickle_path,pickle_file)):
            print " => Computing reference evaluation with %s"%chosen_runner
            self.create_loop_pickle(my_proc_list, model,
                                             pickle_file, energy, chosen_runner)
            print "\n => Done with %s evaluation"%chosen_runner
        # Load the stored runner
        if pickle_file != "":
            stored_runner = me_comparator.PickleRunner.find_comparisons(
                              os.path.join(_pickle_path,pickle_file))[0]

        # Create a MERunner object for MadLoop 5 optimized
        ML5_opt = loop_me_comparator.LoopMG5Runner()
        ML5_opt.setup(_mg5_path, optimized_output=True, temp_dir=filename)
    
        # Create a MERunner object for MadLoop 5 default
        ML5_default = loop_me_comparator.LoopMG5Runner()
        ML5_default.setup(_mg5_path, optimized_output=False, temp_dir=filename) 

        # Create and setup a comparator
        my_comp = loop_me_comparator.LoopMEComparator()
        
        # Always put the saved run first if you use it, so that the corresponding PS
        # points will be used.
        if pickle_file != "":
            my_comp.set_me_runners(stored_runner,ML5_opt,ML5_default)
        else:
            my_comp.set_me_runners(ML5_opt,ML5_default)
        
        # Run the actual comparison
        my_comp.run_comparison(my_proc_list,
                           model=model,
                           energy=energy)
        
        # Print the output
        my_comp.output_result(filename=os.path.join(_mg5_path,filename+'.log'))

        # Assert that all process comparisons passed the tolerance cut
        my_comp.assert_processes(self, tolerance)

        # Do some cleanup
        my_comp.cleanup()
Ejemplo n.º 3
0
def create_loop_pickle(my_proc_list, model, pickle_file, energy, \
                                                             chosen_runner):
    """ Create the pickle file for reference for the arguments here."""
    #       print "Creating loop pickle for chosen_runner=",chosen_runner
    allowed_chosen_runners = ['ML5_opt', 'ML5_default']
    if chosen_runner not in allowed_chosen_runners:
        raise MadGraph5Error, 'The reference runner can only be in %s.'%\
                                                      allowed_chosen_runners

    runner = None
    if chosen_runner == 'ML5_opt':
        runner = loop_me_comparator.LoopMG5Runner()
        runner.setup(_mg5_path, optimized_output=True)
    if chosen_runner == 'ML5_default':
        runner = loop_me_comparator.LoopMG5Runner()
        runner.setup(_mg5_path, optimized_output=False)

    create_pickle(my_proc_list,pickle_file, runner, ref_runner=None, \
                                                  model=model,energy=energy)

    runner.cleanup()
Ejemplo n.º 4
0
    # Load a saved run
    #SavedRun = me_comparator.PickleRunner.find_comparisons(
    #                     os.path.join(pickle_path,'ml5_parallel_test.pkl'))[0]
    # Create a MERunner object for MadLoop 4
    #ML4 = loop_me_comparator.LoopMG4Runner()
    #ML4.setup('/Users/Spooner/Documents/PhD/MadFKS/ML4ParrallelTest/NLOComp')
    # Create a MERunner object from Hard-Coded Reference value
    HCRvalue = loop_me_comparator.LoopHardCodedRefRunner()
    HCRvalue.setup(my_proc_list, my_res_list, model)
    # Create a MERunner object for GoSam
    #GoSam = loop_me_comparator.GoSamRunner()
    # GoSam.setup('/Users/erdissshaw/Works/GoSam/gosam_dir')
    # GoSam.setup('/Users/valentin/Documents/HEP_softs/GoSam/gosam-2.0.beta')

    # Create a MERunner object for MadLoop 5 optimized
    ML5_opt = loop_me_comparator.LoopMG5Runner()
    ML5_opt.setup(mg5_path, optimized_output=True)

    # Create a MERunner object for MadLoop 5 default
    ML5_default = loop_me_comparator.LoopMG5Runner()
    ML5_default.setup(mg5_path, optimized_output=False)

    # Create a MERunner object for UFO-ALOHA-MG5
    #    my_mg5_ufo = me_comparator.MG5_UFO_Runner()
    #    my_mg5_ufo.setup(mg5_path, mg4_path)

    # Create and setup a comparator
    my_comp = loop_me_comparator.LoopMEComparator()
    # Always put the saved run first if you use it, so that the corresponding PS
    # points will be used
    #my_comp.set_me_runners(ML5_opt,GoSam)
Ejemplo n.º 5
0
    def compare_processes(self,
                          my_proc_list=[],
                          model='loop_sm-parallel_test',
                          pickle_file="",
                          energy=2000,
                          tolerance=3e-06,
                          filename="",
                          chosen_runner="ML5_opt",
                          compare_with=['ML5_opt', 'ML5_def']):
        """ A helper function to compare processes. 
        Note that the chosen_runner is what runner should to create the reference
        pickle if missing"""

        # Print out progress if it is a run for an individual process
        if len(my_proc_list) == 1:
            print "\n== %s ==" % my_proc_list[0][0]
        else:
            print "\n== %s ==" % filename

        # Check if pickle exists, if not create it
        if pickle_file != "" and not os.path.isfile(
                os.path.join(_pickle_path, pickle_file)):
            print " => Computing reference evaluation with %s" % chosen_runner
            self.create_loop_pickle(my_proc_list, model, pickle_file, energy,
                                    chosen_runner)
            print "\n => Done with %s evaluation" % chosen_runner
        # Load the stored runner
        if pickle_file != "":
            stored_runner = me_comparator.PickleRunner.find_comparisons(
                os.path.join(_pickle_path, pickle_file))[0]

        # Create a MERunner object for MadLoop 5 optimized
        ML5_opt = loop_me_comparator.LoopMG5Runner()
        ML5_opt.setup(_mg5_path, optimized_output=True, temp_dir=filename)

        MLCard = banner_mod.MadLoopParam(
            os.path.join(_mg5_path, 'Template', 'loop_material', 'StandAlone',
                         'Cards', 'MadLoopParams.dat'))
        MLredstr = MLCard['MLReductionLib'][0:1]
        if MLredstr == "1":
            # Create a MERunner object for MadLoop 5 default
            ML5_default = loop_me_comparator.LoopMG5Runner()
            ML5_default.setup(_mg5_path,
                              optimized_output=False,
                              temp_dir=filename)

        # Create and setup a comparator
        my_comp = loop_me_comparator.LoopMEComparator()

        # Remove the default ML5 comparator if using TIR
        to_compare_with = copy.copy(compare_with)
        if MLredstr != '1':
            try:
                to_compare_with.pop(to_compare_with.index('ML5_def'))
            except ValueError:
                pass

        runners_available = {
            'ML5_opt': ML5_opt,
            'ML5_def': ML5_opt,
            'Stored': stored_runner
        }
        # Always put the saved run first if you use it, so that the corresponding PS
        # points will be used.
        runners_to_compare = []
        if pickle_file != "":
            runners_to_compare.append(stored_runner)
        runners_to_compare.extend([runners_available[runner] for runner in \
                                                               to_compare_with])

        if len(runners_to_compare) <= 1:
            raise MadGraph5Error,\
"""  Only one runner to compute the result with, so there is no possible comparison.
  This is most likely due to the fact that you are running a TIR only comparison
  and the reference pickle cannot be found."""

        # Set the runners to include
        my_comp.set_me_runners(*runners_to_compare)

        # Run the actual comparison
        my_comp.run_comparison(my_proc_list, model=model, energy=energy)

        # Print the output
        my_comp.output_result(filename=os.path.join(_mg5_path, filename +
                                                    '.log'))

        # Assert that all process comparisons passed the tolerance cut
        my_comp.assert_processes(self, tolerance)

        # Do some cleanup
        my_comp.cleanup()
Ejemplo n.º 6
0
def compare_processes(testInstance,
                      my_proc_list=[],
                      model='loop_qcd_qed_sm-parallel_test',
                      pickle_file="",
                      energy=2000,
                      tolerance=3e-06,
                      filename="",
                      chosen_runner="ML5_opt",
                      loop_induce=False,
                      mu_r=0.0):
    """ A helper function to compare processes. 
    Note that the chosen_runner is what runner should to create the reference
    pickle if missing"""

    # Print out progress if it is a run for an individual process
    if len(my_proc_list) == 1:
        print "\n== %s %s ==" % (my_proc_list[0][0], my_proc_list[0][2])
    else:
        print "\n== %s ==" % filename

    # Check if pickle exists, if not create it
    if pickle_file != "" and not os.path.isfile(
            os.path.join(_pickle_path, pickle_file)):
        print " => Computing reference evaluation with %s" % chosen_runner
        create_loop_pickle(my_proc_list, model, pickle_file, energy,
                           chosen_runner)
        print "\n => Done with %s evaluation" % chosen_runner
    # Load the stored runner
    if pickle_file != "":
        stored_runner = me_comparator.PickleRunner.find_comparisons(
            os.path.join(_pickle_path, pickle_file))[0]
        energy = stored_runner.energy

    file = open(
        os.path.join(_mg5_path, 'Template', 'loop_material', 'StandAlone',
                     'Cards', 'MadLoopParams.dat'), 'r')

    # Check if the process has squared order constraints
    has_sqso = any('^2' in key for proc in my_proc_list for key in \
                                                             proc[3].keys())

    MLParams = file.read()
    MLred = re.search(r'#MLReductionLib\n', MLParams)
    MLredstr = MLParams[MLred.end():MLred.end() + 1]
    if loop_induce and MLredstr != "1": return
    # Create a MERunner object for MadLoop 5 optimized
    # Open Loops is not avaiable for loop induced processes
    if not loop_induce:
        ML5_opt = loop_me_comparator.LoopMG5Runner()
        ML5_opt.setup(_mg5_path, optimized_output=True, temp_dir=filename,\
                      mu_r=mu_r)

    if MLredstr == "1" and not has_sqso:
        # Create a MERunner object for MadLoop 5 default
        ML5_default = loop_me_comparator.LoopMG5Runner()
        ML5_default.setup(_mg5_path, optimized_output=False, temp_dir=filename,\
                      mu_r=mu_r)

    # Create and setup a comparator
    my_comp = loop_me_comparator.LoopMEComparator()

    if MLredstr == "1" and not has_sqso:
        # Always put the saved run first if you use it, so that the corresponding PS
        # points will be used.
        if pickle_file != "" and not loop_induce:
            my_comp.set_me_runners(stored_runner, ML5_opt, ML5_default)
        elif pickle_file != "" and loop_induce:
            my_comp.set_me_runners(stored_runner, ML5_default)
        elif pickle_file == "" and not loop_induce:
            my_comp.set_me_runners(ML5_opt, ML5_default)
        else:
            raise MadGraph5Error, \
                'Cannot find pickle_file for loop induced process.'
    else:
        if pickle_file != "":
            my_comp.set_me_runners(stored_runner, ML5_opt)
        else:
            raise MadGraph5Error, "CANNOT find the stored result with TIR"

    # Run the actual comparison
    my_comp.run_comparison(my_proc_list, model=model, energy=energy)

    # Print the output
    my_comp.output_result(filename=os.path.join(_mg5_path,filename+'.log'),\
                          tolerance = tolerance)

    # Assert that all process comparisons passed the tolerance cut
    my_comp.assert_processes(testInstance, tolerance)

    # Do some cleanup
    my_comp.cleanup()