10 from JetRecConfig.JetDefinition
import JetInputConstitSeq,JetInputConstit, xAODType, JetInputType, JetDefinition, formatRvalue
11 from JetRecConfig.JetGrooming
import GroomingDefinition
12 from ..Menu.SignatureDicts
import JetRecoKeys
as recoKeys
14 from .
import TriggerJetMods
18 from AthenaCommon.Logging
import logging
19 log = logging.getLogger(__name__)
36 if p[
'trigType'] ==
'j':
45 if jetRecoDict[
'ionopt']==
'ion':
48 return jetRecoDict[
'recoAlg'] +
"_ion"
49 strtemp =
"{recoAlg}_{constitMod}{constitType}_{clusterCalib}_{jetCalib}"
51 strtemp +=
"_{trkopt}"
52 return strtemp.format(**jetRecoDict)
64 if k
in recoDict.keys():
65 if p[k] != recoDict[k]:
66 raise RuntimeError(
'Inconsistent reco setting for %s' % k)
71 if recoDict[
'jetCalib'] ==
"default":
84 from TriggerMenuMT.HLT.Menu.SignatureDicts
import JetChainParts,JetChainParts_Default
88 for part
in jet_def_string.split(
'_'):
89 if part
in JetChainParts[tmp_key]:
90 jetRecoDict[key] = part
93 jetRecoDict[key] = JetChainParts_Default[key]
96 if jetRecoDict[
'jetCalib'] ==
"default":
97 jetRecoDict[
'jetCalib'] =
getJetCalibDefaultString(jetRecoDict[
'recoAlg'],jetRecoDict[
'constitType'],jetRecoDict[
'trkopt'])
106 newJetRecoDict = copy.copy(jetRecoDict)
107 newJetRecoDict.update(dict(**kwargs))
109 return newJetRecoDict
120 if isinstance(jetDef,GroomingDefinition):
121 _jetDef = jetDef.ungroomeddef
123 if jetDef.groomSpecAsStr().startswith(
'Trimmed'):
125 elif jetDef.groomSpecAsStr().startswith(
'SoftDrop'):
128 raise ValueError(
'Unsupported grooming type for HLT')
129 elif jetDef.inputdef.jetinputtype == JetInputType.Jet:
133 algstr = f
'{str.lower(_jetDef.algorithm[0])}{formatRvalue(_jetDef._radius)}{poststr}'
134 constitdef = _jetDef.inputdef
135 if constitdef.label ==
'HI':
138 clusterCalib =
'lcw' if 'LC' in constitdef.label
else 'em'
139 constittype =
'pf' if 'PFlow' in constitdef.label
else 'tc'
141 if isinstance(constitdef,JetInputConstitSeq):
142 ignore = [
'EM',
'LC',
'CHS',
'CorrectPFO']
143 for mod
in constitdef.modifiers:
144 if mod
not in ignore:
145 constitmods += str.lower(mod)
146 constitstr = f
'{constitmods}{constittype}_{clusterCalib}'
147 jetdefstr = f
'{algstr}_{constitstr}{jetDef.suffix}'
152 jetCalib = jetDef.suffix[1:]
153 if jetCalib.endswith(
'_ftf'):
154 jetCalib = jetCalib[:-4]
167 jetalg, jetradius, jetextra = re.split(
r'(\d+)',recoAlg)
168 return jetalg,
int(jetradius), jetextra
174 return jetRecoDict[
"trkopt"]!=
"notrk" and (jetRecoDict[
"constitType"]!=
"tc" or jetRecoDict[
"recoAlg"]
in [
'a2',
'a4',
'a10'])
178 return jetRecoDict[
"trkopt"]!=
"notrk"
181 return jetRecoDict[
"trkopt"]==
"ftf"
185 isPFlow = jetRecoDict[
"constitType"] ==
"pf"
187 raise ValueError(
"This is a PFlow chain but an incompatible tracking option is given!")
192 return {
"a2":4000,
"a4":4000,
"a10":50000,
"a10r": 50000,
"a10t":50000,
"a10sd":50000}[recoAlg]
196 flags.addFlag(
"Jet.Context.notrk",
lambda prevFlags : prevFlags.Jet.Context.default )
199 def _buildContextDic(prevFlags, trkopt):
201 idFlags = prevFlags.Trigger.InDetTracking
202 (tracksname,verticesname) = {
203 'ftf': (idFlags.fullScan.tracks_FTF,
204 idFlags.fullScan.vertex),
205 'roiftf': (idFlags.jetSuper.tracks_FTF,
206 idFlags.jetSuper.vertex),
209 tvaname = f
"JetTrackVtxAssoc_{trkopt}"
210 label = f
"GhostTrack_{trkopt}"
211 ghosttracksname = f
"PseudoJet{label}"
213 contextDic = prevFlags.Jet.Context.default.clone(
215 Vertices = verticesname,
217 GhostTracks = ghosttracksname,
218 GhostTracksLabel = label ,
219 JetTracks = f
'JetSelectedTracks_{trkopt}',
224 from JetRecConfig.StandardJetConstits
import stdInputExtDic
225 if tracksname
not in stdInputExtDic:
226 from JetRecConfig.JetDefinition
import JetInputExternal
227 from xAODBase.xAODType
import xAODType
228 stdInputExtDic[tracksname] = JetInputExternal( tracksname, xAODType.TrackParticle )
229 stdInputExtDic[verticesname] = JetInputExternal( verticesname, xAODType.Vertex )
236 flags.addFlag(
"Jet.Context.ftf",
lambda prevFlags : _buildContextDic(prevFlags,
"ftf") )
237 flags.addFlag(
"Jet.Context.roiftf",
lambda prevFlags : _buildContextDic(prevFlags,
"roiftf") )
250 if recoDict[
'ionopt'] ==
'ion':
251 return "HLT_HICaloClustersFS"
252 clusterCalib = recoDict[
"clusterCalib"]
253 if clusterCalib ==
"em":
254 from ..CommonSequences.FullScanDefs
import em_clusters
256 elif clusterCalib ==
"lcw":
257 from ..CommonSequences.FullScanDefs
import lc_clusters
260 raise ValueError(
"Invalid value for calib: '{}'".
format(clusterCalib))
263 if recoAlg ==
'a4' or recoAlg ==
'a2':
264 if constitType ==
'tc':
265 return 'subresjesgscIS' if trkopt ==
'ftf' else 'subjesIS'
266 elif constitType ==
'pf':
267 return 'subresjesgscIS'
268 elif recoAlg ==
'a10':
270 elif recoAlg ==
'a10t':
272 elif recoAlg ==
'a10sd':
274 elif recoAlg ==
'a10r':
277 raise RuntimeError(f
'No default calibration is defined for {recoAlg}, {constitType}, {trkopt}')
280 'CLEANlb':
'LooseBad',
281 'CLEANllp':
'LooseBadLLP',
285 found_cleanings= [ci
for ck, ci
in cleaningDict.items()
if ck
in prefilters_list]
286 if len(found_cleanings) <= 1:
287 return 'noCleaning' if len(found_cleanings) == 0
else found_cleanings[0]
290 'Multijet jet cleanings found in jet trigger reco dictionary {}. Multiple jet cleanings are currently unsupported'.
format(found_cleanings))
302 jetalg = jetRecoDict[
"recoAlg"]
303 if jetRecoDict[
"jetCalib"] ==
"nojcalib" or jetalg==
"a10r":
307 if not dotracking
and "gsc" in jetRecoDict[
"jetCalib"]:
308 raise ValueError(
"Track GSC requested but no track source provided!")
310 if not dotracking
and "subres" in jetRecoDict[
"jetCalib"]:
311 raise ValueError(
"Pileup residual calibration requested but no track source provided!")
313 if jetRecoDict[
"constitType"] ==
"tc":
314 calibKey = flags.Trigger.Jet.emtopoCalibKey
315 calibContext,calibSeq = {
316 (
"a4",
"subjes"): (calibKey,
"JetArea_EtaJES_GSC"),
317 (
"a4",
"subjesIS"): (calibKey,
"JetArea_EtaJES_GSC"),
318 (
"a4",
"subjesgscIS"): (calibKey,
"JetArea_EtaJES_GSC"),
319 (
"a4",
"subresjesgscIS"): (calibKey,
"JetArea_Residual_EtaJES_GSC"),
320 (
"a4",
"subjesgsc"): (calibKey,
"JetArea_EtaJES_GSC"),
321 (
"a4",
"subresjesgsc"): (calibKey,
"JetArea_Residual_EtaJES_GSC"),
322 (
"a10",
"subjes"): (
"TrigUngroomed",
"JetArea_EtaJES"),
323 (
"a10t",
"jes"): (
"TrigTrimmed",
"EtaJES_JMS"),
324 }[(jetRecoDict[
"recoAlg"],jetRecoDict[
"jetCalib"])]
328 if "gsc" in jetRecoDict[
"jetCalib"]:
329 gscDepth =
"trackWIDTH"
330 pvname = flags.Trigger.InDetTracking.fullScan.vertex_jet
332 elif jetRecoDict[
"constitType"] ==
"pf":
334 if 'sd' in jetRecoDict[
"recoAlg"]:
335 calibContext = flags.Trigger.Jet.pflowLJCalibKey
336 calibSeq =
"EtaJES_JMS"
338 calibKey = flags.Trigger.Jet.pflowCalibKey
339 gscDepth =
"trackWIDTH"
340 if "gsc" not in jetRecoDict[
"jetCalib"]:
342 calibContext,calibSeq = {
343 (
"a4",
"jes"): (calibKey,
"EtaJES_GSC"),
344 (
"a4",
"subjesgsc"): (calibKey,
"JetArea_EtaJES_GSC"),
345 (
"a4",
"subresjesgsc"): (calibKey,
"JetArea_Residual_EtaJES_GSC"),
346 (
"a4",
"subjesgscIS"): (calibKey,
"JetArea_EtaJES_GSC"),
347 (
"a4",
"subresjesgscIS"): (calibKey,
"JetArea_Residual_EtaJES_GSC"),
348 }[(jetRecoDict[
"recoAlg"],jetRecoDict[
"jetCalib"])]
349 pvname = flags.Trigger.InDetTracking.fullScan.vertex_jet
350 if jetRecoDict[
"jetCalib"].endswith(
"IS")
and (
not flags.Input.isMC):
351 calibSeq +=
"_Insitu"
353 dataSource =
"mc" if flags.Input.isMC
else "data"
354 calibSpec =
":".
join( [calibContext, dataSource, calibSeq, rhoKey, pvname, gscDepth] )
357 calibMods = [
"EMScaleMom",
358 "ConstitFourMom_copy",
362 calibMods = [
"ConstitFourMom_copy",
370 return (TriggerJetMods.stdJetModifiers[modname],
str(modspec))
380 decorlist += [
'AlgorithmType',
'InputType',
381 'ActiveArea',
'ActiveArea4vec_eta',
'ActiveArea4vec_m',
382 'ActiveArea4vec_phi',
'ActiveArea4vec_pt',
383 'EMFrac',
'HECFrac',
'EnergyPerSampling',
'N90Constituents',
'constit',
'Tile0Frac']
385 if jetDef.context ==
'ftf':
386 decorlist += [
"GhostTrack_ftf",
387 "NumTrkPt500",
"NumTrkPt1000",
388 "SumPtTrkPt500",
"SumPtTrkPt1000",
390 "JVFCorr",
"JvtRpt",
"Jvt"]
391 if 'PFlow' in jetDef.basename:
392 decorlist += [
"SumPtChargedPFOPt500"]
408 if jetRecoDict[
"constitType"] ==
"pf":
409 if pfoPrefix
is None:
410 raise RuntimeError(
"JetRecoCommon: Cannot define PF jets without pfo prefix!")
412 constitMods = [
"CorrectPFO"]
414 if "vs" in jetRecoDict[
"constitMod"]:
415 constitMods.append(
"Vor")
416 if "cs" in jetRecoDict[
"constitMod"]:
417 constitMods.append(
"CS")
418 if "sk" in jetRecoDict[
"constitMod"]:
419 constitMods.append(
"SK")
420 constitMods += [
"CHS"]
422 inputPFO = pfoPrefix+
"ParticleFlowObjects"
423 modstring =
''.
join(constitMods[1:-1])
427 inputxAODType = xAODType.FlowElement
429 jetConstit = JetInputConstitSeq(
"HLT_EMPFlow", inputxAODType, constitMods, inputname=inputPFO, outputname=pfoPrefix+
"CHSParticleFlowObjects", label=
"EMPFlow", jetinputtype=
"EMPFlow")
431 jetConstit = JetInputConstitSeq(
"HLT_EMPFlow"+modstring, inputxAODType, constitMods, inputname=inputPFO, outputname=pfoPrefix+modstring+
"ParticleFlowObjects",label=
'EMPFlow'+(modstring
if modstring!=
'CHS' else ''), jetinputtype=
"EMPFlow" )
434 if jetRecoDict[
"constitType"] ==
"tc":
436 if "vs" in jetRecoDict[
"constitMod"]:
437 constitMods.append(
"Vor")
438 if "cs" in jetRecoDict[
"constitMod"]:
439 constitMods.append(
"CS")
440 if "sk" in jetRecoDict[
"constitMod"]:
441 constitMods.append(
"SK")
443 modstring =
''.
join(constitMods)
445 if jetRecoDict[
"clusterCalib"] ==
"em":
446 constitMods = [
"EM"] + constitMods
447 elif jetRecoDict[
"clusterCalib"] ==
"lcw":
448 constitMods = [
"LC"] + constitMods
450 log.error(
"cluster calib state not recognised : ",jetRecoDict[
"clusterCalib"])
452 raise ValueError(
"cluster key must be provided for topocluster jets.")
456 jetConstit = JetInputConstitSeq(
"HLT_EMTopo",xAODType.CaloCluster, constitMods, inputname=clustersKey, outputname=clustersKey+modstring,label=
'EMTopo'+modstring)
458 jetConstit = JetInputConstitSeq(
"HLT_"+constitMods[0]+
"Topo",xAODType.CaloCluster, constitMods, inputname=clustersKey, outputname=clustersKey+modstring,label=constitMods[0]+
'Topo'+modstring)
461 from JetRecConfig.StandardJetConstits
import stdConstitDic
462 stdConstitDic.setdefault(jetConstit.name, jetConstit)
469 def defineJets(flags,jetRecoDict,clustersKey=None,prefix='',suffix='',pfoPrefix=None):
479 filter_type =
"lowpt" if flags.Trigger.Jet.LowPtFilter
else "default"
481 actualradius =
float(jetradius)/10
484 suffix=
"_"+jetRecoDict[
"jetCalib"]+
'_'*(suffix.strip()!=
'')+suffix
486 suffix +=
"_"+jetRecoDict[
"trkopt"]
488 jetDef = JetDefinition(
"AntiKt", actualradius, jetConstit, ptmin=minpt[filter_type][jetradius], prefix=prefix, suffix=suffix, context=jetRecoDict[
"trkopt"])
492 rcJetConstit = JetInputConstit(
"RCJet", xAODType.Jet, smallRjets, label=inputlabel+
'RC', lock=
True)
493 rcJetDef = JetDefinition(
"AntiKt", 1.0, rcJetConstit, prefix=prefix, suffix=suffix, context=jetRecoDict[
'trkopt'])
497 from JetRecConfig.JetGrooming
import JetTrimming, JetSoftDrop
498 groomAlg = jetRecoDict[
"recoAlg"][3:]
if 'sd' in jetRecoDict[
"recoAlg"]
else jetRecoDict[
"recoAlg"][-1]
499 suffix =
"_"+ jetRecoDict[
"jetCalib"]
501 suffix +=
"_"+jetRecoDict[
"trkopt"]
504 "sd":
JetSoftDrop(ungroomedDef,ZCut=0.1,Beta=1.0,suffix=suffix,context=jetRecoDict[
'trkopt']),
505 "t" :JetTrimming(ungroomedDef,RClus=0.2,PtFrac=0.04,suffix=suffix,context=jetRecoDict[
'trkopt']),
511 jetconstit = JetInputConstit(
"PV0Track", xAODType.TrackParticle,
"PV0JetSelectedTracks_ftf")
512 VRTrackJetDef = JetDefinition(
"AntiKt", Rmax, jetconstit, ptmin=Ptmin, VRMinR=Rmin, VRMassSc=VRMassScale, prefix=prefix, suffix=suffix, lock=
True)
517 minpt = {2:7000, 3:7000, 4:7000, 6:7000, 10:50000}
519 actualradius =
float(jetradius)/10
522 jetConstit = JetInputConstitSeq(
"HLT_HIConstit",xAODType.CaloCluster, constitMods, inputname=clustersKey, outputname=clustersKey,label=
'HI')
523 from JetRecConfig.StandardJetConstits
import stdConstitDic
524 stdConstitDic.setdefault(jetConstit.name, jetConstit)
526 jetDef = JetDefinition(
"AntiKt", actualradius, jetConstit, ptmin=minpt[jetradius], prefix=prefix, suffix=suffix)