-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathJetVetoMap.py
More file actions
54 lines (48 loc) · 2.28 KB
/
JetVetoMap.py
File metadata and controls
54 lines (48 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import os
import ROOT
from .CorrectionsCore import *
# https://twiki.cern.ch/twiki/bin/viewauth/CMS/SWGuideMuonSelection
# https://gitlab.cern.ch/cms-nanoAOD/jsonpog-integration/-/tree/master/POG/MUO
# note: at the beginning of february 2024, the names have been changed to muon_Z.json.gz and muon_HighPt.json.gz for high pT muons
# https://twiki.cern.ch/twiki/bin/view/CMS/MuonUL2018
# https://twiki.cern.ch/twiki/bin/view/CMS/MuonUL2017
# https://twiki.cern.ch/twiki/bin/view/CMS/MuonUL2016
class JetVetoMapProvider:
JME_vetoMap_JsonPath = (
"/cvmfs/cms-griddata.cern.ch/cat/metadata/JME/{}/latest/jetvetomaps.json.gz"
)
initialized = False
jetvetomap_names = {
"2022_Summer22": "Summer22_23Sep2023_RunCD_V1", # period: , entryname
"2022_Summer22EE": "Summer22EE_23Sep2023_RunEFG_V1",
"2023_Summer23BPix": "Summer23BPixPrompt23_RunD_V1",
"2023_Summer23": "Summer23Prompt23_RunC_V1",
"2024_Summer24": "Summer24Prompt24_RunBCDEFGHI_V1",
"2025_Winter25": "Winter25Prompt25_RunCDEFG_V1",
"2025_Summer24": "Winter25Prompt25_RunCDEFG_V1",
}
def __init__(self, era):
period = period_names[era]
entry_name = JetVetoMapProvider.jetvetomap_names[period]
JME_vetoMap_JsonFile = os.path.join(
os.environ["ANALYSIS_PATH"],
JetVetoMapProvider.JME_vetoMap_JsonPath.format(
pog_folder_names["JERC"][period]
),
)
if not JetVetoMapProvider.initialized:
headers_dir = os.path.dirname(os.path.abspath(__file__))
header_path = os.path.join(headers_dir, "JetVetoMap.h")
ROOT.gInterpreter.Declare(f'#include "{header_path}"')
ROOT.gInterpreter.ProcessLine(
f'::correction::JetVetoMapProvider::Initialize("{JME_vetoMap_JsonFile}", "{entry_name}")'
)
JetVetoMapProvider.period = period
JetVetoMapProvider.initialized = True
def GetJetVetoMap(self, df):
# jet pT > 15 GeV, tight jet ID, PU jet ID for CHS jets with pT < 50 GeV, jet EM fraction (charged + neutral) < 0.9
df = df.Define(
f"Jet_isInsideVetoRegion",
f"""::correction::JetVetoMapProvider::getGlobal().GetJetVetoMapValues(Jet_p4)""",
)
return df