9 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
10 from AthenaConfiguration.ComponentFactory
import CompFactory
11 from AthenaConfiguration.Enums
import MetadataCategory
15 from DerivationFrameworkEGamma.PhotonsCPDetailedContent
import (
16 PhotonsCPDetailedContent,
19 from DerivationFrameworkEGamma.TriggerContent
import (
20 ExtraContainersTrigger,
21 ExtraContainersElectronTrigger,
26 """Configure the EGAM1 skimming tool"""
29 expression =
" || ".
join(
31 "(count( EGAM1_DiElectronMass1 > 50.0*GeV ) >= 1)",
32 "(count( EGAM1_DiElectronMass2 > 50.0*GeV ) >= 1)",
33 "(count( EGAM1_DiElectronMass3 > 50.0*GeV ) >= 1)",
34 "(count( EGAM1_ElectronPhotonMass > 50.0*GeV )>=1)",
37 print(
"EGAM1 skimming expression: ", expression)
40 CompFactory.DerivationFramework.xAODStringSkimmingTool(
41 name=
"EGAM1SkimmingTool", expression=expression
49 """Configure the EGAM1 ee invariant mass augmentation tool 1"""
62 requirement_tag =
" && ".
join(
63 [
"(Electrons.DFCommonElectronsLHTight)",
"(Electrons.pt > 24.5*GeV)"]
66 requirement_probe =
" && ".
join(
67 [
"(Electrons.DFCommonElectronsLHMedium)",
"(Electrons.pt > 19.5*GeV)"]
71 CompFactory.DerivationFramework.EGInvariantMassTool(
72 name=
"EGAM1_ZEEMassTool1",
73 Object1Requirements=requirement_tag,
74 Object2Requirements=requirement_probe,
75 StoreGateEntryName=
"EGAM1_DiElectronMass1",
76 Mass1Hypothesis=0.511 * MeV,
77 Mass2Hypothesis=0.511 * MeV,
78 Container1Name=
"Electrons",
79 Container2Name=
"Electrons",
81 DoTransverseMass=
False,
90 """Configure the EGAM1 ee invariant mass augmentation tool 2"""
102 requirement =
" && ".
join(
103 [
"(Electrons.DFCommonElectronsLHMedium)",
"(Electrons.pt > 19.5*GeV)"]
107 CompFactory.DerivationFramework.EGInvariantMassTool(
108 name=
"EGAM1_ZEEMassTool2",
109 Object1Requirements=requirement,
110 Object2Requirements=requirement,
111 StoreGateEntryName=
"EGAM1_DiElectronMass2",
112 Mass1Hypothesis=0.511 * MeV,
113 Mass2Hypothesis=0.511 * MeV,
114 Container1Name=
"Electrons",
115 Container2Name=
"Electrons",
117 DoTransverseMass=
False,
126 """Configure the EGAM1 ee invariant mass augmentation tool 3"""
140 requirement_tag =
" && ".
join(
141 [
"(Electrons.DFCommonElectronsLHMedium)",
"(Electrons.pt > 24.5*GeV)"]
144 requirement_probe =
"Electrons.pt > 4*GeV"
147 CompFactory.DerivationFramework.EGInvariantMassTool(
148 name=
"EGAM1_ZEEMassTool3",
149 Object1Requirements=requirement_tag,
150 Object2Requirements=requirement_probe,
151 StoreGateEntryName=
"EGAM1_DiElectronMass3",
152 Mass1Hypothesis=0.511 * MeV,
153 Mass2Hypothesis=0.511 * MeV,
154 Container1Name=
"Electrons",
155 Container2Name=
"Electrons",
157 DoTransverseMass=
False,
166 """Configure the EGAM1 e+photon mass augmentation tool"""
181 requirement_tag =
" && ".
join(
182 [
"(Electrons.DFCommonElectronsLHMedium)",
"(Electrons.pt > 24.5*GeV)"]
185 requirement_probe =
"DFCommonPhotons_et > 14.5*GeV"
188 CompFactory.DerivationFramework.EGInvariantMassTool(
189 name=
"EGAM1_ZEGMassTool",
190 Object1Requirements=requirement_tag,
191 Object2Requirements=requirement_probe,
192 StoreGateEntryName=
"EGAM1_ElectronPhotonMass",
193 Mass1Hypothesis=0.511 * MeV,
194 Mass2Hypothesis=0.511 * MeV,
195 Container1Name=
"Electrons",
196 Container2Name=
"Photons",
197 Pt2BranchName=
"DFCommonPhotons_et",
198 Eta2BranchName=
"DFCommonPhotons_eta",
199 Phi2BranchName=
"DFCommonPhotons_phi",
201 DoTransverseMass=
False,
210 """Configure the derivation framework driving algorithm (kernel)
215 from JetRecConfig.StandardSmallRJets
import AntiKt4PV0Track
216 from JetRecConfig.JetRecConfig
import JetRecCfg
218 jetList = [AntiKt4PV0Track]
223 from DerivationFrameworkPhys.PhysCommonConfig
import PhysCommonAugmentationsCfg
227 flags, TriggerListsHelper=kwargs[
"TriggerListsHelper"]
232 augmentationTools = []
238 acc.addPublicTool(EGAM1ZeeMassTool1)
239 augmentationTools.append(EGAM1ZeeMassTool1)
242 acc.addPublicTool(EGAM1ZeeMassTool2)
243 augmentationTools.append(EGAM1ZeeMassTool2)
246 acc.addPublicTool(EGAM1ZeeMassTool3)
247 augmentationTools.append(EGAM1ZeeMassTool3)
250 acc.addPublicTool(EGAM1ZegMassTool)
251 augmentationTools.append(EGAM1ZegMassTool)
256 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
257 CaloDecoratorKernelCfg)
262 streamName = kwargs[
"StreamName"]
265 if flags.Derivation.Egamma.doTrackThinning:
266 from DerivationFrameworkInDet.InDetToolsConfig
import (
267 TrackParticleThinningCfg,
268 MuonTrackParticleThinningCfg,
269 TauTrackParticleThinningCfg,
272 TrackThinningKeepElectronTracks =
True
273 TrackThinningKeepPhotonTracks =
True
274 TrackThinningKeepAllElectronTracks =
True
275 TrackThinningKeepJetTracks =
False
276 TrackThinningKeepMuonTracks =
False
277 TrackThinningKeepTauTracks =
False
278 TrackThinningKeepPVTracks =
True
281 if TrackThinningKeepElectronTracks:
282 EGAM1ElectronTPThinningTool = (
283 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
284 name=
"EGAM1ElectronTPThinningTool",
285 StreamName=streamName,
287 GSFTrackParticlesKey=
"GSFTrackParticles",
288 InDetTrackParticlesKey=
"InDetTrackParticles",
289 SelectionString=
"Electrons.pt > 0*GeV",
294 acc.addPublicTool(EGAM1ElectronTPThinningTool)
295 thinningTools.append(EGAM1ElectronTPThinningTool)
299 if TrackThinningKeepAllElectronTracks:
300 EGAM1ElectronTPThinningTool2 = (
301 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
302 name=
"EGAM1ElectronTPThinningTool2",
303 StreamName=streamName,
305 GSFTrackParticlesKey=
"GSFTrackParticles",
306 InDetTrackParticlesKey=
"InDetTrackParticles",
307 SelectionString=
"Electrons.pt > 4*GeV",
312 acc.addPublicTool(EGAM1ElectronTPThinningTool2)
313 thinningTools.append(EGAM1ElectronTPThinningTool2)
316 if TrackThinningKeepPhotonTracks:
317 EGAM1PhotonTPThinningTool = (
318 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
319 name=
"EGAM1PhotonTPThinningTool",
320 StreamName=streamName,
322 GSFTrackParticlesKey=
"GSFTrackParticles",
323 InDetTrackParticlesKey=
"InDetTrackParticles",
324 GSFConversionVerticesKey=
"GSFConversionVertices",
325 SelectionString=
"Photons.pt > 0*GeV",
330 acc.addPublicTool(EGAM1PhotonTPThinningTool)
331 thinningTools.append(EGAM1PhotonTPThinningTool)
334 if TrackThinningKeepJetTracks:
335 EGAM1JetTPThinningTool = (
336 CompFactory.DerivationFramework.JetTrackParticleThinning(
337 name=
"EGAM1JetTPThinningTool",
338 StreamName=streamName,
339 JetKey=
"AntiKt4EMPFlowJets",
340 InDetTrackParticlesKey=
"InDetTrackParticles",
343 acc.addPublicTool(EGAM1JetTPThinningTool)
344 thinningTools.append(EGAM1JetTPThinningTool)
347 if TrackThinningKeepMuonTracks:
348 EGAM1MuonTPThinningTool = acc.getPrimaryAndMerge(
351 name=
"EGAM1MuonTPThinningTool",
352 StreamName=streamName,
354 InDetTrackParticlesKey=
"InDetTrackParticles",
357 thinningTools.append(EGAM1MuonTPThinningTool)
360 if TrackThinningKeepTauTracks:
361 EGAM1TauTPThinningTool = acc.getPrimaryAndMerge(
364 name=
"EGAM1TauTPThinningTool",
365 StreamName=streamName,
368 InDetTrackParticlesKey=
"InDetTrackParticles",
369 DoTauTracksThinning=
True,
370 TauTracksKey=
"TauTracks",
373 thinningTools.append(EGAM1TauTPThinningTool)
376 thinning_expression =
" && ".
join(
378 "(InDetTrackParticles.DFCommonTightPrimary)",
379 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
380 "(InDetTrackParticles.pt>10*GeV)",
383 if TrackThinningKeepPVTracks:
384 EGAM1TPThinningTool = acc.getPrimaryAndMerge(
387 name=
"EGAM1TPThinningTool",
388 StreamName=streamName,
389 SelectionString=thinning_expression,
390 InDetTrackParticlesKey=
"InDetTrackParticles",
393 thinningTools.append(EGAM1TPThinningTool)
396 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
397 CaloClusterThinningCfg,
400 EGAM1CCTCThinningTool = acc.getPrimaryAndMerge(
403 name=
"EGAM1CCTCThinningTool",
404 StreamName=streamName,
406 SelectionString=
"Electrons.pt>4*GeV",
407 TopoClCollectionSGKey=
"CaloCalTopoClusters",
411 thinningTools.append(EGAM1CCTCThinningTool)
416 truth_cond_WZH =
" && ".
join(
417 [
"(abs(TruthParticles.pdgId) >= 23)",
"(abs(TruthParticles.pdgId) <= 25)"]
420 truth_cond_lep =
" && ".
join(
421 [
"(abs(TruthParticles.pdgId) >= 11)",
"(abs(TruthParticles.pdgId) <= 16)"]
424 truth_cond_top =
"(abs(TruthParticles.pdgId) == 6)"
426 truth_cond_gam =
" && ".
join(
427 [
"(abs(TruthParticles.pdgId) == 22)",
"(TruthParticles.pt > 1*GeV)"]
430 truth_cond_finalState =
"(TruthParticles.isGenStable)"
445 + truth_cond_finalState
448 print(
"EGAM1 truth thinning expression: ", truth_expression)
450 EGAM1TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
451 name=
"EGAM1TruthThinningTool",
452 StreamName=streamName,
453 ParticleSelectionString=truth_expression,
454 PreserveDescendants=
False,
455 PreserveGeneratorDescendants=
True,
456 PreserveAncestors=
True,
458 acc.addPublicTool(EGAM1TruthThinningTool)
459 thinningTools.append(EGAM1TruthThinningTool)
463 acc.addPublicTool(skimmingTool)
467 CompFactory.DerivationFramework.DerivationKernel(
469 SkimmingTools=[skimmingTool],
470 AugmentationTools=augmentationTools,
471 ThinningTools=thinningTools,
488 from DerivationFrameworkPhys.TriggerListsHelper
import TriggerListsHelper
490 EGAM1TriggerListsHelper = TriggerListsHelper(flags)
497 StreamName=
"StreamDAOD_EGAM1",
498 TriggerListsHelper=EGAM1TriggerListsHelper,
503 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
504 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
505 from DerivationFrameworkCore.SlimmingHelper
import SlimmingHelper
508 "EGAM1SlimmingHelper",
509 NamesAndTypes=flags.Input.TypedCollections,
518 EGAM1SlimmingHelper.AllVariables = [
522 "CaloCalTopoClusters",
527 if flags.Trigger.EDMVersion == 2:
529 elif flags.Trigger.EDMVersion == 3:
533 EGAM1SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
534 EGAM1SlimmingHelper.AllVariables += ExtraContainersElectronTrigger[MenuType]
538 EGAM1SlimmingHelper.AllVariables += [
542 "egammaTruthParticles",
553 EGAM1SlimmingHelper.SmartCollections = [
559 "InDetTrackParticles",
560 "AntiKt4EMPFlowJets",
561 "BTagging_AntiKt4EMPFlow",
562 "MET_Baseline_AntiKt4EMPFlow",
565 EGAM1SlimmingHelper.SmartCollections += [
567 "AntiKt4TruthDressedWZJets",
573 EGAM1SlimmingHelper.ExtraVariables += [
574 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
578 EGAM1SlimmingHelper.ExtraVariables += [
579 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
580 "GSFConversionVertices.trackParticleLinks",
584 EGAM1SlimmingHelper.ExtraVariables += [
"PrimaryVertices.sumPt2"]
587 EGAM1SlimmingHelper.ExtraVariables += [
588 "AntiKt4PV0TrackJets.pt.eta.phi.e.m.btaggingLink.constituentLinks"
592 EGAM1SlimmingHelper.ExtraVariables += [
593 "TopoClusterIsoCentralEventShape.Density",
594 "TopoClusterIsoForwardEventShape.Density",
595 "NeutralParticleFlowIsoCentralEventShape.Density",
596 "NeutralParticleFlowIsoForwardEventShape.Density",
599 from DerivationFrameworkEGamma
import EGammaIsoConfig
606 ) = EGammaIsoConfig.makeEGammaCommonIsoCfg(flags)
608 EGAM1SlimmingHelper.AppendToDictionary.update(densityDict)
609 EGAM1SlimmingHelper.ExtraVariables += densityList
612 EGAM1SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
615 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
617 getClusterEnergyPerLayerDecorations,
621 print(
"EGAM1 gain decorations: ", gainDecorations)
622 EGAM1SlimmingHelper.ExtraVariables.extend(gainDecorations)
624 print(
"EGAM1 cluster energy decorations: ", clusterEnergyDecorations)
625 EGAM1SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
629 EGAM1SlimmingHelper.ExtraVariables += [
630 "MuonTruthParticles.e.px.py.pz.status.pdgId.truthOrigin.truthType"
633 EGAM1SlimmingHelper.ExtraVariables += [
634 "Photons.truthOrigin.truthType.truthParticleLink"
638 if flags.Derivation.Egamma.doEventInfoSlimming:
639 EGAM1SlimmingHelper.SmartCollections.append(
"EventInfo")
641 EGAM1SlimmingHelper.AllVariables += [
"EventInfo"]
644 EGAM1SlimmingHelper.IncludeEGammaTriggerContent =
True
648 if flags.Trigger.EDMVersion == 2:
649 from DerivationFrameworkPhys.TriggerMatchingCommonConfig
import AddRun2TriggerMatchingToSlimmingHelper
651 OutputContainerPrefix =
"TrigMatch_",
652 TriggerList = EGAM1TriggerListsHelper.Run2TriggerNamesNoTau)
654 if flags.Trigger.EDMVersion == 3
or (flags.Trigger.EDMVersion == 2
and flags.Trigger.doEDMVersionConversion):
655 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig
import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
659 EGAM1SlimmingHelper.StaticContent = [
660 "CaloCellContainer#AllCalo",
661 "CaloClusterCellLinkContainer#egammaClusters_links",
665 if flags.Derivation.Egamma.addPLITInputs:
666 from LeptonTaggers.LeptonTaggersConfig
import DecorateImprovedPromptLeptonAlgsCfg, GetExtraImprovedPromptVariablesForDxAOD
669 if flags.Derivation.Egamma.addPLITOutputs:
670 from LeptonTaggers.LeptonTaggersConfig
import DecoratePLITAlgsCfg, GetExtraPLITVariablesForDxAOD
674 EGAM1ItemList = EGAM1SlimmingHelper.GetItemList()
679 ItemList=EGAM1ItemList,
680 AcceptAlgs=[
"EGAM1Kernel"],
687 AcceptAlgs=[
"EGAM1Kernel"],
689 MetadataCategory.CutFlowMetaData,
690 MetadataCategory.TruthMetaData,