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