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", ],
198 JetInputExternal(
"GlobalParticleFlowObjects_tauSeedEleRM", xAODType.FlowElement,
199 algoBuilder = inputcfg.buildPFlowSel_tauSeedEleRM,
200 prereqs = [
"input:JetETMissParticleFlowObjects", ],
206 filterfn = _trackParticleInputsExist
212 prereqs = [inputsFromContext(
"Tracks")],
213 filterfn =
lambda flags : (flags.Beam.Type == BeamType.Collisions, f
"No vertexing with {flags.Beam.Type}"),
217 prereqs= [ inputsFromContext(
"Tracks") ],
218 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
222 prereqs= [ inputsFromContext(
"Tracks") ],
223 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
227 prereqs= [ inputsFromContext(
"Tracks") ],
228 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
232 prereqs= [ inputsFromContext(
"Tracks") ],
233 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
238 prereqs= [ inputsFromContext(
"Tracks") ],
239 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
True )
242 prereqs= [ inputsFromContext(
"Tracks") ,
243 inputsFromContext(
"Vertices")],
244 algoBuilder = inputcfg.buildJetTrackUsedInFitDeco
248 lambda jdef, _ : jrtcfg.getJetTrackVtxAlg(
250 algname=
"jetTVA" if jdef.context
in [
"HL_LHC",
"default",
"notrk",
""]
else f
"jetTVA_{jdef.context}",
251 WorkingPoint=
"Nonprompt_All_MaxWeight"
254 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices")],
258 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
260 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices") ]
263 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
265 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices") ]
268 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
270 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices") ]
273 JetInputExternal(
"EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
274 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
275 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name]
278 JetInputExternal(
"EleRM_EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
279 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
280 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name],
283 JetInputExternal(
"HLT_EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
284 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
285 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name],
291 prereqs = [inputsFromContext(
"Tracks")],
292 filterfn = _muonSegmentInputsExist
296 prereqs = [inputsFromContext(
"Tracks")],
297 filterfn = _unassocMuonSegmentInputsExist
305 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC ),
311 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"NoWZ"),
317 prereqs = [
"input:DressedObjects"],
318 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"DressedWZ"),
326 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"Charged"),
332 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC ),
335 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC,specs=
"NoWZ"),
340 prereqs=[
"input:JetSelectedTracks_trackSelOpt",
"input:JetTrackUsedInFitDeco"],
341 algoBuilder = inputcfg.buildPV0TrackSel ),
346 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK'],
347 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
348 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK'])
352 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noElectrons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noElectrons'],
353 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noElectrons' 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_noElectrons'])
358 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noMuons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noMuons'],
359 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noMuons' 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_noMuons'])
365 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noLeptons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noLeptons'],
366 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noLeptons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
367 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noLeptons'])
371 prereqs = [
'input:GPFlow'],
372 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlow'])
378_truthFlavours = [
"BHadronsInitial",
"BHadronsFinal",
"BQuarksFinal",
379 "CHadronsInitial",
"CHadronsFinal",
"CQuarksFinal",
381 "WBosons",
"ZBosons",
"HBosons",
"TQuarksFinal",
383for label
in _truthFlavours:
385 _stdInputList.append(
JetInputExternal(
"TruthLabel"+label, xAODType.TruthParticle,
386 algoBuilder = inputcfg.buildLabelledTruth,
387 filterfn=isMC, specs = label ) )
392for ji
in _stdInputList:
394 stdInputExtDic[ji.name] = ji
416 "CaloCalTopoClusters",
"EMTopoClusters", jetinputtype=
"EMTopo",
419 "CaloCalTopoClusters",
"LCTopoClusters", jetinputtype=
"LCTopo",
422 "CaloCalTopoClusters",
"EMOriginTopoClusters", jetinputtype=
"EMTopo",
425 "CaloCalTopoClusters",
"MLOriginTopoClusters", jetinputtype=
"EMTopo",
428 "CaloCalTopoClusters",
"LCOriginTopoClusters", jetinputtype=
"LCTopo",
432 "CaloCalTopoClusters_EleRM",
"LCOriginTopoClusters_EleRM", jetinputtype=
"LCTopo",
435 "CaloCalTopoClusters",
"LCOriginTopoCSSK", jetinputtype=
"LCTopo",
443 JetInputConstitSeq(
"EMPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'JetETMissParticleFlowObjects',
'CHSParticleFlowObjects'),
446 JetInputConstitSeq(
"GPFlowML", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalClusterMLCorrectedParticleFlowObjects',
'CHSGlobalClusterMLCorrectedParticleFlowObjects', label =
'EMPFlow',),
449 JetInputConstitSeq(
"GPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSGParticleFlowObjects',
452 JetInputConstitSeq(
"GPFlow_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noElectrons',
'CHSGParticleFlowObjects_noElectrons',
453 label=
'EMPFlow_noElectrons'),
455 JetInputConstitSeq(
"GPFlow_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noMuons',
'CHSGParticleFlowObjects_noMuons',
456 label=
'EMPFlow_noMuons'),
458 JetInputConstitSeq(
"GPFlow_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noLeptons',
'CHSGParticleFlowObjects_noLeptons',
459 label=
'EMPFlow_noLeptons'),
462 JetInputConstitSeq(
"GPFlow_tauSeedEleRM", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_tauSeedEleRM',
'CHSGParticleFlowObjects_tauSeedEleRM',
463 label=
'EMPFlow_tauSeedEleRM'),
467 JetInputConstitSeq(
"GPFlowByVtx", xAODType.FlowElement, [
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSByVtxGParticleFlowObjects',
468 label=
'EMPFlowByVertex', byVertex=
True),
471 JetInputConstitSeq(
"EMPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
472 'JetETMissParticleFlowObjects',
'CSSKParticleFlowObjects', jetinputtype=
"EMPFlow"),
474 JetInputConstitSeq(
"GPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
475 'GlobalParticleFlowObjects',
'CSSKGParticleFlowObjects', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK'),
477 JetInputConstitSeq(
"GPFlowCSSK_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
478 'GlobalParticleFlowObjects_noElectrons',
'CSSKGParticleFlowObjects_noElectrons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noElectrons'),
480 JetInputConstitSeq(
"GPFlowCSSK_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
481 'GlobalParticleFlowObjects_noMuons',
'CSSKGParticleFlowObjects_noMuons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noMuons'),
483 JetInputConstitSeq(
"GPFlowCSSK_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
484 'GlobalParticleFlowObjects_noLeptons',
'CSSKGParticleFlowObjects_noLeptons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noLeptons'),
488 JetInputConstit(
"UFOCSSK_noElectrons", xAODType.FlowElement,
"UFOCSSK_noElectrons" ),
490 JetInputConstit(
"UFOCSSK_noMuons", xAODType.FlowElement,
"UFOCSSK_noMuons" ),
492 JetInputConstit(
"UFOCSSK_noLeptons", xAODType.FlowElement,
"UFOCSSK_noLeptons" ),
499 filterfn =
lambda flags : (
"CaloCalFwdTopoTowers" in flags.Input.Collections,
"Towers as ghosts disabled as CaloCalFwdTopoTowers are not in the input")),
503 JetInputConstit(
"Track", xAODType.TrackParticle, inputsFromContext(
"JetTracks")),
505 JetInputConstit(
"PV0Track", xAODType.TrackParticle, inputsFromContext(
"JetTracks", prefix=
"PV0")),
508 JetInputConstit(
"TrackLRT", xAODType.TrackParticle,
"InDetLargeD0TrackParticles",
509 filterfn = _largeRTracksExist),
515 JetInputConstit(
"UnAssocMuonSegment",
"UnAssocMuonSegment",
"UnAssocMuonSegments", ),
527 JetInputConstit(
"Truth", xAODType.TruthParticle,
"JetInputTruthParticles" ),
529 JetInputConstit(
"TruthWZ", xAODType.TruthParticle,
"JetInputTruthParticlesNoWZ", jetinputtype=
"TruthWZ"),
531 JetInputConstit(
"TruthDressedWZ", xAODType.TruthParticle,
"JetInputTruthParticlesDressedWZ", jetinputtype=
"TruthDressedWZ"),
533 JetInputConstit(
"TruthCharged", xAODType.TruthParticle,
"JetInputTruthParticlesCharged", jetinputtype=
"TruthCharged"),
537 JetInputConstit(
"TruthGEN", xAODType.TruthParticle,
"JetInputTruthParticlesGEN" , label=
"Truth"),
539 JetInputConstit(
"TruthGENWZ", xAODType.TruthParticle,
"JetInputTruthParticlesGENNoWZ", jetinputtype=
"TruthWZ", label=
"TruthWZ"),
544for label
in _truthFlavours:
545 _stdSeqList.append(
JetInputConstit(label, xAODType.TruthParticle,
"TruthLabel"+label ) )
548for jc
in _stdSeqList:
550 stdConstitDic[jc.name] = jc
558 """One Property of the CorrectPFO constit modifier is a tool.
559 we use this function as a placeholder, allowing to delay the instantiation of this property tool
560 to the time the modifier itself is instantiated.
562 from AthenaConfiguration.ComponentFactory
import CompFactory
563 return CompFactory.getComp(
"CP::WeightPFOTool")(
"weightPFO")
566vtxKey =
"PrimaryVertices"
567tvaKey =
"JetTrackVtxAssoc"
573 JetConstitModifier(
"Origin",
"CaloClusterConstituentsOrigin", prereqs=[inputsFromContext(
"Vertices")]),
575 JetConstitModifier(
"ML",
"ClusterAtMLScaleTool", prereqs=[
"input:CaloCalTopoClustersML"]),
581 prereqs=[inputsFromContext(
"Vertices")],
582 properties=dict(VertexContainerKey=propFromContext(
"Vertices"),
583 WeightPFOTool= _getWeightPFOToolDefault,
584 DoByVertex =
lambda jdef, _: jdef.byVertex) ),
590 prereqs=
lambda parentjdef : [inputsFromContext(
"Vertices"),] + ( [inputsFromContext(
"TVA")]
if parentjdef.context==
'default' else []) ,
591 properties=dict(VertexContainerKey=propFromContext(
"Vertices"),
592 TrackVertexAssociation=propFromContext(
"TVA"),
593 UseTrackToVertexTool=
lambda jdef,_: jdef.context
in [
'default',
'HL_LHC'],
594 DoByVertex =
lambda jdef, _: jdef.byVertex
598 JetConstitModifier(
"Vor",
"VoronoiWeightTool", properties=dict(doSpread=
False, nSigma=0) ),
605for ji
in _stdModList:
607 stdContitModifDic[ji.name] = ji
_unassocMuonSegmentInputsExist(flags)
getPFOClusterMLCorrectionAlgorithmBuilder()
getCaloClusterEnergyMLCalibAlgBuilder()
_largeRTracksExist(flags)
_trackParticleInputsExist(flags)
List of standard input sources for jets.
_muonSegmentInputsExist(flags)
_getWeightPFOToolDefault(*l)
List of standard constituent modifiers.