ATLAS Offline Software
Loading...
Searching...
No Matches
JetInputConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2"""
3# JetInputConfig: A helper module providing function to setup algorithms
4# in charge of preparing input sources to jets (ex: EventDensity algo, track
5# or truth selection,...)
6#
7# Author: P-A Delsart #
8"""
9from AthenaConfiguration.ComponentFactory import CompFactory
10from AthenaCommon import Logging
11jetlog = Logging.logging.getLogger('JetInputConfig')
12
13# we can't add the imports here, because some modules may not be available
14# in all releases (Ex: AthGeneration, AnalysisBase...) so we delay the imports
15# inside the functions
16
17def _buildJetAlgForInput(suffix, tools ):
18 jetalg = CompFactory.JetAlgorithm("jetalg_"+suffix,
19 Tools = tools,
20 )
21 return jetalg
22
23def buildJetTrackUsedInFitDeco( parentjetdef, inputspec ):
24 from InDetUsedInFitTrackDecoratorTool.UsedInVertexFitTrackDecoratorConfig import (
25 getUsedInVertexFitTrackDecoratorAlg)
26 trkProperties = parentjetdef._contextDic
27
28 return getUsedInVertexFitTrackDecoratorAlg(trackCont=trkProperties["Tracks"],
29 vtxCont= trkProperties["Vertices"])
30
31
32def buildJetInputTruth(parentjetdef, truthmod):
33 truthmod = truthmod or ""
34 from ParticleJetTools.ParticleJetToolsConfig import getCopyTruthJetParticles
35 return _buildJetAlgForInput("truthpartcopy_"+truthmod,
36 tools = [ getCopyTruthJetParticles(truthmod, parentjetdef._cflags) ]
37 )
38
39
40def buildJetInputTruthGEN(parentjetdef, truthmod):
41 """ Build truth constituents as in EVTGEN jobs in the r21 config.
42 IMPORTANT : this is expected to be temporary, only to reproduce the EVTGEN r21 config with the new config. The definitions should be harmonized with reco-level at some point and this function removed.
43 The source for r21 EVTGEN config was in GeneratorFilters/share/common/GenerateTruthJets.py
44 """
45 truthmod = truthmod or ""
46 from ParticleJetTools.ParticleJetToolsConfig import getCopyTruthJetParticlesGEN
47 return _buildJetAlgForInput("truthpartcopy_"+truthmod,
48 tools = [ getCopyTruthJetParticlesGEN(truthmod, parentjetdef._cflags) ]
49 )
50
51
52def buildLabelledTruth(parentjetdef, truthmod):
53 from ParticleJetTools.ParticleJetToolsConfig import getCopyTruthLabelParticles
54 tool = getCopyTruthLabelParticles(truthmod)
55 return _buildJetAlgForInput("truthlabelcopy_"+truthmod,
56 tools = [ tool ]
57 )
58
59def buildPV0TrackSel(parentjetdef, spec):
60 from TrackVertexAssociationTool.TrackVertexAssociationToolConfig import getTTVAToolForReco
61 trkOptions = parentjetdef._contextDic
62 tvaTool = getTTVAToolForReco("trackjetTVAtool",
63 HardScatterLinkDeco = "",
64 WorkingPoint = "Nonprompt_All_MaxWeight",
65 TrackContName = trkOptions['JetTracksQualityCuts']
66 )
67 alg = CompFactory.PV0TrackSelectionAlg("pv0tracksel_trackjet",
68 InputTrackContainer = trkOptions['JetTracksQualityCuts'],
69 VertexContainer = trkOptions['Vertices'],
70 OutputTrackContainer = "PV0"+trkOptions['JetTracks'],
71 TVATool = tvaTool,
72 )
73 return alg
74
75
76def buildPFlowSel(parentjetdef, spec, egammaPEB=False):
77 egammaPEB = parentjetdef._cflags.Input.TriggerStream=='physics_EgammaPEBTLA' or egammaPEB
78 if egammaPEB:
79 jetlog.warning("Configuring muon-less reconstruction for EgammaPEB stream")
80 return CompFactory.JetPFlowSelectionAlg( "pflowselalg",
81 electronIDToExclude = "LHMedium",
82 ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
83 NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
84 ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects",
85 NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects",
86 isEgammaPEB = egammaPEB # Autoconfigure muon-less reconstruction
87 )
88
89#This is to be used to seed tau jets which exclude electrons.
90#Therefore it is an inclusive selection, which means we have
91#to change the default settings and include all muons.
92#Then we also exclude charged + neutral FE linked to electrons
93#passing the relevant egamma PID WP.
94def buildPFlowSel_tauSeedEleRM(parentjetdef,spec):
95 return CompFactory.JetPFlowSelectionAlg( "pflowselalg_tauSeedEleRM",
96 electronIDToExclude = "LHMedium",
97 ElectronInputContainer="Electrons",
98 excludeNeutralElectronFE=True,
99 muonIDToInclude = "Loose",
100 excludeChargedMuonFE=False,
101 includeChargedMuonFE=True,
102 includeNeutralMuonFE=True,
103 ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
104 NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
105 ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_tauSeedEleRM",
106 NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_tauSeedEleRM"
107 )
108
109def buildPFlowSel_noElectrons(parentjetdef,spec):
110 return CompFactory.JetPFlowSelectionAlg( "pflowselalg_noElectrons",
111 electronIDToExclude = "LHMedium",
112 ElectronInputContainer="Electrons",
113 excludeNeutralElectronFE=True,
114 ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
115 NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
116 ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_noElectrons",
117 NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_noElectrons"
118 )
119
120def buildPFlowSel_noMuons(parentjetdef,spec):
121 return CompFactory.JetPFlowSelectionAlg( "pflowselalg_noMuons",
122 electronIDToExclude = "LHMedium",
123 muonIDToExclude = "Medium",
124 excludeNeutralMuonFE=True,
125 ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
126 NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
127 ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_noMuons",
128 NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_noMuons"
129 )
130
131def buildPFlowSel_noLeptons(parentjetdef,spec):
132 return CompFactory.JetPFlowSelectionAlg( "pflowselalg_noLeptons",
133 electronIDToExclude = "LHMedium",
134 ElectronInputContainer="Electrons",
135 excludeNeutralElectronFE=True,
136 muonIDToExclude = "Medium",
137 excludeNeutralMuonFE=True,
138 ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
139 NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
140 ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_noLeptons",
141 NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_noLeptons"
142 )
143
144
145
146def buildEventShapeAlg(jetOrConstitdef, inputspec, voronoiRf = 0.9, radius = 0.4, suffix = None ):
147 """Function producing an EventShapeAlg to calculate
148 median energy density for pileup correction"""
149
150 from .JetRecConfig import getPJContName
151 from EventShapeTools.EventDensityConfig import configEventDensityTool, getEventShapeName
152
153
154 pjContName = getPJContName(jetOrConstitdef,suffix)
155 nameprefix = inputspec or ""
156 rhotool = configEventDensityTool(
157 f"EventDensity_{nameprefix}Kt4{pjContName}",
158 jetOrConstitdef,
159 InputContainer = pjContName,
160 OutputContainer = getEventShapeName(jetOrConstitdef, nameprefix=nameprefix, suffix=suffix, radius=radius),
161 JetRadius = radius,
162 VoronoiRfact = voronoiRf,
163 )
164
165 eventshapealg = CompFactory.EventDensityAthAlg(
166 f"EventDensity_{nameprefix}Kt4{pjContName}Alg",
167 EventDensityTool = rhotool )
168
169 return eventshapealg
170
buildPV0TrackSel(parentjetdef, spec)
buildPFlowSel_noElectrons(parentjetdef, spec)
buildJetInputTruth(parentjetdef, truthmod)
buildPFlowSel(parentjetdef, spec, egammaPEB=False)
buildLabelledTruth(parentjetdef, truthmod)
_buildJetAlgForInput(suffix, tools)
buildPFlowSel_noLeptons(parentjetdef, spec)
buildPFlowSel_tauSeedEleRM(parentjetdef, spec)
buildJetTrackUsedInFitDeco(parentjetdef, inputspec)
buildPFlowSel_noMuons(parentjetdef, spec)
buildJetInputTruthGEN(parentjetdef, truthmod)
buildEventShapeAlg(jetOrConstitdef, inputspec, voronoiRf=0.9, radius=0.4, suffix=None)