LHCfitNikhef / smefit_release

SMEFiT a Standard Model Effective Field Theory fitter
GNU General Public License v3.0
6 stars 1 forks source link

Bug in loader when running a fit in a different basis for a reduced set of coefficients #54

Closed tgiani closed 1 year ago

tgiani commented 1 year ago

When running a fit in a basis different from warsaw, like in the case of ATLAS, if commenting out one (or more) of the coefficients in the runcards the code crashes when computing the theory prediction

Traceback (most recent call last):
  File "/Users/tommy/miniconda3-intel/envs/smefit_ultranest/bin/smefit", line 6, in <module>
    sys.exit(base_command())
  File "/Users/tommy/miniconda3-intel/envs/smefit_ultranest/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/tommy/miniconda3-intel/envs/smefit_ultranest/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/tommy/miniconda3-intel/envs/smefit_ultranest/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/tommy/miniconda3-intel/envs/smefit_ultranest/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/tommy/miniconda3-intel/envs/smefit_ultranest/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/tommy/physics/smefit_release/src/smefit/cli/__init__.py", line 81, in nested_sampling
    runner.run_analysis("NS")
  File "/Users/tommy/physics/smefit_release/src/smefit/runner.py", line 219, in run_analysis
    self.global_analysis(optimizer)
  File "/Users/tommy/physics/smefit_release/src/smefit/runner.py", line 160, in global_analysis
    self.ultranest(config)
  File "/Users/tommy/physics/smefit_release/src/smefit/runner.py", line 131, in ultranest
    opt.run_sampling()
  File "/Users/tommy/physics/smefit_release/src/smefit/optimize/ultranest.py", line 243, in run_sampling
    sampler = ultranest.ReactiveNestedSampler(
  File "/Users/tommy/miniconda3-intel/envs/smefit_ultranest/lib/python3.10/site-packages/ultranest/integrator.py", line 1196, in __init__
    if not self._check_likelihood_function(transform, loglike, num_test_samples):
  File "/Users/tommy/miniconda3-intel/envs/smefit_ultranest/lib/python3.10/site-packages/ultranest/integrator.py", line 1258, in _check_likelihood_function
    logl = loglike(p)
  File "/Users/tommy/miniconda3-intel/envs/smefit_ultranest/lib/python3.10/site-packages/ultranest/utils.py", line 134, in vectorized
    return np.asarray([function(arg) for arg in args])
  File "/Users/tommy/miniconda3-intel/envs/smefit_ultranest/lib/python3.10/site-packages/ultranest/utils.py", line 134, in <listcomp>
    return np.asarray([function(arg) for arg in args])
  File "/Users/tommy/physics/smefit_release/src/smefit/optimize/ultranest.py", line 215, in gaussian_loglikelihood
    return -0.5 * self.chi2_func_ns(hypercube)
  File "/Users/tommy/physics/smefit_release/src/smefit/optimize/ultranest.py", line 198, in chi2_func_ns
    return self.chi2_func()
  File "/Users/tommy/physics/smefit_release/src/smefit/optimize/__init__.py", line 98, in chi2_func
    chi2_tot = chi2.compute_chi2(
  File "/Users/tommy/physics/smefit_release/src/smefit/chi2.py", line 46, in compute_chi2
    theory_predictions = pr.make_predictions(
  File "/Users/tommy/physics/smefit_release/src/smefit/compute_theory.py", line 48, in make_predictions
    summed_corrections = np.einsum(
  File "<__array_function__ internals>", line 200, in einsum
  File "/Users/tommy/miniconda3-intel/envs/smefit_ultranest/lib/python3.10/site-packages/numpy/core/einsumfunc.py", line 1371, in einsum
    return c_einsum(*operands, **kwargs)
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (130,28)->(130,28) (27,)->(27) 

I think this is due to the fact that when running fits in different basis Loader does not keep into account the coefficients specified in the runcard, and assumes that all of them should be considered in the analisys. In the case of a fit in the warsaw basis this does not happen thanks to the function is_to_keep, which should then be used to fix this problem