5 StandardJetConstits: A module containing standard definitions for jet inputs : external container and
7 These can be copied and modified by users who want something a bit
8 different from what is provided.
10 Author: TJ Khoo, P-A Delsart
16from .JetDefinition
import xAODType, JetInputConstitSeq, JetInputExternal, JetConstitModifier, JetInputConstit
17from .StandardJetContext
import inputsFromContext, propFromContext
18from .JetRecConfig
import isAnalysisRelease
19from AthenaConfiguration.Enums
import BeamType
20from JetRecConfig.JetRecCommon
import isMC
25from .Utilities
import ldict
33import JetRecConfig.JetInputConfig
as inputcfg
35 import JetRecTools.JetRecToolsConfig
as jrtcfg
36except ModuleNotFoundError:
41 import TrackCaloClusterRecTools.TrackCaloClusterConfig
as tcccfg
42except ModuleNotFoundError:
47 """Returns a helper function which invokes the standard reco configuration for the container 'input'
48 (where input is external to the jet domain).
50 We group the definition of functions here rather than separately, so that we can change them
51 automatically to a void function in case we're in an Analysis release and we can not import upstream packages.
55 doNothingFunc =
lambda *l:
None
56 if isAnalysisRelease():
60 if input==
'CaloClusters':
62 from CaloRec.CaloRecoConfig
import CaloRecoCfg
63 flags = jetdef._cflags
64 return CaloRecoCfg(flags)
if flags.Jet.doUpstreamDependencies
else None
67 from InDetConfig.TrackRecoConfig
import InDetTrackRecoCfg
68 flags = jetdef._cflags
69 return InDetTrackRecoCfg(flags)
if flags.Jet.doUpstreamDependencies
else None
72 from MuonConfig.MuonReconstructionConfig
import MuonReconstructionCfg
73 flags = jetdef._cflags
74 return MuonReconstructionCfg(flags)
if flags.Jet.doUpstreamDependencies
else None
77 if not jetdef._cflags.Jet.doUpstreamDependencies:
79 from eflowRec.PFRun3Config
import PFCfg
80 return PFCfg(jetdef._cflags)
81 elif input==
"DressedWZ":
83 from DerivationFrameworkMCTruth.MCTruthCommonConfig
import PreJetMCTruthAugmentationsCfg
84 return PreJetMCTruthAugmentationsCfg(jetdef._cflags,decorationDressing=
'dressedPhoton')
97 warning =
"Tracking is disabled and no InDetTrackParticles in input"
98 if "InDetTrackParticles" in flags.Input.Collections:
100 if isAnalysisRelease():
103 return False, warning
104 return flags.Reco.EnableTracking, warning
107 warning =
"Muon reco is disabled"
108 if "MuonSegments" in flags.Input.Collections:
110 if isAnalysisRelease():
112 return False, warning
113 return flags.Reco.EnableCombinedMuon, warning
116 warning =
"UnAssociated muon segments not present"
117 if "UnAssocMuonSegments" in flags.Input.Collections:
119 if flags.Input.RunNumbers[0] < 410000:
121 return False, warning
122 if isAnalysisRelease():
124 return False, warning
125 return flags.Reco.EnableCombinedMuon, warning
128 warning =
"Large radius tracking did not run"
129 if "InDetLargeD0TrackParticles" in flags.Input.Collections:
138 if isAnalysisRelease()
or flags.Tracking.doLargeD0:
140 return False, warning
144 from CaloRec.CaloClusterMLCalibAlgLiteConfig
import CaloClusterMLCalibAlgLiteCfg
145 return CaloClusterMLCalibAlgLiteCfg(flags._cflags)
149 from eflowRec.PFRun3Config
import PFOClusterMLCorrectionAlgorithmBuilder
150 return PFOClusterMLCorrectionAlgorithmBuilder(flags._cflags, spec)
171 prereqs = [inputsFromContext(
"Tracks"),
"input:CaloCalTopoClusters"],
175 algoBuilder = inputcfg.buildPFlowSel,
176 prereqs = [
"input:JetETMissParticleFlowObjects", ],
180 prereqs = [
"input:GlobalParticleFlowObjects",
"input:CaloCalTopoClusters",
"input:CaloCalTopoClustersML"],
183 JetInputExternal(
"GlobalParticleFlowObjects_noElectrons", xAODType.FlowElement,
184 algoBuilder = inputcfg.buildPFlowSel_noElectrons,
185 prereqs = [
"input:JetETMissParticleFlowObjects", ],
189 algoBuilder = inputcfg.buildPFlowSel_noMuons,
190 prereqs = [
"input:JetETMissParticleFlowObjects", ],
193 JetInputExternal(
"GlobalParticleFlowObjects_noLeptons", xAODType.FlowElement,
194 algoBuilder = inputcfg.buildPFlowSel_noLeptons,
195 prereqs = [
"input:JetETMissParticleFlowObjects", ],
199 JetInputExternal(
"GlobalParticleFlowObjects_inclMuons", xAODType.FlowElement,
200 algoBuilder = inputcfg.buildPFlowSel_inclMuons,
201 prereqs = [
"input:JetETMissParticleFlowObjects", ],
204 JetInputExternal(
"GlobalParticleFlowObjects_tauSeedEleRM", xAODType.FlowElement,
205 algoBuilder = inputcfg.buildPFlowSel_tauSeedEleRM,
206 prereqs = [
"input:JetETMissParticleFlowObjects", ],
212 filterfn = _trackParticleInputsExist
218 prereqs = [inputsFromContext(
"Tracks")],
219 filterfn =
lambda flags : (flags.Beam.Type == BeamType.Collisions, f
"No vertexing with {flags.Beam.Type}"),
223 prereqs= [ inputsFromContext(
"Tracks") ],
224 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
228 prereqs= [ inputsFromContext(
"Tracks") ],
229 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
233 prereqs= [ inputsFromContext(
"Tracks") ],
234 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
238 prereqs= [ inputsFromContext(
"Tracks") ],
239 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
244 prereqs= [ inputsFromContext(
"Tracks") ],
245 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
True )
248 prereqs= [ inputsFromContext(
"Tracks") ,
249 inputsFromContext(
"Vertices")],
250 algoBuilder = inputcfg.buildJetTrackUsedInFitDeco
254 lambda jdef, _ : jrtcfg.getJetTrackVtxAlg(
256 algname=
"jetTVA" if jdef.context
in [
"HL_LHC",
"default",
"notrk",
""]
else f
"jetTVA_{jdef.context}",
257 WorkingPoint=
"Nonprompt_All_MaxWeight"
260 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices")],
264 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
266 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices") ]
269 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
271 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices") ]
274 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
276 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices") ]
279 JetInputExternal(
"EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
280 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
281 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name]
284 JetInputExternal(
"EleRM_EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
285 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
286 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name],
289 JetInputExternal(
"HLT_EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
290 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
291 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name],
297 prereqs = [inputsFromContext(
"Tracks")],
298 filterfn = _muonSegmentInputsExist
302 prereqs = [inputsFromContext(
"Tracks")],
303 filterfn = _unassocMuonSegmentInputsExist
311 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC ),
317 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"NoWZ"),
323 prereqs = [
"input:DressedObjects"],
324 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"DressedWZ"),
332 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"Charged"),
338 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC ),
341 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC,specs=
"NoWZ"),
346 prereqs=[
"input:JetSelectedTracks_trackSelOpt",
"input:JetTrackUsedInFitDeco"],
347 algoBuilder = inputcfg.buildPV0TrackSel ),
352 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK'],
353 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
354 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK'])
358 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noElectrons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noElectrons'],
359 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noElectrons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
360 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noElectrons'])
364 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noMuons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noMuons'],
365 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noMuons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
366 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noMuons'])
371 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noLeptons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noLeptons'],
372 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noLeptons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
373 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noLeptons'])
378 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_inclMuons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_inclMuons'],
379 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_inclMuons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
380 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_inclMuons'])
386 prereqs = [
'input:GPFlow'],
387 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlow'])
393_truthFlavours = [
"BHadronsInitial",
"BHadronsFinal",
"BQuarksFinal",
394 "CHadronsInitial",
"CHadronsFinal",
"CQuarksFinal",
396 "WBosons",
"ZBosons",
"HBosons",
"TQuarksFinal",
398for label
in _truthFlavours:
400 _stdInputList.append(
JetInputExternal(
"TruthLabel"+label, xAODType.TruthParticle,
401 algoBuilder = inputcfg.buildLabelledTruth,
402 filterfn=isMC, specs = label ) )
407for ji
in _stdInputList:
409 stdInputExtDic[ji.name] = ji
431 "CaloCalTopoClusters",
"EMTopoClusters", jetinputtype=
"EMTopo",
434 "CaloCalTopoClusters",
"LCTopoClusters", jetinputtype=
"LCTopo",
437 "CaloCalTopoClusters",
"EMOriginTopoClusters", jetinputtype=
"EMTopo",
440 "CaloCalTopoClusters",
"MLOriginTopoClusters", jetinputtype=
"EMTopo",
443 "CaloCalTopoClusters",
"LCOriginTopoClusters", jetinputtype=
"LCTopo",
447 "CaloCalTopoClusters_EleRM",
"LCOriginTopoClusters_EleRM", jetinputtype=
"LCTopo",
450 "CaloCalTopoClusters",
"LCOriginTopoCSSK", jetinputtype=
"LCTopo",
458 JetInputConstitSeq(
"EMPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'JetETMissParticleFlowObjects',
'CHSParticleFlowObjects'),
461 JetInputConstitSeq(
"GPFlowML", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalClusterMLCorrectedParticleFlowObjects',
'CHSGlobalClusterMLCorrectedParticleFlowObjects', label =
'EMPFlow',),
464 JetInputConstitSeq(
"GPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSGParticleFlowObjects',
467 JetInputConstitSeq(
"GPFlow_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noElectrons',
'CHSGParticleFlowObjects_noElectrons',
468 label=
'EMPFlow_noElectrons'),
470 JetInputConstitSeq(
"GPFlow_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noMuons',
'CHSGParticleFlowObjects_noMuons',
471 label=
'EMPFlow_noMuons'),
473 JetInputConstitSeq(
"GPFlow_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noLeptons',
'CHSGParticleFlowObjects_noLeptons',
474 label=
'EMPFlow_noLeptons'),
477 JetInputConstitSeq(
"GPFlow_inclMuons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_inclMuons',
'CHSGParticleFlowObjects_inclMuons',
478 label=
'EMPFlow_inclMuons'),
481 JetInputConstitSeq(
"GPFlow_tauSeedEleRM", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_tauSeedEleRM',
'CHSGParticleFlowObjects_tauSeedEleRM',
482 label=
'EMPFlow_tauSeedEleRM'),
486 JetInputConstitSeq(
"GPFlowByVtx", xAODType.FlowElement, [
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSByVtxGParticleFlowObjects',
487 label=
'EMPFlowByVertex', byVertex=
True),
490 JetInputConstitSeq(
"EMPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
491 'JetETMissParticleFlowObjects',
'CSSKParticleFlowObjects', jetinputtype=
"EMPFlow"),
493 JetInputConstitSeq(
"GPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
494 'GlobalParticleFlowObjects',
'CSSKGParticleFlowObjects', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK'),
496 JetInputConstitSeq(
"GPFlowCSSK_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
497 'GlobalParticleFlowObjects_noElectrons',
'CSSKGParticleFlowObjects_noElectrons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noElectrons'),
499 JetInputConstitSeq(
"GPFlowCSSK_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
500 'GlobalParticleFlowObjects_noMuons',
'CSSKGParticleFlowObjects_noMuons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noMuons'),
502 JetInputConstitSeq(
"GPFlowCSSK_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
503 'GlobalParticleFlowObjects_noLeptons',
'CSSKGParticleFlowObjects_noLeptons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noLeptons'),
506 JetInputConstitSeq(
"GPFlowCSSK_inclMuons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
507 'GlobalParticleFlowObjects_inclMuons',
'CSSKGParticleFlowObjects_inclMuons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_inclMuons'),
512 JetInputConstit(
"UFOCSSK_noElectrons", xAODType.FlowElement,
"UFOCSSK_noElectrons" ),
514 JetInputConstit(
"UFOCSSK_noMuons", xAODType.FlowElement,
"UFOCSSK_noMuons" ),
516 JetInputConstit(
"UFOCSSK_noLeptons", xAODType.FlowElement,
"UFOCSSK_noLeptons" ),
519 JetInputConstit(
"UFOCSSK_inclMuons", xAODType.FlowElement,
"UFOCSSK_inclMuons" ),
526 filterfn =
lambda flags : (
"CaloCalFwdTopoTowers" in flags.Input.Collections,
"Towers as ghosts disabled as CaloCalFwdTopoTowers are not in the input")),
530 JetInputConstit(
"Track", xAODType.TrackParticle, inputsFromContext(
"JetTracks")),
532 JetInputConstit(
"PV0Track", xAODType.TrackParticle, inputsFromContext(
"JetTracks", prefix=
"PV0")),
535 JetInputConstit(
"TrackLRT", xAODType.TrackParticle,
"InDetLargeD0TrackParticles",
536 filterfn = _largeRTracksExist),
542 JetInputConstit(
"UnAssocMuonSegment",
"UnAssocMuonSegment",
"UnAssocMuonSegments", ),
554 JetInputConstit(
"Truth", xAODType.TruthParticle,
"JetInputTruthParticles" ),
556 JetInputConstit(
"TruthWZ", xAODType.TruthParticle,
"JetInputTruthParticlesNoWZ", jetinputtype=
"TruthWZ"),
558 JetInputConstit(
"TruthDressedWZ", xAODType.TruthParticle,
"JetInputTruthParticlesDressedWZ", jetinputtype=
"TruthDressedWZ"),
560 JetInputConstit(
"TruthCharged", xAODType.TruthParticle,
"JetInputTruthParticlesCharged", jetinputtype=
"TruthCharged"),
564 JetInputConstit(
"TruthGEN", xAODType.TruthParticle,
"JetInputTruthParticlesGEN" , label=
"Truth"),
566 JetInputConstit(
"TruthGENWZ", xAODType.TruthParticle,
"JetInputTruthParticlesGENNoWZ", jetinputtype=
"TruthWZ", label=
"TruthWZ"),
571for label
in _truthFlavours:
572 _stdSeqList.append(
JetInputConstit(label, xAODType.TruthParticle,
"TruthLabel"+label ) )
575for jc
in _stdSeqList:
577 stdConstitDic[jc.name] = jc
585 """One Property of the CorrectPFO constit modifier is a tool.
586 we use this function as a placeholder, allowing to delay the instantiation of this property tool
587 to the time the modifier itself is instantiated.
589 from AthenaConfiguration.ComponentFactory
import CompFactory
590 return CompFactory.getComp(
"CP::WeightPFOTool")(
"weightPFO")
593vtxKey =
"PrimaryVertices"
594tvaKey =
"JetTrackVtxAssoc"
600 JetConstitModifier(
"Origin",
"CaloClusterConstituentsOrigin", prereqs=[inputsFromContext(
"Vertices")]),
602 JetConstitModifier(
"ML",
"ClusterAtMLScaleTool", prereqs=[
"input:CaloCalTopoClustersML"]),
608 prereqs=[inputsFromContext(
"Vertices")],
609 properties=dict(VertexContainerKey=propFromContext(
"Vertices"),
610 WeightPFOTool= _getWeightPFOToolDefault,
611 DoByVertex =
lambda jdef, _: jdef.byVertex) ),
617 prereqs=
lambda parentjdef : [inputsFromContext(
"Vertices"),] + ( [inputsFromContext(
"TVA")]
if parentjdef.context==
'default' else []) ,
618 properties=dict(VertexContainerKey=propFromContext(
"Vertices"),
619 TrackVertexAssociation=propFromContext(
"TVA"),
620 UseTrackToVertexTool=
lambda jdef,_: jdef.context
in [
'default',
'HL_LHC'],
621 DoByVertex =
lambda jdef, _: jdef.byVertex
625 JetConstitModifier(
"Vor",
"VoronoiWeightTool", properties=dict(doSpread=
False, nSigma=0) ),
632for ji
in _stdModList:
634 stdContitModifDic[ji.name] = ji
_getWeightPFOToolDefault(*l)
List of standard constituent modifiers.
_trackParticleInputsExist(flags)
List of standard input sources for jets.
getPFOClusterMLCorrectionAlgorithmBuilder()
_unassocMuonSegmentInputsExist(flags)
_muonSegmentInputsExist(flags)
getCaloClusterEnergyMLCalibAlgBuilder()
_largeRTracksExist(flags)