Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New ht thcovmat #2126

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open

New ht thcovmat #2126

wants to merge 48 commits into from

Conversation

achiefa
Copy link
Contributor

@achiefa achiefa commented Jul 15, 2024

This PR allows for the inclusion of theory uncertainties due to the effect of power corrections. The theory covariance matrix is constructed by computing the shifts for the theoretical predictions as done for the MHOUs. The shift is computed at the level of the structure functions. Then, the shifts for the structure functions are combined to reconstruct the shift for the xsec. For this reason, the calculation of the shift depends on the dataset. Currently, only 1-JET and DIS (NC and CC) are supported.

At the level of the runcard, power corrections are specified as follows

theorycovmatconfig:
  point_prescriptions: ["power corrections"]
  pc_parameters:
  - {ht: H2p, yshift: [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0], nodes: [0.0, 0.001, 0.01, 0.1, 0.3, 0.5, 0.7, 0.9, 1]}
  - {ht: H2d, yshift: [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0], nodes: [0.0, 0.001, 0.01, 0.1, 0.3, 0.5, 0.7, 0.9, 1]}
  - {ht: HLp, yshift: [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0], nodes: [0.0, 0.001, 0.01, 0.1, 0.3, 0.5, 0.7, 0.9, 1]}
  - {ht: HLd, yshift: [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0], nodes: [0.0, 0.001, 0.01, 0.1, 0.3, 0.5, 0.7, 0.9, 1]}
  - {ht: H3p, yshift: [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0], nodes: [0.0, 0.001, 0.01, 0.1, 0.3, 0.5, 0.7, 0.9, 1]}
  - {ht: H3d, yshift: [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.0], nodes: [0.0, 0.001, 0.01, 0.1, 0.3, 0.5, 0.7, 0.9, 1]}
  - {ht: Hj, yshift: [2.0, 2.0, 2.0, 2.0, 2.0, 2.0], nodes: [0.25, 0.75, 1.25, 1.75, 2.25, 2.75]}
  func_type: "linear" 
  pc_included_procs: ["JETS", "DIS NC", "DIS CC"]
  pc_excluded_exps: [HERA_NC_318GEV_EAVG_CHARM-SIGMARED,
                     HERA_NC_318GEV_EAVG_BOTTOM-SIGMARED]
  pdf: 240701-02-rs-nnpdf40-baseline
  use_thcovmat_in_fitting: true
  use_thcovmat_in_sampling: true

For each process/sf implemented, we need to specify a series of information:

  1. The name of the power correction, under the key ht. This is useful to identify the type of power correction, in particular when computing the posterior.
  2. The values in yshift are the magnitudes of the prior.
  3. nodes contains the points where the prior is shifted

The array pc_included_procs specifies the processes for which the shifts are computed. I've also implemented the possibility to exclude some particular datasets within the selected processes, and this can be done by specifying the names in pc_excluded_exps.

The key func_type is temporary and will be deleted once we decide which function to use to construct the prior.

All the relevant details for this PR are contained in the module higher_twist_functions.py. For each observable for which the shift has to be computed, I implemented a factory that constructs a function which will then compute the shift. I thought it was kind of necessary to make the shift dependent on the shift parameters (yshift and nodes) and on the prescription according to which we vary the parameters (which for now is fixed), and not on the kinematics (I think this is known as currying in computer science).

TO DO

  • Add documentation
  • Remove func_type
  • What happens if power_corrections is specified but the parameters are not given?
  • Change the name ht to name (?)
  • Something else?

@achiefa achiefa added the run-fit-bot Starts fit bot from a PR. label Jul 15, 2024
@achiefa achiefa requested a review from RoyStegeman July 15, 2024 10:11
@achiefa achiefa self-assigned this Jul 15, 2024
Copy link

Greetings from your nice fit 🤖 !
I have good news for you, I just finished my tasks:

Check the report carefully, and please buy me a ☕ , or better, a GPU 😉!

