ATLAS Offline Software
Loading...
Searching...
No Matches
JetCalibToolsCfg.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from JetRecConfig.StandardJetConstits import inputsFromContext
4from PathResolver import PathResolver
5
6from AthenaCommon import Logging
7jetcaliblog = Logging.logging.getLogger('JetCalibToolsConfig')
8
9from AthenaConfiguration.Enums import LHCPeriod
10
11all = ['getJetCalibTool']
12
13commonPath = '/eos/atlas/atlascerngroupdisk/perf-jets/JSV/JetCalibToolsMigration/configFiles/'
14
15calibdic_T0 = {
16 "AntiKt4EMPFlow": commonPath+"T0/EMPFlow/JES_MC15cRecommendation_PFlow_Aug2016_rel21.yaml",
17 "AntiKt4EMTopo": commonPath+"T0/EMTopo/JES_MC15cRecommendation_May2016_rel21.yaml",
18 "AntiKt4LCTopo": commonPath+"T0/LCTopo/JES_MC15cRecommendation_May2016_rel21.yaml",
19 "AntiKt10UFOCSSKSoftDropBeta100Zcut10": commonPath+"LatestRecommendations/largeR_Run23/JES_MC20PreRecommendation_R10_UFO_CSSK_SoftDrop_JMS_R21Insitu_26Nov2024.yaml",
20}
21
22calibdic_analysis_Run2 = {
23 "AntiKt4EMPFlow": commonPath+"LatestRecommendations/smallR_mc20_Run2/PreRec_R22_PFlow_ResPU_EtaJES_GSC_February23_230215.yaml",
24 "AntiKt4EMTopo": commonPath+"LatestRecommendations/EMTopo/PreRec_R22_EMTopo_ResPU_EtaJES_October23_231024.yaml",
25 "AntiKt10UFOCSSKSoftDropBeta100Zcut10": commonPath+"LatestRecommendations/largeR_Run23/JES_MC20PreRecommendation_R10_UFO_CSSK_SoftDrop_JMS_R21Insitu_26Nov2024.yaml",
26}
27
28calibdic_analysis_Run3 = {
29 "AntiKt4EMPFlow": commonPath+"LatestRecommendations/smallR_mc23_Run3/AntiKt4EMPFlow_MC23a_PreRecR22_Phase2_CalibConfig_ResPU_EtaJES_GSC_241208_InSitu.yaml",
30 "AntiKt4EMTopo": commonPath+"LatestRecommendations/EMTopo/PreRec_R22_EMTopo_ResPU_EtaJES_October23_231024.yaml",
31 "AntiKt10UFOCSSKSoftDropBeta100Zcut10": commonPath+"LatestRecommendations/largeR_Run23/JES_MC20PreRecommendation_R10_UFO_CSSK_SoftDrop_JMS_R21Insitu_26Nov2024.yaml",
32}
33
34calibdic = {
35 "T0": calibdic_T0,
36 "Run2": calibdic_analysis_Run2,
37 "Run3": calibdic_analysis_Run3,
38}
39
40# This method actually sets up the tool
41def defineJetCalibTool(jetdef, modspec):
42 from JetCalibTools.JetCalibStepsConfig import calibToolFromConfigFile
43
44 # Get the yaml file and calibration sequence
45 cfg, calibSeq, forceCalibSeq = getJetCalibToolSettings(jetdef, modspec)
46 path_configFile = PathResolver.FindCalibFile(cfg)
47 toolname = "jetcalib_new_{0}_{1}".format(jetdef.basename,modspec)
48 jct = calibToolFromConfigFile(jetdef._cflags, path_configFile, toolname, forceCalibSeq, calibSeq)
49
50 return jct
51
52# This method extends the basic config getter to specify the requisite jet
53# moments or other inputs
54def getJetCalibToolPrereqs(jetdef, modspec):
55 from JetCalibTools.JetCalibStepsConfig import load_yaml_cfg
56
57 cfg = calibdic_T0[jetdef.basename]
58 configDic = load_yaml_cfg(cfg)
59
60 prereqs = ["mod:ConstitFourMom"]
61 pvname = "PrimaryVertices" # this can be set dinamically in future
62
63 for step, step_config in configDic.items():
64 # JetArea
65 if step_config.get("DoJetArea", False):
66 if modspec.startswith("Trig"):
67 prereqs.append("input:HLT_EventDensity")
68 elif pvname == "PrimaryVertices_initial":
69 prereqs.append("input:EventDensityCustomVtxGNN")
70 elif pvname != "PrimaryVertices":
71 prereqs.append("input:EventDensityCustomVtx")
72 else:
73 prereqs.append(inputsFromContext("EventDensity")(jetdef))
74
75 # read prereqs from context or default config block
76 prereq_block = step_config.get("prereqs", {})
77 step_prereqs = prereq_block.get(modspec, prereq_block.get("default", []))
78 prereqs.extend(step_prereqs)
79
80 # remove duplication and keep order
81 seen = set()
82 prereqs_unique = []
83 for p in prereqs:
84 if p not in seen:
85 prereqs_unique.append(p)
86 seen.add(p)
87
88 return prereqs_unique
89
90# Get specific settings for JetCalibTools
91def getJetCalibToolSettings(jetdef, modspec):
92
93 calibspecs = modspec.split(':')
94 context = calibspecs[0]
95
96
99
100 # For some specific jet collections, e.g. lepton-free PFlow jets,
101 # we want to apply the calibrations of the default jet PFlow jets
102
103 jetcollection = jetdef.basename
104
105 if "_noElectrons" in jetcollection:
106 jetcollection = jetcollection.replace("_noElectrons","")
107 if "_noMuons" in jetcollection:
108 jetcollection = jetcollection.replace("_noMuons","")
109 if "_noLeptons" in jetcollection :
110 jetcollection = jetcollection.replace("_noLeptons","")
111 if "_tauSeedEleRM" in jetcollection :
112 jetcollection = jetcollection.replace("_tauSeedEleRM","")
113
114
117
118 # Per default, the calibration sequence is determined from the yaml file
119 calibSeq = ""
120 forceCalibSeq = False
121 # Check if specified in configuration (e.g. for low / no pT jet collections)
122 if len(calibspecs) > 2:
123 forceCalibSeq = True
124 calibSeq = calibspecs[2]
125 # Check if T0 configuration, if yes, want to apply only certain calibrations
126 elif context == "T0":
127 forceCalibSeq = True
128 calibSeq = "JetArea_Residual_EtaJES"
129 if jetcollection == "AntiKt10UFOCSSKSoftDropBeta100Zcut10":
130 calibSeq = "EtaJES_JMS"
131
132
135 if context == "AnalysisLatest":
136 if jetdef._cflags.GeoModel.Run == LHCPeriod.Run2:
137 cfg = calibdic["Run2"][jetcollection]
138 elif jetdef._cflags.GeoModel.Run == LHCPeriod.Run3:
139 cfg = calibdic["Run3"][jetcollection]
140 elif jetdef._cflags.GeoModel.Run >= LHCPeriod.Run4:
141 cfg = calibdic["HLLHC"][jetcollection]
142 else:
143 cfg = calibdic[context][jetcollection]
144
145 return cfg, calibSeq, forceCalibSeq
static std::string FindCalibFile(const std::string &logical_file_name)
STL class.
getJetCalibToolSettings(jetdef, modspec)
getJetCalibToolPrereqs(jetdef, modspec)
defineJetCalibTool(jetdef, modspec)