209def EGAM1KernelCfg(flags, name="EGAM1Kernel", **kwargs):
210 """Configure the derivation framework driving algorithm (kernel)
211 for EGAM1"""
212 acc = ComponentAccumulator()
213
214
215 from JetRecConfig.StandardSmallRJets import AntiKt4PV0Track
216 from JetRecConfig.JetRecConfig import JetRecCfg
217
218 jetList = [AntiKt4PV0Track]
219 for jd in jetList:
220 acc.merge(JetRecCfg(flags, jd))
221
222
223 from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
224
225 acc.merge(
226 PhysCommonAugmentationsCfg(
227 flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
228 )
229 )
230
231
232 augmentationTools = []
233
234
235
236
237 EGAM1ZeeMassTool1 = acc.popToolsAndMerge(EGAM1ZeeMassTool1Cfg(flags))
238 acc.addPublicTool(EGAM1ZeeMassTool1)
239 augmentationTools.append(EGAM1ZeeMassTool1)
240
241 EGAM1ZeeMassTool2 = acc.popToolsAndMerge(EGAM1ZeeMassTool2Cfg(flags))
242 acc.addPublicTool(EGAM1ZeeMassTool2)
243 augmentationTools.append(EGAM1ZeeMassTool2)
244
245 EGAM1ZeeMassTool3 = acc.popToolsAndMerge(EGAM1ZeeMassTool3Cfg(flags))
246 acc.addPublicTool(EGAM1ZeeMassTool3)
247 augmentationTools.append(EGAM1ZeeMassTool3)
248
249 EGAM1ZegMassTool = acc.popToolsAndMerge(EGAM1ZegMassToolCfg(flags))
250 acc.addPublicTool(EGAM1ZegMassTool)
251 augmentationTools.append(EGAM1ZegMassTool)
252
253
254
255
256 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
257 CaloDecoratorKernelCfg)
258 acc.merge(CaloDecoratorKernelCfg(flags))
259
260
261 thinningTools = []
262 streamName = kwargs["StreamName"]
263
264
265 if flags.Derivation.Egamma.doTrackThinning:
266 from DerivationFrameworkInDet.InDetToolsConfig import (
267 TrackParticleThinningCfg,
268 MuonTrackParticleThinningCfg,
269 TauTrackParticleThinningCfg,
270 )
271
272 TrackThinningKeepElectronTracks = True
273 TrackThinningKeepPhotonTracks = True
274 TrackThinningKeepAllElectronTracks = True
275 TrackThinningKeepJetTracks = False
276 TrackThinningKeepMuonTracks = False
277 TrackThinningKeepTauTracks = False
278 TrackThinningKeepPVTracks = True
279
280
281 if TrackThinningKeepElectronTracks:
282 EGAM1ElectronTPThinningTool = (
283 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
284 name="EGAM1ElectronTPThinningTool",
285 StreamName=streamName,
286 SGKey="Electrons",
287 GSFTrackParticlesKey="GSFTrackParticles",
288 InDetTrackParticlesKey="InDetTrackParticles",
289 SelectionString="Electrons.pt > 0*GeV",
290 BestMatchOnly=True,
291 ConeSize=0.3,
292 )
293 )
294 acc.addPublicTool(EGAM1ElectronTPThinningTool)
295 thinningTools.append(EGAM1ElectronTPThinningTool)
296
297
298
299 if TrackThinningKeepAllElectronTracks:
300 EGAM1ElectronTPThinningTool2 = (
301 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
302 name="EGAM1ElectronTPThinningTool2",
303 StreamName=streamName,
304 SGKey="Electrons",
305 GSFTrackParticlesKey="GSFTrackParticles",
306 InDetTrackParticlesKey="InDetTrackParticles",
307 SelectionString="Electrons.pt > 4*GeV",
308 BestMatchOnly=False,
309 ConeSize=0.6,
310 )
311 )
312 acc.addPublicTool(EGAM1ElectronTPThinningTool2)
313 thinningTools.append(EGAM1ElectronTPThinningTool2)
314
315
316 if TrackThinningKeepPhotonTracks:
317 EGAM1PhotonTPThinningTool = (
318 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
319 name="EGAM1PhotonTPThinningTool",
320 StreamName=streamName,
321 SGKey="Photons",
322 GSFTrackParticlesKey="GSFTrackParticles",
323 InDetTrackParticlesKey="InDetTrackParticles",
324 GSFConversionVerticesKey="GSFConversionVertices",
325 SelectionString="Photons.pt > 0*GeV",
326 BestMatchOnly=True,
327 ConeSize=0.3,
328 )
329 )
330 acc.addPublicTool(EGAM1PhotonTPThinningTool)
331 thinningTools.append(EGAM1PhotonTPThinningTool)
332
333
334 if TrackThinningKeepJetTracks:
335 EGAM1JetTPThinningTool = (
336 CompFactory.DerivationFramework.JetTrackParticleThinning(
337 name="EGAM1JetTPThinningTool",
338 StreamName=streamName,
339 JetKey="AntiKt4EMPFlowJets",
340 InDetTrackParticlesKey="InDetTrackParticles",
341 )
342 )
343 acc.addPublicTool(EGAM1JetTPThinningTool)
344 thinningTools.append(EGAM1JetTPThinningTool)
345
346
347 if TrackThinningKeepMuonTracks:
348 EGAM1MuonTPThinningTool = acc.getPrimaryAndMerge(
349 MuonTrackParticleThinningCfg(
350 flags,
351 name="EGAM1MuonTPThinningTool",
352 StreamName=streamName,
353 MuonKey="Muons",
354 InDetTrackParticlesKey="InDetTrackParticles",
355 )
356 )
357 thinningTools.append(EGAM1MuonTPThinningTool)
358
359
360 if TrackThinningKeepTauTracks:
361 EGAM1TauTPThinningTool = acc.getPrimaryAndMerge(
362 TauTrackParticleThinningCfg(
363 flags,
364 name="EGAM1TauTPThinningTool",
365 StreamName=streamName,
366 TauKey="TauJets",
367 ConeSize=0.6,
368 InDetTrackParticlesKey="InDetTrackParticles",
369 DoTauTracksThinning=True,
370 TauTracksKey="TauTracks",
371 )
372 )
373 thinningTools.append(EGAM1TauTPThinningTool)
374
375
376 thinning_expression = " && ".join(
377 [
378 "(InDetTrackParticles.DFCommonTightPrimary)",
379 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
380 "(InDetTrackParticles.pt>10*GeV)",
381 ]
382 )
383 if TrackThinningKeepPVTracks:
384 EGAM1TPThinningTool = acc.getPrimaryAndMerge(
385 TrackParticleThinningCfg(
386 flags,
387 name="EGAM1TPThinningTool",
388 StreamName=streamName,
389 SelectionString=thinning_expression,
390 InDetTrackParticlesKey="InDetTrackParticles",
391 )
392 )
393 thinningTools.append(EGAM1TPThinningTool)
394
395
396 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
397 CaloClusterThinningCfg,
398 )
399
400 EGAM1CCTCThinningTool = acc.getPrimaryAndMerge(
401 CaloClusterThinningCfg(
402 flags,
403 name="EGAM1CCTCThinningTool",
404 StreamName=streamName,
405 SGKey="Electrons",
406 SelectionString="Electrons.pt>4*GeV",
407 TopoClCollectionSGKey="CaloCalTopoClusters",
408 ConeSize=0.5,
409 )
410 )
411 thinningTools.append(EGAM1CCTCThinningTool)
412
413
414 if flags.Input.isMC:
415
416 truth_cond_WZH = " && ".join(
417 ["(abs(TruthParticles.pdgId) >= 23)", "(abs(TruthParticles.pdgId) <= 25)"]
418 )
419
420 truth_cond_lep = " && ".join(
421 ["(abs(TruthParticles.pdgId) >= 11)", "(abs(TruthParticles.pdgId) <= 16)"]
422 )
423
424 truth_cond_top = "(abs(TruthParticles.pdgId) == 6)"
425
426 truth_cond_gam = " && ".join(
427 ["(abs(TruthParticles.pdgId) == 22)", "(TruthParticles.pt > 1*GeV)"]
428 )
429
430 truth_cond_finalState = "(TruthParticles.isGenStable)"
431 truth_expression = (
432 "( "
433 + truth_cond_WZH
434 + " ) || "
435 + "( "
436 + truth_cond_lep
437 + " ) || "
438 + "( "
439 + truth_cond_top
440 + " ) || "
441 + "( "
442 + truth_cond_gam
443 + " ) || "
444 + "( "
445 + truth_cond_finalState
446 + " )"
447 )
448 print(
"EGAM1 truth thinning expression: ", truth_expression)
449
450 EGAM1TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
451 name="EGAM1TruthThinningTool",
452 StreamName=streamName,
453 ParticleSelectionString=truth_expression,
454 PreserveDescendants=False,
455 PreserveGeneratorDescendants=True,
456 PreserveAncestors=True,
457 )
458 acc.addPublicTool(EGAM1TruthThinningTool)
459 thinningTools.append(EGAM1TruthThinningTool)
460
461
462 skimmingTool = acc.popToolsAndMerge(EGAM1SkimmingToolCfg(flags))
463 acc.addPublicTool(skimmingTool)
464
465
466 acc.addEventAlgo(
467 CompFactory.DerivationFramework.DerivationKernel(
468 name,
469 SkimmingTools=[skimmingTool],
470 AugmentationTools=augmentationTools,
471 ThinningTools=thinningTools,
472 )
473 )
474
475 return acc
476
477