From 399c96d842c1256944d8a91398b7679bdf7532ec Mon Sep 17 00:00:00 2001 From: Daniel Hundhausen Date: Tue, 30 Jan 2024 13:27:50 +0100 Subject: [PATCH 1/2] fix HT plots and add tests --- .../ElectronsIsolation_Barrel_-999_V29.json | 4 +- .../reference_data/HT_50perc_350_V29.json | 620 ++++++++++++++++++ .../reference_data/HT_50perc_350_V29.yaml | 27 + .../reference_data/HT_90perc_350_V29.json | 620 ++++++++++++++++++ .../reference_data/HT_90perc_350_V29.yaml | 27 + ...st_electron_v29.py => test_turnons_v29.py} | 21 +- menu_tools/utils/objects.py | 4 +- 7 files changed, 1313 insertions(+), 10 deletions(-) create mode 100644 menu_tools/object_performance/tests/reference_data/HT_50perc_350_V29.json create mode 100644 menu_tools/object_performance/tests/reference_data/HT_50perc_350_V29.yaml create mode 100644 menu_tools/object_performance/tests/reference_data/HT_90perc_350_V29.json create mode 100644 menu_tools/object_performance/tests/reference_data/HT_90perc_350_V29.yaml rename menu_tools/object_performance/tests/{test_electron_v29.py => test_turnons_v29.py} (67%) diff --git a/menu_tools/object_performance/tests/reference_data/ElectronsIsolation_Barrel_-999_V29.json b/menu_tools/object_performance/tests/reference_data/ElectronsIsolation_Barrel_-999_V29.json index b2973374..76626ecc 100644 --- a/menu_tools/object_performance/tests/reference_data/ElectronsIsolation_Barrel_-999_V29.json +++ b/menu_tools/object_performance/tests/reference_data/ElectronsIsolation_Barrel_-999_V29.json @@ -2,7 +2,7 @@ "xlabel": "Isolation", "ylabel": "Efficiency (Barrel)", "watermark": "V29_ElectronsIsolation_Barrel_-999", - "tkElectron_NoIso": { + "tkElectron:NoIso:inclusive": { "label": "TkElectron", "efficiency": [ 0.9405951546885947, @@ -522,4 +522,4 @@ "markersize": 8 } } -} \ No newline at end of file +} diff --git a/menu_tools/object_performance/tests/reference_data/HT_50perc_350_V29.json b/menu_tools/object_performance/tests/reference_data/HT_50perc_350_V29.json new file mode 100644 index 00000000..1189c8fb --- /dev/null +++ b/menu_tools/object_performance/tests/reference_data/HT_50perc_350_V29.json @@ -0,0 +1,620 @@ +{ + "xlabel": "Gen. HT (GeV)", + "ylabel": "Trigger Efficiency (350 GeV)", + "watermark": "V29_HT_50perc_350", + "trackerHT:default:inclusive": { + "label": "Tracker HT", + "efficiency": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.00013333333333333334, + 0.0, + 0.0, + 0.0002831657935721365, + 0.00015202189115232594, + 0.00017137960582690659, + 0.0005751533742331289, + 0.0013259668508287293, + 0.0010070493454179255, + 0.0011458034947006588, + 0.0047169811320754715, + 0.0065334358186010764, + 0.009683098591549295, + 0.020813623462630087, + 0.02336448598130841, + 0.048731642189586116, + 0.05747126436781609, + 0.061837455830388695, + 0.09765625, + 0.10372040586245772, + 0.12862547288776796, + 0.1485148514851485, + 0.22085889570552147, + 0.26119402985074625, + 0.23586744639376217, + 0.288135593220339 + ], + "efficiency_err": [ + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.00011008648525952339, + 0.0, + 0.0, + 0.0001823513829141161, + 0.0001255167107782635, + 0.0001414994374845714, + 0.00031192164388792805, + 0.0005236922261730564, + 0.00048009876080158523, + 0.0005462387052469576, + 0.001238184873004851, + 0.0015586180038634307, + 0.002032740516790456, + 0.003086696109909668, + 0.0036299344476051904, + 0.005552239303424154, + 0.006436728922849196, + 0.007156409074103788, + 0.009303555410625802, + 0.010276833295418189, + 0.011961828411951522, + 0.0134836778358714, + 0.016468200979164654, + 0.01932259798778216, + 0.01906225933597891, + 0.022810750520902534 + ], + [ + 0.0046879041451349576, + 0.004073155301754859, + 0.002224231670144308, + 0.0017487856735373052, + 0.0009992720608026564, + 0.0007243644346267765, + 0.0005336709648947606, + 0.00040679589146676575, + 0.00033362631974555594, + 0.0002866581334490885, + 0.0002579314630318181, + 0.0003050696561426725, + 0.00023905576131004127, + 0.00024195956021445879, + 0.00037153169312786834, + 0.0003478188064797919, + 0.0003920958493622838, + 0.0005563888435802931, + 0.0007871342825670361, + 0.0007915796948517353, + 0.0009005340889981848, + 0.0016139392292979912, + 0.001981014480253805, + 0.0025071376227297996, + 0.003570982617458661, + 0.004226832816821902, + 0.006186050147179441, + 0.007149778995645256, + 0.007971980522778178, + 0.01012428693723158, + 0.011212116822432228, + 0.012940250496853822, + 0.014522080708850332, + 0.01735752730139206, + 0.020249609977856187, + 0.02013640533025912, + 0.02388299640520314 + ] + ], + "xbins": [ + 10.0, + 30.0, + 50.0, + 70.0, + 90.0, + 110.0, + 130.0, + 150.0, + 170.0, + 190.0, + 210.0, + 230.0, + 250.0, + 270.0, + 290.0, + 310.0, + 330.0, + 350.0, + 370.0, + 390.0, + 410.0, + 430.0, + 450.0, + 470.0, + 490.0, + 510.0, + 530.0, + 550.0, + 570.0, + 590.0, + 610.0, + 630.0, + 650.0, + 670.0, + 690.0, + 710.0, + 730.0 + ], + "err_kwargs": { + "xerr": [ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ], + "capsize": 3, + "marker": "o", + "markersize": 8 + } + }, + "phase1PuppiHT:default:inclusive": { + "label": "Histogrammed Puppi HT", + "efficiency": [ + 0.0, + 0.0022271714922048997, + 0.002430133657351154, + 0.0009551098376313276, + 0.0016366612111292963, + 0.0019770660340055358, + 0.0029129041654529565, + 0.005772646536412078, + 0.008011653313911144, + 0.0172090112640801, + 0.029842342342342343, + 0.06066666666666667, + 0.09575994781474234, + 0.1526475637131916, + 0.21959507291519184, + 0.31529340224992397, + 0.4281062553556127, + 0.5433282208588958, + 0.6651933701657459, + 0.7595669687814703, + 0.8427384703523346, + 0.8800539083557951, + 0.9362029208301307, + 0.9617077464788732, + 0.9744560075685903, + 0.9853971962616822, + 0.985981308411215, + 0.9846743295019157, + 0.9973498233215548, + 1.0, + 0.9977452085682075, + 1.0, + 1.0, + 1.0, + 0.9981343283582089, + 0.9980506822612085, + 0.9975786924939467 + ], + "efficiency_err": [ + [ + 0.0, + 0.0018389319832569585, + 0.0015648087797643124, + 0.0007885970671355072, + 0.0008875236458577121, + 0.0008503624538187063, + 0.0009009377552959101, + 0.001117258583657704, + 0.0011937195600976802, + 0.0016182739735769065, + 0.0020105396509121944, + 0.0027485350801974145, + 0.003354359186525241, + 0.004129541396414388, + 0.0049290698539978806, + 0.005744412295983381, + 0.006514426960063269, + 0.006962391845237836, + 0.007123242155422038, + 0.006934412945263868, + 0.006369835376131561, + 0.006229648041136793, + 0.005130677874428113, + 0.00443887806185439, + 0.0038909454852842362, + 0.003492967407424552, + 0.003721998685895622, + 0.004186612456707484, + 0.0025584787506947038, + 0.0017880299021929558, + 0.002951688848833567, + 0.0023082794376581006, + 0.0025886965210667467, + 0.0028067614256136464, + 0.004256551066554315, + 0.004446778399965989, + 0.005519190778433658 + ], + [ + 0.0046879041451349576, + 0.005078294715424368, + 0.0031805789145277334, + 0.0021823611280588733, + 0.001581610553844316, + 0.0013285594214324592, + 0.0012339867559877774, + 0.0013565887776518116, + 0.0013850621382176243, + 0.0017754451527456604, + 0.0021465129005511577, + 0.0028676381984171703, + 0.003461087503886115, + 0.004222050485594181, + 0.005009014088096453, + 0.005800893257580153, + 0.006539209238764998, + 0.0069456729954276986, + 0.007049632644374859, + 0.006802284247529711, + 0.0061704198638199426, + 0.005968287652665327, + 0.004784555424000914, + 0.004013419733016055, + 0.0034146848995719736, + 0.0028733743898573527, + 0.003007174042333638, + 0.0033662712202982004, + 0.0014370010235984498, + 0.0, + 0.0014519127770952212, + 0.0, + 0.0, + 0.0, + 0.0015404383715550418, + 0.001609505337728745, + 0.0019992334393843514 + ] + ], + "xbins": [ + 10.0, + 30.0, + 50.0, + 70.0, + 90.0, + 110.0, + 130.0, + 150.0, + 170.0, + 190.0, + 210.0, + 230.0, + 250.0, + 270.0, + 290.0, + 310.0, + 330.0, + 350.0, + 370.0, + 390.0, + 410.0, + 430.0, + 450.0, + 470.0, + 490.0, + 510.0, + 530.0, + 550.0, + 570.0, + 590.0, + 610.0, + 630.0, + 650.0, + 670.0, + 690.0, + 710.0, + 730.0 + ], + "err_kwargs": { + "xerr": [ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ], + "capsize": 3, + "marker": "o", + "markersize": 8 + } + }, + "seededConePuppiHT:default:inclusive": { + "label": "SeededCone HT", + "efficiency": [ + 0.0, + 0.0022271714922048997, + 0.002430133657351154, + 0.0009551098376313276, + 0.0005455537370430987, + 0.0019770660340055358, + 0.0037867754150888435, + 0.005772646536412078, + 0.010742898761835398, + 0.01955569461827284, + 0.03420608108108108, + 0.0672, + 0.10437051532941943, + 0.16255116862537963, + 0.23148803624522157, + 0.3339920948616601, + 0.4481576692373608, + 0.5648006134969326, + 0.6846408839779006, + 0.7779456193353474, + 0.8607848753938699, + 0.8982479784366577, + 0.9465795541890853, + 0.9691901408450704, + 0.9796594134342479, + 0.9877336448598131, + 0.9919893190921228, + 0.9877394636015325, + 0.9964664310954063, + 1.0, + 0.9988726042841037, + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 1.0 + ], + "efficiency_err": [ + [ + 0.0, + 0.0018389319832569585, + 0.0015648087797643124, + 0.0007885970671355072, + 0.0004504391188022924, + 0.0008503624538187063, + 0.0010308807980181803, + 0.001117258583657704, + 0.0013819069127093287, + 0.0017234954877210357, + 0.0021481838905352754, + 0.0028832249924839876, + 0.0034858887659411225, + 0.004237227675487343, + 0.005023187390551687, + 0.005833142665312374, + 0.00655043422376117, + 0.006934376650048257, + 0.007020225149216741, + 0.006754273421534895, + 0.006074460092601042, + 0.00582430916443577, + 0.0047551672768813, + 0.004045688680966553, + 0.0035369437733976383, + 0.0032604119472066095, + 0.0030115358616300547, + 0.0038435540182472083, + 0.0027712486786956037, + 0.0017880299021929558, + 0.002575292661612605, + 0.0023082794376581006, + 0.0025886965210667467, + 0.0028067614256136464, + 0.0034131571592493914, + 0.003565910541162176, + 0.004427413234551869 + ], + [ + 0.0046879041451349576, + 0.005078294715424368, + 0.0031805789145277334, + 0.0021823611280588733, + 0.001247393278627939, + 0.0013285594214324592, + 0.0013577907768089897, + 0.0013565887776518116, + 0.0015703676556506358, + 0.0018794641871793562, + 0.0022826039655549704, + 0.00300042747386578, + 0.003590268761640189, + 0.004327063398556902, + 0.005099720754426218, + 0.0058838958976762945, + 0.006568303462218095, + 0.00690937073223985, + 0.006937929890030614, + 0.006612716368271099, + 0.005864297382878636, + 0.005549872504061137, + 0.004399618977669162, + 0.0036108457836996344, + 0.003051788994082316, + 0.0026327050815019293, + 0.002265023346719186, + 0.003008289686007304, + 0.0016840561707416324, + 0.0, + 0.0009308497718625297, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ] + ], + "xbins": [ + 10.0, + 30.0, + 50.0, + 70.0, + 90.0, + 110.0, + 130.0, + 150.0, + 170.0, + 190.0, + 210.0, + 230.0, + 250.0, + 270.0, + 290.0, + 310.0, + 330.0, + 350.0, + 370.0, + 390.0, + 410.0, + 430.0, + 450.0, + 470.0, + 490.0, + 510.0, + 530.0, + 550.0, + 570.0, + 590.0, + 610.0, + 630.0, + 650.0, + 670.0, + 690.0, + 710.0, + 730.0 + ], + "err_kwargs": { + "xerr": [ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ], + "capsize": 3, + "marker": "o", + "markersize": 8 + } + } +} diff --git a/menu_tools/object_performance/tests/reference_data/HT_50perc_350_V29.yaml b/menu_tools/object_performance/tests/reference_data/HT_50perc_350_V29.yaml new file mode 100644 index 00000000..224160bf --- /dev/null +++ b/menu_tools/object_performance/tests/reference_data/HT_50perc_350_V29.yaml @@ -0,0 +1,27 @@ +HT_50perc: + binning: + max: 750 + min: 0 + step: 20 + version: V29 + reference_object: + cuts: + object: + - abs({eta}) < 2.4 + - '{pt} > 30' + label: Gen HT + object: jet + x_arg: Pt + trafo: HT + sample: TT + scalings: + method: naive + threshold: 0.5 + test_objects: + phase1PuppiHT:default: "" + seededConePuppiHT:default: "" + trackerHT:default: "" + thresholds: + - 350 + xlabel: Gen. HT (GeV) + ylabel: Trigger Efficiency ( GeV) diff --git a/menu_tools/object_performance/tests/reference_data/HT_90perc_350_V29.json b/menu_tools/object_performance/tests/reference_data/HT_90perc_350_V29.json new file mode 100644 index 00000000..136fafdb --- /dev/null +++ b/menu_tools/object_performance/tests/reference_data/HT_90perc_350_V29.json @@ -0,0 +1,620 @@ +{ + "xlabel": "Gen. HT (GeV)", + "ylabel": "Trigger Efficiency (350 GeV)", + "watermark": "V29_HT_90perc_350", + "trackerHT:default:inclusive": { + "label": "Tracker HT", + "efficiency": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.00013333333333333334, + 0.0, + 0.0, + 0.0002831657935721365, + 0.00015202189115232594, + 0.00017137960582690659, + 0.0005751533742331289, + 0.0013259668508287293, + 0.0010070493454179255, + 0.0011458034947006588, + 0.0047169811320754715, + 0.0065334358186010764, + 0.009683098591549295, + 0.020813623462630087, + 0.02336448598130841, + 0.048731642189586116, + 0.05747126436781609, + 0.061837455830388695, + 0.09765625, + 0.10372040586245772, + 0.12862547288776796, + 0.1485148514851485, + 0.22085889570552147, + 0.26119402985074625, + 0.23586744639376217, + 0.288135593220339 + ], + "efficiency_err": [ + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.00011008648525952339, + 0.0, + 0.0, + 0.0001823513829141161, + 0.0001255167107782635, + 0.0001414994374845714, + 0.00031192164388792805, + 0.0005236922261730564, + 0.00048009876080158523, + 0.0005462387052469576, + 0.001238184873004851, + 0.0015586180038634307, + 0.002032740516790456, + 0.003086696109909668, + 0.0036299344476051904, + 0.005552239303424154, + 0.006436728922849196, + 0.007156409074103788, + 0.009303555410625802, + 0.010276833295418189, + 0.011961828411951522, + 0.0134836778358714, + 0.016468200979164654, + 0.01932259798778216, + 0.01906225933597891, + 0.022810750520902534 + ], + [ + 0.0046879041451349576, + 0.004073155301754859, + 0.002224231670144308, + 0.0017487856735373052, + 0.0009992720608026564, + 0.0007243644346267765, + 0.0005336709648947606, + 0.00040679589146676575, + 0.00033362631974555594, + 0.0002866581334490885, + 0.0002579314630318181, + 0.0003050696561426725, + 0.00023905576131004127, + 0.00024195956021445879, + 0.00037153169312786834, + 0.0003478188064797919, + 0.0003920958493622838, + 0.0005563888435802931, + 0.0007871342825670361, + 0.0007915796948517353, + 0.0009005340889981848, + 0.0016139392292979912, + 0.001981014480253805, + 0.0025071376227297996, + 0.003570982617458661, + 0.004226832816821902, + 0.006186050147179441, + 0.007149778995645256, + 0.007971980522778178, + 0.01012428693723158, + 0.011212116822432228, + 0.012940250496853822, + 0.014522080708850332, + 0.01735752730139206, + 0.020249609977856187, + 0.02013640533025912, + 0.02388299640520314 + ] + ], + "xbins": [ + 10.0, + 30.0, + 50.0, + 70.0, + 90.0, + 110.0, + 130.0, + 150.0, + 170.0, + 190.0, + 210.0, + 230.0, + 250.0, + 270.0, + 290.0, + 310.0, + 330.0, + 350.0, + 370.0, + 390.0, + 410.0, + 430.0, + 450.0, + 470.0, + 490.0, + 510.0, + 530.0, + 550.0, + 570.0, + 590.0, + 610.0, + 630.0, + 650.0, + 670.0, + 690.0, + 710.0, + 730.0 + ], + "err_kwargs": { + "xerr": [ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ], + "capsize": 3, + "marker": "o", + "markersize": 8 + } + }, + "phase1PuppiHT:default:inclusive": { + "label": "Histogrammed Puppi HT", + "efficiency": [ + 0.0, + 0.0022271714922048997, + 0.002430133657351154, + 0.0009551098376313276, + 0.0016366612111292963, + 0.0019770660340055358, + 0.0029129041654529565, + 0.005772646536412078, + 0.008011653313911144, + 0.0172090112640801, + 0.029842342342342343, + 0.06066666666666667, + 0.09575994781474234, + 0.1526475637131916, + 0.21959507291519184, + 0.31529340224992397, + 0.4281062553556127, + 0.5433282208588958, + 0.6651933701657459, + 0.7595669687814703, + 0.8427384703523346, + 0.8800539083557951, + 0.9362029208301307, + 0.9617077464788732, + 0.9744560075685903, + 0.9853971962616822, + 0.985981308411215, + 0.9846743295019157, + 0.9973498233215548, + 1.0, + 0.9977452085682075, + 1.0, + 1.0, + 1.0, + 0.9981343283582089, + 0.9980506822612085, + 0.9975786924939467 + ], + "efficiency_err": [ + [ + 0.0, + 0.0018389319832569585, + 0.0015648087797643124, + 0.0007885970671355072, + 0.0008875236458577121, + 0.0008503624538187063, + 0.0009009377552959101, + 0.001117258583657704, + 0.0011937195600976802, + 0.0016182739735769065, + 0.0020105396509121944, + 0.0027485350801974145, + 0.003354359186525241, + 0.004129541396414388, + 0.0049290698539978806, + 0.005744412295983381, + 0.006514426960063269, + 0.006962391845237836, + 0.007123242155422038, + 0.006934412945263868, + 0.006369835376131561, + 0.006229648041136793, + 0.005130677874428113, + 0.00443887806185439, + 0.0038909454852842362, + 0.003492967407424552, + 0.003721998685895622, + 0.004186612456707484, + 0.0025584787506947038, + 0.0017880299021929558, + 0.002951688848833567, + 0.0023082794376581006, + 0.0025886965210667467, + 0.0028067614256136464, + 0.004256551066554315, + 0.004446778399965989, + 0.005519190778433658 + ], + [ + 0.0046879041451349576, + 0.005078294715424368, + 0.0031805789145277334, + 0.0021823611280588733, + 0.001581610553844316, + 0.0013285594214324592, + 0.0012339867559877774, + 0.0013565887776518116, + 0.0013850621382176243, + 0.0017754451527456604, + 0.0021465129005511577, + 0.0028676381984171703, + 0.003461087503886115, + 0.004222050485594181, + 0.005009014088096453, + 0.005800893257580153, + 0.006539209238764998, + 0.0069456729954276986, + 0.007049632644374859, + 0.006802284247529711, + 0.0061704198638199426, + 0.005968287652665327, + 0.004784555424000914, + 0.004013419733016055, + 0.0034146848995719736, + 0.0028733743898573527, + 0.003007174042333638, + 0.0033662712202982004, + 0.0014370010235984498, + 0.0, + 0.0014519127770952212, + 0.0, + 0.0, + 0.0, + 0.0015404383715550418, + 0.001609505337728745, + 0.0019992334393843514 + ] + ], + "xbins": [ + 10.0, + 30.0, + 50.0, + 70.0, + 90.0, + 110.0, + 130.0, + 150.0, + 170.0, + 190.0, + 210.0, + 230.0, + 250.0, + 270.0, + 290.0, + 310.0, + 330.0, + 350.0, + 370.0, + 390.0, + 410.0, + 430.0, + 450.0, + 470.0, + 490.0, + 510.0, + 530.0, + 550.0, + 570.0, + 590.0, + 610.0, + 630.0, + 650.0, + 670.0, + 690.0, + 710.0, + 730.0 + ], + "err_kwargs": { + "xerr": [ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ], + "capsize": 3, + "marker": "o", + "markersize": 8 + } + }, + "seededConePuppiHT:default:inclusive": { + "label": "SeededCone HT", + "efficiency": [ + 0.0, + 0.0022271714922048997, + 0.002430133657351154, + 0.0009551098376313276, + 0.0005455537370430987, + 0.0019770660340055358, + 0.0037867754150888435, + 0.005772646536412078, + 0.010742898761835398, + 0.01955569461827284, + 0.03420608108108108, + 0.0672, + 0.10437051532941943, + 0.16255116862537963, + 0.23148803624522157, + 0.3339920948616601, + 0.4481576692373608, + 0.5648006134969326, + 0.6846408839779006, + 0.7779456193353474, + 0.8607848753938699, + 0.8982479784366577, + 0.9465795541890853, + 0.9691901408450704, + 0.9796594134342479, + 0.9877336448598131, + 0.9919893190921228, + 0.9877394636015325, + 0.9964664310954063, + 1.0, + 0.9988726042841037, + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 1.0 + ], + "efficiency_err": [ + [ + 0.0, + 0.0018389319832569585, + 0.0015648087797643124, + 0.0007885970671355072, + 0.0004504391188022924, + 0.0008503624538187063, + 0.0010308807980181803, + 0.001117258583657704, + 0.0013819069127093287, + 0.0017234954877210357, + 0.0021481838905352754, + 0.0028832249924839876, + 0.0034858887659411225, + 0.004237227675487343, + 0.005023187390551687, + 0.005833142665312374, + 0.00655043422376117, + 0.006934376650048257, + 0.007020225149216741, + 0.006754273421534895, + 0.006074460092601042, + 0.00582430916443577, + 0.0047551672768813, + 0.004045688680966553, + 0.0035369437733976383, + 0.0032604119472066095, + 0.0030115358616300547, + 0.0038435540182472083, + 0.0027712486786956037, + 0.0017880299021929558, + 0.002575292661612605, + 0.0023082794376581006, + 0.0025886965210667467, + 0.0028067614256136464, + 0.0034131571592493914, + 0.003565910541162176, + 0.004427413234551869 + ], + [ + 0.0046879041451349576, + 0.005078294715424368, + 0.0031805789145277334, + 0.0021823611280588733, + 0.001247393278627939, + 0.0013285594214324592, + 0.0013577907768089897, + 0.0013565887776518116, + 0.0015703676556506358, + 0.0018794641871793562, + 0.0022826039655549704, + 0.00300042747386578, + 0.003590268761640189, + 0.004327063398556902, + 0.005099720754426218, + 0.0058838958976762945, + 0.006568303462218095, + 0.00690937073223985, + 0.006937929890030614, + 0.006612716368271099, + 0.005864297382878636, + 0.005549872504061137, + 0.004399618977669162, + 0.0036108457836996344, + 0.003051788994082316, + 0.0026327050815019293, + 0.002265023346719186, + 0.003008289686007304, + 0.0016840561707416324, + 0.0, + 0.0009308497718625297, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ] + ], + "xbins": [ + 10.0, + 30.0, + 50.0, + 70.0, + 90.0, + 110.0, + 130.0, + 150.0, + 170.0, + 190.0, + 210.0, + 230.0, + 250.0, + 270.0, + 290.0, + 310.0, + 330.0, + 350.0, + 370.0, + 390.0, + 410.0, + 430.0, + 450.0, + 470.0, + 490.0, + 510.0, + 530.0, + 550.0, + 570.0, + 590.0, + 610.0, + 630.0, + 650.0, + 670.0, + 690.0, + 710.0, + 730.0 + ], + "err_kwargs": { + "xerr": [ + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0, + 10.0 + ], + "capsize": 3, + "marker": "o", + "markersize": 8 + } + } +} diff --git a/menu_tools/object_performance/tests/reference_data/HT_90perc_350_V29.yaml b/menu_tools/object_performance/tests/reference_data/HT_90perc_350_V29.yaml new file mode 100644 index 00000000..969165bf --- /dev/null +++ b/menu_tools/object_performance/tests/reference_data/HT_90perc_350_V29.yaml @@ -0,0 +1,27 @@ +HT_90perc: + binning: + max: 750 + min: 0 + step: 20 + version: V29 + reference_object: + cuts: + object: + - abs({eta}) < 2.4 + - '{pt} > 30' + label: Gen HT + object: jet + x_arg: Pt + trafo: HT + sample: TT + scalings: + method: naive + threshold: 0.9 + test_objects: + phase1PuppiHT:default: "" + seededConePuppiHT:default: "" + trackerHT:default: "" + thresholds: + - 350 + xlabel: Gen. HT (GeV) + ylabel: Trigger Efficiency ( GeV) diff --git a/menu_tools/object_performance/tests/test_electron_v29.py b/menu_tools/object_performance/tests/test_turnons_v29.py similarity index 67% rename from menu_tools/object_performance/tests/test_electron_v29.py rename to menu_tools/object_performance/tests/test_turnons_v29.py index 2a0788cc..0cb4f583 100644 --- a/menu_tools/object_performance/tests/test_electron_v29.py +++ b/menu_tools/object_performance/tests/test_turnons_v29.py @@ -6,15 +6,24 @@ import sys import numpy as np +import pytest from menu_tools.object_performance import plotter -def test_isolation_barrel(): +testdata = [ + "HT_50perc_350_V29", + "HT_90perc_350_V29", + "ElectronsIsolation_Barrel_-999_V29" +] + + +@pytest.mark.parametrize("test_name", testdata) +def test_matching_plots_reproduced(test_name): # Prepare patching of the command line arguments for argparse testargs = [ "foo", - "menu_tools/object_performance/tests/reference_data/ElectronsIsolation_Barrel_-999_V29.yaml", + f"menu_tools/object_performance/tests/reference_data/{test_name}.yaml", ] # Run Plotting @@ -23,22 +32,20 @@ def test_isolation_barrel(): # Load result and assert correct outcome with open( - "outputs/object_performance/V29/turnons/ElectronsIsolation_Barrel_-999_V29.json", + f"outputs/object_performance/V29/turnons/{test_name}.json", "r", ) as f: test_result = json.load(f) with open( - "menu_tools/object_performance/tests/reference_data/ElectronsIsolation_Barrel_-999_V29.json", + f"menu_tools/object_performance/tests/reference_data/{test_name}.json", "r", ) as f: reference_data = json.load(f) for key, val in reference_data.items(): if isinstance(val, dict): - if "tkEle" in key: - test_key = "tkElectron:NoIso:inclusive" efficiencies_test = np.array( - test_result[test_key]["efficiency"], dtype=np.float64 + test_result[key]["efficiency"], dtype=np.float64 ) efficiencies_reference = np.array(val["efficiency"], dtype=np.float64) print(efficiencies_reference) diff --git a/menu_tools/utils/objects.py b/menu_tools/utils/objects.py index 1b281bf3..ead996b9 100644 --- a/menu_tools/utils/objects.py +++ b/menu_tools/utils/objects.py @@ -128,7 +128,9 @@ def plot_label(self) -> str: @property def eta_ranges(self) -> dict[str, tuple[float, float]]: - _eta_ranges = self._object_params["eta_ranges"] + _eta_ranges = {} + if "eta_ranges" in self._object_params.keys(): + _eta_ranges = self._object_params["eta_ranges"] if "inclusive" not in _eta_ranges: _eta_ranges["inclusive"] = [0, 7] return _eta_ranges From cdd3b9943423b1a1f5c8cce23c4cec2893ade790 Mon Sep 17 00:00:00 2001 From: Daniel Hundhausen Date: Tue, 30 Jan 2024 13:30:38 +0100 Subject: [PATCH 2/2] run black --- menu_tools/object_performance/tests/test_turnons_v29.py | 2 +- menu_tools/utils/objects.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/menu_tools/object_performance/tests/test_turnons_v29.py b/menu_tools/object_performance/tests/test_turnons_v29.py index 0cb4f583..4ae892d0 100644 --- a/menu_tools/object_performance/tests/test_turnons_v29.py +++ b/menu_tools/object_performance/tests/test_turnons_v29.py @@ -14,7 +14,7 @@ testdata = [ "HT_50perc_350_V29", "HT_90perc_350_V29", - "ElectronsIsolation_Barrel_-999_V29" + "ElectronsIsolation_Barrel_-999_V29", ] diff --git a/menu_tools/utils/objects.py b/menu_tools/utils/objects.py index ead996b9..5b19182c 100644 --- a/menu_tools/utils/objects.py +++ b/menu_tools/utils/objects.py @@ -144,7 +144,9 @@ def cuts(self) -> Optional[dict[str, list[str]]]: # if a region other than inclusive is specified an eta cut eta_min = self.eta_ranges[self.eta_range][0] eta_max = self.eta_ranges[self.eta_range][1] - global_eta_cut = f"((abs({{eta}}) > {eta_min}) & (abs({{eta}}) < {eta_max}))" + global_eta_cut = ( + f"((abs({{eta}}) > {eta_min}) & (abs({{eta}}) < {eta_max}))" + ) try: _cuts["inclusive"].append(global_eta_cut) except KeyError: