Skip to content

Instantly share code, notes, and snippets.

@riga
Last active July 20, 2026 15:43
Show Gist options
  • Select an option

  • Save riga/5aad795980919d23ea6b7df0502a999b to your computer and use it in GitHub Desktop.

Select an option

Save riga/5aad795980919d23ea6b7df0502a999b to your computer and use it in GitHub Desktop.
Event ID based splitting of 2024 MC samples into 2024, 2025 and 2026 parts.

Event ID based splitting of 2024 MC samples into 2024, 2025 and 2026 parts

The snippets below demonstrate how to split MC events originally intended for the 2024 data-taking period into orthogonal parts that can be used to simulate the 2024, 2025 and 2026 data-taking periods. The splitting is done event-by-event and only depends on the event ID. The underlying algorithm is deterministic and splits events into three parts with frequencies that reflect the relative recorded luminosities in 2024, 2025 and 2026.

The unbiased behavior is strictly necessary to avoid that algorithms based on event IDs that are used downstream in analyses see a bias towards specific event IDs in any of the three years. For instance, event splitting for ML training / validation purposes, usually done via (e.g.) event % 2 == 0 or alike, should remain statistically unaffected. If there was a bias in the event ID distribution, this would lead to skewed training and validation datasets, which is not desirable.

Usage

import correctionlib as clib

cset = correctionlib.CorrectionSet.from_file("mc_event_splitter.json")
splitter = cset["mc_event_splitter"]

# note that event numbers must be passed as float values
splitter.evaluate(16849655.0)
# -> 2026.0
{
"schema_version": 2,
"corrections": [
{
"name": "mc_event_splitter",
"description": "Event number based splitting of 2024 MC events into orthogonal parts for 2024, 2025 and 2026 with frequencies corresponding to recorded luminosities, taken from https://twiki.cern.ch/twiki/bin/view/CMSPublic/LumiPublicResults?rev=213. See https://gist.github.com/riga/f9476f3b1477f1609683bea68ae64897 for more info.",
"version": 1,
"inputs": [
{
"name": "event",
"type": "real",
"description": "event number (float!)"
}
],
"output": {
"name": "year",
"type": "real",
"description": "assigned year (float!); one of 2024, 2025, 2026"
},
"data": {
"nodetype": "transform",
"input": "event",
"rule": {
"nodetype": "hashprng",
"inputs": [
"event"
],
"distribution": "stdflat"
},
"content": {
"nodetype": "formula",
"parser": "TFormula",
"variables": [
"event"
],
"expression": "2024 * (x < 0.43697) + 2025 * (x >= 0.43697) * (x < 0.88228) + 2026 * (x >= 0.88228)"
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment