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,
"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", ],
173 filterfn = _trackParticleInputsExist
180 filterfn =
lambda flags : (flags.Beam.Type == BeamType.Collisions, f
"No vertexing with {flags.Beam.Type}"),
185 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
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 )
206 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
True )
211 algoBuilder = inputcfg.buildJetTrackUsedInFitDeco
215 lambda jdef, _ : jrtcfg.getJetTrackVtxAlg(
217 algname=
"jetTVA" if jdef.context
in [
"HL_LHC",
"default",
"notrk",
""]
else f
"jetTVA_{jdef.context}",
218 WorkingPoint=
"Nonprompt_All_MaxWeight"
225 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, 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 JetInputExternal(
"EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
241 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
242 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name]
245 JetInputExternal(
"EleRM_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(
"HLT_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],
259 filterfn = _muonSegmentInputsExist
267 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC ),
273 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"NoWZ"),
279 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"DressedWZ"),
284 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"Charged"),
290 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC ),
293 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC,specs=
"NoWZ"),
298 prereqs=[
"input:JetSelectedTracks_trackSelOpt",
"input:JetTrackUsedInFitDeco"],
299 algoBuilder = inputcfg.buildPV0TrackSel ),
304 prereqs =
lambda parentjdef : []
if (
isAnalysisRelease()
or 'UFOCSSK' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK'],
305 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
306 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK'])
310 prereqs =
lambda parentjdef : []
if (
isAnalysisRelease()
or 'UFOCSSK_noElectrons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noElectrons'],
311 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noElectrons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
312 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noElectrons'])
316 prereqs =
lambda parentjdef : []
if (
isAnalysisRelease()
or 'UFOCSSK_noMuons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noMuons'],
317 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noMuons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
318 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noMuons'])
323 prereqs =
lambda parentjdef : []
if (
isAnalysisRelease()
or 'UFOCSSK_noLeptons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noLeptons'],
324 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noLeptons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
325 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noLeptons'])
329 prereqs = [
'input:GPFlow'],
330 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlow'])
336 _truthFlavours = [
"BHadronsInitial",
"BHadronsFinal",
"BQuarksFinal",
337 "CHadronsInitial",
"CHadronsFinal",
"CQuarksFinal",
339 "WBosons",
"ZBosons",
"HBosons",
"TQuarksFinal",
341 for label
in _truthFlavours:
343 _stdInputList.append(
JetInputExternal(
"TruthLabel"+label, xAODType.TruthParticle,
344 algoBuilder = inputcfg.buildLabelledTruth,
345 filterfn=isMC, specs = label ) )
350 for ji
in _stdInputList:
352 stdInputExtDic[ji.name] = ji
374 "CaloCalTopoClusters",
"EMTopoClusters", jetinputtype=
"EMTopo",
377 "CaloCalTopoClusters",
"LCTopoClusters", jetinputtype=
"LCTopo",
380 "CaloCalTopoClusters",
"EMOriginTopoClusters", jetinputtype=
"EMTopo",
383 "CaloCalTopoClusters",
"LCOriginTopoClusters", jetinputtype=
"LCTopo",
387 "CaloCalTopoClusters_EleRM",
"LCOriginTopoClusters_EleRM", jetinputtype=
"LCTopo",
390 "CaloCalTopoClusters",
"LCOriginTopoCSSK", jetinputtype=
"LCTopo",
400 JetInputConstitSeq(
"EMPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'JetETMissParticleFlowObjects',
'CHSParticleFlowObjects'),
403 JetInputConstitSeq(
"GPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSGParticleFlowObjects',
406 JetInputConstitSeq(
"GPFlow_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noElectrons',
'CHSGParticleFlowObjects_noElectrons',
407 label=
'EMPFlow_noElectrons'),
409 JetInputConstitSeq(
"GPFlow_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noMuons',
'CHSGParticleFlowObjects_noMuons',
410 label=
'EMPFlow_noMuons'),
412 JetInputConstitSeq(
"GPFlow_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noLeptons',
'CHSGParticleFlowObjects_noLeptons',
413 label=
'EMPFlow_noLeptons'),
416 JetInputConstitSeq(
"GPFlowByVtx", xAODType.FlowElement, [
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSByVtxGParticleFlowObjects',
417 label=
'EMPFlowByVertex', byVertex=
True),
420 JetInputConstitSeq(
"EMPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
421 'JetETMissParticleFlowObjects',
'CSSKParticleFlowObjects', jetinputtype=
"EMPFlow"),
423 JetInputConstitSeq(
"GPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
424 'GlobalParticleFlowObjects',
'CSSKGParticleFlowObjects', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK'),
426 JetInputConstitSeq(
"GPFlowCSSK_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
427 'GlobalParticleFlowObjects_noElectrons',
'CSSKGParticleFlowObjects_noElectrons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noElectrons'),
429 JetInputConstitSeq(
"GPFlowCSSK_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
430 'GlobalParticleFlowObjects_noMuons',
'CSSKGParticleFlowObjects_noMuons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noMuons'),
432 JetInputConstitSeq(
"GPFlowCSSK_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
433 'GlobalParticleFlowObjects_noLeptons',
'CSSKGParticleFlowObjects_noLeptons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noLeptons'),
437 JetInputConstit(
"UFOCSSK_noElectrons", xAODType.FlowElement,
"UFOCSSK_noElectrons" ),
439 JetInputConstit(
"UFOCSSK_noMuons", xAODType.FlowElement,
"UFOCSSK_noMuons" ),
441 JetInputConstit(
"UFOCSSK_noLeptons", xAODType.FlowElement,
"UFOCSSK_noLeptons" ),
448 filterfn =
lambda flags : (
"CaloCalFwdTopoTowers" in flags.Input.Collections,
"Towers as ghosts disabled as CaloCalFwdTopoTowers are not in the input")),
457 JetInputConstit(
"TrackLRT", xAODType.TrackParticle,
"InDetLargeD0TrackParticles",
458 filterfn = _largeRTracksExist),
474 JetInputConstit(
"Truth", xAODType.TruthParticle,
"JetInputTruthParticles" ),
476 JetInputConstit(
"TruthWZ", xAODType.TruthParticle,
"JetInputTruthParticlesNoWZ", jetinputtype=
"TruthWZ"),
478 JetInputConstit(
"TruthDressedWZ", xAODType.TruthParticle,
"JetInputTruthParticlesDressedWZ", jetinputtype=
"TruthDressedWZ"),
480 JetInputConstit(
"TruthCharged", xAODType.TruthParticle,
"JetInputTruthParticlesCharged", jetinputtype=
"TruthCharged"),
484 JetInputConstit(
"TruthGEN", xAODType.TruthParticle,
"JetInputTruthParticlesGEN" , label=
"Truth"),
486 JetInputConstit(
"TruthGENWZ", xAODType.TruthParticle,
"JetInputTruthParticlesGENNoWZ", jetinputtype=
"TruthWZ", label=
"TruthWZ"),
491 for label
in _truthFlavours:
492 _stdSeqList.append(
JetInputConstit(label, xAODType.TruthParticle,
"TruthLabel"+label ) )
495 for jc
in _stdSeqList:
497 stdConstitDic[jc.name] = jc
505 """One Property of the CorrectPFO constit modifier is a tool.
506 we use this function as a placeholder, allowing to delay the intantiation of this property tool
507 to the time the modifier itself is instantiated.
509 from AthenaConfiguration.ComponentFactory
import CompFactory
510 return CompFactory.getComp(
"CP::WeightPFOTool")(
"weightPFO")
514 vtxKey =
"PrimaryVertices"
515 tvaKey =
"JetTrackVtxAssoc"
530 WeightPFOTool= _getPFOTool,
531 DoByVertex =
lambda jdef, _: jdef.byVertex) ),
541 UseTrackToVertexTool=
lambda jdef,_: jdef.context
in [
'default',
'HL_LHC'],
542 DoByVertex =
lambda jdef, _: jdef.byVertex
546 JetConstitModifier(
"Vor",
"VoronoiWeightTool", properties=dict(doSpread=
False, nSigma=0) ),
553 for ji
in _stdModList:
555 stdContitModifDic[ji.name] = ji