cms-analysis / HiggsAnalysis-CombinedLimit

CMS Higgs Combination toolkit.
https://cms-analysis.github.io/HiggsAnalysis-CombinedLimit/latest
Apache License 2.0
75 stars 389 forks source link

Fix #884, remove code repetition in ProcessNormalization and AsymPow #989

Open pitkajuh opened 4 months ago

pitkajuh commented 4 months ago

Dear All. This PR fixes #884. Unfortunately I could not figure out a proper place for new logKappa function, so I created a new file for it. If there is a better place for it, please do not hesitate to tell me.

The code compiles without any problems but some test fail after running pytest via conda in test/ directory:

========================================================================== test session starts ==========================================================================
platform linux -- Python 3.8.0, pytest-8.2.2, pluggy-1.5.0
rootdir: /home/pitkajuh/bin/HiggsAnalysis/CombinedLimit/test
plugins: anyio-4.4.0
collected 0 items / 8 errors

================================================================================ ERRORS =================================================================================
________________________________________________________________ ERROR collecting validation/test_AS.py _________________________________________________________________
validation/test_AS.py:13: in <module>
    datacardGlob("simple-counting/counting-B5p5-Obs[16]*.txt"),
validation/TestClasses.py:439: in datacardGlob
    base = os.environ["CMSSW_BASE"] + "/src/HiggsAnalysis/CombinedLimit/data/benchmarks/"
../../../../anaconda3/envs/combine/lib/python3.8/os.py:673: in __getitem__
    raise KeyError(key) from None
E   KeyError: 'CMSSW_BASE'
________________________________________________________________ ERROR collecting validation/test_BS.py _________________________________________________________________
validation/test_BS.py:13: in <module>
    datacardGlob("simple-counting/counting-B5p5-Obs[16]*.txt"),
validation/TestClasses.py:439: in datacardGlob
    base = os.environ["CMSSW_BASE"] + "/src/HiggsAnalysis/CombinedLimit/data/benchmarks/"
../../../../anaconda3/envs/combine/lib/python3.8/os.py:673: in __getitem__
    raise KeyError(key) from None
E   KeyError: 'CMSSW_BASE'
________________________________________________________________ ERROR collecting validation/test_BT.py _________________________________________________________________
validation/test_BT.py:15: in <module>
    datacardGlob("simple-counting/counting-B5p5-Obs[16]*.txt"),
validation/TestClasses.py:439: in datacardGlob
    base = os.environ["CMSSW_BASE"] + "/src/HiggsAnalysis/CombinedLimit/data/benchmarks/"
../../../../anaconda3/envs/combine/lib/python3.8/os.py:673: in __getitem__
    raise KeyError(key) from None
E   KeyError: 'CMSSW_BASE'
________________________________________________________________ ERROR collecting validation/test_FC.py _________________________________________________________________
validation/test_FC.py:13: in <module>
    datacardGlob("simple-counting/counting-B5p5-Obs[16]*-Syst30U.txt"),
validation/TestClasses.py:439: in datacardGlob
    base = os.environ["CMSSW_BASE"] + "/src/HiggsAnalysis/CombinedLimit/data/benchmarks/"
../../../../anaconda3/envs/combine/lib/python3.8/os.py:673: in __getitem__
    raise KeyError(key) from None
E   KeyError: 'CMSSW_BASE'
________________________________________________________________ ERROR collecting validation/test_HN.py _________________________________________________________________
validation/test_HN.py:261: in <module>
    datacardGlob("simple-counting/counting-B5p5-Obs[16]*-S*[Uy].txt"),
validation/TestClasses.py:439: in datacardGlob
    base = os.environ["CMSSW_BASE"] + "/src/HiggsAnalysis/CombinedLimit/data/benchmarks/"
../../../../anaconda3/envs/combine/lib/python3.8/os.py:673: in __getitem__
    raise KeyError(key) from None
E   KeyError: 'CMSSW_BASE'
_______________________________________________________________ ERROR collecting validation/test_MCMC.py ________________________________________________________________
validation/test_MCMC.py:13: in <module>
    datacardGlob("simple-counting/counting-B5p5-Obs6*.txt"),
validation/TestClasses.py:439: in datacardGlob
    base = os.environ["CMSSW_BASE"] + "/src/HiggsAnalysis/CombinedLimit/data/benchmarks/"
../../../../anaconda3/envs/combine/lib/python3.8/os.py:673: in __getitem__
    raise KeyError(key) from None
E   KeyError: 'CMSSW_BASE'
________________________________________________________________ ERROR collecting validation/test_PLC.py ________________________________________________________________
validation/test_PLC.py:13: in <module>
    datacardGlob("simple-counting/counting-B5p5-Obs[16]*.txt"),
validation/TestClasses.py:439: in datacardGlob
    base = os.environ["CMSSW_BASE"] + "/src/HiggsAnalysis/CombinedLimit/data/benchmarks/"
../../../../anaconda3/envs/combine/lib/python3.8/os.py:673: in __getitem__
    raise KeyError(key) from None
E   KeyError: 'CMSSW_BASE'
________________________________________________________________ ERROR collecting validation/test_htt.py ________________________________________________________________
validation/test_htt.py:17: in <module>
    datacardGlob("htt/125/htt_*_8TeV.txt"),
validation/TestClasses.py:439: in datacardGlob
    base = os.environ["CMSSW_BASE"] + "/src/HiggsAnalysis/CombinedLimit/data/benchmarks/"
../../../../anaconda3/envs/combine/lib/python3.8/os.py:673: in __getitem__
    raise KeyError(key) from None
E   KeyError: 'CMSSW_BASE'
======================================================================== short test summary info ========================================================================
ERROR validation/test_AS.py - KeyError: 'CMSSW_BASE'
ERROR validation/test_BS.py - KeyError: 'CMSSW_BASE'
ERROR validation/test_BT.py - KeyError: 'CMSSW_BASE'
ERROR validation/test_FC.py - KeyError: 'CMSSW_BASE'
ERROR validation/test_HN.py - KeyError: 'CMSSW_BASE'
ERROR validation/test_MCMC.py - KeyError: 'CMSSW_BASE'
ERROR validation/test_PLC.py - KeyError: 'CMSSW_BASE'
ERROR validation/test_htt.py - KeyError: 'CMSSW_BASE'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 8 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================================== 8 errors in 24.11s ===========================================================================

I am not sure if these errors have anything to do with the edits I made. I ran the tests by executing pytest command in test/ directory. I don't know if this is the proper way to run the tests. I did not find any information how to run tests. Can anyone provide any insight on this?

pitkajuh commented 4 months ago

It seems that the files I edited had unnecessary white spaces. My text editor automatically removes them. Is this ok?

guitargeek commented 4 months ago

Very nice initiative!

About the place to put your function: I would create a new file to collect these free math functions, just like we do in RooFit: https://github.com/root-project/root/blob/master/roofit/roofitcore/inc/RooFit/Detail/MathFuncs.h#L86

Mabye CombineMathFuncs.h. Then we can also put other repeated code there.

@adewit, what do you think?

guitargeek commented 3 days ago

@pitkajuh, you can close this PR, and alternative PR has been merged. Thanks for the initial work!