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