def theta_limit_madminer(xsec=0.001, lumi=1000000.0, effect_phys=0.1, effect_sys=0.1): # Set up MadMiner file miner = MadMiner() miner.add_parameter( lha_block="no one cares", lha_id=12345, parameter_name="theta", morphing_max_power=1, parameter_range=(-1.0, 1.0), ) miner.add_benchmark({"theta": 0.0}) miner.add_benchmark({"theta": 1.0}) miner.set_morphing(include_existing_benchmarks=True, max_overall_power=1) miner.save(".data.h5") # Set up observations proc = LHEProcessor(".data.h5") proc.add_observable("x", "no one cares") proc.reference_benchmark = "benchmark_0" proc.nuisance_parameters = OrderedDict() proc.nuisance_parameters["nu"] = ("benchmark_nuisance", None) proc.observations = OrderedDict() proc.observations["x"] = np.array([1.0]) proc.weights = OrderedDict() proc.weights["benchmark_0"] = np.array([xsec]) proc.weights["benchmark_1"] = np.array([xsec * (1.0 + effect_phys)]) proc.weights["benchmark_nuisance"] = np.array([xsec * (1.0 + effect_sys)]) proc.save(".data2.h5") # Calculate Fisher information fisher = FisherInformation(".data2.h5") info, cov = fisher.calculate_fisher_information_full_truth(theta=np.array( [0.0]), luminosity=lumi) constraint = fisher.calculate_fisher_information_nuisance_constraints() info = info + constraint profiled = profile_information(info, [0]) # Uncertainty on theta theta_limit = profiled[0, 0]**-0.5 # Remove file os.remove(".data.h5") os.remove(".data2.h5") return theta_limit
if "madminer" not in key: logging.getLogger(key).setLevel(logging.WARNING) # Please enter here the path to your MG5 root directory. This notebook assumes that you installed Delphes and Pythia through MG5. # In[3]: mg_dir = '/home/software/MG5_aMC_v2_6_2/' # ## 1. Generate events # Let's load our setup: # In[4]: miner = MadMiner() miner.load("data/setup.h5") # In a next step, MadMiner starts MadGraph and Pythia to generate events and calculate the weights. You can use `run()` or `run_multiple()`; the latter allows to generate different runs with different run cards and optimizing the phase space for different benchmark points. # # In either case, you have to provide paths to the process card, run card, param card (the entries corresponding to the parameters of interest will be automatically adapted), and an empty reweight card. Log files in the `log_directory` folder collect the MadGraph output and are important for debugging. # # The `sample_benchmark` (or in the case of `run_all`, `sample_benchmarks`) option can be used to specify which benchmark should be used for sampling, i.e. for which benchmark point the phase space is optimized. If you just use one benchmark, reweighting to far-away points in parameter space can lead to large event weights and thus large statistical fluctuations. It is therefore often a good idea to combine at least a few different benchmarks for this option. Here we use the SM and the benchmark "w" that we defined during the setup step. # # One slight annoyance is that MadGraph only supports Python 2. The `run()` and `run_multiple()` commands have a keyword `initial_command` that let you load a virtual environment in which `python` maps to Python 2 (which is what we do below). Alternatively / additionally you can set `python2_override=True`, which calls `python2.7` instead of `python` to start MadGraph. # In[5]: miner.run( sample_benchmark='sm', mg_directory=mg_dir,
# In[2]: # MadMiner output logging.basicConfig( format='%(asctime)-5.5s %(name)-20.20s %(levelname)-7.7s %(message)s', datefmt='%H:%M', level=logging.DEBUG) # Output of all other modules (e.g. matplotlib) for key in logging.Logger.manager.loggerDict: if "madminer" not in key: logging.getLogger(key).setLevel(logging.WARNING) mg_dir = '/home/llr/cms/cortinovis/EFT2Obs/MG5_aMC_v2_6_7' miner = MadMiner() miner.load("/data_CMS/cms/cortinovis/ewdim6/data_ew_1M_az/setup.h5") miner.run( sample_benchmark='sm', temp_directory='./', mg_directory=mg_dir, mg_process_directory= '/data_CMS/cms/cortinovis/ewdim6/mg_processes_ew_1M_az/signal_pythia', proc_card_file='cards/proc_card_signal.dat', param_card_template_file='cards/param_card_template.dat', pythia8_card_file='cards/pythia8_card.dat', run_card_file='cards/run_card_signal_large.dat', log_directory='/data_CMS/cms/cortinovis/ewdim6/logs_ew_1M_az/signal', initial_command="PYTHONPATH=/usr/lib64/python", python2_override=True,
#from matplotlib import pyplot as plt #%matplotlib inline import sys import yaml import inspect from madminer.core import MadMiner from madminer.plotting import plot_2d_morphing_basis from madminer.sampling import combine_and_shuffle from madminer.sampling import SampleAugmenter from madminer.sampling import benchmark, benchmarks from madminer.sampling import morphing_point, morphing_points, random_morphing_points mg_dir = '/madminer/software/MG5_aMC_v2_6_2' miner = MadMiner()#(debug=False) input_file = str(sys.argv[1]) print('inputfile: ',input_file) ########### ADD parameters and benchmarks from input file with open(input_file) as f: # use safe_load instead load dict_all = yaml.safe_load(f) #get default values of miner.add_parameters() default_arr = inspect.getargspec(miner.add_parameter) default = dict(zip(reversed(default_arr.args), reversed(default_arr.defaults)))
from madminer.core import MadMiner from madminer.plotting import plot_2d_morphing_basis from madminer.sampling import combine_and_shuffle from madminer.sampling import SampleAugmenter input_file = str(sys.argv[1]) with open(input_file) as f: dict_all = yaml.safe_load(f) njobs = int(sys.argv[2]) h5_file = str(sys.argv[3]) mg_dir = '/home/software/MG5_aMC_v2_6_2' miner = MadMiner() #(debug=False) miner.load(h5_file) ################################################################################## #signal benchmarks = [str(i) for i in miner.benchmarks] m = len(benchmarks) print('list of benchmarks', benchmarks) miner.run_multiple( only_prepare_script=True, #sample benchmarks from already stablished benchmarks in a democratic way sample_benchmarks=benchmarks[0:njobs % m] + benchmarks * int(
# Please enter here the path to your MG5 root directory. This notebook assumes that you installed Delphes and Pythia through MG5. # In[3]: mg_dir = '/home/software/MG5_aMC_v2_6_2/' # ## 1. Generate events # Let's load our setup: # In[4]: miner = MadMiner() miner.load("data/setup.h5") delphes = DelphesReader('data/setup.h5') # After creating the `DelphesReader` object, one can add a number of event samples (the output of running MadGraph and Pythia in step 1 above) with the `add_sample()` function. # # In addition, you have to provide the information which sample was generated from which benchmark with the `sampled_from_benchmark` keyword, and set `is_background=True` for all background samples. # careful to keep same order of benchmarks as in the simulation file benchmarks = ['sm', 'no-higgs','1.5pow4-higgs', '2pow4-higgs'] # Works up to 8 benchmarks assert len(benchmarks) < 9
mg_dir = '/home/llr/cms/cortinovis/EFT2Obs/MG5_aMC_v2_6_7' # Please enter here the path to your MG5 root directory. This notebook assumes that you installed Delphes and Pythia through MG5. # In[248]: # ## 1. Generate events # Let's load our setup: # In[250]: miner = MadMiner() miner.load("data_sme_hw_hbox/setup.h5") # In a next step, MadMiner starts MadGraph and Pythia to generate events and calculate the weights. You can use `run()` or `run_multiple()`; the latter allows to generate different runs with different run cards and optimizing the phase space for different benchmark points. # # In either case, you have to provide paths to the process card, run card, param card (the entries corresponding to the parameters of interest will be automatically adapted), and an empty reweight card. Log files in the `log_directory` folder collect the MadGraph output and are important for debugging. # # The `sample_benchmark` (or in the case of `run_all`, `sample_benchmarks`) option can be used to specify which benchmark should be used for sampling, i.e. for which benchmark point the phase space is optimized. If you just use one benchmark, reweighting to far-away points in parameter space can lead to large event weights and thus large statistical fluctuations. It is therefore often a good idea to combine at least a few different benchmarks for this option. Here we use the SM and the benchmark "w" that we defined during the setup step. # # One slight annoyance is that MadGraph only supports Python 2. The `run()` and `run_multiple()` commands have a keyword `initial_command` that let you load a virtual environment in which `python` maps to Python 2 (which is what we do below). Alternatively / additionally you can set `python2_override=True`, which calls `python2.7` instead of `python` to start MadGraph. # In[210]:
# Please enter here the path to your MG5 root directory. This notebook assumes that you installed Delphes and Pythia through MG5. # In[321]: mg_dir = '/home/llr/cms/cortinovis/EFT2Obs/MG5_aMC_v2_6_7' # ## 1. Generate events # Let's load our setup: # In[323]: miner = MadMiner() miner.load("/home/llr/cms/cortinovis/miner/madminer/examples/tutorial_particle_physics/data_hel_w_b/setup.h5") # In a next step, MadMiner starts MadGraph and Pythia to generate events and calculate the weights. You can use `run()` or `run_multiple()`; the latter allows to generate different runs with different run cards and optimizing the phase space for different benchmark points. # # In either case, you have to provide paths to the process card, run card, param card (the entries corresponding to the parameters of interest will be automatically adapted), and an empty reweight card. Log files in the `log_directory` folder collect the MadGraph output and are important for debugging. # # The `sample_benchmark` (or in the case of `run_all`, `sample_benchmarks`) option can be used to specify which benchmark should be used for sampling, i.e. for which benchmark point the phase space is optimized. If you just use one benchmark, reweighting to far-away points in parameter space can lead to large event weights and thus large statistical fluctuations. It is therefore often a good idea to combine at least a few different benchmarks for this option. Here we use the SM and the benchmark "w" that we defined during the setup step. # # One slight annoyance is that MadGraph only supports Python 2. The `run()` and `run_multiple()` commands have a keyword `initial_command` that let you load a virtual environment in which `python` maps to Python 2 (which is what we do below). Alternatively / additionally you can set `python2_override=True`, which calls `python2.7` instead of `python` to start MadGraph. # In[344]: additional_benchmarks = ['w', 'neg_w', 'ww', 'neg_ww']