113def getJetCalibTool(jetdef, context, data_type, calibseq = "", rhoname = "", pvname = "PrimaryVertices", gscdepth = "auto"):
115 jetcollection = jetdef.basename
118 if data_type
not in [
'data',
'mc',
'afii']:
119 jetcaliblog.error(
"JetCalibConfig accepts data_type values: 'data', 'mc', 'afii'")
120 raise ValueError(
"Unsupported data_type provided: '{0}".format(data_type))
122 if jetcollection.endswith(
"Jets"):
123 jetcaliblog.error(
"Jet collection '{0}'should be specified w/o 'Jets' in the name.".format(jetcollection))
124 raise ValueError(
"Bad jet collection formatting in getJetCalibTool.")
126 jetcaliblog.debug(
"Preparing calibration for {0}, in context {1} on sample type {2}".format(jetcollection,context,data_type))
128 jetcontexts = calibcontexts[jetcollection]
130 if jetcollection ==
"AntiKt4EMTopo" and context ==
"T0":
131 if jetdef._cflags.GeoModel.Run >= LHCPeriod.Run4:
135 configfile, calibarea, calibseq_def = jetcontexts[context]
136 _calibseq = calibseq
if calibseq
else calibseq_def
141 if _calibseq.endswith(
"Insitu"):
142 if data_type ==
'data':
143 if jetcollection
not in hasInSitu:
144 raise ValueError(
"In situ calibration does not exist for {0}, context {1}".format(jetcollection,context))
146 raise ValueError(
"In situ calibration requested for MC on {0}, context {1}".format(jetcollection,context))
147 _configfile = configfile
148 if data_type ==
"afii" and jetcollection
in af2configs.keys():
149 _configfile = af2configs[jetcollection]
150 _data_type = data_type
157 if "Residual" in _calibseq
or "GSC" in _calibseq
and gscdepth!=
"EM3" or "LargeRDNN" in _calibseq:
160 if context ==
"TrigHIUPC":
163 _jetcollection = jetcollection
164 if "PFlow" in jetcollection
and (context==
"TrigSoftDrop" or context==
"TrigHLTSoftDrop"):
165 _jetcollection = jetcollection.replace(
"EMPFlow",
"UFO")
166 if "_noElectrons" in jetcollection :
167 _jetcollection = _jetcollection.replace(
"_noElectrons",
"")
168 if "_noMuons" in jetcollection :
169 _jetcollection = _jetcollection.replace(
"_noMuons",
"")
170 if "_noLeptons" in jetcollection :
171 _jetcollection = _jetcollection.replace(
"_noLeptons",
"")
172 if "_tauSeedEleRM" in jetcollection :
173 _jetcollection = _jetcollection.replace(
"_tauSeedEleRM",
"")
175 if "ByVertex" in jetcollection:
176 _jetcollection = jetcollection.replace(
"ByVertex",
"")
177 return defineJetCalibTool(_jetcollection, context, _configfile, calibarea, _calibseq, _data_type, rhoname, _pvname, gscdepth)
178 except KeyError
as e:
179 jetcaliblog.error(
"Context '{0}' not found for jet collection '{1}'".format(context,jetcollection))
180 jetcaliblog.error(
"Options are '{0}".format(
','.join(jetcontexts.keys())))
185def defineJetCalibTool(jetcollection, context, configfile, calibarea, calibseq, data_type, rhoname, pvname, gscdepth):
187 calibseqshort =
''.join([ step[0]
for step
in calibseq.split(
'_') ])
188 toolname =
"jetcalib_{0}_{1}_{2}".format(jetcollection,calibseqshort,context)
190 from AthenaConfiguration.ComponentFactory
import CompFactory
191 jct = CompFactory.JetCalibrationTool(toolname,
192 JetCollection = jetcollection,
193 ConfigFile = configfile,
194 CalibArea = calibarea,
195 CalibSequence = calibseq,
196 IsData = (data_type ==
"data"),
198 PrimaryVerticesContainerName = pvname,
208 cfg, calibarea, calibseq = calibcontexts[jetdef.basename][calibcontext]
213 prereqs.append(
"mod:ConstitFourMom")
214 if "JetArea" in calibseq:
215 if calibcontext.startswith(
"Trig"): prereqs.append(
"input:HLT_EventDensity")
216 elif pvname ==
"PrimaryVertices_initial": prereqs.append(
"input:EventDensityCustomVtxGNN")
217 elif pvname !=
"PrimaryVertices": prereqs.append(
"input:EventDensityCustomVtx")
218 else: prereqs.append(inputsFromContext(
"EventDensity")(jetdef))
219 if "GSC" in calibseq:
220 prereqs += [
"mod:CaloEnergies"]
221 if calibcontext !=
"TrigRun2":
222 prereqs += [
"mod:TrackMoments",
224 if "GNNC" in calibseq:
225 prereqs += [
"mod:CaloQuality",
"mod:TrackMoments"]
226 if "CombinedMass" in calibcontext:
227 prereqs += [
"mod:TrackSumMoments"]
228 if "LargeRDNN" in calibseq:
229 prereqs += [
"mod:CaloEnergiesLargeR",
"mod:ConstitFrac",
"mod:groomMRatio",
"mod:Width",
230 "mod:nsubjettiness",
"mod:nsubjettinessR",
"mod:ktsplitter",
"mod:ecorr",
231 "mod:ecorrR",
"mod:qw"]
232 jetcaliblog.debug(
"Prereqs for calibseq '{0}': {1}".format(calibseq,str(prereqs)))
239 rhoname =
"EleRM_Kt4LCTopoOriginEventShape" if jetdef.context ==
"EleRM" else "auto"
240 pvname =
"PrimaryVertices"
242 calibspecs = modspec.split(
':')
244 calibcontext, data_type = calibspecs[:2]
245 if len(calibspecs)>2: calibseq = calibspecs[2]
246 if len(calibspecs)>3: rhoname = calibspecs[3]
247 if len(calibspecs)>4: pvname = calibspecs[4]
248 if len(calibspecs)>5: gscdepth = calibspecs[5]
250 return calibcontext, data_type, calibseq, rhoname, pvname, gscdepth