ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleJetToolsConfig Namespace Reference

Functions

 isAnalysisRelease ()
 getMCTruthClassifier ()
 getCopyTruthLabelParticles (truthtype)
 getCopyTruthJetParticles (modspec, cflags)
 getCopyTruthJetParticlesGEN (modspec, cflags)
 _getCommonLabelNames (prefix)
 getJetDeltaRFlavorLabelTool (name='jetdrlabeler', jet_pt_min=5000, collection="Final", dr_max=0.3, use_barcode=False)
 getJetQuarkChargeLabelTool (name='jetquarkcharge', output_label="QuarkChargeTruthLabelID", hadron_label="HadronGhostInitialTruthLabelPdgId", parton_label="PartonExtendedTruthLabelID")
 getJetDeltaRLabelTool (jetdef, modspec)
 getJetQuarkChargeTool (jetdef, modspec)
 getJetDeltaRInitialLabelTool (jetdef, modspec)
 getJetGhostFlavorLabelTool (name="jetghostlabeler", collection="Final", use_barcode=False)
 getJetGhostInitialLabelTool (jetdef, modspec)
 getJetGhostLabelTool (jetdef, modspec)
 getJetTruthLabelTool (jetdef, modspec)
 getJetTruthLabelToolPrereqs (jetdef, modspec)
 getJetPileupLabelTool (jetdef, modspec)
 getJetIRCSafeLabelTool (jetdef, modspec)

Variables

 jrtlog = Logging.logging.getLogger('ParticleJetToolsConfig')
dict truthpartoptions
dict truthLabelSettings

Function Documentation

◆ _getCommonLabelNames()

_getCommonLabelNames ( prefix)
protected
Internal unlity to name labels

Returns a dictionary to configure labeling tools. Takes one
argument which is prefixed to each label.

Definition at line 107 of file ParticleJetToolsConfig.py.

107def _getCommonLabelNames(prefix):
108 """Internal unlity to name labels
109
110 Returns a dictionary to configure labeling tools. Takes one
111 argument which is prefixed to each label.
112 """
113 return dict(
114 LabelName=f"{prefix}TruthLabelID",
115 DoubleLabelName=f"{prefix}ExtendedTruthLabelID",
116 LabelPtName=f"{prefix}TruthLabelPt",
117 LabelLxyName=f"{prefix}TruthLabelLxy",
118 LabelDRName=f"{prefix}TruthLabelDR",
119 LabelPdgIdName=f"{prefix}TruthLabelPdgId",
120 LabelPositionDPhiName=f"{prefix}TruthLabelPositionDPhi",
121 LabelPositionDEtaName=f"{prefix}TruthLabelPositionDEta",
122 LabelBarcodeName=f"{prefix}TruthLabelBarcode",
123 ChildLxyName=f"{prefix}TruthLabelChildLxy",
124 ChildPtName=f"{prefix}TruthLabelChildPt",
125 ChildPdgIdName=f"{prefix}TruthLabelChildPdgId",
126 ChildPositionDPhiName=f"{prefix}TruthLabelChildPositionDPhi",
127 ChildPositionDEtaName=f"{prefix}TruthLabelChildPositionDEta",
128 )
129
130
131# ATLASRECTS-8290: remove use_barcode here

◆ getCopyTruthJetParticles()

getCopyTruthJetParticles ( modspec,
cflags )

Definition at line 63 of file ParticleJetToolsConfig.py.

63def getCopyTruthJetParticles(modspec, cflags):
64 truthclassif = getMCTruthClassifier()
65
66 truthpartcopy = CompFactory.CopyTruthJetParticles(
67 "truthpartcopy"+modspec,
68 OutputName="JetInputTruthParticles"+modspec,
69 MCTruthClassifier=truthclassif)
70 if modspec=="NoWZ":
71 truthpartcopy.IncludePromptLeptons=False
72 truthpartcopy.IncludePromptPhotons=False
73 truthpartcopy.IncludeMuons=True
74 truthpartcopy.IncludeNeutrinos=True
75 if modspec=="DressedWZ":
76 truthpartcopy.IncludePromptLeptons=False
77 truthpartcopy.IncludePromptPhotons=True
78 truthpartcopy.IncludeMuons=True
79 truthpartcopy.IncludeNeutrinos=True
80 truthpartcopy.DressingDecorationNames=['TruthParticles.dressedPhoton_e','TruthParticles.dressedPhoton_mu']
81
82 truthpartcopy.ExtraInputs = {( 'xAOD::TruthParticleContainer' , 'StoreGateSvc+TruthParticles.dressedPhoton_e' ),
83 ( 'xAOD::TruthParticleContainer' , 'StoreGateSvc+TruthParticles.dressedPhoton_mu' )}
84 if modspec=="Charged":
85 truthpartcopy.ChargedParticlesOnly=True
86 return truthpartcopy
87
88

