22 '''Configure the STDM7 trigger skimming tool'''
23 acc = ComponentAccumulator()
25 TriggerAPI.setConfigFlags(flags)
27 if flags.Trigger.EDMVersion <= 2:
36 allperiods = TriggerPeriod.y2015 | TriggerPeriod.y2016 | TriggerPeriod.y2017 | TriggerPeriod.y2018 | TriggerPeriod.future2e34
37 trig_el = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.el, livefraction=0.8)
38 trig_mu = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.mu, livefraction=0.8)
39 trig_tau = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.tau, livefraction=0.8)
41 trig_em = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.el, additionalTriggerType=TriggerType.mu, livefraction=0.8)
42 trig_et = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.el, additionalTriggerType=TriggerType.tau, livefraction=0.8)
43 trig_mt = TriggerAPI.getLowestUnprescaledAnyPeriod(allperiods, triggerType=TriggerType.mu, additionalTriggerType=TriggerType.tau, livefraction=0.8)
46 extra_file_notau = read_trig_list_file(
"DerivationFrameworkPhys/run2ExtraMatchingTriggers.txt")
47 extra_file_tau = read_trig_list_file(
"DerivationFrameworkPhys/run2ExtraMatchingTauTriggers.txt")
50 extra_flag_notau, extra_flag_tau = read_trig_list_flags(flags)
53 trigger_names = list(
set(trig_el+trig_mu+trig_tau+trig_em+trig_et+trig_mt+extra_file_notau+extra_file_tau+extra_flag_notau+extra_flag_tau))
57 session = getTapisSession(flags)
58 api_trigger_names =
set()
59 api_trigger_names = session.getLowestUnprescaled(triggerType=TriggerType.el, livefraction=0.8).union(api_trigger_names)
60 api_trigger_names = session.getLowestUnprescaled(triggerType=TriggerType.mu, livefraction=0.8).union(api_trigger_names)
61 api_trigger_names = session.getLowestUnprescaled(triggerType=TriggerType.tau, livefraction=0.8).union(api_trigger_names)
63 api_trigger_names = session.getLowestUnprescaled(triggerType=[TriggerType.el, TriggerType.mu], livefraction=0.8).union(api_trigger_names)
64 api_trigger_names = session.getLowestUnprescaled(triggerType=[TriggerType.el, TriggerType.tau], livefraction=0.8).union(api_trigger_names)
65 api_trigger_names = session.getLowestUnprescaled(triggerType=[TriggerType.mu, TriggerType.tau], livefraction=0.8).union(api_trigger_names)
68 extra_flag_notau, extra_flag_tau = read_trig_list_flags(flags)
69 extra_flag = extra_flag_notau + extra_flag_tau
72 extra_file = read_trig_list_file(
"DerivationFrameworkPhys/run3ExtraMatchingTriggers.txt")
75 trigger_names = list(
set(extra_file + extra_flag + list(api_trigger_names)))
77 STDM7TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(name =
"STDM7TriggerSkimmingTool",
79 TriggerListOR = trigger_names,
81 acc.addPublicTool(STDM7TriggerSkimmingTool,primary=
True)
85 '''Configure the STDM7 string skimming tool'''
86 acc = ComponentAccumulator()
89 muonsRequirements =
'(Muons.pt >= 10.*GeV) && (abs(Muons.eta) < 2.6) && (Muons.DFCommonMuonPassPreselection) && (Muons.DFCommonMuonPassIDCuts)'
90 electronsRequirements =
'(Electrons.pt >= 15.*GeV) && (abs(Electrons.eta) < 2.6) && ((Electrons.DFCommonElectronsLHLoose) || (Electrons.DFCommonElectronsDNNLoose))'
91 tausRequirements =
'(TauJets.pt >= 20.*GeV) && (abs(TauJets.eta) < 2.6) && ((TauJets.DFTauRNNLoose || TauJets.DFTauGNTauLoose))'
93 chargedParticleRequirements =
'(TruthParticles.pt >= 500) && (TruthParticles.isGenStable)' \
94 '&& (TruthParticles.charge != 0)' \
95 '&& (TruthParticles.theta > 0.163803) && (TruthParticles.theta < 2.97778)' \
96 '&& (TruthParticles.HSBool)'
99 muonOnlySelection =
'count('+muonsRequirements+
') >=2'
100 electronOnlySelection =
'count('+electronsRequirements+
') >= 2'
101 tauOnlySelection =
'count('+tausRequirements+
') >= 2'
102 electronMuonSelection =
'(count('+electronsRequirements+
') + count('+muonsRequirements+
')) >= 2'
103 electronTauSelection =
'(count('+electronsRequirements+
') + count('+tausRequirements+
')) >= 2'
104 muonTauSelection =
'(count('+muonsRequirements+
') + count('+tausRequirements+
')) >= 2'
108 if filterVal > -1
and flags.Input.isMC :
109 chargedParticleSelection =
'count('+chargedParticleRequirements+
') < '+str(filterVal)
110 offlineExpression =
'(('+muonOnlySelection+
' || '+electronOnlySelection+
' || '+tauOnlySelection+
' || '+electronMuonSelection+
' || '+electronTauSelection+
' || '+muonTauSelection+
')' \
111 '&& ('+chargedParticleSelection+
'))'
113 offlineExpression =
'('+muonOnlySelection+
' || '+electronOnlySelection+
' || '+tauOnlySelection+
' || '+electronMuonSelection+
' || '+electronTauSelection+
' || '+muonTauSelection+
')'
115 from DerivationFrameworkTools.DerivationFrameworkToolsConfig
import xAODStringSkimmingToolCfg
116 STDM7StringSkimmingTool = acc.getPrimaryAndMerge(xAODStringSkimmingToolCfg(
117 flags, name =
"STDM7StringSkimmingTool", expression = offlineExpression))
118 acc.addPublicTool(STDM7StringSkimmingTool, primary=
True)
124 """Configure the derivation framework driving algorithm (kernel) for STDM7"""
125 acc = ComponentAccumulator()
128 from DerivationFrameworkPhys.PhysCommonConfig
import PhysCommonAugmentationsCfg
129 acc.merge(PhysCommonAugmentationsCfg(
131 TriggerListsHelper = kwargs[
'TriggerListsHelper'],
134 from DerivationFrameworkTau.TauCommonConfig
import AddTauAugmentationCfg
135 acc.merge(AddTauAugmentationCfg(flags, wp=
"GNTauLoose"))
138 from LeptonTaggers.LeptonTaggersConfig
import DecoratePLITAlgsCfg
139 acc.merge(DecoratePLITAlgsCfg(flags))
144 if flags.Trigger.EDMVersion >= 0:
148 skimmingTools = [ acc.addPublicTool(CompFactory.DerivationFramework.FilterCombinationAND(
149 name=
"STDM7SkimmingTool",
150 FilterList = filterList,
153 nametag = name.replace(
'Kernel',
'')
154 thinningToolsArgs = {
155 'TauJetThinningToolName' : nametag+
"TauJetThinningTool",
159 from DerivationFrameworkPhys.PhysCommonThinningConfig
import PhysCommonThinningCfg
160 acc.merge(PhysCommonThinningCfg(flags, StreamName = kwargs[
'StreamName'], **thinningToolsArgs))
164 from DerivationFrameworkInDet.InDetToolsConfig
import TrackParticleThinningCfg
165 acc.merge(TrackParticleThinningCfg(flags,
166 name =
'STDM7TrackParticleThinningTool',
167 StreamName = kwargs[
'StreamName'],
168 SelectionString =
"InDetTrackParticles.pt > -1",
169 InDetTrackParticlesKey =
"InDetTrackParticles"))
172 for key
in thinningToolsArgs:
173 thinningTools.append(acc.getPublicTool(thinningToolsArgs[key]))
174 thinningTools.append(acc.getPublicTool(
'STDM7TrackParticleThinningTool'))
177 DerivationKernel = CompFactory.DerivationFramework.DerivationKernel
178 acc.addEventAlgo(DerivationKernel(name,
179 ThinningTools = thinningTools,
180 SkimmingTools = skimmingTools))
183def STDM7CoreCfg(flags, name_tag='STDM7', StreamName='StreamDAOD_STDM7', TriggerListsHelper=None):
185 if TriggerListsHelper
is None:
186 from DerivationFrameworkPhys.TriggerListsHelper
import TriggerListsHelper
187 TriggerListsHelper = TriggerListsHelper(flags)
189 acc = ComponentAccumulator()
194 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
195 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
196 from DerivationFrameworkCore.SlimmingHelper
import SlimmingHelper
198 STDM7SlimmingHelper =
SlimmingHelper(name_tag+
"SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
199 STDM7SlimmingHelper.SmartCollections = [
"EventInfo",
204 "InDetTrackParticles",
206 "AntiKt4EMPFlowJets",
207 "MET_Baseline_AntiKt4EMTopo",
208 "MET_Baseline_AntiKt4EMPFlow",
212 excludedVertexAuxData =
"-vxTrackAtVertex.-MvfFitInfo.-isInitialized.-VTAV"
214 StaticContent += [
"xAOD::VertexContainer#SoftBVrtClusterTool_Tight_Vertices"]
215 StaticContent += [
"xAOD::VertexAuxContainer#SoftBVrtClusterTool_Tight_VerticesAux." + excludedVertexAuxData]
216 StaticContent += [
"xAOD::VertexContainer#SoftBVrtClusterTool_Medium_Vertices"]
217 StaticContent += [
"xAOD::VertexAuxContainer#SoftBVrtClusterTool_Medium_VerticesAux." + excludedVertexAuxData]
218 StaticContent += [
"xAOD::VertexContainer#SoftBVrtClusterTool_Loose_Vertices"]
219 StaticContent += [
"xAOD::VertexAuxContainer#SoftBVrtClusterTool_Loose_VerticesAux." + excludedVertexAuxData]
221 STDM7SlimmingHelper.StaticContent = StaticContent
224 from LeptonTaggers.LeptonTaggersConfig
import GetExtraPLITVariablesForDxAOD
225 STDM7SlimmingHelper.ExtraVariables += GetExtraPLITVariablesForDxAOD()
230 from DerivationFrameworkMCTruth.MCTruthCommonConfig
import addTruth3ContentToSlimmerTool
231 addTruth3ContentToSlimmerTool(STDM7SlimmingHelper)
232 STDM7SlimmingHelper.AllVariables += [
'TruthLHEParticles',
'TruthHFWithDecayParticles',
'TruthHFWithDecayVertices',
'TruthCharm',
'TruthPileupParticles',
'InTimeAntiKt4TruthJets',
'OutOfTimeAntiKt4TruthJets']
233 STDM7SlimmingHelper.ExtraVariables += [
"Electrons.TruthLink",
236 "TruthPrimaryVertices.t.x.y.z",
237 "EventInfo.hardScatterVertexLink.timeStampNSOffset",
238 "InDetTrackParticles.TTVA_AMVFVertices.TTVA_AMVFWeights.eProbabilityHT.numberOfTRTHits.numberOfTRTOutliers",
239 "TauJets.dRmax.etOverPtLeadTrk",
242 from DerivationFrameworkMCTruth.MCTruthCommonConfig
import AddTauAndDownstreamParticlesCfg
243 acc.merge(AddTauAndDownstreamParticlesCfg(flags))
244 STDM7SlimmingHelper.AllVariables += [
'TruthTausWithDecayParticles',
'TruthTausWithDecayVertices']
248 STDM7SlimmingHelper.AllVariables = [
"AFPSiHitContainer",
249 "AFPToFHitContainer",
250 "AFPSiHitsClusterContainer",
252 "AFPToFTrackContainer",
253 "AFPProtonContainer",
254 "AFPVertexContainer",
258 STDM7SlimmingHelper.IncludeTriggerNavigation =
False
259 STDM7SlimmingHelper.IncludeJetTriggerContent =
False
260 STDM7SlimmingHelper.IncludeMuonTriggerContent =
False
261 STDM7SlimmingHelper.IncludeEGammaTriggerContent =
False
262 STDM7SlimmingHelper.IncludeTauTriggerContent =
False
263 STDM7SlimmingHelper.IncludeEtMissTriggerContent =
False
264 STDM7SlimmingHelper.IncludeBJetTriggerContent =
False
265 STDM7SlimmingHelper.IncludeBPhysTriggerContent =
False
266 STDM7SlimmingHelper.IncludeMinBiasTriggerContent =
False
268 STDM7SlimmingHelper.IncludeBJetTriggerByYearContent =
False
272 if flags.Trigger.EDMVersion == 2:
273 from DerivationFrameworkPhys.TriggerMatchingCommonConfig
import AddRun2TriggerMatchingToSlimmingHelper
274 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = STDM7SlimmingHelper,
275 OutputContainerPrefix =
"TrigMatch_",
276 TriggerList = TriggerListsHelper.Run2TriggerNamesTau)
277 AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = STDM7SlimmingHelper,
278 OutputContainerPrefix =
"TrigMatch_",
279 TriggerList = TriggerListsHelper.Run2TriggerNamesNoTau)
281 if flags.Trigger.EDMVersion == 3
or (flags.Trigger.EDMVersion == 2
and flags.Trigger.doEDMVersionConversion):
282 from TrigNavSlimmingMT.TrigNavSlimmingMTConfig
import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
283 AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(STDM7SlimmingHelper)
286 STDM7ItemList = STDM7SlimmingHelper.GetItemList()
287 acc.merge(OutputStreamCfg(flags,
"DAOD_"+name_tag, ItemList=STDM7ItemList, AcceptAlgs=[name_tag+
"Kernel"]))
288 acc.merge(SetupMetaDataForStreamCfg(flags,
"DAOD_"+name_tag, AcceptAlgs=[name_tag+
"Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData, MetadataCategory.TruthMetaData]))