LHCfitNikhef / smefit_release

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

Adding external likelihoods #61

Closed jacoterh closed 7 months ago

jacoterh commented 12 months ago

This PR adds functionality for the addition of external chi2-modules on top of the SMEFiT chi2. Please check the updated documentation for instructions.

LucaMantani commented 12 months ago

Do I understand correctly that the external chi2 will have to accept the WC in the same order and length of the ones in the runcard? This means that one would need to write a different external chi2 for different fits, e.g. if i change the number of operators I am fitting

jacoterh commented 12 months ago

Thanks Luca, good point, so perhaps it is more convenient to pass a dictionary to the external chi2 such that there is a clear mapping between operator name and corresponding value.

LucaMantani commented 12 months ago

Yes, I think that's a good idea. I think we need to find a smart way to have it such that one can call subsets of the WC defined in the external chi2 but also that it doesn't mess up if the external chi2 doesn't depend on some of the coeffs. For example,

def external_chi2(c1=0, c2=0, c3=0)

And we fit (c1, c2 and c4). It should understand that c3 is zero (that's why the default value) and should understand that c4 is only internal.

giacomomagni commented 12 months ago

Hi @jacoterh, as a suggestion, maybe here it would be helpful and easier to write also some unit test.

arossia94 commented 12 months ago

Hi @jacoterh @LucaMantani , regarding the order of the basis, I implemented a solution in my interface for the external likelihood of the optimal observables. My solution uses the knowledge of the basis that the external likelihood is written in, then reads the run card and constructs the mapping between one and the other automatically. You can see the code here: https://github.com/LHCfitNikhef/smefit_ewpo/blob/FCC_optimal/benchmarks/add_optimal_chi2/interface_oos.py I guess something like this could be generalized, allowing the user to specify the ordered basis of the external likelihood and then the function builds the mapping automatically.

codecov[bot] commented 11 months ago

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (d37742c) 42.88% compared to head (0721105) 43.24%. Report is 9 commits behind head on main.

:exclamation: Current head 0721105 differs from pull request most recent head 2033214. Consider uploading reports for the commit 2033214 to get more accurate results

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/LHCfitNikhef/smefit_release/pull/61/graphs/tree.svg?width=650&height=150&src=pr&token=MRTEXUP8XU&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef)](https://app.codecov.io/gh/LHCfitNikhef/smefit_release/pull/61?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef) ```diff @@ Coverage Diff @@ ## main #61 +/- ## ========================================== + Coverage 42.88% 43.24% +0.35% ========================================== Files 29 27 -2 Lines 2318 2234 -84 ========================================== - Hits 994 966 -28 + Misses 1324 1268 -56 ``` | [Flag](https://app.codecov.io/gh/LHCfitNikhef/smefit_release/pull/61/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/LHCfitNikhef/smefit_release/pull/61/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef) | `43.24% <45.00%> (+0.35%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/LHCfitNikhef/smefit_release/pull/61?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef) | Coverage Δ | | |---|---|---| | [src/smefit/analyze/pca.py](https://app.codecov.io/gh/LHCfitNikhef/smefit_release/pull/61?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef#diff-c3JjL3NtZWZpdC9hbmFseXplL3BjYS5weQ==) | `68.15% <ø> (ø)` | | | [src/smefit/chi2.py](https://app.codecov.io/gh/LHCfitNikhef/smefit_release/pull/61?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef#diff-c3JjL3NtZWZpdC9jaGkyLnB5) | `38.88% <100.00%> (ø)` | | | [src/smefit/fit\_manager.py](https://app.codecov.io/gh/LHCfitNikhef/smefit_release/pull/61?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef#diff-c3JjL3NtZWZpdC9maXRfbWFuYWdlci5weQ==) | `67.27% <ø> (ø)` | | | [src/smefit/loader.py](https://app.codecov.io/gh/LHCfitNikhef/smefit_release/pull/61?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef#diff-c3JjL3NtZWZpdC9sb2FkZXIucHk=) | `91.95% <100.00%> (ø)` | | | [src/smefit/optimize/mc.py](https://app.codecov.io/gh/LHCfitNikhef/smefit_release/pull/61?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef#diff-c3JjL3NtZWZpdC9vcHRpbWl6ZS9tYy5weQ==) | `53.06% <100.00%> (+0.97%)` | :arrow_up: | | [src/smefit/optimize/ultranest.py](https://app.codecov.io/gh/LHCfitNikhef/smefit_release/pull/61?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef#diff-c3JjL3NtZWZpdC9vcHRpbWl6ZS91bHRyYW5lc3QucHk=) | `62.74% <100.00%> (+0.74%)` | :arrow_up: | | [src/smefit/optimize/\_\_init\_\_.py](https://app.codecov.io/gh/LHCfitNikhef/smefit_release/pull/61?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef#diff-c3JjL3NtZWZpdC9vcHRpbWl6ZS9fX2luaXRfXy5weQ==) | `55.26% <31.25%> (-6.41%)` | :arrow_down: | ... and [4 files with indirect coverage changes](https://app.codecov.io/gh/LHCfitNikhef/smefit_release/pull/61/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LHCfitNikhef)