◆ getCopyTruthJetParticlesGEN()

getCopyTruthJetParticlesGEN ( modspec,
cflags )
  Build truth constituents as in EVTGEN jobs in the r21 config.
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.
The source for r21 EVTGEN config was in GeneratorFilters/share/common/GenerateTruthJets.py

Definition at line 89 of file ParticleJetToolsConfig.py.

89def getCopyTruthJetParticlesGEN(modspec, cflags):
90 """ Build truth constituents as in EVTGEN jobs in the r21 config.
91 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.
92 The source for r21 EVTGEN config was in GeneratorFilters/share/common/GenerateTruthJets.py
93 """
94 truthclassif = getMCTruthClassifier()
95
96 if modspec == "":
97 return CompFactory.CopyTruthJetParticles("truthpartcopy",
98 OutputName="JetInputTruthParticlesGEN",
99 MCTruthClassifier=truthclassif)
100 elif modspec=="NoWZ":
101 return CompFactory.CopyTruthJetParticles("truthpartcopywz",
102 OutputName="JetInputTruthParticlesGENNoWZ",
103 MCTruthClassifier=truthclassif,
104 IncludePromptLeptons=False)
105
106

◆ getCopyTruthLabelParticles()

getCopyTruthLabelParticles ( truthtype)

Definition at line 43 of file ParticleJetToolsConfig.py.

43def getCopyTruthLabelParticles(truthtype):
44 toolProperties = {}
45 if truthtype == "Partons":
46 truthcategory = "Partons"
47 elif truthtype in ["WBosons", "ZBosons", "HBosons", "TQuarksFinal"]:
48 truthcategory = "BosonTop"
49 toolProperties['ParticleType'] = truthtype
50 else:
51 truthcategory = "FlavourLabel"
52 toolProperties['ParticleType'] = truthtype
53
54 tooltype = truthpartoptions[truthcategory]["ToolType"]
55 toolProperties.update( PtMin = truthpartoptions[truthcategory]["ptmin"],
56 OutputName = "TruthLabel"+truthtype)
57 ctp = tooltype("truthpartcopy_"+truthtype,
58 **toolProperties
59 )
60 return ctp
61
62# Generates input truth particle containers for truth jets

◆ getJetDeltaRFlavorLabelTool()

getJetDeltaRFlavorLabelTool ( name = 'jetdrlabeler',
jet_pt_min = 5000,
collection = "Final",
dr_max = 0.3,
use_barcode = False )
Get the standard flavor tagging delta-R labeling tool

Uses cone matching to B, C and tau truth particles.

Definition at line 132 of file ParticleJetToolsConfig.py.

132def getJetDeltaRFlavorLabelTool(name='jetdrlabeler', jet_pt_min=5000, collection="Final", dr_max=0.3, use_barcode=False):
133 """Get the standard flavor tagging delta-R labeling tool
134
135 Uses cone matching to B, C and tau truth particles.
136 """
137 prefix_to_name = "HadronConeExcl"
138 if collection != "Final":
139 prefix_to_name += collection
140 name+=collection
141
142 return CompFactory.ParticleJetDeltaRLabelTool(
143 name,
144 **_getCommonLabelNames(prefix_to_name),
145 BLabelName = "ConeExclBHadrons"+collection,
146 CLabelName = "ConeExclCHadrons"+collection,
147 TauLabelName = "ConeExclTausFinal",
148 BParticleCollection = "TruthLabelBHadrons"+collection,
149 CParticleCollection = "TruthLabelCHadrons"+collection,
150 TauParticleCollection = "TruthLabelTausFinal",
151 PartPtMin = 5000.,
152 DRMax = dr_max,
153 MatchMode = "MinDR",
154 JetPtMin = jet_pt_min,
155 useBarcode=use_barcode, # ATLASRECTS-8290: remove this eventually
156 )
157
158

◆ getJetDeltaRInitialLabelTool()

getJetDeltaRInitialLabelTool ( jetdef,
modspec )
returns a ParticleJetDeltaRLabelTool
Cone matching for B, C and tau truth for all but track jets.

This function is meant to be used as callback from JetRecConfig where
it is called as func(jetdef, modspec). Hence the jetdef argument even if not used in this case.

Definition at line 204 of file ParticleJetToolsConfig.py.

