125     """Configure the derivation framework driving algorithm (kernel) 
  130     from DerivationFrameworkPhys.PhysCommonConfig 
import PhysCommonAugmentationsCfg
 
  134             flags, TriggerListsHelper=kwargs[
"TriggerListsHelper"]
 
  139     augmentationTools = []
 
  145     acc.addPublicTool(EGAM8ZeeMassTool)
 
  146     augmentationTools.append(EGAM8ZeeMassTool)
 
  149     acc.addPublicTool(EGAM8ZmueMassTool)
 
  150     augmentationTools.append(EGAM8ZmueMassTool)
 
  155     from DerivationFrameworkCalo.DerivationFrameworkCaloConfig 
import (
 
  156         CaloDecoratorKernelCfg)
 
  159     from DerivationFrameworkEGamma.EGammaToolsConfig 
import (
 
  160         EGammaCookieCutClusterToolCfg)
 
  161     cookieCutTool = acc.popToolsAndMerge(
 
  164                                       StoreInputMoments=
True,
 
  165                                       StoreCookedMoments=
True,
 
  167     acc.addPublicTool(cookieCutTool)
 
  168     augmentationTools.append(cookieCutTool)
 
  172     streamName = kwargs[
"StreamName"]
 
  175     if flags.Derivation.Egamma.doTrackThinning:
 
  176         from DerivationFrameworkInDet.InDetToolsConfig 
import (
 
  177             TrackParticleThinningCfg,
 
  178             MuonTrackParticleThinningCfg,
 
  179             TauTrackParticleThinningCfg,
 
  182         TrackThinningKeepElectronTracks = 
True 
  183         TrackThinningKeepPhotonTracks = 
True 
  184         TrackThinningKeepAllElectronTracks = 
False 
  185         TrackThinningKeepJetTracks = 
False 
  186         TrackThinningKeepMuonTracks = 
True 
  187         TrackThinningKeepTauTracks = 
False 
  188         TrackThinningKeepPVTracks = 
False 
  191         if TrackThinningKeepElectronTracks:
 
  192             EGAM8ElectronTPThinningTool = (
 
  193                 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
 
  194                     name=
"EGAM8ElectronTPThinningTool",
 
  195                     StreamName=streamName,
 
  197                     GSFTrackParticlesKey=
"GSFTrackParticles",
 
  198                     InDetTrackParticlesKey=
"InDetTrackParticles",
 
  199                     SelectionString=
"Electrons.pt > 0*GeV",
 
  204             acc.addPublicTool(EGAM8ElectronTPThinningTool)
 
  205             thinningTools.append(EGAM8ElectronTPThinningTool)
 
  209         if TrackThinningKeepAllElectronTracks:
 
  210             EGAM8ElectronTPThinningTool2 = (
 
  211                 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
 
  212                     name=
"EGAM8ElectronTPThinningTool2",
 
  213                     StreamName=streamName,
 
  215                     GSFTrackParticlesKey=
"GSFTrackParticles",
 
  216                     InDetTrackParticlesKey=
"InDetTrackParticles",
 
  217                     SelectionString=
"Electrons.pt > 4*GeV",
 
  222             acc.addPublicTool(EGAM8ElectronTPThinningTool2)
 
  223             thinningTools.append(EGAM8ElectronTPThinningTool2)
 
  226         if TrackThinningKeepPhotonTracks:
 
  227             EGAM8PhotonTPThinningTool = (
 
  228                 CompFactory.DerivationFramework.EgammaTrackParticleThinning(
 
  229                     name=
"EGAM8PhotonTPThinningTool",
 
  230                     StreamName=streamName,
 
  232                     GSFTrackParticlesKey=
"GSFTrackParticles",
 
  233                     InDetTrackParticlesKey=
"InDetTrackParticles",
 
  234                     GSFConversionVerticesKey=
"GSFConversionVertices",
 
  235                     SelectionString=
"Photons.pt > 0*GeV",
 
  240             acc.addPublicTool(EGAM8PhotonTPThinningTool)
 
  241             thinningTools.append(EGAM8PhotonTPThinningTool)
 
  244         if TrackThinningKeepJetTracks:
 
  245             EGAM8JetTPThinningTool = (
 
  246                 CompFactory.DerivationFramework.JetTrackParticleThinning(
 
  247                     name=
"EGAM8JetTPThinningTool",
 
  248                     StreamName=streamName,
 
  249                     JetKey=
"AntiKt4EMPFlowJets",
 
  250                     InDetTrackParticlesKey=
"InDetTrackParticles",
 
  253             acc.addPublicTool(EGAM8JetTPThinningTool)
 
  254             thinningTools.append(EGAM8JetTPThinningTool)
 
  257         if TrackThinningKeepMuonTracks:
 
  258             EGAM8MuonTPThinningTool = acc.getPrimaryAndMerge(
 
  261                     name=
"EGAM8MuonTPThinningTool",
 
  262                     StreamName=streamName,
 
  264                     InDetTrackParticlesKey=
"InDetTrackParticles",
 
  267             thinningTools.append(EGAM8MuonTPThinningTool)
 
  270         if TrackThinningKeepTauTracks:
 
  271             EGAM8TauTPThinningTool = acc.getPrimaryAndMerge(
 
  274                     name=
"EGAM8TauTPThinningTool",
 
  275                     StreamName=streamName,
 
  278                     InDetTrackParticlesKey=
"InDetTrackParticles",
 
  279                     DoTauTracksThinning=
True,
 
  280                     TauTracksKey=
"TauTracks",
 
  283             thinningTools.append(EGAM8TauTPThinningTool)
 
  286         thinning_expression = 
" && ".
join(
 
  288                 "(InDetTrackParticles.DFCommonTightPrimary)",
 
  289                 "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3.0*mm)",
 
  290                 "(InDetTrackParticles.pt>10*GeV)",
 
  293         if TrackThinningKeepPVTracks:
 
  294             EGAM8TPThinningTool = acc.getPrimaryAndMerge(
 
  297                     name=
"EGAM8TPThinningTool",
 
  298                     StreamName=streamName,
 
  299                     SelectionString=thinning_expression,
 
  300                     InDetTrackParticlesKey=
"InDetTrackParticles",
 
  303             thinningTools.append(EGAM8TPThinningTool)
 
  308         truth_cond_WZH = 
" && ".
join(
 
  309             [
"(abs(TruthParticles.pdgId) >= 23)", 
"(abs(TruthParticles.pdgId) <= 25)"]
 
  312         truth_cond_lep = 
" && ".
join(
 
  313             [
"(abs(TruthParticles.pdgId) >= 11)", 
"(abs(TruthParticles.pdgId) <= 16)"]
 
  316         truth_cond_top = 
"(abs(TruthParticles.pdgId) ==  6)" 
  318         truth_cond_gam = 
" && ".
join(
 
  319             [
"(TruthParticles.isPhoton)", 
"(TruthParticles.pt > 1*GeV)"]
 
  322         truth_cond_finalState = 
" && ".
join(
 
  323             [
"(TruthParticles.isGenStable)", 
"(!TruthParticles.isSimulationParticle)"]
 
  339             + truth_cond_finalState
 
  342         print(
"EGAM8 truth thinning expression: ", truth_expression)
 
  344         EGAM8TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
 
  345             name=
"EGAM8TruthThinningTool",
 
  346             StreamName=streamName,
 
  347             ParticleSelectionString=truth_expression,
 
  348             PreserveDescendants=
False,
 
  349             PreserveGeneratorDescendants=
True,
 
  350             PreserveAncestors=
True,
 
  352         acc.addPublicTool(EGAM8TruthThinningTool)
 
  353         thinningTools.append(EGAM8TruthThinningTool)
 
  357     acc.addPublicTool(skimmingTool)
 
  361         CompFactory.DerivationFramework.DerivationKernel(
 
  363             SkimmingTools=[skimmingTool],
 
  364             AugmentationTools=augmentationTools,
 
  365             ThinningTools=thinningTools,