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
34import JetRecConfig.JetRecConfig
as jrcfg
36 import JetRecTools.JetRecToolsConfig
as jrtcfg
37except ModuleNotFoundError:
42 import TrackCaloClusterRecTools.TrackCaloClusterConfig
as tcccfg
43except ModuleNotFoundError:
48 """Returns a helper function which invokes the standard reco configuration for the container 'input'
49 (where input is external to the jet domain).
51 We group the definition of functions here rather than separately, so that we can change them
52 automatically to a void function in case we're in an Analysis release and we can not import upstream packages.
56 doNothingFunc =
lambda *l:
None
57 if isAnalysisRelease():
61 if input==
'CaloClusters':
63 from CaloRec.CaloRecoConfig
import CaloRecoCfg
64 flags = jetdef._cflags
65 return CaloRecoCfg(flags)
if flags.Jet.doUpstreamDependencies
else None
68 from InDetConfig.TrackRecoConfig
import InDetTrackRecoCfg
69 flags = jetdef._cflags
70 return InDetTrackRecoCfg(flags)
if flags.Jet.doUpstreamDependencies
else None
73 from MuonConfig.MuonReconstructionConfig
import MuonReconstructionCfg
74 flags = jetdef._cflags
75 return MuonReconstructionCfg(flags)
if flags.Jet.doUpstreamDependencies
else None
78 if not jetdef._cflags.Jet.doUpstreamDependencies:
80 from eflowRec.PFRun3Config
import PFCfg
81 return PFCfg(jetdef._cflags)
82 elif input==
"DressedWZ":
84 from DerivationFrameworkMCTruth.MCTruthCommonConfig
import PreJetMCTruthAugmentationsCfg
85 return PreJetMCTruthAugmentationsCfg(jetdef._cflags,decorationDressing=
'dressedPhoton')
98 warning =
"Tracking is disabled and no InDetTrackParticles in input"
99 if "InDetTrackParticles" in flags.Input.Collections:
101 if isAnalysisRelease():
104 return False, warning
105 return flags.Reco.EnableTracking, warning
108 warning =
"Muon reco is disabled"
109 if "MuonSegments" in flags.Input.Collections:
111 if isAnalysisRelease():
113 return False, warning
114 return flags.Reco.EnableCombinedMuon, warning
117 warning =
"UnAssociated muon segments not present"
118 if "UnAssocMuonSegments" in flags.Input.Collections:
120 if flags.Input.RunNumbers[0] < 410000:
122 return False, warning
123 if isAnalysisRelease():
125 return False, warning
126 return flags.Reco.EnableCombinedMuon, warning
129 warning =
"Large radius tracking did not run"
130 if "InDetLargeD0TrackParticles" in flags.Input.Collections:
139 if isAnalysisRelease()
or flags.Tracking.doLargeD0:
141 return False, warning
145 from CaloRec.CaloClusterMLCalibAlgLiteConfig
import CaloClusterMLCalibAlgLiteCfg
146 return CaloClusterMLCalibAlgLiteCfg(flags._cflags)
150 from eflowRec.PFRun3Config
import PFOClusterMLCorrectionAlgorithmBuilder
151 return PFOClusterMLCorrectionAlgorithmBuilder(flags._cflags, spec)
172 prereqs = [inputsFromContext(
"Tracks"),
"input:CaloCalTopoClusters"],
176 algoBuilder = inputcfg.buildPFlowSel,
177 prereqs = [
"input:JetETMissParticleFlowObjects", ],
181 prereqs = [
"input:GlobalParticleFlowObjects",
"input:CaloCalTopoClusters",
"input:CaloCalTopoClustersML"],
184 JetInputExternal(
"GlobalParticleFlowObjects_noElectrons", xAODType.FlowElement,
185 algoBuilder = inputcfg.buildPFlowSel_noElectrons,
186 prereqs = [
"input:JetETMissParticleFlowObjects", ],
190 algoBuilder = inputcfg.buildPFlowSel_noMuons,
191 prereqs = [
"input:JetETMissParticleFlowObjects", ],
194 JetInputExternal(
"GlobalParticleFlowObjects_noLeptons", xAODType.FlowElement,
195 algoBuilder = inputcfg.buildPFlowSel_noLeptons,
196 prereqs = [
"input:JetETMissParticleFlowObjects", ],
200 JetInputExternal(
"GlobalParticleFlowObjects_inclMuons", xAODType.FlowElement,
201 algoBuilder = inputcfg.buildPFlowSel_inclMuons,
202 prereqs = [
"input:JetETMissParticleFlowObjects", ],
205 JetInputExternal(
"GlobalParticleFlowObjects_tauSeedEleRM", xAODType.FlowElement,
206 algoBuilder = inputcfg.buildPFlowSel_tauSeedEleRM,
207 prereqs = [
"input:JetETMissParticleFlowObjects", ],
213 filterfn = _trackParticleInputsExist
219 prereqs = [inputsFromContext(
"Tracks")],
220 filterfn =
lambda flags : (flags.Beam.Type == BeamType.Collisions, f
"No vertexing with {flags.Beam.Type}"),
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 )
234 prereqs= [ inputsFromContext(
"Tracks") ],
235 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
239 prereqs= [ inputsFromContext(
"Tracks") ],
240 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
245 prereqs= [ inputsFromContext(
"Tracks") ],
246 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
True )
249 prereqs= [ inputsFromContext(
"Tracks") ,
250 inputsFromContext(
"Vertices")],
251 algoBuilder = inputcfg.buildJetTrackUsedInFitDeco
255 lambda jdef, _ : jrtcfg.getJetTrackVtxAlg(
257 algname=
"jetTVA" if jdef.context
in [
"HL_LHC",
"default",
"notrk",
""]
else f
"jetTVA_{jdef.context}",
258 WorkingPoint=
"Nonprompt_All_MaxWeight"
261 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 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
272 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices") ]
275 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
277 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices") ]
280 JetInputExternal(
"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]
287 algoBuilder =
lambda jetdef,_: inputcfg.buildEventShapeAlg(jetdef,
'', suffix=
'Neut'),
288 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"NeutEventShape",
289 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name+
'_Neut']
293 JetInputExternal(
"EleRM_EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
294 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
295 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name],
298 JetInputExternal(
"HLT_EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
299 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
300 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name],
306 prereqs = [inputsFromContext(
"Tracks")],
307 filterfn = _muonSegmentInputsExist
311 prereqs = [inputsFromContext(
"Tracks")],
312 filterfn = _unassocMuonSegmentInputsExist
320 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC ),
326 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"NoWZ"),
332 prereqs = [
"input:DressedObjects"],
333 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"DressedWZ"),
341 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"Charged"),
347 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC ),
350 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC,specs=
"NoWZ"),
355 prereqs=[
"input:JetSelectedTracks_trackSelOpt",
"input:JetTrackUsedInFitDeco"],
356 algoBuilder = inputcfg.buildPV0TrackSel ),
361 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK'],
362 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
363 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK'])
367 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noElectrons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noElectrons'],
368 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noElectrons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
369 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noElectrons'])
373 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noMuons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noMuons'],
374 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noMuons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
375 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noMuons'])
380 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noLeptons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noLeptons'],
381 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noLeptons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
382 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noLeptons'])
387 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_inclMuons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_inclMuons'],
388 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_inclMuons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
389 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_inclMuons'])
393 prereqs = [
'input:GPFlow'],
394 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlow'])
400 prereqs = [
'input:GPFlow'],
401 algoBuilder =
lambda jdef,_ : jrcfg.getConstitPJGAlg(stdConstitDic[
'GPFlow'], suffix=
'Neut'),
407_truthFlavours = [
"BHadronsInitial",
"BHadronsFinal",
"BQuarksFinal",
408 "CHadronsInitial",
"CHadronsFinal",
"CQuarksFinal",
410 "WBosons",
"ZBosons",
"HBosons",
"TQuarksFinal",
412for label
in _truthFlavours:
414 _stdInputList.append(
JetInputExternal(
"TruthLabel"+label, xAODType.TruthParticle,
415 algoBuilder = inputcfg.buildLabelledTruth,
416 filterfn=isMC, specs = label ) )
421for ji
in _stdInputList:
423 stdInputExtDic[ji.name] = ji
445 "CaloCalTopoClusters",
"EMTopoClusters", jetinputtype=
"EMTopo",
448 "CaloCalTopoClusters",
"LCTopoClusters", jetinputtype=
"LCTopo",
451 "CaloCalTopoClusters",
"EMOriginTopoClusters", jetinputtype=
"EMTopo",
454 "CaloCalTopoClusters",
"MLOriginTopoClusters", jetinputtype=
"EMTopo",
457 "CaloCalTopoClusters",
"LCOriginTopoClusters", jetinputtype=
"LCTopo",
461 "CaloCalTopoClusters_EleRM",
"LCOriginTopoClusters_EleRM", jetinputtype=
"LCTopo",
464 "CaloCalTopoClusters",
"LCOriginTopoCSSK", jetinputtype=
"LCTopo",
472 JetInputConstitSeq(
"EMPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'JetETMissParticleFlowObjects',
'CHSParticleFlowObjects'),
475 JetInputConstitSeq(
"GPFlowML", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalClusterMLCorrectedParticleFlowObjects',
'CHSGlobalClusterMLCorrectedParticleFlowObjects', label =
'EMPFlowML',),
478 JetInputConstitSeq(
"GPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSGParticleFlowObjects',
481 JetInputConstitSeq(
"GPFlow_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noElectrons',
'CHSGParticleFlowObjects_noElectrons',
482 label=
'EMPFlow_noElectrons'),
484 JetInputConstitSeq(
"GPFlow_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noMuons',
'CHSGParticleFlowObjects_noMuons',
485 label=
'EMPFlow_noMuons'),
487 JetInputConstitSeq(
"GPFlow_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noLeptons',
'CHSGParticleFlowObjects_noLeptons',
488 label=
'EMPFlow_noLeptons'),
491 JetInputConstitSeq(
"GPFlow_inclMuons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_inclMuons',
'CHSGParticleFlowObjects_inclMuons',
492 label=
'EMPFlow_inclMuons'),
495 JetInputConstitSeq(
"GPFlow_tauSeedEleRM", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_tauSeedEleRM',
'CHSGParticleFlowObjects_tauSeedEleRM',
496 label=
'EMPFlow_tauSeedEleRM'),
499 JetInputConstitSeq(
"GPFlowByVtx", xAODType.FlowElement, [
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSByVtxGParticleFlowObjects',
500 label=
'EMPFlowByVertex', byVertex=
True),
503 JetInputConstitSeq(
"EMPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
504 'JetETMissParticleFlowObjects',
'CSSKParticleFlowObjects', jetinputtype=
"EMPFlow"),
506 JetInputConstitSeq(
"GPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
507 'GlobalParticleFlowObjects',
'CSSKGParticleFlowObjects', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK'),
509 JetInputConstitSeq(
"GPFlowCSSK_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
510 'GlobalParticleFlowObjects_noElectrons',
'CSSKGParticleFlowObjects_noElectrons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noElectrons'),
512 JetInputConstitSeq(
"GPFlowCSSK_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
513 'GlobalParticleFlowObjects_noMuons',
'CSSKGParticleFlowObjects_noMuons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noMuons'),
515 JetInputConstitSeq(
"GPFlowCSSK_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
516 'GlobalParticleFlowObjects_noLeptons',
'CSSKGParticleFlowObjects_noLeptons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noLeptons'),
519 JetInputConstitSeq(
"GPFlowCSSK_inclMuons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
520 'GlobalParticleFlowObjects_inclMuons',
'CSSKGParticleFlowObjects_inclMuons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_inclMuons'),
524 JetInputConstit(
"UFOCSSK_noElectrons", xAODType.FlowElement,
"UFOCSSK_noElectrons" ),
526 JetInputConstit(
"UFOCSSK_noMuons", xAODType.FlowElement,
"UFOCSSK_noMuons" ),
528 JetInputConstit(
"UFOCSSK_noLeptons", xAODType.FlowElement,
"UFOCSSK_noLeptons" ),
531 JetInputConstit(
"UFOCSSK_inclMuons", xAODType.FlowElement,
"UFOCSSK_inclMuons" ),
538 filterfn =
lambda flags : (
"CaloCalFwdTopoTowers" in flags.Input.Collections,
"Towers as ghosts disabled as CaloCalFwdTopoTowers are not in the input")),
542 JetInputConstit(
"Track", xAODType.TrackParticle, inputsFromContext(
"JetTracks")),
544 JetInputConstit(
"PV0Track", xAODType.TrackParticle, inputsFromContext(
"JetTracks", prefix=
"PV0")),
547 JetInputConstit(
"TrackLRT", xAODType.TrackParticle,
"InDetLargeD0TrackParticles",
548 filterfn = _largeRTracksExist),
554 JetInputConstit(
"UnAssocMuonSegment",
"UnAssocMuonSegment",
"UnAssocMuonSegments", ),
566 JetInputConstit(
"Truth", xAODType.TruthParticle,
"JetInputTruthParticles" ),
568 JetInputConstit(
"TruthWZ", xAODType.TruthParticle,
"JetInputTruthParticlesNoWZ", jetinputtype=
"TruthWZ"),
570 JetInputConstit(
"TruthDressedWZ", xAODType.TruthParticle,
"JetInputTruthParticlesDressedWZ", jetinputtype=
"TruthDressedWZ"),
572 JetInputConstit(
"TruthCharged", xAODType.TruthParticle,
"JetInputTruthParticlesCharged", jetinputtype=
"TruthCharged"),
576 JetInputConstit(
"TruthGEN", xAODType.TruthParticle,
"JetInputTruthParticlesGEN" , label=
"Truth"),
578 JetInputConstit(
"TruthGENWZ", xAODType.TruthParticle,
"JetInputTruthParticlesGENNoWZ", jetinputtype=
"TruthWZ", label=
"TruthWZ"),
583for label
in _truthFlavours:
584 _stdSeqList.append(
JetInputConstit(label, xAODType.TruthParticle,
"TruthLabel"+label ) )
587for jc
in _stdSeqList:
589 stdConstitDic[jc.name] = jc
597 """One Property of the CorrectPFO constit modifier is a tool.
598 we use this function as a placeholder, allowing to delay the instantiation of this property tool
599 to the time the modifier itself is instantiated.
601 from AthenaConfiguration.ComponentFactory
import CompFactory
602 return CompFactory.getComp(
"CP::WeightPFOTool")(
"weightPFO")
605vtxKey =
"PrimaryVertices"
606tvaKey =
"JetTrackVtxAssoc"
612 JetConstitModifier(
"Origin",
"CaloClusterConstituentsOrigin", prereqs=[inputsFromContext(
"Vertices")]),
614 JetConstitModifier(
"ML",
"ClusterAtMLScaleTool", prereqs=[
"input:CaloCalTopoClustersML"]),
620 prereqs=[inputsFromContext(
"Vertices")],
621 properties=dict(VertexContainerKey=propFromContext(
"Vertices"),
622 WeightPFOTool= _getWeightPFOToolDefault,
623 DoByVertex =
lambda jdef, _: jdef.byVertex) ),
629 prereqs=
lambda parentjdef : [inputsFromContext(
"Vertices"),] + ( [inputsFromContext(
"TVA")]
if parentjdef.context==
'default' else []) ,
630 properties=dict(VertexContainerKey=propFromContext(
"Vertices"),
631 TrackVertexAssociation=propFromContext(
"TVA"),
632 UseTrackToVertexTool=
lambda jdef,_: jdef.context
in [
'default',
'HL_LHC'],
633 DoByVertex =
lambda jdef, _: jdef.byVertex
637 JetConstitModifier(
"Vor",
"VoronoiWeightTool", properties=dict(doSpread=
False, nSigma=0) ),
644for ji
in _stdModList:
646 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)