204def getJetDeltaRInitialLabelTool(jetdef, modspec):
205 """returns a ParticleJetDeltaRLabelTool
206 Cone matching for B, C and tau truth for all but track jets.
207
208 This function is meant to be used as callback from JetRecConfig where
209 it is called as func(jetdef, modspec). Hence the jetdef argument even if not used in this case.
210 """
211 jetptmin = float(modspec)
212 name = "jetdrlabeler_jetpt{0}GeV".format(int(jetptmin/1000))
213 return getJetDeltaRFlavorLabelTool(name, jetptmin, collection = "Initial")
214
215
216# ATLASRECTS-8290: remove use_barcode here

◆ getJetDeltaRLabelTool()

getJetDeltaRLabelTool ( jetdef,
modspec )
returns a ParticleJetDeltaRLabelTool
Cone matching for B, C and tau truth for all but track jets.

This function is meant to be used as callback from JetRecConfig where
it is called as func(jetdef, modspec). Hence the jetdef argument even if not used in this case.

Definition at line 178 of file ParticleJetToolsConfig.py.

178def getJetDeltaRLabelTool(jetdef, modspec):
179 """returns a ParticleJetDeltaRLabelTool
180 Cone matching for B, C and tau truth for all but track jets.
181
182 This function is meant to be used as callback from JetRecConfig where
183 it is called as func(jetdef, modspec). Hence the jetdef argument even if not used in this case.
184 """
185 jetptmin = float(modspec)
186 name = "jetdrlabeler_jetpt{0}GeV".format(int(jetptmin/1000))
187 return getJetDeltaRFlavorLabelTool(name, jetptmin)
188
189

◆ getJetGhostFlavorLabelTool()

getJetGhostFlavorLabelTool ( name = "jetghostlabeler",
collection = "Final",
use_barcode = False )

Definition at line 217 of file ParticleJetToolsConfig.py.

220 use_barcode=False):
221
222 prefix_to_name = "HadronGhost"
223 if collection != "Final":
224 prefix_to_name += collection
225 name+=collection
226 return CompFactory.ParticleJetGhostLabelTool(
227 name,
228 **_getCommonLabelNames(prefix_to_name),
229 GhostBName = "GhostBHadrons"+collection,
230 GhostCName = "GhostCHadrons"+collection,
231 GhostTauName = "GhostTausFinal",
232 useBarcode = use_barcode, # ATLASRECTS-8290: remove this eventually
233 PartPtMin = 5000.0
234 )
235

◆ getJetGhostInitialLabelTool()

getJetGhostInitialLabelTool ( jetdef,
modspec )
get ghost-based flavor tagging labeling

This is a wrapper for JetRecConfig where it's called as
func(jetdef, modspec)

Definition at line 236 of file ParticleJetToolsConfig.py.

236def getJetGhostInitialLabelTool(jetdef, modspec):
237 """get ghost-based flavor tagging labeling
238
239 This is a wrapper for JetRecConfig where it's called as
240 func(jetdef, modspec)
241 """
242 return getJetGhostFlavorLabelTool(modspec,collection = "Initial")
243

◆ getJetGhostLabelTool()

getJetGhostLabelTool ( jetdef,
modspec )
get ghost-based flavor tagging labeling

This is a wrapper for JetRecConfig where it's called as
func(jetdef, modspec)

Definition at line 244 of file ParticleJetToolsConfig.py.

244def getJetGhostLabelTool(jetdef, modspec):
245 """get ghost-based flavor tagging labeling
246
247 This is a wrapper for JetRecConfig where it's called as
248 func(jetdef, modspec)
249 """
250 return getJetGhostFlavorLabelTool(modspec)
251
252
253# Settings of JetTruthLabelingTool for each truth label

◆ getJetIRCSafeLabelTool()

getJetIRCSafeLabelTool ( jetdef,
modspec )
returns the IRCSafe labelling tools, applying four new flavour labelling
   schemes to truth particle jets and then matching them in terms of deltaR
   to any type of reconstructed jets (for now the radius of truth jets is
   set by hand to R = 0.4, so shouldnt really be used for other jets)

Definition at line 338 of file ParticleJetToolsConfig.py.

