114def AddEventCleanFlagsCfg(ConfigFlags, workingPoints = ['Loose', 'Tight', 'LooseLLP']):
115 """Add event cleaning flags"""
116
117 acc = ComponentAccumulator()
118 acc.merge(AddJvtDecorationAlgCfg(ConfigFlags, algName="JvtPassDecorAlg_EMTopo", jetContainer='AntiKt4EMTopo'))
119 acc.merge(AddJvtDecorationAlgCfg(ConfigFlags, algName="JvtPassDecorAlg", jetContainer='AntiKt4EMPFlow'))
120
121 from DerivationFrameworkTau.TauCommonConfig import AddTauAugmentationCfg
122 acc.merge(AddTauAugmentationCfg(ConfigFlags, wp="GNTauLoose"))
123 acc.addSequence(CompFactory.AthSequencer('EventCleanSeq', Sequential=True))
124
125
126 from AssociationUtils.AssociationUtilsConfig import OverlapRemovalToolCfg
127 inputLabel_legacy = 'selected_eventClean_EMTopo'
128 outputLabel_legacy = 'DFCommonJets_passOR_EMTopo'
129 bJetLabel = ''
130 tauLabel = 'DFTauGNTauLoose'
131 orTool_legacy = acc.popToolsAndMerge(OverlapRemovalToolCfg(ConfigFlags,inputLabel=inputLabel_legacy,outputLabel=outputLabel_legacy,bJetLabel=bJetLabel))
132 algOR_legacy = CompFactory.OverlapRemovalGenUseAlg('OverlapRemovalGenUseAlg_EMTopo',
133 JetKey="AntiKt4EMTopoJets",
134 SelectionLabel=inputLabel_legacy,
135 OverlapLabel=outputLabel_legacy,
136 OverlapRemovalTool=orTool_legacy,
137 TauLabel=tauLabel,
138 BJetLabel=bJetLabel
139 )
140 acc.addEventAlgo(algOR_legacy, 'EventCleanSeq')
141
142
143 inputLabel = 'selected_eventClean_EMPFlow'
144 outputLabel = 'DFCommonJets_passOR_EMPFlow'
145 orTool = acc.popToolsAndMerge(OverlapRemovalToolCfg(ConfigFlags,inputLabel=inputLabel,outputLabel=outputLabel,bJetLabel=bJetLabel))
146 algOR = CompFactory.OverlapRemovalGenUseAlg('OverlapRemovalGenUseAlg',
147 SelectionLabel=inputLabel,
148 OverlapLabel=outputLabel,
149 OverlapRemovalTool=orTool,
150 TauLabel=tauLabel,
151 BJetLabel=bJetLabel)
152 acc.addEventAlgo(algOR, 'EventCleanSeq')
153
154 CommonAugmentation = CompFactory.DerivationFramework.CommonAugmentation
155 from DerivationFrameworkMuons.MuonsToolsConfig import MuonJetDrToolCfg
156 muonJetDrTool = acc.getPrimaryAndMerge(MuonJetDrToolCfg(ConfigFlags, "MuonJetDrTool"))
157 acc.addEventAlgo(CommonAugmentation("DFCommonMuonsKernel2", AugmentationTools = [muonJetDrTool]), 'EventCleanSeq')
158
159 from JetSelectorTools.JetSelectorToolsConfig import EventCleaningToolCfg,JetCleaningToolCfg
160
161 supportedWPs = ['Loose', 'Tight', 'LooseLLP', 'VeryLooseLLP', 'SuperLooseLLP']
162 prefix = "DFCommonJets_"
163 evt_lvl_suppWPs_PFlow = ['LooseBad', 'TightBad']
164
165 for wp in workingPoints:
166 if wp not in supportedWPs:
167 continue
168
169 cleaningLevel = wp + 'Bad'
170
171 if 'LLP' in wp:
172 cleaningLevel = wp.replace('LLP', 'BadLLP')
173
174
175 doEvent_PFlow=False
176 for evt_swp in evt_lvl_suppWPs_PFlow:
177 if evt_swp == cleaningLevel:
178 doEvent_PFlow=True
179 break
180
181 doEvent_EMTopo=False
182 if 'Loose' in cleaningLevel:
183 doEvent_EMTopo=True
184
185
186 if doEvent_EMTopo:
187 jetCleaningTool_legacy = acc.popToolsAndMerge(JetCleaningToolCfg(
188 ConfigFlags, 'JetCleaningTool_'+cleaningLevel+'_EMTopo',
189 'AntiKt4EMTopoJets', cleaningLevel, False))
190 acc.addPublicTool(jetCleaningTool_legacy)
191 ecTool_legacy = acc.popToolsAndMerge(EventCleaningToolCfg(
192 ConfigFlags,'EventCleaningTool_'+wp+'_EMTopo', cleaningLevel))
193 ecTool_legacy.JetCleanPrefix = prefix
194 ecTool_legacy.OrDecorator = "passOR_EMTopo"
195 ecTool_legacy.JetContainer = "AntiKt4EMTopoJets"
196 ecTool_legacy.JetCleaningTool = jetCleaningTool_legacy
197 acc.addPublicTool(ecTool_legacy)
198
199 eventCleanAlg_legacy = CompFactory.EventCleaningTestAlg('EventCleaningTestAlg_'+wp+'_EMTopo',
200 EventCleaningTool=ecTool_legacy,
201 JetCollectionName="AntiKt4EMTopoJets",
202 EventCleanPrefix=prefix,
203 CleaningLevel=cleaningLevel,
204 doEvent=True)
205 acc.addEventAlgo(eventCleanAlg_legacy, 'EventCleanSeq')
206
207
208 if doEvent_PFlow:
209 jetCleaningTool = acc.popToolsAndMerge(JetCleaningToolCfg(
210 ConfigFlags, 'JetCleaningTool_'+cleaningLevel,
211 'AntiKt4EMPFlowJets', cleaningLevel, False))
212 acc.addPublicTool(jetCleaningTool)
213
214 ecTool = acc.popToolsAndMerge(EventCleaningToolCfg(ConfigFlags,'EventCleaningTool_' + wp, cleaningLevel))
215 ecTool.JetCleanPrefix = prefix
216 ecTool.OrDecorator = "passOR_EMPFlow"
217 ecTool.JetContainer = "AntiKt4EMPFlowJets"
218 ecTool.JetCleaningTool = jetCleaningTool
219 acc.addPublicTool(ecTool)
220
221 eventCleanAlg = CompFactory.EventCleaningTestAlg('EventCleaningTestAlg_'+wp,
222 EventCleaningTool=ecTool,
223 JetCollectionName="AntiKt4EMPFlowJets",
224 EventCleanPrefix=prefix,
225 CleaningLevel=cleaningLevel,
226 doEvent=True)
227 acc.addEventAlgo(eventCleanAlg, 'EventCleanSeq')
228
229 return acc
230
231