Skip to content

Commit

Permalink
Fix unittests and deprecated warning in analysesCombinations
Browse files Browse the repository at this point in the history
  • Loading branch information
andlessa committed Jan 17, 2024
1 parent ac2ea09 commit 0725a3f
Show file tree
Hide file tree
Showing 5 changed files with 278 additions and 5 deletions.
6 changes: 5 additions & 1 deletion smodels/statistics/analysesCombinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ def lmax(
def fun(mu):
# Make sure to always compute the correct llhd value (from theoryPrediction)
# and not used the cached value (which is constant for mu~=1 an mu~=0)
return self.likelihood(float(mu), expected=expected, return_nll=True, useCached=False)
if isinstance(mu,np.ndarray):
x = float(mu[0])
else:
x = float(mu)
return self.likelihood(x, expected=expected, return_nll=True, useCached=False)

if allowNegativeSignals:
toTry += [1.0, 0.0, 3.0, -1.0, 10.0, -3.0, 0.1, -0.1]
Expand Down
52 changes: 51 additions & 1 deletion unittests/T6bbHH_pyhf_default.py
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
smodelsOutputDefault = {'OutputStatus': {'sigmacut': 0.03, 'minmassgap': 5.0, 'maxcond': 0.2, 'ncpus': -1, 'model': 'share.models.mssm', 'checkinput': True, 'doinvisible': True, 'docompress': True, 'computestatistics': False, 'testcoverage': True, 'combinesrs': True, 'file status': 1, 'decomposition status': 1, 'warnings': 'Input file ok', 'input file': './testFiles/slha/T6bbHH_pyhf.slha', 'database version': 'unittest211', 'smodels version': '2.2.0'}, 'ExptRes': [{'maxcond': 0.0, 'theory prediction (fb)': 0.10091, 'upper limit (fb)': 0.08247307, 'expected upper limit (fb)': 0.1200876, 'TxNames': ['T6bbHH'], 'Mass (GeV)': [[1400.0, 1000.0, 60.0], [1400.0, 1000.0, 60.0]], 'AnalysisID': 'ATLAS-SUSY-2018-31', 'DataSetID': '(combined)', 'AnalysisSqrts (TeV)': 13.0, 'lumi (fb-1)': 139.0, 'dataType': 'combined', 'r': 1.223551, 'r_expected': 0.8403036, 'Width (GeV)': [['prompt', 'prompt', 'stable'], ['prompt', 'prompt', 'stable']], 'likelihood': 4.972371e-23, 'l_max': 9.723844e-22, 'l_SM': 9.723844e-22}], 'Total xsec for missing topologies (fb)': 0.0, 'missing topologies': [], 'Total xsec for missing topologies with displaced decays (fb)': 0.0, 'missing topologies with displaced decays': [], 'Total xsec for missing topologies with prompt decays (fb)': 0.0, 'missing topologies with prompt decays': [], 'Total xsec for topologies outside the grid (fb)': 0.0, 'topologies outside the grid': []}
smodelsOutputDefault = {
'OutputStatus' : {
'sigmacut' : 0.03,
'minmassgap' : 5.0,
'maxcond' : 0.2,
'ncpus' : -1,
'model' : 'share.models.mssm',
'checkinput' : True,
'doinvisible' : True,
'docompress' : True,
'computestatistics' : False,
'testcoverage' : True,
'combinesrs' : True,
'file status' : 1,
'decomposition status' : 1,
'warnings' : 'Input file ok',
'input file' : './testFiles/slha/T6bbHH_pyhf.slha',
'database version' : 'unittest211',
'smodels version' : '2.2.0'
},
'ExptRes' : [
{
'maxcond' : 0.0,
'theory prediction (fb)' : 0.10091,
'upper limit (fb)' : 0.08247307,
'expected upper limit (fb)' : 0.1200876,
'TxNames' : ['T6bbHH'],
'Mass (GeV)' : [[1400.0, 1000.0, 60.0], [1400.0, 1000.0, 60.0]],
'AnalysisID' : 'ATLAS-SUSY-2018-31',
'DataSetID' : '(combined)',
'AnalysisSqrts (TeV)' : 13.0,
'lumi (fb-1)' : 139.0,
'dataType' : 'combined',
'r' : 1.223551,
'r_expected' : 0.8403036,
'Width (GeV)' : [[1.0, 1.0, 'stable'], [1.0, 1.0, 'stable']],
'likelihood' : 4.972371e-23,
'l_max' : 9.723844e-22,
'l_SM' : 9.723844e-22
}
],
'Total xsec for missing topologies (fb)' : 0.0,
'missing topologies' : [],
'Total xsec for missing topologies with displaced decays (fb)' : 0.0,
'missing topologies with displaced decays' : [],
'Total xsec for missing topologies with prompt decays (fb)' : 0.0,
'missing topologies with prompt decays' : [],
'Total xsec for topologies outside the grid (fb)' : 0.0,
'topologies outside the grid' : []
}

129 changes: 128 additions & 1 deletion unittests/longLived_default.py
Original file line number Diff line number Diff line change
@@ -1 +1,128 @@
smodelsOutputDefault = {'OutputStatus': {'sigmacut': 0.03, 'minmassgap': 5.0, 'maxcond': 0.2, 'ncpus': -6, 'model': 'share.models.mssm', 'checkinput': True, 'doinvisible': True, 'docompress': True, 'computestatistics': False, 'testcoverage': True, 'combineanas': 'CMS-SUS-13-012,ATLAS-SUSY-2018-31,ATLAS-CONF-2013-037', 'file status': 1, 'decomposition status': 1, 'warnings': 'Input file ok', 'input file': './testFiles/slha/longLived.slha', 'database version': 'unittest211', 'smodels version': '2.2.0'}, 'ExptRes': [{'maxcond': 0.0, 'theory prediction (fb)': 0.1335974, 'upper limit (fb)': 0.16, 'expected upper limit (fb)': 0.16, 'TxNames': ['THSCPM1', 'THSCPM2'], 'Mass (GeV)': None, 'AnalysisID': 'CMS-EXO-13-006', 'DataSetID': 'c200track', 'AnalysisSqrts (TeV)': 8.0, 'lumi (fb-1)': 18.8, 'dataType': 'efficiencyMap', 'r': 0.8349838, 'r_expected': 0.8349838, 'Width (GeV)': None, 'likelihood': 0.1680834, 'l_max': 2.071631, 'l_SM': 2.071631}, {'maxcond': 0.0, 'theory prediction (fb)': 0.003205744, 'upper limit (fb)': 0.4, 'expected upper limit (fb)': 0.35, 'TxNames': ['T2tt'], 'Mass (GeV)': [[1061.5, 351.7], [1061.5, 351.7]], 'AnalysisID': 'ATLAS-CONF-2013-037', 'DataSetID': 'SRtN3', 'AnalysisSqrts (TeV)': 8.0, 'lumi (fb-1)': 20.7, 'dataType': 'efficiencyMap', 'r': 0.008014361, 'r_expected': 0.00915927, 'Width (GeV)': [['prompt', 'stable'], ['prompt', 'stable']], 'likelihood': 0.02475033, 'l_max': 0.02972175, 'l_SM': 0.02442398}], 'Total xsec for missing topologies (fb)': 0.6027619, 'missing topologies': [{'sqrts (TeV)': 8.0, 'weight (fb)': 0.3356614, 'element': '[[[l]],[[l]]] (MET,MET)'}, {'sqrts (TeV)': 8.0, 'weight (fb)': 0.2016084, 'element': '[[],[[l]]] (MET,MET)'}, {'sqrts (TeV)': 8.0, 'weight (fb)': 0.03292622, 'element': '[[],[[jet]]] (MET,MET)'}, {'sqrts (TeV)': 8.0, 'weight (fb)': 0.03256586, 'element': '[[],[]] (MET,MET)'}], 'Total xsec for missing topologies with displaced decays (fb)': 0.0, 'missing topologies with displaced decays': [], 'Total xsec for missing topologies with prompt decays (fb)': 0.6027619, 'missing topologies with prompt decays': [{'sqrts (TeV)': 8.0, 'weight (fb)': 0.3356614, 'element': '[[[l]],[[l]]] (MET,MET)'}, {'sqrts (TeV)': 8.0, 'weight (fb)': 0.2016084, 'element': '[[],[[l]]] (MET,MET)'}, {'sqrts (TeV)': 8.0, 'weight (fb)': 0.03292622, 'element': '[[],[[jet]]] (MET,MET)'}, {'sqrts (TeV)': 8.0, 'weight (fb)': 0.03256586, 'element': '[[],[]] (MET,MET)'}], 'Total xsec for topologies outside the grid (fb)': 0.3697722, 'topologies outside the grid': [{'sqrts (TeV)': 8.0, 'weight (fb)': 0.3697722, 'element': '[[[jet]],[[jet]]] (MET,MET)'}], 'CombinedRes': [{'AnalysisID': 'ATLAS-CONF-2013-037', 'r': 0.008014361, 'r_expected': 0.00915927, 'likelihood': 0.02475033, 'l_max': 0.02972175, 'l_SM': 0.02442398}]}
smodelsOutputDefault = {
'OutputStatus' : {
'sigmacut' : 0.03,
'minmassgap' : 5.0,
'maxcond' : 0.2,
'ncpus' : -6,
'model' : 'share.models.mssm',
'checkinput' : True,
'doinvisible' : True,
'docompress' : True,
'computestatistics' : False,
'testcoverage' : True,
'combineanas' : 'CMS-SUS-13-012,ATLAS-SUSY-2018-31,ATLAS-CONF-2013-037',
'file status' : 1,
'decomposition status' : 1,
'warnings' : 'Input file ok',
'input file' : './testFiles/slha/longLived.slha',
'database version' : 'unittest211',
'smodels version' : '2.2.0'
},
'ExptRes' : [
{
'maxcond' : 0.0,
'theory prediction (fb)' : 0.1335974,
'upper limit (fb)' : 0.16,
'expected upper limit (fb)' : 0.16,
'TxNames' : ['THSCPM1', 'THSCPM2'],
'Mass (GeV)' : None,
'AnalysisID' : 'CMS-EXO-13-006',
'DataSetID' : 'c200track',
'AnalysisSqrts (TeV)' : 8.0,
'lumi (fb-1)' : 18.8,
'dataType' : 'efficiencyMap',
'r' : 0.8349838,
'r_expected' : 0.8349838,
'Width (GeV)' : None,
'likelihood' : 0.1680834,
'l_max' : 2.071631,
'l_SM' : 2.071631
},
{
'maxcond' : 0.0,
'theory prediction (fb)' : 0.003205744,
'upper limit (fb)' : 0.4,
'expected upper limit (fb)' : 0.35,
'TxNames' : ['T2tt'],
'Mass (GeV)' : [[1061.5, 351.7], [1061.5, 351.7]],
'AnalysisID' : 'ATLAS-CONF-2013-037',
'DataSetID' : 'SRtN3',
'AnalysisSqrts (TeV)' : 8.0,
'lumi (fb-1)' : 20.7,
'dataType' : 'efficiencyMap',
'r' : 0.008014361,
'r_expected' : 0.00915927,
'Width (GeV)' : [[2.37186555, 'stable'], [2.37186555, 'stable']],
'likelihood' : 0.02475033,
'l_max' : 0.02972175,
'l_SM' : 0.02442398
}
],
'Total xsec for missing topologies (fb)' : 0.6027619,
'missing topologies' : [
{
'sqrts (TeV)' : 8.0,
'weight (fb)' : 0.3356614,
'element' : '[[[l]],[[l]]] (MET,MET)'
},
{
'sqrts (TeV)' : 8.0,
'weight (fb)' : 0.2016084,
'element' : '[[],[[l]]] (MET,MET)'
},
{
'sqrts (TeV)' : 8.0,
'weight (fb)' : 0.03292622,
'element' : '[[],[[jet]]] (MET,MET)'
},
{
'sqrts (TeV)' : 8.0,
'weight (fb)' : 0.03256586,
'element' : '[[],[]] (MET,MET)'
}
],
'Total xsec for missing topologies with displaced decays (fb)' : 0.0,
'missing topologies with displaced decays' : [],
'Total xsec for missing topologies with prompt decays (fb)' : 0.6027619,
'missing topologies with prompt decays' : [
{
'sqrts (TeV)' : 8.0,
'weight (fb)' : 0.3356614,
'element' : '[[[l]],[[l]]] (MET,MET)'
},
{
'sqrts (TeV)' : 8.0,
'weight (fb)' : 0.2016084,
'element' : '[[],[[l]]] (MET,MET)'
},
{
'sqrts (TeV)' : 8.0,
'weight (fb)' : 0.03292622,
'element' : '[[],[[jet]]] (MET,MET)'
},
{
'sqrts (TeV)' : 8.0,
'weight (fb)' : 0.03256586,
'element' : '[[],[]] (MET,MET)'
}
],
'Total xsec for topologies outside the grid (fb)' : 0.3697722,
'topologies outside the grid' : [
{
'sqrts (TeV)' : 8.0,
'weight (fb)' : 0.3697722,
'element' : '[[[jet]],[[jet]]] (MET,MET)'
}
],
'CombinedRes' : [
{
'AnalysisID' : 'ATLAS-CONF-2013-037',
'r' : 0.008014361,
'r_expected' : 0.00915927,
'likelihood' : 0.02475033,
'l_max' : 0.02972175,
'l_SM' : 0.02442398
}
]
}

94 changes: 93 additions & 1 deletion unittests/simplyGluino_default.py
Original file line number Diff line number Diff line change
@@ -1 +1,93 @@
smodelsOutputDefault = {'OutputStatus': {'sigmacut': 0.03, 'minmassgap': 5.0, 'maxcond': 0.2, 'ncpus': -6, 'model': 'share.models.mssm', 'checkinput': True, 'doinvisible': True,'docompress': True, 'computestatistics': False, 'testcoverage': True, 'combineanas': 'CMS-SUS-13-012,ATLAS-SUSY-2018-31,ATLAS-CONF-2013-037', 'file status': 1, 'decomposition status': 1, 'warnings': 'Input file ok', 'input file': './testFiles/slha/simplyGluino.slha', 'database version': 'unittest211', 'smodels version': '2.2.0'}, 'ExptRes': [{'maxcond': 0.0, 'theory prediction (fb)': 4309.035, 'upper limit (fb)': 167.6413, 'expected upper limit (fb)': None, 'TxNames': ['T1'], 'Mass (GeV)': [[675.0, 200.0], [675.0, 200.0]], 'AnalysisID': 'CMS-PAS-SUS-15-002', 'DataSetID': None, 'AnalysisSqrts (TeV)': 13.0, 'lumi (fb-1)': 2.2, 'dataType': 'upperLimit', 'r': 25.70389, 'r_expected': None, 'Width (GeV)': [['prompt', 'stable'], ['prompt', 'stable']]}, {'maxcond': 0.0, 'theory prediction (fb)': 572.1689, 'upper limit (fb)': 38.13784, 'expected upper limit (fb)': None, 'TxNames': ['T1'], 'Mass (GeV)': [[675.0, 200.0], [675.0, 200.0]], 'AnalysisID': 'ATLAS-SUSY-2013-02', 'DataSetID': None, 'AnalysisSqrts (TeV)': 8.0, 'lumi (fb-1)': 20.3, 'dataType': 'upperLimit', 'r': 15.00266, 'r_expected': None, 'Width (GeV)': [['prompt', 'stable'], ['prompt', 'stable']]}, {'maxcond': 0.0, 'theory prediction (fb)': 1.716507, 'upper limit (fb)': 0.3857116, 'expected upper limit (fb)': 0.2637784, 'TxNames': ['T1'], 'Mass (GeV)': [[675.0, 200.0], [675.0, 200.0]], 'AnalysisID': 'CMS-SUS-13-012', 'DataSetID': '6NJet8_1000HT1250_450MHTinf', 'AnalysisSqrts (TeV)': 8.0, 'lumi (fb-1)': 19.5, 'dataType': 'efficiencyMap', 'r': 4.450234, 'r_expected': 6.507382, 'Width (GeV)': [['prompt', 'stable'], ['prompt', 'stable']], 'likelihood': 1.267167e-11, 'l_max': 0.07085462, 'l_SM': 0.04875737}], 'Total xsec for missing topologies (fb)': 0.0, 'missing topologies': [], 'Total xsec for missing topologies with displaced decays (fb)': 0.0, 'missing topologies with displaced decays': [], 'Total xsec for missing topologies with prompt decays (fb)': 0.0, 'missing topologies with prompt decays': [], 'Total xsec for topologies outside the grid (fb)': 0.0, 'topologies outside the grid': [], 'CombinedRes': [{'AnalysisID': 'CMS-SUS-13-012', 'r': 4.450234, 'r_expected': 6.507382, 'likelihood': 1.267167e-11, 'l_max': 0.07085462, 'l_SM': 0.04875737}]}
smodelsOutputDefault = {
'OutputStatus' : {
'sigmacut' : 0.03,
'minmassgap' : 5.0,
'maxcond' : 0.2,
'ncpus' : -6,
'model' : 'share.models.mssm',
'checkinput' : True,
'doinvisible' : True,
'docompress' : True,
'computestatistics' : False,
'testcoverage' : True,
'combineanas' : 'CMS-SUS-13-012,ATLAS-SUSY-2018-31,ATLAS-CONF-2013-037',
'file status' : 1,
'decomposition status' : 1,
'warnings' : 'Input file ok',
'input file' : './testFiles/slha/simplyGluino.slha',
'database version' : 'unittest211',
'smodels version' : '2.2.0'
},
'ExptRes' : [
{
'maxcond' : 0.0,
'theory prediction (fb)' : 4309.035,
'upper limit (fb)' : 167.6413,
'expected upper limit (fb)' : None,
'TxNames' : ['T1'],
'Mass (GeV)' : [[675.0, 200.0], [675.0, 200.0]],
'AnalysisID' : 'CMS-PAS-SUS-15-002',
'DataSetID' : None,
'AnalysisSqrts (TeV)' : 13.0,
'lumi (fb-1)' : 2.2,
'dataType' : 'upperLimit',
'r' : 25.70389,
'r_expected' : None,
'Width (GeV)' : [[1.0, 'stable'], [1.0, 'stable']]
},
{
'maxcond' : 0.0,
'theory prediction (fb)' : 572.1689,
'upper limit (fb)' : 38.13784,
'expected upper limit (fb)' : None,
'TxNames' : ['T1'],
'Mass (GeV)' : [[675.0, 200.0], [675.0, 200.0]],
'AnalysisID' : 'ATLAS-SUSY-2013-02',
'DataSetID' : None,
'AnalysisSqrts (TeV)' : 8.0,
'lumi (fb-1)' : 20.3,
'dataType' : 'upperLimit',
'r' : 15.00266,
'r_expected' : None,
'Width (GeV)' : [[1.0, 'stable'], [1.0, 'stable']]
},
{
'maxcond' : 0.0,
'theory prediction (fb)' : 1.716507,
'upper limit (fb)' : 0.3857116,
'expected upper limit (fb)' : 0.2637784,
'TxNames' : ['T1'],
'Mass (GeV)' : [[675.0, 200.0], [675.0, 200.0]],
'AnalysisID' : 'CMS-SUS-13-012',
'DataSetID' : '6NJet8_1000HT1250_450MHTinf',
'AnalysisSqrts (TeV)' : 8.0,
'lumi (fb-1)' : 19.5,
'dataType' : 'efficiencyMap',
'r' : 4.450234,
'r_expected' : 6.507382,
'Width (GeV)' : [[1.0, 'stable'], [1.0, 'stable']],
'likelihood' : 1.267167e-11,
'l_max' : 0.07085462,
'l_SM' : 0.04875737
}
],
'Total xsec for missing topologies (fb)' : 0.0,
'missing topologies' : [],
'Total xsec for missing topologies with displaced decays (fb)' : 0.0,
'missing topologies with displaced decays' : [],
'Total xsec for missing topologies with prompt decays (fb)' : 0.0,
'missing topologies with prompt decays' : [],
'Total xsec for topologies outside the grid (fb)' : 0.0,
'topologies outside the grid' : [],
'CombinedRes' : [
{
'AnalysisID' : 'CMS-SUS-13-012',
'r' : 4.450234,
'r_expected' : 6.507382,
'likelihood' : 1.267167e-11,
'l_max' : 0.07085462,
'l_SM' : 0.04875737
}
]
}

2 changes: 1 addition & 1 deletion unittests/testTxnameWidths.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_match(self):


smsData = [np.round(x,3) for x in tx.getDataFromSMS(smsMatch)]
massPoint = [134.4, 68.1, 134.4, 68.1, 184.207, 184.207]
massPoint = [134.4, 68.1, 134.4, 68.1, 59.696, 59.696]
for im,m in enumerate(smsData):
self.assertAlmostEqual(m,massPoint[im],places=1)
v = tx.txnameData.getValueFor(smsData)
Expand Down

0 comments on commit 0725a3f

Please sign in to comment.