338def getJetIRCSafeLabelTool(jetdef, modspec):
339 """returns the IRCSafe labelling tools, applying four new flavour labelling
340 schemes to truth particle jets and then matching them in terms of deltaR
341 to any type of reconstructed jets (for now the radius of truth jets is
342 set by hand to R = 0.4, so shouldnt really be used for other jets)
343 """
344 tool_kwargs = dict(
345 LabelNameIFN = "IRCSafeLabelIFN",
346 LabelNameCMP = "IRCSafeLabelCMP",
347 LabelNameGHS = "IRCSafeLabelGHS",
348 LabelNameSDF = "IRCSafeLabelSDF",
349 LabelNameAKT = "IRCSafeLabelAKT",
350 BParticleCollection = "TruthLabelBHadronsFinal",
351 CParticleCollection = "TruthLabelCHadronsFinal",
352 TruthParticleCollection = "JetInputTruthParticles",
353 EnabledAlgorithms = ["IFN","CMP","GHS","SDF","AKT"],
354 TruthJetPtMin = 5000.0,
355 JetPtMin = 10000.0,
356 DRMax = 0.3,
357 TruthR = 0.4
358 )
359 return CompFactory.JetIRCSafeLabelTool("jetircsafelabeler", **tool_kwargs)

◆ getJetPileupLabelTool()

getJetPileupLabelTool ( jetdef,
modspec )

Definition at line 330 of file ParticleJetToolsConfig.py.

330def getJetPileupLabelTool(jetdef, modspec):
331
332 jetPileupLabelTool = CompFactory.JetPileupLabelingTool('pileuplabeler',
333 RecoJetContainer = jetdef.fullname(),
334 TruthJetContainer= "AntiKt4TruthDressedWZJets")
335
336 return jetPileupLabelTool
337

◆ getJetQuarkChargeLabelTool()

getJetQuarkChargeLabelTool ( name = 'jetquarkcharge',
output_label = "QuarkChargeTruthLabelID",
hadron_label = "HadronGhostInitialTruthLabelPdgId",
parton_label = "PartonExtendedTruthLabelID" )
Get the flavor tagging labeling tool to store the quark charge of a jet
It is necessary to have saved before an hadron label and a parton label, otherwise the code will break

Definition at line 159 of file ParticleJetToolsConfig.py.

162 parton_label = "PartonExtendedTruthLabelID"):
163 """Get the flavor tagging labeling tool to store the quark charge of a jet
164 It is necessary to have saved before an hadron label and a parton label, otherwise the code will break
165 """
166
167 import ParticleJetTools.quarkChargeMap as qcMap
168 charge_map = qcMap.hadrons_dict
169
170 return CompFactory.JetQuarkChargeLabelingTool(
171 name,
172 HadronDecorationName = hadron_label,
173 PartonDecorationName = parton_label,
174 HadronChargeMap = charge_map,
175 OutputName = output_label,
176 )
177

◆ getJetQuarkChargeTool()

getJetQuarkChargeTool ( jetdef,
modspec )
returns a JetQuarkChargeLabelingTool

This function is meant to be used as callback from JetRecConfig where
it is called as func(jetdef, modspec). Hence the jetdef argument even if not used.

Definition at line 190 of file ParticleJetToolsConfig.py.

190def getJetQuarkChargeTool(jetdef, modspec):
191 """returns a JetQuarkChargeLabelingTool
192
193 This function is meant to be used as callback from JetRecConfig where
194 it is called as func(jetdef, modspec). Hence the jetdef argument even if not used.
195 """
196 if modspec == "":
197 return getJetQuarkChargeLabelTool()
198
199 outputLabel,hadronLabel,partonLabel = modspec.split(",")
200
201 name = f"jetquarkcharge_{outputLabel}_{hadronLabel}_{partonLabel}"
202 return getJetQuarkChargeLabelTool(name,output_label = outputLabel, hadron_label = hadronLabel, parton_label = partonLabel)
203

◆ getJetTruthLabelTool()

getJetTruthLabelTool ( jetdef,
modspec )

Definition at line 287 of file ParticleJetToolsConfig.py.

287def getJetTruthLabelTool(jetdef, modspec):
288
289 isTruthJet = 'Truth' in jetdef.fullname()
290 addopts = None
291
292 if not isinstance(modspec, str):
293 raise ValueError("JetTruthLabelingTool can only be scheduled with str as modspec")
294 else:
295 if ':' in modspec:
296 truthLabel, addopts = modspec.split(':',1)
297 else:
298 truthLabel = modspec
299
300 kwargs = dict(truthLabelSettings[truthLabel])
301 if addopts:
302 if 'DeltaR' in addopts:
303 kwargs['UseGhostJetMatch'] = False
304
305 jetTruthLabelTool = CompFactory.JetTruthLabelingTool('truthlabeler_{0}'.format(truthLabel),
306 RecoJetContainer = jetdef.fullname(),
307 IsTruthJetCollection = isTruthJet,
308 TruthLabelName = truthLabel,
309 **kwargs)
310
311 return jetTruthLabelTool
312

◆ getJetTruthLabelToolPrereqs()

getJetTruthLabelToolPrereqs ( jetdef,
modspec )

Definition at line 313 of file ParticleJetToolsConfig.py.

