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