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 =
" && ".
join(
431 [
"(TruthParticles.status == 1)",
"(TruthParticles.barcode < 200000)"]
447 + truth_cond_finalState
450 print(
"EGAM1 truth thinning expression: ", truth_expression)
452 EGAM1TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
453 name=
"EGAM1TruthThinningTool",
454 StreamName=streamName,
455 ParticleSelectionString=truth_expression,
456 PreserveDescendants=
False,
457 PreserveGeneratorDescendants=
True,
458 PreserveAncestors=
True,
460 acc.addPublicTool(EGAM1TruthThinningTool)
461 thinningTools.append(EGAM1TruthThinningTool)
465 acc.addPublicTool(skimmingTool)
469 CompFactory.DerivationFramework.DerivationKernel(
471 SkimmingTools=[skimmingTool],
472 AugmentationTools=augmentationTools,
473 ThinningTools=thinningTools,
490 from DerivationFrameworkPhys.TriggerListsHelper
import TriggerListsHelper
492 EGAM1TriggerListsHelper = TriggerListsHelper(flags)
499 StreamName=
"StreamDAOD_EGAM1",
500 TriggerListsHelper=EGAM1TriggerListsHelper,
505 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
506 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
507 from DerivationFrameworkCore.SlimmingHelper
import SlimmingHelper
510 "EGAM1SlimmingHelper",
511 NamesAndTypes=flags.Input.TypedCollections,
520 EGAM1SlimmingHelper.AllVariables = [
524 "CaloCalTopoClusters",
529 if flags.Trigger.EDMVersion == 2:
531 elif flags.Trigger.EDMVersion == 3:
535 EGAM1SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
536 EGAM1SlimmingHelper.AllVariables += ExtraContainersElectronTrigger[MenuType]
540 EGAM1SlimmingHelper.AllVariables += [
544 "egammaTruthParticles",
555 EGAM1SlimmingHelper.SmartCollections = [
561 "InDetTrackParticles",
562 "AntiKt4EMPFlowJets",
563 "BTagging_AntiKt4EMPFlow",
564 "MET_Baseline_AntiKt4EMPFlow",
567 EGAM1SlimmingHelper.SmartCollections += [
569 "AntiKt4TruthDressedWZJets",
575 EGAM1SlimmingHelper.ExtraVariables += [
576 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
580 EGAM1SlimmingHelper.ExtraVariables += [
581 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
582 "GSFConversionVertices.trackParticleLinks",
586 EGAM1SlimmingHelper.ExtraVariables += [
"PrimaryVertices.sumPt2"]
589 EGAM1SlimmingHelper.ExtraVariables += [
590 "AntiKt4PV0TrackJets.pt.eta.phi.e.m.btaggingLink.constituentLinks"
594 EGAM1SlimmingHelper.ExtraVariables += [
595 "TopoClusterIsoCentralEventShape.Density",
596 "TopoClusterIsoForwardEventShape.Density",
597 "NeutralParticleFlowIsoCentralEventShape.Density",
598 "NeutralParticleFlowIsoForwardEventShape.Density",
601 from DerivationFrameworkEGamma
import EGammaIsoConfig
608 ) = EGammaIsoConfig.makeEGammaCommonIsoCfg(flags)
610 EGAM1SlimmingHelper.AppendToDictionary.update(densityDict)
611 EGAM1SlimmingHelper.ExtraVariables += densityList
614 EGAM1SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
617 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
619 getClusterEnergyPerLayerDecorations,
623 print(
"EGAM1 gain decorations: ", gainDecorations)
624 EGAM1SlimmingHelper.ExtraVariables.extend(gainDecorations)
626 print(
"EGAM1 cluster energy decorations: ", clusterEnergyDecorations)
627 EGAM1SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
631 EGAM1SlimmingHelper.ExtraVariables += [
632 "MuonTruthParticles.e.px.py.pz.status.pdgId.truthOrigin.truthType"
635 EGAM1SlimmingHelper.ExtraVariables += [
636 "Photons.truthOrigin.truthType.truthParticleLink"
640 if flags.Derivation.Egamma.doEventInfoSlimming:
641 EGAM1SlimmingHelper.SmartCollections.append(
"EventInfo")
643 EGAM1SlimmingHelper.AllVariables += [
"EventInfo"]
646 EGAM1SlimmingHelper.IncludeEGammaTriggerContent =
True
650 if flags.Trigger.EDMVersion == 2:
651 from DerivationFrameworkPhys.TriggerMatchingCommonConfig
import AddRun2TriggerMatchingToSlimmingHelper
653 OutputContainerPrefix =
"TrigMatch_",
654 TriggerList = EGAM1TriggerListsHelper.Run2TriggerNamesNoTau)
656 if flags.Trigger.EDMVersion == 3
or (flags.Trigger.EDMVersion == 2
and flags.Trigger.doEDMVersionConversion):
657 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig
import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
661 EGAM1SlimmingHelper.StaticContent = [
662 "CaloCellContainer#AllCalo",
663 "CaloClusterCellLinkContainer#egammaClusters_links",
666 EGAM1ItemList = EGAM1SlimmingHelper.GetItemList()
671 ItemList=EGAM1ItemList,
672 AcceptAlgs=[
"EGAM1Kernel"],
679 AcceptAlgs=[
"EGAM1Kernel"],
681 MetadataCategory.CutFlowMetaData,
682 MetadataCategory.TruthMetaData,