10 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
11 from AthenaConfiguration.ComponentFactory
import CompFactory
12 from AthenaConfiguration.Enums
import MetadataCategory
14 from DerivationFrameworkEGamma.PhotonsCPDetailedContent
import (
15 PhotonsCPDetailedContent,
17 from DerivationFrameworkEGamma.ElectronsCPDetailedContent
import (
18 ElectronsCPDetailedContent,
19 GSFTracksCPDetailedContent,
22 from DerivationFrameworkEGamma.TriggerContent
import (
23 BootstrapPhotonTriggers,
25 ExtraContainersTrigger,
26 ExtraContainersPhotonTrigger,
27 ExtraContainersTriggerDataOnly,
34 applyTriggerSelection =
True
39 """Configure the EGAM9 skimming tool"""
44 "(count(Photons.pt > 9.5*GeV && " +
"Photons.DFCommonPhotonsIsEMLoose) > 0)"
46 electron_selection = (
47 "(count(Electrons.pt > 9.5*GeV && "
48 +
"Electrons.DFCommonElectronsLHMedium) > 0)"
50 expression = photon_selection +
" || " + electron_selection
52 if applyTriggerSelection:
55 if flags.Trigger.EDMVersion == 2:
57 elif flags.Trigger.EDMVersion == 3:
61 triggers = BootstrapPhotonTriggers[MenuType]
62 triggers += noalgTriggers[MenuType]
63 print(
"EGAM9 trigger skimming list (OR): ", triggers)
64 EGAM9_TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(
65 name=
"EGAM9_TriggerSkimmingTool", TriggerListOR=triggers
69 print(
"EGAM9 offline skimming expression: ", expression)
70 EGAM9_OfflineSkimmingTool = (
71 CompFactory.DerivationFramework.xAODStringSkimmingTool(
72 name=
"EGAM9_OfflineSkimmingTool", expression=expression
77 print(
"EGAM9 skimming is logical AND of previous selections")
78 EGAM9_SkimmingTool = CompFactory.DerivationFramework.FilterCombinationAND(
79 name=
"EGAM9_SkimmingTool",
80 FilterList=[EGAM9_OfflineSkimmingTool, EGAM9_TriggerSkimmingTool],
82 acc.addPublicTool(EGAM9_OfflineSkimmingTool)
83 acc.addPublicTool(EGAM9_TriggerSkimmingTool)
84 acc.addPublicTool(EGAM9_SkimmingTool, primary=
True)
87 print(
"EGAM9 skimming expression: ", expression)
88 EGAM9_SkimmingTool = CompFactory.DerivationFramework.xAODStringSkimmingTool(
89 name=
"EGAM9_SkimmingTool", expression=expression
91 acc.addPublicTool(EGAM9_SkimmingTool, primary=
True)
97 """Configure the derivation framework driving algorithm (kernel)
102 from DerivationFrameworkPhys.PhysCommonConfig
import PhysCommonAugmentationsCfg
106 flags, TriggerListsHelper=kwargs[
"TriggerListsHelper"]
111 augmentationTools = []
116 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
117 CaloDecoratorKernelCfg)
122 streamName = kwargs[
"StreamName"]
125 if flags.Derivation.Egamma.doTrackThinning:
126 TrackThinningKeepElectronTracks =
False
127 TrackThinningKeepPhotonTracks =
True
128 TrackThinningKeepPVTracks =
False
131 if TrackThinningKeepElectronTracks:
132 EGAM9ElectronTPThinningTool = (
133 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
134 name=
"EGAM9ElectronTPThinningTool",
135 StreamName=streamName,
137 GSFTrackParticlesKey=
"GSFTrackParticles",
138 InDetTrackParticlesKey=
"InDetTrackParticles",
139 SelectionString=
"Electrons.pt > 0*GeV",
144 acc.addPublicTool(EGAM9ElectronTPThinningTool)
145 thinningTools.append(EGAM9ElectronTPThinningTool)
148 if TrackThinningKeepPhotonTracks:
149 EGAM9PhotonTPThinningTool = (
150 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
151 name=
"EGAM9PhotonTPThinningTool",
152 StreamName=streamName,
154 GSFTrackParticlesKey=
"GSFTrackParticles",
155 InDetTrackParticlesKey=
"InDetTrackParticles",
156 GSFConversionVerticesKey=
"GSFConversionVertices",
157 SelectionString=
"Photons.pt > 0*GeV",
162 acc.addPublicTool(EGAM9PhotonTPThinningTool)
163 thinningTools.append(EGAM9PhotonTPThinningTool)
166 thinning_expression =
" && ".
join(
168 "(InDetTrackParticles.DFCommonTightPrimary)",
169 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
170 "(InDetTrackParticles.pt > 10*GeV)",
173 if TrackThinningKeepPVTracks:
174 from DerivationFrameworkInDet.InDetToolsConfig
import (
175 TrackParticleThinningCfg,
178 EGAM9TPThinningTool = acc.getPrimaryAndMerge(
181 name=
"EGAM9TPThinningTool",
182 StreamName=streamName,
183 SelectionString=thinning_expression,
184 InDetTrackParticlesKey=
"InDetTrackParticles",
187 thinningTools.append(EGAM9TPThinningTool)
192 truth_cond_WZH =
" && ".
join(
193 [
"(abs(TruthParticles.pdgId) >= 23)",
"(abs(TruthParticles.pdgId) <= 25)"]
196 truth_cond_lep =
" && ".
join(
197 [
"(abs(TruthParticles.pdgId) >= 11)",
"(abs(TruthParticles.pdgId) <= 16)"]
200 truth_cond_top =
"(abs(TruthParticles.pdgId) == 6)"
202 truth_cond_gam =
" && ".
join(
203 [
"(abs(TruthParticles.pdgId) == 22)",
"(TruthParticles.pt > 1*GeV)"]
206 truth_cond_finalState =
" && ".
join(
207 [
"(TruthParticles.status == 1)",
"(TruthParticles.barcode<200000)"]
223 + truth_cond_finalState
226 print(
"EGAM9 truth thinning expression: ", truth_expression)
228 EGAM9TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
229 name=
"EGAM9TruthThinningTool",
230 StreamName=streamName,
231 ParticleSelectionString=truth_expression,
232 PreserveDescendants=
False,
233 PreserveGeneratorDescendants=
True,
234 PreserveAncestors=
True,
236 acc.addPublicTool(EGAM9TruthThinningTool)
237 thinningTools.append(EGAM9TruthThinningTool)
241 from DerivationFrameworkCalo.CaloCellDFGetterConfig
import thinCaloCellsForDFCfg
246 inputClusterKeys=[
"egammaClusters"],
247 streamName=
"StreamDAOD_EGAM9",
248 inputCellKey=
"AllCalo",
249 outputCellKey=
"DFEGAMCellContainer",
258 CompFactory.DerivationFramework.DerivationKernel(
260 SkimmingTools=[skimmingTool],
261 AugmentationTools=augmentationTools,
262 ThinningTools=thinningTools,
279 from DerivationFrameworkPhys.TriggerListsHelper
import TriggerListsHelper
281 EGAM9TriggerListsHelper = TriggerListsHelper(flags)
288 StreamName=
"StreamDAOD_EGAM9",
289 TriggerListsHelper=EGAM9TriggerListsHelper,
294 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
295 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
296 from DerivationFrameworkCore.SlimmingHelper
import SlimmingHelper
299 "EGAM9SlimmingHelper",
300 NamesAndTypes=flags.Input.TypedCollections,
309 EGAM9SlimmingHelper.AllVariables = [
318 if flags.Trigger.EDMVersion == 2:
320 elif flags.Trigger.EDMVersion == 3:
324 EGAM9SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
325 EGAM9SlimmingHelper.AllVariables += ExtraContainersPhotonTrigger[MenuType]
326 if not flags.Input.isMC:
327 EGAM9SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly[MenuType]
331 EGAM9SlimmingHelper.AllVariables += [
335 "egammaTruthParticles",
346 EGAM9SlimmingHelper.SmartCollections = [
349 "InDetTrackParticles",
353 EGAM9SlimmingHelper.SmartCollections += [
"AntiKt4EMPFlowJets"]
355 EGAM9SlimmingHelper.SmartCollections += [
357 "AntiKt4TruthDressedWZJets",
363 EGAM9SlimmingHelper.ExtraVariables += [
"Photons.DFCommonLoosePrime5"]
366 EGAM9SlimmingHelper.ExtraVariables += [
367 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
368 "GSFConversionVertices.trackParticleLinks",
372 EGAM9SlimmingHelper.ExtraVariables += [
"PrimaryVertices.x.y.sumPt2"]
376 EGAM9SlimmingHelper.ExtraVariables += [
377 "AntiKt4PV0TrackJets.pt.eta.phi.e.m.btaggingLink.constituentLinks"
381 EGAM9SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
382 EGAM9SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent
383 EGAM9SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent
386 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
388 getClusterEnergyPerLayerDecorations,
392 print(
"EGAM9 gain decorations: ", gainDecorations)
393 EGAM9SlimmingHelper.ExtraVariables.extend(gainDecorations)
395 print(
"EGAM9 cluster energy decorations: ", clusterEnergyDecorations)
396 EGAM9SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
399 EGAM9SlimmingHelper.ExtraVariables += [
400 "TopoClusterIsoCentralEventShape.Density",
401 "TopoClusterIsoForwardEventShape.Density",
402 "NeutralParticleFlowIsoCentralEventShape.Density",
403 "NeutralParticleFlowIsoForwardEventShape.Density",
408 EGAM9SlimmingHelper.ExtraVariables += [
409 "Photons.truthOrigin.truthType.truthParticleLink"
413 if flags.Derivation.Egamma.doEventInfoSlimming:
414 EGAM9SlimmingHelper.SmartCollections.append(
"EventInfo")
416 EGAM9SlimmingHelper.AllVariables += [
"EventInfo"]
419 EGAM9SlimmingHelper.IncludeEGammaTriggerContent =
True
423 if flags.Trigger.EDMVersion == 2:
424 from DerivationFrameworkPhys.TriggerMatchingCommonConfig
import AddRun2TriggerMatchingToSlimmingHelper
426 OutputContainerPrefix =
"TrigMatch_",
427 TriggerList = EGAM9TriggerListsHelper.Run2TriggerNamesNoTau)
429 if flags.Trigger.EDMVersion == 3
or (flags.Trigger.EDMVersion == 2
and flags.Trigger.doEDMVersionConversion):
430 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig
import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
436 EGAM9SlimmingHelper.StaticContent = [
437 "CaloCellContainer#DFEGAMCellContainer",
438 "CaloClusterCellLinkContainer#egammaClusters_links",
441 EGAM9SlimmingHelper.StaticContent = [
442 "CaloCellContainer#AllCalo",
443 "CaloClusterCellLinkContainer#egammaClusters_links",
446 EGAM9ItemList = EGAM9SlimmingHelper.GetItemList()
451 ItemList=EGAM9ItemList,
452 AcceptAlgs=[
"EGAM9Kernel"],
459 AcceptAlgs=[
"EGAM9Kernel"],
461 MetadataCategory.CutFlowMetaData,
462 MetadataCategory.TruthMetaData,