163def EGAM2KernelCfg(flags, name="EGAM2Kernel", **kwargs):
164 """Configure the derivation framework driving algorithm (kernel)
165 for EGAM2"""
166 acc = ComponentAccumulator()
167
168
169 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
170
171 acc.merge(
172 PhysCommonAugmentationsCfg(
173 flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
174 )
175 )
176
177
178 augmentationTools = []
179
180
181
182
183 EGAM2JpsieeMassTool1 = acc.popToolsAndMerge(EGAM2JpsieeMassTool1Cfg(flags))
184 acc.addPublicTool(EGAM2JpsieeMassTool1)
185 augmentationTools.append(EGAM2JpsieeMassTool1)
186
187 EGAM2JpsieeMassTool2 = acc.popToolsAndMerge(EGAM2JpsieeMassTool2Cfg(flags))
188 acc.addPublicTool(EGAM2JpsieeMassTool2)
189 augmentationTools.append(EGAM2JpsieeMassTool2)
190
191
192
193
194 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
195 CaloDecoratorKernelCfg,
196 )
197
198 acc.merge(CaloDecoratorKernelCfg(flags))
199
200
201 thinningTools = []
202 streamName = kwargs["StreamName"]
203
204
205 if flags.Derivation.Egamma.doTrackThinning:
206 from DerivationFrameworkInDet.InDetToolsConfig import (
207 TrackParticleThinningCfg,
208 MuonTrackParticleThinningCfg,
209 TauTrackParticleThinningCfg,
210 )
211
212 TrackThinningKeepElectronTracks = True
213 TrackThinningKeepPhotonTracks = True
214 TrackThinningKeepAllElectronTracks = False
215 TrackThinningKeepJetTracks = False
216 TrackThinningKeepMuonTracks = False
217 TrackThinningKeepTauTracks = False
218 TrackThinningKeepPVTracks = False
219
220
221 if TrackThinningKeepElectronTracks:
222 EGAM2ElectronTPThinningTool = (
223 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
224 name="EGAM2ElectronTPThinningTool",
225 StreamName=streamName,
226 SGKey="Electrons",
227 GSFTrackParticlesKey="GSFTrackParticles",
228 InDetTrackParticlesKey="InDetTrackParticles",
229 SelectionString="Electrons.pt > 0*GeV",
230 BestMatchOnly=True,
231 ConeSize=0.3,
232 )
233 )
234 acc.addPublicTool(EGAM2ElectronTPThinningTool)
235 thinningTools.append(EGAM2ElectronTPThinningTool)
236
237
238
239 if TrackThinningKeepAllElectronTracks:
240 EGAM2ElectronTPThinningTool2 = (
241 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
242 name="EGAM2ElectronTPThinningTool2",
243 StreamName=streamName,
244 SGKey="Electrons",
245 GSFTrackParticlesKey="GSFTrackParticles",
246 InDetTrackParticlesKey="InDetTrackParticles",
247 SelectionString="Electrons.pt > 4*GeV",
248 BestMatchOnly=False,
249 ConeSize=0.6,
250 )
251 )
252 acc.addPublicTool(EGAM2ElectronTPThinningTool2)
253 thinningTools.append(EGAM2ElectronTPThinningTool2)
254
255
256 if TrackThinningKeepPhotonTracks:
257 EGAM2PhotonTPThinningTool = (
258 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
259 name="EGAM2PhotonTPThinningTool",
260 StreamName=streamName,
261 SGKey="Photons",
262 GSFTrackParticlesKey="GSFTrackParticles",
263 InDetTrackParticlesKey="InDetTrackParticles",
264 GSFConversionVerticesKey="GSFConversionVertices",
265 SelectionString="Photons.pt > 0*GeV",
266 BestMatchOnly=True,
267 ConeSize=0.3,
268 )
269 )
270 acc.addPublicTool(EGAM2PhotonTPThinningTool)
271 thinningTools.append(EGAM2PhotonTPThinningTool)
272
273
274 if TrackThinningKeepJetTracks:
275 EGAM2JetTPThinningTool = (
276 CompFactory.DerivationFramework.JetTrackParticleThinning(
277 name="EGAM2JetTPThinningTool",
278 StreamName=streamName,
279 JetKey="AntiKt4EMPFlowJets",
280 InDetTrackParticlesKey="InDetTrackParticles",
281 )
282 )
283 acc.addPublicTool(EGAM2JetTPThinningTool)
284 thinningTools.append(EGAM2JetTPThinningTool)
285
286
287 if TrackThinningKeepMuonTracks:
288 EGAM2MuonTPThinningTool = acc.getPrimaryAndMerge(
289 MuonTrackParticleThinningCfg(
290 flags,
291 name="EGAM2MuonTPThinningTool",
292 StreamName=streamName,
293 MuonKey="Muons",
294 InDetTrackParticlesKey="InDetTrackParticles",
295 )
296 )
297 thinningTools.append(EGAM2MuonTPThinningTool)
298
299
300 if TrackThinningKeepTauTracks:
301 EGAM2TauTPThinningTool = acc.getPrimaryAndMerge(
302 TauTrackParticleThinningCfg(
303 flags,
304 name="EGAM2TauTPThinningTool",
305 StreamName=streamName,
306 TauKey="TauJets",
307 ConeSize=0.6,
308 InDetTrackParticlesKey="InDetTrackParticles",
309 DoTauTracksThinning=True,
310 TauTracksKey="TauTracks",
311 )
312 )
313 thinningTools.append(EGAM2TauTPThinningTool)
314
315
316 thinning_expression = " && ".join(
317 [
318 "(InDetTrackParticles.DFCommonTightPrimary)",
319 "(abs(InDetTrackParticles.DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
320 "(InDetTrackParticles.pt > 10*GeV)",
321 ]
322 )
323 if TrackThinningKeepPVTracks:
324 EGAM2TPThinningTool = acc.getPrimaryAndMerge(
325 TrackParticleThinningCfg(
326 flags,
327 name="EGAM2TPThinningTool",
328 StreamName=streamName,
329 SelectionString=thinning_expression,
330 InDetTrackParticlesKey="InDetTrackParticles",
331 )
332 )
333 thinningTools.append(EGAM2TPThinningTool)
334
335
336 skimmingTool = acc.getPrimaryAndMerge(EGAM2SkimmingToolCfg(flags))
337
338
339 acc.addEventAlgo(
340 CompFactory.DerivationFramework.DerivationKernel(
341 name,
342 SkimmingTools=[skimmingTool],
343 AugmentationTools=augmentationTools,
344 ThinningTools=thinningTools,
345 )
346 )
347
348 return acc
349
350