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
16 from .JetDefinition
import xAODType, JetInputConstitSeq, JetInputExternal, JetConstitModifier, JetInputConstit
17 from .StandardJetContext
import inputsFromContext, propFromContext
18 from .JetRecConfig
import isAnalysisRelease
19 from AthenaConfiguration.Enums
import BeamType
23 from .Utilities
import ldict
31 import JetRecConfig.JetInputConfig
as inputcfg
33 import JetRecTools.JetRecToolsConfig
as jrtcfg
34 except ModuleNotFoundError:
39 import TrackCaloClusterRecTools.TrackCaloClusterConfig
as tcccfg
40 except 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
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
76 from MuonConfig.MuonReconstructionConfig
import MuonReconstructionCfg
77 flags = jetdef._cflags
81 if not jetdef._cflags.Jet.doUpstreamDependencies:
83 from eflowRec.PFRun3Config
import PFCfg
84 return PFCfg(jetdef._cflags)
100 warning =
"Tracking is disabled and no InDetTrackParticles in input"
101 if "InDetTrackParticles" in flags.Input.Collections:
106 return False, warning
107 return flags.Reco.EnableTracking, warning
110 warning =
"Muon reco is disabled"
111 if "MuonSegments" in flags.Input.Collections:
115 return False, warning
116 return flags.Reco.EnableCombinedMuon, warning
119 warning =
"Large radius tracking did not run"
120 if "InDetLargeD0TrackParticles" in flags.Input.Collections:
131 return False, warning
151 algoBuilder = inputcfg.buildPFlowSel,
152 prereqs = [
"input:JetETMissParticleFlowObjects", ],
155 JetInputExternal(
"GlobalParticleFlowObjects_noElectrons", xAODType.FlowElement,
156 algoBuilder = inputcfg.buildPFlowSel_noElectrons,
157 prereqs = [
"input:JetETMissParticleFlowObjects", ],
161 algoBuilder = inputcfg.buildPFlowSel_noMuons,
162 prereqs = [
"input:JetETMissParticleFlowObjects", ],
165 JetInputExternal(
"GlobalParticleFlowObjects_noLeptons", xAODType.FlowElement,
166 algoBuilder = inputcfg.buildPFlowSel_noLeptons,
167 prereqs = [
"input:JetETMissParticleFlowObjects", ],
170 JetInputExternal(
"GlobalParticleFlowObjects_tauSeedEleRM", xAODType.FlowElement,
171 algoBuilder = inputcfg.buildPFlowSel_tauSeedEleRM,
172 prereqs = [
"input:JetETMissParticleFlowObjects", ],
178 filterfn = _trackParticleInputsExist
185 filterfn =
lambda flags : (flags.Beam.Type == BeamType.Collisions, f
"No vertexing with {flags.Beam.Type}"),
190 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
195 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
200 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
205 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
211 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
True )
216 algoBuilder = inputcfg.buildJetTrackUsedInFitDeco
220 lambda jdef, _ : jrtcfg.getJetTrackVtxAlg(
222 algname=
"jetTVA" if jdef.context
in [
"HL_LHC",
"default",
"notrk",
""]
else f
"jetTVA_{jdef.context}",
223 WorkingPoint=
"Nonprompt_All_MaxWeight"
230 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
235 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
240 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
245 JetInputExternal(
"EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
246 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
247 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name]
250 JetInputExternal(
"EleRM_EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
251 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
252 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name],
255 JetInputExternal(
"HLT_EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
256 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
257 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name],
264 filterfn = _muonSegmentInputsExist
272 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC ),
278 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"NoWZ"),
284 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"DressedWZ"),
289 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"Charged"),
295 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC ),
298 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC,specs=
"NoWZ"),
303 prereqs=[
"input:JetSelectedTracks_trackSelOpt",
"input:JetTrackUsedInFitDeco"],
304 algoBuilder = inputcfg.buildPV0TrackSel ),
309 prereqs =
lambda parentjdef : []
if (
isAnalysisRelease()
or 'UFOCSSK' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK'],
310 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
311 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK'])
315 prereqs =
lambda parentjdef : []
if (
isAnalysisRelease()
or 'UFOCSSK_noElectrons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noElectrons'],
316 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noElectrons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
317 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noElectrons'])
321 prereqs =
lambda parentjdef : []
if (
isAnalysisRelease()
or 'UFOCSSK_noMuons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noMuons'],
322 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noMuons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
323 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noMuons'])
328 prereqs =
lambda parentjdef : []
if (
isAnalysisRelease()
or 'UFOCSSK_noLeptons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noLeptons'],
329 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noLeptons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
330 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noLeptons'])
334 prereqs = [
'input:GPFlow'],
335 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlow'])
341 _truthFlavours = [
"BHadronsInitial",
"BHadronsFinal",
"BQuarksFinal",
342 "CHadronsInitial",
"CHadronsFinal",
"CQuarksFinal",
344 "WBosons",
"ZBosons",
"HBosons",
"TQuarksFinal",
346 for label
in _truthFlavours:
348 _stdInputList.append(
JetInputExternal(
"TruthLabel"+label, xAODType.TruthParticle,
349 algoBuilder = inputcfg.buildLabelledTruth,
350 filterfn=isMC, specs = label ) )
355 for ji
in _stdInputList:
357 stdInputExtDic[ji.name] = ji
379 "CaloCalTopoClusters",
"EMTopoClusters", jetinputtype=
"EMTopo",
382 "CaloCalTopoClusters",
"LCTopoClusters", jetinputtype=
"LCTopo",
385 "CaloCalTopoClusters",
"EMOriginTopoClusters", jetinputtype=
"EMTopo",
388 "CaloCalTopoClusters",
"LCOriginTopoClusters", jetinputtype=
"LCTopo",
392 "CaloCalTopoClusters_EleRM",
"LCOriginTopoClusters_EleRM", jetinputtype=
"LCTopo",
395 "CaloCalTopoClusters",
"LCOriginTopoCSSK", jetinputtype=
"LCTopo",
405 JetInputConstitSeq(
"EMPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'JetETMissParticleFlowObjects',
'CHSParticleFlowObjects'),
408 JetInputConstitSeq(
"GPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSGParticleFlowObjects',
411 JetInputConstitSeq(
"GPFlow_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noElectrons',
'CHSGParticleFlowObjects_noElectrons',
412 label=
'EMPFlow_noElectrons'),
414 JetInputConstitSeq(
"GPFlow_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noMuons',
'CHSGParticleFlowObjects_noMuons',
415 label=
'EMPFlow_noMuons'),
417 JetInputConstitSeq(
"GPFlow_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noLeptons',
'CHSGParticleFlowObjects_noLeptons',
418 label=
'EMPFlow_noLeptons'),
421 JetInputConstitSeq(
"GPFlow_tauSeedEleRM", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_tauSeedEleRM',
'CHSGParticleFlowObjects_tauSeedEleRM',
422 label=
'EMPFlow_tauSeedEleRM'),
426 JetInputConstitSeq(
"GPFlowByVtx", xAODType.FlowElement, [
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSByVtxGParticleFlowObjects',
427 label=
'EMPFlowByVertex', byVertex=
True),
430 JetInputConstitSeq(
"EMPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
431 'JetETMissParticleFlowObjects',
'CSSKParticleFlowObjects', jetinputtype=
"EMPFlow"),
433 JetInputConstitSeq(
"GPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
434 'GlobalParticleFlowObjects',
'CSSKGParticleFlowObjects', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK'),
436 JetInputConstitSeq(
"GPFlowCSSK_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
437 'GlobalParticleFlowObjects_noElectrons',
'CSSKGParticleFlowObjects_noElectrons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noElectrons'),
439 JetInputConstitSeq(
"GPFlowCSSK_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
440 'GlobalParticleFlowObjects_noMuons',
'CSSKGParticleFlowObjects_noMuons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noMuons'),
442 JetInputConstitSeq(
"GPFlowCSSK_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
443 'GlobalParticleFlowObjects_noLeptons',
'CSSKGParticleFlowObjects_noLeptons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noLeptons'),
447 JetInputConstit(
"UFOCSSK_noElectrons", xAODType.FlowElement,
"UFOCSSK_noElectrons" ),
449 JetInputConstit(
"UFOCSSK_noMuons", xAODType.FlowElement,
"UFOCSSK_noMuons" ),
451 JetInputConstit(
"UFOCSSK_noLeptons", xAODType.FlowElement,
"UFOCSSK_noLeptons" ),
458 filterfn =
lambda flags : (
"CaloCalFwdTopoTowers" in flags.Input.Collections,
"Towers as ghosts disabled as CaloCalFwdTopoTowers are not in the input")),
467 JetInputConstit(
"TrackLRT", xAODType.TrackParticle,
"InDetLargeD0TrackParticles",
468 filterfn = _largeRTracksExist),
484 JetInputConstit(
"Truth", xAODType.TruthParticle,
"JetInputTruthParticles" ),
486 JetInputConstit(
"TruthWZ", xAODType.TruthParticle,
"JetInputTruthParticlesNoWZ", jetinputtype=
"TruthWZ"),
488 JetInputConstit(
"TruthDressedWZ", xAODType.TruthParticle,
"JetInputTruthParticlesDressedWZ", jetinputtype=
"TruthDressedWZ"),
490 JetInputConstit(
"TruthCharged", xAODType.TruthParticle,
"JetInputTruthParticlesCharged", jetinputtype=
"TruthCharged"),
494 JetInputConstit(
"TruthGEN", xAODType.TruthParticle,
"JetInputTruthParticlesGEN" , label=
"Truth"),
496 JetInputConstit(
"TruthGENWZ", xAODType.TruthParticle,
"JetInputTruthParticlesGENNoWZ", jetinputtype=
"TruthWZ", label=
"TruthWZ"),
501 for label
in _truthFlavours:
502 _stdSeqList.append(
JetInputConstit(label, xAODType.TruthParticle,
"TruthLabel"+label ) )
505 for jc
in _stdSeqList:
507 stdConstitDic[jc.name] = jc
515 """One Property of the CorrectPFO constit modifier is a tool.
516 we use this function as a placeholder, allowing to delay the intantiation of this property tool
517 to the time the modifier itself is instantiated.
519 from AthenaConfiguration.ComponentFactory
import CompFactory
520 return CompFactory.getComp(
"CP::WeightPFOTool")(
"weightPFO")
524 vtxKey =
"PrimaryVertices"
525 tvaKey =
"JetTrackVtxAssoc"
540 WeightPFOTool= _getPFOTool,
541 DoByVertex =
lambda jdef, _: jdef.byVertex) ),
551 UseTrackToVertexTool=
lambda jdef,_: jdef.context
in [
'default',
'HL_LHC'],
552 DoByVertex =
lambda jdef, _: jdef.byVertex
556 JetConstitModifier(
"Vor",
"VoronoiWeightTool", properties=dict(doSpread=
False, nSigma=0) ),
563 for ji
in _stdModList:
565 stdContitModifDic[ji.name] = ji