11 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
12 from AthenaConfiguration.ComponentFactory
import CompFactory
13 from AthenaConfiguration.Enums
import MetadataCategory
15 from DerivationFrameworkEGamma.PhotonsCPDetailedContent
import (
16 PhotonsCPDetailedContent,
19 from DerivationFrameworkEGamma.TriggerContent
import (
21 ExtraContainersTrigger,
22 ExtraContainersElectronTrigger,
23 ExtraContainersTriggerDataOnly,
31 """Configure the EGAM7 skimming tool"""
35 expression =
"count(Electrons.pt > 4.5*GeV) >= 1"
36 print(
"EGAM7 offline skimming expression: ", expression)
37 EGAM7_OfflineSkimmingTool = CompFactory.DerivationFramework.xAODStringSkimmingTool(
38 name=
"EGAM7_OfflineSkimmingTool", expression=expression
43 if flags.Trigger.EDMVersion == 2:
45 elif flags.Trigger.EDMVersion == 3:
49 triggers = BkgElectronTriggers[MenuType]
50 print(
"EGAM7 trigger skimming list (OR): ", triggers)
52 EGAM7_TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(
53 name=
"EGAM7_TriggerSkimmingTool", TriggerListOR=triggers
57 print(
"EGAM7 skimming is logical AND of previous selections")
58 EGAM7_SkimmingTool = CompFactory.DerivationFramework.FilterCombinationAND(
59 name=
"EGAM7_SkimmingTool",
60 FilterList=[EGAM7_OfflineSkimmingTool, EGAM7_TriggerSkimmingTool],
63 acc.addPublicTool(EGAM7_OfflineSkimmingTool)
64 acc.addPublicTool(EGAM7_TriggerSkimmingTool)
65 acc.addPublicTool(EGAM7_SkimmingTool, primary=
True)
71 """Configure the derivation framework driving algorithm (kernel)
76 from JetRecConfig.StandardSmallRJets
import AntiKt4PV0Track
77 from JetRecConfig.JetRecConfig
import JetRecCfg
79 jetList = [AntiKt4PV0Track]
84 from DerivationFrameworkPhys.PhysCommonConfig
import PhysCommonAugmentationsCfg
88 flags, TriggerListsHelper=kwargs[
"TriggerListsHelper"]
93 augmentationTools = []
98 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
99 CaloDecoratorKernelCfg)
105 streamName = kwargs[
"StreamName"]
108 if flags.Derivation.Egamma.doTrackThinning:
109 from DerivationFrameworkInDet.InDetToolsConfig
import (
110 TrackParticleThinningCfg,
111 MuonTrackParticleThinningCfg,
112 TauTrackParticleThinningCfg,
115 TrackThinningKeepElectronTracks =
True
116 TrackThinningKeepPhotonTracks =
True
117 TrackThinningKeepAllElectronTracks =
False
118 TrackThinningKeepJetTracks =
False
119 TrackThinningKeepMuonTracks =
False
120 TrackThinningKeepTauTracks =
False
121 TrackThinningKeepPVTracks =
False
124 if TrackThinningKeepElectronTracks:
125 EGAM7ElectronTPThinningTool = (
126 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
127 name=
"EGAM7ElectronTPThinningTool",
128 StreamName=streamName,
130 GSFTrackParticlesKey=
"GSFTrackParticles",
131 InDetTrackParticlesKey=
"InDetTrackParticles",
132 SelectionString=
"Electrons.pt > 0*GeV",
137 acc.addPublicTool(EGAM7ElectronTPThinningTool)
138 thinningTools.append(EGAM7ElectronTPThinningTool)
142 if TrackThinningKeepAllElectronTracks:
143 EGAM7ElectronTPThinningTool2 = (
144 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
145 name=
"EGAM7ElectronTPThinningTool2",
146 StreamName=streamName,
148 GSFTrackParticlesKey=
"GSFTrackParticles",
149 InDetTrackParticlesKey=
"InDetTrackParticles",
150 SelectionString=
"Electrons.pt > 4*GeV",
155 acc.addPublicTool(EGAM7ElectronTPThinningTool2)
156 thinningTools.append(EGAM7ElectronTPThinningTool2)
159 if TrackThinningKeepPhotonTracks:
160 EGAM7PhotonTPThinningTool = (
161 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
162 name=
"EGAM7PhotonTPThinningTool",
163 StreamName=streamName,
165 GSFTrackParticlesKey=
"GSFTrackParticles",
166 InDetTrackParticlesKey=
"InDetTrackParticles",
167 GSFConversionVerticesKey=
"GSFConversionVertices",
168 SelectionString=
"Photons.pt > 0*GeV",
173 acc.addPublicTool(EGAM7PhotonTPThinningTool)
174 thinningTools.append(EGAM7PhotonTPThinningTool)
177 if TrackThinningKeepJetTracks:
178 EGAM7JetTPThinningTool = (
179 CompFactory.DerivationFramework.JetTrackParticleThinning(
180 name=
"EGAM7JetTPThinningTool",
181 StreamName=streamName,
182 JetKey=
"AntiKt4EMPFlowJets",
183 InDetTrackParticlesKey=
"InDetTrackParticles",
186 acc.addPublicTool(EGAM7JetTPThinningTool)
187 thinningTools.append(EGAM7JetTPThinningTool)
190 if TrackThinningKeepMuonTracks:
191 EGAM7MuonTPThinningTool = acc.getPrimaryAndMerge(
194 name=
"EGAM7MuonTPThinningTool",
195 StreamName=streamName,
197 InDetTrackParticlesKey=
"InDetTrackParticles",
200 thinningTools.append(EGAM7MuonTPThinningTool)
203 if TrackThinningKeepTauTracks:
204 EGAM7TauTPThinningTool = acc.getPrimaryAndMerge(
207 name=
"EGAM7TauTPThinningTool",
208 StreamName=streamName,
211 InDetTrackParticlesKey=
"InDetTrackParticles",
212 DoTauTracksThinning=
True,
213 TauTracksKey=
"TauTracks",
216 thinningTools.append(EGAM7TauTPThinningTool)
219 thinning_expression =
" && ".
join(
221 "(InDetTrackParticles.DFCommonTightPrimary)",
222 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
223 "(InDetTrackParticles.pt>10*GeV)",
226 if TrackThinningKeepPVTracks:
227 EGAM7TPThinningTool = acc.getPrimaryAndMerge(
230 name=
"EGAM7TPThinningTool",
231 StreamName=streamName,
232 SelectionString=thinning_expression,
233 InDetTrackParticlesKey=
"InDetTrackParticles",
236 thinningTools.append(EGAM7TPThinningTool)
241 truth_cond_WZH =
" && ".
join(
242 [
"(abs(TruthParticles.pdgId) >= 23)",
"(abs(TruthParticles.pdgId) <= 25)"]
245 truth_cond_lep =
" && ".
join(
246 [
"(abs(TruthParticles.pdgId) >= 11)",
"(abs(TruthParticles.pdgId) <= 16)"]
249 truth_cond_top =
"(abs(TruthParticles.pdgId) == 6)"
251 truth_cond_gam =
" && ".
join(
252 [
"(abs(TruthParticles.pdgId) == 22)",
"(TruthParticles.pt > 1*GeV)"]
255 truth_cond_finalState =
" && ".
join(
256 [
"(TruthParticles.status == 1)",
"(TruthParticles.barcode<200000)"]
272 + truth_cond_finalState
275 print(
"EGAM7 truth thinning expression: ", truth_expression)
277 EGAM7TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
278 name=
"EGAM7TruthThinningTool",
279 StreamName=streamName,
280 ParticleSelectionString=truth_expression,
281 PreserveDescendants=
False,
282 PreserveGeneratorDescendants=
True,
283 PreserveAncestors=
True,
285 acc.addPublicTool(EGAM7TruthThinningTool)
286 thinningTools.append(EGAM7TruthThinningTool)
290 from DerivationFrameworkCalo.CaloCellDFGetterConfig
import thinCaloCellsForDFCfg
295 inputClusterKeys=[
"egammaClusters"],
296 streamName=
"StreamDAOD_EGAM7",
297 inputCellKey=
"AllCalo",
298 outputCellKey=
"DFEGAMCellContainer",
307 CompFactory.DerivationFramework.DerivationKernel(
309 SkimmingTools=[skimmingTool],
310 AugmentationTools=augmentationTools,
311 ThinningTools=thinningTools,
328 from DerivationFrameworkPhys.TriggerListsHelper
import TriggerListsHelper
330 EGAM7TriggerListsHelper = TriggerListsHelper(flags)
337 StreamName=
"StreamDAOD_EGAM7",
338 TriggerListsHelper=EGAM7TriggerListsHelper,
343 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
344 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
345 from DerivationFrameworkCore.SlimmingHelper
import SlimmingHelper
348 "EGAM7SlimmingHelper",
349 NamesAndTypes=flags.Input.TypedCollections,
358 EGAM7SlimmingHelper.AllVariables = [
366 if flags.Trigger.EDMVersion == 2:
368 elif flags.Trigger.EDMVersion == 3:
372 EGAM7SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
373 EGAM7SlimmingHelper.AllVariables += ExtraContainersElectronTrigger[MenuType]
374 if not flags.Input.isMC:
375 EGAM7SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly[MenuType]
379 EGAM7SlimmingHelper.AllVariables += [
383 "egammaTruthParticles",
396 EGAM7SlimmingHelper.SmartCollections = [
401 "InDetTrackParticles",
403 "AntiKt4EMPFlowJets",
404 "MET_Baseline_AntiKt4EMPFlow",
405 "BTagging_AntiKt4EMPFlow",
408 EGAM7SlimmingHelper.SmartCollections += [
410 "AntiKt4TruthDressedWZJets",
416 EGAM7SlimmingHelper.ExtraVariables += [
417 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
421 EGAM7SlimmingHelper.ExtraVariables += [
422 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
423 "GSFConversionVertices.trackParticleLinks",
427 EGAM7SlimmingHelper.ExtraVariables += [
"PrimaryVertices.x.y.sumPt2"]
430 EGAM7SlimmingHelper.ExtraVariables += [
431 "AntiKt4PV0TrackJets.pt.eta.phi.e.m.btaggingLink.constituentLinks"
435 EGAM7SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
438 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
440 getClusterEnergyPerLayerDecorations,
444 print(
"EGAM7 gain decorations: ", gainDecorations)
445 EGAM7SlimmingHelper.ExtraVariables.extend(gainDecorations)
447 print(
"EGAM7 cluster energy decorations: ", clusterEnergyDecorations)
448 EGAM7SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
451 EGAM7SlimmingHelper.ExtraVariables += [
452 "TopoClusterIsoCentralEventShape.Density",
453 "TopoClusterIsoForwardEventShape.Density",
454 "NeutralParticleFlowIsoCentralEventShape.Density",
455 "NeutralParticleFlowIsoForwardEventShape.Density",
460 EGAM7SlimmingHelper.ExtraVariables += [
461 "MuonTruthParticles.e.px.py.pz.status.pdgId.truthOrigin.truthType"
464 EGAM7SlimmingHelper.ExtraVariables += [
465 "Photons.truthOrigin.truthType.truthParticleLink"
469 if flags.Derivation.Egamma.doEventInfoSlimming:
470 EGAM7SlimmingHelper.SmartCollections.append(
"EventInfo")
472 EGAM7SlimmingHelper.AllVariables += [
"EventInfo"]
475 EGAM7SlimmingHelper.IncludeEGammaTriggerContent =
True
479 if flags.Trigger.EDMVersion == 2:
480 from DerivationFrameworkPhys.TriggerMatchingCommonConfig
import AddRun2TriggerMatchingToSlimmingHelper
482 OutputContainerPrefix =
"TrigMatch_",
483 TriggerList = EGAM7TriggerListsHelper.Run2TriggerNamesNoTau)
485 if flags.Trigger.EDMVersion == 3
or (flags.Trigger.EDMVersion == 2
and flags.Trigger.doEDMVersionConversion):
486 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig
import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
491 EGAM7SlimmingHelper.StaticContent = [
492 "CaloCellContainer#DFEGAMCellContainer",
493 "CaloClusterCellLinkContainer#egammaClusters_links",
496 EGAM7SlimmingHelper.StaticContent = [
497 "CaloCellContainer#AllCalo",
498 "CaloClusterCellLinkContainer#egammaClusters_links",
501 EGAM7ItemList = EGAM7SlimmingHelper.GetItemList()
506 ItemList=EGAM7ItemList,
507 AcceptAlgs=[
"EGAM7Kernel"],
514 AcceptAlgs=[
"EGAM7Kernel"],
516 MetadataCategory.CutFlowMetaData,
517 MetadataCategory.TruthMetaData,