HEP-PBSP / SIMUnet

The public code for SIMUnet, a NNPDF based tool to perform simultaneous determination of PDFs and EFT Wilson coefficients.
https://hep-pbsp.github.io/SIMUnet/
GNU General Public License v3.0
2 stars 2 forks source link

Analytic initialisation #41

Open J-M-Moore opened 10 months ago

J-M-Moore commented 10 months ago

This PR adds the option to initialise the simu parameters to their analytic minimum. Currently uses the analytic minimum of the chi2 evaluated on the experimental dataset, but allows for any user-defined PDF set to produce the predictions (which can be different from the fixed PDF used in a fixed PDF fit).

ElieHammou commented 10 months ago

It looks like if only one operator is used in the fit and the analytic initialisation is used, the code is not working. I get the error message

Traceback (most recent call last):
  File "/home/eh651/rds/hpc-work/miniconda3/envs/simunet/lib/python3.9/site-packages/tensorflow/python/framework/ops.py", line 1853, in _create_c_op
    c_op = pywrap_tf_session.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Index out of range using input dim 0; input has only 0 dims for '{{node combine_cfac_layer/strided_slice}} = StridedSlice[Index=DT_INT32, T=DT_FLOAT, begin_mask=1, ellipsis_mask=0, end_mask=1, new_axis_mask=2, shrink_axis_mask=0](combine_cfac_layer/ReadVariableOp, combine_cfac_layer/strided_slice/stack, combine_cfac_layer/strided_slice/stack_1, combine_cfac_layer/strided_slice/stack_2)' with input shapes: [], [2], [2], [2] and with computed input tensors: input[3] = <1 1>.

Things are fine if I run with a different initialisation.

J-M-Moore commented 10 months ago

It looks like if only one operator is used in the fit and the analytic initialisation is used, the code is not working. I get the error message

Traceback (most recent call last):
  File "/home/eh651/rds/hpc-work/miniconda3/envs/simunet/lib/python3.9/site-packages/tensorflow/python/framework/ops.py", line 1853, in _create_c_op
    c_op = pywrap_tf_session.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Index out of range using input dim 0; input has only 0 dims for '{{node combine_cfac_layer/strided_slice}} = StridedSlice[Index=DT_INT32, T=DT_FLOAT, begin_mask=1, ellipsis_mask=0, end_mask=1, new_axis_mask=2, shrink_axis_mask=0](combine_cfac_layer/ReadVariableOp, combine_cfac_layer/strided_slice/stack, combine_cfac_layer/strided_slice/stack_1, combine_cfac_layer/strided_slice/stack_2)' with input shapes: [], [2], [2], [2] and with computed input tensors: input[3] = <1 1>.

Things are fine if I run with a different initialisation.

Fixed now!

LucaMantani commented 10 months ago

@J-M-Moore I am getting a KeyError:

  File "/auto/home/users/l/m/lmantani/applications/SIMUnet/simunet_release/n3fit/src/n3fit/performfit.py", line 208, in performfit
    exp_data = exp_data.loc[groups_index]
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexing.py", line 1073, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexing.py", line 1301, in _getitem_axis
    return self._getitem_iterable(key, axis=axis)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexing.py", line 1239, in _getitem_iterable
    keyarr, indexer = self._get_listlike_indexer(key, axis)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexing.py", line 1432, in _get_listlike_indexer
    keyarr, indexer = ax._get_indexer_strict(key, axis_name)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexes/multi.py", line 2626, in _get_indexer_strict
    return super()._get_indexer_strict(key, axis_name)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 6070, in _get_indexer_strict
    self._raise_if_missing(keyarr, indexer, axis_name)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexes/multi.py", line 2646, in _raise_if_missing
    return super()._raise_if_missing(key, indexer, axis_name)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 6133, in _raise_if_missing
    raise KeyError(f"{not_found} not in index")
KeyError: "[('ATLAS', 'ATLAS_TTBAR_13TEV_HADRONIC_2D_TTM_ABSYTTNORM', 10), ('ATLAS', 'ATLAS_TTBAR_13TEV_TTMNORM', 8), ('ATLAS', 'ATLAS_TTBARZ_13TEV_PTZNORM', 5), ('CMS', 'CMS_TTB_DIFF_13TEV_2016_2L_TTMNORM', 5), ('CMS', 'CMS_TTBAR_13TEV_TTMNORM', 14), ('CMS', 'CMS_TTBARZ_13TEV_PTZNORM', 3)] not in index"

Do you know what is going on?

J-M-Moore commented 10 months ago

