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

Functions

 minimumJetPtForTrackAssociation (flags)
 runOldSecVrtSecIncl (prevFlags)
 isRun3Derivation (flags)
 runFlipTag (flags)
 sv1OnnxPath (flags)
 _copiedVariables (flags, tagger, probs, track_vars, uints=())
 getCalibratedCopies (flags)
 getNNs (flags)
 createBTaggingConfigFlags ()

Variables

dict sv1OnnxPaths
dict _frozen_t0_calibration
list _fold_hashes = ['jetFoldHash', 'jetFoldHash_noHits', 'jetFoldRankHash']

Function Documentation

◆ _copiedVariables()

_copiedVariables ( flags,
tagger,
probs,
track_vars,
uints = () )
protected

Definition at line 54 of file BTaggingConfigFlags.py.

54def _copiedVariables(flags, tagger, probs, track_vars, uints=()):
55 suffixes = [''] + (['SimpleFlip'] if flags.BTagging.RunFlipTaggers else [])
56
57 def names(parts):
58 return [f'{tagger}{s}_{p}' for s in suffixes for p in parts]
59
60 return {
61 'floats': names(probs),
62 'uints': list(uints),
63 'charVectors': names(track_vars),
64 'trackLinks': names(['TrackLinks']),
65 }
66
67

◆ createBTaggingConfigFlags()

createBTaggingConfigFlags ( )

Definition at line 200 of file BTaggingConfigFlags.py.

200def createBTaggingConfigFlags():
201 btagcf = AthConfigFlags()
202
203 # the track association minimum is set to 4 GeV because of track
204 # jets in offline reconstruction.
205 btagcf.addFlag("BTagging.minimumJetPtForTrackAssociation",
206 minimumJetPtForTrackAssociation)
207
208 # Run the SV1 likelihood as an onnx model.
209 # The probabilities are not written to any output by default.
210 btagcf.addFlag("BTagging.RunSV1Onnx", False)
211
212 # Run the flip taggers
213 btagcf.addFlag("BTagging.RunFlipTaggers", runFlipTag)
214
215 # Trackless approach
216 btagcf.addFlag("BTagging.Trackless", False)
217 btagcf.addFlag("BTagging.Trackless_JetCollection", "AntiKt4EMPFlowJets")
218 btagcf.addFlag("BTagging.Trackless_JetPtMin", 250*Units.GeV)
219 btagcf.addFlag("BTagging.Trackless_dR", 0.4)
220
221 # more aggressive trackless approach
222 btagcf.addFlag("BTagging.savePixelHits", False)
223 btagcf.addFlag("BTagging.saveSCTHits", False)
224
225 # experimental flags
226 btagcf.addFlag("BTagging.Pseudotrack", False)
227
228 #NewVrtSecInclusiveAlg
229 btagcf.addFlag("BTagging.RunNewVrtSecInclusive", runOldSecVrtSecIncl)
230
231 # track classification tool flags
232 btagcf.addFlag("BTagging.TrkClassFiveBinMode",False)
233
234 # a flag to add V0finder
235 btagcf.addFlag("BTagging.AddV0Finder", False)
236
237 # GNN vertex fitter
238 btagcf.addFlag("BTagging.GNNVertexFitter", False)
239
240 # (multifold) NN trainings, each jet collection maps to a list of
241 # dicts. The dict has several keys:
242 # - folds: list of NNs to run
243 # - remapping (optional): any variable remapping
244 # - ip_prefix (optional): for taggers trained on the poor man's
245 # impact parameters, the decoration prefix they should be read
246 # from. Schedules PoorMansIpAugmenterAlg with this prefix. See
247 # _ip_definitions in FlavorTaggingConfig.py for the allowed
248 # prefixes and the definition each one selects.
249 # - <group>_ip_prefix (optional): same, for one constituent group
250 # ('tracks', 'electrons', 'muons'). A group with no entry follows
251 # ip_prefix, which is itself the tracks prefix.
252 btagcf.addFlag("BTagging.NNs", getNNs)
253 # taggers running on a frozen-calibration shallow copy of their jet
254 # collection (see FlavorTaggingConfig.FlavorTaggingCfg)
255 btagcf.addFlag("BTagging.CalibratedCopies", getCalibratedCopies)
256 btagcf.addFlag("BTagging.AK4TaggerName", lambda pcf: (
257 "GN2HLv01" if pcf.GeoModel.Run>=LHCPeriod.Run4 else "GN2v01"))
258
259 # master switch for using Triton for NN inference.
260 # see athena/PhysicsAnalysis/JetTagging/FlavorTagInference/python/FlavorTagNNConfig.py
261 btagcf.addFlag("BTagging.UseTriton", False)
262
263 return btagcf

◆ getCalibratedCopies()

