115def getJetCalibTool(jetdef, context, data_type, calibseq = "", rhoname = "", pvname = "PrimaryVertices", gscdepth = "auto"):
117 jetcollection = jetdef.basename
120 if data_type
not in [
'data',
'mc',
'afii']:
121 jetcaliblog.error(
"JetCalibConfig accepts data_type values: 'data', 'mc', 'afii'")
122 raise ValueError(
"Unsupported data_type provided: '{0}".format(data_type))
124 if jetcollection.endswith(
"Jets"):
125 jetcaliblog.error(
"Jet collection '{0}'should be specified w/o 'Jets' in the name.".format(jetcollection))
126 raise ValueError(
"Bad jet collection formatting in getJetCalibTool.")
128 jetcaliblog.debug(
"Preparing calibration for {0}, in context {1} on sample type {2}".format(jetcollection,context,data_type))
130 jetcontexts = calibcontexts[jetcollection]
132 if jetcollection ==
"AntiKt4EMTopo" and context ==
"T0":
133 if jetdef._cflags.GeoModel.Run >= LHCPeriod.Run4:
137 configfile, calibarea, calibseq_def = jetcontexts[context]
138 _calibseq = calibseq
if calibseq
else calibseq_def
143 if _calibseq.endswith(
"Insitu"):
144 if data_type ==
'data':
145 if jetcollection
not in hasInSitu:
146 raise ValueError(
"In situ calibration does not exist for {0}, context {1}".format(jetcollection,context))
148 raise ValueError(
"In situ calibration requested for MC on {0}, context {1}".format(jetcollection,context))
149 _configfile = configfile
150 if data_type ==
"afii" and jetcollection
in af2configs.keys():
151 _configfile = af2configs[jetcollection]
152 _data_type = data_type
159 if "Residual" in _calibseq
or "GSC" in _calibseq
and gscdepth!=
"EM3" or "LargeRDNN" in _calibseq:
162 if context ==
"TrigHIUPC":
165 _jetcollection = jetcollection
166 if "PFlow" in jetcollection
and (context==
"TrigSoftDrop" or context==
"TrigHLTSoftDrop"):
167 _jetcollection = jetcollection.replace(
"EMPFlow",
"UFO")
168 if "_noElectrons" in jetcollection :
169 _jetcollection = _jetcollection.replace(
"_noElectrons",
"")
170 if "_noMuons" in jetcollection :
171 _jetcollection = _jetcollection.replace(
"_noMuons",
"")
172 if "_noLeptons" in jetcollection :
173 _jetcollection = _jetcollection.replace(
"_noLeptons",
"")
174 if "_inclMuons" in jetcollection :
175 _jetcollection = _jetcollection.replace(
"_inclMuons",
"")
176 if "_tauSeedEleRM" in jetcollection :
177 _jetcollection = _jetcollection.replace(
"_tauSeedEleRM",
"")
179 if "ByVertex" in jetcollection:
180 _jetcollection = jetcollection.replace(
"ByVertex",
"")
181 return defineJetCalibTool(_jetcollection, context, _configfile, calibarea, _calibseq, _data_type, rhoname, _pvname, gscdepth)
182 except KeyError
as e:
183 jetcaliblog.error(
"Context '{0}' not found for jet collection '{1}'".format(context,jetcollection))
184 jetcaliblog.error(
"Options are '{0}".format(
','.join(jetcontexts.keys())))
189def defineJetCalibTool(jetcollection, context, configfile, calibarea, calibseq, data_type, rhoname, pvname, gscdepth):
191 calibseqshort =
''.join([ step[0]
for step
in calibseq.split(
'_') ])
192 toolname =
"jetcalib_{0}_{1}_{2}".format(jetcollection,calibseqshort,context)
194 from AthenaConfiguration.ComponentFactory
import CompFactory
195 jct = CompFactory.JetCalibrationTool(toolname,
196 JetCollection = jetcollection,
197 ConfigFile = configfile,
198 CalibArea = calibarea,
199 CalibSequence = calibseq,
200 IsData = (data_type ==
"data"),
202 PrimaryVerticesContainerName = pvname,
212 cfg, calibarea, calibseq = calibcontexts[jetdef.basename][calibcontext]
217 prereqs.append(
"mod:ConstitFourMom")
218 if "JetArea" in calibseq:
219 if calibcontext.startswith(
"Trig"): prereqs.append(
"input:HLT_EventDensity")
220 elif pvname ==
"PrimaryVertices_initial": prereqs.append(
"input:EventDensityCustomVtxGNN")
221 elif pvname !=
"PrimaryVertices": prereqs.append(
"input:EventDensityCustomVtx")
222 else: prereqs.append(inputsFromContext(
"EventDensity")(jetdef))
223 if "GSC" in calibseq:
224 prereqs += [
"mod:CaloEnergies"]
225 if calibcontext !=
"TrigRun2":
226 prereqs += [
"mod:TrackMoments",
228 if "GNNC" in calibseq:
229 prereqs += [
"mod:CaloQuality",
"mod:TrackMoments"]
230 if "CombinedMass" in calibcontext:
231 prereqs += [
"mod:TrackSumMoments"]
232 if "LargeRDNN" in calibseq:
233 prereqs += [
"mod:CaloEnergiesLargeR",
"mod:ConstitFrac",
"mod:groomMRatio",
"mod:Width",
234 "mod:nsubjettiness",
"mod:nsubjettinessR",
"mod:ktsplitter",
"mod:ecorr",
235 "mod:ecorrR",
"mod:qw"]
236 jetcaliblog.debug(
"Prereqs for calibseq '{0}': {1}".format(calibseq,str(prereqs)))
243 rhoname =
"EleRM_Kt4LCTopoOriginEventShape" if jetdef.context ==
"EleRM" else "auto"
244 pvname =
"PrimaryVertices"
246 calibspecs = modspec.split(
':')
248 calibcontext, data_type = calibspecs[:2]
249 if len(calibspecs)>2: calibseq = calibspecs[2]
250 if len(calibspecs)>3: rhoname = calibspecs[3]
251 if len(calibspecs)>4: pvname = calibspecs[4]
252 if len(calibspecs)>5: gscdepth = calibspecs[5]
254 return calibcontext, data_type, calibseq, rhoname, pvname, gscdepth