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