@J-M-Moore I am getting a KeyError:

  File "/auto/home/users/l/m/lmantani/applications/SIMUnet/simunet_release/n3fit/src/n3fit/performfit.py", line 208, in performfit
    exp_data = exp_data.loc[groups_index]
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexing.py", line 1073, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexing.py", line 1301, in _getitem_axis
    return self._getitem_iterable(key, axis=axis)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexing.py", line 1239, in _getitem_iterable
    keyarr, indexer = self._get_listlike_indexer(key, axis)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexing.py", line 1432, in _get_listlike_indexer
    keyarr, indexer = ax._get_indexer_strict(key, axis_name)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexes/multi.py", line 2626, in _get_indexer_strict
    return super()._get_indexer_strict(key, axis_name)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 6070, in _get_indexer_strict
    self._raise_if_missing(keyarr, indexer, axis_name)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexes/multi.py", line 2646, in _raise_if_missing
    return super()._raise_if_missing(key, indexer, axis_name)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 6133, in _raise_if_missing
    raise KeyError(f"{not_found} not in index")
KeyError: "[('ATLAS', 'ATLAS_TTBAR_13TEV_HADRONIC_2D_TTM_ABSYTTNORM', 10), ('ATLAS', 'ATLAS_TTBAR_13TEV_TTMNORM', 8), ('ATLAS', 'ATLAS_TTBARZ_13TEV_PTZNORM', 5), ('CMS', 'CMS_TTB_DIFF_13TEV_2016_2L_TTMNORM', 5), ('CMS', 'CMS_TTBAR_13TEV_TTMNORM', 14), ('CMS', 'CMS_TTBARZ_13TEV_PTZNORM', 3)] not in index"

Do you know what is going on?

I think it is to do with cuts, I will fix it

J-M-Moore commented 10 months ago

@J-M-Moore I am getting a KeyError:

  File "/auto/home/users/l/m/lmantani/applications/SIMUnet/simunet_release/n3fit/src/n3fit/performfit.py", line 208, in performfit
    exp_data = exp_data.loc[groups_index]
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexing.py", line 1073, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexing.py", line 1301, in _getitem_axis
    return self._getitem_iterable(key, axis=axis)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexing.py", line 1239, in _getitem_iterable
    keyarr, indexer = self._get_listlike_indexer(key, axis)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexing.py", line 1432, in _get_listlike_indexer
    keyarr, indexer = ax._get_indexer_strict(key, axis_name)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexes/multi.py", line 2626, in _get_indexer_strict
    return super()._get_indexer_strict(key, axis_name)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 6070, in _get_indexer_strict
    self._raise_if_missing(keyarr, indexer, axis_name)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexes/multi.py", line 2646, in _raise_if_missing
    return super()._raise_if_missing(key, indexer, axis_name)
  File "/home/ucl/cp3/lmantani/miniconda3/envs/simunet/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 6133, in _raise_if_missing
    raise KeyError(f"{not_found} not in index")
KeyError: "[('ATLAS', 'ATLAS_TTBAR_13TEV_HADRONIC_2D_TTM_ABSYTTNORM', 10), ('ATLAS', 'ATLAS_TTBAR_13TEV_TTMNORM', 8), ('ATLAS', 'ATLAS_TTBARZ_13TEV_PTZNORM', 5), ('CMS', 'CMS_TTB_DIFF_13TEV_2016_2L_TTMNORM', 5), ('CMS', 'CMS_TTBAR_13TEV_TTMNORM', 14), ('CMS', 'CMS_TTBARZ_13TEV_PTZNORM', 3)] not in index"

Do you know what is going on?

I think it is to do with cuts, I will fix it

It was to do with cuts, it is fixed now :)

comane commented 9 months ago

[ERROR]: Bad configuration encountered: A parameter is required: analytic_check. This is needed to process:

comane commented 9 months ago

I think it is important that we can still run a standard runcard on this branch without having to specify anything on analytic initialisation. So I think there should be some default values used when things like analytic_check are not specified

LucaMantani commented 9 months ago

Something is wrong with the scales, if they are different from 1.0, they affect both the initialisation and the final writing, making the automatic initialisation not usable.

LucaMantani commented 9 months ago

I pushed a small fix, in which the scales multiply the initialisation values, not divide. I think this was the source of the problem as now things seem to be working no matter the value of the scales.

If the values from the table are divided by the scale, the Wilson coefficient needs to be multiplied, so that the theoretical prediction given by c * lin = (c * scale) * (lin / scale) = c' * lin'

This was not introduced in this PR, when initialising in 0 we were not noticing the problem, other kind of initialisation were affected.