112 def getJetCalibTool(jetdef, context, data_type, calibseq = "", rhoname = "", pvname = "PrimaryVertices", gscdepth = "auto"):
114 jetcollection = jetdef.basename
117 if data_type
not in [
'data',
'mc',
'afii']:
118 jetcaliblog.error(
"JetCalibConfig accepts data_type values: 'data', 'mc', 'afii'")
119 raise ValueError(
"Unsupported data_type provided: '{0}".
format(data_type))
121 if jetcollection.endswith(
"Jets"):
122 jetcaliblog.error(
"Jet collection '{0}'should be specified w/o 'Jets' in the name.".
format(jetcollection))
123 raise ValueError(
"Bad jet collection formatting in getJetCalibTool.")
125 jetcaliblog.debug(
"Preparing calibration for {0}, in context {1} on sample type {2}".
format(jetcollection,context,data_type))
127 jetcontexts = calibcontexts[jetcollection]
129 if jetcollection ==
"AntiKt4EMTopo" and context ==
"T0":
130 if jetdef._cflags.GeoModel.Run >= LHCPeriod.Run4:
134 configfile, calibarea, calibseq_def = jetcontexts[context]
135 _calibseq = calibseq
if calibseq
else calibseq_def
140 if _calibseq.endswith(
"Insitu"):
141 if data_type ==
'data':
142 if jetcollection
not in hasInSitu:
143 raise ValueError(
"In situ calibration does not exist for {0}, context {1}".
format(jetcollection,context))
145 raise ValueError(
"In situ calibration requested for MC on {0}, context {1}".
format(jetcollection,context))
146 _configfile = configfile
147 if data_type ==
"afii" and jetcollection
in af2configs.keys():
148 _configfile = af2configs[jetcollection]
149 _data_type = data_type
156 if "Residual" in _calibseq
or "GSC" in _calibseq
and gscdepth!=
"EM3" or "LargeRDNN" in _calibseq:
159 if context ==
"TrigHIUPC":
162 _jetcollection = jetcollection
163 if "PFlow" in jetcollection
and (context==
"TrigSoftDrop" or context==
"TrigHLTSoftDrop"):
164 _jetcollection = jetcollection.replace(
"EMPFlow",
"UFO")
165 if "_noElectrons" in jetcollection :
166 _jetcollection = _jetcollection.replace(
"_noElectrons",
"")
167 if "_noMuons" in jetcollection :
168 _jetcollection = _jetcollection.replace(
"_noMuons",
"")
169 if "_noLeptons" in jetcollection :
170 _jetcollection = _jetcollection.replace(
"_noLeptons",
"")
172 if "ByVertex" in jetcollection:
173 _jetcollection = jetcollection.replace(
"ByVertex",
"")
174 return defineJetCalibTool(_jetcollection, context, _configfile, calibarea, _calibseq, _data_type, rhoname, _pvname, gscdepth)
175 except KeyError
as e:
176 jetcaliblog.error(
"Context '{0}' not found for jet collection '{1}'".
format(context,jetcollection))
177 jetcaliblog.error(
"Options are '{0}".
format(
','.
join(jetcontexts.keys())))