117def getJetCalibTool(jetdef, context, data_type, calibseq = "", rhoname = "", pvname = "PrimaryVertices", gscdepth = "auto"):
119 jetcollection = jetdef.basename
122 if data_type
not in [
'data',
'mc',
'afii']:
123 jetcaliblog.error(
"JetCalibConfig accepts data_type values: 'data', 'mc', 'afii'")
124 raise ValueError(
"Unsupported data_type provided: '{0}".format(data_type))
126 if jetcollection.endswith(
"Jets"):
127 jetcaliblog.error(
"Jet collection '{0}'should be specified w/o 'Jets' in the name.".format(jetcollection))
128 raise ValueError(
"Bad jet collection formatting in getJetCalibTool.")
130 jetcaliblog.debug(
"Preparing calibration for {0}, in context {1} on sample type {2}".format(jetcollection,context,data_type))
132 jetcontexts = calibcontexts[jetcollection]
134 if jetcollection ==
"AntiKt4EMTopo" and context ==
"T0":
135 if jetdef._cflags.GeoModel.Run >= LHCPeriod.Run4:
139 configfile, calibarea, calibseq_def = jetcontexts[context]
140 _calibseq = calibseq
if calibseq
else calibseq_def
145 if _calibseq.endswith(
"Insitu"):
146 if data_type ==
'data':
147 if jetcollection
not in hasInSitu:
148 raise ValueError(
"In situ calibration does not exist for {0}, context {1}".format(jetcollection,context))
150 raise ValueError(
"In situ calibration requested for MC on {0}, context {1}".format(jetcollection,context))
151 _configfile = configfile
152 if data_type ==
"afii" and jetcollection
in af2configs.keys():
153 _configfile = af2configs[jetcollection]
154 _data_type = data_type
161 if "Residual" in _calibseq
or "GSC" in _calibseq
and gscdepth!=
"EM3" or "LargeRDNN" in _calibseq:
164 if context ==
"TrigHIUPC":
167 _jetcollection = jetcollection
168 if "PFlow" in jetcollection
and (context==
"TrigSoftDrop" or context==
"TrigHLTSoftDrop"):
169 _jetcollection = jetcollection.replace(
"EMPFlow",
"UFO")
174 '_noElectrons',
'_noMuons',
'_noLeptons',
'_inclMuons',
176 'ByVertex',
'CustomVtxGNN',
'CustomVtx',
178 for text
in ignore_substr:
179 if text
in jetcollection :
180 _jetcollection = _jetcollection.replace(text,
"")
182 return defineJetCalibTool(_jetcollection, context, _configfile, calibarea, _calibseq, _data_type, rhoname, _pvname, gscdepth)
183 except KeyError
as e:
184 jetcaliblog.error(
"Context '{0}' not found for jet collection '{1}'".format(context,jetcollection))
185 jetcaliblog.error(
"Options are '{0}".format(
','.join(jetcontexts.keys())))
190def defineJetCalibTool(jetcollection, context, configfile, calibarea, calibseq, data_type, rhoname, pvname, gscdepth):
192 calibseqshort =
''.join([ step[0]
for step
in calibseq.split(
'_') ])
193 toolname =
"jetcalib_{0}_{1}_{2}".format(jetcollection,calibseqshort,context)
195 from AthenaConfiguration.ComponentFactory
import CompFactory
196 jct = CompFactory.JetCalibrationTool(toolname,
197 JetCollection = jetcollection,
198 ConfigFile = configfile,
199 CalibArea = calibarea,
200 CalibSequence = calibseq,
201 IsData = (data_type ==
"data"),
203 PrimaryVerticesContainerName = pvname,
213 cfg, calibarea, calibseq = calibcontexts[jetdef.basename][calibcontext]
218 prereqs.append(
"mod:ConstitFourMom")
219 if "JetArea" in calibseq:
220 if calibcontext.startswith(
"Trig"): prereqs.append(
"input:HLT_EventDensity")
221 elif pvname ==
"PrimaryVertices_initial": prereqs.append(
"input:EventDensityCustomVtxGNN")
222 elif pvname !=
"PrimaryVertices": prereqs.append(
"input:EventDensityCustomVtx")
223 else: prereqs.append(inputsFromContext(
"EventDensity")(jetdef))
224 if "GSC" in calibseq:
225 prereqs += [
"mod:CaloEnergies"]
226 if calibcontext !=
"TrigRun2":
227 prereqs += [
"mod:TrackMoments",
229 if "GNNC" in calibseq:
230 prereqs += [
"mod:CaloQuality",
"mod:TrackMoments"]
231 if "CombinedMass" in calibcontext:
232 prereqs += [
"mod:TrackSumMoments"]
233 if "LargeRDNN" in calibseq:
234 prereqs += [
"mod:CaloEnergiesLargeR",
"mod:ConstitFrac",
"mod:groomMRatio",
"mod:Width",
235 "mod:nsubjettiness",
"mod:nsubjettinessR",
"mod:ktsplitter",
"mod:ecorr",
236 "mod:ecorrR",
"mod:qw"]
237 jetcaliblog.debug(
"Prereqs for calibseq '{0}': {1}".format(calibseq,str(prereqs)))
244 rhoname =
"EleRM_Kt4LCTopoOriginEventShape" if jetdef.context ==
"EleRM" else "auto"
245 pvname =
"PrimaryVertices"
247 calibspecs = modspec.split(
':')
249 calibcontext, data_type = calibspecs[:2]
250 if len(calibspecs)>2: calibseq = calibspecs[2]
251 if len(calibspecs)>3: rhoname = calibspecs[3]
252 if len(calibspecs)>4: pvname = calibspecs[4]
253 if len(calibspecs)>5: gscdepth = calibspecs[5]
255 return calibcontext, data_type, calibseq, rhoname, pvname, gscdepth