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 (
20 ExtraContainersTrigger,
21 ExtraContainersElectronTrigger,
27 """Configure the EGAM2 skimming tool"""
32 "(count(EGAM2_DiElectronMass1 > 1.0*GeV && "
33 +
"EGAM2_DiElectronMass1 < 5.0*GeV)>=1)"
36 "(count(EGAM2_DiElectronMass2 > 1.0*GeV && "
37 +
"EGAM2_DiElectronMass2 < 6.0*GeV)>=1)"
39 expression = expression_calib +
" || " + expression_TP
40 print(
"EGAM2 offline skimming expression: ", expression)
42 EGAM2_OfflineSkimmingTool = CompFactory.DerivationFramework.xAODStringSkimmingTool(
43 name=
"EGAM2_OfflineSkimmingTool", expression=expression
48 if flags.Trigger.EDMVersion == 2:
50 elif flags.Trigger.EDMVersion == 3:
54 triggers = JPsiTriggers[MenuType]
55 print(
"EGAM2 trigger skimming list (OR): ", triggers)
57 EGAM2_TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(
58 name=
"EGAM2_TriggerSkimmingTool", TriggerListOR=triggers
62 print(
"EGAM2 skimming is logical OR of previous selections")
63 EGAM2_SkimmingTool = CompFactory.DerivationFramework.FilterCombinationOR(
64 name=
"EGAM2_SkimmingTool",
65 FilterList=[EGAM2_OfflineSkimmingTool, EGAM2_TriggerSkimmingTool],
68 acc.addPublicTool(EGAM2_OfflineSkimmingTool)
69 acc.addPublicTool(EGAM2_TriggerSkimmingTool)
70 acc.addPublicTool(EGAM2_SkimmingTool, primary=
True)
76 """Configure the EGAM2 ee invariant mass augmentation tool 1"""
86 electronPtRequirement =
"(Electrons.pt > 4.5*GeV)"
87 electronQualityRequirement =
"(Electrons.DFCommonElectronsLHMedium)"
89 "(" + electronQualityRequirement +
"&&" + electronPtRequirement +
")"
93 CompFactory.DerivationFramework.EGInvariantMassTool(
94 name=
"EGAM2_JpsieeMassTool1",
95 Object1Requirements=requirement_el,
96 Object2Requirements=requirement_el,
97 StoreGateEntryName=
"EGAM2_DiElectronMass1",
98 Mass1Hypothesis=0.511 * MeV,
99 Mass2Hypothesis=0.511 * MeV,
100 Container1Name=
"Electrons",
101 Container2Name=
"Electrons",
103 DoTransverseMass=
False,
112 """Configure the EGAM2 ee invariant mass augmentation tool 2"""
126 requirement_el_tag =
" && ".
join(
127 [
"(Electrons.DFCommonElectronsLHTight)",
"(Electrons.pt > 4.5*GeV)"]
129 requirement_el_probe =
"Electrons.pt > 4.5*GeV"
132 CompFactory.DerivationFramework.EGInvariantMassTool(
133 name=
"EGAM2_JpsieeMassTool2",
134 Object1Requirements=requirement_el_tag,
135 Object2Requirements=requirement_el_probe,
136 StoreGateEntryName=
"EGAM2_DiElectronMass2",
137 Mass1Hypothesis=0.511 * MeV,
138 Mass2Hypothesis=0.511 * MeV,
139 Container1Name=
"Electrons",
140 Container2Name=
"Electrons",
142 DoTransverseMass=
False,
151 """Configure the derivation framework driving algorithm (kernel)
156 from DerivationFrameworkPhys.PhysCommonConfig
import PhysCommonAugmentationsCfg
160 flags, TriggerListsHelper=kwargs[
"TriggerListsHelper"]
165 augmentationTools = []
171 acc.addPublicTool(EGAM2JpsieeMassTool1)
172 augmentationTools.append(EGAM2JpsieeMassTool1)
175 acc.addPublicTool(EGAM2JpsieeMassTool2)
176 augmentationTools.append(EGAM2JpsieeMassTool2)
181 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
182 CaloDecoratorKernelCfg,
189 streamName = kwargs[
"StreamName"]
192 if flags.Derivation.Egamma.doTrackThinning:
193 from DerivationFrameworkInDet.InDetToolsConfig
import (
194 TrackParticleThinningCfg,
195 MuonTrackParticleThinningCfg,
196 TauTrackParticleThinningCfg,
199 TrackThinningKeepElectronTracks =
True
200 TrackThinningKeepPhotonTracks =
True
201 TrackThinningKeepAllElectronTracks =
False
202 TrackThinningKeepJetTracks =
False
203 TrackThinningKeepMuonTracks =
False
204 TrackThinningKeepTauTracks =
False
205 TrackThinningKeepPVTracks =
False
208 if TrackThinningKeepElectronTracks:
209 EGAM2ElectronTPThinningTool = (
210 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
211 name=
"EGAM2ElectronTPThinningTool",
212 StreamName=streamName,
214 GSFTrackParticlesKey=
"GSFTrackParticles",
215 InDetTrackParticlesKey=
"InDetTrackParticles",
216 SelectionString=
"Electrons.pt > 0*GeV",
221 acc.addPublicTool(EGAM2ElectronTPThinningTool)
222 thinningTools.append(EGAM2ElectronTPThinningTool)
226 if TrackThinningKeepAllElectronTracks:
227 EGAM2ElectronTPThinningTool2 = (
228 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
229 name=
"EGAM2ElectronTPThinningTool2",
230 StreamName=streamName,
232 GSFTrackParticlesKey=
"GSFTrackParticles",
233 InDetTrackParticlesKey=
"InDetTrackParticles",
234 SelectionString=
"Electrons.pt > 4*GeV",
239 acc.addPublicTool(EGAM2ElectronTPThinningTool2)
240 thinningTools.append(EGAM2ElectronTPThinningTool2)
243 if TrackThinningKeepPhotonTracks:
244 EGAM2PhotonTPThinningTool = (
245 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
246 name=
"EGAM2PhotonTPThinningTool",
247 StreamName=streamName,
249 GSFTrackParticlesKey=
"GSFTrackParticles",
250 InDetTrackParticlesKey=
"InDetTrackParticles",
251 GSFConversionVerticesKey=
"GSFConversionVertices",
252 SelectionString=
"Photons.pt > 0*GeV",
257 acc.addPublicTool(EGAM2PhotonTPThinningTool)
258 thinningTools.append(EGAM2PhotonTPThinningTool)
261 if TrackThinningKeepJetTracks:
262 EGAM2JetTPThinningTool = (
263 CompFactory.DerivationFramework.JetTrackParticleThinning(
264 name=
"EGAM2JetTPThinningTool",
265 StreamName=streamName,
266 JetKey=
"AntiKt4EMPFlowJets",
267 InDetTrackParticlesKey=
"InDetTrackParticles",
270 acc.addPublicTool(EGAM2JetTPThinningTool)
271 thinningTools.append(EGAM2JetTPThinningTool)
274 if TrackThinningKeepMuonTracks:
275 EGAM2MuonTPThinningTool = acc.getPrimaryAndMerge(
278 name=
"EGAM2MuonTPThinningTool",
279 StreamName=streamName,
281 InDetTrackParticlesKey=
"InDetTrackParticles",
284 thinningTools.append(EGAM2MuonTPThinningTool)
287 if TrackThinningKeepTauTracks:
288 EGAM2TauTPThinningTool = acc.getPrimaryAndMerge(
291 name=
"EGAM2TauTPThinningTool",
292 StreamName=streamName,
295 InDetTrackParticlesKey=
"InDetTrackParticles",
296 DoTauTracksThinning=
True,
297 TauTracksKey=
"TauTracks",
300 thinningTools.append(EGAM2TauTPThinningTool)
303 thinning_expression =
" && ".
join(
305 "(InDetTrackParticles.DFCommonTightPrimary)",
306 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
307 "(InDetTrackParticles.pt > 10*GeV)",
310 if TrackThinningKeepPVTracks:
311 EGAM2TPThinningTool = acc.getPrimaryAndMerge(
314 name=
"EGAM2TPThinningTool",
315 StreamName=streamName,
316 SelectionString=thinning_expression,
317 InDetTrackParticlesKey=
"InDetTrackParticles",
320 thinningTools.append(EGAM2TPThinningTool)
327 CompFactory.DerivationFramework.DerivationKernel(
329 SkimmingTools=[skimmingTool],
330 AugmentationTools=augmentationTools,
331 ThinningTools=thinningTools,
348 from DerivationFrameworkPhys.TriggerListsHelper
import TriggerListsHelper
350 EGAM2TriggerListsHelper = TriggerListsHelper(flags)
357 StreamName=
"StreamDAOD_EGAM2",
358 TriggerListsHelper=EGAM2TriggerListsHelper,
363 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
364 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
365 from DerivationFrameworkCore.SlimmingHelper
import SlimmingHelper
368 "EGAM2SlimmingHelper",
369 NamesAndTypes=flags.Input.TypedCollections,
378 EGAM2SlimmingHelper.AllVariables = [
386 if flags.Trigger.EDMVersion == 2:
388 elif flags.Trigger.EDMVersion == 3:
392 EGAM2SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
393 EGAM2SlimmingHelper.AllVariables += ExtraContainersElectronTrigger[MenuType]
397 EGAM2SlimmingHelper.AllVariables += [
401 "egammaTruthParticles",
414 EGAM2SlimmingHelper.SmartCollections = [
419 "InDetTrackParticles",
421 "AntiKt4EMPFlowJets",
422 "MET_Baseline_AntiKt4EMPFlow",
423 "BTagging_AntiKt4EMPFlow",
426 EGAM2SlimmingHelper.SmartCollections += [
428 "AntiKt4TruthDressedWZJets",
434 EGAM2SlimmingHelper.ExtraVariables += [
435 "Muons.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"
439 EGAM2SlimmingHelper.ExtraVariables += [
440 "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
441 "GSFConversionVertices.trackParticleLinks",
445 EGAM2SlimmingHelper.ExtraVariables += [
"PrimaryVertices.x.y.sumPt2"]
448 EGAM2SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
451 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig
import (
453 getClusterEnergyPerLayerDecorations,
457 print(
"EGAM2 gain decorations: ", gainDecorations)
458 EGAM2SlimmingHelper.ExtraVariables.extend(gainDecorations)
460 print(
"EGAM2 cluster energy decorations: ", clusterEnergyDecorations)
461 EGAM2SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
464 EGAM2SlimmingHelper.ExtraVariables += [
465 "TopoClusterIsoCentralEventShape.Density",
466 "TopoClusterIsoForwardEventShape.Density",
467 "NeutralParticleFlowIsoCentralEventShape.Density",
468 "NeutralParticleFlowIsoForwardEventShape.Density",
473 EGAM2SlimmingHelper.ExtraVariables += [
474 "MuonTruthParticles.e.px.py.pz.status.pdgId.truthOrigin.truthType"
477 EGAM2SlimmingHelper.ExtraVariables += [
478 "Photons.truthOrigin.truthType.truthParticleLink"
482 if flags.Derivation.Egamma.doEventInfoSlimming:
483 EGAM2SlimmingHelper.SmartCollections.append(
"EventInfo")
485 EGAM2SlimmingHelper.AllVariables += [
"EventInfo"]
488 EGAM2SlimmingHelper.IncludeEGammaTriggerContent =
True
492 if flags.Trigger.EDMVersion == 2:
493 from DerivationFrameworkPhys.TriggerMatchingCommonConfig
import AddRun2TriggerMatchingToSlimmingHelper
495 OutputContainerPrefix =
"TrigMatch_",
496 TriggerList = EGAM2TriggerListsHelper.Run2TriggerNamesNoTau)
501 from DerivationFrameworkPhys.TriggerMatchingCommonConfig
import (
502 TriggerMatchingCommonRun2Cfg
504 EGAM2TrigMatchList = [
505 "HLT_e5_lhtight_nod0",
506 "HLT_e9_lhtight_nod0",
507 "HLT_e14_lhtight_nod0",
511 name=
"EGAM2TrigMatch",
512 OutputContainerPrefix=
"TrigMatch_",
513 ChainNames=EGAM2TrigMatchList)
516 SlimmingHelper=EGAM2SlimmingHelper,
517 OutputContainerPrefix=
"TrigMatch_",
518 TriggerList=EGAM2TrigMatchList
522 if flags.Trigger.EDMVersion == 3
or (flags.Trigger.EDMVersion == 2
and flags.Trigger.doEDMVersionConversion):
523 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig
import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
527 EGAM2ItemList = EGAM2SlimmingHelper.GetItemList()
532 ItemList=EGAM2ItemList,
533 AcceptAlgs=[
"EGAM2Kernel"],
540 AcceptAlgs=[
"EGAM2Kernel"],
542 MetadataCategory.CutFlowMetaData,
543 MetadataCategory.TruthMetaData,