9 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
10 from AthenaConfiguration.ComponentFactory
import CompFactory
11 from AthenaConfiguration.Enums
import MetadataCategory
15 from DerivationFrameworkEGamma.ElectronsCPDetailedContent
import (
16 ElectronsCPDetailedContent,
17 GSFTracksCPDetailedContent,
20 from DerivationFrameworkEGamma.TriggerContent
import (
21 ExtraContainersTrigger,
22 ExtraContainersPhotonTrigger,
23 ExtraContainersMuonTrigger,
24 ExtraContainersTriggerDataOnly,
29 """Configure the EGAM4 skimming tool"""
33 expression1a =
" && ".
join(
35 "(count(DFCommonPhotons_et>9.5*GeV)>=1)",
36 "(count(EGAM4_DiMuonMass > 40.0*GeV)>=1)",
41 expression1b =
" && ".
join(
42 [
"(count(Electrons.pt>9.5*GeV)>=1)",
"(count(EGAM4_DiMuonMass > 40.0*GeV)>=1)"]
46 expression =
"( " + expression1a +
" ) || ( " + expression1b +
" )"
47 print(
"EGAM4 skimming expression: ", expression)
50 CompFactory.DerivationFramework.xAODStringSkimmingTool(
51 name=
"EGAM4SkimmingTool", expression=expression
59 """Configure the EGAM4 mumu invariant mass augmentation tool"""
66 requirementMuons =
" && ".
join(
67 [
"Muons.pt>9.5*GeV",
"abs(Muons.eta)<2.7",
"Muons.DFCommonMuonPassPreselection"]
71 CompFactory.DerivationFramework.EGInvariantMassTool(
72 name=
"EGAM4_MuMuMassTool",
73 Object1Requirements=requirementMuons,
74 Object2Requirements=requirementMuons,
75 StoreGateEntryName=
"EGAM4_DiMuonMass",
76 Mass1Hypothesis=105 * MeV,
77 Mass2Hypothesis=105 * MeV,
78 Container1Name=
"Muons",
79 Container2Name=
"Muons",
81 DoTransverseMass=
False,
91 """Configure the derivation framework driving algorithm (kernel)
96 from DerivationFrameworkPhys.PhysCommonConfig
import PhysCommonAugmentationsCfg
100 flags, TriggerListsHelper=kwargs[
"TriggerListsHelper"]
105 augmentationTools = []
111 acc.addPublicTool(EGAM4mumuMassTool)
112 augmentationTools.append(EGAM4mumuMassTool)
117 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
118 CaloDecoratorKernelCfg)
123 streamName = kwargs[
"StreamName"]
126 if flags.Derivation.Egamma.doTrackThinning:
127 from DerivationFrameworkInDet.InDetToolsConfig
import (
128 TrackParticleThinningCfg,
129 MuonTrackParticleThinningCfg,
130 TauTrackParticleThinningCfg,
133 TrackThinningKeepElectronTracks =
True
134 TrackThinningKeepAllElectronTracks =
False
135 TrackThinningKeepPhotonTracks =
True
136 TrackThinningKeepAllPhotonTracks =
True
137 TrackThinningKeepJetTracks =
False
138 TrackThinningKeepMuonTracks =
False
139 TrackThinningKeepTauTracks =
False
140 TrackThinningKeepPVTracks =
True
143 if TrackThinningKeepElectronTracks:
144 EGAM4ElectronTPThinningTool = (
145 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
146 name=
"EGAM4ElectronTPThinningTool",
147 StreamName=streamName,
149 GSFTrackParticlesKey=
"GSFTrackParticles",
150 InDetTrackParticlesKey=
"InDetTrackParticles",
151 SelectionString=
"Electrons.pt > 0*GeV",
156 acc.addPublicTool(EGAM4ElectronTPThinningTool)
157 thinningTools.append(EGAM4ElectronTPThinningTool)
161 if TrackThinningKeepAllElectronTracks:
162 EGAM4ElectronTPThinningTool2 = (
163 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
164 name=
"EGAM4ElectronTPThinningTool2",
165 StreamName=streamName,
167 GSFTrackParticlesKey=
"GSFTrackParticles",
168 InDetTrackParticlesKey=
"InDetTrackParticles",
169 SelectionString=
"Electrons.pt > 4*GeV",
174 acc.addPublicTool(EGAM4ElectronTPThinningTool2)
175 thinningTools.append(EGAM4ElectronTPThinningTool2)
178 if TrackThinningKeepPhotonTracks:
179 EGAM4PhotonTPThinningTool = (
180 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
181 name=
"EGAM4PhotonTPThinningTool",
182 StreamName=streamName,
184 GSFTrackParticlesKey=
"GSFTrackParticles",
185 InDetTrackParticlesKey=
"InDetTrackParticles",
186 GSFConversionVerticesKey=
"GSFConversionVertices",
187 SelectionString=
"Photons.pt > 0*GeV",
192 acc.addPublicTool(EGAM4PhotonTPThinningTool)
193 thinningTools.append(EGAM4PhotonTPThinningTool)
197 if TrackThinningKeepAllPhotonTracks:
198 EGAM4PhotonTPThinningTool2 = (
199 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
200 name=
"EGAM4PhotonTPThinningTool2",
201 StreamName=streamName,
203 GSFTrackParticlesKey=
"GSFTrackParticles",
204 InDetTrackParticlesKey=
"InDetTrackParticles",
205 GSFConversionVerticesKey=
"GSFConversionVertices",
206 SelectionString=
"Photons.pt > 9.5*GeV",
211 acc.addPublicTool(EGAM4PhotonTPThinningTool2)
212 thinningTools.append(EGAM4PhotonTPThinningTool2)
215 if TrackThinningKeepJetTracks:
216 EGAM4JetTPThinningTool = (
217 CompFactory.DerivationFramework.JetTrackParticleThinning(
218 name=
"EGAM4JetTPThinningTool",
219 StreamName=streamName,
220 JetKey=
"AntiKt4EMPFlowJets",
221 InDetTrackParticlesKey=
"InDetTrackParticles",
224 acc.addPublicTool(EGAM4JetTPThinningTool)
225 thinningTools.append(EGAM4JetTPThinningTool)
228 if TrackThinningKeepMuonTracks:
229 EGAM4MuonTPThinningTool = acc.getPrimaryAndMerge(
232 name=
"EGAM4MuonTPThinningTool",
233 StreamName=streamName,
235 InDetTrackParticlesKey=
"InDetTrackParticles",
238 thinningTools.append(EGAM4MuonTPThinningTool)
241 if TrackThinningKeepTauTracks:
242 EGAM4TauTPThinningTool = acc.getPrimaryAndMerge(
245 name=
"EGAM4TauTPThinningTool",
246 StreamName=streamName,
249 InDetTrackParticlesKey=
"InDetTrackParticles",
250 DoTauTracksThinning=
True,
251 TauTracksKey=
"TauTracks",
254 thinningTools.append(EGAM4TauTPThinningTool)
257 thinning_expression =
" && ".
join(
259 "(InDetTrackParticles.DFCommonTightPrimary)",
260 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
261 "(InDetTrackParticles.pt>10*GeV)",
264 if TrackThinningKeepPVTracks:
265 EGAM4TPThinningTool = acc.getPrimaryAndMerge(
268 name=
"EGAM4TPThinningTool",
269 StreamName=streamName,
270 SelectionString=thinning_expression,
271 InDetTrackParticlesKey=
"InDetTrackParticles",
274 thinningTools.append(EGAM4TPThinningTool)
278 acc.addPublicTool(skimmingTool)
282 CompFactory.DerivationFramework.DerivationKernel(
284 SkimmingTools=[skimmingTool],
285 AugmentationTools=augmentationTools,
286 ThinningTools=thinningTools,
302 from DerivationFrameworkPhys.TriggerListsHelper
import TriggerListsHelper
304 EGAM4TriggerListsHelper = TriggerListsHelper(flags)
311 StreamName=
"StreamDAOD_EGAM4",
312 TriggerListsHelper=EGAM4TriggerListsHelper,
317 from IsolationAlgs.DerivationTrackIsoConfig
import DerivationTrackIsoCfg
321 flags, object_types=(
"Photons",), ptCuts=(500, 1000), postfix=
"Extra"
326 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
327 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
328 from DerivationFrameworkCore.SlimmingHelper
import SlimmingHelper
331 "EGAM4SlimmingHelper",
332 NamesAndTypes=flags.Input.TypedCollections,
341 EGAM4SlimmingHelper.AllVariables = [
349 if flags.Trigger.EDMVersion == 2:
351 elif flags.Trigger.EDMVersion == 3:
355 EGAM4SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
356 EGAM4SlimmingHelper.AllVariables += ExtraContainersPhotonTrigger[MenuType]
357 EGAM4SlimmingHelper.AllVariables += ExtraContainersMuonTrigger[MenuType]
358 if not flags.Input.isMC:
359 EGAM4SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly[MenuType]
363 EGAM4SlimmingHelper.AllVariables += [
367 "egammaTruthParticles",
368 "MuonTruthParticles",
379 EGAM4SlimmingHelper.SmartCollections = [
385 "InDetTrackParticles",
386 "AntiKt4EMPFlowJets",
387 "BTagging_AntiKt4EMPFlow",
388 "MET_Baseline_AntiKt4EMPFlow",
391 EGAM4SlimmingHelper.SmartCollections += [
393 "AntiKt4TruthDressedWZJets",
395 if flags.Derivation.Egamma.addHLTJets:
396 EGAM4SlimmingHelper.SmartCollections += [
397 "HLT_AntiKt4EMPFlowJets_subresjesgscIS_ftf",
403 EGAM4SlimmingHelper.ExtraVariables += [
"Electrons.Loose.Medium.Tight"]
406 EGAM4SlimmingHelper.ExtraVariables += [
407 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
411 EGAM4SlimmingHelper.ExtraVariables += [
412 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
413 "GSFConversionVertices.trackParticleLinks",
417 EGAM4SlimmingHelper.ExtraVariables += [
"PrimaryVertices.x.y.sumPt2"]
420 EGAM4SlimmingHelper.ExtraVariables += [
421 "TopoClusterIsoCentralEventShape.Density",
422 "TopoClusterIsoForwardEventShape.Density",
423 "NeutralParticleFlowIsoCentralEventShape.Density",
424 "NeutralParticleFlowIsoForwardEventShape.Density",
428 EGAM4SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent
429 EGAM4SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent
433 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
435 getClusterEnergyPerLayerDecorations,
439 print(
"EGAM4 gain decorations: ", gainDecorations)
440 EGAM4SlimmingHelper.ExtraVariables.extend(gainDecorations)
442 print(
"EGAM4 cluster energy decorations: ", clusterEnergyDecorations)
443 EGAM4SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
447 EGAM4SlimmingHelper.ExtraVariables += [
448 "Electrons.truthOrigin.truthType.truthParticleLink"
452 if flags.Derivation.Egamma.doEventInfoSlimming:
453 EGAM4SlimmingHelper.SmartCollections.append(
"EventInfo")
455 EGAM4SlimmingHelper.AllVariables += [
"EventInfo"]
458 EGAM4SlimmingHelper.IncludeEGammaTriggerContent =
True
459 EGAM4SlimmingHelper.IncludeMuonTriggerContent =
True
463 if flags.Trigger.EDMVersion == 2:
464 from DerivationFrameworkPhys.TriggerMatchingCommonConfig
import AddRun2TriggerMatchingToSlimmingHelper
466 OutputContainerPrefix =
"TrigMatch_",
467 TriggerList = EGAM4TriggerListsHelper.Run2TriggerNamesNoTau)
469 if flags.Trigger.EDMVersion == 3
or (flags.Trigger.EDMVersion == 2
and flags.Trigger.doEDMVersionConversion):
470 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig
import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
474 EGAM4SlimmingHelper.StaticContent = [
475 "CaloCellContainer#AllCalo",
476 "CaloClusterCellLinkContainer#egammaClusters_links",
479 EGAM4ItemList = EGAM4SlimmingHelper.GetItemList()
484 ItemList=EGAM4ItemList,
485 AcceptAlgs=[
"EGAM4Kernel"],
492 AcceptAlgs=[
"EGAM4Kernel"],
494 MetadataCategory.CutFlowMetaData,
495 MetadataCategory.TruthMetaData,