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