205def EGAM3KernelCfg(flags, name="EGAM3Kernel", **kwargs):
206 """Configure the derivation framework driving algorithm (kernel)
207 for EGAM3"""
208 acc = ComponentAccumulator()
209
210
211 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
212
213 acc.merge(
214 PhysCommonAugmentationsCfg(
215 flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
216 )
217 )
218
219
220 augmentationTools = []
221
222
223
224
225 EGAM3eeMassTool1 = acc.popToolsAndMerge(EGAM3eeMassTool1Cfg(flags))
226 acc.addPublicTool(EGAM3eeMassTool1)
227 augmentationTools.append(EGAM3eeMassTool1)
228
229 EGAM3eeMassTool2 = acc.popToolsAndMerge(EGAM3eeMassTool2Cfg(flags))
230 acc.addPublicTool(EGAM3eeMassTool2)
231 augmentationTools.append(EGAM3eeMassTool2)
232
233 EGAM3eeMassTool3 = acc.popToolsAndMerge(EGAM3eeMassTool3Cfg(flags))
234 acc.addPublicTool(EGAM3eeMassTool3)
235 augmentationTools.append(EGAM3eeMassTool3)
236
237
238
239
240 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
241 CaloDecoratorKernelCfg)
242 acc.merge(CaloDecoratorKernelCfg(flags))
243
244
245 thinningTools = []
246 streamName = kwargs["StreamName"]
247
248
249 if flags.Derivation.Egamma.doTrackThinning:
250 from DerivationFrameworkInDet.InDetToolsConfig import (
251 TrackParticleThinningCfg,
252 MuonTrackParticleThinningCfg,
253 TauTrackParticleThinningCfg,
254 )
255
256 TrackThinningKeepElectronTracks = True
257 TrackThinningKeepAllElectronTracks = False
258 TrackThinningKeepPhotonTracks = True
259 TrackThinningKeepAllPhotonTracks = True
260 TrackThinningKeepJetTracks = False
261 TrackThinningKeepMuonTracks = False
262 TrackThinningKeepTauTracks = False
263 TrackThinningKeepPVTracks = True
264
265
266 if TrackThinningKeepElectronTracks:
267 EGAM3ElectronTPThinningTool = (
268 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
269 name="EGAM3ElectronTPThinningTool",
270 StreamName=streamName,
271 SGKey="Electrons",
272 GSFTrackParticlesKey="GSFTrackParticles",
273 InDetTrackParticlesKey="InDetTrackParticles",
274 SelectionString="Electrons.pt > 0*GeV",
275 BestMatchOnly=True,
276 ConeSize=0.3,
277 )
278 )
279 acc.addPublicTool(EGAM3ElectronTPThinningTool)
280 thinningTools.append(EGAM3ElectronTPThinningTool)
281
282
283
284 if TrackThinningKeepAllElectronTracks:
285 EGAM3ElectronTPThinningTool2 = (
286 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
287 name="EGAM3ElectronTPThinningTool2",
288 StreamName=streamName,
289 SGKey="Electrons",
290 GSFTrackParticlesKey="GSFTrackParticles",
291 InDetTrackParticlesKey="InDetTrackParticles",
292 SelectionString="Electrons.pt > 4*GeV",
293 BestMatchOnly=False,
294 ConeSize=0.6,
295 )
296 )
297 acc.addPublicTool(EGAM3ElectronTPThinningTool2)
298 thinningTools.append(EGAM3ElectronTPThinningTool2)
299
300
301 if TrackThinningKeepPhotonTracks:
302 EGAM3PhotonTPThinningTool = (
303 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
304 name="EGAM3PhotonTPThinningTool",
305 StreamName=streamName,
306 SGKey="Photons",
307 GSFTrackParticlesKey="GSFTrackParticles",
308 InDetTrackParticlesKey="InDetTrackParticles",
309 GSFConversionVerticesKey="GSFConversionVertices",
310 SelectionString="Photons.pt > 0*GeV",
311 BestMatchOnly=True,
312 ConeSize=0.3,
313 )
314 )
315 acc.addPublicTool(EGAM3PhotonTPThinningTool)
316 thinningTools.append(EGAM3PhotonTPThinningTool)
317
318
319
320 if TrackThinningKeepAllPhotonTracks:
321 EGAM3PhotonTPThinningTool2 = (
322 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
323 name="EGAM3PhotonTPThinningTool2",
324 StreamName=streamName,
325 SGKey="Photons",
326 GSFTrackParticlesKey="GSFTrackParticles",
327 InDetTrackParticlesKey="InDetTrackParticles",
328 GSFConversionVerticesKey="GSFConversionVertices",
329 SelectionString="Photons.pt > 9.5*GeV",
330 BestMatchOnly=False,
331 ConeSize=0.6,
332 )
333 )
334 acc.addPublicTool(EGAM3PhotonTPThinningTool2)
335 thinningTools.append(EGAM3PhotonTPThinningTool2)
336
337
338 if TrackThinningKeepJetTracks:
339 EGAM3JetTPThinningTool = (
340 CompFactory.DerivationFramework.JetTrackParticleThinning(
341 name="EGAM3JetTPThinningTool",
342 StreamName=streamName,
343 JetKey="AntiKt4EMPFlowJets",
344 InDetTrackParticlesKey="InDetTrackParticles",
345 )
346 )
347 acc.addPublicTool(EGAM3JetTPThinningTool)
348 thinningTools.append(EGAM3JetTPThinningTool)
349
350
351 if TrackThinningKeepMuonTracks:
352 EGAM3MuonTPThinningTool = acc.getPrimaryAndMerge(
353 MuonTrackParticleThinningCfg(
354 flags,
355 name="EGAM3MuonTPThinningTool",
356 StreamName=streamName,
357 MuonKey="Muons",
358 InDetTrackParticlesKey="InDetTrackParticles",
359 )
360 )
361 thinningTools.append(EGAM3MuonTPThinningTool)
362
363
364 if TrackThinningKeepTauTracks:
365 EGAM3TauTPThinningTool = acc.getPrimaryAndMerge(
366 TauTrackParticleThinningCfg(
367 flags,
368 name="EGAM3TauTPThinningTool",
369 StreamName=streamName,
370 TauKey="TauJets",
371 ConeSize=0.6,
372 InDetTrackParticlesKey="InDetTrackParticles",
373 DoTauTracksThinning=True,
374 TauTracksKey="TauTracks",
375 )
376 )
377 thinningTools.append(EGAM3TauTPThinningTool)
378
379
380 thinning_expression = " && ".join(
381 [
382 "(InDetTrackParticles.DFCommonTightPrimary)",
383 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
384 "(InDetTrackParticles.pt>10*GeV)",
385 ]
386 )
387 if TrackThinningKeepPVTracks:
388 EGAM3TPThinningTool = acc.getPrimaryAndMerge(
389 TrackParticleThinningCfg(
390 flags,
391 name="EGAM3TPThinningTool",
392 StreamName=streamName,
393 SelectionString=thinning_expression,
394 InDetTrackParticlesKey="InDetTrackParticles",
395 )
396 )
397 thinningTools.append(EGAM3TPThinningTool)
398
399
400 skimmingTool = acc.popToolsAndMerge(EGAM3SkimmingToolCfg(flags))
401 acc.addPublicTool(skimmingTool)
402
403
404 acc.addEventAlgo(
405 CompFactory.DerivationFramework.DerivationKernel(
406 name,
407 SkimmingTools=[skimmingTool],
408 AugmentationTools=augmentationTools,
409 ThinningTools=thinningTools,
410 )
411 )
412
413 return acc
414
415