10 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
11 from AthenaConfiguration.ComponentFactory
import CompFactory
12 from AthenaConfiguration.Enums
import MetadataCategory
16 from DerivationFrameworkEGamma.PhotonsCPDetailedContent
import (
17 PhotonsCPDetailedContent,
22 """Configure the EGAM11 skimming tool"""
25 expression =
" || ".
join(
27 "(count( EGAM11_DiElectronMass1 > 50.0*GeV ) >= 1)",
28 "(count( EGAM11_DiElectronMass2 > 50.0*GeV ) >= 1)",
29 "(count( EGAM11_DiElectronMass3 > 50.0*GeV ) >= 1)",
30 "(count( EGAM11_ElectronPhotonMass > 50.0*GeV )>=1)",
33 print(
"EGAM11 skimming expression: ", expression)
36 CompFactory.DerivationFramework.xAODStringSkimmingTool(
37 name=
"EGAM11SkimmingTool", expression=expression, TrigDecisionTool=
""
45 """Configure the EGAM11 ee invariant mass augmentation tool 1"""
58 requirement_tag =
" && ".
join(
59 [
"(Electrons.DFCommonElectronsLHTight)",
"(Electrons.pt > 24.5*GeV)"]
62 requirement_probe =
" && ".
join(
63 [
"(Electrons.DFCommonElectronsLHMedium)",
"(Electrons.pt > 19.5*GeV)"]
67 CompFactory.DerivationFramework.EGInvariantMassTool(
68 name=
"EGAM11_ZEEMassTool1",
69 Object1Requirements=requirement_tag,
70 Object2Requirements=requirement_probe,
71 StoreGateEntryName=
"EGAM11_DiElectronMass1",
72 Mass1Hypothesis=0.511 * MeV,
73 Mass2Hypothesis=0.511 * MeV,
74 Container1Name=
"Electrons",
75 Container2Name=
"Electrons",
77 DoTransverseMass=
False,
86 """Configure the EGAM11 ee invariant mass augmentation tool 2"""
98 requirement =
" && ".
join(
99 [
"(Electrons.DFCommonElectronsLHMedium)",
"(Electrons.pt > 19.5*GeV)"]
103 CompFactory.DerivationFramework.EGInvariantMassTool(
104 name=
"EGAM11_ZEEMassTool2",
105 Object1Requirements=requirement,
106 Object2Requirements=requirement,
107 StoreGateEntryName=
"EGAM11_DiElectronMass2",
108 Mass1Hypothesis=0.511 * MeV,
109 Mass2Hypothesis=0.511 * MeV,
110 Container1Name=
"Electrons",
111 Container2Name=
"Electrons",
113 DoTransverseMass=
False,
122 """Configure the EGAM11 ee invariant mass augmentation tool 3"""
135 requirement_tag =
" && ".
join(
136 [
"(Electrons.DFCommonElectronsLHMedium)",
"(Electrons.pt > 24.5*GeV)"]
139 requirement_probe =
"Electrons.pt > 4*GeV"
142 CompFactory.DerivationFramework.EGInvariantMassTool(
143 name=
"EGAM11_ZEEMassTool3",
144 Object1Requirements=requirement_tag,
145 Object2Requirements=requirement_probe,
146 StoreGateEntryName=
"EGAM11_DiElectronMass3",
147 Mass1Hypothesis=0.511 * MeV,
148 Mass2Hypothesis=0.511 * MeV,
149 Container1Name=
"Electrons",
150 Container2Name=
"Electrons",
152 DoTransverseMass=
False,
161 """Configure the EGAM11 e+photon mass augmentation tool"""
176 requirement_tag =
" && ".
join(
177 [
"(Electrons.DFCommonElectronsLHMedium)",
"(Electrons.pt > 24.5*GeV)"]
180 requirement_probe =
"DFCommonPhotons_et > 14.5*GeV"
183 CompFactory.DerivationFramework.EGInvariantMassTool(
184 name=
"EGAM11_ZEGMassTool",
185 Object1Requirements=requirement_tag,
186 Object2Requirements=requirement_probe,
187 StoreGateEntryName=
"EGAM11_ElectronPhotonMass",
188 Mass1Hypothesis=0.511 * MeV,
189 Mass2Hypothesis=0.511 * MeV,
190 Container1Name=
"Electrons",
191 Container2Name=
"Photons",
192 Pt2BranchName=
"DFCommonPhotons_et",
193 Eta2BranchName=
"DFCommonPhotons_eta",
194 Phi2BranchName=
"DFCommonPhotons_phi",
196 DoTransverseMass=
False,
205 """Configure the derivation framework driving algorithm (kernel)
210 from JetRecConfig.StandardSmallRJets
import AntiKt4PV0Track, AntiKt4EMTopo
211 from JetRecConfig.JetRecConfig
import JetRecCfg
213 jetList = [AntiKt4PV0Track, AntiKt4EMTopo]
222 from DerivationFrameworkInDet.InDetCommonConfig
import InDetCommonCfg
223 from DerivationFrameworkMuons.MuonsCommonConfig
import MuonsCommonCfg
224 from DerivationFrameworkEGamma.EGammaCommonConfig
import EGammaCommonCfg
226 TrackingFlags = flags.Tracking
230 DoVertexFinding=TrackingFlags.doVertexFinding,
231 AddPseudoTracks=TrackingFlags.doPseudoTracking,
233 DoR3LargeD0=flags.Tracking.doLargeD0,
234 StoreSeparateLargeD0Container=TrackingFlags.storeSeparateLargeD0Container,
249 from JetJvtEfficiency.JetJvtEfficiencyToolConfig
import getJvtEffToolCfg
251 algName =
"DFJet_EventCleaning_passJvtAlg"
252 passJvtTool = acc.popToolsAndMerge(
getJvtEffToolCfg(flags,
"AntiKt4EMTopo"))
253 passJvtTool.PassJVTKey =
"AntiKt4EMTopoJets.DFCommonJets_passJvt"
255 CompFactory.JetDecorationAlg(
256 algName, JetContainer=
"AntiKt4EMTopoJets", Decorators=[passJvtTool]
262 from AssociationUtils.AssociationUtilsConfig
import OverlapRemovalToolCfg
264 outputLabel =
"DFCommonJets_passOR"
268 orTool = acc.popToolsAndMerge(
270 flags, outputLabel=outputLabel, bJetLabel=bJetLabel, doTaus=
False
273 algOR = CompFactory.OverlapRemovalGenUseAlg(
274 "OverlapRemovalGenUseAlg",
275 OverlapLabel=outputLabel,
276 OverlapRemovalTool=orTool,
281 acc.addEventAlgo(algOR)
284 from JetSelectorTools.JetSelectorToolsConfig
import (
285 EventCleaningToolCfg,
289 workingPoints = [
"Loose"]
290 prefix =
"DFCommonJets_"
292 for wp
in workingPoints:
293 cleaningLevel = wp +
"Bad"
296 cleaningLevel = wp.replace(
"LLP",
"BadLLP")
298 jetCleaningTool = acc.popToolsAndMerge(
301 "JetCleaningTool_" + cleaningLevel,
307 acc.addPublicTool(jetCleaningTool)
309 ecTool = acc.popToolsAndMerge(
312 ecTool.JetCleanPrefix = prefix
313 ecTool.JetContainer =
"AntiKt4EMTopoJets"
314 ecTool.JetCleaningTool = jetCleaningTool
315 acc.addPublicTool(ecTool)
319 eventCleanAlg = CompFactory.EventCleaningTestAlg(
320 "EventCleaningTestAlg_" + wp,
321 EventCleaningTool=ecTool,
322 JetCollectionName=
"AntiKt4EMTopoJets",
323 EventCleanPrefix=prefix,
324 CleaningLevel=cleaningLevel,
325 doEvent=(
"Loose" in wp),
327 acc.addEventAlgo(eventCleanAlg)
330 augmentationTools = []
336 acc.addPublicTool(EGAM11ZeeMassTool1)
337 augmentationTools.append(EGAM11ZeeMassTool1)
340 acc.addPublicTool(EGAM11ZeeMassTool2)
341 augmentationTools.append(EGAM11ZeeMassTool2)
344 acc.addPublicTool(EGAM11ZeeMassTool3)
345 augmentationTools.append(EGAM11ZeeMassTool3)
348 acc.addPublicTool(EGAM11ZegMassTool)
349 augmentationTools.append(EGAM11ZegMassTool)
353 streamName = kwargs[
"StreamName"]
356 if flags.Derivation.Egamma.doTrackThinning:
357 from DerivationFrameworkInDet.InDetToolsConfig
import (
358 TrackParticleThinningCfg,
359 MuonTrackParticleThinningCfg,
360 TauTrackParticleThinningCfg,
363 TrackThinningKeepElectronTracks =
True
364 TrackThinningKeepPhotonTracks =
True
365 TrackThinningKeepAllElectronTracks =
True
366 TrackThinningKeepJetTracks =
False
367 TrackThinningKeepMuonTracks =
False
368 TrackThinningKeepTauTracks =
False
369 TrackThinningKeepPVTracks =
True
372 if TrackThinningKeepElectronTracks:
373 EGAM11ElectronTPThinningTool = (
374 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
375 name=
"EGAM11ElectronTPThinningTool",
376 StreamName=streamName,
378 GSFTrackParticlesKey=
"GSFTrackParticles",
379 InDetTrackParticlesKey=
"InDetTrackParticles",
380 SelectionString=
"Electrons.pt > 0*GeV",
385 acc.addPublicTool(EGAM11ElectronTPThinningTool)
386 thinningTools.append(EGAM11ElectronTPThinningTool)
390 if TrackThinningKeepAllElectronTracks:
391 EGAM11ElectronTPThinningTool2 = (
392 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
393 name=
"EGAM11ElectronTPThinningTool2",
394 StreamName=streamName,
396 GSFTrackParticlesKey=
"GSFTrackParticles",
397 InDetTrackParticlesKey=
"InDetTrackParticles",
398 SelectionString=
"Electrons.pt > 4*GeV",
403 acc.addPublicTool(EGAM11ElectronTPThinningTool2)
404 thinningTools.append(EGAM11ElectronTPThinningTool2)
407 if TrackThinningKeepPhotonTracks:
408 EGAM11PhotonTPThinningTool = (
409 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
410 name=
"EGAM11PhotonTPThinningTool",
411 StreamName=streamName,
413 GSFTrackParticlesKey=
"GSFTrackParticles",
414 InDetTrackParticlesKey=
"InDetTrackParticles",
415 GSFConversionVerticesKey=
"GSFConversionVertices",
416 SelectionString=
"Photons.pt > 0*GeV",
421 acc.addPublicTool(EGAM11PhotonTPThinningTool)
422 thinningTools.append(EGAM11PhotonTPThinningTool)
425 if TrackThinningKeepJetTracks:
426 EGAM11JetTPThinningTool = (
427 CompFactory.DerivationFramework.JetTrackParticleThinning(
428 name=
"EGAM11JetTPThinningTool",
429 StreamName=streamName,
430 JetKey=
"AntiKt4EMTopoJets",
431 InDetTrackParticlesKey=
"InDetTrackParticles",
434 acc.addPublicTool(EGAM11JetTPThinningTool)
435 thinningTools.append(EGAM11JetTPThinningTool)
438 if TrackThinningKeepMuonTracks:
439 EGAM11MuonTPThinningTool = acc.getPrimaryAndMerge(
442 name=
"EGAM11MuonTPThinningTool",
443 StreamName=streamName,
445 InDetTrackParticlesKey=
"InDetTrackParticles",
448 thinningTools.append(EGAM11MuonTPThinningTool)
451 if TrackThinningKeepTauTracks:
452 EGAM11TauTPThinningTool = acc.getPrimaryAndMerge(
455 name=
"EGAM11TauTPThinningTool",
456 StreamName=streamName,
459 InDetTrackParticlesKey=
"InDetTrackParticles",
460 DoTauTracksThinning=
True,
461 TauTracksKey=
"TauTracks",
464 thinningTools.append(EGAM11TauTPThinningTool)
467 thinning_expression =
" && ".
join(
469 "(InDetTrackParticles.DFCommonTightPrimary)",
470 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3mm)",
471 "(InDetTrackParticles.pt>10*GeV)",
474 if TrackThinningKeepPVTracks:
475 EGAM11TPThinningTool = acc.getPrimaryAndMerge(
478 name=
"EGAM11TPThinningTool",
479 StreamName=streamName,
480 SelectionString=thinning_expression,
481 InDetTrackParticlesKey=
"InDetTrackParticles",
484 thinningTools.append(EGAM11TPThinningTool)
487 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
488 CaloClusterThinningCfg,
491 EGAM11CCTCThinningTool = acc.getPrimaryAndMerge(
494 name=
"EGAM11CCTCThinningTool",
495 StreamName=streamName,
497 SelectionString=
"Electrons.pt>4*GeV",
498 TopoClCollectionSGKey=
"CaloCalTopoClusters",
502 thinningTools.append(EGAM11CCTCThinningTool)
507 truth_cond_WZH =
" && ".
join(
508 [
"(abs(TruthParticles.pdgId) >= 23)",
"(abs(TruthParticles.pdgId) <= 25)"]
511 truth_cond_lep =
" && ".
join(
512 [
"(abs(TruthParticles.pdgId) >= 11)",
"(abs(TruthParticles.pdgId) <= 16)"]
515 truth_cond_top =
"(abs(TruthParticles.pdgId) == 6)"
517 truth_cond_gam =
" && ".
join(
518 [
"(abs(TruthParticles.pdgId) == 22)",
"(TruthParticles.pt > 1*GeV)"]
521 truth_cond_finalState =
" && ".
join(
522 [
"(TruthParticles.status == 1)",
"(TruthParticles.barcode < 200000)"]
538 + truth_cond_finalState
541 print(
"EGAM11 truth thinning expression: ", truth_expression)
543 EGAM11TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
544 name=
"EGAM11TruthThinningTool",
545 StreamName=streamName,
546 ParticleSelectionString=truth_expression,
547 PreserveDescendants=
False,
548 PreserveGeneratorDescendants=
True,
549 PreserveAncestors=
True,
551 acc.addPublicTool(EGAM11TruthThinningTool)
552 thinningTools.append(EGAM11TruthThinningTool)
556 acc.addPublicTool(skimmingTool)
560 CompFactory.DerivationFramework.DerivationKernel(
562 SkimmingTools=[skimmingTool],
563 AugmentationTools=augmentationTools,
564 ThinningTools=thinningTools,
579 StreamName=
"StreamDAOD_EGAM11",
580 TriggerListsHelper=
None,
585 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
586 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
587 from DerivationFrameworkCore.SlimmingHelper
import SlimmingHelper
590 "EGAM11SlimmingHelper",
591 NamesAndTypes=flags.Input.TypedCollections,
600 EGAM11SlimmingHelper.AllVariables = [
604 "CaloCalTopoClusters",
609 EGAM11SlimmingHelper.AllVariables += [
613 "egammaTruthParticles",
624 EGAM11SlimmingHelper.SmartCollections = [
630 "InDetTrackParticles",
634 EGAM11SlimmingHelper.SmartCollections += [
636 "AntiKt4TruthDressedWZJets",
642 EGAM11SlimmingHelper.ExtraVariables += [
643 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
647 EGAM11SlimmingHelper.ExtraVariables += [
648 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
649 "GSFConversionVertices.trackParticleLinks",
653 EGAM11SlimmingHelper.ExtraVariables += [
"PrimaryVertices.sumPt2"]
656 EGAM11SlimmingHelper.ExtraVariables += [
657 "AntiKt4PV0TrackJets.pt.eta.phi.e.m.btaggingLink.constituentLinks"
661 EGAM11SlimmingHelper.ExtraVariables += [
662 "TopoClusterIsoCentralEventShape.Density",
663 "TopoClusterIsoForwardEventShape.Density",
667 EGAM11SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
671 EGAM11SlimmingHelper.ExtraVariables += [
672 "MuonTruthParticles.e.px.py.pz.status.pdgId.truthOrigin.truthType"
675 EGAM11SlimmingHelper.ExtraVariables += [
676 "Photons.truthOrigin.truthType.truthParticleLink"
680 if flags.Derivation.Egamma.doEventInfoSlimming:
681 EGAM11SlimmingHelper.SmartCollections.append(
"EventInfo")
683 EGAM11SlimmingHelper.AllVariables += [
"EventInfo"]
686 EGAM11SlimmingHelper.AllVariables += [
"HIEventShape"]
687 EGAM11SlimmingHelper.AllVariables += [
"CaloSums"]
690 EGAM11SlimmingHelper.StaticContent = [
691 "CaloCellContainer#AllCalo",
692 "CaloClusterCellLinkContainer#egammaClusters_links",
695 EGAM11ItemList = EGAM11SlimmingHelper.GetItemList()
700 ItemList=EGAM11ItemList,
701 AcceptAlgs=[
"EGAM11Kernel"],
708 AcceptAlgs=[
"EGAM11Kernel"],
710 MetadataCategory.CutFlowMetaData,
711 MetadataCategory.TruthMetaData,