Exemplo n.º 1
0
 def _load_likelihoods(self,
                       include_likelihoods=None,
                       exclude_likelihoods=None):
     if include_likelihoods is not None and exclude_likelihoods is not None:
         raise ValueError("include_likelihoods and exclude_likelihoods "
                          "should not be specified simultaneously.")
     for fn in self._fast_likelihoods_yaml:
         if include_likelihoods is not None and fn not in include_likelihoods:
             continue
         if exclude_likelihoods is not None and fn in exclude_likelihoods:
             continue
         with open(self._get_likelihood_path(fn), 'r') as f:
             L = FastLikelihood.load(f)
         self.fast_likelihoods[fn] = L
     for fn in self._likelihoods_yaml:
         if include_likelihoods is not None and fn not in include_likelihoods:
             continue
         if exclude_likelihoods is not None and fn in exclude_likelihoods:
             continue
         if self.eft != 'SMEFT' and fn in ['likelihood_ewpt.yaml',
                                           'likelihood_zlfv.yaml',]:
             continue
         with open(self._get_likelihood_path(fn), 'r') as f:
             L = Likelihood.load(f)
         self.likelihoods[fn] = L
     for name, observables in self._custom_likelihoods_dict.items():
         L = CustomLikelihood(self, observables)
         self.custom_likelihoods['custom_' + name] = L
Exemplo n.º 2
0
 def _load_likelihoods(self,
                       include_likelihoods=None,
                       exclude_likelihoods=None):
     if include_likelihoods is not None and exclude_likelihoods is not None:
         raise ValueError("include_likelihoods and exclude_likelihoods "
                          "should not be specified simultaneously.")
     for argument_name, argument in [
         ('exclude_likelihoods', exclude_likelihoods),
         ('include_likelihoods', include_likelihoods)
     ]:
         if argument:
             unknown_likelihoods = set(argument) - set(
                 self._fast_likelihoods_yaml + self._likelihoods_yaml)
             if unknown_likelihoods:
                 raise ValueError(
                     "{} contains unknown likelihoods: {}".format(
                         argument_name, unknown_likelihoods))
     # load ckm parameters for given CKM scheme
     par_ckm_file = 'par_ckm_{}.yaml'.format(self._ckm_scheme_name)
     with open(self._get_yaml_path(par_ckm_file), 'r') as f:
         par_ckm_dict = flavio.io.yaml.load_include(f)
     for fn in self._fast_likelihoods_yaml:
         if include_likelihoods is not None and fn not in include_likelihoods:
             continue
         if exclude_likelihoods is not None and fn in exclude_likelihoods:
             continue
         with open(self._get_yaml_path(fn), 'r') as f:
             yaml_dict = flavio.io.yaml.load_include(f)
             if not self.fix_ckm:
                 yaml_dict['par_obj'] = par_ckm_dict
             L = FastLikelihood.load_dict(yaml_dict)
         self.fast_likelihoods[fn] = L
     for fn in self._likelihoods_yaml:
         if include_likelihoods is not None and fn not in include_likelihoods:
             continue
         if exclude_likelihoods is not None and fn in exclude_likelihoods:
             continue
         if self.eft != 'SMEFT' and fn in [
                 'likelihood_ewpt.yaml',
                 'likelihood_eeww.yaml',
                 'likelihood_zlfv.yaml',
                 'likelihood_higgs.yaml',
         ]:
             continue
         with open(self._get_yaml_path(fn), 'r') as f:
             L = Likelihood.load(f)
         self.likelihoods[fn] = L
     for name, observables in self._custom_likelihoods_dict.items():
         L = CustomLikelihood(self, observables)
         self.custom_likelihoods['custom_' + name] = L
Exemplo n.º 3
0
 def _load_likelihoods(self,
                       include_likelihoods=None,
                       exclude_likelihoods=None):
     if include_likelihoods is not None and exclude_likelihoods is not None:
         raise ValueError("include_likelihoods and exclude_likelihoods "
                          "should not be specified simultaneously.")
     for fn in [
             'fast_likelihood_quarks.yaml', 'fast_likelihood_leptons.yaml'
     ]:
         if include_likelihoods is not None and fn not in include_likelihoods:
             continue
         if exclude_likelihoods is not None and fn in exclude_likelihoods:
             continue
         with open(get_datapath('smelli', 'data/yaml/' + fn), 'r') as f:
             L = FastLikelihood.load(f)
         self.fast_likelihoods[fn] = L
     for fn in [
             'likelihood_ewpt.yaml',
             'likelihood_lept.yaml',
             'likelihood_rd_rds.yaml',
             'likelihood_lfu_fccc.yaml',
             'likelihood_lfu_fcnc.yaml',
             'likelihood_bcpv.yaml',
             'likelihood_bqnunu.yaml',
             'likelihood_lfv.yaml',
             'likelihood_zlfv.yaml',
     ]:
         if include_likelihoods is not None and fn not in include_likelihoods:
             continue
         if exclude_likelihoods is not None and fn in exclude_likelihoods:
             continue
         if self.eft != 'SMEFT' and fn in [
                 'likelihood_ewpt.yaml',
                 'likelihood_zlfv.yaml',
         ]:
             continue
         with open(get_datapath('smelli', 'data/yaml/' + fn), 'r') as f:
             L = Likelihood.load(f)
         self.likelihoods[fn] = L
