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 EGAM8 skimming tool"""
25 expression =
" || ".
join(
27 "(count(EGAM8_DiElectronMass >50.0*GeV) >=1)",
28 "(count(EGAM8_MuonElectronMass >50.0*GeV) >=1)",
31 print(
"EGAM8 skimming expression: ", expression)
34 CompFactory.DerivationFramework.xAODStringSkimmingTool(
35 name=
"EGAM8SkimmingTool", expression=expression
43 """Configure the EGAM8 ee invariant mass augmentation tool"""
57 requirement_tag =
" && ".
join(
58 [
"(Electrons.DFCommonElectronsLHMedium)",
"(Electrons.pt > 24.5*GeV)"]
60 requirement_probe =
"ForwardElectrons.pt > 19.5*GeV"
63 CompFactory.DerivationFramework.EGInvariantMassTool(
64 name=
"EGAM8_ZEEMassTool",
65 Object1Requirements=requirement_tag,
66 Object2Requirements=requirement_probe,
67 StoreGateEntryName=
"EGAM8_DiElectronMass",
68 Mass1Hypothesis=0.511 * MeV,
69 Mass2Hypothesis=0.511 * MeV,
70 Container1Name=
"Electrons",
71 Container2Name=
"ForwardElectrons",
73 DoTransverseMass=
False,
82 """Configure the EGAM8 mue invariant mass augmentation tool"""
95 requirement_muon =
" && ".
join(
99 "Muons.DFCommonMuonPassPreselection",
102 requirement_electron =
"ForwardElectrons.pt > 19.5*GeV"
105 CompFactory.DerivationFramework.EGInvariantMassTool(
106 name=
"EGAM8_ZMuEMassTool",
107 Object1Requirements=requirement_muon,
108 Object2Requirements=requirement_electron,
109 StoreGateEntryName=
"EGAM8_MuonElectronMass",
110 Mass1Hypothesis=105 * MeV,
111 Mass2Hypothesis=0.511 * MeV,
112 Container1Name=
"Muons",
113 Container2Name=
"ForwardElectrons",
115 DoTransverseMass=
False,
125 """Configure the derivation framework driving algorithm (kernel)
130 from DerivationFrameworkPhys.PhysCommonConfig
import PhysCommonAugmentationsCfg
134 flags, TriggerListsHelper=kwargs[
"TriggerListsHelper"]
139 augmentationTools = []
145 acc.addPublicTool(EGAM8ZeeMassTool)
146 augmentationTools.append(EGAM8ZeeMassTool)
149 acc.addPublicTool(EGAM8ZmueMassTool)
150 augmentationTools.append(EGAM8ZmueMassTool)
155 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
156 CaloDecoratorKernelCfg)
161 streamName = kwargs[
"StreamName"]
164 if flags.Derivation.Egamma.doTrackThinning:
165 from DerivationFrameworkInDet.InDetToolsConfig
import (
166 TrackParticleThinningCfg,
167 MuonTrackParticleThinningCfg,
168 TauTrackParticleThinningCfg,
171 TrackThinningKeepElectronTracks =
True
172 TrackThinningKeepPhotonTracks =
True
173 TrackThinningKeepAllElectronTracks =
False
174 TrackThinningKeepJetTracks =
False
175 TrackThinningKeepMuonTracks =
True
176 TrackThinningKeepTauTracks =
False
177 TrackThinningKeepPVTracks =
False
180 if TrackThinningKeepElectronTracks:
181 EGAM8ElectronTPThinningTool = (
182 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
183 name=
"EGAM8ElectronTPThinningTool",
184 StreamName=streamName,
186 GSFTrackParticlesKey=
"GSFTrackParticles",
187 InDetTrackParticlesKey=
"InDetTrackParticles",
188 SelectionString=
"Electrons.pt > 0*GeV",
193 acc.addPublicTool(EGAM8ElectronTPThinningTool)
194 thinningTools.append(EGAM8ElectronTPThinningTool)
198 if TrackThinningKeepAllElectronTracks:
199 EGAM8ElectronTPThinningTool2 = (
200 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
201 name=
"EGAM8ElectronTPThinningTool2",
202 StreamName=streamName,
204 GSFTrackParticlesKey=
"GSFTrackParticles",
205 InDetTrackParticlesKey=
"InDetTrackParticles",
206 SelectionString=
"Electrons.pt > 4*GeV",
211 acc.addPublicTool(EGAM8ElectronTPThinningTool2)
212 thinningTools.append(EGAM8ElectronTPThinningTool2)
215 if TrackThinningKeepPhotonTracks:
216 EGAM8PhotonTPThinningTool = (
217 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
218 name=
"EGAM8PhotonTPThinningTool",
219 StreamName=streamName,
221 GSFTrackParticlesKey=
"GSFTrackParticles",
222 InDetTrackParticlesKey=
"InDetTrackParticles",
223 GSFConversionVerticesKey=
"GSFConversionVertices",
224 SelectionString=
"Photons.pt > 0*GeV",
229 acc.addPublicTool(EGAM8PhotonTPThinningTool)
230 thinningTools.append(EGAM8PhotonTPThinningTool)
233 if TrackThinningKeepJetTracks:
234 EGAM8JetTPThinningTool = (
235 CompFactory.DerivationFramework.JetTrackParticleThinning(
236 name=
"EGAM8JetTPThinningTool",
237 StreamName=streamName,
238 JetKey=
"AntiKt4EMPFlowJets",
239 InDetTrackParticlesKey=
"InDetTrackParticles",
242 acc.addPublicTool(EGAM8JetTPThinningTool)
243 thinningTools.append(EGAM8JetTPThinningTool)
246 if TrackThinningKeepMuonTracks:
247 EGAM8MuonTPThinningTool = acc.getPrimaryAndMerge(
250 name=
"EGAM8MuonTPThinningTool",
251 StreamName=streamName,
253 InDetTrackParticlesKey=
"InDetTrackParticles",
256 thinningTools.append(EGAM8MuonTPThinningTool)
259 if TrackThinningKeepTauTracks:
260 EGAM8TauTPThinningTool = acc.getPrimaryAndMerge(
263 name=
"EGAM8TauTPThinningTool",
264 StreamName=streamName,
267 InDetTrackParticlesKey=
"InDetTrackParticles",
268 DoTauTracksThinning=
True,
269 TauTracksKey=
"TauTracks",
272 thinningTools.append(EGAM8TauTPThinningTool)
275 thinning_expression =
" && ".
join(
277 "(InDetTrackParticles.DFCommonTightPrimary)",
278 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3.0*mm)",
279 "(InDetTrackParticles.pt>10*GeV)",
282 if TrackThinningKeepPVTracks:
283 EGAM8TPThinningTool = acc.getPrimaryAndMerge(
286 name=
"EGAM8TPThinningTool",
287 StreamName=streamName,
288 SelectionString=thinning_expression,
289 InDetTrackParticlesKey=
"InDetTrackParticles",
292 thinningTools.append(EGAM8TPThinningTool)
297 truth_cond_WZH =
" && ".
join(
298 [
"(abs(TruthParticles.pdgId) >= 23)",
"(abs(TruthParticles.pdgId) <= 25)"]
301 truth_cond_lep =
" && ".
join(
302 [
"(abs(TruthParticles.pdgId) >= 11)",
"(abs(TruthParticles.pdgId) <= 16)"]
305 truth_cond_top =
"(abs(TruthParticles.pdgId) == 6)"
307 truth_cond_gam =
" && ".
join(
308 [
"(abs(TruthParticles.pdgId) == 22)",
"(TruthParticles.pt > 1*GeV)"]
311 truth_cond_finalState =
" && ".
join(
312 [
"(TruthParticles.status == 1)",
"(TruthParticles.barcode<200000)"]
328 + truth_cond_finalState
331 print(
"EGAM8 truth thinning expression: ", truth_expression)
333 EGAM8TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
334 name=
"EGAM8TruthThinningTool",
335 StreamName=streamName,
336 ParticleSelectionString=truth_expression,
337 PreserveDescendants=
False,
338 PreserveGeneratorDescendants=
True,
339 PreserveAncestors=
True,
341 acc.addPublicTool(EGAM8TruthThinningTool)
342 thinningTools.append(EGAM8TruthThinningTool)
346 acc.addPublicTool(skimmingTool)
350 CompFactory.DerivationFramework.DerivationKernel(
352 SkimmingTools=[skimmingTool],
353 AugmentationTools=augmentationTools,
354 ThinningTools=thinningTools,
371 from DerivationFrameworkPhys.TriggerListsHelper
import TriggerListsHelper
373 EGAM8TriggerListsHelper = TriggerListsHelper(flags)
380 StreamName=
"StreamDAOD_EGAM8",
381 TriggerListsHelper=EGAM8TriggerListsHelper,
386 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
387 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
388 from DerivationFrameworkCore.SlimmingHelper
import SlimmingHelper
391 "EGAM8SlimmingHelper",
392 NamesAndTypes=flags.Input.TypedCollections,
401 EGAM8SlimmingHelper.AllVariables = [
406 "ForwardElectronClusters",
414 EGAM8SlimmingHelper.AllVariables += [
418 "egammaTruthParticles",
429 EGAM8SlimmingHelper.SmartCollections = [
435 "InDetTrackParticles",
436 "AntiKt4EMPFlowJets",
437 "BTagging_AntiKt4EMPFlow",
438 "MET_Baseline_AntiKt4EMPFlow",
441 EGAM8SlimmingHelper.SmartCollections += [
443 "AntiKt4TruthDressedWZJets",
449 EGAM8SlimmingHelper.ExtraVariables += [
450 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
454 EGAM8SlimmingHelper.ExtraVariables += [
455 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
456 "GSFConversionVertices.trackParticleLinks",
460 EGAM8SlimmingHelper.ExtraVariables += [
"PrimaryVertices.x.y.sumPt2"]
463 EGAM8SlimmingHelper.ExtraVariables += [
464 "AntiKt4PV0TrackJets.pt.eta.phi.e.m.btaggingLink.constituentLinks"
468 EGAM8SlimmingHelper.ExtraVariables += [
469 "TopoClusterIsoCentralEventShape.Density",
470 "TopoClusterIsoForwardEventShape.Density",
471 "NeutralParticleFlowIsoCentralEventShape.Density",
472 "NeutralParticleFlowIsoForwardEventShape.Density",
476 EGAM8SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
479 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
481 getClusterEnergyPerLayerDecorations,
485 print(
"EGAM8 gain decorations: ", gainDecorations)
486 EGAM8SlimmingHelper.ExtraVariables.extend(gainDecorations)
488 print(
"EGAM8 cluster energy decorations: ", clusterEnergyDecorations)
489 EGAM8SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
493 EGAM8SlimmingHelper.ExtraVariables += [
494 "MuonTruthParticles.e.px.py.pz.status.pdgId.truthOrigin.truthType"
497 EGAM8SlimmingHelper.ExtraVariables += [
498 "Photons.truthOrigin.truthType.truthParticleLink"
502 if flags.Derivation.Egamma.doEventInfoSlimming:
503 EGAM8SlimmingHelper.SmartCollections.append(
"EventInfo")
505 EGAM8SlimmingHelper.AllVariables += [
"EventInfo"]
508 EGAM8SlimmingHelper.IncludeEGammaTriggerContent =
True
509 EGAM8SlimmingHelper.IncludeMuonTriggerContent =
True
513 if flags.Trigger.EDMVersion == 2:
514 from DerivationFrameworkPhys.TriggerMatchingCommonConfig
import AddRun2TriggerMatchingToSlimmingHelper
516 OutputContainerPrefix =
"TrigMatch_",
517 TriggerList = EGAM8TriggerListsHelper.Run2TriggerNamesNoTau)
519 if flags.Trigger.EDMVersion == 3
or (flags.Trigger.EDMVersion == 2
and flags.Trigger.doEDMVersionConversion):
520 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig
import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
524 EGAM8SlimmingHelper.StaticContent = [
525 "CaloCellContainer#AllCalo",
526 "CaloClusterCellLinkContainer#egammaClusters_links",
527 "CaloClusterCellLinkContainer#ForwardElectronClusters_links",
530 EGAM8ItemList = EGAM8SlimmingHelper.GetItemList()
535 ItemList=EGAM8ItemList,
536 AcceptAlgs=[
"EGAM8Kernel"],
543 AcceptAlgs=[
"EGAM8Kernel"],
545 MetadataCategory.CutFlowMetaData,
546 MetadataCategory.TruthMetaData,