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)
94 warning =
"Tracking is disabled and no InDetTrackParticles in input"
95 if "InDetTrackParticles" in flags.Input.Collections:
97 if isAnalysisRelease():
100 return False, warning
101 return flags.Reco.EnableTracking, warning
104 warning =
"Muon reco is disabled"
105 if "MuonSegments" in flags.Input.Collections:
107 if isAnalysisRelease():
109 return False, warning
110 return flags.Reco.EnableCombinedMuon, warning
113 warning =
"UnAssociated muon segments not present"
114 if "UnAssocMuonSegments" in flags.Input.Collections:
116 if flags.Input.RunNumbers[0] < 410000:
118 return False, warning
119 if isAnalysisRelease():
121 return False, warning
122 return flags.Reco.EnableCombinedMuon, warning
125 warning =
"Large radius tracking did not run"
126 if "InDetLargeD0TrackParticles" in flags.Input.Collections:
135 if isAnalysisRelease()
or flags.Tracking.doLargeD0:
137 return False, warning
141 from CaloRec.CaloClusterMLCalibAlgLiteConfig
import CaloClusterMLCalibAlgLiteCfg
142 return CaloClusterMLCalibAlgLiteCfg(flags._cflags)
146 from eflowRec.PFRun3Config
import PFOClusterMLCorrectionAlgorithmBuilder
147 return PFOClusterMLCorrectionAlgorithmBuilder(flags._cflags, spec)
168 prereqs = [inputsFromContext(
"Tracks"),
"input:CaloCalTopoClusters"],
172 algoBuilder = inputcfg.buildPFlowSel,
173 prereqs = [
"input:JetETMissParticleFlowObjects", ],
177 prereqs = [
"input:GlobalParticleFlowObjects",
"input:CaloCalTopoClusters",
"input:CaloCalTopoClustersML"],
180 JetInputExternal(
"GlobalParticleFlowObjects_noElectrons", xAODType.FlowElement,
181 algoBuilder = inputcfg.buildPFlowSel_noElectrons,
182 prereqs = [
"input:JetETMissParticleFlowObjects", ],
186 algoBuilder = inputcfg.buildPFlowSel_noMuons,
187 prereqs = [
"input:JetETMissParticleFlowObjects", ],
190 JetInputExternal(
"GlobalParticleFlowObjects_noLeptons", xAODType.FlowElement,
191 algoBuilder = inputcfg.buildPFlowSel_noLeptons,
192 prereqs = [
"input:JetETMissParticleFlowObjects", ],
195 JetInputExternal(
"GlobalParticleFlowObjects_tauSeedEleRM", xAODType.FlowElement,
196 algoBuilder = inputcfg.buildPFlowSel_tauSeedEleRM,
197 prereqs = [
"input:JetETMissParticleFlowObjects", ],
203 filterfn = _trackParticleInputsExist
209 prereqs = [inputsFromContext(
"Tracks")],
210 filterfn =
lambda flags : (flags.Beam.Type == BeamType.Collisions, f
"No vertexing with {flags.Beam.Type}"),
214 prereqs= [ inputsFromContext(
"Tracks") ],
215 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
219 prereqs= [ inputsFromContext(
"Tracks") ],
220 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
224 prereqs= [ inputsFromContext(
"Tracks") ],
225 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
229 prereqs= [ inputsFromContext(
"Tracks") ],
230 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
235 prereqs= [ inputsFromContext(
"Tracks") ],
236 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
True )
239 prereqs= [ inputsFromContext(
"Tracks") ,
240 inputsFromContext(
"Vertices")],
241 algoBuilder = inputcfg.buildJetTrackUsedInFitDeco
245 lambda jdef, _ : jrtcfg.getJetTrackVtxAlg(
247 algname=
"jetTVA" if jdef.context
in [
"HL_LHC",
"default",
"notrk",
""]
else f
"jetTVA_{jdef.context}",
248 WorkingPoint=
"Nonprompt_All_MaxWeight"
251 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices")],
255 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
257 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices") ]
260 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
262 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices") ]
265 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
267 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices") ]
270 JetInputExternal(
"EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
271 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
272 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name]
275 JetInputExternal(
"EleRM_EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
276 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
277 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name],
280 JetInputExternal(
"HLT_EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
281 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
282 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name],
288 prereqs = [inputsFromContext(
"Tracks")],
289 filterfn = _muonSegmentInputsExist
293 prereqs = [inputsFromContext(
"Tracks")],
294 filterfn = _unassocMuonSegmentInputsExist
302 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC ),
308 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"NoWZ"),
314 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"DressedWZ"),
319 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"Charged"),
325 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC ),
328 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC,specs=
"NoWZ"),
333 prereqs=[
"input:JetSelectedTracks_trackSelOpt",
"input:JetTrackUsedInFitDeco"],
334 algoBuilder = inputcfg.buildPV0TrackSel ),
339 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK'],
340 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
341 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK'])
345 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noElectrons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noElectrons'],
346 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noElectrons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
347 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noElectrons'])
351 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noMuons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noMuons'],
352 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noMuons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
353 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noMuons'])
358 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noLeptons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noLeptons'],
359 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noLeptons' 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_noLeptons'])
364 prereqs = [
'input:GPFlow'],
365 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlow'])
371_truthFlavours = [
"BHadronsInitial",
"BHadronsFinal",
"BQuarksFinal",
372 "CHadronsInitial",
"CHadronsFinal",
"CQuarksFinal",
374 "WBosons",
"ZBosons",
"HBosons",
"TQuarksFinal",
376for label
in _truthFlavours:
378 _stdInputList.append(
JetInputExternal(
"TruthLabel"+label, xAODType.TruthParticle,
379 algoBuilder = inputcfg.buildLabelledTruth,
380 filterfn=isMC, specs = label ) )
385for ji
in _stdInputList:
387 stdInputExtDic[ji.name] = ji
409 "CaloCalTopoClusters",
"EMTopoClusters", jetinputtype=
"EMTopo",
412 "CaloCalTopoClusters",
"LCTopoClusters", jetinputtype=
"LCTopo",
415 "CaloCalTopoClusters",
"EMOriginTopoClusters", jetinputtype=
"EMTopo",
418 "CaloCalTopoClusters",
"MLOriginTopoClusters", jetinputtype=
"EMTopo",
421 "CaloCalTopoClusters",
"LCOriginTopoClusters", jetinputtype=
"LCTopo",
425 "CaloCalTopoClusters_EleRM",
"LCOriginTopoClusters_EleRM", jetinputtype=
"LCTopo",
428 "CaloCalTopoClusters",
"LCOriginTopoCSSK", jetinputtype=
"LCTopo",
436 JetInputConstitSeq(
"EMPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'JetETMissParticleFlowObjects',
'CHSParticleFlowObjects'),
439 JetInputConstitSeq(
"GPFlowML", xAODType.FlowElement,[
"CHS"] ,
'GlobalClusterMLCorrectedParticleFlowObjects',
'CHSGlobalClusterMLCorrectedParticleFlowObjects', label =
'EMPFlow',),
442 JetInputConstitSeq(
"GPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSGParticleFlowObjects',
445 JetInputConstitSeq(
"GPFlow_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noElectrons',
'CHSGParticleFlowObjects_noElectrons',
446 label=
'EMPFlow_noElectrons'),
448 JetInputConstitSeq(
"GPFlow_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noMuons',
'CHSGParticleFlowObjects_noMuons',
449 label=
'EMPFlow_noMuons'),
451 JetInputConstitSeq(
"GPFlow_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noLeptons',
'CHSGParticleFlowObjects_noLeptons',
452 label=
'EMPFlow_noLeptons'),
455 JetInputConstitSeq(
"GPFlow_tauSeedEleRM", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_tauSeedEleRM',
'CHSGParticleFlowObjects_tauSeedEleRM',
456 label=
'EMPFlow_tauSeedEleRM'),
460 JetInputConstitSeq(
"GPFlowByVtx", xAODType.FlowElement, [
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSByVtxGParticleFlowObjects',
461 label=
'EMPFlowByVertex', byVertex=
True),
464 JetInputConstitSeq(
"EMPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
465 'JetETMissParticleFlowObjects',
'CSSKParticleFlowObjects', jetinputtype=
"EMPFlow"),
467 JetInputConstitSeq(
"GPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
468 'GlobalParticleFlowObjects',
'CSSKGParticleFlowObjects', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK'),
470 JetInputConstitSeq(
"GPFlowCSSK_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
471 'GlobalParticleFlowObjects_noElectrons',
'CSSKGParticleFlowObjects_noElectrons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noElectrons'),
473 JetInputConstitSeq(
"GPFlowCSSK_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
474 'GlobalParticleFlowObjects_noMuons',
'CSSKGParticleFlowObjects_noMuons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noMuons'),
476 JetInputConstitSeq(
"GPFlowCSSK_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
477 'GlobalParticleFlowObjects_noLeptons',
'CSSKGParticleFlowObjects_noLeptons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noLeptons'),
481 JetInputConstit(
"UFOCSSK_noElectrons", xAODType.FlowElement,
"UFOCSSK_noElectrons" ),
483 JetInputConstit(
"UFOCSSK_noMuons", xAODType.FlowElement,
"UFOCSSK_noMuons" ),
485 JetInputConstit(
"UFOCSSK_noLeptons", xAODType.FlowElement,
"UFOCSSK_noLeptons" ),
492 filterfn =
lambda flags : (
"CaloCalFwdTopoTowers" in flags.Input.Collections,
"Towers as ghosts disabled as CaloCalFwdTopoTowers are not in the input")),
496 JetInputConstit(
"Track", xAODType.TrackParticle, inputsFromContext(
"JetTracks")),
498 JetInputConstit(
"PV0Track", xAODType.TrackParticle, inputsFromContext(
"JetTracks", prefix=
"PV0")),
501 JetInputConstit(
"TrackLRT", xAODType.TrackParticle,
"InDetLargeD0TrackParticles",
502 filterfn = _largeRTracksExist),
508 JetInputConstit(
"UnAssocMuonSegment",
"UnAssocMuonSegment",
"UnAssocMuonSegments", ),
520 JetInputConstit(
"Truth", xAODType.TruthParticle,
"JetInputTruthParticles" ),
522 JetInputConstit(
"TruthWZ", xAODType.TruthParticle,
"JetInputTruthParticlesNoWZ", jetinputtype=
"TruthWZ"),
524 JetInputConstit(
"TruthDressedWZ", xAODType.TruthParticle,
"JetInputTruthParticlesDressedWZ", jetinputtype=
"TruthDressedWZ"),
526 JetInputConstit(
"TruthCharged", xAODType.TruthParticle,
"JetInputTruthParticlesCharged", jetinputtype=
"TruthCharged"),
530 JetInputConstit(
"TruthGEN", xAODType.TruthParticle,
"JetInputTruthParticlesGEN" , label=
"Truth"),
532 JetInputConstit(
"TruthGENWZ", xAODType.TruthParticle,
"JetInputTruthParticlesGENNoWZ", jetinputtype=
"TruthWZ", label=
"TruthWZ"),
537for label
in _truthFlavours:
538 _stdSeqList.append(
JetInputConstit(label, xAODType.TruthParticle,
"TruthLabel"+label ) )
541for jc
in _stdSeqList:
543 stdConstitDic[jc.name] = jc
551 """One Property of the CorrectPFO constit modifier is a tool.
552 we use this function as a placeholder, allowing to delay the intantiation of this property tool
553 to the time the modifier itself is instantiated.
555 from AthenaConfiguration.ComponentFactory
import CompFactory
556 return CompFactory.getComp(
"CP::WeightPFOTool")(
"weightPFO")
560vtxKey =
"PrimaryVertices"
561tvaKey =
"JetTrackVtxAssoc"
567 JetConstitModifier(
"Origin",
"CaloClusterConstituentsOrigin", prereqs=[inputsFromContext(
"Vertices")]),
569 JetConstitModifier(
"ML",
"ClusterAtMLScaleTool", prereqs=[
"input:CaloCalTopoClustersML"]),
575 prereqs=[inputsFromContext(
"Vertices")],
576 properties=dict(VertexContainerKey=propFromContext(
"Vertices"),
577 WeightPFOTool= _getPFOTool,
578 DoByVertex =
lambda jdef, _: jdef.byVertex) ),
585 prereqs=
lambda parentjdef : [inputsFromContext(
"Vertices"),] + ( [inputsFromContext(
"TVA")]
if parentjdef.context==
'default' else []) ,
586 properties=dict(VertexContainerKey=propFromContext(
"Vertices"),
587 TrackVertexAssociation=propFromContext(
"TVA"),
588 UseTrackToVertexTool=
lambda jdef,_: jdef.context
in [
'default',
'HL_LHC'],
589 DoByVertex =
lambda jdef, _: jdef.byVertex
593 JetConstitModifier(
"Vor",
"VoronoiWeightTool", properties=dict(doSpread=
False, nSigma=0) ),
600for ji
in _stdModList:
602 stdContitModifDic[ji.name] = ji
_unassocMuonSegmentInputsExist(flags)
getPFOClusterMLCorrectionAlgorithmBuilder()
getCaloClusterEnergyMLCalibAlgBuilder()
_getPFOTool(*l)
List of standard constituent modifiers.
_largeRTracksExist(flags)
_trackParticleInputsExist(flags)
List of standard input sources for jets.
_muonSegmentInputsExist(flags)