getCalibratedCopies ( flags)
Taggers to run on a frozen-calibration shallow copy of their jet
collection, as {collection: {tagger: {calibration, copied_variables}}}
(aft/open-tasks#105). The copied variables are an explicit opt-in list
of the outputs that flow back to the original jets; unlisted taggers
run directly on the original collection. Empty outside derivations.

Definition at line 68 of file BTaggingConfigFlags.py.

68def getCalibratedCopies(flags):
69 '''
70 Taggers to run on a frozen-calibration shallow copy of their jet
71 collection, as {collection: {tagger: {calibration, copied_variables}}}
72 (aft/open-tasks#105). The copied variables are an explicit opt-in list
73 of the outputs that flow back to the original jets; unlisted taggers
74 run directly on the original collection. Empty outside derivations.
75 '''
76 if not isRun3Derivation(flags):
77 return {}
78 gn3_base = ['pb', 'pc', 'ps', 'pu', 'pud', 'pg', 'ptau',
79 'ptFromTruthDressedWZJet']
80 gn3_probs = gn3_base + ['pquark']
81 gn3_epcl_probs = gn3_base + ['pbquark', 'pantibquark', 'pcquark',
82 'panticquark', 'pother']
83 gn2_tracks = ['TrackOrigin', 'VertexIndex']
84 gn3_tracks = ['TrackOrigin', 'TrackType', 'VertexIndex']
85 taggers = {
86 'GN2v01': (['pb', 'pc', 'pu', 'ptau'], gn2_tracks, _fold_hashes),
87 'GN3PflowMuonsV00': (gn3_probs, gn3_tracks, ()),
88 'GN3EPCLV01': (gn3_epcl_probs, gn3_tracks, ()),
89 'GN3V03': (gn3_epcl_probs, gn3_tracks, ()),
90 }
91 return {
92 'AntiKt4EMPFlowJets': {
93 tagger: {
94 'calibration': _frozen_t0_calibration,
95 'copied_variables': _copiedVariables(
96 flags, tagger, probs, tracks, uints),
97 }
98 for tagger, (probs, tracks, uints) in taggers.items()
99 },
100 }
101

◆ getNNs()

getNNs ( flags)
Gets the paths of models to run via MultiFoldTagger.

Definition at line 102 of file BTaggingConfigFlags.py.

102def getNNs(flags):
103 '''
104 Gets the paths of models to run via MultiFoldTagger.
105 '''
106
107 # dummy for now
108 ak4_nns = []
109 if flags.GeoModel.Run >= LHCPeriod.Run4:
110 ak4_nns = ["BTagging/20260308/GN2HL/antikt4emtopo/network.onnx"]
111 else:
112 caldir = 'BTagging/20231205/GN2v01/antikt4empflow'
113 ak4_nns = [f'{caldir}/network_fold{n}.onnx' for n in range(4)]
114
115 # We can save our results to the jet container, rather than the b-tagging container
116 # but this functionality is not yet setup for non multi-fold taggers. The easiest (/hackiest)
117 # solution is to pass all the GN3 paths below as seperate single-fold-multi-fold-taggers
118 # But this *should* be cleaned up at some point
119 # Note also, reco tests failing due to leptonID missing, so for now don't run taggers unless derivation
120 # https://gitlab.cern.ch/atlas/athena/-/merge_requests/77764#note_9063625
121 gn3pflowmuons_paths = [
122 "BTagging/20250213/GN3PflowMuonsV00/antikt4empflow/network.onnx", # Tracks+Muons+PFlow
123 ] if isRun3Derivation(flags) else []
124 gn3v01_paths = [
125 "BTagging/20260805/GN3EPCLV01/antikt4empflow/network.onnx", # Electrons+Pflow+Charge+Muons
126 ] if isRun3Derivation(flags) else []
127 # Trained on the poor man's impact parameters, so it needs its own
128 # entry below rather than joining gn3_paths
129 gn3v03_paths = [
130 "BTagging/20260922/GN3V03/antikt4empflow/network.onnx", # Electrons+Pflow+Charge+Muons
131 ] if isRun3Derivation(flags) else []
132 # Combine the paths for the GN3PflowMuonsV00 and GN3v01 models
133 gn3_paths = gn3pflowmuons_paths + gn3v01_paths
134
135 bjr4_paths = [
136 "JetCalibTools/CalibArea-00-04-83/CalibrationFactors/bJES_calibFactors_R22_MC20MC23_AntiKt4EMPflow_bJR4v01_20260319.onnx" # bJR4v01
137 ] if isRun3Derivation(flags) else []
138
139 lrj_paths = [
140 "BTagging/20230705/gn2xv01/antikt10ufo/network.onnx",
141 "BTagging/20240925/GN2Xv02/antikt10ufo/network.onnx",
142 "BTagging/20250310/GN2XTauV00/antikt10ufo/network.onnx",
143 "BTagging/20250912/GN3XPV01/antikt10ufo/network.onnx",
144 "BTagging/20260803/tautauJRv00/antikt10ufo/network.onnx",
145 "JetCalibTools/CalibArea-00-04-83/CalibrationFactors/bbJESJMS_calibFactors_R22_MC20_CSSKUFO_bJR10v00Ext_20260513.onnx", # bJR10v00Ext
146 "JetCalibTools/CalibArea-00-04-83/CalibrationFactors/bbJESJMS_calibFactors_R22_MC20MC23_CSSKUFO_bJR10v01_20260513.onnx" # bJR10v01
147 ]
148 # we can't flip large-R taggers
149 noflip = dict(flip=False)
150
151 sv1_paths = [sv1OnnxPath(flags)] if flags.BTagging.RunSV1Onnx else []
152
153 return {
154 'AntiKt4EMPFlowJets': [
155 {
156 'folds': ak4_nns,
157 'hash': 'jetFoldHash',
158 'cone_association': True,
159 },
160 *[{'folds' : [nn_path]} for nn_path in gn3_paths+bjr4_paths],
161 *[{'folds': [nn_path], 'ip_prefix': 'poormanIp_'}
162 for nn_path in gn3v03_paths],
163 *[{'folds': [nn_path]} for nn_path in sv1_paths]
164 ],
165 'AntiKt4EMTopoJets': [
166 {
167 'folds': ak4_nns,
168 'hash': 'jetFoldHash',
169 'cone_association': True,
170 },
171 ],
172 'AntiKt4EMPFlowCustomVtxJets': [
173 {
174 'folds': ak4_nns,
175 'hash': 'jetFoldHash',
176 'cone_association': True
177 },
178 *[{'folds' : [nn_path]} for nn_path in gn3_paths+bjr4_paths]
179 ],
180 'AntiKt4EMPFlowByVertexJets': [
181 {
182 'folds': ak4_nns,
183 'hash': 'jetFoldHash',
184 'cone_association': True
185 }
186 ],
187 'AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets': [
188 {'folds' : [nn_path], **noflip} for nn_path in lrj_paths
189 ],
190 'DFAntiKt4HIJets': [
191 {
192 'folds': ak4_nns,
193 'hash': 'jetFoldHash',
194 'cone_association': True
195 }
196 ]
197 }
198
199

◆ isRun3Derivation()

isRun3Derivation ( flags)

Definition at line 18 of file BTaggingConfigFlags.py.

18def isRun3Derivation(flags):
19 derivation = flags.Common.ProductionStep is ProductionStep.Derivation
20 before_the_future = flags.GeoModel.Run < LHCPeriod.Run4
21 return derivation and before_the_future
22
23

◆ minimumJetPtForTrackAssociation()

minimumJetPtForTrackAssociation ( flags)

Definition at line 8 of file BTaggingConfigFlags.py.

8def minimumJetPtForTrackAssociation(flags):
9 if flags.Trigger.doHLT:
10 return 5e3
11 return 4e3
12
13

◆ runFlipTag()

runFlipTag ( flags)

Definition at line 24 of file BTaggingConfigFlags.py.

24def runFlipTag(flags):
25 return isRun3Derivation(flags)
26
27
28# The SV1 likelihood is frozen into these models, one per calibration, so the
29# tagger no longer needs the conditions histograms. AFT-869.

◆ runOldSecVrtSecIncl()

runOldSecVrtSecIncl ( prevFlags)

Definition at line 14 of file BTaggingConfigFlags.py.

14def runOldSecVrtSecIncl(prevFlags):
15 return prevFlags.Common.ProductionStep is ProductionStep.Derivation
16
17

◆ sv1OnnxPath()

sv1OnnxPath ( flags)

Definition at line 36 of file BTaggingConfigFlags.py.

36def sv1OnnxPath(flags):
37 period = LHCPeriod.Run4 if flags.GeoModel.Run >= LHCPeriod.Run4 else LHCPeriod.Run3
38 return sv1OnnxPaths[period]
39
40
41# Frozen calibration applied to the tagged shallow copy, decoupling the
42# listed taggers from changes to the reco-level t0 calibration
43# (aft/open-tasks#105). Deliberately hard-coded: must NOT follow
44# JetCalibToolsConfig updates.

Variable Documentation

◆ _fold_hashes

list BTaggingConfigFlags._fold_hashes = ['jetFoldHash', 'jetFoldHash_noHits', 'jetFoldRankHash']
protected

Definition at line 51 of file BTaggingConfigFlags.py.

◆ _frozen_t0_calibration

dict BTaggingConfigFlags._frozen_t0_calibration
protected
Initial value:
= {
'configFile': 'JES_MC15cRecommendation_PFlow_Aug2016_rel21.config',
'calibArea': '00-04-77',
'calibSequence': 'JetArea_Residual_EtaJES',
}

Definition at line 45 of file BTaggingConfigFlags.py.

◆ sv1OnnxPaths

dict BTaggingConfigFlags.sv1OnnxPaths
Initial value:
= {
LHCPeriod.Run3: "BTagging/20261001/SV1/antikt4empflow/network.onnx",
LHCPeriod.Run4: "BTagging/20261001/SV1HL/antikt4empflow/network.onnx",
}

Definition at line 30 of file BTaggingConfigFlags.py.