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
23from .Utilities
import ldict
31import JetRecConfig.JetInputConfig
as inputcfg
33 import JetRecTools.JetRecToolsConfig
as jrtcfg
34except ModuleNotFoundError:
39 import TrackCaloClusterRecTools.TrackCaloClusterConfig
as tcccfg
40except ModuleNotFoundError:
45 """A simple filter function for testing if we're running in MC
46 returns (bool, str) where the str contains an explanation of why the bool is False.
47 (probably worth re-allocating somehere else)"""
48 return flags.Input.isMC
or flags.Overlay.DataOverlay,
"Input file is not MC"
51 """Returns a helper function which invokes the standard reco configuration for the container 'input'
52 (where input is external to the jet domain).
54 We group the definition of functions here rather than separately, so that we can change them
55 automatically to a void function in case we're in an Analysis release and we can not import upstream packages.
59 doNothingFunc =
lambda *l:
None
60 if isAnalysisRelease():
64 if input==
'CaloClusters':
66 from CaloRec.CaloRecoConfig
import CaloRecoCfg
67 flags = jetdef._cflags
68 return CaloRecoCfg(flags)
if flags.Jet.doUpstreamDependencies
else None
71 from InDetConfig.TrackRecoConfig
import InDetTrackRecoCfg
72 flags = jetdef._cflags
73 return InDetTrackRecoCfg(flags)
if flags.Jet.doUpstreamDependencies
else None
76 from MuonConfig.MuonReconstructionConfig
import MuonReconstructionCfg
77 flags = jetdef._cflags
78 return MuonReconstructionCfg(flags)
if flags.Jet.doUpstreamDependencies
else None
81 if not jetdef._cflags.Jet.doUpstreamDependencies:
83 from eflowRec.PFRun3Config
import PFCfg
84 return PFCfg(jetdef._cflags)
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", ],
199 JetInputExternal(
"GlobalParticleFlowObjects_tauSeedEleRM", xAODType.FlowElement,
200 algoBuilder = inputcfg.buildPFlowSel_tauSeedEleRM,
201 prereqs = [
"input:JetETMissParticleFlowObjects", ],
207 filterfn = _trackParticleInputsExist
213 prereqs = [inputsFromContext(
"Tracks")],
214 filterfn =
lambda flags : (flags.Beam.Type == BeamType.Collisions, f
"No vertexing with {flags.Beam.Type}"),
218 prereqs= [ inputsFromContext(
"Tracks") ],
219 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
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 )
239 prereqs= [ inputsFromContext(
"Tracks") ],
240 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
True )
243 prereqs= [ inputsFromContext(
"Tracks") ,
244 inputsFromContext(
"Vertices")],
245 algoBuilder = inputcfg.buildJetTrackUsedInFitDeco
249 lambda jdef, _ : jrtcfg.getJetTrackVtxAlg(
251 algname=
"jetTVA" if jdef.context
in [
"HL_LHC",
"default",
"notrk",
""]
else f
"jetTVA_{jdef.context}",
252 WorkingPoint=
"Nonprompt_All_MaxWeight"
255 prereqs = [
"input:JetTrackUsedInFitDeco", inputsFromContext(
"Vertices")],
259 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
261 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 JetInputExternal(
"EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
275 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
276 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name]
279 JetInputExternal(
"EleRM_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(
"HLT_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],
292 prereqs = [inputsFromContext(
"Tracks")],
293 filterfn = _muonSegmentInputsExist
297 prereqs = [inputsFromContext(
"Tracks")],
298 filterfn = _unassocMuonSegmentInputsExist
306 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC ),
312 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"NoWZ"),
318 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"DressedWZ"),
323 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"Charged"),
329 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC ),
332 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC,specs=
"NoWZ"),
337 prereqs=[
"input:JetSelectedTracks_trackSelOpt",
"input:JetTrackUsedInFitDeco"],
338 algoBuilder = inputcfg.buildPV0TrackSel ),
343 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK'],
344 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
345 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK'])
349 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noElectrons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noElectrons'],
350 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noElectrons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
351 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noElectrons'])
355 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noMuons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noMuons'],
356 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noMuons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
357 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noMuons'])
362 prereqs =
lambda parentjdef : []
if (isAnalysisRelease()
or 'UFOCSSK_noLeptons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noLeptons'],
363 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noLeptons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
364 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noLeptons'])
368 prereqs = [
'input:GPFlow'],
369 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlow'])
375_truthFlavours = [
"BHadronsInitial",
"BHadronsFinal",
"BQuarksFinal",
376 "CHadronsInitial",
"CHadronsFinal",
"CQuarksFinal",
378 "WBosons",
"ZBosons",
"HBosons",
"TQuarksFinal",
380for label
in _truthFlavours:
382 _stdInputList.append(
JetInputExternal(
"TruthLabel"+label, xAODType.TruthParticle,
383 algoBuilder = inputcfg.buildLabelledTruth,
384 filterfn=isMC, specs = label ) )
389for ji
in _stdInputList:
391 stdInputExtDic[ji.name] = ji
413 "CaloCalTopoClusters",
"EMTopoClusters", jetinputtype=
"EMTopo",
416 "CaloCalTopoClusters",
"LCTopoClusters", jetinputtype=
"LCTopo",
419 "CaloCalTopoClusters",
"EMOriginTopoClusters", jetinputtype=
"EMTopo",
422 "CaloCalTopoClusters",
"MLOriginTopoClusters", jetinputtype=
"EMTopo",
425 "CaloCalTopoClusters",
"LCOriginTopoClusters", jetinputtype=
"LCTopo",
429 "CaloCalTopoClusters_EleRM",
"LCOriginTopoClusters_EleRM", jetinputtype=
"LCTopo",
432 "CaloCalTopoClusters",
"LCOriginTopoCSSK", jetinputtype=
"LCTopo",
440 JetInputConstitSeq(
"EMPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'JetETMissParticleFlowObjects',
'CHSParticleFlowObjects'),
443 JetInputConstitSeq(
"GPFlowML", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalClusterMLCorrectedParticleFlowObjects',
'CHSGlobalClusterMLCorrectedParticleFlowObjects', label =
'EMPFlow',),
446 JetInputConstitSeq(
"GPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSGParticleFlowObjects',
449 JetInputConstitSeq(
"GPFlow_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noElectrons',
'CHSGParticleFlowObjects_noElectrons',
450 label=
'EMPFlow_noElectrons'),
452 JetInputConstitSeq(
"GPFlow_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noMuons',
'CHSGParticleFlowObjects_noMuons',
453 label=
'EMPFlow_noMuons'),
455 JetInputConstitSeq(
"GPFlow_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noLeptons',
'CHSGParticleFlowObjects_noLeptons',
456 label=
'EMPFlow_noLeptons'),
459 JetInputConstitSeq(
"GPFlow_tauSeedEleRM", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_tauSeedEleRM',
'CHSGParticleFlowObjects_tauSeedEleRM',
460 label=
'EMPFlow_tauSeedEleRM'),
464 JetInputConstitSeq(
"GPFlowByVtx", xAODType.FlowElement, [
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSByVtxGParticleFlowObjects',
465 label=
'EMPFlowByVertex', byVertex=
True),
468 JetInputConstitSeq(
"EMPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
469 'JetETMissParticleFlowObjects',
'CSSKParticleFlowObjects', jetinputtype=
"EMPFlow"),
471 JetInputConstitSeq(
"GPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
472 'GlobalParticleFlowObjects',
'CSSKGParticleFlowObjects', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK'),
474 JetInputConstitSeq(
"GPFlowCSSK_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
475 'GlobalParticleFlowObjects_noElectrons',
'CSSKGParticleFlowObjects_noElectrons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noElectrons'),
477 JetInputConstitSeq(
"GPFlowCSSK_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
478 'GlobalParticleFlowObjects_noMuons',
'CSSKGParticleFlowObjects_noMuons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noMuons'),
480 JetInputConstitSeq(
"GPFlowCSSK_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
481 'GlobalParticleFlowObjects_noLeptons',
'CSSKGParticleFlowObjects_noLeptons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noLeptons'),
485 JetInputConstit(
"UFOCSSK_noElectrons", xAODType.FlowElement,
"UFOCSSK_noElectrons" ),
487 JetInputConstit(
"UFOCSSK_noMuons", xAODType.FlowElement,
"UFOCSSK_noMuons" ),
489 JetInputConstit(
"UFOCSSK_noLeptons", xAODType.FlowElement,
"UFOCSSK_noLeptons" ),
496 filterfn =
lambda flags : (
"CaloCalFwdTopoTowers" in flags.Input.Collections,
"Towers as ghosts disabled as CaloCalFwdTopoTowers are not in the input")),
500 JetInputConstit(
"Track", xAODType.TrackParticle, inputsFromContext(
"JetTracks")),
502 JetInputConstit(
"PV0Track", xAODType.TrackParticle, inputsFromContext(
"JetTracks", prefix=
"PV0")),
505 JetInputConstit(
"TrackLRT", xAODType.TrackParticle,
"InDetLargeD0TrackParticles",
506 filterfn = _largeRTracksExist),
512 JetInputConstit(
"UnAssocMuonSegment",
"UnAssocMuonSegment",
"UnAssocMuonSegments", ),
524 JetInputConstit(
"Truth", xAODType.TruthParticle,
"JetInputTruthParticles" ),
526 JetInputConstit(
"TruthWZ", xAODType.TruthParticle,
"JetInputTruthParticlesNoWZ", jetinputtype=
"TruthWZ"),
528 JetInputConstit(
"TruthDressedWZ", xAODType.TruthParticle,
"JetInputTruthParticlesDressedWZ", jetinputtype=
"TruthDressedWZ"),
530 JetInputConstit(
"TruthCharged", xAODType.TruthParticle,
"JetInputTruthParticlesCharged", jetinputtype=
"TruthCharged"),
534 JetInputConstit(
"TruthGEN", xAODType.TruthParticle,
"JetInputTruthParticlesGEN" , label=
"Truth"),
536 JetInputConstit(
"TruthGENWZ", xAODType.TruthParticle,
"JetInputTruthParticlesGENNoWZ", jetinputtype=
"TruthWZ", label=
"TruthWZ"),
541for label
in _truthFlavours:
542 _stdSeqList.append(
JetInputConstit(label, xAODType.TruthParticle,
"TruthLabel"+label ) )
545for jc
in _stdSeqList:
547 stdConstitDic[jc.name] = jc
555 """One Property of the CorrectPFO constit modifier is a tool.
556 we use this function as a placeholder, allowing to delay the intantiation of this property tool
557 to the time the modifier itself is instantiated.
559 from AthenaConfiguration.ComponentFactory
import CompFactory
560 return CompFactory.getComp(
"CP::WeightPFOTool")(
"weightPFO")
564vtxKey =
"PrimaryVertices"
565tvaKey =
"JetTrackVtxAssoc"
571 JetConstitModifier(
"Origin",
"CaloClusterConstituentsOrigin", prereqs=[inputsFromContext(
"Vertices")]),
579 prereqs=[inputsFromContext(
"Vertices")],
580 properties=dict(VertexContainerKey=propFromContext(
"Vertices"),
581 WeightPFOTool= _getPFOTool,
582 DoByVertex =
lambda jdef, _: jdef.byVertex) ),
589 prereqs=
lambda parentjdef : [inputsFromContext(
"Vertices"),] + ( [inputsFromContext(
"TVA")]
if parentjdef.context==
'default' else []) ,
590 properties=dict(VertexContainerKey=propFromContext(
"Vertices"),
591 TrackVertexAssociation=propFromContext(
"TVA"),
592 UseTrackToVertexTool=
lambda jdef,_: jdef.context
in [
'default',
'HL_LHC'],
593 DoByVertex =
lambda jdef, _: jdef.byVertex
597 JetConstitModifier(
"Vor",
"VoronoiWeightTool", properties=dict(doSpread=
False, nSigma=0) ),
604for ji
in _stdModList:
606 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)