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 =
"UnAssociated muon segments not present"
120 if "UnAssocMuonSegments" in flags.Input.Collections:
122 if flags.Input.RunNumbers[0] < 410000:
124 return False, warning
127 return False, warning
128 return flags.Reco.EnableCombinedMuon, warning
131 warning =
"Large radius tracking did not run"
132 if "InDetLargeD0TrackParticles" in flags.Input.Collections:
143 return False, warning
163 algoBuilder = inputcfg.buildPFlowSel,
164 prereqs = [
"input:JetETMissParticleFlowObjects", ],
167 JetInputExternal(
"GlobalParticleFlowObjects_noElectrons", xAODType.FlowElement,
168 algoBuilder = inputcfg.buildPFlowSel_noElectrons,
169 prereqs = [
"input:JetETMissParticleFlowObjects", ],
173 algoBuilder = inputcfg.buildPFlowSel_noMuons,
174 prereqs = [
"input:JetETMissParticleFlowObjects", ],
177 JetInputExternal(
"GlobalParticleFlowObjects_noLeptons", xAODType.FlowElement,
178 algoBuilder = inputcfg.buildPFlowSel_noLeptons,
179 prereqs = [
"input:JetETMissParticleFlowObjects", ],
182 JetInputExternal(
"GlobalParticleFlowObjects_tauSeedEleRM", xAODType.FlowElement,
183 algoBuilder = inputcfg.buildPFlowSel_tauSeedEleRM,
184 prereqs = [
"input:JetETMissParticleFlowObjects", ],
190 filterfn = _trackParticleInputsExist
197 filterfn =
lambda flags : (flags.Beam.Type == BeamType.Collisions, f
"No vertexing with {flags.Beam.Type}"),
202 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
207 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
212 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
217 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False )
223 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
True )
228 algoBuilder = inputcfg.buildJetTrackUsedInFitDeco
232 lambda jdef, _ : jrtcfg.getJetTrackVtxAlg(
234 algname=
"jetTVA" if jdef.context
in [
"HL_LHC",
"default",
"notrk",
""]
else f
"jetTVA_{jdef.context}",
235 WorkingPoint=
"Nonprompt_All_MaxWeight"
242 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
247 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
252 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVA_" + jdef.context, WorkingPoint=
"Nonprompt_All_MaxWeight"),
257 JetInputExternal(
"EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
258 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
259 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name]
262 JetInputExternal(
"EleRM_EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
263 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
264 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name],
267 JetInputExternal(
"HLT_EventDensity",
"EventShape", algoBuilder = inputcfg.buildEventShapeAlg,
268 containername =
lambda jetdef, specs : (specs
or "")+
"Kt4"+jetdef.inputdef.label+
"EventShape",
269 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name],
276 filterfn = _muonSegmentInputsExist
281 filterfn = _unassocMuonSegmentInputsExist
289 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC ),
295 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"NoWZ"),
301 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"DressedWZ"),
306 algoBuilder = inputcfg.buildJetInputTruth, filterfn=isMC,specs=
"Charged"),
312 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC ),
315 algoBuilder = inputcfg.buildJetInputTruthGEN, filterfn=isMC,specs=
"NoWZ"),
320 prereqs=[
"input:JetSelectedTracks_trackSelOpt",
"input:JetTrackUsedInFitDeco"],
321 algoBuilder = inputcfg.buildPV0TrackSel ),
326 prereqs =
lambda parentjdef : []
if (
isAnalysisRelease()
or 'UFOCSSK' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK'],
327 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
328 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK'])
332 prereqs =
lambda parentjdef : []
if (
isAnalysisRelease()
or 'UFOCSSK_noElectrons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noElectrons'],
333 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noElectrons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
334 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noElectrons'])
338 prereqs =
lambda parentjdef : []
if (
isAnalysisRelease()
or 'UFOCSSK_noMuons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noMuons'],
339 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noMuons' in flag.Input.Collections),
"Can't build UFO in Analysis projects and not UFOCSSK in input") ,
340 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlowCSSK_noMuons'])
345 prereqs =
lambda parentjdef : []
if (
isAnalysisRelease()
or 'UFOCSSK_noLeptons' in parentjdef._cflags.Input.Collections )
else [
'input:GPFlowCSSK_noLeptons'],
346 filterfn =
lambda flag : ( (
not isAnalysisRelease()
or 'UFOCSSK_noLeptons' 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_noLeptons'])
351 prereqs = [
'input:GPFlow'],
352 algoBuilder =
lambda jdef,_ : tcccfg.runUFOReconstruction(jdef._cflags, stdConstitDic[
'GPFlow'])
358 _truthFlavours = [
"BHadronsInitial",
"BHadronsFinal",
"BQuarksFinal",
359 "CHadronsInitial",
"CHadronsFinal",
"CQuarksFinal",
361 "WBosons",
"ZBosons",
"HBosons",
"TQuarksFinal",
363 for label
in _truthFlavours:
365 _stdInputList.append(
JetInputExternal(
"TruthLabel"+label, xAODType.TruthParticle,
366 algoBuilder = inputcfg.buildLabelledTruth,
367 filterfn=isMC, specs = label ) )
372 for ji
in _stdInputList:
374 stdInputExtDic[ji.name] = ji
396 "CaloCalTopoClusters",
"EMTopoClusters", jetinputtype=
"EMTopo",
399 "CaloCalTopoClusters",
"LCTopoClusters", jetinputtype=
"LCTopo",
402 "CaloCalTopoClusters",
"EMOriginTopoClusters", jetinputtype=
"EMTopo",
405 "CaloCalTopoClusters",
"LCOriginTopoClusters", jetinputtype=
"LCTopo",
409 "CaloCalTopoClusters_EleRM",
"LCOriginTopoClusters_EleRM", jetinputtype=
"LCTopo",
412 "CaloCalTopoClusters",
"LCOriginTopoCSSK", jetinputtype=
"LCTopo",
422 JetInputConstitSeq(
"EMPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'JetETMissParticleFlowObjects',
'CHSParticleFlowObjects'),
425 JetInputConstitSeq(
"GPFlow", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSGParticleFlowObjects',
428 JetInputConstitSeq(
"GPFlow_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noElectrons',
'CHSGParticleFlowObjects_noElectrons',
429 label=
'EMPFlow_noElectrons'),
431 JetInputConstitSeq(
"GPFlow_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noMuons',
'CHSGParticleFlowObjects_noMuons',
432 label=
'EMPFlow_noMuons'),
434 JetInputConstitSeq(
"GPFlow_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_noLeptons',
'CHSGParticleFlowObjects_noLeptons',
435 label=
'EMPFlow_noLeptons'),
438 JetInputConstitSeq(
"GPFlow_tauSeedEleRM", xAODType.FlowElement,[
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects_tauSeedEleRM',
'CHSGParticleFlowObjects_tauSeedEleRM',
439 label=
'EMPFlow_tauSeedEleRM'),
443 JetInputConstitSeq(
"GPFlowByVtx", xAODType.FlowElement, [
"CorrectPFO",
"CHS"] ,
'GlobalParticleFlowObjects',
'CHSByVtxGParticleFlowObjects',
444 label=
'EMPFlowByVertex', byVertex=
True),
447 JetInputConstitSeq(
"EMPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
448 'JetETMissParticleFlowObjects',
'CSSKParticleFlowObjects', jetinputtype=
"EMPFlow"),
450 JetInputConstitSeq(
"GPFlowCSSK", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
451 'GlobalParticleFlowObjects',
'CSSKGParticleFlowObjects', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK'),
453 JetInputConstitSeq(
"GPFlowCSSK_noElectrons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
454 'GlobalParticleFlowObjects_noElectrons',
'CSSKGParticleFlowObjects_noElectrons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noElectrons'),
456 JetInputConstitSeq(
"GPFlowCSSK_noMuons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
457 'GlobalParticleFlowObjects_noMuons',
'CSSKGParticleFlowObjects_noMuons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noMuons'),
459 JetInputConstitSeq(
"GPFlowCSSK_noLeptons", xAODType.FlowElement,[
"CorrectPFO",
"CS",
"SK",
"CHS"] ,
460 'GlobalParticleFlowObjects_noLeptons',
'CSSKGParticleFlowObjects_noLeptons', jetinputtype=
"EMPFlow", label=
'EMPFlowCSSK_noLeptons'),
464 JetInputConstit(
"UFOCSSK_noElectrons", xAODType.FlowElement,
"UFOCSSK_noElectrons" ),
466 JetInputConstit(
"UFOCSSK_noMuons", xAODType.FlowElement,
"UFOCSSK_noMuons" ),
468 JetInputConstit(
"UFOCSSK_noLeptons", xAODType.FlowElement,
"UFOCSSK_noLeptons" ),
475 filterfn =
lambda flags : (
"CaloCalFwdTopoTowers" in flags.Input.Collections,
"Towers as ghosts disabled as CaloCalFwdTopoTowers are not in the input")),
484 JetInputConstit(
"TrackLRT", xAODType.TrackParticle,
"InDetLargeD0TrackParticles",
485 filterfn = _largeRTracksExist),
491 JetInputConstit(
"UnAssocMuonSegment",
"UnAssocMuonSegment",
"UnAssocMuonSegments", ),
503 JetInputConstit(
"Truth", xAODType.TruthParticle,
"JetInputTruthParticles" ),
505 JetInputConstit(
"TruthWZ", xAODType.TruthParticle,
"JetInputTruthParticlesNoWZ", jetinputtype=
"TruthWZ"),
507 JetInputConstit(
"TruthDressedWZ", xAODType.TruthParticle,
"JetInputTruthParticlesDressedWZ", jetinputtype=
"TruthDressedWZ"),
509 JetInputConstit(
"TruthCharged", xAODType.TruthParticle,
"JetInputTruthParticlesCharged", jetinputtype=
"TruthCharged"),
513 JetInputConstit(
"TruthGEN", xAODType.TruthParticle,
"JetInputTruthParticlesGEN" , label=
"Truth"),
515 JetInputConstit(
"TruthGENWZ", xAODType.TruthParticle,
"JetInputTruthParticlesGENNoWZ", jetinputtype=
"TruthWZ", label=
"TruthWZ"),
520 for label
in _truthFlavours:
521 _stdSeqList.append(
JetInputConstit(label, xAODType.TruthParticle,
"TruthLabel"+label ) )
524 for jc
in _stdSeqList:
526 stdConstitDic[jc.name] = jc
534 """One Property of the CorrectPFO constit modifier is a tool.
535 we use this function as a placeholder, allowing to delay the intantiation of this property tool
536 to the time the modifier itself is instantiated.
538 from AthenaConfiguration.ComponentFactory
import CompFactory
539 return CompFactory.getComp(
"CP::WeightPFOTool")(
"weightPFO")
543 vtxKey =
"PrimaryVertices"
544 tvaKey =
"JetTrackVtxAssoc"
559 WeightPFOTool= _getPFOTool,
560 DoByVertex =
lambda jdef, _: jdef.byVertex) ),
570 UseTrackToVertexTool=
lambda jdef,_: jdef.context
in [
'default',
'HL_LHC'],
571 DoByVertex =
lambda jdef, _: jdef.byVertex
575 JetConstitModifier(
"Vor",
"VoronoiWeightTool", properties=dict(doSpread=
False, nSigma=0) ),
582 for ji
in _stdModList:
584 stdContitModifDic[ji.name] = ji