313def getJetTruthLabelToolPrereqs(jetdef, modspec):
314 labelconfig = modspec
315 if ':' in modspec:
316 labelconfig = modspec.split(':')[0]
317 prereqs = []
318 if (jetdef._cflags.Input.isMC):
319 prereqs.append({
320 "R10WZTruthLabel_R22v1": "input:AntiKt10TruthDressedWZSoftDropBeta100Zcut10Jets",
321 "R4TruthLabel": "input:AntiKt4TruthJets",
322 "R4TruthDressedWZLabel": "input:AntiKt4TruthDressedWZJets",
323 "R4InTimeTruthLabel": "input:InTimeAntiKt4TruthJets",
324 "R4OutOfTimeTruthLabel": "input:OutOfTimeAntiKt4TruthJets",
325 "R10TruthLabel_R21Precision_2022v1": "input:AntiKt10TruthJets",
326 "R10TruthLabel_R22v1": "input:AntiKt10TruthSoftDropBeta100Zcut10Jets",
327 }[labelconfig])
328 return prereqs
329

◆ getMCTruthClassifier()

getMCTruthClassifier ( )

Definition at line 23 of file ParticleJetToolsConfig.py.

23def getMCTruthClassifier():
24 # Assume mc15 value
25 truthclassif = CompFactory.MCTruthClassifier(
26 "JetMCTruthClassifier"
27 )
28 if not isAnalysisRelease() :
29 truthclassif.xAODTruthLinkVector= ""
30 # Config neessary only for Athena releases
31 import os
32 if "AtlasProject" in os.environ.keys():
33 if os.environ["AtlasProject"] in ["Athena","AthDerivation"]:
34 truthclassif.ParticleCaloExtensionTool=""
35 return truthclassif
36
37# Generates truth particle containers for truth labeling

◆ isAnalysisRelease()

isAnalysisRelease ( )

Definition at line 19 of file ParticleJetToolsConfig.py.

19 def isAnalysisRelease():
20 return True
21
22# Putting MCTruthClassifier here as we needn't stick jet configs in really foreign packages

Variable Documentation

◆ jrtlog

ParticleJetToolsConfig.jrtlog = Logging.logging.getLogger('ParticleJetToolsConfig')

Definition at line 12 of file ParticleJetToolsConfig.py.

◆ truthLabelSettings

dict ParticleJetToolsConfig.truthLabelSettings
Initial value:
= {
# Large R labels
"R10TruthLabel_R21Precision_2022v1": dict(
TruthJetContainer = "AntiKt10TruthJets",
MatchUngroomedParent = True,
dRTruthJet = 0.75,
),
"R10TruthLabel_R22v1": dict(
TruthJetContainer = "AntiKt10TruthJets",
GetTruthGroomedJetValues = True,
TruthGroomedJetContainer = "AntiKt10TruthSoftDropBeta100Zcut10Jets",
MatchUngroomedParent = True,
dRTruthJet = 0.75,
),
"R10WZTruthLabel_R22v1": dict(
TruthJetContainer = "AntiKt10TruthDressedWZJets",
GetTruthGroomedJetValues = True,
TruthGroomedJetContainer = "AntiKt10TruthDressedWZSoftDropBeta100Zcut10Jets",
MatchUngroomedParent = True,
dRTruthJet = 0.75,
),
# Small R labels
"R4TruthLabel": dict(TruthJetContainer = "AntiKt4TruthJets", dRTruthJet = 0.3, DoLargeRLabels = False),
"R4TruthDressedWZLabel": dict(TruthJetContainer = "AntiKt4TruthDressedWZJets", dRTruthJet = 0.3, DoLargeRLabels = False),
"R4InTimeTruthLabel": dict(TruthJetContainer = "InTimeAntiKt4TruthJets", dRTruthJet = 0.3, DoLargeRLabels = False),
"R4OutOfTimeTruthLabel": dict(TruthJetContainer = "OutOfTimeAntiKt4TruthJets", dRTruthJet = 0.3, DoLargeRLabels = False),
}

Definition at line 254 of file ParticleJetToolsConfig.py.

◆ truthpartoptions

dict ParticleJetToolsConfig.truthpartoptions
Initial value:
= {
"Partons":{"ToolType":CompFactory.CopyTruthPartons,"ptmin":5000},
"BosonTop":{"ToolType":CompFactory.CopyBosonTopLabelTruthParticles,"ptmin":100000},
"FlavourLabel":{"ToolType":CompFactory.CopyFlavorLabelTruthParticles,"ptmin":5000},
}

Definition at line 38 of file ParticleJetToolsConfig.py.