14from __future__
import annotations
16from typing
import TYPE_CHECKING, Any
18from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
19from AthenaConfiguration.ComponentFactory
import CompFactory
20from AthenaConfiguration.Enums
import LHCPeriod, MetadataCategory
21from DerivationFrameworkCore.SlimmingHelper
import SlimmingHelper
22from DerivationFrameworkEGamma.ElectronsCPDetailedContent
import ElectronsCPDetailedContent
23from DerivationFrameworkFlavourTag.FtagBaseContent
import (
24 add_baseline_slimming_allvariables,
25 add_baseline_slimming_smartcollections,
26 add_common_augmentation,
27 add_extra_variables_to_slimming_helper,
28 add_truth_to_slimming_helper,
29 add_truth_vertex_decorations,
32 update_append_to_dictionary_in_slimming_helper,
34from DerivationFrameworkFlavourTag.FtagDerivationConfig
import (
35 HLTJetFTagDecorationCfg,
37from DerivationFrameworkFlavourTag.FtagVRJetConfig
import (
38 VR_JET_APPEND_TO_DICTIONARY,
39 VR_JET_TRUTH_VERTEX_DR,
42 add_vr_jet_truth_augmentation,
44from DerivationFrameworkJetEtMiss.CommonJETMXContent
import (
50 TrackingVariablesHGTD,
53from DerivationFrameworkJetEtMiss.JetCommonConfig
import addOriginCorrectedClustersToSlimmingTool
54from DerivationFrameworkMCTruth.MCTruthCommonConfig
import (
55 AddTopQuarkAndDownstreamParticlesCfg,
56 AddTruthCollectionNavigationDecorationsCfg,
58from DerivationFrameworkPhys.PhysCommonConfig
import PhysCommonAugmentationsCfg
59from DerivationFrameworkPhys.TriggerListsHelper
import TriggerListsHelper
60from InDetConfig.InDetPoolReadConfig
import InDetPoolReadCfg
61from JetRecConfig.JetRecConfig
import JetRecCfg
62from JetRecConfig.StandardLargeRJets
import AntiKt10TruthDressedWZSoftDrop
63from JetRecConfig.StandardSmallRJets
import AntiKt4LCTopo
64from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
65from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
68 from AthenaConfiguration.AthConfigFlags
import AthConfigFlags
71LARGE_R_JETS =
"AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets"
76 "poormanIp_d0Uncertainty",
77 "poormanIp_z0SinThetaUncertainty",
78 "poormanIp_trackDisplacement",
79 "poormanIp_trackMomentum",
80 "poormanIp_invalidIp",
85 "GN3EPCLV01_Latent128",
86 "GN3EPCLV01_Latent64",
87 "GN3EPCLV01_Latent32",
88 "GN3EPCLV01SimpleFlip_Latent",
89 "GN3EPCLV01SimpleFlip_Latent128",
90 "GN3EPCLV01SimpleFlip_Latent64",
91 "GN3EPCLV01SimpleFlip_Latent32",
96 flags: AthConfigFlags,
97 acc: ComponentAccumulator,
98 slimming_helper: SlimmingHelper,
99 keep_truth_collections: bool =
True,
100 tau_as_smart_collection: bool =
False,
102 """Add the flavour-tagging content and augmentations to the slimming helper."""
105 add_baseline_slimming_smartcollections(slimming_helper=slimming_helper)
106 add_baseline_slimming_allvariables(slimming_helper=slimming_helper)
107 add_truth_to_slimming_helper(slimming_helper=slimming_helper)
110 add_common_augmentation(
113 slimming_helper=slimming_helper,
119 add_truth_vertex_decorations(
122 slimming_helper=slimming_helper,
123 large_r_jet_collection=LARGE_R_JETS,
124 extra_jet_collections=[(VR_JETS, VR_JET_TRUTH_VERTEX_DR)],
127 add_vr_jet_truth_augmentation(
130 slimming_helper=slimming_helper,
133 slimming_helper.SmartCollections += [
138 slimming_helper.AllVariables += [
139 "AntiKt4EMPFlowJets",
141 "CaloCalFwdTopoTowers",
144 "GlobalChargedParticleFlowObjects",
145 "GlobalNeutralParticleFlowObjects",
146 "CHSGChargedParticleFlowObjects",
147 "CHSGNeutralParticleFlowObjects",
148 "CSSKGChargedParticleFlowObjects",
149 "CSSKGNeutralParticleFlowObjects",
150 "CaloCalTopoClusters",
151 "JetAssociatedPixelClusters",
152 "JetAssociatedSCTClusters",
157 if tau_as_smart_collection:
158 slimming_helper.SmartCollections += [
"TauJets"]
160 slimming_helper.AllVariables += [
162 "TauNeutralParticleFlowObjects",
163 "TauShotParticleFlowObjects",
166 if keep_truth_collections:
167 slimming_helper.AllVariables += [
174 slimming_helper.ExtraVariables += ElectronsCPDetailedContent
175 add_extra_variables_to_slimming_helper(
177 slimming_helper=slimming_helper,
180 slimming_helper.ExtraVariables += [
"AntiKt4TruthJets.constituentLinks"]
183 for jet_collection
in [
"AntiKt4EMTopoJets",
"AntiKt4LCTopoJets"]:
184 slimming_helper.ExtraVariables.append(
188 "HadronConeExclTruthLabelID",
189 "HadronGhostTruthLabelID",
190 "GhostBHadronsFinal",
191 "GhostCHadronsFinal",
193 "ConeExclBHadronsFinal",
194 "ConeExclCHadronsFinal",
201 if flags.GeoModel.Run >= LHCPeriod.Run4:
202 slimming_helper.SmartCollections += [
"MET_Baseline_AntiKt4EMTopo"]
203 slimming_helper.AllVariables += [
206 "ITkPixelMeasurements",
207 "ITkStripMeasurements",
208 "ITkPixelSpacePoints",
209 "ITkStripSpacePoints",
210 "ITkStripOverlapSpacePoints",
212 slimming_helper.ExtraVariables += [
213 ".".join([
"InDetTrackParticles"] + TrackingVariablesHGTD)
217 acc.merge(InDetPoolReadCfg(flags))
220 if flags.BTagging.Pseudotrack:
221 slimming_helper.AllVariables += [
"InDetPseudoTrackParticles"]
224 if flags.Trigger.EDMVersion == 3
and flags.Input.isMC:
225 acc.merge(HLTJetFTagDecorationCfg(flags))
229 flags: AthConfigFlags,
230 slimming_helper: SlimmingHelper,
232 """Add the jet reconstruction and constituent content to the slimming helper."""
234 slimming_helper.SmartCollections += [
241 slimming_helper.ExtraVariables += [
242 ".".join([
"CaloCalTopoClusters"] + ClusterVariables),
243 ".".join([
"EMOriginTopoClusters"] + [
"calM"]),
245 [
"GlobalChargedParticleFlowObjects"] + FlowElementVariables + [
"otherObjectWeights"]
248 [
"GlobalNeutralParticleFlowObjects"] + FlowElementVariables + [
"otherObjectWeights"]
250 ".".join([
"UFOCSSK"] + UFOVariables),
251 ".".join([
"InDetTrackParticles"] + TrackingVariables),
255 slimming_helper.ExtraVariables += FELinks
258 slimming_helper.ExtraVariables += [
".".join([LARGE_R_JETS] + ExtraJSSVariables)]
260 slimming_helper.ExtraVariables += [
263 "AntiKt4EMPFlowJets",
266 "IsoFixedCone5PtPUsub",
270 "AntiKt4EMTopoJets.IsoFixedCone5Pt.IsoFixedCone5PtPUsub.constituentLinks",
271 f
"{LARGE_R_JETS}.SizeParameter.GhostTrack.constituentLinks",
272 "GSFTrackParticles.particleHypothesis.vx.vy.vz",
273 "PrimaryVertices.x.y.z.covariance.trackWeights",
274 "TauJets.clusterLinks",
283 "MeasEnergyLossSigma",
284 "ParamEnergyLossSigmaPlus",
285 "ParamEnergyLossSigmaMinus",
287 "FSR_CandidateEnergy",
290 "MuonSegments.x.y.z.px.py.pz",
293 addOriginCorrectedClustersToSlimmingTool(slimming_helper, writeLC=
True, writeEM=
True)
296 slimming_helper.AllVariables += [
297 "TruthTopQuarkWithDecayParticles",
298 "TruthTopQuarkWithDecayVertices",
301 slimming_helper.SmartCollections += [
302 "AntiKt4TruthWZJets",
304 "AntiKt10TruthDressedWZSoftDropBeta100Zcut10Jets",
307 slimming_helper.ExtraVariables += [
308 "AntiKt10TruthSoftDropBeta100Zcut10Jets.SizeParameter.constituentLinks",
309 "AntiKt10TruthDressedWZSoftDropBeta100Zcut10Jets.constituentLinks",
310 "AntiKt10TruthDressedWZJets.constituentLinks",
311 "AntiKt10TruthJets.constituentLinks",
312 "AntiKt4TruthWZJets.IsoFixedCone5Pt.constituentLinks",
313 "AntiKt4TruthDressedWZJets.IsoFixedCone5Pt.constituentLinks",
317 "GhostTQuarksFinalCount",
326 "GhostTQuarksFinalPt",
332 f
"{LARGE_R_JETS}.GhostBHadronsFinalPt.GhostCHadronsFinalPt",
337 """Drop aux variables from the InDetTrackParticles output item."""
338 dropped =
".".join(
"-" + variable
for variable
in variables)
340 def drop(item: str) -> str:
341 if "#InDetTrackParticlesAux." not in item:
343 sep =
"" if item.endswith(
"Aux.")
else "."
344 return item + sep + dropped
346 return [drop(item)
for item
in item_list]
350 flags: AthConfigFlags,
351 name: str =
"HID1Kernel",
353) -> ComponentAccumulator:
354 """Configure the derivation kernel for HID1."""
355 acc = ComponentAccumulator()
358 PhysCommonAugmentationsCfg(
360 TriggerListsHelper=kwargs[
"trigger_lists_helper"],
365 acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel(name=name))
373 flags: AthConfigFlags,
374 name_tag: str =
"HID1",
375 extra_SmartCollections: list[str] |
None =
None,
376 extra_AllVariables: list[str] |
None =
None,
377 trigger_lists_helper: TriggerListsHelper |
None =
None,
378 keep_truth_collections: bool =
True,
379 keep_track_covariance_offdiag: bool =
True,
380 tau_as_smart_collection: bool =
False,
381 compress_gn3_latent: bool =
True,
382) -> ComponentAccumulator:
383 """Configure HID1 slimming and output content."""
384 if extra_SmartCollections
is None:
385 extra_SmartCollections = []
386 if extra_AllVariables
is None:
387 extra_AllVariables = []
389 acc = ComponentAccumulator()
392 inputName=name_tag +
"SlimmingHelper",
393 NamesAndTypes=flags.Input.TypedCollections,
398 slimming_helper.SmartCollections = []
399 slimming_helper.AllVariables = []
400 slimming_helper.ExtraVariables = []
405 slimming_helper=slimming_helper,
406 keep_truth_collections=keep_truth_collections,
407 tau_as_smart_collection=tau_as_smart_collection,
412 slimming_helper=slimming_helper,
416 for container
in extra_SmartCollections:
417 if container
not in slimming_helper.SmartCollections:
418 slimming_helper.SmartCollections.append(container)
420 for container
in extra_AllVariables:
421 if container
not in slimming_helper.AllVariables:
422 slimming_helper.AllVariables.append(container)
425 update_append_to_dictionary_in_slimming_helper(
427 slimming_helper=slimming_helper,
428 extra_append_to_dictionary=VR_JET_APPEND_TO_DICTIONARY,
432 trigger_setup(slimming_helper=slimming_helper)
435 slimming_helper=slimming_helper,
436 trigger_lists_helper=trigger_lists_helper,
440 item_list = slimming_helper.GetItemList()
443 if not keep_track_covariance_offdiag:
446 gn3_latent_compression = []
447 if compress_gn3_latent:
448 gn3_latent_compression = [
449 "xAOD::AuxContainerBase!#AntiKt4EMPFlowJetsAux." +
".".join(GN3_LATENT_VARS)
455 streamName=
"DAOD_" + name_tag,
457 AcceptAlgs=[name_tag +
"Kernel"],
458 CompressionListHigh=gn3_latent_compression,
463 SetupMetaDataForStreamCfg(
465 streamName=
"DAOD_" + name_tag,
466 AcceptAlgs=[name_tag +
"Kernel"],
468 MetadataCategory.CutFlowMetaData,
469 MetadataCategory.TruthMetaData,
478 """Configure extra reconstructed jet content for HID1."""
479 acc = ComponentAccumulator()
481 jet_list = [AntiKt4LCTopo]
483 jet_list += [AntiKt10TruthDressedWZSoftDrop]
485 for jet_def
in jet_list:
486 acc.merge(JetRecCfg(flags, jet_def))
489 acc.merge(VRFtagJetsCfg(flags))
493 acc.merge(AddTopQuarkAndDownstreamParticlesCfg(flags))
495 AddTruthCollectionNavigationDecorationsCfg(
498 "TruthTopQuarkWithDecayParticles",
499 "TruthBosonsWithDecayParticles",
509 flags: AthConfigFlags,
510 name_tag: str =
"HID1",
511) -> ComponentAccumulator:
512 """Configure the full HID1 derivation."""
513 acc = ComponentAccumulator()
515 trigger_lists_helper = TriggerListsHelper(flags)
520 name=name_tag +
"Kernel",
521 StreamName=
"StreamDAOD_" + name_tag,
522 trigger_lists_helper=trigger_lists_helper,
530 trigger_lists_helper=trigger_lists_helper,
ComponentAccumulator HID1Cfg(AthConfigFlags flags, str name_tag="HID1")
ComponentAccumulator HID1ExtraContentCfg(AthConfigFlags flags)
None _add_ftag_content(AthConfigFlags flags, ComponentAccumulator acc, SlimmingHelper slimming_helper, bool keep_truth_collections=True, bool tau_as_smart_collection=False)
None _add_jet_content(AthConfigFlags flags, SlimmingHelper slimming_helper)
ComponentAccumulator HID1CoreCfg(AthConfigFlags flags, str name_tag="HID1", list[str]|None extra_SmartCollections=None, list[str]|None extra_AllVariables=None, TriggerListsHelper|None trigger_lists_helper=None, bool keep_truth_collections=True, bool keep_track_covariance_offdiag=True, bool tau_as_smart_collection=False, bool compress_gn3_latent=True)
list[str] _drop_track_variables(list[str] item_list, list[str] variables)
ComponentAccumulator HID1KernelCfg(AthConfigFlags flags, str name="HID1Kernel", **Any kwargs)