@scarlehoff scarlehoff marked this pull request as draft July 17, 2024 14:26
fktable_arr,
dataset_name,
boundary_condition=None,
operation_name="NULL",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keyword arguments (kwargs) you don't use at this level, you don't have to specify. That's what **kwargs is for.

This function is very similar to `compute_ht_parametrisation` in
validphys.theorycovariance.construction.py. However, the latter
accounts for shifts in the 5pt prescription. As of now, this function
is meant to work only for DIS NC data, using the ABMP16 result.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe reference Eq. 6 of https://arxiv.org/pdf/1701.05838

x = self.exp_kinematics['kin1']
y = self.exp_kinematics['kin3']
Q2 = self.exp_kinematics['kin2']
N2, NL = 1#compute_normalisation_by_experiment(self.dataname, x, y, Q2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this function? Also I think you can do N2=NL=1, but not NL,N2=1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DIS.py is not in sync with the new way shifts are computed. Hence, that function that adds the shift in the theory predictions can be removed. I'll work on that later on, as we discussed. I should have deleted them.

Comment on lines 166 to 169
if (sam_t0 := file_content.get('sampling')) is not None:
SETUPFIT_FIXED_CONFIG['separate_multiplicative'] = sam_t0.get(
'separate_multiplicative', False
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember why I implemented that...I think I can remove it

Comment on lines 177 to 178
# NOTE: from the perspective of the fit scalevar and ht uncertainties are the same since
# they are saved under the same name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, we may want to start thinking of a long term solution as well. A tree of if-statments that grows exponentially for each source of theory uncertainty (scales, alphas, HT) is not super nice

Comment on lines +244 to 243
# NOTE: Same a `groups_data_by_process` in `construction.py`
procs_data = collect("data", ("group_dataset_inputs_by_process",))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to delete one (in master)

@achiefa achiefa force-pushed the new_ht_thcovmat branch 2 times, most recently from 28662e8 to 6b71fae Compare October 11, 2024 22:16
@achiefa achiefa force-pushed the new_ht_thcovmat branch 2 times, most recently from 348be41 to 9ac473c Compare January 14, 2025 14:06
@achiefa
Copy link
Contributor Author

achiefa commented Jan 14, 2025

Hi @roy, I've updated the code so that now the covmat for power corrections can be constructed as in the case of scale variations. Please, look and let me know if something is unclear. I'd like if you could double-check the functions that compute the shifts, in particular when normalisation factors and conversion factors are used.

There are few things that I still don't like here and there, but you're free to propose modifications.

@achiefa achiefa added run-fit-bot Starts fit bot from a PR. and removed run-fit-bot Starts fit bot from a PR. labels Jan 14, 2025
@@ -47,11 +49,11 @@ def theory_covmat_dataset(results, results_central_bytheoryids, point_prescripti
return thcovmat


ProcessInfo = namedtuple("ProcessInfo", ("preds", "namelist", "sizes"))
ProcessInfo = namedtuple("ProcessInfo", ("preds", "namelist", "sizes", "data", "data_spec"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included another key in the namedtuple containing the information that I need to compute the shifts for the power corrections. I'm not sure this is the best solution though.

return s


@check_correct_theory_combination
def covs_pt_prescrip(combine_by_type, point_prescription):
def covs_pt_prescrip(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add additional dependencies here for the power correction case. I don't know if there is a clever solution, maybe extracting these quantities from the context?

@achiefa achiefa removed the run-fit-bot Starts fit bot from a PR. label Jan 14, 2025
point_prescription,
pdf: PDF,
power_corr_dict,
pc_included_prosc,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the tests fail because there is not default for pc_included_procs (typo) and pc_excluded_exps. What do you suggest to do? Should I add two functions in config.py that default these two values when not specified in the runcard?

Copy link

Greetings from your nice fit 🤖 !
I have good news for you, I just finished my tasks:

Check the report carefully, and please buy me a ☕ , or better, a GPU 😉!

@achiefa achiefa marked this pull request as ready for review January 30, 2025 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants