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 (
21 ExtraContainersTrigger,
22 ExtraContainersElectronTrigger,
23 ExtraContainersTriggerDataOnly,
28 """Configure the EGAM5 skimming tool"""
33 if flags.Trigger.EDMVersion == 2:
35 elif flags.Trigger.EDMVersion == 3:
39 triggers = WTnPTriggers[MenuType]
40 print(
"EGAM5 trigger skimming list (OR): ", triggers)
42 EGAM5_TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(
43 name=
"EGAM5_TriggerSkimmingTool", TriggerListOR=triggers
47 expression2 =
"count(EGAM5_ENuTransverseMass > 40*GeV)>=1"
48 print(
"EGAM5 offline skimming expression: ", expression2)
49 EGAM5_OfflineSkimmingTool = CompFactory.DerivationFramework.xAODStringSkimmingTool(
50 name=
"EGAM5_OfflineSkimmingTool", expression=expression2
54 expression3a =
" || ".
join(
56 "HLT_e60_lhloose_xe60noL1",
60 "HLT_xe80_tc_lcw_L1XE50",
61 "HLT_xe90_mht_L1XE50",
62 "HLT_xe90_tc_lcw_wEFMu_L1XE50",
63 "HLT_xe90_mht_wEFMu_L1XE50",
66 expression3b =
"count(Electrons.pt > 14.5*GeV) >= 1"
67 expression3 =
"( " + expression3a +
" ) && ( " + expression3b +
" )"
68 print(
"EGAM5 mixed offline-online skimming expression: ", expression3)
70 EGAM5_OnlineOfflineSkimmingTool = (
71 CompFactory.DerivationFramework.xAODStringSkimmingTool(
72 name=
"EGAM5_OnlineOfflineSkimmingTool", expression=expression3
77 print(
"EGAM5 skimming is logical OR of previous selections")
78 EGAM5_SkimmingTool = CompFactory.DerivationFramework.FilterCombinationOR(
79 name=
"EGAM5_SkimmingTool",
81 EGAM5_OfflineSkimmingTool,
82 EGAM5_TriggerSkimmingTool,
83 EGAM5_OnlineOfflineSkimmingTool,
87 acc.addPublicTool(EGAM5_OfflineSkimmingTool)
88 acc.addPublicTool(EGAM5_TriggerSkimmingTool)
89 acc.addPublicTool(EGAM5_OnlineOfflineSkimmingTool)
90 acc.addPublicTool(EGAM5_SkimmingTool, primary=
True)
96 """Configure the EGAM5 enu transverse mass augmentation tool"""
104 electronPtRequirement =
"(Electrons.pt > 24.5*GeV)"
105 electronQualityRequirement =
"(Electrons.DFCommonElectronsLHTight)"
107 "(" + electronQualityRequirement +
"&&" + electronPtRequirement +
")"
111 CompFactory.DerivationFramework.EGTransverseMassTool(
112 name=
"EGAM5_enuTransverseMassTool",
113 ObjectRequirements=requirement_el,
115 StoreGateEntryName=
"EGAM5_ENuTransverseMass",
116 ObjectMassHypothesis=0.511 * MeV,
117 ObjectContainerName=
"Electrons",
118 METContainerName=
"MET_Core_AntiKt4EMPFlow",
126 """Configure the derivation framework driving algorithm (kernel)
131 from DerivationFrameworkPhys.PhysCommonConfig
import PhysCommonAugmentationsCfg
135 flags, TriggerListsHelper=kwargs[
"TriggerListsHelper"]
140 augmentationTools = []
145 EGAM5enuTransverseMassTool = acc.popToolsAndMerge(
148 acc.addPublicTool(EGAM5enuTransverseMassTool)
149 augmentationTools.append(EGAM5enuTransverseMassTool)
154 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
155 CaloDecoratorKernelCfg)
160 streamName = kwargs[
"StreamName"]
163 if flags.Derivation.Egamma.doTrackThinning:
164 from DerivationFrameworkInDet.InDetToolsConfig
import (
165 TrackParticleThinningCfg,
166 MuonTrackParticleThinningCfg,
167 TauTrackParticleThinningCfg,
170 TrackThinningKeepElectronTracks =
True
171 TrackThinningKeepPhotonTracks =
True
172 TrackThinningKeepAllElectronTracks =
False
173 TrackThinningKeepJetTracks =
False
174 TrackThinningKeepMuonTracks =
False
175 TrackThinningKeepTauTracks =
False
176 TrackThinningKeepPVTracks =
True
179 if TrackThinningKeepElectronTracks:
180 EGAM5ElectronTPThinningTool = (
181 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
182 name=
"EGAM5ElectronTPThinningTool",
183 StreamName=streamName,
185 GSFTrackParticlesKey=
"GSFTrackParticles",
186 InDetTrackParticlesKey=
"InDetTrackParticles",
187 SelectionString=
"Electrons.pt > 0*GeV",
192 acc.addPublicTool(EGAM5ElectronTPThinningTool)
193 thinningTools.append(EGAM5ElectronTPThinningTool)
197 if TrackThinningKeepAllElectronTracks:
198 EGAM5ElectronTPThinningTool2 = (
199 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
200 name=
"EGAM5ElectronTPThinningTool2",
201 StreamName=streamName,
203 GSFTrackParticlesKey=
"GSFTrackParticles",
204 InDetTrackParticlesKey=
"InDetTrackParticles",
205 SelectionString=
"Electrons.pt > 4*GeV",
210 acc.addPublicTool(EGAM5ElectronTPThinningTool2)
211 thinningTools.append(EGAM5ElectronTPThinningTool2)
214 if TrackThinningKeepPhotonTracks:
215 EGAM5PhotonTPThinningTool = (
216 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
217 name=
"EGAM5PhotonTPThinningTool",
218 StreamName=streamName,
220 GSFTrackParticlesKey=
"GSFTrackParticles",
221 InDetTrackParticlesKey=
"InDetTrackParticles",
222 GSFConversionVerticesKey=
"GSFConversionVertices",
223 SelectionString=
"Photons.pt > 0*GeV",
228 acc.addPublicTool(EGAM5PhotonTPThinningTool)
229 thinningTools.append(EGAM5PhotonTPThinningTool)
232 if TrackThinningKeepJetTracks:
233 EGAM5JetTPThinningTool = (
234 CompFactory.DerivationFramework.JetTrackParticleThinning(
235 name=
"EGAM5JetTPThinningTool",
236 StreamName=streamName,
237 JetKey=
"AntiKt4EMPFlowJets",
238 InDetTrackParticlesKey=
"InDetTrackParticles",
241 acc.addPublicTool(EGAM5JetTPThinningTool)
242 thinningTools.append(EGAM5JetTPThinningTool)
245 if TrackThinningKeepMuonTracks:
246 EGAM5MuonTPThinningTool = acc.getPrimaryAndMerge(
249 name=
"EGAM5MuonTPThinningTool",
250 StreamName=streamName,
252 InDetTrackParticlesKey=
"InDetTrackParticles",
255 thinningTools.append(EGAM5MuonTPThinningTool)
258 if TrackThinningKeepTauTracks:
259 EGAM5TauTPThinningTool = acc.getPrimaryAndMerge(
262 name=
"EGAM5TauTPThinningTool",
263 StreamName=streamName,
266 InDetTrackParticlesKey=
"InDetTrackParticles",
267 DoTauTracksThinning=
True,
268 TauTracksKey=
"TauTracks",
271 thinningTools.append(EGAM5TauTPThinningTool)
274 thinning_expression =
" && ".
join(
276 "(InDetTrackParticles.DFCommonTightPrimary)",
277 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
278 "(InDetTrackParticles.pt>10*GeV)",
281 if TrackThinningKeepPVTracks:
282 EGAM5TPThinningTool = acc.getPrimaryAndMerge(
285 name=
"EGAM5TPThinningTool",
286 StreamName=streamName,
287 SelectionString=thinning_expression,
288 InDetTrackParticlesKey=
"InDetTrackParticles",
291 thinningTools.append(EGAM5TPThinningTool)
298 CompFactory.DerivationFramework.DerivationKernel(
300 SkimmingTools=[skimmingTool],
301 AugmentationTools=augmentationTools,
302 ThinningTools=thinningTools,
319 from DerivationFrameworkPhys.TriggerListsHelper
import TriggerListsHelper
321 EGAM5TriggerListsHelper = TriggerListsHelper(flags)
328 StreamName=
"StreamDAOD_EGAM5",
329 TriggerListsHelper=EGAM5TriggerListsHelper,
334 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
335 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
336 from DerivationFrameworkCore.SlimmingHelper
import SlimmingHelper
339 "EGAM5SlimmingHelper",
340 NamesAndTypes=flags.Input.TypedCollections,
349 EGAM5SlimmingHelper.AllVariables = [
357 if flags.Trigger.EDMVersion == 2:
359 elif flags.Trigger.EDMVersion == 3:
363 EGAM5SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
364 EGAM5SlimmingHelper.AllVariables += ExtraContainersElectronTrigger[MenuType]
365 if not flags.Input.isMC:
366 EGAM5SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly[MenuType]
370 EGAM5SlimmingHelper.AllVariables += [
374 "egammaTruthParticles",
385 EGAM5SlimmingHelper.SmartCollections = [
390 "InDetTrackParticles",
392 "AntiKt4EMPFlowJets",
393 "MET_Baseline_AntiKt4EMPFlow",
394 "BTagging_AntiKt4EMPFlow",
399 EGAM5SlimmingHelper.SmartCollections += [
401 "AntiKt4TruthDressedWZJets",
407 EGAM5SlimmingHelper.ExtraVariables += [
408 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
412 EGAM5SlimmingHelper.ExtraVariables += [
413 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
414 "GSFConversionVertices.trackParticleLinks",
418 EGAM5SlimmingHelper.ExtraVariables += [
"PrimaryVertices.x.y.sumPt2"]
421 EGAM5SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
424 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
426 getClusterEnergyPerLayerDecorations,
430 print(
"EGAM5 gain decorations: ", gainDecorations)
431 EGAM5SlimmingHelper.ExtraVariables.extend(gainDecorations)
433 print(
"EGAM5 cluster energy decorations: ", clusterEnergyDecorations)
434 EGAM5SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
437 EGAM5SlimmingHelper.ExtraVariables += [
438 "TopoClusterIsoCentralEventShape.Density",
439 "TopoClusterIsoForwardEventShape.Density",
440 "NeutralParticleFlowIsoCentralEventShape.Density",
441 "NeutralParticleFlowIsoForwardEventShape.Density",
446 EGAM5SlimmingHelper.ExtraVariables += [
447 "MuonTruthParticles.e.px.py.pz.status.pdgId.truthOrigin.truthType"
450 EGAM5SlimmingHelper.ExtraVariables += [
451 "Photons.truthOrigin.truthType.truthParticleLink"
455 if flags.Derivation.Egamma.doEventInfoSlimming:
456 EGAM5SlimmingHelper.SmartCollections.append(
"EventInfo")
458 EGAM5SlimmingHelper.AllVariables += [
"EventInfo"]
461 EGAM5SlimmingHelper.IncludeEGammaTriggerContent =
True
465 if flags.Trigger.EDMVersion == 2:
466 from DerivationFrameworkPhys.TriggerMatchingCommonConfig
import AddRun2TriggerMatchingToSlimmingHelper
468 OutputContainerPrefix =
"TrigMatch_",
469 TriggerList = EGAM5TriggerListsHelper.Run2TriggerNamesNoTau)
471 if flags.Trigger.EDMVersion == 3
or (flags.Trigger.EDMVersion == 2
and flags.Trigger.doEDMVersionConversion):
472 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig
import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
475 EGAM5ItemList = EGAM5SlimmingHelper.GetItemList()
480 ItemList=EGAM5ItemList,
481 AcceptAlgs=[
"EGAM5Kernel"],
488 AcceptAlgs=[
"EGAM5Kernel"],
490 MetadataCategory.CutFlowMetaData,
491 MetadataCategory.TruthMetaData,