diff --git a/src/hbb/common_vars.py b/src/hbb/common_vars.py index fb2de801..e4ded104 100644 --- a/src/hbb/common_vars.py +++ b/src/hbb/common_vars.py @@ -7,7 +7,9 @@ "2022EE": 26671.6, "2023": 18084.4, "2023BPix": 9692.1, + "2024": 109080.0, "2022-2023": 62428.6, + "2022-2024": 171508.6 } norm_preserving_weights = ["genweight", "pileup", "ISRPartonShower", "FSRPartonShower"] diff --git a/src/hbb/corrections.py b/src/hbb/corrections.py index 58862701..cfc7c222 100644 --- a/src/hbb/corrections.py +++ b/src/hbb/corrections.py @@ -104,13 +104,17 @@ def add_pileup_weight(weights: Weights, year: str, nPU): values = {} cset = correctionlib.CorrectionSet.from_file(get_pog_json("pileup", year)) + if year == "2024": + pog_json_file = Path(f"{package_path}/hbb/data/puWeights_2024.json") + cset = correctionlib.CorrectionSet.from_file(pog_json_file) + corr = { "2018": "Collisions18_UltraLegacy_goldenJSON", "2022": "Collisions2022_355100_357900_eraBCD_GoldenJson", "2022EE": "Collisions2022_359022_362760_eraEFG_GoldenJson", "2023": "Collisions2023_366403_369802_eraBC_GoldenJson", "2023BPix": "Collisions2023_369803_370790_eraD_GoldenJson", - #"2024": "", Not yet derived by pog + "2024": "Pileup", }[year] # evaluate and clip up to 4 to avoid large weights values["nominal"] = ak_clip(cset[corr].evaluate(nPU, "nominal"), 0, 4) @@ -239,7 +243,7 @@ def get_veto(j, nj, csetstr): "2022EE": "Summer22EE_23Sep2023_RunEFG_V1", "2023": "Summer23Prompt23_RunC_V1", "2023BPix": "Summer23BPixPrompt23_RunD_V1", - "2024": "Summer24Prompt24", + "2024": "Summer24Prompt24_RunBCDEFGHI_V1", }[year] jet_veto = get_veto(j, nj, corr_str) > 0 @@ -481,7 +485,7 @@ def add_photon_weights(weights: Weights, year: str, photons): "2022EE" : "2022Re-recoE+PromptFG", "2023" : "2023PromptC", "2023BPix" : "2023PromptD", - # "2024" #TODO double check + "2024" : "2024", } cset = correctionlib.CorrectionSet.from_file(get_pog_json("photon", year)) diff --git a/src/hbb/data/PU_weights_Summer24.histo.root b/src/hbb/data/PU_weights_Summer24.histo.root new file mode 100644 index 00000000..68a14940 Binary files /dev/null and b/src/hbb/data/PU_weights_Summer24.histo.root differ diff --git a/src/hbb/data/puWeights_2024.json b/src/hbb/data/puWeights_2024.json new file mode 100644 index 00000000..955350df --- /dev/null +++ b/src/hbb/data/puWeights_2024.json @@ -0,0 +1,676 @@ +{ + "schema_version": 2, + "description": null, + "corrections": [ + { + "name": "Pileup", + "description": "Pileup weights (nominal/up/down) from data/PU_weights_Summer24.histo.root", + "version": 1, + "inputs": [ + { + "name": "nTrueInt", + "type": "real", + "description": "True number of interactions" + }, + { + "name": "variation", + "type": "string", + "description": "nominal/up/down" + } + ], + "output": { + "name": "weight", + "type": "real", + "description": null + }, + "generic_formulas": null, + "data": { + "nodetype": "category", + "input": "variation", + "content": [ + { + "key": "nominal", + "value": { + "nodetype": "binning", + "input": "nTrueInt", + "edges": [ + 0.0, + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + 17.0, + 18.0, + 19.0, + 20.0, + 21.0, + 22.0, + 23.0, + 24.0, + 25.0, + 26.0, + 27.0, + 28.0, + 29.0, + 30.0, + 31.0, + 32.0, + 33.0, + 34.0, + 35.0, + 36.0, + 37.0, + 38.0, + 39.0, + 40.0, + 41.0, + 42.0, + 43.0, + 44.0, + 45.0, + 46.0, + 47.0, + 48.0, + 49.0, + 50.0, + 51.0, + 52.0, + 53.0, + 54.0, + 55.0, + 56.0, + 57.0, + 58.0, + 59.0, + 60.0, + 61.0, + 62.0, + 63.0, + 64.0, + 65.0, + 66.0, + 67.0, + 68.0, + 69.0, + 70.0, + 71.0, + 72.0, + 73.0, + 74.0, + 75.0, + 76.0, + 77.0, + 78.0, + 79.0, + 80.0, + 81.0, + 82.0, + 83.0, + 84.0, + 85.0, + 86.0, + 87.0, + 88.0, + 89.0, + 90.0, + 91.0, + 92.0, + 93.0, + 94.0, + 95.0, + 96.0, + 97.0, + 98.0, + 99.0, + 100.0 + ], + "content": [ + 0.4756280290100345, + 0.6206420166857981, + 0.7744355248413384, + 0.7537587041600128, + 0.7040559210805336, + 0.8409472322798383, + 0.8592780358642784, + 0.8195028665088296, + 0.8262407461275754, + 0.8311668586523688, + 0.5404713667669342, + 0.45962561426114074, + 0.7014071597489918, + 0.6247580668772205, + 0.45307600175504403, + 0.3199871999813462, + 0.3346092018673912, + 0.3730443312470535, + 0.3913602142616873, + 0.41599666798155227, + 0.45449346422482967, + 0.4440466791544415, + 0.3929137148996009, + 0.33327073711490496, + 0.2947597582717126, + 0.2877716315792674, + 0.2969342733134011, + 0.31478072541740015, + 0.33762616030327186, + 0.36192955189836595, + 0.39093184440935547, + 0.42436199161389687, + 0.4620007508917098, + 0.504907707213795, + 0.5563249277613029, + 0.6151599943722698, + 0.6751639036686304, + 0.7221298564354945, + 0.7520124172120612, + 0.7659256284598739, + 0.7685234014796677, + 0.7653103395374865, + 0.7624861520756215, + 0.7635441013172702, + 0.7723264131807228, + 0.7921261300721, + 0.8097175600562057, + 0.8348922034906332, + 0.8855132910559774, + 0.9608734661648879, + 1.0459054576597862, + 1.1323025035384975, + 1.2513704690482004, + 1.3728436256496088, + 1.4745573901368387, + 1.5995952922120986, + 1.7302929305402128, + 1.8780972372880305, + 2.0190657081038395, + 2.147347225302365, + 2.3243819159680004, + 2.465979388250165, + 2.590989672893745, + 2.6646486105436273, + 2.5624221038138555, + 2.664540548705833, + 3.084015401854821, + 3.514405332074599, + 4.1252373730168514, + 6.452617501304059, + 11.020481196276666, + 12.78240602602679, + 17.856179471669968, + 31.070726217175814, + 36.47082704629289, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 3.29227581611356, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "flow": "clamp" + } + }, + { + "key": "up", + "value": { + "nodetype": "binning", + "input": "nTrueInt", + "edges": [ + 0.0, + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + 17.0, + 18.0, + 19.0, + 20.0, + 21.0, + 22.0, + 23.0, + 24.0, + 25.0, + 26.0, + 27.0, + 28.0, + 29.0, + 30.0, + 31.0, + 32.0, + 33.0, + 34.0, + 35.0, + 36.0, + 37.0, + 38.0, + 39.0, + 40.0, + 41.0, + 42.0, + 43.0, + 44.0, + 45.0, + 46.0, + 47.0, + 48.0, + 49.0, + 50.0, + 51.0, + 52.0, + 53.0, + 54.0, + 55.0, + 56.0, + 57.0, + 58.0, + 59.0, + 60.0, + 61.0, + 62.0, + 63.0, + 64.0, + 65.0, + 66.0, + 67.0, + 68.0, + 69.0, + 70.0, + 71.0, + 72.0, + 73.0, + 74.0, + 75.0, + 76.0, + 77.0, + 78.0, + 79.0, + 80.0, + 81.0, + 82.0, + 83.0, + 84.0, + 85.0, + 86.0, + 87.0, + 88.0, + 89.0, + 90.0, + 91.0, + 92.0, + 93.0, + 94.0, + 95.0, + 96.0, + 97.0, + 98.0, + 99.0, + 100.0 + ], + "content": [ + 0.43468577463405017, + 0.5548326563017044, + 0.7172938408932373, + 0.7137556089796828, + 0.6450507247140591, + 0.7783883688311578, + 0.7968386963019467, + 0.7848684876162784, + 0.7855970001036311, + 0.8097740897984116, + 0.5139219464885191, + 0.43258124427330724, + 0.6622319143994418, + 0.5472200257431067, + 0.35791159484516827, + 0.2224056983962378, + 0.23805200561551187, + 0.313407632537037, + 0.3594043810753772, + 0.3637189538825752, + 0.3607286051126196, + 0.3495183873544136, + 0.3024147421665452, + 0.23476799723045927, + 0.1892348350861347, + 0.17547034367529424, + 0.18713898178366165, + 0.2138684837795899, + 0.2453877339758638, + 0.2752107159058336, + 0.3046954074650868, + 0.33487373099704376, + 0.3674474482286455, + 0.40329845859431573, + 0.44381439049824345, + 0.4893968473752577, + 0.5402002515508386, + 0.5895264234119404, + 0.6334737955942401, + 0.6677438719011103, + 0.6895780306570845, + 0.697304977636802, + 0.6916075484109797, + 0.6739396398813562, + 0.6495869672924893, + 0.6256094139071903, + 0.5976083511191855, + 0.5798633173216189, + 0.5895022581930881, + 0.6298092663011952, + 0.6961916919302505, + 0.789352207746917, + 0.939211701068271, + 1.1349571047166787, + 1.3671899658287328, + 1.6853858821142456, + 2.0905774441032223, + 2.6157920917498028, + 3.2486089380988195, + 3.9886206793004155, + 4.968722890717508, + 6.034308803896893, + 7.206982717187029, + 8.356142063451886, + 8.978964298392746, + 10.338934060946677, + 13.13629464666358, + 16.303121072582883, + 20.698296641180953, + 34.81517175292438, + 40.0, + 40.0, + 40.0, + 40.0, + 40.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 18.430528631755244, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "flow": "clamp" + } + }, + { + "key": "down", + "value": { + "nodetype": "binning", + "input": "nTrueInt", + "edges": [ + 0.0, + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + 17.0, + 18.0, + 19.0, + 20.0, + 21.0, + 22.0, + 23.0, + 24.0, + 25.0, + 26.0, + 27.0, + 28.0, + 29.0, + 30.0, + 31.0, + 32.0, + 33.0, + 34.0, + 35.0, + 36.0, + 37.0, + 38.0, + 39.0, + 40.0, + 41.0, + 42.0, + 43.0, + 44.0, + 45.0, + 46.0, + 47.0, + 48.0, + 49.0, + 50.0, + 51.0, + 52.0, + 53.0, + 54.0, + 55.0, + 56.0, + 57.0, + 58.0, + 59.0, + 60.0, + 61.0, + 62.0, + 63.0, + 64.0, + 65.0, + 66.0, + 67.0, + 68.0, + 69.0, + 70.0, + 71.0, + 72.0, + 73.0, + 74.0, + 75.0, + 76.0, + 77.0, + 78.0, + 79.0, + 80.0, + 81.0, + 82.0, + 83.0, + 84.0, + 85.0, + 86.0, + 87.0, + 88.0, + 89.0, + 90.0, + 91.0, + 92.0, + 93.0, + 94.0, + 95.0, + 96.0, + 97.0, + 98.0, + 99.0, + 100.0 + ], + "content": [ + 0.52529160201967, + 0.6960511288722065, + 0.834653744947356, + 0.7999459566064252, + 0.774106510367249, + 0.9157196321760577, + 0.911539438864649, + 0.8639160751320911, + 0.863160529655329, + 0.8557716785793118, + 0.5789682554913964, + 0.4846790965472235, + 0.7747245228595252, + 0.7669793875046229, + 0.6382965407676651, + 0.47046712719670614, + 0.4171730984230016, + 0.4105242793226812, + 0.4449092155764779, + 0.5265681020868005, + 0.5843449104497241, + 0.5850871387098066, + 0.5706103308552287, + 0.5348403667641328, + 0.4944541022081234, + 0.4596875867020245, + 0.4365366333317352, + 0.43254288896961096, + 0.4449644071579149, + 0.46706401389621655, + 0.49899976701347587, + 0.5378640617033613, + 0.58461182587272, + 0.6409941568709234, + 0.7052279324259135, + 0.7670961083743687, + 0.8159685453772939, + 0.8405705609408316, + 0.8466090549086543, + 0.8455622505997906, + 0.8503722569326674, + 0.8710210378569665, + 0.9144267811979614, + 0.9811469200047128, + 1.0685013163075816, + 1.1688740708662162, + 1.2458155961015163, + 1.2972053583098941, + 1.3406273615885338, + 1.3694309081501899, + 1.3618542965114078, + 1.3149486289734253, + 1.2727444613208958, + 1.2071928431785581, + 1.1121783296043772, + 1.0306745319944326, + 0.9520666369639534, + 0.8847865711957453, + 0.8188295533494385, + 0.7553932284975898, + 0.7158018258582045, + 0.6715523697731652, + 0.6304699076640615, + 0.5851727544191885, + 0.5124907845831038, + 0.4891757037524936, + 0.5231375870400492, + 0.5537948436894424, + 0.6066012079675874, + 0.8889919840011115, + 1.428271362447563, + 1.5654136995674006, + 2.0780795883434755, + 3.462511985613749, + 3.9339996313472008, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.093598555737163, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "flow": "clamp" + } + } + ], + "default": null + } + } + ], + "compound_corrections": null +} \ No newline at end of file diff --git a/src/hbb/egamma_triggers.json b/src/hbb/egamma_triggers.json index 2a32d943..28ddf68f 100644 --- a/src/hbb/egamma_triggers.json +++ b/src/hbb/egamma_triggers.json @@ -15,6 +15,11 @@ "Photon30EB_TightID_TightIso" ], "2023BPix": [ + "Photon200", + "Photon110EB_TightID_TightIso", + "Photon30EB_TightID_TightIso" + ], + "2024": [ "Photon200", "Photon110EB_TightID_TightIso", "Photon30EB_TightID_TightIso" diff --git a/src/hbb/metfilters.json b/src/hbb/metfilters.json index a1478b8e..8a5b8305 100644 --- a/src/hbb/metfilters.json +++ b/src/hbb/metfilters.json @@ -78,5 +78,27 @@ "hfNoisyHitsFilter", "eeBadScFilter" ] + }, + "2024": { + "data": [ + "goodVertices", + "globalSuperTightHalo2016Filter", + "EcalDeadCellTriggerPrimitiveFilter", + "BadPFMuonFilter", + "BadPFMuonDzFilter", + "hfNoisyHitsFilter", + "eeBadScFilter", + "ecalBadCalibFilter" + ], + "mc": [ + "goodVertices", + "globalSuperTightHalo2016Filter", + "EcalDeadCellTriggerPrimitiveFilter", + "BadPFMuonFilter", + "BadPFMuonDzFilter", + "hfNoisyHitsFilter", + "eeBadScFilter", + "ecalBadCalibFilter" + ] } } \ No newline at end of file diff --git a/src/hbb/muon_triggers.json b/src/hbb/muon_triggers.json index 82d540cf..3768210e 100644 --- a/src/hbb/muon_triggers.json +++ b/src/hbb/muon_triggers.json @@ -2,5 +2,6 @@ "2022": ["Mu50"], "2022EE": ["Mu50"], "2023": ["Mu50"], - "2023BPix": ["Mu50"] + "2023BPix": ["Mu50"], + "2024": ["Mu50"] } \ No newline at end of file diff --git a/src/hbb/pileup_24.py b/src/hbb/pileup_24.py new file mode 100644 index 00000000..191dd981 --- /dev/null +++ b/src/hbb/pileup_24.py @@ -0,0 +1,86 @@ +import uproot +import correctionlib.schemav2 as cs + +# Input ROOT file +root_file = "data/PU_weights_Summer24.histo.root" +output_file = "data/puWeights_2024.json" + +# Step 1: List contents of the file +with uproot.open(root_file) as f: + print("Contents of the file:") + for key, obj in f.items(): + print(f" {key} -> {type(obj)}") + +''' +PU;1 -> +PUup;1 -> +PUdown;1 -> +''' + +with uproot.open(root_file) as f: + h_nom = f["PU;1"] + h_up = f["PUup;1"] + h_down = f["PUdown;1"] + +# Extract edges (same for all) +edges = h_nom.axes[0].edges() + +# Build correction with categorical variations +corr = cs.Correction( + name="Pileup", # this should match params.pileupJSONfiles[year]['name'] + description=f"Pileup weights (nominal/up/down) from {root_file}", + version=1, + inputs=[ + cs.Variable(name="nTrueInt", type="real", description="True number of interactions"), + cs.Variable(name="variation", type="string", description="nominal/up/down") + ], + output=cs.Variable(name="weight", type="real"), + data=cs.Category( + nodetype="category", + input="variation", + content=[ + cs.CategoryItem( + key="nominal", + value=cs.Binning( + nodetype="binning", + input="nTrueInt", + edges=edges.tolist(), + content=h_nom.values().tolist(), + flow="clamp" + ) + ), + cs.CategoryItem( + key="up", + value=cs.Binning( + nodetype="binning", + input="nTrueInt", + edges=edges.tolist(), + content=h_up.values().tolist(), + flow="clamp" + ) + ), + cs.CategoryItem( + key="down", + value=cs.Binning( + nodetype="binning", + input="nTrueInt", + edges=edges.tolist(), + content=h_down.values().tolist(), + flow="clamp" + ) + ) + ] + ) +) + +# Wrap into CorrectionSet +cset = cs.CorrectionSet( + schema_version=2, + corrections=[corr] +) + +# Save JSON +with open(output_file, "w") as fout: + fout.write(cset.model_dump_json(indent=2)) + +print(f"Saved correctionlib file to {output_file}") \ No newline at end of file diff --git a/src/hbb/processors/categorizer.py b/src/hbb/processors/categorizer.py index 4ce4c7cf..2e246e1f 100644 --- a/src/hbb/processors/categorizer.py +++ b/src/hbb/processors/categorizer.py @@ -96,6 +96,8 @@ def __init__( self._skim_outpath = skim_outpath self._btag_eff = btag_eff self._btagger, self._btag_wp = "btagPNetB", "M" + if year == "2024": + self._btagger = "btagUParTAK4B" self._btag_cut = b_taggers[self._year]["AK4"][self._btagger][self._btag_wp] self._mupt_type = "ptcorr" diff --git a/src/hbb/taggers.py b/src/hbb/taggers.py index 07bb72e3..bb6a38ae 100644 --- a/src/hbb/taggers.py +++ b/src/hbb/taggers.py @@ -46,5 +46,17 @@ } } + }, + "2024": { + "AK4": { + "btagUParTAK4B" : { #Only tagger supported from 2024 forward + "L" : 0.0246, + "M" : 0.1272, + "T" : 0.4648, + "XT" : 0.6298, + "XXT" : 0.9739 + } + } + } } diff --git a/src/hbb/triggers.json b/src/hbb/triggers.json index cabda1f2..1b0e84d9 100644 --- a/src/hbb/triggers.json +++ b/src/hbb/triggers.json @@ -14,5 +14,9 @@ "2023BPix": [ "AK8PFJet250_SoftDropMass40_PNetBB0p06", "AK8PFJet425_SoftDropMass40" + ], + "2024": [ + "AK8PFJet250_SoftDropMass40_PNetBB0p06", + "AK8PFJet425_SoftDropMass30" ] }