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