Exemplo n.º 4
0
    for errscen in ['stat', 'stat+sys']:
        for npscen in ['Scenario I', 'Scenario II', 'SM']:
            for exp in ['LHCb', 'CMS', 'ATLAS']:
                np_measurement(
                    'Projection {} {} {} {}'.format(exp, phase, errscen,
                                                    npscen),
                    w=npscenarios[npscen],
                    observables=observables[' '.join([exp, phase])],
                    covariance=covariances[' '.join([exp, phase, errscen])])

            likelihoods[' '.join([phase, errscen, npscen])] = FastLikelihood(
                'Likelihood LHC {} {} {}'.format(phase, errscen, npscen),
                observables=list(
                    set(observables['LHCb {}'.format(phase)] +
                        observables['CMS {}'.format(phase)] +
                        observables['ATLAS {}'.format(phase)])),
                include_measurements=[
                    'Projection LHCb {} {} {}'.format(phase, errscen, npscen),
                    'Projection CMS {} {} {}'.format(phase, errscen, npscen),
                    'Projection ATLAS {} {} {}'.format(phase, errscen, npscen),
                ])

if __name__ == '__main__':

    if os.path.exists(SMCOV):
        logging.info("Found existing covariance file; using that.")
        with open(SMCOV, 'rb') as f:
            smcov = pickle.load(f)
    else:
        logging.info("Computing covariance ...")
        smcov = compute_sm_covariance(N=N, threads=THREADS)
Exemplo n.º 5
0
 def _load_likelihoods(self,
                       include_likelihoods=None,
                       exclude_likelihoods=None):
     if include_likelihoods is not None and exclude_likelihoods is not None:
         raise ValueError("include_likelihoods and exclude_likelihoods "
                          "should not be specified simultaneously.")
     for argument_name, argument in [
         ('exclude_likelihoods', exclude_likelihoods),
         ('include_likelihoods', include_likelihoods)
     ]:
         if argument:
             unknown_likelihoods = set(argument) - set(
                 self._fast_likelihoods_yaml + self._likelihoods_yaml)
             if unknown_likelihoods:
                 raise ValueError(
                     "{} contains unknown likelihoods: {}".format(
                         argument_name, unknown_likelihoods))
     # load ckm parameters for given CKM scheme
     par_ckm_file = 'par_ckm_{}.yaml'.format(self._ckm_scheme_name)
     with open(self._get_yaml_path(par_ckm_file), 'r') as f:
         par_ckm_dict = flavio.io.yaml.load_include(f)
     for fn in self._fast_likelihoods_yaml:
         if include_likelihoods is not None and fn not in include_likelihoods:
             continue
         if exclude_likelihoods is not None and fn in exclude_likelihoods:
             continue
         with open(self._get_yaml_path(fn), 'r') as f:
             yaml_dict = flavio.io.yaml.load_include(f)
             if not self.fix_ckm:
                 yaml_dict['par_obj'] = par_ckm_dict
             try:
                 L = FastLikelihood.load_dict(yaml_dict)
                 meas_yaml = set(yaml_dict['include_measurements'])
                 meas_loaded = set(
                     L.full_measurement_likelihood.get_measurements)
                 meas_missing = meas_yaml - meas_loaded
             except AssertionError as e:
                 to_upgrade = 'smelli' if _flavio_up_to_date else 'flavio'
                 raise AssertionError(
                     '{}. Please upgrade {} to the latest version.'.format(
                         e, to_upgrade))
             if meas_missing:
                 to_upgrade = 'smelli' if _flavio_up_to_date else 'flavio'
                 raise AssertionError(
                     'The measurements {} have not been found. Please upgrade {} to the latest version.'
                     .format(meas_missing, to_upgrade))
         self.fast_likelihoods[fn] = L
     for fn in self._likelihoods_yaml:
         if include_likelihoods is not None and fn not in include_likelihoods:
             continue
         if exclude_likelihoods is not None and fn in exclude_likelihoods:
             continue
         if self.eft != 'SMEFT' and fn in [
                 'likelihood_ewpt.yaml',
                 'likelihood_eeww.yaml',
                 'likelihood_zlfv.yaml',
                 'likelihood_higgs.yaml',
         ]:
             continue
         with open(self._get_yaml_path(fn), 'r') as f:
             yaml_dict = flavio.io.yaml.load_include(f)
             try:
                 L = Likelihood.load_dict(yaml_dict)
                 meas_yaml = set(yaml_dict['include_measurements'])
                 meas_loaded = set(
                     L.measurement_likelihood.get_measurements)
                 meas_missing = meas_yaml - meas_loaded
             except AssertionError as e:
                 to_upgrade = 'smelli' if _flavio_up_to_date else 'flavio'
                 raise AssertionError(
                     '{}. Please upgrade {} to the latest version.'.format(
                         e, to_upgrade))
             if meas_missing:
                 to_upgrade = 'smelli' if _flavio_up_to_date else 'flavio'
                 raise AssertionError(
                     'The measurements {} have not been found. Please upgrade {} to the latest version.'
                     .format(meas_missing, to_upgrade))
         self.likelihoods[fn] = L
     for name, observables in self._custom_likelihoods_dict.items():
         L = CustomLikelihood(self, observables)
         self.custom_likelihoods['custom_' + name] = L